code wiki / _hdl_build / nx_gamehud.nx
nx_gamehud.nx
buildroot/runtime/_hdl_build/nx_gamehud.nx
about
nx_gamehud.nx -- certified composable game part: UI/MENUS/HUD (gamebench capability 18).
A HUD is BOUND VALUES rendered fresh every frame (never cached text), and a menu is a MODAL,
DETERMINISTIC state machine whose selection CAUSES the game action (not decoration painted after
the fact). This part owns both, game-agnostically:
- HUD slots: caller binds integer values (hp/depth/kills/...) each turn; labels are passed at
RENDER time only, so serialized state is PURE i64 values (pointers never enter a save file).
- Menu: open(n items) -> move (wraps BOTH directions) -> sel returns the cursor item's id and
closes (modal select-close). Cursor/items live in state; a replay reproduces every selection.
- Render: composites over a caller RGB24 framebuffer (w*h*3, like nx_png_write_rgb) with the
sovereign nx_font8x8 glyphs; per-pixel clipped so off-screen text can NEVER write out of bounds.
- Serialization: gh state words [0..GH_NSV) are plain i64s -> ride nx_gamesave like every other
certified part (rpgstats T8 / entity T9 pattern).
LIB, no main (ecosystem convention, cf. nx_swgpu.nx). license_tier: ORIGINAL
dependencies 2 imports · 8 importers
imports: nx_syscalls.nxnx_font8x8.nx
imported by: nx_creature_demo.nxnx_drift_engine.nxnx_frontier_engine.nxnx_gamehud_gate.nxnx_wire_diablo2_gate.nxnx_wire_endlesssky_gate.nxnx_wire_harness.nxnx_wire_nethack_gate.nx
structs
| none |
consts
| 16 | const GH_MAGIC_1469598103: i64 = 1469598103 |
| 19 | const GH_F_NSLOT: i64 = 0 |
| 20 | const GH_F_MOPEN: i64 = 1 |
| 21 | const GH_F_MN: i64 = 2 |
| 22 | const GH_F_MCUR: i64 = 3 |
| 23 | const GH_F_NSEL: i64 = 4 // selections made (lifetime) |
| 24 | const GH_F_LAST: i64 = 5 // last selected id (-1 until first select) |
| 25 | const GH_O_SLOT: i64 = 8 // slot values [8..24) |
| 26 | const GH_O_MID: i64 = 24 // menu item ids [24..40) |
| 27 | const GH_O_MVAL: i64 = 40 // menu item values [40..56) |
| 28 | const GH_NSV: i64 = 56 // serializable span |
| 29 | const GH_WORDS: i64 = 64 // arena size in words |
| 30 | const GH_MAXSLOT: i64 = 16 |
| 31 | const GH_MAXITEM: i64 = 16 |
| 33 | const GH_BAR_X: i64 = 2 |
| 34 | const GH_BAR_Y: i64 = 2 |
| 35 | const GH_GAP: i64 = 10 // px between HUD slots |
| 36 | const GH_MX: i64 = 8 // menu panel origin |
| 37 | const GH_MY: i64 = 14 |
| 38 | const GH_MW: i64 = 110 // menu panel width |
| 39 | const GH_ROWH: i64 = 10 |
functions
| 41 | func gh_init(g: *i64, nslots: i64) -> i64 |
| 51 | func gh_slot_set(g: *i64, i: i64, v: i64) -> i64 |
| 57 | func gh_menu_open(g: *i64, n: i64) -> i64 |
| 66 | func gh_menu_item(g: *i64, i: i64, id: i64, val: i64) -> i64 |
| 74 | func gh_menu_move(g: *i64, d: i64) -> i64 |
| 84 | func gh_menu_sel(g: *i64) -> i64 |
| 92 | func gh_menu_close(g: *i64) -> i64 { g[GH_F_MOPEN] = 0; return 0 } called by 1: main |
| 95 | func gh_ckv(ck: i64, v0: i64) -> i64 called by 1: gh_ck |
| 100 | func gh_ck(g: *i64) -> i64 |
| 108 | func gh_px(fb: *u8, w: i64, h: i64, x: i64, y: i64) -> i64 |
| 119 | func gh_glyph(fb: *u8, w: i64, h: i64, font: *u8, ch: i64, x: i64, y: i64) -> i64 |
| 136 | func gh_text(fb: *u8, w: i64, h: i64, font: *u8, x0: i64, y: i64, s: *u8) -> i64 |
| 147 | func gh_numdraw(fb: *u8, w: i64, h: i64, font: *u8, x0: i64, y: i64, v0: i64) -> i64 |
| 164 | func gh_hline(fb: *u8, w: i64, h: i64, x0: i64, x1: i64, y: i64) -> i64 |
| 169 | func gh_vline(fb: *u8, w: i64, h: i64, x: i64, y0: i64, y1: i64) -> i64 |
| 177 | func gh_render(g: *i64, fb: *u8, w: i64, h: i64, font: *u8, labels: *i64, mlabels: *i64) -> i64 |
| 211 | func gh_frame_ck(fb: *u8, w: i64, h: i64) -> i64 |
| 218 | func gh_ink(fb: *u8, w: i64, h: i64) -> i64 |