nx_game_harness.nx
buildroot/runtime/nx_game_harness.nx
about
nx_game_harness.nx -- fd-99 capture mechanism for the bits-up test
driver. Replaces the "renderChunks" buffer in nishi-host.js. Game's
bits-up render fn writes to sentinel fd 99; we redirect 99 to a temp
file via open + dup3; after render, lseek-rewind + read to retrieve.
Why a tempfile (not pipe2): NishiLang's *i64 indexing of the pipefds
array writes a 16-byte buffer where the kernel writes only 8 bytes
(two int fds), creating subtle layout issues. Tempfile is unambiguous:
open returns one fd, we own the buffer, lseek rewinds for read.
Usage:
let cap = nx_capture_start()
nx_<game>_render(state)
let buf = sys_mmap(65536)
let n = nx_capture_end(cap, buf, 65536)
// buf[0..n] now contains exactly what the game emitted.
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_chk_bits_up_e2e.nxnx_test_driver_e2e.nxnx_ttt_bits_up_e2e.nx
structs
| 37 | struct NxGameCapture |
consts
| 20 | const NX_CAPTURE_FD: i64 = 99 |
| 23 | const _O_RDWR: i64 = 2 |
| 24 | const _O_CREAT: i64 = 64 // 0100 octal |
| 25 | const _O_TRUNC: i64 = 512 // 01000 octal |
| 27 | const _SEEK_SET: i64 = 0 |
functions
| 32 | func _gh_openat_rdwr(path: *u8, mode: i64) -> i64 called by 1: nx_capture_start |
| 42 | func nx_capture_start() -> *NxGameCapture |
| 59 | func nx_capture_end(cap: *NxGameCapture, out: *u8, out_cap: i64) -> i64 |