code wiki / (root) / nx_wasm_shmup.nx

nx_wasm_shmup.nx

buildroot/runtime/nx_wasm_shmup.nx

5983 B134 linesdepth 1pulls 1 transitivereach 1 importersview sourcekind librarytopic wasm
docsdependenciesstructsconstsfunctions

about

nx_wasm_shmup.nx -- BROWSER-PLAYABLE sovereign Shoot-'em-up: BASE-RELATIVE integer core, the SAME code runs native (base = a real mmap -> render a frame to PNG for eyeball verify) AND in the browser (base = 0 = our sovereign WASM linear memory). NO float, NO JS logic, NO 3rd-party canvas drawing. Real-time: the shim's rAF loop calls tick(input) every frame with the held-key bitmask (1=left 2=right 4=shoot); the core moves the ship, fires a bullet, advances it, kills descending enemies, respawns waves endlessly, and game-overs if a wave reaches the ship line (shoot restarts). HUD score drawn by our OWN font (no JS/canvas text). init()/tick(input)/render()/score()/ww()/hh()/fb_off() are the wasm interface (auto-exported by nx_wasm.nx). license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_nishi_font_core.nx nx_wasm_shmup.nx nx_wasm_shmup_gate.nx

imports: nx_nishi_font_core.nx

imported by: nx_wasm_shmup_gate.nx

structs

none

consts

10const W: i64 = 160
11const H: i64 = 192
12const NE: i64 = 6
13const SY: i64 = 176 // ship row
14const EYSTART: i64 = 20 // wave spawn y
15const O_FB: i64 = 0 // framebuffer W*H i64 (packed RGB) at offset 0
16const O_EX: i64 = 245760 // enemy x[16] (W*H*8)
17const O_EA: i64 = 245888 // enemy alive[16]
18const O_ST: i64 = 246016 // scalars[16]: 0=sx 1=bx 2=by 3=bactive 4=score 5=wave_count 6=ey 7=gameover 8=tick
19const O_MSK: i64 = 246144 // HUD glyph scratch mask (base-relative -> no sys_mmap, lowers to wasm)
20const O_STR: i64 = 254336 // HUD score string scratch

functions

22func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) }
called by 1: render_impl
24func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64
called by 1: render_impl
37func spawn_wave(base: i64) -> i64
called by 2: init_impltick_impl
48func init_impl(base: i64) -> i64
called by 3: tick_implinitmain calls 1: spawn_wave
55func tick_impl(base: i64, input: i64) -> i64
called by 2: tickmain calls 2: init_implspawn_wave
82func render_impl(base: i64) -> i64
called by 2: rendermain calls 3: rgbfillrnf_draw_text_mem
127func init() -> i64 { return init_impl(0) }
calls 1: init_impl
128func tick(input: i64) -> i64 { return tick_impl(0, input) }
calls 1: tick_impl
129func sfx_event() -> i64 { let st: *i64 = (0 + O_ST) as *i64; let e: i64 = st[9]; st[9] = 0; return e } // 1=shoot 2=kill 3=gameover; cleared on read
130func render() -> i64 { return render_impl(0) }
calls 1: render_impl
131func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[4] }
132func fb_off() -> i64 { return O_FB }
133func ww() -> i64 { return W }
134func hh() -> i64 { return H }