code wiki / _hdl_build / nx_wire_diablo2_gate.nx
nx_wire_diablo2_gate.nx
buildroot/runtime/_hdl_build/nx_wire_diablo2_gate.nx
about
nx_wire_diablo2_gate.nx -- TITLE WIRING #2: Open Diablo II (ARPG). An actual playable hack-and-slash
loop built ONLY from certified parts: procgen act maps seed monster packs (nx_entity_store), every kill
grants XP (nx_rpgstats) and rolls LOOT (nx_loottable) whose affixes EQUIP as stat modifiers
(rs_apply_mods -- order-independent by construction), the act theme renders through nx_gamemusic, and
the whole game state round-trips through nx_gamesave with the GX-9 transparency test.
CAPS EXERCISED (bit = nx_gamebench capability index; the measured mask is payload[0] of the artifact):
bit 10 loot-item-tables bit 9 rpg-stats-progression bit 3 procgen-world
bit 6 entity-component-sim bit 16 audio-sfx-music bit 15 save-load-persistence
bit 18 ui-menus-hud (nx_gamehud: every DROP's equip-or-keep decision goes THROUGH a modal menu --
item 0 carries the tier policy, the RETURNED id drives the equip mutation; HUD binds live
hp/lvl/act/kills/tier per round, render-chain deterministic across replays)
NOT exercised (title requires, loop does not prove): bit 7 pathfinding, bit 0 render-2d,
bit 17 input-realtime -- the board must down-score these for this title.
FLAGSHIP (mutation target): the kill->loot wiring. Skipping the roll must drive the loot tooth RED
(no tiers observed) while the game still plays to a win (anti-vacuity stays GREEN).
DIALECT: no `else if`, no `||`, no multiline `else` -- those DESYNC the nx_cc parser (found by the
NetHack wiring; minimal repro nx_wire_probe.nx aux2). Plain ifs + flag vars only.
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_loottable.nxnx_gamemusic.nxnx_audio_wav.nxnx_gamehud.nxnx_game_raster.nxnx_frame_sanity.nxnx_wire_harness.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 35 | const D2_W: i64 = 20 |
| 36 | const D2_H: i64 = 10 |
| 37 | const D2_ACTS: i64 = 3 |
| 38 | const D2_NMON: i64 = 8 |
| 39 | const D2_CAP: i64 = 12 |
| 40 | const D2_NCOMP: i64 = 3 // 0=hp 1=xp_reward 2=packed pos |
| 41 | const D2_CARVE: i64 = 90 |
| 42 | const D2_MAXT: i64 = 400 |
| 44 | const D2_XB: i64 = 20 |
| 45 | const D2_XQ: i64 = 10 |
| 46 | const D2_HPB: i64 = 20 |
| 47 | const D2_HPC: i64 = 2 |
| 48 | const D2_HPL: i64 = 4 |
| 49 | const D2_CON: i64 = 12 |
| 50 | const D2_BDMG: i64 = 8 // base weapon damage before mods |
| 51 | const D2_STRIKERS: i64 = 2 // how many monsters strike back per round |
| 53 | const D2_NTIER: i64 = 4 // normal / magic / rare / unique |
| 54 | const D2_NAFF: i64 = 5 // +dmg / +dmg% / +hp / +hp% / +armor |
| 56 | const D2_HDRN: i64 = 48 |
| 57 | const D2_NSV: i64 = 85 // 48 hdr + 1 n + 12*3 monsters |
| 58 | const D2_SCHEMA: i64 = 7308 |
| 59 | const D2_ART_SCHEMA: i64 = 7318 |
| 61 | const D2_T1W: i64 = 22 |
| 62 | const D2_T2W: i64 = 46 |
| 64 | const DG_O_GRID: i64 = 64 // 200 cells |
| 65 | const DG_O_CARVE: i64 = 272 // 208 |
| 66 | const DG_O_ENT: i64 = 480 // en_words(12,3)=4+60+36+8=108 pad 112 |
| 67 | const DG_O_HUD: i64 = 640 // nx_gamehud arena (GH_WORDS=64) APPENDED; UI transient, out of the save |
| 68 | const DG_WORDS: i64 = 704 |
| 69 | const D2_HUDINK: i64 = 50 // min ink px for a non-vacuous HUD frame (T10 guard) |
| 71 | const D_WS: i64 = 0 |
| 72 | const D_ACT: i64 = 1 |
| 73 | const D_TURN: i64 = 2 |
| 74 | const D_XP: i64 = 3 |
| 75 | const D_LVL: i64 = 4 |
| 76 | const D_HP: i64 = 5 |
| 77 | const D_KILLS: i64 = 6 |
| 78 | const D_DROPS: i64 = 7 |
| 79 | const D_T0: i64 = 8 |
| 80 | const D_T1: i64 = 9 |
| 81 | const D_T2: i64 = 10 |
| 82 | const D_T3: i64 = 11 |
| 83 | const D_WIN: i64 = 12 |
| 84 | const D_SPAWNED: i64 = 13 |
| 85 | const D_EQUIPS: i64 = 14 |
| 86 | const D_GENRNG: i64 = 15 |
| 87 | const D_DUPAFF: i64 = 16 // duplicate-affix violations observed (must stay 0) |
| 88 | const D_AFFBAD: i64 = 17 // affix value out of declared range (must stay 0) |
| 89 | const D_WT: i64 = 18 // equipped weapon tier (-1 none) |
| 90 | const D_WNA: i64 = 19 // weapon affix count |
| 91 | const D_WPAIR: i64 = 20 // 6 pairs (affix,val) -> 20..31 |
| 92 | const D_AT: i64 = 32 |
| 93 | const D_ANA: i64 = 33 |
| 94 | const D_APAIR: i64 = 34 // 34..45 |
| 95 | const D_ORDCHK: i64 = 46 // multi-mod drops where fwd/rev order equality was verified |
| 96 | const D_ORDBAD: i64 = 47 // order-dependence violations observed (must stay 0) |
| 410 | const R2_CELL: i64 = 16 |
| 411 | const R2_W: i64 = 320 |
| 412 | const R2_H: i64 = 180 |
functions
| 98 | 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 } |
| 99 | func wn(v: i64) -> i64 |
| 108 | func dbit(i: i64) -> i64 { var v: i64=1; var k: i64=0; while k<i { v=v*2; k=k+1 } return v } called by 1: main |
| 109 | func drng(d: *i64) -> i64 called by 1: d2_genact |
| 118 | func dckv(ck: i64, v0: i64) -> i64 |
| 124 | func d2_tables(tw: *i64, ta: *i64, aw: *i64, alo: *i64, ahi: *i64) -> i64 called by 1: d2_tick |
| 136 | func d2_genact(d: *i64) -> i64 |
| 200 | func d2_new(d: *i64, ws: i64) -> i64 |
| 216 | func d2_wmods(d: *i64, mods: *i64) -> i64 |
| 229 | func d2_amods(d: *i64, mods: *i64) -> i64 called by 1: d2_maxhp |
| 241 | func d2_maxhp(d: *i64) -> i64 |
| 248 | func d2_tick(d: *i64) -> i64 called by 4: d2_rchaind2_hudchaind2_run_fullmain calls 14: en_countd2_genactd2_maxhpen_nthen_getsys_mmap+8 |
| 413 | func d2_render(d: *i64, fb: *i64) -> i64 |
| 445 | func d2_fbck(fb: *i64) -> i64 |
| 450 | func d2_rchain(seed: i64, turns: i64, out: *i64) -> i64 |
| 473 | func d2_hudchain(seed: i64, turns: i64, out: *i64) -> i64 |
| 513 | func d2_run_full(d: *i64) -> i64 |
| 527 | func d2_serialize(d: *i64, S: *i64) -> i64 |
| 549 | func d2_restore(d: *i64, S: *i64) -> i64 |
| 575 | func d2_ck(d: *i64) -> i64 |
| 596 | func d2_song(sng: *i64, k: i64, a2: i64, b2: i64, c2: i64) -> i64 called by 1: d2_render_theme |
| 600 | func d2_render_theme(smp: *i64, nsamp: i64) -> i64 |
| 635 | func main() -> i64 |