code wiki / (root) / nx_tactics_native.nx

nx_tactics_native.nx

buildroot/runtime/nx_tactics_native.nx

13384 B372 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic tactics
docsdependenciesstructsconstsfunctions

about

nx_tactics_native.nx -- PLAYABLE XCOM-style turn-based TACTICS game (a 2nd game MODE, proving the Nishi game ecosystem generalizes beyond the dungeon-crawler). Native binary via Nishi's own toolchain (nx_cc->nxasm_x86, no gcc), terminal-rendered, hostable in the arcade. Reuses the engine library's terminal helpers (bput*/term_raw_*); the tactics logic (squads, action points, cover/hit-chance, enemy AI) is new here. HONEST AUTHORSHIP: tutor (Claude) authored this game module + the engine lib helpers it reuses. Generalizing tactics into a spec-driven emitter (like nx_game_emit does for dungeons) is the named next rung (G-ECO-005 more modes). license_tier: ORIGINAL state region (i64 at st): 0=turn(0=player 1=enemy) 1=cur(active player unit) 2=mode(0play 1win 2lose) 3=rng 4=msg 5=moves_left 6=has_shot units (NUNITS=4: 0,1 player / 2,3 enemy): ux=st[16+i] uy=st[22+i] uhp=st[28+i] uteam=st[34+i] ualive=st[40+i]. world grid 16x12 bytes at st+2048 (0 floor 1 wall 2 cover).

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_game_engine_lib.nx nx_tactics_native.nx

imports: nx_syscalls.nxnx_game_engine_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap term_raw_on sys_ioctl tac_init tac_build tac_cell_set tac_rng tac_cell_get tac_place_unit tac_rng ↻ tac_cell_get ↻ tac_unit_at tac_first_player sys_now_ms sys_mmap ↻ sys_clock_gettime_mono tac_render sys_mmap ↻ bput_clear bputc bput bput ↻ bputn bputc ↻ sys_mmap ↻ tac_team_alive bputc ↻ tac_draw_cell tac_unit_at ↻ bput_bg bputc ↻ bput ↻ bputn ↻ bput_fg bputc ↻ bput ↻ bputn ↻ bput ↻ bputn ↻

structs

none

consts

17const K_MAGIC_1103515245: i64 = 1103515245
18const K_MAGIC_12345: i64 = 12345
19const K_MAGIC_32767: i64 = 32767
20const K_MAGIC_2048: i64 = 2048
21const K_MAGIC_9999: i64 = 9999
22const K_MAGIC_8192: i64 = 8192
23const K_MAGIC_16384: i64 = 16384

functions

25func tac_rng(st: *i64) -> i64
31func tac_cell_get(st: *i64, x: i64, y: i64) -> i64
39func tac_cell_set(st: *i64, x: i64, y: i64, v: i64) -> i64
called by 1: tac_build
44func tac_unit_at(st: *i64, x: i64, y: i64) -> i64
54func tac_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
55func tac_dist(ax: i64, ay: i64, bx: i64, by: i64) -> i64 { return tac_abs(ax - bx) + tac_abs(ay - by) }
56func tac_team_alive(st: *i64, team: i64) -> i64
66func tac_nearest_foe(st: *i64, x: i64, y: i64, myteam: i64) -> i64
called by 2: tac_shoottac_enemy_turn calls 1: tac_dist
81func tac_first_player(st: *i64) -> i64
89func tac_next_player(st: *i64, from: i64) -> i64
called by 1: tac_end_unit
98func tac_place_unit(st: *i64, idx: i64, x0: i64, y0: i64, team: i64) -> i64
116func tac_build(st: *i64) -> i64
151func tac_init(st: *i64, seed: i64) -> i64
162func tac_check_end(st: *i64) -> i64
168func tac_chance(d: i64, cover: i64) -> i64
175func tac_move_unit(st: *i64, ui: i64, dx: i64, dy: i64) -> i64
called by 1: tac_input calls 2: tac_cell_gettac_unit_at
185func tac_end_unit(st: *i64) -> i64
197func tac_shoot(st: *i64, ui: i64) -> i64
212func tac_enemy_turn(st: *i64) -> i64
260func tac_input(st: *i64, key: i64) -> i64
276func tac_draw_cell(buf: *u8, off: *i64, st: *i64, x: i64, y: i64) -> i64
295func tac_render(buf: *u8, st: *i64) -> i64
334func tac_key(c: i64) -> i64
called by 1: main
344func main() -> i64