diff --git a/sources/APU/APU.hpp b/sources/APU/APU.hpp index 5dbc43f..25f9917 100644 --- a/sources/APU/APU.hpp +++ b/sources/APU/APU.hpp @@ -370,7 +370,7 @@ namespace ComSquare::APU explicit APU(std::shared_ptr &map); APU(const APU &) = default; APU &operator=(const APU &) = default; - ~APU() = default; + ~APU() override = default; //! @brief Read from the internal APU register. //! @param addr The address to read from. The address 0x00 should refer to the first byte of the register. diff --git a/sources/APU/Instructions/8bitShiftRotation.cpp b/sources/APU/Instructions/8bitShiftRotation.cpp index 1aece45..db7e538 100644 --- a/sources/APU/Instructions/8bitShiftRotation.cpp +++ b/sources/APU/Instructions/8bitShiftRotation.cpp @@ -2,6 +2,7 @@ // Created by Melefo on 25/02/2020. // +#include #include "../APU.hpp" namespace ComSquare::APU diff --git a/sources/CPU/CPU.hpp b/sources/CPU/CPU.hpp index 3e45f77..adfc4e0 100644 --- a/sources/CPU/CPU.hpp +++ b/sources/CPU/CPU.hpp @@ -5,6 +5,7 @@ #ifndef COMSQUARE_CPU_HPP #define COMSQUARE_CPU_HPP +#include #include "../Memory/AMemory.hpp" #include "../Memory/MemoryBus.hpp" #include "../Models/Int24.hpp" @@ -642,6 +643,7 @@ namespace ComSquare::CPU CPU(const CPU &) = default; CPU &operator=(const CPU &) = delete; ~CPU() override = default; + //! @brief This function continue to execute the Cartridge code. //! @return The number of CPU cycles that elapsed virtual unsigned update(); diff --git a/sources/Memory/MemoryBus.cpp b/sources/Memory/MemoryBus.cpp index 12a0391..4c74b40 100644 --- a/sources/Memory/MemoryBus.cpp +++ b/sources/Memory/MemoryBus.cpp @@ -56,6 +56,8 @@ namespace ComSquare::Memory void MemoryBus::mapComponents(SNES &console) { + this->_memoryAccessors.clear(); + // The WRam and PU registers are always mapped at the same address no matter the mapping mode. console.wram->setMemoryRegion(0x7E, 0x7F, 0x0000, 0xFFFF); this->_memoryAccessors.push_back(console.wram); diff --git a/sources/SNES.cpp b/sources/SNES.cpp index bcbce3c..837593c 100644 --- a/sources/SNES.cpp +++ b/sources/SNES.cpp @@ -6,9 +6,10 @@ #include #include "SNES.hpp" #ifdef DEBUGGER_ENABLED -#include "Debugger/CPUDebug.hpp" +#include "Debugger/CPU/CPUDebug.hpp" #include "Debugger/APUDebug.hpp" #include "Debugger/MemoryBusDebug.hpp" +#include "Debugger/CGramDebug.hpp" #endif @@ -42,8 +43,10 @@ namespace ComSquare cpuDebug->focus(); if (pause) cpuDebug->pause(); - } else + } else { this->cpu = std::make_shared(*this->cpu, *this); + this->_bus->mapComponents(*this); + } #else std::cerr << "Debugging features are not enabled. You can't enable the debugger." << std::endl; (void)pause; @@ -53,6 +56,7 @@ namespace ComSquare void SNES::disableCPUDebugging() { this->cpu = std::make_shared(*this->cpu); + this->_bus->mapComponents(*this); } void SNES::enableRamViewer() @@ -94,8 +98,10 @@ namespace ComSquare #ifdef DEBUGGER_ENABLED if (this->apu->isDebugger()) std::static_pointer_cast(this->apu)->focus(); - else + else { this->apu = std::make_shared(*this->apu, *this); + this->_bus->mapComponents(*this); + } #else std::cerr << "Debugging features are not enabled. You can't enable the debugger." << std::endl; #endif @@ -104,6 +110,7 @@ namespace ComSquare void SNES::disableAPUDebugging() { this->apu = std::make_shared(*this->apu); + this->_bus->mapComponents(*this); } void SNES::enableMemoryBusDebugging() @@ -130,4 +137,21 @@ namespace ComSquare std::cerr << "Debugging features are not enabled. You can't enable the debugger." << std::endl; #endif } + + void SNES::enableCgramDebugging() + { + #ifdef DEBUGGER_ENABLED + if (this->_cgramViewer) + this->_cgramViewer->focus(); + else + this->_cgramViewer = std::make_unique(*this, *this->ppu); + #endif + } + + void SNES::disableCgramDebugging() + { + #ifdef DEBUGGER_ENABLED + this->_cgramViewer = nullptr; + #endif + } } diff --git a/sources/main.cpp b/sources/main.cpp index 195dedc..871f559 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -20,6 +20,8 @@ void usage(char *bin) << "\t-m, --memory: \tEnable the memory viewer panel." << std::endl << "\t-h, --header: \tShow the header of the cartridge." << std::endl << "\t-b, --bus: \tShow the memory bus's log." << std::endl; + << "\t-b, --bus: \tShow the memory bus's log." << std::endl + << "\t-g, --cgram: \tShow the palette viewer." << std::endl; } void parseArguments(int argc, char **argv, SNES &snes) @@ -32,10 +34,11 @@ void parseArguments(int argc, char **argv, SNES &snes) {"memory", no_argument, 0, 'm'}, {"header", no_argument, 0, 'h'}, {"bus", no_argument, 0, 'b'}, + {"cgram", no_argument, 0, 'g'}, {0, 0, 0, 0} }; - int c = getopt_long(argc, argv, "camhb", long_options, &option_index); + int c = getopt_long(argc, argv, "camhbg", long_options, &option_index); if (c == -1) break; switch (c) { @@ -57,6 +60,9 @@ void parseArguments(int argc, char **argv, SNES &snes) case 'b': snes.enableMemoryBusDebugging(); break; + case 'g': + snes.enableCgramDebugging(); + break; default: break; }