Skip to content

Commit

Permalink
Improvements in HuC6270 debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jul 24, 2024
1 parent 83592f7 commit dbf8942
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 117 deletions.
6 changes: 4 additions & 2 deletions platforms/shared/desktop/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ void config_read(void)
config_debug.show_screen = read_bool("Debug", "Screen", true);
config_debug.show_memory = read_bool("Debug", "Memory", true);
config_debug.show_processor = read_bool("Debug", "Processor", true);
config_debug.show_huc6260 = read_bool("Debug", "HuC6260", false);
config_debug.show_huc6260_info = read_bool("Debug", "HuC6260Info", false);
config_debug.show_huc6260_palettes = read_bool("Debug", "HuC6260Palettes", false);
config_debug.show_huc6270_registers = read_bool("Debug", "HuC6270Registers", false);
config_debug.show_huc6270_background = read_bool("Debug", "HuC6270Background", false);
config_debug.show_huc6270_sprites = read_bool("Debug", "HuC6270Sprites", false);
Expand Down Expand Up @@ -212,7 +213,8 @@ void config_write(void)
write_bool("Debug", "Screen", config_debug.show_screen);
write_bool("Debug", "Memory", config_debug.show_memory);
write_bool("Debug", "Processor", config_debug.show_processor);
write_bool("Debug", "HuC6260", config_debug.show_huc6260);
write_bool("Debug", "HuC6260Info", config_debug.show_huc6260_info);
write_bool("Debug", "HuC6260Palettes", config_debug.show_huc6260_palettes);
write_bool("Debug", "HuC6270Registers", config_debug.show_huc6270_registers);
write_bool("Debug", "HuC6270Background", config_debug.show_huc6270_background);
write_bool("Debug", "HuC6270Sprites", config_debug.show_huc6270_sprites);
Expand Down
3 changes: 2 additions & 1 deletion platforms/shared/desktop/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ struct config_Debug
bool show_disassembler = true;
bool show_processor = true;
bool show_memory = true;
bool show_huc6260 = false;
bool show_huc6260_info = false;
bool show_huc6260_palettes = false;
bool show_huc6270_registers = false;
bool show_huc6270_background = false;
bool show_huc6270_sprites = false;
Expand Down
6 changes: 4 additions & 2 deletions platforms/shared/desktop/gui_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ void gui_debug_windows(void)
gui_debug_window_memory();
if (config_debug.show_disassembler)
gui_debug_window_disassembler();
if (config_debug.show_huc6260)
gui_debug_window_huc6260();
if (config_debug.show_huc6260_info)
gui_debug_window_huc6260_info();
if (config_debug.show_huc6260_palettes)
gui_debug_window_huc6260_palettes();
if (config_debug.show_huc6270_registers)
gui_debug_window_huc6270_registers();
if (config_debug.show_huc6270_background)
Expand Down
156 changes: 105 additions & 51 deletions platforms/shared/desktop/gui_debug_huc6260.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,91 +29,145 @@

static ImVec4 color_333_to_float(u16 color);

void gui_debug_window_huc6260(void)
void gui_debug_window_huc6260_info(void)
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 8.0f);
ImGui::SetNextWindowPos(ImVec2(6, 31), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(401, 641), ImGuiCond_FirstUseEver);
ImGui::Begin("HuC6260", &config_debug.show_huc6260);
ImGui::Begin("HuC6260 Info", &config_debug.show_huc6260_info);

ImGui::PushFont(gui_default_font);

GeargrafxCore* core = emu_get_core();
HuC6260* huc6260 = core->GetHuC6260();
HuC6260::HuC6260_State* huc6260_state = huc6260->GetState();
u16* color_table = huc6260->GetColorTable();

ImGui::TextColored(magenta, "CR "); ImGui::SameLine();
ImGui::TextColored(magenta, "SPEED"); ImGui::SameLine();
const char* speed[] = { "10.8 MHz", "7.16 MHz", "5.36 MHz" };
ImGui::TextColored(green, "%s", speed[huc6260->GetSpeed()]);

