Skip to content

Add -headless-render flag and savescreen debug command#61

Open
acscpt wants to merge 3 commits intoscarybeasts:masterfrom
acscpt:pr/headless-render
Open

Add -headless-render flag and savescreen debug command#61
acscpt wants to merge 3 commits intoscarybeasts:masterfrom
acscpt:pr/headless-render

Conversation

@acscpt
Copy link
Copy Markdown

@acscpt acscpt commented Apr 27, 2026

Hi Chris,

This adds the ability to capture rendered screen output from a headless beebjit session via the existing debugger, useful for automation harnesses. Three commits, with functional test coverage included:

  1. -headless-render flag: allocates the render buffer in headless mode. Without it the buffer is NULL (only allocated when -frame-cycles > 0), which short-circuits the video pipeline. The new flag opens a parallel allocation path so render-derived state like frame_buffer_crc32 is available without forcing a -frame-cycles workaround.

  2. savescreen <file> debug command: writes the BGRA framebuffer to a file. Mirrors the existing savemem pattern (util_file_try_open/util_file_write/util_file_close) and uses render_has_buffer for the null check. Prints dimensions on success so converters like convert -size WxH -depth 8 bgra:screen.bgra out.png are easy to invoke.

  3. Functional tests in run_functional_tests.sh: one re-runs the existing RVI rendering scenario in headless mode with -headless-render -opt video:always-render and asserts the same 0x2c23c1b6 CRC, proving headless rendering is pixel-identical to GUI rendering and exercising the new buffer-allocation path. Another asserts savescreen writes a file of the expected size (768×640×4 = 1,966,080 bytes).

The two flags compose: -headless-render allocates the buffer, savescreen reads it. Each works on its own (savescreen works in GUI mode where the buffer is always allocated; -headless-render is useful for any scenario wanting frame_buffer_crc32 without disk dumps).

Testing

  • Linux: full build.sh test suite green including the two new functional tests.
  • Windows: cross-compiled with mingw-w64 and verified under wine. Headless output is byte-identical to Linux.

acscpt added 3 commits April 27, 2026 22:42
Without it the render buffer is only allocated when -frame-cycles is
set. The new flag enables render-derived state (e.g. frame_buffer_crc32)
in headless mode without requiring frame dumps to disk, useful for
debugger and automation harness use.
Writes the raw BGRA render buffer to a file. Convert to PNG with e.g.
ImageMagick: convert -size WxH -depth 8 bgra:screen.bgra out.png. The
command prints the buffer dimensions on success so the converter
arguments are easy to derive. Requires the render buffer to be
allocated (i.e. GUI mode, or headless with -headless-render or
-frame-cycles).
Re-runs the RVI rendering scenario in headless mode with -headless-render
and -opt video:always-render and asserts the framebuffer CRC matches the
existing GUI-mode value, proving headless rendering is pixel-identical
and the buffer allocation path works. A second test exercises savescreen
and asserts the dumped BGRA file size matches the expected render
dimensions.
acscpt added a commit to acscpt/beebjit that referenced this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant