code wiki / (root) / nx_wasm_breeders.nx

nx_wasm_breeders.nx

buildroot/runtime/nx_wasm_breeders.nx

36197 B783 linesdepth 4pulls 4 transitivereach 2 importersview sourcekind librarytopic wasm
docsdependenciesstructsconstsfunctions

about

nx_wasm_breeders.nx -- NISHI BREEDERS, SOVEREIGN. The whole game -- world, characters, animation, genetics, combat -- is NishiLang emitting pixels into a packed-RGB framebuffer. Nothing outside this file draws anything. The browser's only job is to copy the framebuffer to a canvas and hand back key codes; that shim is the single interop boundary and it holds no game logic. BASE-RELATIVE by construction: every address is `base + offset`, so the identical code runs natively (base = mmap) and in wasm (base = 0). The native run renders the same frames to PNG, which is how the wasm build is verified without a browser -- the established "verify wasm by native PNG" loop. Genetics are the real thing, ported from nx_game_genetics.nx: diploid alleles, Mendel's segregation and independent assortment, incomplete dominance on coat, codominant ABO affinity, recessive wings. license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_input_abstract.nx nx_wasm_breeders.nx nx_desktop_breeders.nx nx_wasm_breeders_gate.nx

imports: nx_syscalls.nxnx_input_abstract.nx

imported by: nx_desktop_breeders.nxnx_wasm_breeders_gate.nx

structs

none

consts

15const O_MAGIC_374761393: i64 = 374761393
16const O_MAGIC_668265263: i64 = 668265263
17const O_MAGIC_1442695041: i64 = 1442695041
18const O_MAGIC_4611686018427387903: i64 = 4611686018427387903
19const O_MAGIC_1274126177: i64 = 1274126177
20const O_MAGIC_1024: i64 = 1024
21const O_MAGIC_3072: i64 = 3072
22const O_MAGIC_1048576: i64 = 1048576
23const O_MAGIC_88172645463325252: i64 = 88172645463325252
24const O_MAGIC_99999: i64 = 99999
25const O_MAGIC_2654435761: i64 = 2654435761
26const O_MAGIC_1013904223: i64 = 1013904223
27const O_MAGIC_12345: i64 = 12345
28const O_MAGIC_7919: i64 = 7919
29const O_MAGIC_30000: i64 = 30000
30const O_MAGIC_1600: i64 = 1600
31const O_MAGIC_999999999: i64 = 999999999
32const O_MAGIC_3000: i64 = 3000
33const O_MAGIC_1400: i64 = 1400
34const O_MAGIC_9973: i64 = 9973
35const O_MAGIC_20260727: i64 = 20260727
37const W: i64 = 480
38const H: i64 = 300
39const O_FB: i64 = 0 // framebuffer W*H i64 packed R|G<<8|B<<16
40const O_ST: i64 = W*H*8 // state block
41const O_WLD: i64 = O_ST + 64*8 // tile map MW*MH i64
42const MW: i64 = 40
43const MH: i64 = 26
44const TS: i64 = 32
45const O_WILD: i64 = O_WLD + MW*MH*8 // wilds: 6 rows x 12 i64
46const NWILD: i64 = 6
47const WSTR: i64 = 12
48const O_PARTY: i64 = O_WILD + NWILD*WSTR*8 // party: 8 rows x 6 i64
49const PSTR: i64 = 6
50const O_INPUT: i64 = O_PARTY + 8*PSTR*8 // nx_input_abstract arena (64 words == IA_WORDS, gate-checked)
51const WORDS: i64 = O_INPUT/8 + 64 + 64
54const S_PX:i64=0; const S_PY:i64=1; const S_T:i64=2; const S_HP:i64=3; const S_NP:i64=4
55const S_SEED:i64=5; const S_OVER:i64=6; const S_FACE:i64=7; const S_WALK:i64=8
56const S_MSG:i64=9; const S_MSGT:i64=10; const S_BORN:i64=11; const S_TGT:i64=12
57const S_SHAKE:i64=13; const S_FLASH:i64=14; const S_CHARM:i64=15
59const V_X:i64=0; const V_Y:i64=1; const V_G:i64=2; const V_POLY:i64=3; const V_HP:i64=4
60const V_ALIVE:i64=5; const V_HX:i64=6; const V_HY:i64=7; const V_LVL:i64=8; const V_FACE:i64=9
61const V_WALK:i64=10; const V_PH:i64=11
63const T_GRASS:i64=0; const T_TREE:i64=1; const T_WATER:i64=2; const T_ROCK:i64=3; const T_DEN:i64=4
109const G_HORN:i64=0; const G_WING:i64=1; const G_COAT:i64=2; const G_ELEM:i64=3; const G_TAIL:i64=4

