mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-02 10:15:45 +00:00
Making the debugger spawn on invalid rom exceptions (invalid address access, invalid opcode...) & starting the dissasembly view
This commit is contained in:
@@ -15,22 +15,18 @@ namespace ComSquare::Cartridge
|
||||
Cartridge::Cartridge(const std::string &romPath)
|
||||
: Ram::Ram(0, Rom, "Cartridge")
|
||||
{
|
||||
try {
|
||||
if (romPath.empty())
|
||||
throw InvalidRomException("Path is empty.");
|
||||
size_t size = Cartridge::getRomSize(romPath);
|
||||
FILE *rom = fopen(romPath.c_str(), "rb");
|
||||
if (romPath.empty())
|
||||
throw InvalidRomException("Path is empty.");
|
||||
size_t size = Cartridge::getRomSize(romPath);
|
||||
FILE *rom = fopen(romPath.c_str(), "rb");
|
||||
|
||||
if (!rom)
|
||||
throw InvalidRomException("Could not open the rom file at " + romPath + ". " + strerror(errno));
|
||||
this->_size = size;
|
||||
this->_data = new uint8_t[size];
|
||||
std::memset(this->_data, 0, size);
|
||||
fread(this->_data, 1, size, rom);
|
||||
this->_loadHeader();
|
||||
} catch (InvalidRomException &ex) {
|
||||
std::cerr << "Invalid Rom Error: " << ex.what() << std::endl;
|
||||
}
|
||||
if (!rom)
|
||||
throw InvalidRomException("Could not open the rom file at " + romPath + ". " + strerror(errno));
|
||||
this->_size = size;
|
||||
this->_data = new uint8_t[size];
|
||||
std::memset(this->_data, 0, size);
|
||||
fread(this->_data, 1, size, rom);
|
||||
this->_loadHeader();
|
||||
}
|
||||
|
||||
size_t Cartridge::getRomSize(const std::string &romPath)
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace ComSquare::Debugger
|
||||
this->_ui.setupUi(this->_window);
|
||||
this->_proxy.setSourceModel(&this->_model);
|
||||
this->_ui.log->setModel(&this->_proxy);
|
||||
this->_ui.log->setAlternatingRowColors(true);
|
||||
this->_ui.log->verticalHeader()->hide();
|
||||
this->_ui.log->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
|
||||
this->_ui.log->horizontalHeader()->setStretchLastSection(true);
|
||||
this->_ui.log->horizontalHeader()->setSectionsMovable(true);
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <QMenuBar>
|
||||
#include <iostream>
|
||||
#include "QtSFML.hpp"
|
||||
#include "../../Exceptions/InvalidOpcode.hpp"
|
||||
#include "../../Exceptions/InvalidAddress.hpp"
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <Qt/qx11info_x11.h>
|
||||
@@ -84,6 +86,10 @@ namespace ComSquare::Renderer
|
||||
{
|
||||
try {
|
||||
this->_snes.update();
|
||||
} catch (InvalidOpcode &e) {
|
||||
this->_snes.enableCPUDebugging();
|
||||
} catch (InvalidAddress &e) {
|
||||
this->_snes.enableCPUDebugging();
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << "An error occurred: " << e.what() << std::endl;
|
||||
QApplication::quit();
|
||||
|
||||
+10
-4
@@ -68,8 +68,14 @@ int main(int argc, char **argv)
|
||||
QApplication app(argc, argv);
|
||||
QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
||||
Renderer::QtSFML renderer(600, 800);
|
||||
SNES snes(argv[1], renderer);
|
||||
renderer.createWindow(snes, 60);
|
||||
parseArguments(argc, argv, snes);
|
||||
return QApplication::exec();
|
||||
try {
|
||||
SNES snes(argv[1], renderer);
|
||||
renderer.createWindow(snes, 60);
|
||||
parseArguments(argc, argv, snes);
|
||||
return QApplication::exec();
|
||||
}
|
||||
catch(std::exception &ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>438</height>
|
||||
<width>971</width>
|
||||
<height>709</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -21,28 +21,18 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QTableView" name="dissasembly">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="loggerLabel">
|
||||
<property name="text">
|
||||
<string>Instructions History</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QTextBrowser" name="logger"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="clear">
|
||||
<property name="text">
|
||||
<string>Clear History</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="3">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="accumulatorLabel">
|
||||
@@ -150,10 +140,37 @@
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="clear">
|
||||
<property name="text">
|
||||
<string>Clear History</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="loggerLabel">
|
||||
<property name="text">
|
||||
<string>Instructions History</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="logger"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
|
||||
Reference in New Issue
Block a user