From a826168eb29254424eded2112d1daa101939fb0e Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 6 Feb 2021 18:29:15 +0100 Subject: [PATCH] Starting to load symbols --- CMakeLists.txt | 2 +- sources/Cartridge/Cartridge.cpp | 8 +++++++- sources/Cartridge/Cartridge.hpp | 7 +++++++ sources/Debugger/CPU/CPUDebug.cpp | 21 ++++++++++++++++++-- sources/Debugger/CPU/CPUDebug.hpp | 21 ++++++++++++++++++-- sources/Debugger/CPU/Disassembly.cpp | 4 ++-- sources/Debugger/CPU/SymbolLoaders/WlaDx.cpp | 18 +++++++++++++++++ sources/Debugger/CPU/SymbolLoaders/WlaDx.hpp | 17 ++++++++++++++++ 8 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 sources/Debugger/CPU/SymbolLoaders/WlaDx.cpp create mode 100644 sources/Debugger/CPU/SymbolLoaders/WlaDx.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9db1d4a..e08896b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,7 +220,7 @@ add_executable(ComSquare ui/registersView.ui sources/Debugger/RegisterViewer.cpp sources/Debugger/RegisterViewer.hpp - sources/Memory/IMemory.hpp) + sources/Memory/IMemory.hpp sources/Debugger/CPU/SymbolLoaders/WlaDx.cpp sources/Debugger/CPU/SymbolLoaders/WlaDx.hpp) target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED) diff --git a/sources/Cartridge/Cartridge.cpp b/sources/Cartridge/Cartridge.cpp index ead9363..08573a2 100644 --- a/sources/Cartridge/Cartridge.cpp +++ b/sources/Cartridge/Cartridge.cpp @@ -12,7 +12,8 @@ namespace ComSquare::Cartridge { Cartridge::Cartridge(const std::string &romPath) - : Ram::Ram(0, Rom, "Cartridge") + : Ram::Ram(0, Rom, "Cartridge"), + _romPath(romPath) { if (romPath.empty()) throw InvalidRomException("Path is empty."); @@ -48,6 +49,11 @@ namespace ComSquare::Cartridge throw InvalidAction("Witting to the ROM is not allowed."); } + std::filesystem::path Cartridge::getRomPath() const + { + return this->_romPath; + } + Header Cartridge::_mapHeader(uint32_t headerAddress) { Header head; diff --git a/sources/Cartridge/Cartridge.hpp b/sources/Cartridge/Cartridge.hpp index 90562e8..006da93 100644 --- a/sources/Cartridge/Cartridge.hpp +++ b/sources/Cartridge/Cartridge.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include "../Memory/AMemory.hpp" #include "../Models/Int24.hpp" #include "../Memory/ARectangleMemory.hpp" @@ -65,6 +66,8 @@ namespace ComSquare::Cartridge //! @brief Contains the rom's memory/instructions. class Cartridge : public Ram::Ram { private: + //! @brief The path of the currently loaded rom. + std::string _romPath; //! @brief Sometime the rom's data has an offset for a SMC header. This value indicate the start of the real rom discarding this header. uint16_t _romStart = 0; @@ -104,5 +107,9 @@ namespace ComSquare::Cartridge //! @param data The data to write. //! @throw InvalidAddress will be thrown if the address is more than the size of the rom's memory. void write(uint24_t addr, uint8_t data) override; + + //! @brief The path of the rom file + //! @return The path of the currently loaded rom file. + std::filesystem::path getRomPath() const; }; } \ No newline at end of file diff --git a/sources/Debugger/CPU/CPUDebug.cpp b/sources/Debugger/CPU/CPUDebug.cpp index b635ba4..cd8cb22 100644 --- a/sources/Debugger/CPU/CPUDebug.cpp +++ b/sources/Debugger/CPU/CPUDebug.cpp @@ -10,19 +10,21 @@ #include #include #include +#include using namespace ComSquare::CPU; namespace ComSquare::Debugger { - CPUDebug::CPUDebug(CPU &basicCPU, SNES &snes) + CPUDebug::CPUDebug(const CPU &basicCPU, SNES &snes) : CPU(basicCPU), _window(new ClosableWindow(*this, &CPUDebug::disableDebugger)), _ui(), _model(*this), _painter(*this), _stackModel(this->_bus, *this), - _snes(snes) + _snes(snes), + _labels(this->_loadLabels(snes.cartridge->getRomPath())) { this->_window->setContextMenuPolicy(Qt::NoContextMenu); this->_window->setAttribute(Qt::WA_QuitOnClose, false); @@ -306,6 +308,21 @@ namespace ComSquare::Debugger return ""; return "[" + Utility::to_hex(valueAddr, Utility::AsmPrefix) + "]"; } + + std::vector