diff --git a/CMakeLists.txt b/CMakeLists.txt index d0ef7b1..54faec4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,8 +129,10 @@ 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) + Ui/cpu.ui + sources/Renderer/QtRenderer/QtWindow.cpp + sources/Renderer/QtRenderer/QtWindow.hpp +) target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED) diff --git a/Ui/cpu.ui b/Ui/cpu.ui new file mode 100644 index 0000000..19a841e --- /dev/null +++ b/Ui/cpu.ui @@ -0,0 +1,32 @@ + + + CPU + + + + 0 + 0 + 584 + 407 + + + + CPU + + + + + 270 + 160 + 67 + 17 + + + + CPU + + + + + + diff --git a/resources/debugger/cpu.ui b/resources/debugger/cpu.ui deleted file mode 100644 index 097e209..0000000 --- a/resources/debugger/cpu.ui +++ /dev/null @@ -1,45 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 280 - 120 - 231 - 171 - - - - CPU DEBUGGER* - - - - - - - 0 - 0 - 800 - 28 - - - - - - - - diff --git a/sources/Debugger/DebugCpu.cpp b/sources/Debugger/DebugCpu.cpp index 360c2cc..83a7610 100644 --- a/sources/Debugger/DebugCpu.cpp +++ b/sources/Debugger/DebugCpu.cpp @@ -8,18 +8,18 @@ namespace ComSquare::Debugger { CPUDebug::CPUDebug(ComSquare::CPU::CPU &basicCPU, SNES &snes) - : CPU::CPU(basicCPU), _renderer(600, 1000), _snes(snes) + : CPU::CPU(basicCPU), _snes(snes) { - std::string name = "CPU's Debugger"; - this->_renderer.setWindowName(name); + this->_ui.setupUi(&this->_widget); + this->_widget.show(); } unsigned CPUDebug::update() { -// if (this->_renderer.shouldExit) { -// this->_snes.disableCPUDebugging (); -// return 0; -// } + if (!this->_widget.isVisible()) { + this->_snes.disableCPUDebugging(); + return 0; + } // this->_renderer.drawScreen(); // this->_renderer.getEvents(); diff --git a/sources/Debugger/DebugCpu.hpp b/sources/Debugger/DebugCpu.hpp index a9baf4e..e5552a2 100644 --- a/sources/Debugger/DebugCpu.hpp +++ b/sources/Debugger/DebugCpu.hpp @@ -9,14 +9,17 @@ #include "../Renderer/SFRenderer.hpp" #include "../SNES.hpp" #include "../Renderer/QtRenderer/QtWindow.hpp" +#include "../../Ui/ui_cpu.h" namespace ComSquare::Debugger { //! @brief A custom CPU with a window that show it's registers and the disassembly. class CPUDebug : public CPU::CPU { private: - //! @brief The debug window. - Renderer::QtWindow _renderer; + //! @brief A widget that contain the whole UI. + QWidget _widget; + //! @brief The ui that reside inside the window. + Ui::CPU _ui; //! @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/Renderer/QtRenderer/QtWindow.hpp b/sources/Renderer/QtRenderer/QtWindow.hpp index e53f693..2e726d7 100644 --- a/sources/Renderer/QtRenderer/QtWindow.hpp +++ b/sources/Renderer/QtRenderer/QtWindow.hpp @@ -5,7 +5,7 @@ #ifndef COMSQUARE_QTWINDOW_HPP #define COMSQUARE_QTWINDOW_HPP -#include + #include namespace ComSquare::Renderer diff --git a/sources/SNES.cpp b/sources/SNES.cpp index 9ef413c..8f70c74 100644 --- a/sources/SNES.cpp +++ b/sources/SNES.cpp @@ -5,7 +5,9 @@ #include #include #include "SNES.hpp" -#include "Debugger/DebugCpu.hpp" +#ifdef DEBUGGER_ENABLED + #include "Debugger/DebugCpu.hpp" +#endif namespace ComSquare { @@ -31,6 +33,7 @@ namespace ComSquare void SNES::disableCPUDebugging() { + std::cout << "Disabling CPU debugger." << std::endl; this->cpu = std::make_shared(*this->cpu); }