Skip to content

Commit

Permalink
Fix symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jul 26, 2024
1 parent 88ae877 commit 6ab835a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 40 deletions.
5 changes: 3 additions & 2 deletions platforms/shared/desktop/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "../../../src/geargrafx.h"
#include "config.h"
#include "gui.h"
#include "gui_debug_disassembler.h"
#include "renderer.h"
#include "emu.h"

Expand Down Expand Up @@ -83,8 +84,8 @@ int application_init(const char* rom_file, const char* symbol_file)
if (IsValidPointer(symbol_file) && (strlen(symbol_file) > 0))
{
Debug("Symbol file argument: %s", symbol_file);
// gui_debug_reset_symbols();
// gui_debug_load_symbols_file(symbol_file);
gui_debug_reset_symbols();
gui_debug_load_symbols_file(symbol_file);
}

return ret;
Expand Down
31 changes: 19 additions & 12 deletions platforms/shared/desktop/gui_debug_disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,15 @@ static void prepare_drawable_lines(void)
Memory::GG_Disassembler_Record* record = memory->GetDisassemblerRecord(i);

if (IsValidPointer(record) && (record->name[0] != 0))
{

add_auto_symbol(record, i);
}

for (int i = 0; i < 0x10000; i++)
{
Memory::GG_Disassembler_Record* record = memory->GetDisassemblerRecord(i);

if (IsValidPointer(record) && (record->name[0] != 0))
{
for (long unsigned int s = 0; s < fixed_symbols.size(); s++)
{
if ((fixed_symbols[s].bank == record->bank) && (fixed_symbols[s].address == i) && show_symbols)
Expand Down Expand Up @@ -415,8 +420,12 @@ static void prepare_drawable_lines(void)
if (i == pc)
pc_pos = disassembler_lines.size();

// if (goto_address_requested && (vec[dis_size].record->address <= goto_address_target))
// goto_address_pos = dis_size;
if (goto_address_requested && (i <= goto_address_target))
{
goto_address_pos = disassembler_lines.size();
if ((goto_address_pos > 0) && disassembler_lines[goto_address_pos - 1].is_symbol)
goto_address_pos--;
}

disassembler_lines.push_back(line);
}
Expand Down Expand Up @@ -509,7 +518,7 @@ static void show_disassembly(void)
enable_bg_color = true;
bg_color = dark_yellow;
}
else if (line.record->subroutine_src && !ImGui::IsItemHovered())
else if (line.record->subroutine && !ImGui::IsItemHovered())
{
enable_bg_color = true;
bg_color = dark_green;
Expand Down Expand Up @@ -654,16 +663,14 @@ static void add_auto_symbol(Memory::GG_Disassembler_Record* record, u16 address)
s.address = address;
bool insert = false;

if (record->subroutine_dst)
{
snprintf(s.text, 64, "SUBROUTINE_%02X_%04X", record->bank, address);
insert = true;
}
else if (record->jump && !record->subroutine_src)
if (record->jump)// && !record->subroutine_src)
{
s.address = record->jump_address;
s.bank = record->jump_bank;
snprintf(s.text, 64, "LABEL_%02X_%04X", record->jump_bank, record->jump_address);
if (record->subroutine)
snprintf(s.text, 64, "SUBROUTINE_%02X_%04X", record->jump_bank, record->jump_address);
else
snprintf(s.text, 64, "LABEL_%02X_%04X", record->jump_bank, record->jump_address);
insert = true;
}
else if (record->irq > 0)
Expand Down
11 changes: 3 additions & 8 deletions platforms/shared/desktop/gui_menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ static void menu_input(void)
gamepad_configuration_item("1:", &config_input[0].gamepad_1, 0);
gamepad_configuration_item("2:", &config_input[0].gamepad_2, 0);

gui_popup_modal_gamepad(0);
gui_popup_modal_gamepad(0);

ImGui::EndMenu();
}
Expand Down Expand Up @@ -438,7 +438,7 @@ static void menu_input(void)
gamepad_configuration_item("2:", &config_input[1].gamepad_2, 1);


gui_popup_modal_gamepad(1);
gui_popup_modal_gamepad(1);

ImGui::EndMenu();
}
Expand Down Expand Up @@ -488,11 +488,6 @@ static void menu_debug(void)
if (ImGui::MenuItem("Enable", "", &config_debug.debug))
{
emu_set_overscan(config_debug.debug ? 0 : config_video.overscan);

// if (config_debug.debug)
// emu_debug_step();
// else
// emu_debug_continue();
}

