nx_tactics_native.nx
buildroot/runtime/nx_tactics_native.nx
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
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
structs
| none |
consts
| 17 | const K_MAGIC_1103515245: i64 = 1103515245 |
| 18 | const K_MAGIC_12345: i64 = 12345 |
| 19 | const K_MAGIC_32767: i64 = 32767 |
| 20 | const K_MAGIC_2048: i64 = 2048 |
| 21 | const K_MAGIC_9999: i64 = 9999 |
| 22 | const K_MAGIC_8192: i64 = 8192 |
| 23 | const K_MAGIC_16384: i64 = 16384 |
functions
| 25 | func tac_rng(st: *i64) -> i64 |
| 31 | func tac_cell_get(st: *i64, x: i64, y: i64) -> i64 |
| 39 | func tac_cell_set(st: *i64, x: i64, y: i64, v: i64) -> i64 called by 1: tac_build |
| 44 | func tac_unit_at(st: *i64, x: i64, y: i64) -> i64 |
| 54 | func tac_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } |
| 55 | func tac_dist(ax: i64, ay: i64, bx: i64, by: i64) -> i64 { return tac_abs(ax - bx) + tac_abs(ay - by) } |
| 56 | func tac_team_alive(st: *i64, team: i64) -> i64 |
| 66 | func tac_nearest_foe(st: *i64, x: i64, y: i64, myteam: i64) -> i64 |
| 81 | func tac_first_player(st: *i64) -> i64 |
| 89 | func tac_next_player(st: *i64, from: i64) -> i64 called by 1: tac_end_unit |
| 98 | func tac_place_unit(st: *i64, idx: i64, x0: i64, y0: i64, team: i64) -> i64 |
| 116 | func tac_build(st: *i64) -> i64 |
| 151 | func tac_init(st: *i64, seed: i64) -> i64 |
| 162 | func tac_check_end(st: *i64) -> i64 |
| 168 | func tac_chance(d: i64, cover: i64) -> i64 |
| 175 | func tac_move_unit(st: *i64, ui: i64, dx: i64, dy: i64) -> i64 |
| 185 | func tac_end_unit(st: *i64) -> i64 |
| 197 | func tac_shoot(st: *i64, ui: i64) -> i64 |
| 212 | func tac_enemy_turn(st: *i64) -> i64 called by 1: tac_end_unit calls 7: tac_nearest_foetac_abstac_cell_gettac_unit_attac_disttac_chance+1 |
| 260 | func tac_input(st: *i64, key: i64) -> i64 |
| 276 | func tac_draw_cell(buf: *u8, off: *i64, st: *i64, x: i64, y: i64) -> i64 |
| 295 | func tac_render(buf: *u8, st: *i64) -> i64 |
| 334 | func tac_key(c: i64) -> i64 called by 1: main |
| 344 | func main() -> i64 |