OXYGENHUB
◆ rrdc-perf enhanced-x16-emulator / src / debug_ui / debug_ui.h
2.7 KiB · Objective-C · last changed chore(): initial commit 25 days ago source blame history raw
9120e874 Andy McCall 1
// Commander X16 Emulator — in-process Dear ImGui debugger.
2
//
3
// C-callable API so the C emulator core (main.c / video.c) can drive the
4
// ImGui debugger without knowing any C++. The implementation lives in
5
// debug_ui.cpp; individual panels live under panels/ and self-register (see
6
// debug_ui_panels.h).
7
#ifndef DEBUG_UI_H
8
#define DEBUG_UI_H
9
10
#include <stdbool.h>
11
#include <SDL.h>
12
13
#ifdef __cplusplus
14
extern "C" {
15
#endif
16
17
// Create the ImGui context + SDL2/SDLRenderer2 backends. `win`/`ren` are a
18
// dedicated debugger SDL window + renderer (separate from the emulator display
19
// window), created by the caller (see video.c). Enables docking. Idempotent.
20
void debug_ui_init(SDL_Window *win, SDL_Renderer *ren);
21
22
// Feed one SDL event to ImGui. Call for every event pulled from the pump.
23
void debug_ui_process_event(const SDL_Event *ev);
24
25
// Build and present one debugger frame: NewFrame -> full-window DockSpace ->
26
// iterate the panel registry -> Render + present on the debugger renderer.
27
// Call once per emulator frame.
28
void debug_ui_render(void);
29
30
// Destroy backends + ImGui context. Safe to call even if never initialized.
31
void debug_ui_shutdown(void);
32
33
// Reflects the -imgui flag / runtime enable state.
34
bool debug_ui_is_enabled(void);
35
void debug_ui_set_enabled(bool enabled);
36
37
// The debugger's SDL_Renderer (the one passed to debug_ui_init). Panels that
38
// need to create SDL_Texture objects for ImGui::Image (e.g. the VERA graphical
39
// viewers) obtain it here. Returns nullptr before debug_ui_init runs.
40
SDL_Renderer *debug_ui_get_renderer(void);
41
42
// True when ImGui wants to consume keyboard input this frame (e.g. a text field
43
// is focused). NOTE: with keyboard nav enabled this is ALSO true whenever the
44
// debugger window merely has focus, so it is too broad for gating function-key
45
// shortcuts — use debug_ui_want_text_input() for those.
46
bool debug_ui_want_capture_keyboard(void);
47
48
// True only while an ImGui text field is actively accepting text input. Used to
49
// gate the F5/F9/F10/F11 debug shortcuts so they work whenever the debugger
50
// window is focused but are suppressed while the user types in a goto/search box.
51
bool debug_ui_want_text_input(void);
52
53
// Run to the "cursor" — the disassembly row currently under the mouse, if any
54
// (published each frame by the Disassembly panel via debug_ui_set_cursor).
55
// No-op unless the machine is paused and a valid cursor is set. Returns true if
56
// a run-to actually started. Backs the Ctrl+F10 "run to cursor" shortcut.
57
bool debug_ui_run_to_cursor(void);
58
59
// Toggle a breakpoint on the current instruction (regs.pc / regs.k). Backs the
60
// F9 shortcut so it works regardless of which debugger panel has focus.
61
void debug_ui_toggle_breakpoint_at_pc(void);
62
63
#ifdef __cplusplus
64
} // extern "C"
65
#endif
66
67
#endif // DEBUG_UI_H