nx_wasm_2048.nx
buildroot/runtime/nx_wasm_2048.nx
about
nx_wasm_2048.nx -- the SECOND sovereign browser game genre: a 2048 sliding-tile PUZZLE, pure-Nishi NO-FLOAT,
BASE-RELATIVE (same code native [base=mmap, render a PNG] and in our WASM [base=0]). Structurally distinct
from the collect-class arcade (merge logic + RNG spawns, not avatar movement) -> proves the emitter generalises
across genres ([[feedback-games-as-test-avenues-for-layer-completeness]]). Integer state machine + integer
rasteriser + the sovereign Nishi font for tile numbers. Exports init/tick/render/score/ww/hh/fb_off = the SAME
wasm interface as the arcade, so the SAME blit-only html packager serves it. license_tier: ORIGINAL
dependencies 1 imports · 1 importers
imports: nx_nishi_font_core.nx
imported by: nx_wasm_2048_gate.nx
structs
| none |
consts
| 8 | const O_MAGIC_1103515245: i64 = 1103515245 |
| 9 | const O_MAGIC_12345: i64 = 12345 |
| 10 | const O_MAGIC_2025: i64 = 2025 |
| 11 | const W: i64 = 240 |
| 12 | const H: i64 = 240 |
| 13 | const N: i64 = 4 |
| 14 | const MARGIN: i64 = 12 |
| 15 | const CELL: i64 = 50 |
| 16 | const GAP: i64 = 5 |
| 17 | const O_FB: i64 = 0 // W*H i64 packed RGB = 460800 |
| 18 | const O_GRID: i64 = 460800 // N*N i64 tile values (0=empty, else power of 2) |
| 19 | const O_ST: i64 = 461824 // [0]=score [1]=rng [2]=moved [3]=won |
| 20 | const O_LINE: i64 = 462848 // scratch line (N i64) |
| 21 | const O_TMP: i64 = 463360 // scratch line (N i64) |
| 22 | const O_MSK: i64 = 464384 // font glyph scratch (base-relative) |
| 23 | const O_STR: i64 = 473600 // tile-number string scratch |
functions
| 25 | func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) } |
| 26 | func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64 called by 1: render_impl |
| 38 | func gget(base: i64, i: i64) -> i64 { let g: *i64 = (base + O_GRID) as *i64; return g[i] } |
| 39 | func gset(base: i64, i: i64, v: i64) -> i64 { let g: *i64 = (base + O_GRID) as *i64; g[i] = v; return 0 } |
| 40 | func lget(base: i64, off: i64, i: i64) -> i64 { let p: *i64 = (base + off) as *i64; return p[i] } |
| 41 | func lset(base: i64, off: i64, i: i64, v: i64) -> i64 { let p: *i64 = (base + off) as *i64; p[i] = v; return 0 } |
| 44 | func rng_next(base: i64) -> i64 { let st: *i64 = (base + O_ST) as *i64; st[1] = (st[1]*O_MAGIC_1103515245 + O_MAGIC_12345) & 0x7fffffff; return st[1] } called by 1: spawn |
| 47 | func spawn(base: i64) -> i64 |
| 62 | func init_impl(base: i64) -> i64 |
| 72 | func line_move(base: i64) -> i64 |
| 98 | func read_line(base: i64, dir: i64, k: i64) -> i64 |
| 111 | func write_line(base: i64, dir: i64, k: i64) -> i64 |
| 124 | func tick_impl(base: i64, dir: i64) -> i64 |
| 139 | func tile_color(v: i64) -> i64 |
| 153 | func num_str(base: i64, v: i64) -> i64 called by 1: render_impl |
| 165 | func render_impl(base: i64) -> i64 |
| 198 | func init() -> i64 { return init_impl(0) } calls 1: init_impl |
| 199 | func tick(dir: i64) -> i64 { return tick_impl(0, dir) } calls 1: tick_impl |
| 200 | func render() -> i64 { return render_impl(0) } calls 1: render_impl |
| 201 | func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[0] } |
| 202 | func fb_off() -> i64 { return O_FB } |
| 203 | func ww() -> i64 { return W } |
| 204 | func hh() -> i64 { return H } |