mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-04 18:46:11 +00:00
Creating a base window
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user