code wiki / _hdl_build / nx_nxfh_lib.nx

nx_nxfh_lib.nx

buildroot/runtime/_hdl_build/nx_nxfh_lib.nx

6098 B169 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_nxfh_lib.nx -- shared NXFH1 text-hex framebuffer codec (LIB, no main). license_tier: ORIGINAL WHY A LIB (DRY, rule 15): the NXFH1 parser lived ONLY inside nx_frame_score.nx (an organ with a main, so nothing could import it); the moment a second consumer existed (nx_frame_score2 + gates) copies #2 and #3 were about to happen. This is the extraction. The DEPLOYED nx_frame_score keeps its private copy untouched -- this task builds a new instrument, it does not touch the live one. FORMAT NXFH1 (deliberately TEXT so it travels the fs-write lane safely; raw binary through JSON-string tooling is the proven corruption path): line 1: "NXFH1 <w> <h>\n" then w*h pixels as 6 lowercase hex chars each (rrggbb), any whitespace between pixels ignored. Decoded pixel layout r | g<<8 | b<<16 = the critic fb layout. CONTRACT: nxl_load REFUSES (returns 0) on missing file, bad magic, junk bytes, short/overlong pixel stream -- a truncated capture must never be scored as a dark frame. nxl_dump is the writer; a writer is only tested by a read-back (banked law), which nx_craft_capture_gate enforces.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_nxfh_lib.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

structs

none

consts

15const NXL_MAXW: i64 = 1024
16const NXL_MAXH: i64 = 1024
17const NXL_MAGIC_65536: i64 = 65536
18const NXL_MODE_644: i64 = 420
19const NXL_HDRMIN: i64 = 12

functions

21func nxl_isws(c: i64) -> i64 { if c==32 { return 1 } if c==10 { return 1 } if c==13 { return 1 } if c==9 { return 1 } return 0 }
called by 1: nxl_load
22func nxl_nib(c: i64) -> i64
called by 1: nxl_load
31func nxl_load(path: *u8, whp: *i64) -> *i64
116func nxl_cat(d: *u8, at: i64, s: *u8) -> i64 { var i: i64=0; var a: i64=at; while s[i]!=(0 as u8) { d[a]=s[i]; a=a+1; i=i+1 } return a }
called by 1: nxl_dump
117func nxl_catn(d: *u8, at: i64, v: i64) -> i64
called by 1: nxl_dump calls 1: sys_mmap
129func nxl_hex2(d: *u8, at: i64, v: i64) -> i64
called by 1: nxl_dump
142func nxl_dump(path: *u8, fb: *i64, w: i64, h: i64) -> i64