Debugger: Copy info based on CHR ROM vs RAM (right-click in ppu viewer)

This commit is contained in:
Souryo 2017-08-13 20:45:36 -04:00
parent 70a9b85d4c
commit 47026c3ba8
8 changed files with 38 additions and 6 deletions

View File

@ -738,6 +738,11 @@ int32_t Debugger::GetAbsoluteAddress(uint32_t addr)
return _mapper->ToAbsoluteAddress(addr);
}
int32_t Debugger::GetAbsoluteChrAddress(uint32_t addr)
{
return _mapper->ToAbsoluteChrAddress(addr);
}
void Debugger::SetNextStatement(uint16_t addr)
{
if(_currentReadAddr) {

View File

@ -168,6 +168,7 @@ public:
int32_t GetRelativeAddress(uint32_t addr, AddressType type);
int32_t GetAbsoluteAddress(uint32_t addr);
int32_t GetAbsoluteChrAddress(uint32_t addr);
void GetAbsoluteAddressAndType(uint32_t relativeAddr, AddressTypeInfo* info);
shared_ptr<Profiler> GetProfiler();

View File

@ -250,6 +250,11 @@ void MemoryDumper::GetChrBank(int bankIndex, uint32_t* frameBuffer, uint8_t pale
int bank = bankIndex - 2;
uint32_t baseAddr = bank * 0x1000;
uint32_t chrSize = _mapper->GetMemorySize(isChrRam ? DebugMemoryType::ChrRam : DebugMemoryType::ChrRom);
if(baseAddr + 0xFFF >= chrSize) {
//Out of range, return to prevent crash
return;
}
vector<uint8_t> chrData(chrSize, 0);
_mapper->CopyMemory(isChrRam ? DebugMemoryType::ChrRam : DebugMemoryType::ChrRom, chrData.data());

View File

@ -145,6 +145,7 @@ namespace Mesen.GUI.Debugger.Controls
}
this.cboChrSelection.SelectedIndex = this.cboChrSelection.Items.Count > index && index >= 0 ? index : 0;
this._chrSelection = this.cboChrSelection.SelectedIndex;
}
}
@ -432,9 +433,15 @@ namespace Mesen.GUI.Debugger.Controls
int tileIndex = GetLargeSpriteIndex(_tileIndex);
bool isChrRam = InteropEmu.DebugGetMemorySize(DebugMemoryType.ChrRom) == 0;
StringBuilder sb = new StringBuilder();
for(int i = 0; i < 16; i++) {
sb.Append(InteropEmu.DebugGetMemoryValue(ppuMemory ? DebugMemoryType.PpuMemory : DebugMemoryType.ChrRom, (UInt32)(baseAddress + tileIndex * 16 + i)).ToString("X2"));
if(isChrRam) {
for(int i = 0; i < 16; i++) {
sb.Append(InteropEmu.DebugGetMemoryValue(ppuMemory ? DebugMemoryType.PpuMemory : DebugMemoryType.ChrRom, (UInt32)(baseAddress + tileIndex * 16 + i)).ToString("X2"));
}
} else {
int absoluteTileIndex = ppuMemory ? InteropEmu.DebugGetAbsoluteChrAddress((uint)(baseAddress+tileIndex*16))/16 : (baseAddress / 16 + tileIndex);
sb.Append(absoluteTileIndex.ToString());
}
sb.Append(",");
for(int i = 0; i < 4; i++) {

View File

@ -243,9 +243,15 @@ namespace Mesen.GUI.Debugger.Controls
int bgAddr = state.PPU.ControlFlags.BackgroundPatternAddr;
int tileAddr = bgAddr + tileIndex * 16;
bool isChrRam = InteropEmu.DebugGetMemorySize(DebugMemoryType.ChrRom) == 0;
StringBuilder sb = new StringBuilder();
for(int i = 0; i < 16; i++) {
sb.Append(InteropEmu.DebugGetMemoryValue(DebugMemoryType.PpuMemory, (uint)(tileAddr + i)).ToString("X2"));
if(isChrRam) {
for(int i = 0; i < 16; i++) {
sb.Append(InteropEmu.DebugGetMemoryValue(DebugMemoryType.PpuMemory, (uint)(tileAddr + i)).ToString("X2"));
}
} else {
int absoluteTileIndex = InteropEmu.DebugGetAbsoluteChrAddress((uint)tileAddr) / 16;
sb.Append(absoluteTileIndex.ToString());
}
sb.Append(",");
for(int i = 0; i < 4; i++) {

View File

@ -195,9 +195,15 @@ namespace Mesen.GUI.Debugger.Controls
tileAddr = _spritePatternAddr + (tileIndex << 4);
}
bool isChrRam = InteropEmu.DebugGetMemorySize(DebugMemoryType.ChrRom) == 0;
StringBuilder sb = new StringBuilder();
for(int i = 0; i < 16; i++) {
sb.Append(InteropEmu.DebugGetMemoryValue(DebugMemoryType.PpuMemory, (UInt32)(tileAddr + i)).ToString("X2"));
if(isChrRam) {
for(int i = 0; i < 16; i++) {
sb.Append(InteropEmu.DebugGetMemoryValue(DebugMemoryType.PpuMemory, (UInt32)(tileAddr + i)).ToString("X2"));
}
} else {
int absoluteTileIndex = InteropEmu.DebugGetAbsoluteChrAddress((uint)tileAddr)/16;
sb.Append(absoluteTileIndex.ToString());
}
sb.Append(",FF");
for(int i = 1; i < 4; i++) {

View File

@ -197,6 +197,7 @@ namespace Mesen.GUI
[DllImport(DLLPath)] public static extern Int32 DebugGetRelativeAddress(UInt32 absoluteAddr, AddressType type);
[DllImport(DLLPath)] public static extern Int32 DebugFindSubEntryPoint(UInt16 relativeAddr);
[DllImport(DLLPath)] public static extern Int32 DebugGetAbsoluteAddress(UInt32 relativeAddr);
[DllImport(DLLPath)] public static extern Int32 DebugGetAbsoluteChrAddress(UInt32 relativeAddr);
[DllImport(DLLPath)] public static extern Int32 DebugGetMemorySize(DebugMemoryType type);
[DllImport(DLLPath)] public static extern Byte DebugGetMemoryValue(DebugMemoryType type, UInt32 address);
[DllImport(DLLPath)] public static extern void DebugSetMemoryValue(DebugMemoryType type, UInt32 address, byte value);

View File

@ -67,6 +67,7 @@ extern "C"
DllExport int32_t __stdcall DebugGetRelativeAddress(uint32_t addr, AddressType type) { return GetDebugger()->GetRelativeAddress(addr, type); }
DllExport int32_t __stdcall DebugGetAbsoluteAddress(uint32_t addr) { return GetDebugger()->GetAbsoluteAddress(addr); }
DllExport int32_t __stdcall DebugGetAbsoluteChrAddress(uint32_t addr) { return GetDebugger()->GetAbsoluteChrAddress(addr); }
DllExport void __stdcall DebugGetAbsoluteAddressAndType(uint32_t relativeAddr, AddressTypeInfo* info) { return GetDebugger()->GetAbsoluteAddressAndType(relativeAddr, info); }
DllExport bool __stdcall DebugLoadCdlFile(char* cdlFilepath) { return GetDebugger()->LoadCdlFile(cdlFilepath); }