nx_checkers_render.nx
buildroot/runtime/nx_checkers_render.nx
about
nx_checkers_render.nx -- bits-up HTML rendering + event dispatch for /checkers.
Mirrors nx_tictactoe_render.nx pattern. HTML emitted via sys_write to
sentinel fd 99; dist/_nishi/nishi-host.js captures + sets innerHTML.
Click events route via data-action="<id>" to nx_chk_action.
State block carries one extra "selected square" UI cell after the game
cells so the renderer can highlight the selected source-piece + show
legal destinations. Hash of game state stays in cells 0..67 (unchanged).
Exports:
nx_chk_render_init() -> *i64
nx_chk_render(s) -> i64 -- emits HTML to fd 99
nx_chk_action(s, act, a0, a1, a2, a3) -> i64
Action IDs (data-action):
1 = click square N (arg0 = 0..63)
2 = reset game
3 = set opponent (arg0: -1=human, 0=easy)
4 = set player side (arg0: 1=red, 2=black)
dependencies 4 imports · 1 importers
imports: nx_syscalls.nxnx_tier.nxnx_prng.nxnx_checkers.nx
imported by: nx_chk_bits_up_e2e.nx
structs
| none |
consts
| 26 | const NX_MAGIC_12345: i64 = 12345 |
| 28 | const NX_CHK_RENDER_FD: i64 = 99 |
| 30 | const NX_CHK_ACTION_CLICK_SQ: i64 = 1 |
| 31 | const NX_CHK_ACTION_RESET: i64 = 2 |
| 32 | const NX_CHK_ACTION_SET_OPPONENT: i64 = 3 |
| 33 | const NX_CHK_ACTION_SET_PLAYER: i64 = 4 |
| 36 | const NX_CHK_OFF_SELECTED: i64 = 68 // -1 if no selection |
| 37 | const NX_CHK_OFF_PLAYER_SIDE: i64 = 69 // NX_CHK_RED or NX_CHK_BLACK |
| 38 | const NX_CHK_OFF_OPPONENT: i64 = 70 // -1=human, 0=easy |
| 39 | const NX_CHK_OFF_PRNG: i64 = 71 // pointer (as i64) to separately-allocated PRNG state |
| 40 | const NX_CHK_RENDER_CELLS: i64 = 72 |
functions
| 44 | func _chk_strlen(s: *u8) -> i64 called by 1: _chk_w |
| 50 | func _chk_w(s: *u8) -> i64 |
| 55 | func _chk_wn(n: i64) -> i64 |
| 70 | func nx_chk_render_init() -> *i64 |
| 90 | func _chk_reset_in_place(s: *i64) |
| 103 | func _chk_is_dest_legal(s: *i64, from_sq: i64, to_sq: i64) -> i64 |
| 118 | func _chk_emit_status(s: *i64) -> i64 |
| 160 | func _chk_emit_piece(piece: i64) -> i64 |
| 168 | func _chk_emit_board(s: *i64) -> i64 |
| 212 | func _chk_emit_opt(value: i64, is_selected: i64, label: *u8) -> i64 |
| 226 | func _chk_emit_controls(s: *i64) -> i64 |
| 257 | func _chk_emit_version_banner() -> i64 |
| 264 | func nx_chk_render(s: *i64) -> i64 called by 1: main calls 5: _chk_w_chk_emit_version_banner_chk_emit_status_chk_emit_board_chk_emit_controls |
| 282 | func _chk_handle_click(s: *i64, sq_idx: i64) -> i64 called by 1: nx_chk_action calls 5: nx_chk_outcomenx_chk_turnnx_chk_side_ofnx_chk_apply_movenx_chk_force_continue |
| 323 | func _chk_ai_take_turn(s: *i64) called by 1: nx_chk_action calls 6: nx_chk_outcomenx_chk_othernx_chk_turnsys_mmapnx_chk_picknx_chk_apply_move |
| 343 | func nx_chk_action(s: *i64, action: i64, arg0: i64, arg1: i64, |