diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index 4a1c97fd..48434d74 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -275,6 +275,12 @@ uint32_t Debugger::GetMemoryState(DebugMemoryType type, uint8_t *buffer) } return 0x4000; + case DebugMemoryType::PaletteMemory: + for(int i = 0; i <= 0x1F; i++) { + buffer[i] = _ppu->ReadPaletteRAM(i); + } + return 0x20; + case DebugMemoryType::SpriteMemory: memcpy(buffer, _ppu->GetSpriteRam(), 0x100); return 0x100; diff --git a/Core/Debugger.h b/Core/Debugger.h index 268dc84e..3c680ad7 100644 --- a/Core/Debugger.h +++ b/Core/Debugger.h @@ -23,10 +23,11 @@ enum class DebugMemoryType { CpuMemory = 0, PpuMemory = 1, - SpriteMemory = 2, - SecondarySpriteMemory = 3, - PrgRom = 4, - ChrRom = 5, + PaletteMemory = 2, + SpriteMemory = 3, + SecondarySpriteMemory = 4, + PrgRom = 5, + ChrRom = 6, }; class Debugger diff --git a/Core/PPU.cpp b/Core/PPU.cpp index f7907fd9..9064bbf7 100644 --- a/Core/PPU.cpp +++ b/Core/PPU.cpp @@ -712,7 +712,7 @@ void PPU::StreamState(bool saving) Stream(_frameCount); Stream(_memoryReadBuffer); - StreamArray(_paletteRAM, 0x100); + StreamArray(_paletteRAM, 0x20); StreamArray(_spriteRAM, 0x100); StreamArray(_secondarySpriteRAM, 0x20); diff --git a/Core/PPU.h b/Core/PPU.h index 8e23d502..f96acf31 100644 --- a/Core/PPU.h +++ b/Core/PPU.h @@ -99,7 +99,7 @@ class PPU : public IMemoryHandler, public Snapshotable uint32_t _frameCount; uint8_t _memoryReadBuffer; - uint8_t _paletteRAM[0x100]; + uint8_t _paletteRAM[0x20]; uint8_t _spriteRAM[0x100]; uint8_t _secondarySpriteRAM[0x20]; @@ -157,7 +157,6 @@ class PPU : public IMemoryHandler, public Snapshotable uint32_t GetBGPaletteEntry(uint32_t paletteOffset, uint32_t pixel); uint32_t GetSpritePaletteEntry(uint32_t paletteOffset, uint32_t pixel); - uint8_t ReadPaletteRAM(uint16_t addr); void WritePaletteRAM(uint16_t addr, uint8_t value); void LoadTileInfo(); @@ -202,6 +201,8 @@ class PPU : public IMemoryHandler, public Snapshotable ranges.AddHandler(MemoryOperation::Write, 0x4014); } + uint8_t ReadPaletteRAM(uint16_t addr); + uint8_t ReadRAM(uint16_t addr); void WriteRAM(uint16_t addr, uint8_t value); @@ -239,7 +240,7 @@ class PPU : public IMemoryHandler, public Snapshotable { return PPU::Instance->_scanline; } - + uint8_t* GetSpriteRam() { return _spriteRAM; diff --git a/GUI.NET/Debugger/frmMemoryViewer.Designer.cs b/GUI.NET/Debugger/frmMemoryViewer.Designer.cs index 160d5258..bf8cab7d 100644 --- a/GUI.NET/Debugger/frmMemoryViewer.Designer.cs +++ b/GUI.NET/Debugger/frmMemoryViewer.Designer.cs @@ -88,6 +88,7 @@ this.cboMemoryType.Items.AddRange(new object[] { "CPU Memory", "PPU Memory", + "Palette Memory", "OAM Memory", "Secondary OAM Memory", "PRG ROM", diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index b76af3e4..c7fc1aee 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -303,10 +303,11 @@ namespace Mesen.GUI { CpuMemory = 0, PpuMemory = 1, - SpriteMemory = 2, - SecondarySpriteMemory = 3, - PrgRom = 4, - ChrRom = 5, + PaletteMemory = 2, + SpriteMemory = 3, + SecondarySpriteMemory = 4, + PrgRom = 5, + ChrRom = 6, } public class MD5Helper