nx_wasm_physlab.nx
buildroot/runtime/nx_wasm_physlab.nx
about
nx_wasm_physlab.nx -- PHYSLAB: the VISIBLE consumer of the shared 3D core (reuse census W2: "a game surface
consumes nx_phys3d + nx_softjiggle"). Crates STACK and fall ASLEEP (dimmed = sleeping, visibly), spheres
BOUNCE with real restitution, and a 5-node JIGGLE CHAIN hangs from the mouse and swings AROUND a capsule
pillar (collision visible). Click spawns crates. ALL game logic lives here (the no-JS-logic law): JS may
only pass raw mouse state and blit the framebuffer. ALL INTEGER (phys3d/softjiggle fixed-point law) -- the
ENTIRE surface is VM-vettable byte-for-byte (no f32 anywhere). Side view: x right, y up, orthographic.
license_tier: ORIGINAL
dependencies 3 imports · 2 importers
imports: nx_syscalls.nxnx_phys3d.nxnx_softjiggle.nx
imported by: nx_physlab_wasm_vet.nxnx_wasm_physlab_gate.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 11 | const O_MAGIC_100000: i64 = 100000 |
| 12 | const O_MAGIC_1500: i64 = 1500 |
| 13 | const O_MAGIC_3500: i64 = 3500 |
| 14 | const O_MAGIC_3000: i64 = 3000 |
| 15 | const O_MAGIC_2800: i64 = 2800 |
| 16 | const O_MAGIC_3600: i64 = 3600 |
| 17 | const O_MAGIC_1800: i64 = 1800 |
| 18 | const O_MAGIC_2600: i64 = 2600 |
| 19 | const O_MAGIC_65536: i64 = 65536 |
| 21 | const W: i64 = 320 |
| 22 | const H: i64 = 240 |
| 23 | const HW: i64 = 160 |
| 24 | const GROUNDY: i64 = 210 // screen y of the ground line |
| 25 | const SCALE: i64 = 16 // world fx256 -> screen px divisor |
| 26 | const O_FB: i64 = 0 |
| 27 | const O_PH: i64 = 614400 // W*H*8; ph_bytes now 106560 (warm+target tables, 2026-07-03) |
| 28 | const O_SJ: i64 = 721024 |
| 29 | const O_ST: i64 = 739584 // [0]=tick [1]=prev buttons [2]=spawned [3]=chain0 id [4]=lastmx [5]=lastmy |
| 30 | const NCRATE: i64 = 5 |
functions
| 32 | func st_ptr(base: i64) -> *i64 { return (base + O_ST) as *i64 } |
| 33 | func mem_bytes() -> i64 { return O_ST + 128 } |
| 35 | func world_init(base: i64) -> i64 |
| 68 | func start_at(base: i64) -> i64 { return world_init(base) } |
| 71 | func tick_at(base: i64, mx: i64, my: i64, buttons: i64) -> i64 |
| 97 | func px(base: i64, x: i64, y: i64, col: i64) -> i64 |
| 106 | func rect(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, col: i64) -> i64 |
| 115 | func circle(base: i64, cx: i64, cy: i64, r: i64, col: i64) -> i64 |
| 127 | func sxof(wx: i64) -> i64 { return HW + wx / SCALE } called by 1: render_at |
| 128 | func syof(wy: i64) -> i64 { return GROUNDY - wy / SCALE } called by 1: render_at |
| 129 | func rgbp(r: i64, g: i64, b: i64) -> i64 { return r + g * 256 + b * O_MAGIC_65536 } called by 1: render_at |
| 131 | func render_at(base: i64) -> i64 |
| 198 | func body_count_at(base: i64) -> i64 { let h: *i64 = (base + O_PH) as *i64; return h[0] } |
| 199 | func asleep_count_at(base: i64) -> i64 |
| 212 | func start() -> i64 { return start_at(0) } |
| 213 | func tick(mx: i64, my: i64, buttons: i64) -> i64 { return tick_at(0, mx, my, buttons) } calls 1: tick_at |
| 214 | func render() -> i64 { return render_at(0) } calls 1: render_at |
| 215 | func body_count() -> i64 { return body_count_at(0) } calls 1: body_count_at |
| 216 | func asleep_count() -> i64 { return asleep_count_at(0) } calls 1: asleep_count_at |
| 217 | func fb_off() -> i64 { return O_FB } |
| 218 | func ww() -> i64 { return W } |
| 219 | func hh() -> i64 { return H } |
| 220 | func main() -> i64 { start(); return 0 } calls 1: start |