ImGui::TextColored(magenta, "CR "); ImGui::SameLine();
ImGui::Text("$%02X (" BYTE_TO_BINARY_PATTERN_SPACED ")", *huc6260_state->CR, BYTE_TO_BINARY(*huc6260_state->CR));

ImGui::TextColored(magenta, "CTA "); ImGui::SameLine();
ImGui::TextColored(magenta, "CTA "); ImGui::SameLine();
ImGui::Text("$%04X (" BYTE_TO_BINARY_PATTERN_SPACED " " BYTE_TO_BINARY_PATTERN_SPACED ")", *huc6260_state->CTA, BYTE_TO_BINARY(*huc6260_state->CTA >> 8), BYTE_TO_BINARY(*huc6260_state->CTA & 0xFF));

ImGui::TextColored(magenta, "B&W "); ImGui::SameLine();
ImGui::TextColored(IsSetBit(*huc6260_state->CR, 7) ? green : gray, "%s", IsSetBit(*huc6260_state->CR, 7) ? "ON" : "OFF");

ImGui::TextColored(magenta, "BLUR "); ImGui::SameLine();
ImGui::TextColored(magenta, "BLUR "); ImGui::SameLine();
ImGui::TextColored(IsSetBit(*huc6260_state->CR, 2) ? green : gray, "%s", IsSetBit(*huc6260_state->CR, 2) ? "ON" : "OFF");

ImGui::TextColored(magenta, "SPEED "); ImGui::SameLine();
const char* speed[] = { "10.8 MHz", "7.16 MHz", "5.36 MHz" };
ImGui::TextColored(green, "%s", speed[huc6260->GetSpeed()]);
ImGui::TextColored(magenta, "B&W "); ImGui::SameLine();
ImGui::TextColored(IsSetBit(*huc6260_state->CR, 7) ? green : gray, "%s", IsSetBit(*huc6260_state->CR, 7) ? "ON" : "OFF");

ImGui::NewLine();
ImGui::PopFont();

ImGui::PushStyleColor(ImGuiCol_Text, cyan);
ImGui::SeparatorText("BACKGROUND PALETTE");
ImGui::PopStyleColor();
ImGui::End();
ImGui::PopStyleVar();
}

void gui_debug_window_huc6260_palettes(void)
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 8.0f);
ImGui::SetNextWindowPos(ImVec2(6, 31), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(401, 641), ImGuiCond_FirstUseEver);
ImGui::Begin("HuC6260 Palettes", &config_debug.show_huc6260_palettes);

ImGui::NewLine(); //ImGui::Text(""); ImGui::SameLine(0,0);
GeargrafxCore* core = emu_get_core();
HuC6260* huc6260 = core->GetHuC6260();
u16* color_table = huc6260->GetColorTable();

