Skip to content

Commit

Permalink
Debugger: Register Viewer - SNES - Added wram register position
Browse files Browse the repository at this point in the history
  • Loading branch information
SourMesen committed May 28, 2023
1 parent 6262048 commit bccdfa2
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Core/SNES/RegisterHandlerB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Core/SNES/RegisterHandlerB.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class RegisterHandlerB : public IMemoryHandler, public ISerializable
void Write(uint32_t addr, uint8_t value) override;

AddressInfo GetAbsoluteAddress(uint32_t address) override;

uint32_t GetWramPosition();

void Serialize(Serializer &s) override;
};
1 change: 1 addition & 0 deletions Core/SNES/SnesConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions Core/SNES/SnesMemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Core/SNES/SnesMemoryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,7 @@ class SnesMemoryManager : public ISerializable
bool IsRegister(uint32_t cpuAddress);
bool IsWorkRam(uint32_t cpuAddress);

uint32_t GetWramPosition();

void Serialize(Serializer &s) override;
};
2 changes: 2 additions & 0 deletions Core/SNES/SnesState.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ struct SnesState
SnesDmaControllerState Dma;
InternalRegisterState InternalRegs;
AluState Alu;

uint32_t WramPosition;
};
2 changes: 2 additions & 0 deletions UI/Debugger/ViewModels/RegisterViewerWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,8 @@ private RegisterViewerTab GetSnesCpuTab(ref SnesState state)
AluState alu = state.Alu;

List<RegEntry> entries = new List<RegEntry>() {
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),
Expand Down
2 changes: 2 additions & 0 deletions UI/Interop/DebugState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,8 @@ public struct SnesState : BaseState
public SnesDmaControllerState Dma;
public InternalRegisterState InternalRegs;
public AluState Alu;

public UInt32 WramPosition;
}

public struct EmptyPpuToolsState : BaseState
Expand Down

0 comments on commit bccdfa2

Please sign in to comment.