code wiki / _hdl_build / nx_wire_crawl_gate.nx

nx_wire_crawl_gate.nx

buildroot/runtime/_hdl_build/nx_wire_crawl_gate.nx

42427 B1087 linesdepth 5pulls 18 transitivereach 0 importersview sourcekind gate/prooftopic wire
docsdependenciesstructsconstsfunctions

about

nx_wire_crawl_gate.nx -- TITLE WIRING #4: Dungeon Crawl Stone Soup (roguelike). 2026-08-23. Composes the SAME certified parts as the proven NetHack wiring (nx_wire_nethack_gate, 12/12 GREEN) plus the LOOT part exactly as the proven Diablo II wiring exercises it (nx_wire_diablo2_gate 14/14): every kill rolls an item through nx_loottable's lt_roll, audited in-loop (no duplicate affixes, values in declared range), and the loot is CAUSAL in the economy -- tier>=2 drops grant a ration that the inventory conservation ledger must then balance exactly. CAPS EXERCISED (bit = nx_gamebench capability index, set ONLY if its tooth passes; the mask is written into knowledge/nx_wire_crawl.sav payload[0] so nx_gamebench_gate can cross-check): bit 3 procgen-world bit 7 pathfinding-ai bit 6 entity-component-sim bit 9 rpg-stats-progression bit 11 inventory-crafting bit 14 text-render-typography bit 15 save-load-persistence bit 18 ui-menus-hud bit 25 asset-pipeline-import bit 10 loot-item-tables (the crawl-specific addition; Diablo II lt_roll pattern) Full mask when all teeth pass = 33868488 (NetHack's proven set) + 1024 (bit 10) = 33869512, which EQUALS the board's required vector ttmk[8] -- readiness 1000 permil is reachable, measured. DIALECT (inherited from the donor, which found these traps): no else-if chains with declarations, no ||, flag variables instead of else branches in game code; ASCII-only comments (the 08-22 non-ASCII-reached-codegen landmine); per-kill sys_mmap in the loot block mirrors the proven d2 wiring (about 18 kills per run -- not a hot loop). license_tier: ORIGINAL expect_exit: 0

dependencies 11 imports · 0 importers

nx_syscalls.nx nx_gamesave.nx nx_rpgstats.nx nx_entity_store.nx nx_pathfind.nx nx_loottable.nx nx_gamehud.nx nx_wire_harness.nx nx_gate_verdict.nx nx_trimesh.nx nx_wire_crawl_gate.nx

diagram shows first 10 each side; +1 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_gamesave.nxnx_rpgstats.nxnx_entity_store.nxnx_pathfind.nxnx_loottable.nxnx_gamehud.nxnx_wire_harness.nxnx_gate_verdict.nxnx_trimesh.nxnx_objload.nx

imported by: nobody (leaf or entry point)

structs

none

consts

