code wiki / (root) / nx_game_harness.nx

nx_game_harness.nx

buildroot/runtime/nx_game_harness.nx

2828 B77 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic game
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_game_harness.nx nx_chk_bits_up_e2e.nx nx_test_driver_e2e.nx nx_ttt_bits_up_e2e.nx

imports: nx_syscalls.nx

imported by: nx_chk_bits_up_e2e.nxnx_test_driver_e2e.nxnx_ttt_bits_up_e2e.nx

structs

37struct NxGameCapture

consts

20const NX_CAPTURE_FD: i64 = 99
23const _O_RDWR: i64 = 2
24const _O_CREAT: i64 = 64 // 0100 octal
25const _O_TRUNC: i64 = 512 // 01000 octal
27const _SEEK_SET: i64 = 0

functions

32func _gh_openat_rdwr(path: *u8, mode: i64) -> i64
called by 1: nx_capture_start
42func nx_capture_start() -> *NxGameCapture
59func nx_capture_end(cap: *NxGameCapture, out: *u8, out_cap: i64) -> i64