code wiki / (root) / nx_wasm_physlab.nx

nx_wasm_physlab.nx

buildroot/runtime/nx_wasm_physlab.nx

8242 B220 linesdepth 3pulls 4 transitivereach 2 importersview sourcekind tooltopic wasm
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_phys3d.nx nx_softjiggle.nx nx_wasm_physlab.nx nx_physlab_wasm_vet.nx nx_wasm_physlab_gate.nx

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

main start start_at world_init ph_init ph_hdr ph_acc ph_warm ph_tgt sj_init sj_hdr ph_add ph_hdr ↻ ph_body sj_add_capsule sj_hdr ↻ sj_capsule sj_add sj_hdr ↻ sj_node sj_chain sj_node ↻ st_ptr

structs

none

consts

11const O_MAGIC_100000: i64 = 100000
12const O_MAGIC_1500: i64 = 1500
13const O_MAGIC_3500: i64 = 3500
14const O_MAGIC_3000: i64 = 3000
15const O_MAGIC_2800: i64 = 2800
16const O_MAGIC_3600: i64 = 3600
17const O_MAGIC_1800: i64 = 1800
18const O_MAGIC_2600: i64 = 2600
19const O_MAGIC_65536: i64 = 65536
21const W: i64 = 320
22const H: i64 = 240
23const HW: i64 = 160
24const GROUNDY: i64 = 210 // screen y of the ground line
25const SCALE: i64 = 16 // world fx256 -> screen px divisor
26const O_FB: i64 = 0
27const O_PH: i64 = 614400 // W*H*8; ph_bytes now 106560 (warm+target tables, 2026-07-03)
28const O_SJ: i64 = 721024
29const O_ST: i64 = 739584 // [0]=tick [1]=prev buttons [2]=spawned [3]=chain0 id [4]=lastmx [5]=lastmy
30const NCRATE: i64 = 5

functions

32func st_ptr(base: i64) -> *i64 { return (base + O_ST) as *i64 }
33func mem_bytes() -> i64 { return O_ST + 128 }
called by 2: mainmain
35func world_init(base: i64) -> i64
68func start_at(base: i64) -> i64 { return world_init(base) }
called by 3: mainstartmain calls 1: world_init
71func tick_at(base: i64, mx: i64, my: i64, buttons: i64) -> i64
97func px(base: i64, x: i64, y: i64, col: i64) -> i64
called by 3: rectcirclerender_at
106func rect(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, col: i64) -> i64
called by 1: render_at calls 1: px
115func circle(base: i64, cx: i64, cy: i64, r: i64, col: i64) -> i64
called by 1: render_at calls 1: px
127func sxof(wx: i64) -> i64 { return HW + wx / SCALE }
called by 1: render_at
128func syof(wy: i64) -> i64 { return GROUNDY - wy / SCALE }
called by 1: render_at
129func rgbp(r: i64, g: i64, b: i64) -> i64 { return r + g * 256 + b * O_MAGIC_65536 }
called by 1: render_at
131func render_at(base: i64) -> i64
198func body_count_at(base: i64) -> i64 { let h: *i64 = (base + O_PH) as *i64; return h[0] }
called by 2: body_countmain
199func asleep_count_at(base: i64) -> i64
called by 2: asleep_countmain calls 1: ph_body
212func start() -> i64 { return start_at(0) }
called by 1: main calls 1: start_at
213func tick(mx: i64, my: i64, buttons: i64) -> i64 { return tick_at(0, mx, my, buttons) }
calls 1: tick_at
214func render() -> i64 { return render_at(0) }
calls 1: render_at
215func body_count() -> i64 { return body_count_at(0) }
calls 1: body_count_at
216func asleep_count() -> i64 { return asleep_count_at(0) }
calls 1: asleep_count_at
217func fb_off() -> i64 { return O_FB }
called by 2: mainmain
218func ww() -> i64 { return W }
called by 2: mainmain
219func hh() -> i64 { return H }
called by 2: mainmain
220func main() -> i64 { start(); return 0 }
calls 1: start