code wiki / _hdl_build / nx_viz_axis_gate.nx
nx_viz_axis_gate.nx source
↩ module page · 64 lines · 2916 B
1// nx_viz_axis_gate.nx -- REFEREE for the axis layer.
2// T1 va_ticks(0..100, 5, px 0..500) -> vals 0,25,50,75,100 px 0,125,250,375,500
3// T2 va_ticks(0..50, 6, px 0..600) -> vals 0,10,20,30,40,50 px 0,120,240,360,480,600
4// T3 va_axis_bottom render: non-empty + emits the right tick count (count "<text" labels)
5// GREEN iff T1+T2+T3. Sovereign: nx_viz_axis (-> scales + shapes + trig). license_tier: ORIGINAL
6import "nx_viz_axis.nx"
7import "nx_syscalls.nx"
8import "nx_gate_verdict.nx"
9
10func 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 }
11func g_row(name: *u8, ok: i64) -> i64 {
12 if ok == 1 { g_w(" PASS " as *u8) }
13 if ok != 1 { g_w(" FAIL " as *u8) }
14 g_w(name); g_w("\n" as *u8)
15 return ok
16}
17// count occurrences of two-byte needle "<t" (start of "<text") in out[0..len)
18func count_text(out: *u8, len: i64) -> i64 {
19 var c: i64 = 0; var i: i64 = 0
20 while i < len - 1 {
21 if out[i] == 60 { if out[i + 1] == 116 { c = c + 1 } }
22 i = i + 1
23 }
24 return c
25}
26
27func main() -> i64 {
28 g_w("viz-axis gate (d3-axis: tick values -> pixels -> SVG axis)\n" as *u8)
29 let vals: *i64 = sys_mmap(256) as *i64
30 let pxs: *i64 = sys_mmap(256) as *i64
31 let out: *u8 = sys_mmap(4096)
32 var pass: i64 = 0
33
34 var c1: i64 = va_ticks(0, 100, 5, 0, 500, vals, pxs)
35 var t1: i64 = 0
36 if c1 == 5 { if vals[0] == 0 { if vals[1] == 25 { if vals[4] == 100 {
37 if pxs[0] == 0 { if pxs[1] == 125 { if pxs[2] == 250 { if pxs[4] == 500 { t1 = 1 } } } } } } } }
38 pass = pass + g_row("T1 ticks 0..100 x5 -> vals 0,25,..100 px 0,125,..500\x00" as *u8, t1)
39
40 var c2: i64 = va_ticks(0, 50, 6, 0, 600, vals, pxs)
41 var t2: i64 = 0
42 if c2 == 6 { if vals[1] == 10 { if vals[5] == 50 { if pxs[1] == 120 { if pxs[5] == 600 { t2 = 1 } } } } }
43 pass = pass + g_row("T2 ticks 0..50 x6 -> vals 0,10,..50 px 0,120,..600\x00" as *u8, t2)
44
45 var len: i64 = va_axis_bottom(0, 100, 0, 500, 5, 300, out)
46 var t3: i64 = 0
47 if len > 0 { if count_text(out, len) == 5 { t3 = 1 } }
48 pass = pass + g_row("T3 bottom render non-empty + 5 tick labels\x00" as *u8, t3)
49
50 var len2: i64 = va_axis_left(0, 500, 400, 40, 6, 70, out)
51 var t4: i64 = 0
52 if len2 > 0 { if count_text(out, len2) == 6 { t4 = 1 } }
53 pass = pass + g_row("T4 left render non-empty + 6 tick labels\x00" as *u8, t4)
54
55 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
56 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
57 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
58 let ctr__dry: *i64 = gv_ctr()
59 ctr__dry[0] = pass
60 ctr__dry[1] = 4
61 let rc__dry: i64 = gv_verdict("VIZ-AXIS-GATE" as *u8, ctr__dry, "4/4 (bottom + left axis = ticks->pixels->SVG)" as *u8)
62 sys_exit(rc__dry)
63 return rc__dry
64}