From d372609bdcde013e8fbabbb8dd07659cf4725164 Mon Sep 17 00:00:00 2001 From: PugsyMAME Date: Sun, 26 May 2024 14:39:15 +0100 Subject: [PATCH] Add memory contents to "Addr=" string in debugger Tweaks the format of the addr= string in the debugger/trace so that it includes the memory contents. It will also take the 2nd character of the opcode and if it's b or h it will size it accordingly. so addr=800BC2D0 becomes addr=800BC2D0[00000000] or addr=800BC2D0[0000] or addr=800BC2D0[00] This change amongst other things will facilitate a widescreen cheat scanner, that will take a lot of the work away from making widescreen cheats. --- src/core/cpu_disasm.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/core/cpu_disasm.cpp b/src/core/cpu_disasm.cpp index f9abf0a9a..90e14240f 100644 --- a/src/core/cpu_disasm.cpp +++ b/src/core/cpu_disasm.cpp @@ -434,8 +434,35 @@ void CPU::FormatComment(SmallStringBase* dest, const Instruction inst, u32 pc, c else if (std::strncmp(str, "offsetrs", 8) == 0) { const s32 offset = static_cast(inst.i.imm_sext32()); - dest->append_format("{}addr={:08X}", dest->empty() ? "" : ", ", - regs->r[static_cast(inst.i.rs.GetValue())] + offset); + const VirtualMemoryAddress address = (regs->r[static_cast(inst.i.rs.GetValue())] + offset); + + if (!dest->empty()) + dest->append_format(", "); + + if (inst.op == InstructionOp::lb || inst.op == InstructionOp::lbu) + { + u8 data = 0; + CPU::SafeReadMemoryByte(address, &data); + dest->append_format("addr={:08X}[{:02X}]", address, data); + } + else if (inst.op == InstructionOp::lh || inst.op == InstructionOp::lhu) + { + u16 data = 0; + CPU::SafeReadMemoryHalfWord(address, &data); + dest->append_format("addr={:08X}[{:04X}]", address, data); + } + else if (inst.op == InstructionOp::lw || (inst.op >= InstructionOp::lwc0 && inst.op <= InstructionOp::lwc3) || + inst.op == InstructionOp::lwl || inst.op == InstructionOp::lwr) + { + u32 data = 0; + CPU::SafeReadMemoryWord(address, &data); + dest->append_format("addr={:08X}[{:08X}]", address, data); + } + else + { + dest->append_format("addr={:08X}", address); + } + str += 8; } else if (std::strncmp(str, "jt", 2) == 0)