Spelunky Classic HD 1.1.7 (yancharkin, 2021; GameMaker:Studio 1.4)

App id spelunky_classic_hd (local-only, lib/apps.js), route ?app=spelunky_classic_hd on a localhost dev server. Download, hashes and licence terms: test/binaries/SOURCES.md, sections "Spelunky Classic HD 1.1.7" and "DirectX End-User Runtimes, June 2010". Evidence: scratch/runs/20261124-spelunky-hd/ (final2/ is the run on the committed build).

What the binary is

Load bases (headless)

Module Runtime base Original base
SpelunkyClassicHD.exe 0x00400000 (entry 0x006b8609) same
d3dx9_43.dll 0x00b88000 0x10000000
msvcrt.dll 0x00e87000
comctl32.dll 0x00fcb000
oleaut32.dll 0x01157000

shell32 and ole32 are not on disk; the WAT stubs answer them.

Threads

Route (headless)

node test/run.js --app=spelunky_classic_hd --headless-gl --quiet-api \
  --screen=1024x768 --tick-ms-per-batch=5 --max-batches=181000 --no-close \
  --input=112000:keydown:13,112060:keyup:13,131000:keydown:37,166100:keyup:37,166200:keydown:38,166600:keyup:38,180000:png:out.png

Gameplay route: level 1-1 via START (headless, deterministic)

Run scratch/runs/20261125-spelunky-hd-gameplay-profile/route/route.sh. It drives run.js --control --frozen with tools/ctl.js. Its gen-input.js emits the same events as one --input= string. Both produce byte-identical PNGs at every checkpoint (ctl and three --input replays matched).

Flags: --screen=1024x768 --tick-ms-per-batch=5 --stuck-after=0 --headless-gl.

Batch Event
112000 Enter, held 60 batches
131000–160000 Hold Left; he stops at TUTORIAL
160200–162700 Right
163200–163900 Right
164300 Up, held 400 batches; enters START
~205000 Level 1-1 is generated
213550 Player at the entrance door; HUD shows 4 hearts, 4 bombs, 4 ropes, $0

Browser: Enter twice, about 30 frames apart, skips the intro straight to the title room by about frame 70. Two attempts with --guest-script frame pacing and wall-clock key holds left the player at the START door without entering it. The script's hold times are wall seconds, not frames.

Gameplay profile (2026-11-25, worktree a0bc18145)

Window: batches 225000–345000, 485 presents, inside level 1-1. Load average was 4–15 throughout, so read the shares, not the times. Evidence is in scratch/runs/20261125-spelunky-hd-gameplay-profile/.

Headless (run C, V8 cpuprofile). Wasm is only 37% of samples. The rest splits into:

Rerunning with node --no-turbo-inline-js-wasm-calls (run D) leaves both buckets the same. So inlined JS-to-wasm calls are not what hides there.

The main closure is one async function about 11,800 lines long. Each batch crosses about 15 awaits (nativeFault.wait, mainExecutionSuspended, mainOwner.run/call, serviceMain*Wait, comInterfaces.drain, pumpWaveCallbacks, …), and most of them await a value that is already settled. That is about 0.57 ms of JS per batch. The likely reason, not verified, is that a function this size is never optimized: its own bytecode, plus the async resume and suspend V8 reports at the function-end position, runs as that closure's self time. The browser's host.js step is 0.4%.

Inside wasm (gameplay, all shares are % of wasm self time):

Group % of wasm
Threaded handlers 38
SSE handlers 26
Uop tier (uop_fast alone is 14) 18
Memory access (gs32, g2w_slow) 5
x87 3
Dispatch 3
D3D9/GPS in wasm 0.1 (presents go through the GL stream)

th_sse_rr alone is 18% of wasm. It is 11.9% of threaded ops but 40% of handler self time, at about 231 ns per op against a mean of 68 ns. Next by self time are th_push_r (115 ns), th_load32_rop, th_test_jcc (134 ns), movss_load_ro and movss_store_ro (about 93 ns).

Guest side (run B). Threaded counts come from --handler-hist, and the SSE shares from insn-mix.js (threaded EXE blocks only).

Hot guest code:

Browser (profile-web-frames.js --headful, real GPU): the level was not reached, so the title room was profiled while the player ran, jumped and whipped. Wasm is 85% of the page with Threads off and 96% of the guest Worker with Threads on.

SSE in the uop tier and dedicated SSE2 handlers (2026-11-25, branch uop-sse-bench)

Two opt-in arms, both off by default. Evidence is in scratch/runs/20261125-uop-sse/.

What we know:

Fixed gaps (in order of appearance)

  1. SSE2 XMM forms (decoder gate src/07-decoder.wat, $sse2_form / $sse2_exec in src/06c-mmx.wat): the subops are listed in the table comment there; test/test-sse2-xmm-forms.js.
  2. ExpandEnvironmentStringsW: A and W now share $env_expand.
  3. GetConsoleWindow: returns NULL for this GUI process.
  4. EnumDisplaySettingsW used DEVMODEA offsets. DEVMODEW doubles dmDeviceName and dmFormName, so its fields are 64 bytes later (dmBitsPerPel 168, dmPelsWidth 172, dmPelsHeight 176, dmDisplayFrequency 184; full size 220). The runner read the bit depth from the wrong field and stopped with the MessageBox "requires 16-bit or 32-bit mode". Also added: EnumDisplaySettingsExW, ChangeDisplaySettingsW (same offsets) and GetMonitorInfoW (MONITORINFOEXW, 104 bytes).
  5. IDirect3DDevice9::QueryInterface / IDirect3D9::QueryInterface. D3DX9_43 (at d3dx+0xc8d64) asks the device for IID_IDirect3DDevice9Ex before creating a texture. These now answer IUnknown plus their own IID; the Ex IIDs get E_NOINTERFACE. The crash first showed as <ord> KERNEL32#18.
  6. Waitable timers (CreateWaitableTimerW / SetWaitableTimer / CancelWaitableTimer; CloseHandle disarms). These reuse the multimedia-timer slots with flag 0x40, signalling the timer's event through the winmm timer thread. A completion routine (an APC) still crashes as unimplemented.
  7. WebGL present into a too-small canvas (lib/gpu-stream-webgl.js). The canvas was sized from the first RT the ring created: a 604x453 offscreen RT the size of the window's first client area. The 640x460 back buffer then failed every present. A whole-RT present now resizes the canvas to that RT. Growing it only was tried and is wrong: after a larger whole-RT present, the tutorial's 640x460 frames sat in a stale black margin (final/tutorial-level.png).

Tests: test/test-sse2-xmm-forms.js, test/test-spelunky-hd-win32-gaps.js, plus updated DEVMODEW offsets in the four display tests.

Imports that would still trap

WININET (HttpEndRequestW, InternetWriteFile, HttpQueryInfoA, InternetCrackUrlA, InternetCanonicalizeUrlA, InternetGetConnectedState), dbghelp (MiniDumpWriteDump, SymInitialize, SymFromAddr), ws2_32 (getaddrinfo, WSAAddressToStringA, freeaddrinfo), RtlCaptureStackBackTrace, GetRawInputDeviceInfoA, GetRawInputDeviceList. None was reached on the route above. D3DX also imports GetFileSizeEx and some msvcrt entries.

Hypotheses ruled out

Open