diff options
| author | gbc dev <gbc@localhost> | 2026-07-17 20:22:13 +0200 |
|---|---|---|
| committer | gbc dev <gbc@localhost> | 2026-07-17 20:22:13 +0200 |
| commit | e8c1777a1761ebf55029589912198c83fb06aaec (patch) | |
| tree | e6e439b976fbbca3aba059358207a03d82b1fced /src | |
| parent | cpu: log the $ED poweroff opcode with pc/registers (diff) | |
| download | sl0pboy-e8c1777a1761ebf55029589912198c83fb06aaec.tar.gz sl0pboy-e8c1777a1761ebf55029589912198c83fb06aaec.tar.xz sl0pboy-e8c1777a1761ebf55029589912198c83fb06aaec.zip | |
main: allow --sock (control/debug socket) in headless mode
The control socket was only opened on the windowed path, so a --headless
GB couldn't be inspected. A scriptable, invisible GB is exactly the one
you most want to peek into - reading kernel WRAM over the debug socket is
how the TCP field-offset corruption got pinned down. Open it in the
headless loop too and poll it each frame; close it on exit.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -251,6 +251,14 @@ int main(int argc, char **argv) { gb->serial_in_fd = STDIN_FILENO; gb->serial_no_eof = (keys != NULL); // OSK provides input; don't EOF-exit } + // --sock works headless too: a scriptable GB you can also debug + // (read/write memory, breakpoints, button injection) is far more + // useful than one you can't see into. + if (sock_path) { + control_open(sock_path); + if (control_active()) + fprintf(stderr, "control socket: %s\n", sock_path); + } int keys_frame = 0; int fl = fcntl(STDIN_FILENO, F_GETFL, 0); if (fl != -1) fcntl(STDIN_FILENO, F_SETFL, fl | O_NONBLOCK); @@ -280,6 +288,7 @@ int main(int argc, char **argv) { gb->buttons = keys_mask(keys, keys_frame); if (keys_frame++ > (int)strlen(keys) * 20 + 40) break; } + if (sock_path && !control_poll(gb)) break; // debug socket quit run_frame(gb); // advance ~a frame's worth of cycles if (!uncapped) { double target = start_t + (gb->cycles - start_cyc) / HZ; @@ -294,6 +303,7 @@ int main(int argc, char **argv) { } } if (raw_tty) tcsetattr(STDIN_FILENO, TCSANOW, &saved_tio); + control_close(); fprintf(stderr, "[sl0pboy] headless loop exit: %s\n", gb->poweroff ? "guest poweroff" : "signal"); if (shot_frames >= 0) { // --headless --shot FILE: dump final LCD |
