code wiki / _hdl_build / nx_viz_contour_gate.nx

nx_viz_contour_gate.nx source

↩ module page · 53 lines · 2454 B

1// nx_viz_contour_gate.nx -- REFEREE for the contour layer (marching squares vs the standard table). 2// case(10,10,0,0,t5)=12 (top above) -> seg left-right [3,1]; case(0,0,0,10,t5)=1 (BL) -> seg [3,2] 3// case all-below=0 / all-above=15 -> 0 segs; case 5 (saddle) -> 2 segs; case(0,10,10,0,t5)=6 -> [0,2] 4// GREEN iff all. Sovereign: nx_viz_contour + nx_syscalls. license_tier: ORIGINAL 5import "nx_viz_contour.nx" 6import "nx_syscalls.nx" 7import "nx_gate_verdict.nx" 8 9func g_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 10func g_row(name: *u8, ok: i64) -> i64 { 11 if ok == 1 { g_w(" PASS " as *u8) } 12 if ok != 1 { g_w(" FAIL " as *u8) } 13 g_w(name); g_w("\n" as *u8) 14 return ok 15} 16 17func main() -> i64 { 18 g_w("viz-contour gate (marching squares case + segment table)\n" as *u8) 19 let seg: *i64 = sys_mmap(64) as *i64 20 var pass: i64 = 0 21 22 var t1: i64 = 0 23 if vc_ms_case(10, 10, 0, 0, 5) == 12 { if vc_ms_case(0, 0, 0, 10, 5) == 1 { if vc_ms_case(0, 10, 10, 0, 5) == 6 { t1 = 1 } } } 24 pass = pass + g_row("T1 case classify: 12 / 1 / 6\x00" as *u8, t1) 25 26 var t2: i64 = 0 27 if vc_ms_case(0, 0, 0, 0, 5) == 0 { if vc_ms_case(10, 10, 10, 10, 5) == 15 { t2 = 1 } } 28 pass = pass + g_row("T2 all-below=0, all-above=15\x00" as *u8, t2) 29 30 var n12: i64 = vc_ms_segs(12, seg) 31 var t3: i64 = 0 32 if n12 == 1 { if seg[0] == 3 { if seg[1] == 1 { t3 = 1 } } } 33 pass = pass + g_row("T3 case 12 -> 1 seg left-right [3,1]\x00" as *u8, t3) 34 35 var n1: i64 = vc_ms_segs(1, seg) 36 var t4: i64 = 0 37 if n1 == 1 { if seg[0] == 3 { if seg[1] == 2 { t4 = 1 } } } 38 pass = pass + g_row("T4 case 1 -> 1 seg left-bottom [3,2]\x00" as *u8, t4) 39 40 var t5: i64 = 0 41 if vc_ms_segs(0, seg) == 0 { if vc_ms_segs(15, seg) == 0 { if vc_ms_segs(5, seg) == 2 { t5 = 1 } } } 42 pass = pass + g_row("T5 empty=0 segs, saddle(5)=2 segs\x00" as *u8, t5) 43 44 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 45 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 46 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 47 let ctr__dry: *i64 = gv_ctr() 48 ctr__dry[0] = pass 49 ctr__dry[1] = 5 50 let rc__dry: i64 = gv_verdict("VIZ-CONTOUR-GATE" as *u8, ctr__dry, "5/5 (marching squares, standard table)" as *u8) 51 sys_exit(rc__dry) 52 return rc__dry 53}