code wiki / _hdl_build / nx_world_snap_dunes_t70.nx
nx_world_snap_dunes_t70.nx source
↩ module page · 742 lines · 43818 B
1// nx_world_snap.nx -- THE WORLD-ART CAPTURE INSTRUMENT (operator 2026-08-12: "make sure you are
2// running the tools to evaluate the art and realism and quality"). The W1b style overlay applies
3// in the BROWSER page only, so no estate instrument had ever SEEN a styled world -- this organ
4// renders any (identity, seed, style-rows) world NATIVELY through the same engine source the wasm
5// is compiled from (nx_wasm_craft as a lib; its 54-tooth gate is the native-behavior proof), and
6// writes the frame as PNG for the judge battery (nx_uiq_visual analyze / nx_frame_score / eye).
7// The style poke here is semantically what the page's NXSP loop does: sp[idx]=val post-init,
8// idx bounded 7..58 (same belt as the page).
9// usage: nx_world_snap <out.png> [v] [seed] [style idx:val,...] [ticks]
10// exit: 0 written+read-back | 2 usage | 5 png-write-fail. license_tier: ORIGINAL
11// No hw writes (Rule 26).
12import "nx_wasm_craft_dunes_t70.nx"
13import "nx_genp_allow_lib.nx" // THE ONE gen-time allowlist (2026-09-04): the g8 chain below was a mirrored copy and it is now the same ruler the engine reads
14import "nx_png_write.nx"
15import "_hdl_build/nx_nxfh_lib.nx"
16const K_MAGIC_20260728: i64 = 20260728
17const K_MAGIC_4096: i64 = 4096
18const K_MAGIC_65536: i64 = 65536
19const K_MODE_RW: i64 = 420 // 0644 -- the .d16 raw depth plane, same mode nx_png_write uses
20// ★RESOLUTION POLICY CONSTANTS. None of these is a tuning number.
21// wc_rw(base) = W/q and wc_rh(base) = H/q, so q=1 IS one ray per pixel -- the engine's OWN definition
22// of native. The ceiling W x H is itself derived (nx_wasm_craft's const W: the page's min(98vw,1920px)
23// display cap), so no resolution literal below is chosen by hand.
24const WS_Q_NATIVE: i64 = 1
25const WS_CH_Q: i64 = 113 // ASCII 'q' -- first byte of the `q=<n>` reduction keyword
26const WS_CH_EQ: i64 = 61 // ASCII '='
27const WS_PERMIL: i64 = 1000 // permil base for the announced resolution fraction
28// The `q=` keyword is exactly the two named bytes above, so its length is a property of the keyword
29// rather than a number to remember: the scan resumes at the first byte AFTER them.
30const WS_QKW_LEN: i64 = 2
31const WS_CURSOR_BYTES: i64 = 16 // one i64 cursor cell, page-rounded by mmap
32// THE PERCEPT ANCHOR GEOMETRY. nx_percept's entire anchor corpus declares NXFH1 400 240 -- all twelve
33// of them -- so a 1920x1200 capture is scoreable by nx_frame_score and comparable to NOTHING in the
34// perceptual corpus. These two numbers are that corpus's shape, not a taste: they are the size the
35// consumer already publishes, and the downsample factor below is DERIVED from them against the
36// engine's own native ceiling rather than chosen.
37const WS_PERCEPT_W: i64 = 400
38const WS_PERCEPT_H: i64 = 240
39// The PORTRAIT SUBJECT'S GENOME is DERIVED FROM THE SEED, never chosen: every other appearance in
40// this organ is a deterministic function of (identity, seed), and a hand-picked genome would make
41// one girl's look a property of the instrument rather than of the world being judged. The genome
42// WIDTH is the engine's own (WATER_MAGIC_1048576, the modulus genmobs itself uses), read from the
43// engine rather than restated here, so the two can never disagree about how wide a genome is.
44// ★NAMED FOR THEIR PURPOSE, NOT THEIR VALUE (rule 11). Both were inline literals that predate this
45// lane: the magic ratchet reported magic=5 against a banked baseline of 0, so NO build of this organ
46// could ship until they were named -- a permanently-refusing gate on the estate's world-capture
47// instrument, and the refusal correctly named literals whose author was long gone. Fixed rather than
48// bypassed: a ratchet is only worth having if its author fixes what it finds.
49// The .d16 ground-truth plane stores each depth sample as a little-endian UNSIGNED 16-BIT word, so
50// its saturation value is a property of the format, not a tuning choice.
51const WS_D16_MAX: i64 = 65535
52// The normal channel normalises an integer gradient by binary-searching isqrt(m2). m2 is a sum of
53// three squares of clamped gradient terms, so bounding `hi` at 2^32 keeps mid*mid inside i64 for
54// every input the loop can be handed -- an OVERFLOW bound, not a magnitude guess.
55const WS_ISQRT_HI_BOUND: i64 = 4294967296
56// The engine's native ceiling, read through FUNCTION scope on purpose: main() later declares its own
57// `let W` for the RENDERED extent, and a single-pass compiler resolving one name to two different
58// things inside one body is exactly how a measurement silently reports the wrong subject.
59func ws2_natw() -> i64 { return W }
60func ws2_nath() -> i64 { return H }
61
62func ws2_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
63func ws2_puts(s: *u8) -> i64 { sys_write(1, s, ws2_slen(s)); return 0 }
64func ws2_pn(v: i64) -> i64 {
65 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
66 var m: i64 = v
67 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
68 let t: *u8 = sys_mmap(32)
69 var k: i64 = 0
70 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
71 let o: *u8 = sys_mmap(32)
72 var i: i64 = 0
73 while i < k { o[i] = t[k - 1 - i]; i = i + 1 }
74 sys_write(1, o, k)
75 return 0
76}
77func ws2_int(s: *u8) -> i64 {
78 var v: i64 = 0
79 var i: i64 = 0
80 while s[i] != (0 as u8) {
81 let c: i64 = s[i] as i64
82 if c >= 48 { if c <= 57 { v = v*10 + (c - 48) } }
83 i = i + 1
84 }
85 return v
86}
87func ws2_num_at(s: *u8, pos: *i64) -> i64 {
88 var v: i64 = 0
89 var i: i64 = pos[0]
90 var run: i64 = 1
91 while run == 1 {
92 let c: i64 = s[i] as i64
93 if c >= 48 { if c <= 57 { v = v*10 + (c-48); i = i + 1 } else { run = 0 } } else { run = 0 }
94 }
95 pos[0] = i
96 return v
97}
98
99func ws2_streq(a: *u8, b: *u8) -> i64 {
100 var i: i64 = 0
101 while a[i] != (0 as u8) {
102 if a[i] != b[i] { return 0 }
103 i = i + 1
104 }
105 if b[i] != (0 as u8) { return 0 }
106 return 1
107}
108
109func main(argc: i64, argv: *i64) -> i64 {
110 // ★THE `char` VERB SHIFTS EVERY LATER ARGUMENT BY ONE AND CHANGES NOTHING ELSE ON THE WORLD PATH
111 // (ao=0 there, so its argv indices are literally unchanged -- proven by behaveprobe IDENTICAL before
112 // promote, which is also the experiment that caught the ARENA-0 extent defect this organ carried:
113 // the first landing of this verb crashed, a full revert STILL crashed at the same address, and that
114 // is what proved the fault was ww()/hh() reading a foreign arena rather than this change).
115 // "char" cannot collide with the world path's first argument because that argument is an output PATH.
116 var ao: i64 = 0
117 var charmode: i64 = 0
118 if argc > 1 { if ws2_streq(argv[1] as *u8, "char" as *u8) == 1 { charmode = 1; ao = 1 } }
119 // ws_groundtruth_emit -- THE DATASET-FACTORY VERB (/compare/graphics contract row, 2026-08-18):
120 // gt renders the identical world path with the engine's zero-cost depth plane KEPT (S_GT_KEEP), and
121 // emits three ALIGNED channels beside the RGB: <out>.depth.png (16-bit gray, near = bright, the
122 // engine's own 24-bit ray depth clamped to 16) and <out>.normal.png (screen-space normal from the
123 // depth gradient, encoded 0..255 -- DERIVED from depth and labeled so; a G-buffer normal is the next
124 // rung). Same argv shape as the world path after the verb. Infinigen's annotation pipeline is why its
125 // datasets exist; this is that lane through OUR renderer, deterministic under the seed.
126 var gtmode: i64 = 0
127 if argc > 1 { if ws2_streq(argv[1] as *u8, "gt" as *u8) == 1 { gtmode = 1; ao = 1 } }
128 if argc < 2 + ao {
129 ws2_puts("usage: nx_world_snap <out.png> [v] [seed] [style idx:val,...] [ticks]\n" as *u8)
130 ws2_puts(" nx_world_snap char <out.png> [v] [seed] [style idx:val,...] [ticks] -- frame a girl (T59's placement)\n" as *u8)
131 ws2_puts(" nx_world_snap gt <out.png> [v] [seed] [style idx:val,...] [ticks] -- ground truth: +<out>.depth.png +<out>.normal.png\n" as *u8)
132 return 2
133 }
134 let outp: *u8 = argv[1 + ao] as *u8
135 var v: i64 = 0
136 if argc > 2 + ao { v = ws2_int(argv[2 + ao] as *u8) }
137 var seed: i64 = K_MAGIC_20260728
138 if argc > 3 + ao { seed = ws2_int(argv[3 + ao] as *u8) }
139 var ticks: i64 = 30
140 if argc > 5 + ao { ticks = ws2_int(argv[5 + ao] as *u8) }
141 let base: i64 = sys_mmap(CRAFT_TOTAL + K_MAGIC_4096) as i64
142 // W1c: gen rows (0..6, 59, 60) in the SAME spec string are written into GENP *BEFORE* init --
143 // without this a snap of a gen-row world renders the bare identity's terrain, i.e. the judge
144 // measures the WRONG SUBJECT (debt 1786644871). The engine enforces the allowlist; the count
145 // it actually applied is world truth (S_GENP) and is announced below.
146 if argc > 4 + ao {
147 let sp8: *u8 = argv[4 + ao] as *u8
148 let gp8: *i64 = wgp(base)
149 let pos8: *i64 = sys_mmap(16) as *i64
150 pos8[0] = 0
151 var gk8: i64 = 0
152 var run8: i64 = 1
153 while run8 == 1 {
154 let iv8: i64 = ws2_num_at(sp8, pos8)
155 if sp8[pos8[0]] != (58 as u8) { run8 = 0 } else {
156 pos8[0] = pos8[0] + 1
157 var vv8: i64 = 0
158 if iv8 == GA_DUNE {
159 vv8 = genp_dune_decimal(sp8,pos8)
160 if genp_dune_valid(vv8) == 0 { ws2_puts("NX-WORLD-SNAP REFUSED invalid dune recipe\n" as *u8); return 79 }
161 } else { vv8 = ws2_num_at(sp8, pos8) }
162 // THE ONE ALLOWLIST (nx_genp_allow_lib, 2026-09-04): the engine's own ruler, read here instead of mirrored.
163 let g8: i64 = genp_dune_gen_ok(iv8)
164 // 2026-09-01 this filter mirrored init_impl_v's chain index-for-index and named itself a DUPLICATE RULER
165 // (debt 1788294505); 2026-09-04 the root fix landed -- nx_genp_allow_lib is the one list the engine, this
166 // instrument and the page emitter all read, so an index admitted to the engine is seen here by construction.
167 if g8 == 1 { if gk8 < GENP_MAXP {
168 gp8[2 + gk8*2] = iv8
169 gp8[3 + gk8*2] = vv8
170 gk8 = gk8 + 1
171 } }
172 if sp8[pos8[0]] == (44 as u8) { pos8[0] = pos8[0] + 1 } else { run8 = 0 }
173 }
174 }
175 if gk8 > 0 { gp8[0] = GENP_MAGIC; gp8[1] = gk8 }
176 }
177 let init_code: i64 = init_impl_v(base,v,seed)
178 if init_code != 0 { ws2_puts("NX-WORLD-SNAP REFUSED native init code=" as *u8); ws2_pn(init_code); ws2_puts("\n" as *u8); return 79 }
179 // ---- style poke: the page's NXSP loop, natively; applied count ANNOUNCED ----
180 var applied: i64 = 0
181 if argc > 4 + ao {
182 let sp7: *u8 = argv[4 + ao] as *u8
183 let sp: *i64 = wsp(base)
184 let pos: *i64 = sys_mmap(16) as *i64
185 pos[0] = 0
186 var run: i64 = 1
187 while run == 1 {
188 let iv: i64 = ws2_num_at(sp7, pos)
189 if sp7[pos[0]] != (58 as u8) { run = 0 } else {
190 pos[0] = pos[0] + 1
191 let vv: i64 = ws2_num_at(sp7, pos)
192 if iv >= 7 { if iv <= 58 { sp[iv] = vv; applied = applied + 1 } }
193 if sp7[pos[0]] == (44 as u8) { pos[0] = pos[0] + 1 } else { run = 0 }
194 }
195 }
196 }
197 var t: i64 = 0
198 while t < ticks { tick_impl(base, 16); t = t + 1 }
199 // ★FULL RESOLUTION IS THE DEFAULT ON EVERY PATH, NOT ONLY ON `char` (operator 2026-08-28: "when you
200 // screenshot it needs to be full resolution not this bullshit sampled tiny stuff make sure this is
201 // true everywhere, we are fine with the cost to make sure the product is the best it can be").
202 // The `char` verb ALREADY set q=1 and derived exactly why (its comment is below, unchanged). The
203 // WORLD path and the `gt` DATASET-FACTORY path did NOT, so they rendered at whatever the browser's
204 // adaptive frame-time controller happened to land on during the tick loop above.
205 // MEASURED 2026-08-28 on the bare default invocation: w=240 h=150 -- q=8, i.e. 36,000 of the
206 // engine's 2,304,000 native pixels (15 permil of the product's own resolution). Two things follow
207 // and both are defects: the published product frame (nx_world_emit -> /world/emit_craft.png) shipped
208 // at 240x150, and every art verdict taken from this instrument was a verdict about 1/64 of the
209 // picture. ★A CAPTURE WHOSE RESOLUTION IS SET BY A LOAD-SENSITIVE GOVERNOR MAKES EVERY VERDICT A
210 // FUNCTION OF BOX LOAD RATHER THAN OF THE SUBJECT -- and it fails toward LESS evidence exactly when
211 // the estate is busiest, which is when nobody has time to notice.
212 // A REDUCTION IS STILL AVAILABLE AND MUST BE ASKED FOR BY NAME: `q=<n>` anywhere in argv. It is a
213 // KEYWORD, never a positional, because every positional index here is load-bearing (nx_world_emit
214 // forks this organ on a fixed 5-arg contract) and a new slot would silently reinterpret an existing
215 // caller's arguments. The chosen q and the resulting fraction of native are ANNOUNCED below, so a
216 // reduced capture can never pass itself off as a full one.
217 let wsq: *i64 = wst(base)
218 var qsel: i64 = WS_Q_NATIVE
219 var qk: i64 = 1
220 while qk < argc {
221 let av: *u8 = argv[qk] as *u8
222 if av[0] == (WS_CH_Q as u8) { if av[1] == (WS_CH_EQ as u8) {
223 let qp: *i64 = sys_mmap(WS_CURSOR_BYTES) as *i64
224 qp[0] = WS_QKW_LEN
225 let qv: i64 = ws2_num_at(av, qp)
226 if qv >= WS_Q_NATIVE { qsel = qv }
227 } }
228 qk = qk + 1
229 }
230 // clamp to the ENGINE's own declared range instead of declaring a second one: two guards for one
231 // invariant is the duplicate-ruler defect, and the engine is the owner of what q may be.
232 if qsel > Q_MAX { qsel = Q_MAX }
233 wsq[S_Q] = qsel
234 // THE `percept` KEYWORD, scanned anywhere in argv for exactly the reason `q=` is: every positional
235 // index in this organ is load-bearing (nx_world_emit forks it on a fixed 5-arg contract) and a new
236 // slot would silently reinterpret an existing caller's arguments. Put it LAST, after ticks.
237 var perceptmode: i64 = 0
238 var pck: i64 = 1
239 while pck < argc {
240 if ws2_streq(argv[pck] as *u8, "percept" as *u8) == 1 { perceptmode = 1 }
241 pck = pck + 1
242 }
243 // ★CHARACTER FRAMING. The world snapshot renders whatever the spawn camera happens to face, and
244 // MEASURED 2026-08-15 that frames no girl at all: judging craft before and after a genome-shading
245 // change returned BYTE-IDENTICAL axes -- composition 246, palette 343, contour 933,
246 // palette_buckets 176, edge_total 10761 -- because the subject was never in the picture. A referee
247 // is only as good as the frame it is handed, and a capture that cannot see a character cannot grade
248 // character work no matter how good the judge is.
249 // The placement recipe is T59's (stand her along the camera forward axis, on the ground, camera at
250 // eye height) -- but the DISTANCE diverged from the tooth's on 2026-08-16, deliberately and declared
251 // on the board BEFORE it moved: T59 proves VISIBILITY at gameplay distance (4 blocks), while this
252 // instrument takes a PORTRAIT for the figure judge, and the two subjects earn different framings.
253 // The portrait distance is DERIVED, not tasted: composition needs shaded regions wider than the
254 // judge's 16px cell, so the torso (diameter 2*chest radius = 44 q8) must span >= 2 cells (32px);
255 // at q=1 (foc = 600) that requires vz <= 44*600/32 = 825 q8, and TWO BLOCKS (512) gives a 51px
256 // torso -- about 3 cells with margin -- while her 308px height still fits the 750px frame.
257 // ⚠CALIBRATION BREAK: crop numbers before/after this change are NOT comparable; the flat-vs-lit
258 // delta was completed at the old distance first, precisely so this break costs no history.
259 // Every other girl is parked far away so the judge's numbers are attributable to HER, not a crowd --
260 // the same reason T59 moves them all for its negative control.
261 var framed: i64 = 0
262 var framed_gy: i64 = 0 - 1
263 // DENOMINATOR FOR THE FRAMING CLAIM. framed=1 used to mean only "a ground cell was found and
264 // en_nth(mc,0) returned a positive handle" -- and en_nth over an EMPTY store still hands back a
265 // positive-looking handle, so an empty cast framed=1 with nothing in the picture to frame.
266 // MEASURED 2026-09-01 on the beach: CHAR-FRAME framed=1 ground_y=11 followed immediately by
267 // CHAR-CROP pixels=0, because genmobs only places a girl on a cell whose block is GRASS
268 // (vget == 1) below the snow line -- a sand world spawns no cast at all, and the framing tooth
269 // could not tell "she is standing there" from "there is nobody in this world".
270 var framed_mobs: i64 = 0 - 1
271 var framed_spawned: i64 = 0
272 if charmode == 1 {
273 let sc: *i64 = wst(base)
274 let mc: *i64 = mobp(base)
275 sc[S_PITCH] = 0
276 // ★NATIVE CAPTURE AFFORDS FULL RESOLUTION. The browser's adaptive controller trades rays for
277 // frame time; this instrument runs once, offline, so it renders at q=1. At the adaptive default
278 // the girl is ~180px of a 36,000px frame -- below the judge's 16px cell statistics -- and a
279 // subject crop of that is a handful of cells. At q=1 she is thousands of pixels: a real subject
280 // image. Announced in the WORLD-SNAP line via w=/h=, so a capture that silently fell back to the
281 // small frame is visible.
282 // ★THE SETTER MOVED OUT OF THIS BRANCH ON 2026-08-28 AND NOW SERVES EVERY PATH (see the block
283 // after the tick loop). It was correct here and absent from its two siblings -- the world path
284 // and the `gt` dataset factory -- which is a third of a fix, and the two left undone were the
285 // art-verdict path and the training-data factory. The literal "1200x750" this comment used to
286 // quote was ALSO stale: the engine ceiling has been 1920x1200 since the render cap was derived
287 // from the page's own display cap, so the number that justified the rule had drifted from the
288 // rule. Nothing is set here now, deliberately: one owner of q, not two.
289 let fxc: i64 = it_sin4096(sc[S_YAW])
290 let fzc: i64 = it_cos4096(sc[S_YAW])
291 let txc: i64 = sc[S_CX] + fxc*2*256/K_MAGIC_4096
292 let tzc: i64 = sc[S_CZ] + fzc*2*256/K_MAGIC_4096
293 let gyc: i64 = mob_ground(base, txc/256, WY-1, tzc/256)
294 framed_mobs = en_count(mc)
295 // THE PORTRAIT VERB OWNS ITS SUBJECT. If the world's own generator placed no cast, this
296 // instrument spawns exactly one and says so -- so a portrait of an EMPTY world can never be
297 // mistaken for a portrait of an inhabited one, and the figure judge is never handed scenery
298 // and asked to grade a character. A world that already has a cast is untouched: this branch
299 // cannot run there, so the behaviour of every existing caller is unchanged by construction.
300 if framed_mobs == 0 { if gyc >= 0 {
301 let hn0: i64 = en_spawn(mc)
302 if hn0 > 0 {
303 en_set(mc, hn0, MC_KIND, 0)
304 en_set(mc, hn0, MC_PH, 0)
305 en_set(mc, hn0, MC_DISG, 0)
306 en_set(mc, hn0, MC_GENE, seed % WATER_MAGIC_1048576)
307 framed_spawned = 1
308 framed_mobs = en_count(mc)
309 }
310 } }
311 // BIND THE HANDLE TO THE COUNT: over an empty store en_nth answers a handle that looks valid,
312 // which is exactly how framed=1 was published for a world with nobody in it.
313 var hc: i64 = 0
314 if framed_mobs > 0 { hc = en_nth(mc, 0) }
315 framed_gy = gyc
316 if gyc >= 0 { if hc > 0 {
317 var kc: i64 = 1
318 while kc < en_count(mc) {
319 let hk: i64 = en_nth(mc, kc)
320 if hk > 0 { en_set(mc, hk, MC_X, 256); en_set(mc, hk, MC_Z, 256) }
321 kc = kc + 1
322 }
323 en_set(mc, hc, MC_X, txc)
324 en_set(mc, hc, MC_Z, tzc)
325 en_set(mc, hc, MC_Y, (gyc+1)*256)
326 // SEAT THE CAMERA ON THE HIGHER OF THE TWO COLUMNS, NEVER BLINDLY ON THE SUBJECT'S.
327 // This line used to read `sc[S_CY] = (gyc+1)*256 + 128` -- the camera was re-seated onto the
328 // ground height of a column TWO BLOCKS AWAY. Where that column is LOWER than the one the
329 // camera stands on, the camera is planted inside its own column's top block and the subject
330 // is occluded by the terrain between them. MEASURED 2026-09-01, and it is the WHOLE of the
331 // CHAR-CROP pixels=0 defect: on craft (cam_ground 20 == subj_ground 20) the crop measures
332 // 1866 subject pixels and on vale (29 == 29) 1990, while on beach and isle -- the only two
333 // shipped worlds where the two DIFFER (12 vs 11) -- it measured exactly 0, at every q from
334 // 1 to 8. Taking the MAXIMUM is BYTE-NEUTRAL wherever they are equal, which is every world
335 // that already worked, so the fix cannot regress a capture that was already correct.
336 var seat_gy: i64 = gyc
337 let cam_gy0: i64 = mob_ground(base, sc[S_CX]/256, WY-1, sc[S_CZ]/256)
338 if cam_gy0 > seat_gy { seat_gy = cam_gy0 }
339 sc[S_CY] = (seat_gy+1)*256 + 128
340 framed = 1
341 // ATTRIBUTION FOR AN EMPTY CROP. CHAR-CROP pixels=0 says only "the two renders agree"; it
342 // cannot say WHICH conjunct of "a subject is in this picture" failed, and a bare 0 reads as
343 // "the crop is broken" when it may equally mean "she was placed somewhere the camera cannot
344 // see". These four numbers separate those: cam_ground vs subj_ground says whether the camera
345 // was re-seated onto a column two blocks away that is LOWER than the one it stands on (which
346 // buries it inside the spawn column), and subj_vz_q8 is her view-space depth in the SAME q8
347 // units mob_draw's own visibility window uses. The window itself is deliberately NOT restated
348 // here: a second copy of the engine's bounds is a duplicate ruler that drifts silently. Pitch
349 // is zero on this path by construction three lines above, so forward reduces to (sin, 0, cos).
350 let cam_gy: i64 = mob_ground(base, sc[S_CX]/256, WY-1, sc[S_CZ]/256)
351 let dqx: i64 = txc - sc[S_CX]
352 let dqz: i64 = tzc - sc[S_CZ]
353 let fvx: i64 = it_sin4096(sc[S_YAW])
354 let fvz: i64 = it_cos4096(sc[S_YAW])
355 let vzq: i64 = (dqx*fvx + dqz*fvz)/K_MAGIC_4096
356 ws2_puts("CHAR-GEOM cam_ground=" as *u8); ws2_pn(cam_gy)
357 ws2_puts(" subj_ground=" as *u8); ws2_pn(gyc)
358 ws2_puts(" cam_y_q8=" as *u8); ws2_pn(sc[S_CY])
359 ws2_puts(" subj_y_q8=" as *u8); ws2_pn((gyc+1)*256)
360 ws2_puts(" subj_vz_q8=" as *u8); ws2_pn(vzq)
361 ws2_puts("\n" as *u8)
362 } }
363 }
364 // ★BIND THE POINTER, THEN INDEX IT. `wst(base)[S_GT_KEEP] = 1` does not parse as an assignment
365 // target in this dialect -- the parser closes the expression after the postfix index and then meets
366 // a bare `=` (token kind=45, "an operator starts this expression"). MEASURED 2026-08-28: this line
367 // failed EVERY build of this organ, so the `gt` ground-truth verb could not be compiled at all and
368 // the served binary predates it. The compiler's own remedy is the one taken here, and it is the
369 // idiom this file already uses three lines up (`let sc: *i64 = wst(base)`).
370 if gtmode == 1 {
371 let gts: *i64 = wst(base)
372 gts[S_GT_KEEP] = 1
373 }
374 render_impl(base)
375 // ANNOUNCE THE FRAMING so its ABSENCE is visible in normal output -- a capture that silently fell
376 // back to the world view is exactly how a null measurement gets read as a real one.
377 if charmode == 1 {
378 ws2_puts("CHAR-FRAME framed=" as *u8); ws2_pn(framed)
379 ws2_puts(" ground_y=" as *u8); ws2_pn(framed_gy)
380 ws2_puts(" mobs=" as *u8); ws2_pn(framed_mobs)
381 ws2_puts(" spawned=" as *u8); ws2_pn(framed_spawned)
382 ws2_puts("\n" as *u8)
383 }
384 // ★SUBJECT CROP: THE DIFF *IS* THE GIRL. T63's proven recipe promoted into the capture instrument:
385 // bank the framed render, park her, render the SAME scene without her, and every differing pixel is
386 // attributable to HER -- so the crop rectangle is MEASURED, never guessed, and the frame-level judge
387 // can finally be pointed at the subject instead of at 36,000 pixels of scenery it already scored.
388 // The margin is CHJ-cell-derived at the call site (the judge's own 16px composition cell), not a
389 // taste constant. A framed=1 run with ZERO differing pixels announces pixels=0 and writes NO crop --
390 // a capture that silently fell back to scenery is exactly how a null measurement reads as a real one.
391 if charmode == 1 { if framed == 1 {
392 let cw3: i64 = wc_rw(base)
393 let ch3: i64 = wc_rh(base)
394 let np3: i64 = cw3*ch3
395 let fbm: *i64 = wfb(base)
396 let s1: *i64 = sys_mmap(np3*8) as *i64
397 var c1: i64 = 0
398 while c1 < np3 { s1[c1] = fbm[c1]; c1 = c1 + 1 }
399 // park the subject, re-render the identical scene
400 let mc2: *i64 = mobp(base)
401 let hc2: i64 = en_nth(mc2, 0)
402 en_set(mc2, hc2, MC_X, 256)
403 en_set(mc2, hc2, MC_Z, 256)
404 render_impl(base)
405 var cnt3: i64 = 0
406 var bx0: i64 = cw3
407 var bx1: i64 = 0 - 1
408 var by0: i64 = ch3
409 var by1: i64 = 0 - 1
410 var d3: i64 = 0
411 while d3 < np3 {
412 if s1[d3] != fbm[d3] {
413 cnt3 = cnt3 + 1
414 let qx: i64 = d3 % cw3
415 let qy: i64 = d3 / cw3
416 if qx < bx0 { bx0 = qx }
417 if qx > bx1 { bx1 = qx }
418 if qy < by0 { by0 = qy }
419 if qy > by1 { by1 = qy }
420 }
421 d3 = d3 + 1
422 }
423 // restore the FRAMED image into the fb so the main PNG below is the picture with her in it
424 c1 = 0
425 while c1 < np3 { fbm[c1] = s1[c1]; c1 = c1 + 1 }
426 sys_munmap(s1 as *u8, np3*8)
427 ws2_puts("CHAR-CROP pixels=" as *u8); ws2_pn(cnt3)
428 if cnt3 > 0 { if bx1 >= bx0 { if by1 >= by0 {
429 // margin = one judge composition cell (16px) of surrounding context on every side, clamped:
430 // derived from the consumer's own cell size, so the crop always hands the judge at least one
431 // ring of non-subject cells to hold composition against
432 var mx0: i64 = bx0 - 16
433 var my0: i64 = by0 - 16
434 var mx1: i64 = bx1 + 16
435 var my1: i64 = by1 + 16
436 if mx0 < 0 { mx0 = 0 }
437 if my0 < 0 { my0 = 0 }
438 if mx1 > cw3-1 { mx1 = cw3-1 }
439 if my1 > ch3-1 { my1 = ch3-1 }
440 let ww4: i64 = mx1 - mx0 + 1
441 let hh4: i64 = my1 - my0 + 1
442 let fillb: i64 = (bx1-bx0+1)*(by1-by0+1)
443 var fillp3: i64 = 0
444 if fillb > 0 { fillp3 = cnt3*1000/fillb }
445 ws2_puts(" bbox=" as *u8); ws2_pn(bx0); ws2_puts("," as *u8); ws2_pn(by0)
446 ws2_puts("," as *u8); ws2_pn(bx1); ws2_puts("," as *u8); ws2_pn(by1)
447 ws2_puts(" fill_permil=" as *u8); ws2_pn(fillp3)
448 // crop path = <out>.crop.png -- a derived sibling, so one capture yields the pair the two
449 // judges need: the frame for scene teeth, the crop for FIGURE quality
450 let cpath: *u8 = sys_mmap(512)
451 var co: i64 = 0
452 while outp[co] != (0 as u8) { cpath[co] = outp[co]; co = co + 1 }
453 let csfx: *u8 = ".crop.png" as *u8
454 var cs2: i64 = 0
455 while csfx[cs2] != (0 as u8) { cpath[co+cs2] = csfx[cs2]; cs2 = cs2 + 1 }
456 cpath[co+cs2] = 0 as u8
457 let crgb: *u8 = sys_mmap(ww4*hh4*3 + 16)
458 var ry: i64 = 0
459 while ry < hh4 {
460 var rx2: i64 = 0
461 while rx2 < ww4 {
462 let spx: i64 = fbm[(my0+ry)*cw3 + mx0+rx2]
463 let di: i64 = (ry*ww4 + rx2)*3
464 crgb[di] = (spx % 256) as u8
465 crgb[di+1] = ((spx/256) % 256) as u8
466 crgb[di+2] = ((spx/K_MAGIC_65536) % 256) as u8
467 rx2 = rx2 + 1
468 }
469 ry = ry + 1
470 }
471 nx_png_write_rgb(cpath, crgb, ww4, hh4)
472 sys_munmap(crgb, ww4*hh4*3 + 16)
473 ws2_puts(" crop=" as *u8); ws2_pn(ww4); ws2_puts("x" as *u8); ws2_pn(hh4)
474 ws2_puts(" wrote=" as *u8); ws2_puts(cpath)
475 } } }
476 ws2_puts("\n" as *u8)
477 } }
478 // ★READ THE EXTENT OF THE ARENA THIS ORGAN ACTUALLY RENDERED, NOT ARENA 0. ww()/hh() are the wasm
479 // export surface and are hardwired to arena 0 -- wc_rw(0)/wc_rh(0) -- while every render above goes
480 // into `base`, a fresh mmap this organ never registered as arena 0. The two agreed by luck; when they
481 // stopped agreeing the RGB loop below walked W*H words over a framebuffer of a different size and the
482 // process took SIGSEGV at an address ~1.15 MB out of range. MEASURED 2026-08-15: a full revert of this
483 // organ did NOT fix it, which is what proved the fault was the ARENA MISMATCH and not the change on
484 // top of it -- an unrelated edit to the craft module shifted arena 0's contents and turned a latent
485 // wrong-subject read into a fatal one.
486 // wc_rw/wc_rh take the base precisely so this cannot happen; the gate's own T58 already measures the
487 // written extent that way.
488 let W: i64 = wc_rw(base)
489 let H: i64 = wc_rh(base)
490 let fb: *i64 = wfb(base)
491 let rgb: *u8 = sys_mmap(W*H*3 + 16)
492 var p: i64 = 0
493 while p < W*H {
494 let px: i64 = fb[p]
495 rgb[p*3] = (px % 256) as u8
496 rgb[p*3+1] = ((px/256) % 256) as u8
497 rgb[p*3+2] = ((px/K_MAGIC_65536) % 256) as u8
498 p = p + 1
499 }
500 nx_png_write_rgb(outp, rgb, W, H)
501 if gtmode == 1 {
502 // DEPTH CHANNEL: bits 32..55 of every framebuffer word (FB_DEPTH_SHIFT/FB_DEPTH_MAX are the
503 // engine's own names). Sky/miss rays carry FB_DEPTH_MAX. Two artifacts per channel: a PNG for eyes
504 // (8-bit gray = depth >> 16, near bright) and a raw little-endian u16 plane (.d16) with the exact
505 // 24->16 clamped values, W*H*2 bytes, no header -- the dataset consumer reads W,H from the announce.
506 let dp: *i64 = sys_mmap(W*H*8 + 16) as *i64
507 var gq: i64 = 0
508 var gmin: i64 = FB_DEPTH_MAX
509 var gmax: i64 = 0
510 var ghit: i64 = 0
511 while gq < W*H {
512 let d24: i64 = (fb[gq] / (K_MAGIC_65536*K_MAGIC_65536)) & FB_DEPTH_MAX
513 dp[gq] = d24
514 if d24 < FB_DEPTH_MAX { ghit = ghit + 1; if d24 < gmin { gmin = d24 } if d24 > gmax { gmax = d24 } }
515 gq = gq + 1
516 }
517 // depth PNG (gray) + raw u16
518 let dpng: *u8 = sys_mmap(W*H*3 + 16)
519 let d16: *u8 = sys_mmap(W*H*2 + 16)
520 gq = 0
521 while gq < W*H {
522 var d16v: i64 = dp[gq] / 256
523 if d16v > WS_D16_MAX { d16v = WS_D16_MAX }
524 let inv: i64 = WS_D16_MAX - d16v
525 let g8: i64 = inv / 256
526 dpng[gq*3] = g8 as u8; dpng[gq*3+1] = g8 as u8; dpng[gq*3+2] = g8 as u8
527 d16[gq*2] = (d16v % 256) as u8; d16[gq*2+1] = (d16v / 256) as u8
528 gq = gq + 1
529 }
530 let dpp: *u8 = sys_mmap(512)
531 var dq: i64 = 0
532 while outp[dq] != (0 as u8) { dpp[dq] = outp[dq]; dq = dq + 1 }
533 var dsx: *u8 = ".depth.png" as *u8
534 var dq2: i64 = 0
535 while dsx[dq2] != (0 as u8) { dpp[dq+dq2] = dsx[dq2]; dq2 = dq2 + 1 }
536 dpp[dq+dq2] = 0 as u8
537 nx_png_write_rgb(dpp, dpng, W, H)
538 ws2_puts("GT-DEPTH wrote=" as *u8); ws2_puts(dpp)
539 ws2_puts(" hits=" as *u8); ws2_pn(ghit); ws2_puts(" of=" as *u8); ws2_pn(W*H)
540 ws2_puts(" dmin=" as *u8); ws2_pn(gmin); ws2_puts(" dmax=" as *u8); ws2_pn(gmax); ws2_puts("\n" as *u8)
541 dsx = ".d16" as *u8
542 dq2 = 0
543 while dsx[dq2] != (0 as u8) { dpp[dq+dq2] = dsx[dq2]; dq2 = dq2 + 1 }
544 dpp[dq+dq2] = 0 as u8
545 let dfd: i64 = sys_openat_wr(dpp, K_MODE_RW)
546 if dfd >= 0 { sys_write(dfd, d16, W*H*2); sys_close(dfd); ws2_puts("GT-D16 wrote=" as *u8); ws2_puts(dpp); ws2_puts(" bytes=" as *u8); ws2_pn(W*H*2); ws2_puts(" w=" as *u8); ws2_pn(W); ws2_puts(" h=" as *u8); ws2_pn(H); ws2_puts("\n" as *u8) }
547 // NORMAL CHANNEL, DERIVED FROM DEPTH: central differences on the depth plane, n = normalize(-dx, -dy, k),
548 // integer, encoded (n+1)*127. Miss rays get the flat (128,128,255). Labeled DERIVED in the announce.
549 let npng: *u8 = sys_mmap(W*H*3 + 16)
550 var ny: i64 = 0
551 while ny < H {
552 var nx: i64 = 0
553 while nx < W {
554 let ci: i64 = ny*W + nx
555 var r8: i64 = 128
556 var g8b: i64 = 128
557 var b8: i64 = 255
558 if dp[ci] < FB_DEPTH_MAX {
559 var xl: i64 = nx - 1
560 var xr: i64 = nx + 1
561 var yu: i64 = ny - 1
562 var yd: i64 = ny + 1
563 if xl < 0 { xl = 0 }
564 if xr >= W { xr = W - 1 }
565 if yu < 0 { yu = 0 }
566 if yd >= H { yd = H - 1 }
567 var dxv: i64 = dp[ny*W + xr] - dp[ny*W + xl]
568 var dyv: i64 = dp[yd*W + nx] - dp[yu*W + nx]
569 // a miss neighbour would inject a cliff; clamp gradient at the object edge
570 if dp[ny*W + xr] >= FB_DEPTH_MAX { dxv = 0 }
571 if dp[ny*W + xl] >= FB_DEPTH_MAX { dxv = 0 }
572 if dp[yd*W + nx] >= FB_DEPTH_MAX { dyv = 0 }
573 if dp[yu*W + nx] >= FB_DEPTH_MAX { dyv = 0 }
574 // scale: depth units per pixel step -- k = 2 pixel-steps in depth units at this
575 // resolution; derived from the frame width so it does not drift with q
576 let kz: i64 = 2 * (FB_DEPTH_MAX / (W * 4))
577 var ax: i64 = 0 - dxv
578 var ay: i64 = 0 - dyv
579 var az: i64 = kz
580 // integer normalize via isqrt
581 let m2: i64 = ax*ax + ay*ay + az*az
582 var m: i64 = 1
583 if m2 > 1 { var lo: i64 = 1; var hi: i64 = m2; if hi > WS_ISQRT_HI_BOUND { hi = WS_ISQRT_HI_BOUND } while lo < hi { let mid: i64 = (lo + hi + 1) / 2; if mid*mid <= m2 { lo = mid } else { hi = mid - 1 } } m = lo }
584 if m < 1 { m = 1 }
585 r8 = 128 + ax*127/m
586 g8b = 128 + ay*127/m
587 b8 = 128 + az*127/m
588 if r8 < 0 { r8 = 0 } if r8 > 255 { r8 = 255 }
589 if g8b < 0 { g8b = 0 } if g8b > 255 { g8b = 255 }
590 if b8 < 0 { b8 = 0 } if b8 > 255 { b8 = 255 }
591 }
592 npng[ci*3] = r8 as u8; npng[ci*3+1] = g8b as u8; npng[ci*3+2] = b8 as u8
593 nx = nx + 1
594 }
595 ny = ny + 1
596 }
597 dsx = ".normal.png" as *u8
598 dq2 = 0
599 while dsx[dq2] != (0 as u8) { dpp[dq+dq2] = dsx[dq2]; dq2 = dq2 + 1 }
600 dpp[dq+dq2] = 0 as u8
601 nx_png_write_rgb(dpp, npng, W, H)
602 ws2_puts("GT-NORMAL wrote=" as *u8); ws2_puts(dpp); ws2_puts(" derived=from-depth-gradient\n" as *u8)
603 }
604 // ALSO emit NXFH1 text-hex beside the PNG so nx_frame_score (the game-frame art critic)
605 // can judge the same frame -- one capture, two judges (debt 1786578438 second opinion)
606 let fhp: *u8 = sys_mmap(512)
607 var fq: i64 = 0
608 let a1: *u8 = outp
609 while a1[fq] != (0 as u8) { fhp[fq] = a1[fq]; fq = fq + 1 }
610 let sfx: *u8 = ".nxfh" as *u8
611 var fq2: i64 = 0
612 while sfx[fq2] != (0 as u8) { fhp[fq+fq2] = sfx[fq2]; fq2 = fq2 + 1 }
613 fhp[fq+fq2] = 0 as u8
614 // COMPOSE THE CODEC, DO NOT RE-TYPE IT. This block used to be a hand-rolled NXFH1 writer -- header,
615 // decimal width/height, a 16-byte hex table and the row-end newline -- sitting beside
616 // _hdl_build/nx_nxfh_lib.nx's nxl_dump(path, fb, w, h), which is the estate's ONE owner of that
617 // format and does exactly this. Two writers for one format is the duplicate-ruler defect: the day
618 // the format gains a field, one of them gets it. The fb layout already matched (packed
619 // r | g<<8 | b<<16, compact at stride w), so the swap is a pure composition, and NEUTRALITY IS
620 // PROVEN RATHER THAN ASSERTED -- the emitted .nxfh is byte-identical before and after, hashed both
621 // sides. The writer's return is ANNOUNCED so a failed open is visible in normal output instead of
622 // being swallowed by an `if fd >= 0` with no else.
623 let fhn: i64 = nxl_dump(fhp, fb, W, H)
624 ws2_puts("SNAP-NXFH bytes=" as *u8); ws2_pn(fhn)
625 ws2_puts(" wrote=" as *u8); ws2_puts(fhp); ws2_puts("\n" as *u8)
626 // PERCEPT ANCHOR CAPTURE -- the second consumer this instrument could not reach. nx_frame_score
627 // eats any size; nx_percept compares against a corpus that is 400x240 in every anchor, so a native
628 // capture was scoreable but NOT COMPARABLE. This emits the same frame at the anchor geometry.
629 // THE FACTOR IS DERIVED, NOT RESAMPLED: pk is the largest integer with 400*pk <= W and 240*pk <= H
630 // (here 4, because 5 would need 2000 columns of a 1920-column frame), so the reduction is an exact
631 // pk x pk BOX AVERAGE over a centred 400*pk x 240*pk crop. Two consequences, both deliberate:
632 // there is no interpolation kernel to choose, and the ASPECT IS NEVER SQUASHED -- the crop is taken
633 // at the anchor's own aspect first. A straight rescale of 8:5 into 5:3 would distort every contour
634 // the perceptual judge measures, which is the measure-the-wrong-subject defect wearing a resize.
635 // The crop rectangle and the factor are ANNOUNCED so a reader can tell what was thrown away.
636 if perceptmode == 1 {
637 var pcpk: i64 = W/WS_PERCEPT_W
638 if H/WS_PERCEPT_H < pcpk { pcpk = H/WS_PERCEPT_H }
639 if pcpk < 1 {
640 // A NAMED ABSENCE, NEVER A SILENT SKIP: a frame smaller than the anchor cannot be reduced
641 // to it without inventing pixels, and inventing them would hand the judge a fabrication.
642 ws2_puts("PERCEPT REFUSED render=" as *u8); ws2_pn(W); ws2_puts("x" as *u8); ws2_pn(H)
643 ws2_puts(" anchor=" as *u8); ws2_pn(WS_PERCEPT_W); ws2_puts("x" as *u8); ws2_pn(WS_PERCEPT_H)
644 ws2_puts(" -- the render is smaller than the anchor; upscaling would invent pixels\n" as *u8)
645 } else {
646 let pccw: i64 = WS_PERCEPT_W*pcpk
647 let pcch: i64 = WS_PERCEPT_H*pcpk
648 let pcox: i64 = (W - pccw)/2
649 let pcoy: i64 = (H - pcch)/2
650 let pcn: i64 = pcpk*pcpk
651 let pcfb: *i64 = sys_mmap(WS_PERCEPT_W*WS_PERCEPT_H*8) as *i64
652 let pcrgb: *u8 = sys_mmap(WS_PERCEPT_W*WS_PERCEPT_H*3 + 16)
653 var pcy: i64 = 0
654 while pcy < WS_PERCEPT_H {
655 var pcx: i64 = 0
656 while pcx < WS_PERCEPT_W {
657 var pcsr: i64 = 0
658 var pcsg: i64 = 0
659 var pcsb: i64 = 0
660 var pcby: i64 = 0
661 while pcby < pcpk {
662 var pcbx: i64 = 0
663 while pcbx < pcpk {
664 let pcsi: i64 = ((pcoy + pcy*pcpk + pcby)*W + pcox + pcx*pcpk + pcbx)*3
665 pcsr = pcsr + (rgb[pcsi] as i64)
666 pcsg = pcsg + (rgb[pcsi+1] as i64)
667 pcsb = pcsb + (rgb[pcsi+2] as i64)
668 pcbx = pcbx + 1
669 }
670 pcby = pcby + 1
671 }
672 let pcr: i64 = pcsr/pcn
673 let pcg: i64 = pcsg/pcn
674 let pcb: i64 = pcsb/pcn
675 let pcdi: i64 = (pcy*WS_PERCEPT_W + pcx)*3
676 pcrgb[pcdi] = pcr as u8
677 pcrgb[pcdi+1] = pcg as u8
678 pcrgb[pcdi+2] = pcb as u8
679 pcfb[pcy*WS_PERCEPT_W + pcx] = pcr + pcg*256 + pcb*K_MAGIC_65536
680 pcx = pcx + 1
681 }
682 pcy = pcy + 1
683 }
684 let pcpp: *u8 = sys_mmap(512)
685 var pcq: i64 = 0
686 while outp[pcq] != (0 as u8) { pcpp[pcq] = outp[pcq]; pcq = pcq + 1 }
687 let pcsx: *u8 = ".percept.png" as *u8
688 var pcq2: i64 = 0
689 while pcsx[pcq2] != (0 as u8) { pcpp[pcq+pcq2] = pcsx[pcq2]; pcq2 = pcq2 + 1 }
690 pcpp[pcq+pcq2] = 0 as u8
691 nx_png_write_rgb(pcpp, pcrgb, WS_PERCEPT_W, WS_PERCEPT_H)
692 let pcnp: *u8 = sys_mmap(512)
693 pcq = 0
694 while outp[pcq] != (0 as u8) { pcnp[pcq] = outp[pcq]; pcq = pcq + 1 }
695 let pcnx: *u8 = ".percept.nxfh" as *u8
696 pcq2 = 0
697 while pcnx[pcq2] != (0 as u8) { pcnp[pcq+pcq2] = pcnx[pcq2]; pcq2 = pcq2 + 1 }
698 pcnp[pcq+pcq2] = 0 as u8
699 let pcnb: i64 = nxl_dump(pcnp, pcfb, WS_PERCEPT_W, WS_PERCEPT_H)
700 ws2_puts("PERCEPT anchor=" as *u8); ws2_pn(WS_PERCEPT_W); ws2_puts("x" as *u8); ws2_pn(WS_PERCEPT_H)
701 ws2_puts(" factor=" as *u8); ws2_pn(pcpk)
702 ws2_puts(" crop=" as *u8); ws2_pn(pccw); ws2_puts("x" as *u8); ws2_pn(pcch)
703 ws2_puts("+" as *u8); ws2_pn(pcox); ws2_puts("+" as *u8); ws2_pn(pcoy)
704 ws2_puts(" nxfh_bytes=" as *u8); ws2_pn(pcnb)
705 ws2_puts(" wrote=" as *u8); ws2_puts(pcpp); ws2_puts(" " as *u8); ws2_puts(pcnp)
706 ws2_puts("\n" as *u8)
707 }
708 }
709 // readback: the FILE is the claim, never the writer's return
710 let lp: *i64 = sys_mmap(16) as *i64
711 let rb: *u8 = sys_read_file(outp, lp)
712 if (rb as i64) == 0 { ws2_puts("SNAP-FAIL: png not written\n" as *u8); return 5 }
713 ws2_puts("WORLD-SNAP v=" as *u8); ws2_pn(v)
714 ws2_puts(" seed=" as *u8); ws2_pn(seed)
715 ws2_puts(" ticks=" as *u8); ws2_pn(ticks)
716 ws2_puts(" style_applied=" as *u8); ws2_pn(applied)
717 ws2_puts(" gen_applied=" as *u8); ws2_pn(wst(base)[S_GENP])
718 ws2_puts(" w=" as *u8); ws2_pn(W)
719 ws2_puts(" h=" as *u8); ws2_pn(H)
720 // ★EVERY CAPTURE DECLARES ITS RESOLUTION AS A FRACTION OF THE PRODUCT'S OWN NATIVE RESOLUTION.
721 // w=/h= alone cannot answer "is this full resolution?" -- that question needs the ceiling beside the
722 // measurement, and the ceiling lives in the engine, not in the reader's head. res_permil is DERIVED
723 // from the two extents at emit time and res_class is derived from res_permil, so neither can agree
724 // with a flag while disagreeing with the pixels. This is the field the capture-resolution gate reads:
725 // a verdict built on a capture below the declared product resolution is refusable BECAUSE the
726 // capture said so itself.
727 ws2_puts(" q=" as *u8); ws2_pn(qsel)
728 ws2_puts(" native_w=" as *u8); ws2_pn(ws2_natw())
729 ws2_puts(" native_h=" as *u8); ws2_pn(ws2_nath())
730 let ws_natpx: i64 = ws2_natw()*ws2_nath()
731 var ws_permil: i64 = 0
732 if ws_natpx > 0 { ws_permil = W*H*WS_PERMIL/ws_natpx }
733 ws2_puts(" res_permil=" as *u8); ws2_pn(ws_permil)
734 ws2_puts(" res_class=" as *u8)
735 if ws_permil >= WS_PERMIL { ws2_puts("FULL" as *u8) } else { ws2_puts("REDUCED" as *u8) }
736 ws2_puts(" skytop_rgb=" as *u8); ws2_pn(fb[0] % 256)
737 ws2_puts("," as *u8); ws2_pn((fb[0]/256) % 256)
738 ws2_puts("," as *u8); ws2_pn((fb[0]/K_MAGIC_65536) % 256)
739 ws2_puts(" png_bytes=" as *u8); ws2_pn(lp[0])
740 ws2_puts("\n" as *u8)
741 return 0
742}