Skip to content

Commit

Permalink
Debugger improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jan 14, 2024
1 parent e8f6dc0 commit b0a6164
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions platforms/desktop-shared/gui_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ struct DisassmeblerLine
};

static MemoryEditor mem_edit;
static ImVec4 cyan = ImVec4(0.0f,1.0f,1.0f,1.0f);
static ImVec4 cyan = ImVec4(0.1f,0.9f,0.9f,1.0f);
static ImVec4 magenta = ImVec4(1.0f,0.502f,0.957f,1.0f);
static ImVec4 yellow = ImVec4(1.0f,1.0f,0.0f,1.0f);
static ImVec4 red = ImVec4(1.0f,0.149f,0.447f,1.0f);
static ImVec4 green = ImVec4(0.0f,1.0f,0.0f,1.0f);
static ImVec4 yellow = ImVec4(1.0f,0.90f,0.05f,1.0f);
static ImVec4 orange = ImVec4(0.992f,0.592f,0.122f,1.0f);
static ImVec4 red = ImVec4(0.976f,0.149f,0.447f,1.0f);
static ImVec4 green = ImVec4(0.1f,0.9f,0.1f,1.0f);
static ImVec4 violet = ImVec4(0.682f,0.506f,1.0f,1.0f);
static ImVec4 blue = ImVec4(0.2f,0.4f,1.0f,1.0f);
static ImVec4 white = ImVec4(1.0f,1.0f,1.0f,1.0f);
static ImVec4 gray = ImVec4(0.5f,0.5f,0.5f,1.0f);
static ImVec4 dark_gray = ImVec4(0.1f,0.1f,0.1f,1.0f);
Expand Down Expand Up @@ -82,6 +85,7 @@ static void add_breakpoint_mem(void);
static void request_goto_address(u16 addr);
static ImVec4 color_444_to_float(u16 color);
static ImVec4 color_222_to_float(u8 color);
static bool is_return_instruction(u8 opcode1, u8 opcode2);

void gui_debug_windows(void)
{
Expand Down Expand Up @@ -726,6 +730,14 @@ static void debug_window_disassembler(void)
ImGui::TextColored(white, "%s", vec[item].record->name);
}

bool is_ret = is_return_instruction(vec[item].record->opcodes[0], vec[item].record->opcodes[1]);
if (is_ret)
{
ImGui::PushStyleColor(ImGuiCol_Separator, (vec[item].record->opcodes[0] == 0xC9) ? gray : dark_gray);
ImGui::Separator();
ImGui::PopStyleColor();
}

ImGui::PopID();
}
}
Expand All @@ -752,7 +764,7 @@ static void debug_window_processor(void)

ImGui::Separator();

ImGui::TextColored(magenta, " S Z Y H X P N C");
ImGui::TextColored(orange, " S Z Y H X P N C");
ImGui::Text(" " BYTE_TO_BINARY_PATTERN_ALL_SPACED, BYTE_TO_BINARY(proc_state->AF->GetLow()));

ImGui::Columns(2, "registers");
Expand Down Expand Up @@ -1750,3 +1762,27 @@ static void request_goto_address(u16 address)
goto_address_requested = true;
goto_address_target = address;
}

static bool is_return_instruction(u8 opcode1, u8 opcode2)
{
switch (opcode1)
{
case 0xC9: // RET
case 0xC0: // RET NZ
case 0xC8: // RET Z
case 0xD0: // RET NC
case 0xD8: // RET C
case 0xE0: // RET PO
case 0xE8: // RET PE
case 0xF0: // RET P
case 0xF8: // RET M
return true;
case 0xED: // Extended instructions
if (opcode2 == 0x45 || opcode2 == 0x4D) // RETN, RETI
return true;
else
return false;
default:
return false;
}
}

0 comments on commit b0a6164

Please sign in to comment.