mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-04 10:44:37 +00:00
Adding a step feature
This commit is contained in:
@@ -16,6 +16,7 @@ namespace ComSquare::Debugger
|
||||
|
||||
this->_ui.setupUi(this);
|
||||
QMainWindow::connect(this->_ui.actionPause, &QAction::triggered, this, &CPUDebug::pause);
|
||||
QMainWindow::connect(this->_ui.actionStep, &QAction::triggered, this, &CPUDebug::step);
|
||||
this->show();
|
||||
}
|
||||
|
||||
@@ -33,6 +34,12 @@ namespace ComSquare::Debugger
|
||||
|
||||
unsigned CPUDebug::_executeInstruction(uint8_t opcode)
|
||||
{
|
||||
if (this->_isPaused)
|
||||
return 0;
|
||||
if (this->_isStepping) {
|
||||
this->_isStepping = false;
|
||||
this->_isPaused = true;
|
||||
}
|
||||
this->_ui.logger->append(CPUDebug::_getInstructionString(opcode).c_str());
|
||||
return CPU::_executeInstruction(opcode);
|
||||
}
|
||||
@@ -46,6 +53,12 @@ namespace ComSquare::Debugger
|
||||
this->_ui.actionPause->setText("Pause");
|
||||
}
|
||||
|
||||
void CPUDebug::step()
|
||||
{
|
||||
this->_isStepping = true;
|
||||
this->_isPaused = false;
|
||||
}
|
||||
|
||||
std::string CPUDebug::_getInstructionString(uint8_t opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace ComSquare::Debugger
|
||||
Ui::CPUView _ui;
|
||||
//! @brief If this is set to true, the execution of the CPU will be paused.
|
||||
bool _isPaused = true;
|
||||
//! @brief If this is set to true, the CPU will execute one instruction and pause itself.
|
||||
bool _isStepping = false;
|
||||
//! @brief A reference to the snes (to disable the debugger).
|
||||
SNES &_snes;
|
||||
//! @brief Reimplement the basic instruction execution method to log instructions inside the logger view.
|
||||
@@ -29,6 +31,8 @@ namespace ComSquare::Debugger
|
||||
public slots:
|
||||
//! @brief Pause/Resume the CPU.
|
||||
void pause();
|
||||
//! @brief Step - Execute a single instruction.
|
||||
void step();
|
||||
public:
|
||||
//! @brief Convert a basic CPU to a debugging CPU.
|
||||
explicit CPUDebug(ComSquare::CPU::CPU &cpu, SNES &snes);
|
||||
|
||||
Reference in New Issue
Block a user