code wiki / _hdl_build / nx_gamehud.nx

nx_gamehud.nx

buildroot/runtime/_hdl_build/nx_gamehud.nx

8493 B224 linesdepth 3pulls 3 transitivereach 9 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_font8x8.nx nx_gamehud.nx nx_creature_demo.nx nx_drift_engine.nx nx_frontier_engine.nx nx_gamehud_gate.nx nx_wire_diablo2_gate.nx nx_wire_endlesssky_gate.nx nx_wire_harness.nx nx_wire_nethack_gate.nx

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

16const GH_MAGIC_1469598103: i64 = 1469598103
19const GH_F_NSLOT: i64 = 0
20const GH_F_MOPEN: i64 = 1
21const GH_F_MN: i64 = 2
22const GH_F_MCUR: i64 = 3
23const GH_F_NSEL: i64 = 4 // selections made (lifetime)
24const GH_F_LAST: i64 = 5 // last selected id (-1 until first select)
25const GH_O_SLOT: i64 = 8 // slot values [8..24)
26const GH_O_MID: i64 = 24 // menu item ids [24..40)
27const GH_O_MVAL: i64 = 40 // menu item values [40..56)
28const GH_NSV: i64 = 56 // serializable span
29const GH_WORDS: i64 = 64 // arena size in words
30const GH_MAXSLOT: i64 = 16
31const GH_MAXITEM: i64 = 16
33const GH_BAR_X: i64 = 2
34const GH_BAR_Y: i64 = 2
35const GH_GAP: i64 = 10 // px between HUD slots
36const GH_MX: i64 = 8 // menu panel origin
37const GH_MY: i64 = 14
38const GH_MW: i64 = 110 // menu panel width
39const GH_ROWH: i64 = 10

functions

41func gh_init(g: *i64, nslots: i64) -> i64
51func gh_slot_set(g: *i64, i: i64, v: i64) -> i64
57func gh_menu_open(g: *i64, n: i64) -> i64
66func gh_menu_item(g: *i64, i: i64, id: i64, val: i64) -> i64
74func gh_menu_move(g: *i64, d: i64) -> i64
84func gh_menu_sel(g: *i64) -> i64
92func gh_menu_close(g: *i64) -> i64 { g[GH_F_MOPEN] = 0; return 0 }
called by 1: main
95func gh_ckv(ck: i64, v0: i64) -> i64
called by 1: gh_ck
100func gh_ck(g: *i64) -> i64
called by 2: navrunmain calls 1: gh_ckv
108func gh_px(fb: *u8, w: i64, h: i64, x: i64, y: i64) -> i64
119func gh_glyph(fb: *u8, w: i64, h: i64, font: *u8, ch: i64, x: i64, y: i64) -> i64
called by 2: gh_textgh_numdraw calls 1: gh_px
136func gh_text(fb: *u8, w: i64, h: i64, font: *u8, x0: i64, y: i64, s: *u8) -> i64
147func gh_numdraw(fb: *u8, w: i64, h: i64, font: *u8, x0: i64, y: i64, v0: i64) -> i64
164func gh_hline(fb: *u8, w: i64, h: i64, x0: i64, x1: i64, y: i64) -> i64
called by 1: gh_render calls 1: gh_px
169func gh_vline(fb: *u8, w: i64, h: i64, x: i64, y0: i64, y1: i64) -> i64
called by 1: gh_render calls 1: gh_px
177func gh_render(g: *i64, fb: *u8, w: i64, h: i64, font: *u8, labels: *i64, mlabels: *i64) -> i64
211func gh_frame_ck(fb: *u8, w: i64, h: i64) -> i64
218func gh_ink(fb: *u8, w: i64, h: i64) -> i64