aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgbc dev <gbc@localhost>2026-07-16 15:44:57 +0200
committergbc dev <gbc@localhost>2026-07-16 15:44:57 +0200
commitcc86ccf4011dd470bd43a8bba8795e25136f1e6f (patch)
tree4734992b65d28422d0b2e958f0bf51522d9f89c2
parentheadless: $ED opcode = clean power-off (exit + battery save) (diff)
downloadsl0pboy-cc86ccf4011dd470bd43a8bba8795e25136f1e6f.tar.gz
sl0pboy-cc86ccf4011dd470bd43a8bba8795e25136f1e6f.tar.xz
sl0pboy-cc86ccf4011dd470bd43a8bba8795e25136f1e6f.zip
main: --shot with --headless dumps final LCD on exit
Lets scripted runs feed stdin to the serial console AND capture the resulting screen, e.g. printf 'ls\nexit\n' | gbc rom.gb --headless --shot 0 out.ppm Previously --shot ran frames with no stdin, so anything waiting on input (a shell) only showed its first prompt.
-rw-r--r--src/main.c8
-rw-r--r--src/ppu.c1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 935c9e7..6d6379a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -135,6 +135,14 @@ int main(int argc, char **argv) {
}
}
if (raw_tty) tcsetattr(STDIN_FILENO, TCSANOW, &saved_tio);
+ if (shot_frames >= 0) { // --headless --shot FILE: dump final LCD
+ FILE *pf = fopen(shot_path, "wb");
+ fprintf(pf, "P6\n%d %d\n255\n", SCREEN_W, SCREEN_H);
+ for (int y = 0; y < SCREEN_H; y++)
+ for (int x = 0; x < SCREEN_W; x++)
+ fwrite(gb->ppu.fb[y][x], 1, 3, pf);
+ fclose(pf);
+ }
cart_free(&gb->cart); free(gb); return 0;
}
diff --git a/src/ppu.c b/src/ppu.c
index 16ecc2e..381c306 100644
--- a/src/ppu.c
+++ b/src/ppu.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include "ppu.h"
#include <string.h>