Skip to content

Commit

Permalink
Merge pull request #96 from kichikuou/repl-on-mbutton
Browse files Browse the repository at this point in the history
Enter debugger REPL on middle-button click
  • Loading branch information
nunuhara committed Jan 3, 2023
2 parents 20b6046 + 64a92a2 commit b6f9999
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct dbg_cmd {
};

extern bool dbg_enabled;
extern bool dbg_start_in_debugger;
extern unsigned dbg_current_frame;

void dbg_init(void);
Expand Down
1 change: 1 addition & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "xsystem4.h"

bool dbg_enabled = true;
bool dbg_start_in_debugger = false;
unsigned dbg_current_frame = 0;
static jmp_buf dbg_continuation;

Expand Down
5 changes: 5 additions & 0 deletions src/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "input.h"
#include "scene.h"
#include "vm.h"
#include "debugger.h"

#ifndef M_PI
#define M_PI (3.14159265358979323846)
Expand Down Expand Up @@ -217,6 +218,10 @@ static void mouse_event(SDL_MouseButtonEvent *e)
enum sact_keycode code = sdl_to_sact_button(e->button);
if (code)
key_state[code] = e->state == SDL_PRESSED;
#ifdef DEBUGGER_ENABLED
if (e->button == SDL_BUTTON_MIDDLE && e->state == SDL_PRESSED && dbg_start_in_debugger)
dbg_repl();
#endif
}

#define JOYAXIS_DEADZONE 13500
Expand Down
7 changes: 2 additions & 5 deletions src/system4.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,6 @@ int main(int argc, char *argv[])
char *ainfile;
int err = AIN_SUCCESS;
bool audit = false;
#ifdef DEBUGGER_ENABLED
bool start_in_debugger = false;
#endif

char *font_mincho = NULL;
char *font_gothic = NULL;
Expand Down Expand Up @@ -482,7 +479,7 @@ int main(int argc, char *argv[])
dbg_enabled = false;
break;
case LOPT_DEBUG:
start_in_debugger = true;
dbg_start_in_debugger = true;
break;
#endif
}
Expand Down Expand Up @@ -548,7 +545,7 @@ int main(int argc, char *argv[])

#ifdef DEBUGGER_ENABLED
dbg_init();
if (start_in_debugger)
if (dbg_start_in_debugger)
dbg_repl();
#endif

Expand Down

0 comments on commit b6f9999

Please sign in to comment.