Creating a base window

This commit is contained in:
AnonymusRaccoon
2020-02-14 17:55:53 +01:00
parent c8e6c0d4f9
commit 4f150441a3
8 changed files with 86 additions and 6 deletions
+30
View File
@@ -0,0 +1,30 @@
//
// Created by anonymus-raccoon on 2/14/20.
//
#include <iostream>
#include "DebugCpu.hpp"
namespace ComSquare::Debugger
{
CPUDebug::CPUDebug(ComSquare::CPU::CPU &basicCPU, SNES &snes)
: CPU::CPU(basicCPU), _renderer(600, 1000, 60), _snes(snes)
{
this->_renderer.setWindowName("CPU's Debugger");
std::cout << "CPU debugging enabled!" << std::endl;
}
unsigned CPUDebug::update()
{
if (this->_renderer.shouldExit) {
this->_snes.disableCPUDebugging ();
return 0;
}
this->_renderer.drawScreen();
this->_renderer.getEvents();
if (this->_isPaused)
return 0xFF;
return CPU::update();
}
}
+35
View File
@@ -0,0 +1,35 @@
//
// Created by anonymus-raccoon on 2/14/20.
//
#ifndef COMSQUARE_DEBUGCPU_HPP
#define COMSQUARE_DEBUGCPU_HPP
#include "../CPU/CPU.hpp"
#include "../Renderer/SFRenderer.hpp"
#include "../SNES.hpp"
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::SFRenderer _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).
SNES &_snes;
public:
//! @brief Convert a basic CPU to a debugging CPU.
explicit CPUDebug(ComSquare::CPU::CPU &cpu, SNES &snes);
CPUDebug(const CPUDebug &) = delete;
CPUDebug &operator=(const CPUDebug &) = delete;
~CPUDebug() = default;
//! @brief Override the basic cpu's update to allow pausing of the CPU only.
unsigned update() override;
};
}
#endif //COMSQUARE_DEBUGCPU_HPP