diff --git a/Core/SNES/RegisterHandlerB.cpp b/Core/SNES/RegisterHandlerB.cpp index a2c47d93..792e85ae 100644 --- a/Core/SNES/RegisterHandlerB.cpp +++ b/Core/SNES/RegisterHandlerB.cpp @@ -61,7 +61,7 @@ void RegisterHandlerB::Write(uint32_t addr, uint8_t value) { addr &= 0xFFFF; if(addr >= 0x2140 && addr <= 0x217F) { - return _spc->CpuWriteRegister(addr & 0x03, value); + _spc->CpuWriteRegister(addr & 0x03, value); } if(addr >= 0x2180 && addr <= 0x2183) { switch(addr & 0xFFFF) { case 0x2180: @@ -78,7 +78,7 @@ void RegisterHandlerB::Write(uint32_t addr, uint8_t value) } else if(addr >= 0x2200 && addr <= 0x22FF && _console->GetCartridge()->GetSa1()) { _console->GetCartridge()->GetSa1()->CpuRegisterWrite(addr, value); } else if(_msu1 && addr <= 0x2007) { - return _msu1->Write(addr, value); + _msu1->Write(addr, value); } else { _ppu->Write(addr, value); } @@ -89,6 +89,11 @@ AddressInfo RegisterHandlerB::GetAbsoluteAddress(uint32_t address) return { -1, MemoryType::SnesMemory }; } +uint32_t RegisterHandlerB::GetWramPosition() +{ + return _wramPosition; +} + void RegisterHandlerB::Serialize(Serializer &s) { SV(_wramPosition); diff --git a/Core/SNES/RegisterHandlerB.h b/Core/SNES/RegisterHandlerB.h index d728fe9b..51cf7340 100644 --- a/Core/SNES/RegisterHandlerB.h +++ b/Core/SNES/RegisterHandlerB.h @@ -34,6 +34,8 @@ public: void Write(uint32_t addr, uint8_t value) override; AddressInfo GetAbsoluteAddress(uint32_t address) override; + + uint32_t GetWramPosition(); void Serialize(Serializer &s) override; }; \ No newline at end of file diff --git a/Core/SNES/SnesConsole.cpp b/Core/SNES/SnesConsole.cpp index d0fa21b3..038afdb0 100644 --- a/Core/SNES/SnesConsole.cpp +++ b/Core/SNES/SnesConsole.cpp @@ -513,6 +513,7 @@ void SnesConsole::GetConsoleState(BaseState& baseState, ConsoleType consoleType) SnesState& state = (SnesState&)baseState; state.MasterClock = GetMasterClock(); + state.WramPosition = _memoryManager->GetWramPosition(); state.Cpu = _cpu->GetState(); _ppu->GetState(state.Ppu, false); state.Spc = _spc->GetState(); diff --git a/Core/SNES/SnesMemoryManager.cpp b/Core/SNES/SnesMemoryManager.cpp index 15e97176..48a501eb 100644 --- a/Core/SNES/SnesMemoryManager.cpp +++ b/Core/SNES/SnesMemoryManager.cpp @@ -413,6 +413,11 @@ bool SnesMemoryManager::IsWorkRam(uint32_t cpuAddress) return handler && handler->GetMemoryType() == MemoryType::SnesWorkRam; } +uint32_t SnesMemoryManager::GetWramPosition() +{ + return _registerHandlerB->GetWramPosition(); +} + void SnesMemoryManager::Serialize(Serializer &s) { SV(_masterClock); SV(_openBus); SV(_cpuSpeed); SV(_hClock); SV(_dramRefreshPosition); diff --git a/Core/SNES/SnesMemoryManager.h b/Core/SNES/SnesMemoryManager.h index c3434798..6ad8f100 100644 --- a/Core/SNES/SnesMemoryManager.h +++ b/Core/SNES/SnesMemoryManager.h @@ -103,5 +103,7 @@ public: bool IsRegister(uint32_t cpuAddress); bool IsWorkRam(uint32_t cpuAddress); + uint32_t GetWramPosition(); + void Serialize(Serializer &s) override; }; diff --git a/Core/SNES/SnesState.h b/Core/SNES/SnesState.h index 9d0c4acb..72ecbbc6 100644 --- a/Core/SNES/SnesState.h +++ b/Core/SNES/SnesState.h @@ -27,4 +27,6 @@ struct SnesState SnesDmaControllerState Dma; InternalRegisterState InternalRegs; AluState Alu; + + uint32_t WramPosition; }; \ No newline at end of file diff --git a/UI/Debugger/ViewModels/RegisterViewerWindowViewModel.cs b/UI/Debugger/ViewModels/RegisterViewerWindowViewModel.cs index e0505dac..cce15782 100644 --- a/UI/Debugger/ViewModels/RegisterViewerWindowViewModel.cs +++ b/UI/Debugger/ViewModels/RegisterViewerWindowViewModel.cs @@ -942,6 +942,8 @@ namespace Mesen.Debugger.ViewModels AluState alu = state.Alu; List entries = new List() { + new RegEntry("$2181 - $2183", "Work RAM Position", state.WramPosition, Format.X24), + new RegEntry("$4200 - $4201", "IRQ/NMI/Autopoll Enabled"), new RegEntry("$4200.0", "Auto Joypad Poll", regs.EnableAutoJoypadRead), new RegEntry("$4200.4", "H IRQ Enabled", regs.EnableHorizontalIrq), diff --git a/UI/Interop/DebugState.cs b/UI/Interop/DebugState.cs index 282dbdde..96801b75 100644 --- a/UI/Interop/DebugState.cs +++ b/UI/Interop/DebugState.cs @@ -1010,6 +1010,8 @@ namespace Mesen.Interop public SnesDmaControllerState Dma; public InternalRegisterState InternalRegs; public AluState Alu; + + public UInt32 WramPosition; } public struct EmptyPpuToolsState : BaseState