Fixing the rom reset and adding an open rom button

This commit is contained in:
Zoe Roux
2021-07-06 20:46:36 +02:00
parent c38dfefd73
commit 0d0dbc9b02
7 changed files with 36 additions and 13 deletions
+4
View File
@@ -209,6 +209,8 @@ namespace ComSquare::CPU
unsigned CPU::update(unsigned maxCycles) unsigned CPU::update(unsigned maxCycles)
{ {
if (this->isDisabled)
return 0xFF;
unsigned cycles = this->runDMA(maxCycles); unsigned cycles = this->runDMA(maxCycles);
while (cycles < maxCycles) { while (cycles < maxCycles) {
@@ -221,6 +223,8 @@ namespace ComSquare::CPU
if (!this->_isWaitingForInterrupt) if (!this->_isWaitingForInterrupt)
cycles += this->executeInstruction(); cycles += this->executeInstruction();
else
return 0xFF;
} }
return cycles; return cycles;
} }
+3
View File
@@ -647,6 +647,9 @@ namespace ComSquare::CPU
//! @brief Is an abort requested //! @brief Is an abort requested
bool IsAbortRequested = false; bool IsAbortRequested = false;
//! @brief True if you want to disable updates of this CPU.
bool isDisabled = false;
#ifdef DEBUGGER_ENABLED #ifdef DEBUGGER_ENABLED
friend Debugger::CPU::CPUDebug; friend Debugger::CPU::CPUDebug;
friend Debugger::RegisterViewer; friend Debugger::RegisterViewer;
+2 -2
View File
@@ -62,7 +62,7 @@ namespace ComSquare::Debugger::CPU
this->_updateRegistersPanel(); this->_updateRegistersPanel();
this->_updateDisassembly(this->_cpu._registers.pac, 0); this->_updateDisassembly(this->_cpu._registers.pac, 0);
this->_cpu._isStopped = true; this->_cpu.isDisabled = true;
this->_callback = this->_cpu.onReset.addCallback([this] { this->_callback = this->_cpu.onReset.addCallback([this] {
this->disassembled.clear(); this->disassembled.clear();
this->_updateDisassembly(0xFFFF - this->_cpu._cartridgeHeader.emulationInterrupts.reset); this->_updateDisassembly(0xFFFF - this->_cpu._cartridgeHeader.emulationInterrupts.reset);
@@ -78,7 +78,7 @@ namespace ComSquare::Debugger::CPU
CPUDebug::~CPUDebug() CPUDebug::~CPUDebug()
{ {
this->_cpu.onReset.removeCallback(this->_callback); this->_cpu.onReset.removeCallback(this->_callback);
this->_cpu._isStopped = false; this->_cpu.isDisabled = false;
} }
unsigned CPUDebug::update() unsigned CPUDebug::update()
+13 -2
View File
@@ -7,6 +7,8 @@
#include <QIcon> #include <QIcon>
#include <QMenuBar> #include <QMenuBar>
#include <iostream> #include <iostream>
#include <QDir>
#include <QFileDialog>
#include "Models/Logger.hpp" #include "Models/Logger.hpp"
#include "SNES.hpp" #include "SNES.hpp"
#include "QtSFML.hpp" #include "QtSFML.hpp"
@@ -68,6 +70,14 @@ namespace ComSquare::Renderer
} }
} }
void QtFullSFML::openRom()
{
auto rom = QFileDialog::getOpenFileName(nullptr, tr("Open a ROM"), QDir::homePath(),
tr("Rom files (*.sfc, *.smc);;Audio rom files (*.spc);;All files (*)"));
if (!rom.isEmpty())
this->_snes.loadRom(rom.toStdString());
}
void QtFullSFML::reset() void QtFullSFML::reset()
{ {
this->_snes.cpu.RESB(); this->_snes.cpu.RESB();
@@ -129,8 +139,9 @@ namespace ComSquare::Renderer
this->_window.setCentralWidget(this->_sfWidget); this->_window.setCentralWidget(this->_sfWidget);
QMenu *file = this->_window.menuBar()->addMenu("&File"); QMenu *file = this->_window.menuBar()->addMenu("&File");
//TODO implement rom opening from this menu. auto *open = new QAction("Open", &this->_window);
(void)file; QMainWindow::connect(open, &QAction::triggered, this->_sfWidget, &QtFullSFML::openRom);
file->addAction(open);
QMenu *game = this->_window.menuBar()->addMenu("&Game"); QMenu *game = this->_window.menuBar()->addMenu("&Game");
auto *reset = new QAction("Reset", &this->_window); auto *reset = new QAction("Reset", &this->_window);
+3
View File
@@ -22,6 +22,9 @@ namespace ComSquare::Renderer
SNES &_snes; SNES &_snes;
void onUpdate() override; void onUpdate() override;
public: public:
//! @brief Open the select rom dialog and load a new one if the option is selected.
void openRom();
#ifdef DEBUGGER_ENABLED #ifdef DEBUGGER_ENABLED
//! @brief Action called when clicking on the enable CPU debugger button. //! @brief Action called when clicking on the enable CPU debugger button.
void enableDebugCPU(); void enableDebugCPU();
+2
View File
@@ -47,6 +47,8 @@ namespace ComSquare
{ {
this->cartridge.loadRom(path); this->cartridge.loadRom(path);
this->bus.mapComponents(*this); this->bus.mapComponents(*this);
this->cpu.RESB();
this->apu.reset();
if (this->cartridge.getType() == Cartridge::Audio) if (this->cartridge.getType() == Cartridge::Audio)
this->apu.loadFromSPC(this->cartridge); this->apu.loadFromSPC(this->cartridge);
} }
+9 -9
View File
@@ -65,21 +65,21 @@ void parseArguments(int argc, char **argv, SNES &snes)
case 'c': case 'c':
snes.enableCPUDebugging(); snes.enableCPUDebugging();
break; break;
// case 'a': case 'a':
// snes.enableAPUDebugging(); snes.enableAPUDebugging();
// break; break;
case 'm': case 'm':
snes.enableRamViewer(); snes.enableRamViewer();
break; break;
case 'H': case 'H':
snes.enableHeaderViewer(); snes.enableHeaderViewer();
break; break;
// case 'b': case 'b':
// snes.enableMemoryBusDebugging(); snes.enableMemoryBusDebugging();
// break; break;
// case 'g': case 'g':
// snes.enableCgramViewer(); snes.enableCgramViewer();
// break; break;
case 'r': case 'r':
snes.enableRegisterViewer(); snes.enableRegisterViewer();
break; break;