diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 26ab7bf..a5fea40 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -13,15 +13,7 @@ jobs:
- uses: actions/checkout@v1
- name: Install the SFML.
run: sudo apt-get update &&
- sudo apt-get install --yes libsfml-dev
- - name: Install TGUI.
- run: |
- git clone https://github.com/texus/TGUI -b 0.8 /tmp/tgui
- cd /tmp/tgui
- mkdir build
- cd build
- cmake ..
- make -j 4 && sudo make install
+ sudo apt-get install --yes libsfml-dev qt5
- name: Build Makefile with CMake
run: mkdir -p build && cd build && cmake ..
- name: Build with Makefile
diff --git a/.github/workflows/buildwin.yml b/.github/workflows/buildwin.yml
index 2ed2f08..7943386 100644
--- a/.github/workflows/buildwin.yml
+++ b/.github/workflows/buildwin.yml
@@ -16,12 +16,6 @@ jobs:
Invoke-WebRequest -Uri https://www.sfml-dev.org/files/SFML-2.5.1-windows-gcc-7.3.0-mingw-64-bit.zip -OutFile sfml.zip
Expand-Archive sfml.zip -DestinationPath . -Force
Move-Item -Path SFML-2.5.1 -Destination build
- - name: Install TGUI.
- run: |
- Invoke-WebRequest -Uri https://github.com/texus/TGUI/releases/download/v0.8.6/TGUI-0.8.6-mingw-7.3.0-64bit-for-SFML-2.5.1.zip -OutFile tgui.zip
- Expand-Archive tgui.zip -DestinationPath . -Force
- Move-Item -Path TGUI-0.8/lib/lib* -Destination build/lib
- Move-Item -Path TGUI-0.8/include/* -Destination build/include
- name: Build Makefile with CMake
run: |
Set-Location build
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ded7b13..d0ef7b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,6 +75,10 @@ if ("${GITBUILD}" STREQUAL true)
message("Git build is true")
endif ()
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
# make app
add_executable(ComSquare
main.cpp
@@ -125,7 +129,8 @@ add_executable(ComSquare
sources/Renderer/QtRenderer/QtSFML.hpp
sources/Renderer/QtRenderer/QtWidgetSFML.cpp
sources/Renderer/QtRenderer/QtWidgetSFML.hpp
-)
+ resources/debugger/cpu.ui
+ sources/Renderer/QtRenderer/QtWindow.cpp sources/Renderer/QtRenderer/QtWindow.hpp)
target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED)
diff --git a/Doxyfile b/Doxyfile
index be87542..fe9687f 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -47,8 +47,8 @@ PROJECT_NUMBER =
PROJECT_BRIEF =
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
-# in the documentation. The maximum height of the logo should not exceed 55
-# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# in the documentation. The maximum _height of the logo should not exceed 55
+# pixels and the maximum _width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory.
PROJECT_LOGO =
@@ -1528,7 +1528,7 @@ GENERATE_TREEVIEW = NO
ENUM_VALUES_PER_LINE = 4
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
-# to set the initial width (in pixels) of the frame in which the tree is shown.
+# to set the initial _width (in pixels) of the frame in which the tree is shown.
# Minimum value: 0, maximum value: 1500, default value: 250.
# This tag requires that the tag GENERATE_HTML is set to YES.
diff --git a/README.md b/README.md
index 6f15fed..3cb6640 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-
+
diff --git a/main.cpp b/main.cpp
index 98d1320..79d5089 100644
--- a/main.cpp
+++ b/main.cpp
@@ -19,9 +19,9 @@ int main(int argc, char **argv)
return 1;
}
QApplication app(argc, argv);
- Renderer::QtSFML renderer(app, 600, 800);
+ Renderer::QtSFML renderer(600, 800);
SNES snes(std::make_shared(), argv[1], renderer);
renderer.createWindow(snes, 60);
- //snes.enableCPUDebugging();
+ snes.enableCPUDebugging();
return QApplication::exec();
}
\ No newline at end of file
diff --git a/resources/Black.svg b/resources/Black.svg
index ddd5d49..ce9b135 100644
--- a/resources/Black.svg
+++ b/resources/Black.svg
@@ -1 +1 @@
-
+
diff --git a/resources/White.svg b/resources/White.svg
index 8a853b4..e68d659 100644
--- a/resources/White.svg
+++ b/resources/White.svg
@@ -1 +1 @@
-
+
diff --git a/resources/debugger/cpu.ui b/resources/debugger/cpu.ui
new file mode 100644
index 0000000..097e209
--- /dev/null
+++ b/resources/debugger/cpu.ui
@@ -0,0 +1,45 @@
+
+
+ MainWindow
+
+
+
+ 0
+ 0
+ 800
+ 600
+
+
+
+ MainWindow
+
+
+
+
+
+ 280
+ 120
+ 231
+ 171
+
+
+
+ CPU DEBUGGER*
+
+
+
+
+
+
+ 0
+ 0
+ 800
+ 28
+
+
+
+
+
+
+
+
diff --git a/sources/APU/DSP/DSP.hpp b/sources/APU/DSP/DSP.hpp
index 07f2b8f..838db19 100644
--- a/sources/APU/DSP/DSP.hpp
+++ b/sources/APU/DSP/DSP.hpp
@@ -96,7 +96,7 @@ namespace ComSquare::APU::DSP
uint8_t gain;
//! @brief Envelope value register
uint8_t envx;
- //! @brief Wave height register
+ //! @brief Wave _height register
uint8_t outx;
//! @brief Echo FIR filter coefficients
diff --git a/sources/CPU/CPU.hpp b/sources/CPU/CPU.hpp
index 64cb902..3d42f1e 100644
--- a/sources/CPU/CPU.hpp
+++ b/sources/CPU/CPU.hpp
@@ -84,9 +84,9 @@ namespace ComSquare::CPU
bool i : 1;
//! @brief The Decimal mode flag
bool d : 1;
- //! @brief The indeX register width flag (in native mode only) OR the Break flag (in emulation mode only)
+ //! @brief The indeX register _width flag (in native mode only) OR the Break flag (in emulation mode only)
bool x_b : 1;
- //! @brief The accumulator and Memory width flag (in native mode only)
+ //! @brief The accumulator and Memory _width flag (in native mode only)
bool m : 1;
//! @brief The oVerflow flag
bool v : 1;
diff --git a/sources/Debugger/DebugCpu.cpp b/sources/Debugger/DebugCpu.cpp
index df3ba3a..360c2cc 100644
--- a/sources/Debugger/DebugCpu.cpp
+++ b/sources/Debugger/DebugCpu.cpp
@@ -10,18 +10,19 @@ namespace ComSquare::Debugger
CPUDebug::CPUDebug(ComSquare::CPU::CPU &basicCPU, SNES &snes)
: CPU::CPU(basicCPU), _renderer(600, 1000), _snes(snes)
{
- this->_renderer.setWindowName("CPU's Debugger");
+ std::string name = "CPU's Debugger";
+ this->_renderer.setWindowName(name);
}
unsigned CPUDebug::update()
{
- if (this->_renderer.shouldExit) {
- this->_snes.disableCPUDebugging ();
- return 0;
- }
+// if (this->_renderer.shouldExit) {
+// this->_snes.disableCPUDebugging ();
+// return 0;
+// }
- this->_renderer.drawScreen();
- this->_renderer.getEvents();
+// this->_renderer.drawScreen();
+// this->_renderer.getEvents();
if (this->_isPaused)
return 0xFF;
return CPU::update();
diff --git a/sources/Debugger/DebugCpu.hpp b/sources/Debugger/DebugCpu.hpp
index 44da0b6..a9baf4e 100644
--- a/sources/Debugger/DebugCpu.hpp
+++ b/sources/Debugger/DebugCpu.hpp
@@ -8,6 +8,7 @@
#include "../CPU/CPU.hpp"
#include "../Renderer/SFRenderer.hpp"
#include "../SNES.hpp"
+#include "../Renderer/QtRenderer/QtWindow.hpp"
namespace ComSquare::Debugger
{
@@ -15,7 +16,7 @@ namespace ComSquare::Debugger
class CPUDebug : public CPU::CPU {
private:
//! @brief The debug window.
- Renderer::SFRenderer _renderer;
+ Renderer::QtWindow _renderer;
//! @brief If this is set to true, the execution of the CPU will be paused.
bool _isPaused = true;
//! @brief A reference to the snes (to disable the debugger).
diff --git a/sources/PPU/PPU.hpp b/sources/PPU/PPU.hpp
index 7cda75a..0836011 100644
--- a/sources/PPU/PPU.hpp
+++ b/sources/PPU/PPU.hpp
@@ -163,8 +163,8 @@ namespace ComSquare::PPU
};
struct {
- unsigned int height;
- unsigned int width;
+ unsigned int _height;
+ unsigned int _width;
bool verticalMirroring;
bool horizontalMirroring;
int verticalOffset;
diff --git a/sources/Renderer/IRenderer.hpp b/sources/Renderer/IRenderer.hpp
index aceccdb..fd073f9 100644
--- a/sources/Renderer/IRenderer.hpp
+++ b/sources/Renderer/IRenderer.hpp
@@ -15,7 +15,7 @@ namespace ComSquare
class IRenderer {
public:
//! @brief Set a new name to the window, if there is already a name it will be overwrite
- virtual void setWindowName(std::string) = 0;
+ virtual void setWindowName(std::string &) = 0;
//! @brief Render the buffer to the window
virtual void drawScreen() = 0;
diff --git a/sources/Renderer/NoRenderer.cpp b/sources/Renderer/NoRenderer.cpp
index 7522d08..35fe608 100644
--- a/sources/Renderer/NoRenderer.cpp
+++ b/sources/Renderer/NoRenderer.cpp
@@ -6,7 +6,7 @@
namespace ComSquare::Renderer
{
- void NoRenderer::setWindowName(std::string newWindowName)
+ void NoRenderer::setWindowName(std::string &newWindowName)
{
(void)newWindowName;
}
diff --git a/sources/Renderer/NoRenderer.hpp b/sources/Renderer/NoRenderer.hpp
index c4cb21d..9abf3f7 100644
--- a/sources/Renderer/NoRenderer.hpp
+++ b/sources/Renderer/NoRenderer.hpp
@@ -14,7 +14,7 @@ namespace ComSquare::Renderer
public:
//! @brief Set a new name to the window, if there is already a name it will be overwrite.
//! @param newWindowName new title for the window.
- void setWindowName(std::string newWindowName) override;
+ void setWindowName(std::string &newWindowName) override;
//! @brief Update the screen by printing the buffer.
void drawScreen() override;
//! @brief Add a pixel to the buffer to the coordinates x, y with the color rgba.
@@ -28,8 +28,8 @@ namespace ComSquare::Renderer
//! @param maxFPS The number of FPS you aim to run on.
void createWindow(SNES &snes, int maxFPS) override;
//! @brief Constructor that return the window component of the SFML.
- //! @param height height of the window.
- //! @param width width of the window.
+ //! @param height _height of the window.
+ //! @param width _width of the window.
//! @param maxFPS the number of maximum FPS for the window.
NoRenderer(unsigned int height, unsigned int width, int maxFPS);
NoRenderer(const NoRenderer &) = default;
diff --git a/sources/Renderer/QtRenderer/QtSFML.cpp b/sources/Renderer/QtRenderer/QtSFML.cpp
index 7835a5a..5229e0c 100644
--- a/sources/Renderer/QtRenderer/QtSFML.cpp
+++ b/sources/Renderer/QtRenderer/QtSFML.cpp
@@ -15,24 +15,17 @@
namespace ComSquare::Renderer
{
- QtSFML::QtSFML(QApplication &app, unsigned int h, unsigned int w) :
- _app(app), _sfWidget(nullptr), width(w), height(h)
+ QtSFML::QtSFML(unsigned int h, unsigned int w) :
+ QtWindow(h, w), _sfWidget(nullptr)
{ }
void QtSFML::createWindow(SNES &snes, int maxFPS)
{
- this->frame = new QFrame();
this->setWindowName(snes.cartridge->header.gameName);
- this->frame->show();
- this->_sfWidget = new QtFullSFML(snes, frame, QPoint(0, 0), QSize(this->width, this->height), maxFPS);
+ this->_sfWidget = std::make_unique(snes, &_frame, QPoint(0, 0), QSize(this->_width, this->_height), maxFPS);
this->_sfWidget->show();
}
- void QtSFML::setWindowName(std::string newWindowName)
- {
- this->frame->setWindowTitle((newWindowName + " - ComSquare").c_str());
- }
-
void QtSFML::putPixel(unsigned y, unsigned x, uint32_t rgba)
{
this->_sfWidget->putPixel(y, x, rgba);
@@ -40,6 +33,11 @@ namespace ComSquare::Renderer
void QtSFML::drawScreen() { }
+ void QtSFML::setWindowName(std::string &newWindowName)
+ {
+ QtWindow::setWindowName(newWindowName);
+ }
+
QtFullSFML::QtFullSFML(SNES &snes, QWidget *parent, const QPoint &position, const QSize &size, int frameRate) :
QtWidgetSFML(parent, position, size, frameRate),
_snes(snes)
diff --git a/sources/Renderer/QtRenderer/QtSFML.hpp b/sources/Renderer/QtRenderer/QtSFML.hpp
index 9e5a333..d802a31 100644
--- a/sources/Renderer/QtRenderer/QtSFML.hpp
+++ b/sources/Renderer/QtRenderer/QtSFML.hpp
@@ -11,6 +11,7 @@
#include "../IRenderer.hpp"
#include "../SFRenderer.hpp"
#include "QtWidgetSFML.hpp"
+#include "QtWindow.hpp"
namespace ComSquare::Renderer
{
@@ -28,25 +29,14 @@ namespace ComSquare::Renderer
};
//! @brief A SFML renderer inside a QT window.
- class QtSFML : public IRenderer {
+ class QtSFML : public IRenderer, public QtWindow {
private:
- //! @brief The QT app instance.
- QApplication &_app;
- //! @brief The SFML frame.
- QFrame *frame{};
//! @brief The SFML widget.
- QtFullSFML *_sfWidget{};
- //! @brief The width of the window.
- unsigned int width;
- //! @brief The height of the window.
- unsigned int height;
+ std::unique_ptr _sfWidget = nullptr;
public:
//! @brief Use this function to create the window.
//! @param maxFPS The number of FPS you aim to run on.
void createWindow(SNES &snes, int maxFPS) override;
- //! @brief Set a new name to the window, if there is already a name it will be overwrite.
- //! @param newWindowName new title for the window.
- void setWindowName(std::string newWindowName) override;
//! @brief Add a pixel to the buffer to the coordinates x, y with the color rgba.
//! @param X horizontal index.
//! @param Y vertical index.
@@ -54,10 +44,13 @@ namespace ComSquare::Renderer
void putPixel(unsigned y, unsigned x, uint32_t rgba) override;
//! @brief This function doesn't do anything because QT internally handle drawing to the screen.
void drawScreen() override;
+ //! @brief Set a new name to the window, if there is already a name it will be overwrite.
+ //! @param newWindowName new title for the window.
+ void setWindowName(std::string &newWindowName) override;
//! @brief Constructor that return a SFML renderer inside a QT window.
- //! @param height height of the window.
- //! @param width width of the window.
- QtSFML(QApplication &app, unsigned int height, unsigned int width);
+ //! @param height _height of the window.
+ //! @param width _width of the window.
+ QtSFML(unsigned int height, unsigned int width);
QtSFML(const QtSFML &) = delete;
QtSFML &operator=(const QtSFML &) = delete;
~QtSFML() = default;
diff --git a/sources/Renderer/QtRenderer/QtWindow.cpp b/sources/Renderer/QtRenderer/QtWindow.cpp
new file mode 100644
index 0000000..7268754
--- /dev/null
+++ b/sources/Renderer/QtRenderer/QtWindow.cpp
@@ -0,0 +1,19 @@
+//
+// Created by anonymus-raccoon on 2/16/20.
+//
+
+#include "QtWindow.hpp"
+
+namespace ComSquare::Renderer
+{
+ QtWindow::QtWindow(unsigned int height, unsigned int width) :
+ _frame(), _width(width), _height(height)
+ {
+ this->_frame.show();
+ }
+
+ void QtWindow::setWindowName(std::string &newWindowName)
+ {
+ this->_frame.setWindowTitle((newWindowName + " - ComSquare").c_str());
+ }
+}
\ No newline at end of file
diff --git a/sources/Renderer/QtRenderer/QtWindow.hpp b/sources/Renderer/QtRenderer/QtWindow.hpp
new file mode 100644
index 0000000..e53f693
--- /dev/null
+++ b/sources/Renderer/QtRenderer/QtWindow.hpp
@@ -0,0 +1,35 @@
+//
+// Created by anonymus-raccoon on 2/16/20.
+//
+
+#ifndef COMSQUARE_QTWINDOW_HPP
+#define COMSQUARE_QTWINDOW_HPP
+
+#include
+#include
+
+namespace ComSquare::Renderer
+{
+ class QtWindow {
+ protected:
+ //! @brief The SFML frame.
+ QFrame _frame;
+ //! @brief The _width of the window.
+ unsigned int _width;
+ //! @brief The _height of the window.
+ unsigned int _height;
+ public:
+ //! @brief Set a new name to the window, if there is already a name it will be overwrite.
+ //! @param newWindowName new title for the window.
+ void setWindowName(std::string &newWindowName);
+ //! @brief Constructor that return a SFML renderer inside a QT window.
+ //! @param height _height of the window.
+ //! @param width _width of the window.
+ QtWindow(unsigned int height, unsigned int width);
+ QtWindow(const QtWindow &) = delete;
+ QtWindow &operator=(const QtWindow &) = delete;
+ ~QtWindow() = default;
+ };
+}
+
+#endif //COMSQUARE_QTWINDOW_HPP
diff --git a/sources/Renderer/SFRenderer.cpp b/sources/Renderer/SFRenderer.cpp
index 16dab71..90149d6 100644
--- a/sources/Renderer/SFRenderer.cpp
+++ b/sources/Renderer/SFRenderer.cpp
@@ -40,7 +40,7 @@ namespace ComSquare::Renderer
delete [] this->_pixelBuffer;
}
- void SFRenderer::setWindowName(std::string newWindowName)
+ void SFRenderer::setWindowName(std::string &newWindowName)
{
this->_window.setTitle(newWindowName + " - ComSquare");
}
diff --git a/sources/Renderer/SFRenderer.hpp b/sources/Renderer/SFRenderer.hpp
index 6a9f187..a81712a 100644
--- a/sources/Renderer/SFRenderer.hpp
+++ b/sources/Renderer/SFRenderer.hpp
@@ -11,7 +11,7 @@
#include
#include
#include
-#include
+#include
namespace ComSquare::Renderer
{
@@ -28,7 +28,7 @@ namespace ComSquare::Renderer
protected:
//! @brief The Renderer for the window.
sf::RenderWindow _window;
- //! @brief Video Mode containing the height and width of the window.
+ //! @brief Video Mode containing the _height and _width of the window.
sf::VideoMode _videoMode;
//! @brief The image that contain all of the pixels
sf::Color *_pixelBuffer;
@@ -41,7 +41,7 @@ namespace ComSquare::Renderer
bool shouldExit = false;
//! @brief Set a new name to the window, if there is already a name it will be overwrite.
//! @param newWindowName new title for the window.
- void setWindowName(std::string newWindowName) override;
+ void setWindowName(std::string &newWindowName) override;
//! @brief Update the screen by printing the buffer.
void drawScreen() override;
//! @brief Add a pixel to the buffer to the coordinates x, y with the color rgba.
@@ -56,8 +56,8 @@ namespace ComSquare::Renderer
//! @param maxFPS The number of FPS you aim to run on.
void createWindow(SNES &snes, int maxFPS) override;
//! @brief Constructor that return the window component of the SFML.
- //! @param height height of the window.
- //! @param width width of the window.
+ //! @param height _height of the window.
+ //! @param width _width of the window.
SFRenderer(unsigned int height, unsigned int width);
SFRenderer(const SFRenderer &) = delete;
SFRenderer &operator=(const SFRenderer &) = delete;
diff --git a/sources/SNES.cpp b/sources/SNES.cpp
index 33b8aa9..9ef413c 100644
--- a/sources/SNES.cpp
+++ b/sources/SNES.cpp
@@ -24,6 +24,8 @@ namespace ComSquare
{
#ifdef DEBUGGER_ENABLED
this->cpu = std::make_shared(*this->cpu, *this);
+ #else
+ std::cerr << "Debugging features are not enabled. You can't enable the debugger." << std::endl;
#endif
}