code wiki / _hdl_build / nx_game_emit.nx
nx_game_emit.nx
buildroot/runtime/_hdl_build/nx_game_emit.nx
about
nx_game_emit.nx -- the GAME EMITTER: a data game-spec in, a complete playable game
module out, hands-off. This is the autonomous game-gen lever (operator's choice):
feed specs -> get games. It reads a game-spec (difficulty/theme/title + the combat
FSM transition table) and WRITES a per-game .nx module that fills the engine config +
FSM table and calls eng_run (nx_game_engine_lib). The generated game is then built
native by Nishi's own toolchain and proven playable by a playthrough gate.
Spec grammar (one key per line):
name _game_foo module name (-> runtime/_hdl_build/_game_foo.nx)
title THE CRYPT HUD title (rest of line)
walls 22 interior wall count
enemy_base 2 enemies at depth 1
enemy_per_level 1 extra enemies per depth
ehp_base 18 enemy hp at depth 1
ehp_per_level 4 extra enemy hp per depth
loot 3 loot pickups per level
dmg_base 8 player base damage
dmg_rand 8 player random damage span
fsm 6 6 combat FSM dims (nstates nevents; dungenc convention)
row ... one transition-table row per state (nevents ints, -1=none)
HONEST AUTHORSHIP: this emitter + the engine library are TUTOR-authored tooling. The
GAMES it writes are emitter output (the autonomy). Usage: nx_game_emit <specpath>.
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 26 | const K_MAGIC_2048: i64 = 2048 |
functions
| 28 | func p_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } |
| 29 | func p_c(fd: i64, c: i64) -> i64 { let b: *u8 = sys_mmap(8); b[0] = c as u8; sys_write(fd, b, 1); return 0 } |
| 30 | func p_wn(fd: i64, v: i64) -> i64 |
| 44 | func gcstr_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: gfind |
| 45 | func gmatch(buf: *u8, pos: i64, key: *u8) -> i64 |
| 50 | func gline_start(buf: *u8, pos: i64) -> i64 |
| 55 | func gfind(buf: *u8, len: i64, key: *u8) -> i64 |
| 68 | func gpint(buf: *u8, pos: i64) -> i64 |
| 84 | func gint(buf: *u8, len: i64, key: *u8, dflt: i64) -> i64 |
| 90 | func gstr(buf: *u8, len: i64, key: *u8, out: *u8) -> i64 calls 1: gfind |
| 109 | func gtable(buf: *u8, len: i64, tbl: *i64) -> i64 |
| 146 | func gneeds(buf: *u8, len: i64) -> i64 |
| 164 | func build_path(name: *u8, out: *u8) -> i64 |
| 178 | func emit_assign(fd: i64, idx: i64, val: i64) -> i64 |
| 182 | func emit_head(fd: i64) -> i64 |
| 190 | func emit_cfg(fd: i64, vals: *i64) -> i64 |
| 202 | func emit_needs(fd: i64, name: *u8, mask: i64) -> i64 |
| 209 | func emit_title(fd: i64, title: *u8) -> i64 |
| 213 | func emit_table(fd: i64, tbl: *i64, n: i64) -> i64 |
| 225 | func emit_tail(fd: i64, ns: i64, ne: i64) -> i64 |
| 234 | func main(argc: i64, argv: *i64) -> i64 |