Tooltip in comment now works!

This commit is contained in:
irisz64
2025-07-31 17:25:22 +02:00
parent 1d117bf96b
commit 79de6f20b6
4 changed files with 42 additions and 18 deletions

View File

@@ -185,11 +185,13 @@ Disassembler::DisassemblyResult Disassembler::DisassembleDetailed(const u32 addr
switch (operand.type) { switch (operand.type) {
case MIPS_OP_IMM: case MIPS_OP_IMM:
return {std::format("#{:X}, ", operand.is_unsigned ? operand.uimm : operand.imm)}; return {std::format("#{:X}, ", operand.is_unsigned ? operand.uimm : operand.imm)};
case MIPS_OP_MEM: case MIPS_OP_MEM: {
auto base = CapstoneToRegValue<std::optional<u64>>(operand.mem.base);
return { return {
std::format("{}(0x{:X}), ", CapstoneToRegValue<std::string>(operand.mem.base), operand.mem.disp), std::format("{}(0x{:X}), ", CapstoneToRegValue<std::string>(operand.mem.base), operand.mem.disp),
CapstoneToRegValue<std::optional<u64>>(operand.mem.base).value() + (s16)operand.mem.disp, base.has_value() ? base.value() + (s16)operand.mem.disp : 0xFFFF'FFFF'FFFF'FFFFull,
}; };
}
case MIPS_OP_REG: case MIPS_OP_REG:
return {std::format("{}, ", CapstoneToRegValue<std::string>(operand.reg))}; return {std::format("{}, ", CapstoneToRegValue<std::string>(operand.reg))};
default: default:

View File

@@ -399,7 +399,7 @@ void PI::BusWrite<false>(u32 addr, u64 val) {
warn("Writing dword 0x{:016X} to address 0x{:08X} in unsupported region: REGION_PI_ROM", val, addr); warn("Writing dword 0x{:016X} to address 0x{:08X} in unsupported region: REGION_PI_ROM", val, addr);
break; break;
default: default:
panic("Should never end up here! Access to address %08X which did not match any PI bus regions!", addr); panic("Should never end up here! Access to address {:08X} which did not match any PI bus regions!", addr);
} }
} }

View File

@@ -52,8 +52,12 @@ u32 VI::Read(const u32 paddr) const {
return xscale.raw; return xscale.raw;
case 0x04400034: case 0x04400034:
return yscale.raw; return yscale.raw;
case 0x04400038:
return 0;
case 0x0440003C:
return 0;
default: default:
panic("Unimplemented VI[%08X] read", paddr); panic("Unimplemented VI[{:08X}] read", paddr);
} }
} }
@@ -111,8 +115,12 @@ void VI::Write(const u32 paddr, const u32 val) {
case 0x04400034: case 0x04400034:
yscale.raw = val; yscale.raw = val;
break; break;
case 0x04400038:
break;
case 0x0440003C:
break;
default: default:
panic("Unimplemented VI[%08X] write (%08X)", paddr, val); panic("Unimplemented VI[{:08X}] write ({:08X})", paddr, val);
} }
} }
} // namespace n64 } // namespace n64

View File

@@ -67,33 +67,44 @@ void CommentFunc(s64, s64, Disassembler::DisassemblyResult& disasm) {
} }
ImGui::TextColored(ImColor(0xff71efe5), "%s", std::format("{}", disasm.GetFormattedComment()).c_str()); ImGui::TextColored(ImColor(0xff71efe5), "%s", std::format("{}", disasm.GetFormattedComment()).c_str());
if(!ImGui::BeginItemTooltip())
u64 vaddr = disasm.GetResolvedAddressFromComment();
if(vaddr == 0xFFFF'FFFF'FFFF'FFFFull)
return; return;
ImGui::Text("%s", std::format("Memory contents @ 0x{:016X}", disasm.address).c_str()); if(!ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_ForTooltip))
ImGui::BeginTable("##memoryContents", 16); return;
for(int col = 0; col < 16; col++)
if(!ImGui::BeginTooltip())
return;
ImGui::Text("%s", std::format("Memory contents @ 0x{:016X}", vaddr).c_str());
if(!ImGui::BeginTable("##memoryContents", 16))
return;
for(u32 col = 0; col < 16; col++)
ImGui::TableSetupColumn(std::format("##hexCol{}", col).c_str()); ImGui::TableSetupColumn(std::format("##hexCol{}", col).c_str());
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
for(int row = 0; row < 16; row++) { for(u32 row = 0; row < 16; row++) {
ImGui::TableNextRow(); ImGui::TableNextRow();
for(int col = 0; col < 16; col+=4) { for(u32 col = 0; col < 16; col+=4) {
u32 paddr; u32 paddr;
if(!regs.cop0.MapVAddr(n64::Cop0::LOAD, disasm.GetResolvedAddressFromComment(), paddr)) if(!regs.cop0.MapVAddr(n64::Cop0::LOAD, vaddr+row*0x10+col, paddr))
continue; continue;
u32 val = mem.Read<u32>(paddr); u32 val = mem.Read<u32>(paddr);
ImGui::TableSetColumnIndex(col+0); ImGui::TableSetColumnIndex(col+0);
ImGui::Text("%02X", val >> 24); ImGui::Text("%02X", (val >> 24) & 0xff);
ImGui::TableSetColumnIndex(col+1); ImGui::TableSetColumnIndex(col+1);
ImGui::Text("%02X", val >> 16); ImGui::Text("%02X", (val >> 16) & 0xff);
ImGui::TableSetColumnIndex(col+2); ImGui::TableSetColumnIndex(col+2);
ImGui::Text("%02X", val >> 8); ImGui::Text("%02X", (val >> 8) & 0xff);
ImGui::TableSetColumnIndex(col+3); ImGui::TableSetColumnIndex(col+3);
ImGui::Text("%02X", val >> 0); ImGui::Text("%02X", (val >> 0) & 0xff);
} }
} }
@@ -112,7 +123,8 @@ bool Debugger::render() {
int step = 4, stepFast = 256; int step = 4, stepFast = 256;
static bool followPC = true; static bool followPC = true;
ImGui::Begin("Debugger", &enabled); if(!ImGui::Begin("Debugger", &enabled))
return false;
ImGui::BeginDisabled(followPC); ImGui::BeginDisabled(followPC);
ImGui::InputScalar("Address", ImGuiDataType_S64, (void*)&startAddr, (void*)&step, (void*)&stepFast, "%016lX", ImGuiInputTextFlags_CharsHexadecimal); ImGui::InputScalar("Address", ImGuiDataType_S64, (void*)&startAddr, (void*)&step, (void*)&stepFast, "%016lX", ImGuiInputTextFlags_CharsHexadecimal);
@@ -134,7 +146,9 @@ bool Debugger::render() {
core.ToggleBreakpoint(startAddr); core.ToggleBreakpoint(startAddr);
} }
ImGui::BeginTable("Disassembly", columns.size(), ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody); if(!ImGui::BeginTable("Disassembly", columns.size(), ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody))
return false;
for(int i = 0; i < columns.size(); i++) for(int i = 0; i < columns.size(); i++)
ImGui::TableSetupColumn(columns[i].name); ImGui::TableSetupColumn(columns[i].name);