Adding a header viewer

This commit is contained in:
Anonymus Raccoon
2020-02-18 23:07:21 +01:00
parent 0e97bcaf43
commit 381d624e13
9 changed files with 519 additions and 13 deletions
+2 -1
View File
@@ -131,11 +131,12 @@ add_executable(ComSquare
sources/Renderer/QtRenderer/QtWidgetSFML.hpp
ui/cpu.ui
ui/ramView.ui
ui/cartridgeView.ui
resources/appResources.qrc
sources/Utility/Utility.hpp
sources/Debugger/MemoryViewer.cpp
sources/Debugger/MemoryViewer.hpp
sources/Utility/Utility.cpp)
sources/Utility/Utility.cpp sources/Debugger/HeaderViewer.cpp sources/Debugger/HeaderViewer.hpp)
target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED)
+18 -10
View File
@@ -22,22 +22,30 @@ void parseArguments(int argc, char **argv, SNES &snes)
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = {
{"cpu-debug", no_argument, 0, 'c' },
{"cpu", no_argument, 0, 'c' },
{"memory", no_argument, 0, 'm' },
{"header", no_argument, 0, 'h' },
{0, 0, 0, 0 }
};
char c = getopt_long(argc, argv, "c", long_options, &option_index);
char c = getopt_long(argc, argv, "cmh", long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
usage(argv[0]);
break;
case 'c':
snes.enableCPUDebugging();
break;
default:
break;
case 0:
usage(argv[0]);
break;
case 'c':
snes.enableCPUDebugging();
break;
case 'm':
snes.enableRamViewer();
break;
case 'h':
snes.enableHeaderViewer();
break;
default:
break;
}
}
}
+53
View File
@@ -0,0 +1,53 @@
//
// Created by anonymus-raccoon on 2/18/20.
//
#include "HeaderViewer.hpp"
#include "../Utility/Utility.hpp"
namespace ComSquare::Debugger
{
HeaderViewer::HeaderViewer(ComSquare::Cartridge::Cartridge &cartridge) :
_cartridge(cartridge),
_ui()
{
this->setContextMenuPolicy(Qt::NoContextMenu);
this->setAttribute(Qt::WA_QuitOnClose, false);
this->_ui.setupUi(this);
this->_ui.nameLineEdit->setText(cartridge.header.gameName.c_str());
std::string memType;
if (cartridge.header.mappingMode & Cartridge::LoRom)
memType += "LoRom ";
if (cartridge.header.mappingMode & Cartridge::HiRom)
memType += "HiRom ";
if (cartridge.header.mappingMode & Cartridge::SlowRom)
memType += "SlowRom ";
if (cartridge.header.mappingMode & Cartridge::FastRom)
memType += "FastRom ";
if (cartridge.header.mappingMode & Cartridge::ExRom)
memType += "ExRom ";
this->_ui.mappingLineEdit->setText(memType.c_str());
this->_ui.romSizeLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.romSize).c_str());
this->_ui.sRamSizeLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.sramSize).c_str());
this->_ui.versionLineEdit->setText(std::to_string(cartridge.header.version).c_str());
this->_ui.creatorIDLineEdit->setText(std::to_string(cartridge.header.creatorID).c_str());
this->_ui.checksumLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.checksum).c_str());
this->_ui.checksumComplementLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.checksumComplement).c_str());
this->_ui.coProcessorLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.emulationInterrupts.cop).c_str());
this->_ui.breakLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.emulationInterrupts.brk).c_str());
this->_ui.abortLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.emulationInterrupts.abort).c_str());
this->_ui.nMInteruptLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.emulationInterrupts.nmi).c_str());
this->_ui.resetLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.emulationInterrupts.reset).c_str());
this->_ui.interruptRequestLineEdit->setText(ComSquare::Utility::to_hex(cartridge.header.emulationInterrupts.irq).c_str());
this->_ui.coProcessorLineEditNat->setText(ComSquare::Utility::to_hex(cartridge.header.nativeInterrupts.cop).c_str());
this->_ui.breakLineEditNat->setText(ComSquare::Utility::to_hex(cartridge.header.nativeInterrupts.brk).c_str());
this->_ui.abortLineEditNat->setText(ComSquare::Utility::to_hex(cartridge.header.nativeInterrupts.abort).c_str());
this->_ui.nMInteruptLineEditNat->setText(ComSquare::Utility::to_hex(cartridge.header.nativeInterrupts.nmi).c_str());
this->_ui.resetLineEditNat->setText(ComSquare::Utility::to_hex(cartridge.header.nativeInterrupts.reset).c_str());
this->_ui.interruptRequestLineEditNat->setText(ComSquare::Utility::to_hex(cartridge.header.nativeInterrupts.irq).c_str());
this->show();
}
}
+29
View File
@@ -0,0 +1,29 @@
//
// Created by anonymus-raccoon on 2/18/20.
//
#ifndef COMSQUARE_HEADERVIEWER_HPP
#define COMSQUARE_HEADERVIEWER_HPP
#include <QtWidgets/QMainWindow>
#include "../Cartridge/Cartridge.hpp"
#include "../../ui/ui_cartridgeView.h"
namespace ComSquare::Debugger
{
//! @brief Window that show the header of the currently running game.
class HeaderViewer : public QMainWindow {
private:
//! @brief The cartrdige containing the header.
Cartridge::Cartridge &_cartridge;
//! @brief The layout of the viewer.
Ui::CatridgeView _ui;
public:
explicit HeaderViewer(Cartridge::Cartridge &cartridge);
HeaderViewer(const HeaderViewer &) = delete;
HeaderViewer &operator=(const HeaderViewer &) = delete;
~HeaderViewer() override = default;
};
}
#endif //COMSQUARE_HEADERVIEWER_HPP
+9
View File
@@ -47,6 +47,10 @@ namespace ComSquare::Renderer
ramViewer->setShortcut(Qt::Key_F2);
QMainWindow::connect(ramViewer, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableRamViewer);
debugger->addAction(ramViewer);
QAction *headerViewer = new QAction("Header viewer", &this->_window);
headerViewer->setShortcut(Qt::Key_F3);
QMainWindow::connect(headerViewer, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableHeaderViewer);
debugger->addAction(headerViewer);
this->_window.show();
}
@@ -92,4 +96,9 @@ namespace ComSquare::Renderer
{
this->_snes.enableRamViewer();
}
void QtFullSFML::enableHeaderViewer()
{
this->_snes.enableHeaderViewer();
}
}
+2
View File
@@ -27,6 +27,8 @@ namespace ComSquare::Renderer
void enableDebugCPU();
//! @brief Action called when clicking on the enable Ram viewer button.
void enableRamViewer();
//! @brief Action called when clicking on the enable Header viewer button.
void enableHeaderViewer();
//! @brief Action called when clicking on the reset button.
void reset();
QtFullSFML(SNES &snes, QWidget* parent, const QPoint& position, const QSize& size, int frameRate = 0);
+15 -1
View File
@@ -43,7 +43,7 @@ namespace ComSquare
#endif
}
void SNES::disableRamDebugging()
void SNES::disableRamViewer()
{
#ifdef DEBUGGER_ENABLED
this->_ramViewer = nullptr;
@@ -56,4 +56,18 @@ namespace ComSquare
this->ppu->update(cycleCount);
this->apu->update(cycleCount);
}
void SNES::enableHeaderViewer()
{
#ifdef DEBUGGER_ENABLED
this->_headerViewer = std::make_shared<Debugger::HeaderViewer>(*this->cartridge);
#endif
}
void SNES::disableHeaderViewer()
{
#ifdef DEBUGGER_ENABLED
this->_headerViewer = nullptr;
#endif
}
}
+10 -1
View File
@@ -14,6 +14,8 @@
#include "Renderer/IRenderer.hpp"
#ifdef DEBUGGER_ENABLED
#include "Debugger/MemoryViewer.hpp"
#include "Debugger/HeaderViewer.hpp"
#endif
namespace ComSquare
@@ -22,7 +24,10 @@ namespace ComSquare
class SNES {
#ifdef DEBUGGER_ENABLED
private:
//! @brief The window that allow the user to view a memory.
std::shared_ptr<Debugger::MemoryViewer> _ramViewer;
//! @brief The window that allow the user to view the cartridge's header.
std::shared_ptr<Debugger::HeaderViewer> _headerViewer;
#endif
public:
//! @brief Cartridge containing instructions (ROM).
@@ -46,9 +51,13 @@ namespace ComSquare
//! @brief Enable the CPU's debugging window.
void enableCPUDebugging();
//! @brief Disable the Ram's debugging window.
void disableRamDebugging();
void disableRamViewer();
//! @brief Enable the Ram's debugging window.
void enableRamViewer();
//! @brief Disable the Header's debugging window.
void disableHeaderViewer();
//! @brief Enable the Header's debugging window.
void enableHeaderViewer();
//! @brief Create all the components using a common memory bus for all of them.
SNES(const std::shared_ptr<Memory::MemoryBus> &bus, const std::string &ramPath, Renderer::IRenderer &renderer);
+381
View File
@@ -0,0 +1,381 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CatridgeView</class>
<widget class="QMainWindow" name="CatridgeView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>375</height>
</rect>
</property>
<property name="windowTitle">
<string>Header Viewer</string>
</property>
<property name="windowIcon">
<iconset resource="../resources/appResources.qrc">
<normaloff>:/resources/Logo.png</normaloff>:/resources/Logo.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabs">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="general">
<attribute name="title">
<string>General</string>
</attribute>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>281</width>
<height>316</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mappingLabel">
<property name="text">
<string>Mapping</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mappingLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="romTypeLabel">
<property name="text">
<string>Rom Type</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="romTypeLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="romSizeLabel">
<property name="text">
<string>Rom Size</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="romSizeLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="sRamSizeLabel">
<property name="text">
<string>SRam Size</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="sRamSizeLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="versionLabel">
<property name="text">
<string>Version</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="versionLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="creatorIDLabel">
<property name="text">
<string>Creator ID</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="creatorIDLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="checksumLabel">
<property name="text">
<string>Checksum</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="checksumLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="checksumComplementLabel">
<property name="text">
<string>Complement</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="checksumComplementLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="emul">
<attribute name="title">
<string>Emulation</string>
</attribute>
<widget class="QWidget" name="formLayoutWidget_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>281</width>
<height>351</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="coProcessorLabel">
<property name="text">
<string>Co-Processor</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="coProcessorLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="breakLabel">
<property name="text">
<string>Break</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="breakLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="abortLabel">
<property name="text">
<string>Abort</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="abortLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="nMInteruptLabel">
<property name="text">
<string>NM Interupt</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="nMInteruptLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="resetLabel">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="resetLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="interruptRequestLabel">
<property name="text">
<string>Interrupt Request</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="interruptRequestLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="nat">
<attribute name="title">
<string>Native</string>
</attribute>
<widget class="QWidget" name="formLayoutWidget_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>281</width>
<height>351</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="coProcessorLabelNat">
<property name="text">
<string>Co-Processor</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="coProcessorLineEditNat">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="breakLabelNat">
<property name="text">
<string>Break</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="breakLineEditNat">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="abortLabelNat">
<property name="text">
<string>Abort</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="abortLineEditNat">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="nMInteruptLabelNat">
<property name="text">
<string>NM Interupt</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="nMInteruptLineEditNat">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="resetLabelNat">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="resetLineEditNat">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="interruptRequestLabelNat">
<property name="text">
<string>Interrupt Request</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="interruptRequestLineEditNat">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="../resources/appResources.qrc"/>
</resources>
<connections/>
</ui>