mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-06 07:16:17 +00:00
Fixing the rom reset and adding an open rom button
This commit is contained in:
@@ -209,6 +209,8 @@ namespace ComSquare::CPU
|
||||
|
||||
unsigned CPU::update(unsigned maxCycles)
|
||||
{
|
||||
if (this->isDisabled)
|
||||
return 0xFF;
|
||||
unsigned cycles = this->runDMA(maxCycles);
|
||||
|
||||
while (cycles < maxCycles) {
|
||||
@@ -221,6 +223,8 @@ namespace ComSquare::CPU
|
||||
|
||||
if (!this->_isWaitingForInterrupt)
|
||||
cycles += this->executeInstruction();
|
||||
else
|
||||
return 0xFF;
|
||||
}
|
||||
return cycles;
|
||||
}
|
||||
|
||||
@@ -647,6 +647,9 @@ namespace ComSquare::CPU
|
||||
//! @brief Is an abort requested
|
||||
bool IsAbortRequested = false;
|
||||
|
||||
//! @brief True if you want to disable updates of this CPU.
|
||||
bool isDisabled = false;
|
||||
|
||||
#ifdef DEBUGGER_ENABLED
|
||||
friend Debugger::CPU::CPUDebug;
|
||||
friend Debugger::RegisterViewer;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace ComSquare::Debugger::CPU
|
||||
this->_updateRegistersPanel();
|
||||
this->_updateDisassembly(this->_cpu._registers.pac, 0);
|
||||
|
||||
this->_cpu._isStopped = true;
|
||||
this->_cpu.isDisabled = true;
|
||||
this->_callback = this->_cpu.onReset.addCallback([this] {
|
||||
this->disassembled.clear();
|
||||
this->_updateDisassembly(0xFFFF - this->_cpu._cartridgeHeader.emulationInterrupts.reset);
|
||||
@@ -78,7 +78,7 @@ namespace ComSquare::Debugger::CPU
|
||||
CPUDebug::~CPUDebug()
|
||||
{
|
||||
this->_cpu.onReset.removeCallback(this->_callback);
|
||||
this->_cpu._isStopped = false;
|
||||
this->_cpu.isDisabled = false;
|
||||
}
|
||||
|
||||
unsigned CPUDebug::update()
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <QIcon>
|
||||
#include <QMenuBar>
|
||||
#include <iostream>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include "Models/Logger.hpp"
|
||||
#include "SNES.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()
|
||||
{
|
||||
this->_snes.cpu.RESB();
|
||||
@@ -129,8 +139,9 @@ namespace ComSquare::Renderer
|
||||
this->_window.setCentralWidget(this->_sfWidget);
|
||||
|
||||
QMenu *file = this->_window.menuBar()->addMenu("&File");
|
||||
//TODO implement rom opening from this menu.
|
||||
(void)file;
|
||||
auto *open = new QAction("Open", &this->_window);
|
||||
QMainWindow::connect(open, &QAction::triggered, this->_sfWidget, &QtFullSFML::openRom);
|
||||
file->addAction(open);
|
||||
|
||||
QMenu *game = this->_window.menuBar()->addMenu("&Game");
|
||||
auto *reset = new QAction("Reset", &this->_window);
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace ComSquare::Renderer
|
||||
SNES &_snes;
|
||||
void onUpdate() override;
|
||||
public:
|
||||
//! @brief Open the select rom dialog and load a new one if the option is selected.
|
||||
void openRom();
|
||||
|
||||
#ifdef DEBUGGER_ENABLED
|
||||
//! @brief Action called when clicking on the enable CPU debugger button.
|
||||
void enableDebugCPU();
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace ComSquare
|
||||
{
|
||||
this->cartridge.loadRom(path);
|
||||
this->bus.mapComponents(*this);
|
||||
this->cpu.RESB();
|
||||
this->apu.reset();
|
||||
if (this->cartridge.getType() == Cartridge::Audio)
|
||||
this->apu.loadFromSPC(this->cartridge);
|
||||
}
|
||||
|
||||
@@ -65,21 +65,21 @@ void parseArguments(int argc, char **argv, SNES &snes)
|
||||
case 'c':
|
||||
snes.enableCPUDebugging();
|
||||
break;
|
||||
// case 'a':
|
||||
// snes.enableAPUDebugging();
|
||||
// break;
|
||||
case 'a':
|
||||
snes.enableAPUDebugging();
|
||||
break;
|
||||
case 'm':
|
||||
snes.enableRamViewer();
|
||||
break;
|
||||
case 'H':
|
||||
snes.enableHeaderViewer();
|
||||
break;
|
||||
// case 'b':
|
||||
// snes.enableMemoryBusDebugging();
|
||||
// break;
|
||||
// case 'g':
|
||||
// snes.enableCgramViewer();
|
||||
// break;
|
||||
case 'b':
|
||||
snes.enableMemoryBusDebugging();
|
||||
break;
|
||||
case 'g':
|
||||
snes.enableCgramViewer();
|
||||
break;
|
||||
case 'r':
|
||||
snes.enableRegisterViewer();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user