Skip to content

Commit

Permalink
Breakpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jul 26, 2024
1 parent fa376e3 commit 88ae877
Show file tree
Hide file tree
Showing 14 changed files with 391 additions and 506 deletions.
111 changes: 40 additions & 71 deletions platforms/shared/desktop/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,63 +409,15 @@ static void sdl_events_emu(const SDL_Event* event)
// }
// break;

// case SDL_CONTROLLERAXISMOTION:
// {
// for (int i = 0; i < 2; i++)
// {
// GC_Controllers controller = (i == 0) ? Controller_1 : Controller_2;
// SDL_JoystickID id = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(application_gamepad[i]));

// if (!config_input[i].gamepad)
// continue;

// if (config_input[i].gamepad_directional == 0)
// continue;

// if (event->caxis.which != id)
// continue;

// const int STICK_DEAD_ZONE = 8000;

// if(event->caxis.axis == config_input[i].gamepad_x_axis)
// {
// int x_motion = event->caxis.value * (config_input[i].gamepad_invert_x_axis ? -1 : 1);

// if (x_motion < -STICK_DEAD_ZONE)
// emu_key_pressed(controller, Key_Left);
// else if (x_motion > STICK_DEAD_ZONE)
// emu_key_pressed(controller, Key_Right);
// else
// {
// emu_key_released(controller, Key_Left);
// emu_key_released(controller, Key_Right);
// }
// }
// else if(event->caxis.axis == config_input[i].gamepad_y_axis)
// {
// int y_motion = event->caxis.value * (config_input[i].gamepad_invert_y_axis ? -1 : 1);

// if (y_motion < -STICK_DEAD_ZONE)
// emu_key_pressed(controller, Key_Up);
// else if (y_motion > STICK_DEAD_ZONE)
// emu_key_pressed(controller, Key_Down);
// else
// {
// emu_key_released(controller, Key_Up);
// emu_key_released(controller, Key_Down);
// }
// }
// }
// }
// break;

case SDL_KEYDOWN:
{
if (event->key.repeat != 0)
break;

if (event->key.keysym.mod & KMOD_CTRL)
break;
if (event->key.keysym.mod & KMOD_SHIFT)
break;

int key = event->key.keysym.scancode;

Expand All @@ -475,13 +427,6 @@ static void sdl_events_emu(const SDL_Event* event)
break;
}

if (key == SDL_SCANCODE_F11)
{
config_emulator.fullscreen = !config_emulator.fullscreen;
application_trigger_fullscreen(config_emulator.fullscreen);
break;
}

