#ifndef GBC_CONTROL_H #define GBC_CONTROL_H #include "gb.h" // Socket-based external control + debug channel. // // This is a superset of the legacy input FIFO: a Unix-domain stream socket that // accepts the same button-command vocabulary (see render.h / README) *plus* // emulator-introspection commands (memory read/write, CPU context, single-step, // breakpoints, watchpoints, run/pause). Because it is a socket it can reply to // each command and push asynchronous "event stop ..." lines when execution // halts at a breakpoint / step boundary / watchpoint. // // The protocol is line based (one command per line, '\n' terminated). Replies // begin with "ok" or "err"; asynchronous notifications begin with "event". // Create and start listening on a Unix-domain socket at `path`. Safe to call // once at startup. On failure prints to stderr and leaves the channel inactive. void control_open(const char *path); void control_close(void); bool control_active(void); // Accept new connections and dispatch any pending commands against `gb`. // Returns false if a client requested the emulator to quit. bool control_poll(GB *gb); // True while the debugger is holding execution (no CPU advancement). bool control_paused(void); // Advance emulation by up to one video frame, honoring the debugger's // pause / single-step / breakpoint / watchpoint state. When the control channel // is inactive this simply runs a full frame like the plain emulator loop. void control_run_frame(GB *gb); // If a recording is active (see the `record` command), append the frame just // produced by control_run_frame() to the capture file. No-op otherwise. void control_record_frame(GB *gb); // If a movie is playing (see the `input play` command), set this frame's joypad // state from it. Call once per loop iteration *before* control_run_frame(). void control_input_frame(GB *gb); #endif