for (int row = 0; row < 32; row++)
if (ImGui::BeginTabBar("##palette_tabs", ImGuiTabBarFlags_None))
{
for (int col = 0; col < 16; col++)
if (ImGui::BeginTabItem("Background", NULL, ImGuiTabItemFlags_None))
{
int i = row * 16 + col;
if (col == 0)
ImGui::PushFont(gui_default_font);

for (int row = 0; row < 16; row++)
{
ImGui::TextColored(white, "%03X:", i); ImGui::SameLine();
for (int col = 0; col < 16; col++)
{
int i = row * 16 + col;
if (col == 0)
{
ImGui::TextColored(white, "%03X:", i); ImGui::SameLine();
}

u16 color = color_table[i];
ImVec4 float_color = color_333_to_float(color);
char id[16];
sprintf(id, "##pal_%d_%d", row, col);
ImGui::ColorEdit3(id, (float*)&float_color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip);
if (col != 15)
ImGui::SameLine(0, 10);
}

ImGui::Text(" "); ImGui::SameLine(0,0);

for (int col = 0; col < 16; col++)
{
u16 color = color_table[row * 16 + col];
u8 color_green = (color >> 6) & 0x07;
u8 color_red = (color >> 3) & 0x07;
u8 color_blue = color & 0x07;

ImGui::TextColored(green, "%01X", color_green); ImGui::SameLine(0,0);
ImGui::TextColored(red, "%01X", color_red); ImGui::SameLine(0,0);
ImGui::TextColored(blue, "%01X", color_blue); ImGui::SameLine();
}

ImGui::NewLine();
}

u16 color = color_table[i];
ImVec4 float_color = color_333_to_float(color);
char id[16];
sprintf(id, "##pal_%d_%d", row, col);
ImGui::ColorEdit3(id, (float*)&float_color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip);
if (col != 15)
ImGui::SameLine(0, 10);
ImGui::PopFont();
ImGui::EndTabItem();
}

ImGui::Text(" "); ImGui::SameLine(0,0);

for (int col = 0; col < 16; col++)
if (ImGui::BeginTabItem("Sprites", NULL, ImGuiTabItemFlags_None))
{
u16 color = color_table[row * 16 + col];
u8 color_green = (color >> 6) & 0x07;
u8 color_red = (color >> 3) & 0x07;
u8 color_blue = color & 0x07;

ImGui::TextColored(green, "%01X", color_green); ImGui::SameLine(0,0);
ImGui::TextColored(red, "%01X", color_red); ImGui::SameLine(0,0);
ImGui::TextColored(blue, "%01X", color_blue); ImGui::SameLine();
}
ImGui::PushFont(gui_default_font);

if (row == 15)
{
ImGui::NewLine();
ImGui::NewLine();
ImGui::PushStyleColor(ImGuiCol_Text, cyan);
ImGui::SeparatorText("SPRITES PALETTE");
ImGui::PopStyleColor();
for (int row = 16; row < 32; row++)
{
for (int col = 0; col < 16; col++)
{
int i = row * 16 + col;
if (col == 0)
{
ImGui::TextColored(white, "%03X:", i); ImGui::SameLine();
}

u16 color = color_table[i];
ImVec4 float_color = color_333_to_float(color);
char id[16];
sprintf(id, "##pal_%d_%d", row, col);
ImGui::ColorEdit3(id, (float*)&float_color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip);
if (col != 15)
ImGui::SameLine(0, 10);
}

ImGui::Text(" "); ImGui::SameLine(0,0);

for (int col = 0; col < 16; col++)
{
u16 color = color_table[row * 16 + col];
u8 color_green = (color >> 6) & 0x07;
u8 color_red = (color >> 3) & 0x07;
u8 color_blue = color & 0x07;

ImGui::TextColored(green, "%01X", color_green); ImGui::SameLine(0,0);
ImGui::TextColored(red, "%01X", color_red); ImGui::SameLine(0,0);
ImGui::TextColored(blue, "%01X", color_blue); ImGui::SameLine();
}

ImGui::NewLine();
}

ImGui::PopFont();
ImGui::EndTabItem();
}

ImGui::NewLine(); //ImGui::Text(""); ImGui::SameLine(0,0);
ImGui::EndTabBar();
}

ImGui::PopFont();

ImGui::End();
ImGui::PopStyleVar();
}
Expand Down
3 changes: 2 additions & 1 deletion platforms/shared/desktop/gui_debug_huc6260.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
#define EXTERN extern
#endif

EXTERN void gui_debug_window_huc6260(void);
EXTERN void gui_debug_window_huc6260_info(void);
EXTERN void gui_debug_window_huc6260_palettes(void);

#undef GUI_DEBUG_HUC6260_IMPORT
#undef EXTERN
Expand Down
Loading

0 comments on commit dbf8942

Please sign in to comment.