Skip to content

Commit

Permalink
Use D to toggle live debugger on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
emoon committed Feb 16, 2024
1 parent 98d75a1 commit 5679521
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Debugger* Debugger_create() {
uint32_t window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
uint32_t window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN;
SDL_Window* window =
SDL_CreateWindow("Quaesar: Debugger", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);

Expand Down Expand Up @@ -219,6 +219,18 @@ void Debugger_update(Debugger* debugger) {

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void Debugger_toggle(Debugger* debugger, DebuggerMode mode) {
uint32_t window_flags = SDL_GetWindowFlags(debugger->window);

if (window_flags & SDL_WINDOW_HIDDEN) {
SDL_ShowWindow(debugger->window);
} else {
SDL_HideWindow(debugger->window);
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void Debugger_destroy(Debugger* debugger) {
// Cleanup
ImGui_ImplSDLRenderer2_Shutdown();
Expand All @@ -230,3 +242,5 @@ void Debugger_destroy(Debugger* debugger) {

delete debugger;
}


6 changes: 6 additions & 0 deletions src/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ struct Debugger {
SDL_Renderer* renderer;
};

enum DebuggerMode {
DebuggerMode_Live,
DebuggerMode_Break,
};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Debugger* Debugger_create();
void Debugger_update(Debugger* debugger);
void Debugger_update_event(SDL_Event* event);
void Debugger_destroy(Debugger* debugger);
void Debugger_toggle(Debugger* debugger, DebuggerMode mode);
2 changes: 2 additions & 0 deletions src/dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,8 @@ void unlockscr(struct vidbuffer* vb_in, int y_start, int y_end) {
quit_program == UAE_QUIT;
exit(0);
// TODO: Fix me
} else if (e.key.keysym.sym == SDLK_d) {
Debugger_toggle(s_debugger, DebuggerMode_Live);
}
break;
default:
Expand Down

0 comments on commit 5679521

Please sign in to comment.