code wiki / _hdl_build / nx_wire_crawl_gate.nx
nx_wire_crawl_gate.nx
buildroot/runtime/_hdl_build/nx_wire_crawl_gate.nx
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
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
| 35 | const CR_W: i64 = 24 |
| 36 | const CR_H: i64 = 12 |
| 37 | const CR_DEPTH: i64 = 3 |
| 38 | const CR_NMON: i64 = 6 |
| 39 | const CR_NITEM: i64 = 5 |
| 40 | const CR_CAP: i64 = 16 |
| 41 | const CR_NCOMP: i64 = 4 |
| 42 | const CR_CARVE: i64 = 140 |
| 43 | const CR_AGGRO: i64 = 8 |
| 44 | const CR_MAXT: i64 = 600 |
| 45 | const CR_XB: i64 = 20 |
| 46 | const CR_XQ: i64 = 10 |
| 47 | const CR_HPB: i64 = 10 |
| 48 | const CR_HPC: i64 = 2 |
| 49 | const CR_HPL: i64 = 3 |
| 50 | const CR_CON: i64 = 14 |
| 51 | const CR_BITE: i64 = 2 |
| 52 | const CR_MHPB: i64 = 12 |
| 53 | const CR_HEAL_R: i64 = 10 |
| 54 | const CR_HEAL_F: i64 = 25 |
| 56 | const CR_NTIER: i64 = 4 |
| 57 | const CR_NAFF: i64 = 5 |
| 59 | const CR_HDRN: i64 = 34 |
| 60 | const CR_HDRZ: i64 = 48 // header region zeroed on new/restore (grid starts at word 48) |
| 61 | const CR_NSV: i64 = 114 // 34 hdr + 1 nmon + 16*4 monsters + 5*3 items |
| 62 | const CR_SCHEMA: i64 = 7339 // next in the x9 wire series (nethack 7307, d2 7338) |
| 63 | const CR_ART_SCHEMA: i64 = 7319 // wiring-evidence artifact schema (nethack 7317, d2 7318) |
| 64 | const CR_T1W: i64 = 20 // transparency window: donor's calibration, win lands ~turn 62 |
| 65 | const CR_T2W: i64 = 45 |
| 67 | const CG_O_GRID: i64 = 48 |
| 68 | const CG_O_ITEM: i64 = 336 |
| 69 | const CG_O_ENT: i64 = 352 |
| 70 | const CG_O_PATH: i64 = 512 |
| 71 | const CG_O_G: i64 = 808 |
| 72 | const CG_O_F: i64 = 1104 |
| 73 | const CG_O_CAME: i64 = 1400 |
| 74 | const CG_O_OPENF: i64 = 1696 |
| 75 | const CG_O_CLOSED: i64 = 1992 |
| 76 | const CG_O_CARVE: i64 = 2288 |
| 77 | const CG_O_HUD: i64 = 2592 |
| 78 | const CG_WORDS: i64 = 2656 |
| 79 | const CR_HUDINK: i64 = 50 |
| 81 | const F_WS: i64 = 0 |
| 82 | const F_DEPTH: i64 = 1 |
| 83 | const F_TURN: i64 = 2 |
| 84 | const F_PX: i64 = 3 |
| 85 | const F_PY: i64 = 4 |
| 86 | const F_XP: i64 = 5 |
| 87 | const F_LVL: i64 = 6 |
| 88 | const F_HP: i64 = 7 |
| 89 | const F_KILLS: i64 = 8 |
| 90 | const F_RATION: i64 = 9 |
| 91 | const F_FEAST: i64 = 10 |
| 92 | const F_PICKED: i64 = 11 |
| 93 | const F_USED: i64 = 12 |
| 94 | const F_WIN: i64 = 13 |
| 95 | const F_COMB: i64 = 14 |
| 96 | const F_EATR: i64 = 15 |
| 97 | const F_EATF: i64 = 16 |
| 98 | const F_PSTEPS: i64 = 17 |
| 99 | const F_ATT: i64 = 18 |
| 100 | const F_BITES: i64 = 19 |
| 101 | const F_SPAWNED: i64 = 20 |
| 102 | const F_SX: i64 = 21 |
| 103 | const F_SY: i64 = 22 |
| 104 | const F_NCARVE: i64 = 23 |
| 105 | const F_GENRNG: i64 = 24 |
| 106 | const F_ABAND: i64 = 25 |
| 108 | const F_DROPS: i64 = 26 |
| 109 | const F_T0: i64 = 27 |
| 110 | const F_T1: i64 = 28 |
| 111 | const F_T2: i64 = 29 |
| 112 | const F_T3: i64 = 30 |
| 113 | const F_DUPAFF: i64 = 31 |
| 114 | const F_AFFBAD: i64 = 32 |
| 115 | const F_LOOTR: i64 = 33 // rations gained FROM LOOT (tier>=2) -- balances the ledger tooth |
functions
| 117 | func ww(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 118 | func wn(v: i64) -> i64 |
| 127 | func cbit(i: i64) -> i64 { var v: i64=1; var k: i64=0; while k<i { v=v*2; k=k+1 } return v } |
| 128 | func crng(g: *i64) -> i64 |
| 137 | func cabs(v: i64) -> i64 { if v<0 { return 0-v } return v } |
| 139 | func cr_tables(tw: *i64, ta: *i64, aw: *i64, alo: *i64, ahi: *i64) -> i64 |
| 151 | func cr_genstruct(g: *i64) -> i64 |
| 183 | func cr_populate(g: *i64) -> i64 |
| 254 | func cr_new(g: *i64, ws: i64) -> i64 |
| 269 | func cr_serialize(g: *i64, S: *i64) -> i64 |
| 297 | func cr_restore(g: *i64, S: *i64) -> i64 |
| 326 | func cr_ckv(ck: i64, v0: i64) -> i64 |
| 331 | func cr_ck(g: *i64) -> i64 |
| 354 | func cr_moncell(a: *i64, x: i64, y: i64, skip: i64) -> i64 |
| 368 | func cr_tick(g: *i64) -> i64 |
| 576 | func cr_hudchain(seed: i64, turns: i64, out: *i64) -> i64 |
| 616 | func cr_decint(b: *u8, at: i64, v0: i64) -> i64 |
| 628 | func cr_clearfb(fb: *i64, n: i64, c: i64) -> i64 { var i: i64=0; while i<n { fb[i]=c; i=i+1 } return 0 } |
| 629 | func 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 } |
| 630 | func 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 } |
| 631 | func cr_run_full(g: *i64) -> i64 |
| 645 | func main() -> i64 |