diff --git a/sources/APU/APU.hpp b/sources/APU/APU.hpp index 4ff1acf..6503207 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/CPU/CPU.hpp b/sources/CPU/CPU.hpp index 2d72b91..26dde23 100644 --- a/sources/CPU/CPU.hpp +++ b/sources/CPU/CPU.hpp @@ -685,6 +685,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 0687305..a57cd5a 100644 --- a/sources/SNES.cpp +++ b/sources/SNES.cpp @@ -42,8 +42,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 +55,7 @@ namespace ComSquare void SNES::disableCPUDebugging() { this->cpu = std::make_shared(*this->cpu); + this->_bus->mapComponents(*this); } void SNES::enableRamViewer() @@ -94,8 +97,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 +109,7 @@ namespace ComSquare void SNES::disableAPUDebugging() { this->apu = std::make_shared(*this->apu); + this->_bus->mapComponents(*this); } void SNES::enableMemoryBusDebugging()