for (int i = 0; i < 2; i++)
{
GG_Controllers controller = (i == 0) ? GG_CONTROLLER_1 : GG_CONTROLLER_2;
Expand Down Expand Up @@ -538,47 +483,60 @@ static void sdl_events_emu(const SDL_Event* event)

static void sdl_shortcuts_gui(const SDL_Event* event)
{
if ((event->type == SDL_KEYDOWN) && (event->key.keysym.mod & KMOD_CTRL))
if (event->type == SDL_KEYDOWN)
{
int key = event->key.keysym.scancode;

switch (key)
{
case SDL_SCANCODE_C:
gui_shortcut(gui_ShortcutDebugCopy);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutDebugCopy);
break;
case SDL_SCANCODE_V:
gui_shortcut(gui_ShortcutDebugPaste);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutDebugPaste);
break;
case SDL_SCANCODE_O:
gui_shortcut(gui_ShortcutOpenROM);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutOpenROM);
break;
case SDL_SCANCODE_R:
gui_shortcut(gui_ShortcutReset);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutReset);
break;
case SDL_SCANCODE_P:
gui_shortcut(gui_ShortcutPause);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutPause);
break;
case SDL_SCANCODE_F:
gui_shortcut(gui_ShortcutFFWD);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutFFWD);
break;
case SDL_SCANCODE_L:
gui_shortcut(gui_ShortcutLoadState);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutLoadState);
break;
case SDL_SCANCODE_S:
gui_shortcut(gui_ShortcutSaveState);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutSaveState);
break;
case SDL_SCANCODE_X:
gui_shortcut(gui_ShortcutScreenshot);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutScreenshot);
break;
case SDL_SCANCODE_M:
gui_shortcut(gui_ShortcutShowMainMenu);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutShowMainMenu);
break;
case SDL_SCANCODE_F5:
gui_shortcut(gui_ShortcutDebugContinue);
break;
case SDL_SCANCODE_F6:
gui_shortcut(gui_ShortcutDebugNextFrame);
gui_shortcut(gui_ShortcutDebugStepFrame);
break;
case SDL_SCANCODE_F7:
gui_shortcut(gui_ShortcutDebugBreak);
break;
case SDL_SCANCODE_F8:
gui_shortcut(gui_ShortcutDebugRuntocursor);
Expand All @@ -587,10 +545,21 @@ static void sdl_shortcuts_gui(const SDL_Event* event)
gui_shortcut(gui_ShortcutDebugBreakpoint);
break;
case SDL_SCANCODE_F10:
gui_shortcut(gui_ShortcutDebugStep);
gui_shortcut(gui_ShortcutDebugStepOver);
break;
case SDL_SCANCODE_F11:
if (event->key.keysym.mod & KMOD_SHIFT)
gui_shortcut(gui_ShortcutDebugStepOut);
else
gui_shortcut(gui_ShortcutDebugStepInto);
break;
case SDL_SCANCODE_F12:
config_emulator.fullscreen = !config_emulator.fullscreen;
application_trigger_fullscreen(config_emulator.fullscreen);
break;
case SDL_SCANCODE_BACKSPACE:
gui_shortcut(gui_ShortcutDebugGoBack);
if (event->key.keysym.mod & KMOD_CTRL)
gui_shortcut(gui_ShortcutDebugGoBack);
break;
}
}
Expand Down
14 changes: 9 additions & 5 deletions platforms/shared/desktop/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ void emu_init(void)

