Things to neat up that I noticed with Hazel <3

This commit is contained in:
SimoZ64
2025-07-29 22:46:34 +02:00
parent 01d05ca8fd
commit ff4cd66bdb
14 changed files with 104 additions and 72 deletions

View File

@@ -14,28 +14,17 @@ bool Debugger::render() {
ImGui::SameLine();
ImGui::Checkbox("Follow program counter:", &followPC);
if(followPC)
startAddr = core.cpu->GetRegs().oldPC - 64; // TODO: arbitrary???
startAddr = core.cpu->GetRegs().pc - 128; // TODO: arbitrary???
if(ImGui::BeginTable("Disassembly", 3, ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("Address");
ImGui::TableSetupColumn("Mnemonic");
ImGui::TableSetupColumn("Instruction");
ImGui::TableSetupColumn("Comment");
ImGui::TableHeadersRow();
for(u64 addr = startAddr; addr < startAddr + MAX_LINES_OF_DISASM * sizeof(u32); addr += sizeof(u32)) {
auto disasm = core.cpu->Disassemble(addr);
std::string op_str;
for(int i = 0; i < 3; i++) {
if(i < 2) {
if(!disasm.ops[i].empty()) {
op_str += disasm.ops[i];
if(!disasm.ops[i+1].empty()) op_str += ", ";
}
} else {
if(!disasm.ops[i].empty()) op_str += disasm.ops[i];
}
}
auto isPc = addr == core.cpu->GetRegs().oldPC;
auto disasm = Disassembler::GetInstance().Disassemble(addr);
auto isPc = addr == core.cpu->GetRegs().pc;
if(isPc) {
ImGui::PushStyleColor(ImGuiCol_TableRowBg, 0x809a9ade);
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, 0x807777bf);
@@ -45,9 +34,25 @@ bool Debugger::render() {
ImGui::TableSetColumnIndex(0);
ImGui::TextColored(ImColor(0xffeaefb6), "%s", std::format("{:016X}:", disasm.address).c_str());
ImGui::TableSetColumnIndex(1);
ImGui::TextColored(ImColor(0xffcbf1ae), "%s", std::format("{} {}", disasm.mnemonic, op_str).c_str());
ImGui::TextColored(ImColor(0xffcbf1ae), "%s", std::format("{} ", disasm.mnemonic).c_str());
ImGui::SameLine(0, 0);
for(int i = 0; i < 3; i++) {
if(i < 2) {
if(!disasm.ops[i].str.empty()) {
std::string op_str = disasm.ops[i].str;
if(!disasm.ops[i+1].str.empty()) op_str += ", ";
ImGui::TextColored(ImColor(disasm.ops[i].color), "%s", op_str.c_str());
ImGui::SameLine(0, 0);
}
} else {
if(!disasm.ops[i].str.empty()) {
ImGui::TextColored(ImColor(disasm.ops[i].color), "%s", disasm.ops[i].str.c_str());
ImGui::SameLine(0, 0);
}
}
}
ImGui::TableSetColumnIndex(2);
ImGui::TextColored(ImColor(0xff71efe5), "%s", std::format("{}", "// no comments for now!").c_str());
ImGui::TextColored(ImColor(0xff71efe5), "%s", std::format("{}", disasm.comment).c_str());
} else {
ImGui::TableSetColumnIndex(0);
ImGui::TextColored(ImColor(0xffeaefb6), "????????????????");
@@ -61,6 +66,11 @@ bool Debugger::render() {
ImGui::PopStyleColor();
}
}
if(ImGui::TableGetHoveredColumn() == 2) {
// do the thing with the little fucking hover popup that shows the memory view
}
ImGui::EndTable();
}
ImGui::End();