code wiki / _hdl_build / nx_wasm_2048_gate.nx
nx_wasm_2048_gate.nx
buildroot/runtime/_hdl_build/nx_wasm_2048_gate.nx
about
nx_wasm_2048_gate.nx -- native verify of the 2048 puzzle (base-relative; same code runs in wasm). Tests the
CORE genre logic: slide+merge (line_move), the full tick (with a spawn), no-move detection, determinism, and
renders a PNG to eyeball. This proves the emitter generalises to a SECOND, structurally-different genre.
license_tier: ORIGINAL expect_exit: 0
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_wasm_2048.nxnx_png.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 9 | func vw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 10 | func vn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 } |
| 11 | func vrow(id: *u8, ok: i64, pass: *i64) -> i64 { vw(" " as *u8); vw(id); vw(": " as *u8); if ok==1 { vw("OK\n" as *u8); pass[0]=pass[0]+1 } else { vw("FAIL\n" as *u8) } return 0 } |
| 12 | func setln(base: i64, a: i64, b: i64, c: i64, d: i64) -> i64 { lset(base,O_LINE,0,a); lset(base,O_LINE,1,b); lset(base,O_LINE,2,c); lset(base,O_LINE,3,d); let st: *i64=(base+O_ST) as *i64; st[2]=0; return 0 } |
| 13 | func chkln(base: i64, a: i64, b: i64, c: i64, d: i64) -> i64 |
| 21 | func tilecount(base: i64) -> i64 { var n: i64=0; var i: i64=0; while i<N*N { if gget(base,i)!=0 { n=n+1 } i=i+1 } return n } |
| 23 | func main() -> i64 |