c/sm64-sharworld sm64hero shar
hero binaryshar

The Simpsons: Hit & Run2003, Homer Simpson
SRR2.wasm 3,669,626 bytes8,522 funcs, namedmainSRR2.wasmfunc 5873
; CharacterManager() inlined: Homer's tuning
193505i32.const591676; &sfAirGravity
193509i32.const-1043857408; -25.0
19350fi32.store
193512i32.const591680; &sfStompGravityScale
193516i32.const1078858875; 3.22
19351ci32.store
19351fi32.const591696; &sfJumpHeight
193523i32.const1072902963; 1.9
193529i32.store
19352ci32.const591700; &sfDoubleJump…
193530i32.const1065353216; 1.0
193536i32.store
sm64:sharreal frame, Bob-omb Battlefield1920 x 1080
runtimethree.js + Rapier, rapier.wasm 1,569,588 bytes
; values copied from SRR2.wasm main: 3.22, 1.9, -25
; the only code between the two binaries
host.js:547M._splice_set_puppet(1, p.pos[0], …)
homer.js:279mp.gravityScale = base.gravityScale * 3.22
homer.js:154ctx.combat.melee({ …, kind: 'crush' })
host.js:312M._splice_damage(id, amount, k, …)
host.js:496M.spliceHurt = onHurt
world binarysm64

Super Mario 641996, sm64ex, decompiled
sm64.wasm 12,493,041 bytes2,116 funcs, namedbhv_mario_updatesm64.wasmfunc 1565
; Mario is now Homer's invisible puppet
071b56local.get2; m = gMarioState
071b58local.get13; x, from Homer
071b5alocal.get16; y
071b5cf32.const100
071b61f32.add; y + 100
071b62local.get17; z
071b64local.get2
071b66i32.const104
071b69i32.add; &m->floor
071b6acallfind_floor; under Homer
071b6df32.storeoffset=112; m->floorHeight
Homer's stomp lands as a ground pound
One button press, followed through both binaries. Every block is real code: sm64.wasm runs in the tab, and SRR2.wasm is where Homer's numbers come from, copied into his hero pack.
JumpAction::DoSimulation(float)SRR2.wasm, herofunc 7378
; 1. the slam falls at 3.22 x gravity
207238f32.loadoffset=44; mfGravity = sfAirGravity, -25
20723bf32.mul; x dt
20723ci32.const591680; &CharacterTune::sfStompGravityScale
207240f32.load; 3.22, stored by main at 193516
207243f32.const1
207248local.get0
20724ai32.load8_uoffset=72
20724di32.const64; mbSlam
207250i32.and
207251select; mbSlam ? 3.22 : 1
207252f32.mul; added to mVelocity.y next
homer.js + host.jsruntime, JavaScripthero pack + world adapter
; 2. the same number, then the landing
homer.js:279mp.gravityScale = base.gravityScale * 3.22
homer.js:152h.setAnim('stomp_land')
homer.js:154const hits = ctx.combat.melee({ range: P.stompRadius, arc: TAU,
hero.json"stompDamage": 60, "stompRadius": 4.0
host.js:19const DMG_KIND = { …, fire: 3, crush: 4, magic: 5 }
host.js:311const k = DMG_KIND[kind] ?? 2
host.js:312M._splice_damage(id, amount, k, from ? 1 : 0, …)
obj_handle_attackssm64.wasm, worldfunc 1105
; XREF bhv_goomba_update 04fa35: call obj_handle_attacks
; 4. the Goomba's own code reads it: squished
04da5alocal.get2; sGoombaAttackHandlers
04da5clocal.get0; oInteractStatus
04da5ei32.const255
04da61i32.and; attack type 4
04da62local.tee0
04da64i32.add
04da65i32.const1
04da67i32.sub
04da68i32.load8_u; handlers[3] = ATTACK_HANDLER_SQUISHED
04da6bi32.const1
04da6di32.sub
04da6ebr_table0 1 2 3 4 5 6 7 8; jump to the handler
splice_damagesm64.wasm, worldfunc 1764
; 3. crush counts as Mario's ground pound
0aa7dbi32.const49156; 0xC004 ATTACK_GROUND_POUND_OR_TWIRL
0aa7dflocal.set0
0aa7e5local.get2; kind = 4, crush
0aa7e7i32.const1
0aa7e9i32.sub
0aa7eabr_table1 0 0 1 0; explosion, crush: keep it
; 0aa7f1 .. 0aa80c: from above, punch, kick
0aa80dlocal.get9; the enemy object
0aa80flocal.get0
0aa811i32.storeoffset=308; o->oInteractStatus = 0xC004
splice_report_hurtsm64.wasm, worldfunc 1747
; and back: a Goomba bites Homer
0a8f87i32.const1
0a8f89local.get0; wedges of SM64 health
0a8f8blocal.get0
0a8f8di32.const1
0a8f8fi32.le_s
0a8f90select; at least 1
0a8f91f32.convert_i32_u
0a8f92f32.const12.5; 1 wedge = 12.5 HP
0a8f97f32.mul
; 0a8f98 .. 0a8fa6: promote, store, push args
0a8fa8callemscripten_asm_const_int; to JS
homer.jshero packruntime
; Homer reacts with his own clips
homer.js:229if (dmg >= 35 || …) {
homer.js:232 h.setAnim('knockdown')
homer.js:235} else if (knockT <= 0) {
homer.js:236 h.setAnim('pain')
avatar.glb33 clips from homer_a.p3d
the two binariesas served, read-only
| sm64.wasm | SRR2.wasm | |
|---|---|---|
| bytes | 12,493,041 | 3,669,626 |
| code section | 875,854 | 2,643,585 |
| data section | 11,286,468 | 533,544 |
| functions | 2,116 | 8,522 |
| names | 2,172 | 8,966 |
| imports | 56 | 444 |