ImGui::Separator();
Expand Down Expand Up @@ -588,7 +583,7 @@ static void menu_debug(void)

if (ImGui::MenuItem("Clear Symbols", "", (void*)0, config_debug.debug))
{
// gui_debug_reset_symbols();
gui_debug_reset_symbols();
}

ImGui::EndMenu();
Expand Down
19 changes: 6 additions & 13 deletions src/huc6280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ HuC6280::HuC6280()
m_timer_irq = false;
m_interrupt_disable_register = 0;
m_interrupt_request_register = 0;
m_debug_next_subroutine = false;
m_debug_next_irq = 0;
m_breakpoint_hit = false;
m_processor_state.A = &m_A;
Expand Down Expand Up @@ -99,7 +98,6 @@ void HuC6280::Reset()
m_timer_irq = false;
m_interrupt_disable_register = 0;
m_interrupt_request_register = 0;
m_debug_next_subroutine = false;
m_breakpoint_hit = false;
}

Expand Down Expand Up @@ -230,7 +228,6 @@ void HuC6280::DisassembleNextOPCode()

if (!changed && record->size != 0)
{
m_debug_next_subroutine = false;
m_debug_next_irq = 0;
return;
}
Expand All @@ -243,16 +240,9 @@ void HuC6280::DisassembleNextOPCode()
record->jump = false;
record->jump_address = 0;
record->jump_bank = 0;
record->subroutine_src = false;
record->subroutine_dst = false;
record->subroutine = false;
record->irq = 0;

if (m_debug_next_subroutine)
{
m_debug_next_subroutine = false;
record->subroutine_dst = true;
}

if (m_debug_next_irq > 0)
{
record->irq = m_debug_next_irq;
Expand Down Expand Up @@ -338,8 +328,11 @@ void HuC6280::DisassembleNextOPCode()
// BSR rr, JSR hhll
if (opcode == 0x44 || opcode == 0x20)
{
record->subroutine_src = true;
m_debug_next_subroutine = true;
u16 jump_address = Address16(m_memory->Read(address + 2), m_memory->Read(address + 1));
record->subroutine = true;
record->jump = true;
record->jump_address = jump_address;
record->jump_bank = m_memory->GetBank(jump_address);
}

if (record->bank < 0xF7)
Expand Down
1 change: 0 additions & 1 deletion src/huc6280.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class HuC6280
bool m_timer_irq;
u8 m_interrupt_disable_register;
u8 m_interrupt_request_register;
bool m_debug_next_subroutine;
int m_debug_next_irq;
bool m_breakpoint_hit;

Expand Down
3 changes: 1 addition & 2 deletions src/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ Memory::GG_Disassembler_Record* Memory::GetOrCreateDisassemblerRecord(u16 addres
record->jump = false;
record->jump_address = 0;
record->jump_bank = 0;
record->subroutine_src = false;
record->subroutine_dst = false;
record->subroutine = false;
record->irq = 0;
m_disassembler[physical_address] = record;
}
Expand Down
3 changes: 1 addition & 2 deletions src/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class Memory
bool jump;
u16 jump_address;
u8 jump_bank;
bool subroutine_src;
bool subroutine_dst;
bool subroutine;
int irq;
};

Expand Down

0 comments on commit 6ab835a

Please sign in to comment.