audio_enabled = true;
emu_audio_sync = true;
// emu_debug_disable_breakpoints_cpu = false;
// emu_debug_disable_breakpoints_mem = false;
// emu_debug_tile_palette = 0;
emu_debug_disable_breakpoints = false;
emu_savefiles_dir_option = 0;
emu_savestates_dir_option = 0;
emu_savefiles_path[0] = 0;
Expand Down Expand Up @@ -117,6 +115,8 @@ void emu_update(void)
if (config_debug.debug)
{
bool step = false;
bool breakpoint_hit = false;
bool stop_on_breakpoint = !emu_debug_disable_breakpoints;

switch (debugger_command)
{
Expand All @@ -130,7 +130,10 @@ void emu_update(void)
}

if (debugger_command != Debugger_Command_None)
geargrafx->RunToVBlank(emu_frame_buffer, audio_buffer, &sampleCount, step);
breakpoint_hit = geargrafx->RunToVBlank(emu_frame_buffer, audio_buffer, &sampleCount, step, stop_on_breakpoint);

if (breakpoint_hit)
debugger_command = Debugger_Command_None;

if (debugger_command != Debugger_Command_Continue)
debugger_command = Debugger_Command_None;
Expand Down Expand Up @@ -309,7 +312,8 @@ void emu_debug_step_frame(void)
void emu_debug_break(void)
{
geargrafx->Pause(false);
debugger_command = Debugger_Command_StepInto;
if (debugger_command == Debugger_Command_Continue)
debugger_command = Debugger_Command_StepInto;
}

void emu_debug_continue(void)
Expand Down
3 changes: 1 addition & 2 deletions platforms/shared/desktop/emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ EXTERN int emu_debug_background_buffer_width;
EXTERN int emu_debug_background_buffer_height;

EXTERN bool emu_audio_sync;
// EXTERN bool emu_debug_disable_breakpoints_cpu;
// EXTERN bool emu_debug_disable_breakpoints_mem;
EXTERN bool emu_debug_disable_breakpoints;
EXTERN bool emu_savefiles_dir_option;
EXTERN bool emu_savestates_dir_option;
EXTERN char emu_savefiles_path[4096];
Expand Down
65 changes: 38 additions & 27 deletions platforms/shared/desktop/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "gui_debug_memory.h"
#include "gui_debug_disassembler.h"

static ImFont* default_font[4];
static bool status_message_active = false;
static char status_message[4096] = "";
static u32 status_message_start_time = 0;
Expand Down Expand Up @@ -74,10 +73,10 @@ void gui_init(void)
for (int i = 0; i < 4; i++)
{
font_cfg.SizePixels = (13.0f + (i * 3)) * application_display_scale;
default_font[i] = io.Fonts->AddFontDefault(&font_cfg);
gui_default_fonts[i] = io.Fonts->AddFontDefault(&font_cfg);
}

gui_default_font = default_font[config_debug.font_size];
gui_default_font = gui_default_fonts[config_debug.font_size];

emu_audio_mute(!config_audio.enable);
emu_set_overscan(config_debug.debug ? 0 : config_video.overscan);
Expand Down Expand Up @@ -154,30 +153,42 @@ void gui_shortcut(gui_ShortCutEvent event)
case gui_ShortcutScreenshot:
gui_action_save_screenshot(NULL);
break;
// case gui_ShortcutDebugStep:
// if (config_debug.debug)
// emu_debug_step();
// break;
// case gui_ShortcutDebugContinue:
// if (config_debug.debug)
// emu_debug_continue();
// break;
// case gui_ShortcutDebugNextFrame:
// if (config_debug.debug)
// emu_debug_next_frame();
// break;
// case gui_ShortcutDebugBreakpoint:
// if (config_debug.debug)
// gui_debug_toggle_breakpoint();
// break;
// case gui_ShortcutDebugRuntocursor:
// if (config_debug.debug)
// gui_debug_runtocursor();
// break;
// case gui_ShortcutDebugGoBack:
// if (config_debug.debug)
// gui_debug_go_back();
// break;
case gui_ShortcutDebugStepOver:
if (config_debug.debug)
emu_debug_step_over();
break;
case gui_ShortcutDebugStepInto:
if (config_debug.debug)
emu_debug_step_into();
break;
case gui_ShortcutDebugStepOut:
if (config_debug.debug)
emu_debug_step_out();
break;
case gui_ShortcutDebugStepFrame:
if (config_debug.debug)
emu_debug_step_frame();
break;
case gui_ShortcutDebugBreak:
if (config_debug.debug)
emu_debug_break();
break;
case gui_ShortcutDebugContinue:
if (config_debug.debug)
emu_debug_continue();
break;
case gui_ShortcutDebugRuntocursor:
if (config_debug.debug)
gui_debug_runtocursor();
break;
case gui_ShortcutDebugGoBack:
if (config_debug.debug)
gui_debug_go_back();
break;
case gui_ShortcutDebugBreakpoint:
if (config_debug.debug)
gui_debug_toggle_breakpoint();
break;
case gui_ShortcutDebugCopy:
gui_debug_copy_memory();
break;
Expand Down
10 changes: 7 additions & 3 deletions platforms/shared/desktop/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ enum gui_ShortCutEvent
gui_ShortcutSaveState,
gui_ShortcutLoadState,
gui_ShortcutScreenshot,
gui_ShortcutDebugStep,
gui_ShortcutDebugStepOver,
gui_ShortcutDebugStepInto,
gui_ShortcutDebugStepOut,
gui_ShortcutDebugStepFrame,
gui_ShortcutDebugBreak,
gui_ShortcutDebugContinue,
gui_ShortcutDebugNextFrame,
gui_ShortcutDebugBreakpoint,
gui_ShortcutDebugRuntocursor,
gui_ShortcutDebugGoBack,
gui_ShortcutDebugBreakpoint,
gui_ShortcutDebugCopy,
gui_ShortcutDebugPaste,
gui_ShortcutShowMainMenu
Expand All @@ -54,6 +57,7 @@ EXTERN bool gui_in_use;
EXTERN bool gui_main_window_hovered;
EXTERN bool gui_main_menu_hovered;
EXTERN ImFont* gui_default_font;
EXTERN ImFont* gui_default_fonts[4];
EXTERN ImFont* gui_roboto_font;
EXTERN int gui_main_window_width;
EXTERN int gui_main_window_height;
Expand Down
Loading

0 comments on commit 88ae877

Please sign in to comment.