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 1afc7dd commit 043b066
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
47 changes: 42 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 @@ -80,6 +83,7 @@ static void add_symbol(const char* line);
static void add_breakpoint_cpu(void);
static void add_breakpoint_mem(void);
static void request_goto_address(u16 addr);
static bool is_return_instruction(u8 opcode1, u8 opcode2);

void gui_debug_windows(void)
{
Expand Down Expand Up @@ -642,6 +646,15 @@ static void debug_window_disassembler(void)
ImGui::SameLine();
ImGui::TextColored(color_name, "%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 @@ -668,7 +681,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 @@ -1434,3 +1447,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;
}
}
1 change: 1 addition & 0 deletions platforms/desktop-shared/imgui/imgui_memory_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#include <stdio.h> // sprintf, scanf
#include <stdint.h> // uint8_t, etc.
#include "imgui.h"

#ifdef _MSC_VER
#define _PRISizeT "I"
Expand Down

0 comments on commit 043b066

Please sign in to comment.