nx_wasm_breeders.nx
buildroot/runtime/nx_wasm_breeders.nx
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
imports: nx_syscalls.nxnx_input_abstract.nx
imported by: nx_desktop_breeders.nxnx_wasm_breeders_gate.nx
structs
| none |
consts
| 15 | const O_MAGIC_374761393: i64 = 374761393 |
| 16 | const O_MAGIC_668265263: i64 = 668265263 |
| 17 | const O_MAGIC_1442695041: i64 = 1442695041 |
| 18 | const O_MAGIC_4611686018427387903: i64 = 4611686018427387903 |
| 19 | const O_MAGIC_1274126177: i64 = 1274126177 |
| 20 | const O_MAGIC_1024: i64 = 1024 |
| 21 | const O_MAGIC_3072: i64 = 3072 |
| 22 | const O_MAGIC_1048576: i64 = 1048576 |
| 23 | const O_MAGIC_88172645463325252: i64 = 88172645463325252 |
| 24 | const O_MAGIC_99999: i64 = 99999 |
| 25 | const O_MAGIC_2654435761: i64 = 2654435761 |
| 26 | const O_MAGIC_1013904223: i64 = 1013904223 |
| 27 | const O_MAGIC_12345: i64 = 12345 |
| 28 | const O_MAGIC_7919: i64 = 7919 |
| 29 | const O_MAGIC_30000: i64 = 30000 |
| 30 | const O_MAGIC_1600: i64 = 1600 |
| 31 | const O_MAGIC_999999999: i64 = 999999999 |
| 32 | const O_MAGIC_3000: i64 = 3000 |
| 33 | const O_MAGIC_1400: i64 = 1400 |
| 34 | const O_MAGIC_9973: i64 = 9973 |
| 35 | const O_MAGIC_20260727: i64 = 20260727 |
| 37 | const W: i64 = 480 |
| 38 | const H: i64 = 300 |
| 39 | const O_FB: i64 = 0 // framebuffer W*H i64 packed R|G<<8|B<<16 |
| 40 | const O_ST: i64 = W*H*8 // state block |
| 41 | const O_WLD: i64 = O_ST + 64*8 // tile map MW*MH i64 |
| 42 | const MW: i64 = 40 |
| 43 | const MH: i64 = 26 |
| 44 | const TS: i64 = 32 |
| 45 | const O_WILD: i64 = O_WLD + MW*MH*8 // wilds: 6 rows x 12 i64 |
| 46 | const NWILD: i64 = 6 |
| 47 | const WSTR: i64 = 12 |
| 48 | const O_PARTY: i64 = O_WILD + NWILD*WSTR*8 // party: 8 rows x 6 i64 |
| 49 | const PSTR: i64 = 6 |
| 50 | const O_INPUT: i64 = O_PARTY + 8*PSTR*8 // nx_input_abstract arena (64 words == IA_WORDS, gate-checked) |
| 51 | const WORDS: i64 = O_INPUT/8 + 64 + 64 |
| 54 | const S_PX:i64=0; const S_PY:i64=1; const S_T:i64=2; const S_HP:i64=3; const S_NP:i64=4 |
| 55 | const S_SEED:i64=5; const S_OVER:i64=6; const S_FACE:i64=7; const S_WALK:i64=8 |
| 56 | const S_MSG:i64=9; const S_MSGT:i64=10; const S_BORN:i64=11; const S_TGT:i64=12 |
| 57 | const S_SHAKE:i64=13; const S_FLASH:i64=14; const S_CHARM:i64=15 |
| 59 | const V_X:i64=0; const V_Y:i64=1; const V_G:i64=2; const V_POLY:i64=3; const V_HP:i64=4 |
| 60 | const V_ALIVE:i64=5; const V_HX:i64=6; const V_HY:i64=7; const V_LVL:i64=8; const V_FACE:i64=9 |
| 61 | const V_WALK:i64=10; const V_PH:i64=11 |
| 63 | const T_GRASS:i64=0; const T_TREE:i64=1; const T_WATER:i64=2; const T_ROCK:i64=3; const T_DEN:i64=4 |
| 109 | const 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
| 65 | func st(base: i64) -> *i64 { return (base + O_ST) as *i64 } |
| 66 | func fb(base: i64) -> *i64 { return (base + O_FB) as *i64 } |
| 67 | func wld(base: i64) -> *i64 { return (base + O_WLD) as *i64 } |
| 68 | func wildp(base: i64, i: i64) -> *i64 { return (base + O_WILD + i*WSTR*8) as *i64 } |
| 69 | func party(base: i64, i: i64) -> *i64 { return (base + O_PARTY + i*PSTR*8) as *i64 } |
| 70 | func inp(base: i64) -> *i64 { return (base + O_INPUT) as *i64 } |
| 73 | func iabs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } |
| 74 | func clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v } |
| 75 | func imin(a: i64, b: i64) -> i64 { if a<b {return a} return b } |
| 76 | func isqrt(n: i64) -> i64 { |
| 85 | func hsh(x: i64, y: i64, s: i64) -> i64 { |
| 93 | func vnz(x: i64, y: i64, s: i64, sc: i64) -> i64 { |
| 110 | func al0(g: i64, t: i64) -> i64 { return (g >> (t*4)) & 3 } |
| 111 | func al1(g: i64, t: i64) -> i64 { return (g >> (t*4+2)) & 3 } |
| 112 | func gput(g: i64, t: i64, a: i64, b: i64) -> i64 { |
| 120 | func phen(g: i64, t: i64) -> i64 { |
| 136 | func rng(base: i64) -> i64 { // xorshift on the state seed |
| 145 | func gamete(base: i64, g: i64, t: i64) -> i64 { // Mendel's 1st law |
| 149 | func gcross(base: i64, ga: i64, gb: i64) -> i64 { // Mendel's 2nd law |
| 155 | func founder_g(seed: i64) -> i64 { |
| 169 | func hair_r(g: i64) -> i64 { let c: i64=phen(g,G_COAT); if c==2 {return 196} if c==1 {return 236} return 240 } |
| 170 | func hair_g(g: i64) -> i64 { let c: i64=phen(g,G_COAT); if c==2 {return 44} if c==1 {return 152} return 236 } |
| 171 | func hair_b(g: i64) -> i64 { let c: i64=phen(g,G_COAT); if c==2 {return 62} if c==1 {return 176} return 244 } |
| 172 | func 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 } |
| 173 | func 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 } |
| 174 | func 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 } |
| 177 | func pack(r: i64, g: i64, b: i64) -> i64 { |
| 180 | func px(base: i64, x: i64, y: i64, c: i64) -> i64 { |
| 184 | func rect(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64 { |
| 194 | func ell(base: i64, cx: i64, cy: i64, rx: i64, ry: i64, r: i64, g: i64, b: i64) -> i64 { |
| 213 | func limb(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, r0: i64, r1: i64, r: i64, g: i64, b: i64) -> i64 { |
| 225 | func tri(base: i64, x0:i64,y0:i64,x1:i64,y1:i64,x2:i64,y2:i64, c: i64) -> i64 { |
| 245 | func tile(base: i64, tx: i64, ty: i64) -> i64 { |
| 250 | func 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 |
| 251 | func blocked(base: i64, wx: i64, wy: i64) -> i64 { |
| 259 | func genworld(base: i64, seed: i64) -> i64 { |
| 291 | func drawgirl(base: i64, cx: i64, cy: i64, h: i64, g: i64, t: i64, face: i64, walk: i64) -> i64 { |
| 411 | func init_impl(base: i64, seed: i64) -> i64 { |
| 452 | func tick_impl(base: i64, dir: i64) -> i64 { |
| 506 | func nearest_wild(base: i64) -> i64 { |
| 524 | func do_interact(base: i64) -> i64 { |
| 568 | func do_breed(base: i64) -> i64 { |
| 591 | func render_impl(base: i64) -> i64 { |
| 751 | func step_impl(base: i64) -> i64 { |
| 766 | func init() -> i64 { return init_impl(0, O_MAGIC_20260727) }
calls 1: init_impl |
| 767 | func init_seed(sd: i64) -> i64 { return init_impl(0, sd) }
calls 1: init_impl |
| 768 | func tick(dir: i64) -> i64 { return tick_impl(0, dir) }
calls 1: tick_impl |
| 769 | func render() -> i64 { return render_impl(0) }
calls 1: render_impl |
| 770 | func fb_off() -> i64 { return O_FB } |
| 771 | func ww() -> i64 { return W } |
| 772 | func hh() -> i64 { return H } |
| 773 | func hp() -> i64 { let s: *i64 = st(0); return s[S_HP] }
calls 1: st |
| 774 | func party_n() -> i64 { let s: *i64 = st(0); return s[S_NP] }
calls 1: st |
| 775 | func born() -> i64 { let s: *i64 = st(0); return s[S_BORN] }
calls 1: st |
| 776 | func over() -> i64 { let s: *i64 = st(0); return s[S_OVER] }
calls 1: st |
| 777 | func msg() -> i64 { let s: *i64 = st(0); if s[S_MSGT] > 0 { return s[S_MSG] } return 0 }
calls 1: st |
| 779 | func key(code: i64, down: i64) -> i64 { return ia_key(inp(0), code, down) } |
| 780 | func padb(btn: i64, down: i64) -> i64 { return ia_pad(inp(0), btn, down) } |
| 781 | func paxis(idx: i64, milli: i64) -> i64 { return ia_axis(inp(0), idx, milli) } |
| 782 | func touch(tx: i64, ty: i64, down: i64) -> i64 { return ia_touch(inp(0), tx, ty, W, H, down) } |
| 783 | func step() -> i64 { return step_impl(0) }
calls 1: step_impl |