functions

65func st(base: i64) -> *i64 { return (base + O_ST) as *i64 }
66func fb(base: i64) -> *i64 { return (base + O_FB) as *i64 }
67func wld(base: i64) -> *i64 { return (base + O_WLD) as *i64 }
called by 2: tilegenworld
68func wildp(base: i64, i: i64) -> *i64 { return (base + O_WILD + i*WSTR*8) as *i64 }
69func party(base: i64, i: i64) -> *i64 { return (base + O_PARTY + i*PSTR*8) as *i64 }
70func inp(base: i64) -> *i64 { return (base + O_INPUT) as *i64 }
73func iabs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 2: init_impldo_breed
74func clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v }
75func imin(a: i64, b: i64) -> i64 { if a<b {return a} return b }
76func isqrt(n: i64) -> i64 {
85func hsh(x: i64, y: i64, s: i64) -> i64 {
93func vnz(x: i64, y: i64, s: i64, sc: i64) -> i64 {
called by 2: genworldrender_impl calls 1: hsh
110func al0(g: i64, t: i64) -> i64 { return (g >> (t*4)) & 3 }
called by 2: phengamete
111func al1(g: i64, t: i64) -> i64 { return (g >> (t*4+2)) & 3 }
called by 2: phengamete
112func gput(g: i64, t: i64, a: i64, b: i64) -> i64 {
called by 2: gcrossfounder_g
120func phen(g: i64, t: i64) -> i64 {
136func rng(base: i64) -> i64 { // xorshift on the state seed
called by 2: gametedo_interact calls 1: st
145func gamete(base: i64, g: i64, t: i64) -> i64 { // Mendel's 1st law
called by 1: gcross calls 3: rngal1al0
149func gcross(base: i64, ga: i64, gb: i64) -> i64 { // Mendel's 2nd law
called by 2: do_breedmain calls 2: gputgamete
155func founder_g(seed: i64) -> i64 {
called by 2: init_implmain calls 2: gputhsh
169func hair_r(g: i64) -> i64 { let c: i64=phen(g,G_COAT); if c==2 {return 196} if c==1 {return 236} return 240 }
called by 1: drawgirl calls 1: phen
170func hair_g(g: i64) -> i64 { let c: i64=phen(g,G_COAT); if c==2 {return 44} if c==1 {return 152} return 236 }
called by 1: drawgirl calls 1: phen
171func hair_b(g: i64) -> i64 { let c: i64=phen(g,G_COAT); if c==2 {return 62} if c==1 {return 176} return 244 }
called by 1: drawgirl calls 1: phen
172func eye_r(g: i64) -> i64 { let e: i64=phen(g,G_ELEM); if e==1 {return 255} if e==2 {return 92} if e==3 {return 214} return 130 }
called by 1: drawgirl calls 1: phen
173func eye_g(g: i64) -> i64 { let e: i64=phen(g,G_ELEM); if e==1 {return 152} if e==2 {return 172} if e==3 {return 128} return 196 }
called by 1: drawgirl calls 1: phen
174func eye_b(g: i64) -> i64 { let e: i64=phen(g,G_ELEM); if e==1 {return 64} if e==2 {return 255} if e==3 {return 255} return 180 }
called by 1: drawgirl calls 1: phen
177func pack(r: i64, g: i64, b: i64) -> i64 {
called by 3: elldrawgirlrender_impl calls 1: clamp
180func px(base: i64, x: i64, y: i64, c: i64) -> i64 {
called by 4: elltridrawgirlrender_impl calls 1: fb
184func rect(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64 {
called by 2: drawgirlrender_impl calls 2: clampfb
194func ell(base: i64, cx: i64, cy: i64, rx: i64, ry: i64, r: i64, g: i64, b: i64) -> i64 {
called by 3: limbdrawgirlrender_impl calls 3: clamppxpack
213func limb(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, r0: i64, r1: i64, r: i64, g: i64, b: i64) -> i64 {
called by 1: drawgirl calls 1: ell
225func tri(base: i64, x0:i64,y0:i64,x1:i64,y1:i64,x2:i64,y2:i64, c: i64) -> i64 {
called by 1: drawgirl calls 2: clamppx
245func tile(base: i64, tx: i64, ty: i64) -> i64 {
called by 3: blockedrender_implmain calls 1: wld
250func solidt(t: i64) -> i64 { if t==T_TREE {return 1} if t==T_WATER {return 1} if t==T_ROCK {return 1} return 0 }
called by 1: blocked
251func blocked(base: i64, wx: i64, wy: i64) -> i64 {
called by 2: init_impltick_impl calls 2: solidttile
259func genworld(base: i64, seed: i64) -> i64 {
called by 1: init_impl calls 2: wldvnz
291func drawgirl(base: i64, cx: i64, cy: i64, h: i64, g: i64, t: i64, face: i64, walk: i64) -> i64 {
411func init_impl(base: i64, seed: i64) -> i64 {
452func tick_impl(base: i64, dir: i64) -> i64 {
506func nearest_wild(base: i64) -> i64 {
called by 1: do_interact calls 2: stwildp
524func do_interact(base: i64) -> i64 {
568func do_breed(base: i64) -> i64 {
called by 1: tick_impl calls 5: stiabspartygcrossphen
591func render_impl(base: i64) -> i64 {
called by 3: mainrendermain calls 13: stclamptilevnzpackpx+7
751func step_impl(base: i64) -> i64 {
766func init() -> i64 { return init_impl(0, O_MAGIC_20260727) }
calls 1: init_impl
767func init_seed(sd: i64) -> i64 { return init_impl(0, sd) }
calls 1: init_impl
768func tick(dir: i64) -> i64 { return tick_impl(0, dir) }
calls 1: tick_impl
769func render() -> i64 { return render_impl(0) }
calls 1: render_impl
770func fb_off() -> i64 { return O_FB }
771func ww() -> i64 { return W }
772func hh() -> i64 { return H }
773func hp() -> i64 { let s: *i64 = st(0); return s[S_HP] }
calls 1: st
774func party_n() -> i64 { let s: *i64 = st(0); return s[S_NP] }
calls 1: st
775func born() -> i64 { let s: *i64 = st(0); return s[S_BORN] }
calls 1: st
776func over() -> i64 { let s: *i64 = st(0); return s[S_OVER] }
calls 1: st
777func msg() -> i64 { let s: *i64 = st(0); if s[S_MSGT] > 0 { return s[S_MSG] } return 0 }
calls 1: st
779func key(code: i64, down: i64) -> i64 { return ia_key(inp(0), code, down) }
calls 2: ia_keyinp
780func padb(btn: i64, down: i64) -> i64 { return ia_pad(inp(0), btn, down) }
calls 2: ia_padinp
781func paxis(idx: i64, milli: i64) -> i64 { return ia_axis(inp(0), idx, milli) }
calls 2: ia_axisinp
782func touch(tx: i64, ty: i64, down: i64) -> i64 { return ia_touch(inp(0), tx, ty, W, H, down) }
calls 2: ia_touchinp
783func step() -> i64 { return step_impl(0) }
calls 1: step_impl