35const CR_W: i64 = 24
36const CR_H: i64 = 12
37const CR_DEPTH: i64 = 3
38const CR_NMON: i64 = 6
39const CR_NITEM: i64 = 5
40const CR_CAP: i64 = 16
41const CR_NCOMP: i64 = 4
42const CR_CARVE: i64 = 140
43const CR_AGGRO: i64 = 8
44const CR_MAXT: i64 = 600
45const CR_XB: i64 = 20
46const CR_XQ: i64 = 10
47const CR_HPB: i64 = 10
48const CR_HPC: i64 = 2
49const CR_HPL: i64 = 3
50const CR_CON: i64 = 14
51const CR_BITE: i64 = 2
52const CR_MHPB: i64 = 12
53const CR_HEAL_R: i64 = 10
54const CR_HEAL_F: i64 = 25
56const CR_NTIER: i64 = 4
57const CR_NAFF: i64 = 5
59const CR_HDRN: i64 = 34
60const CR_HDRZ: i64 = 48 // header region zeroed on new/restore (grid starts at word 48)
61const CR_NSV: i64 = 114 // 34 hdr + 1 nmon + 16*4 monsters + 5*3 items
62const CR_SCHEMA: i64 = 7339 // next in the x9 wire series (nethack 7307, d2 7338)
63const CR_ART_SCHEMA: i64 = 7319 // wiring-evidence artifact schema (nethack 7317, d2 7318)
64const CR_T1W: i64 = 20 // transparency window: donor's calibration, win lands ~turn 62
65const CR_T2W: i64 = 45
67const CG_O_GRID: i64 = 48
68const CG_O_ITEM: i64 = 336
69const CG_O_ENT: i64 = 352
70const CG_O_PATH: i64 = 512
71const CG_O_G: i64 = 808
72const CG_O_F: i64 = 1104
73const CG_O_CAME: i64 = 1400
74const CG_O_OPENF: i64 = 1696
75const CG_O_CLOSED: i64 = 1992
76const CG_O_CARVE: i64 = 2288
77const CG_O_HUD: i64 = 2592
78const CG_WORDS: i64 = 2656
79const CR_HUDINK: i64 = 50
81const F_WS: i64 = 0
82const F_DEPTH: i64 = 1
83const F_TURN: i64 = 2
84const F_PX: i64 = 3
85const F_PY: i64 = 4
86const F_XP: i64 = 5
87const F_LVL: i64 = 6
88const F_HP: i64 = 7
89const F_KILLS: i64 = 8
90const F_RATION: i64 = 9
91const F_FEAST: i64 = 10
92const F_PICKED: i64 = 11
93const F_USED: i64 = 12
94const F_WIN: i64 = 13
95const F_COMB: i64 = 14
96const F_EATR: i64 = 15
97const F_EATF: i64 = 16
98const F_PSTEPS: i64 = 17
99const F_ATT: i64 = 18
100const F_BITES: i64 = 19
101const F_SPAWNED: i64 = 20
102const F_SX: i64 = 21
103const F_SY: i64 = 22
104const F_NCARVE: i64 = 23
105const F_GENRNG: i64 = 24
106const F_ABAND: i64 = 25
108const F_DROPS: i64 = 26
109const F_T0: i64 = 27
110const F_T1: i64 = 28
111const F_T2: i64 = 29
112const F_T3: i64 = 30
113const F_DUPAFF: i64 = 31
114const F_AFFBAD: i64 = 32
115const F_LOOTR: i64 = 33 // rations gained FROM LOOT (tier>=2) -- balances the ledger tooth

functions

117func ww(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
118func wn(v: i64) -> i64
127func cbit(i: i64) -> i64 { var v: i64=1; var k: i64=0; while k<i { v=v*2; k=k+1 } return v }
128func crng(g: *i64) -> i64
137func cabs(v: i64) -> i64 { if v<0 { return 0-v } return v }
139func cr_tables(tw: *i64, ta: *i64, aw: *i64, alo: *i64, ahi: *i64) -> i64
151func cr_genstruct(g: *i64) -> i64
183func cr_populate(g: *i64) -> i64
254func cr_new(g: *i64, ws: i64) -> i64
269func cr_serialize(g: *i64, S: *i64) -> i64
297func cr_restore(g: *i64, S: *i64) -> i64
326func cr_ckv(ck: i64, v0: i64) -> i64
331func cr_ck(g: *i64) -> i64
354func cr_moncell(a: *i64, x: i64, y: i64, skip: i64) -> i64
368func cr_tick(g: *i64) -> i64
576func cr_hudchain(seed: i64, turns: i64, out: *i64) -> i64
616func cr_decint(b: *u8, at: i64, v0: i64) -> i64
628func cr_clearfb(fb: *i64, n: i64, c: i64) -> i64 { var i: i64=0; while i<n { fb[i]=c; i=i+1 } return 0 }
629func cr_filled(fb: *i64, n: i64, bg: i64) -> i64 { var c: i64=0; var i: i64=0; while i<n { if fb[i]!=bg { c=c+1 } i=i+1 } return c }
630func cr_fbck(fb: *i64, n: i64) -> i64 { var ck: i64=1469598103; var i: i64=0; while i<n { ck = cr_ckv(ck, fb[i]); i=i+1 } return ck }
631func cr_run_full(g: *i64) -> i64
645func main() -> i64