hn.today

Show HN: PS2 games statically recompiled to WebAssembly

github.com39 points9 comments
Screenshot of Show HN: PS2 games statically recompiled to WebAssembly

This project turns PlayStation 2 games into browser-playable WebAssembly pages by statically recompiling the console's Emotion Engine machine code to C++ and linking it with a reimplementation of PS2 OS and hardware that renders via WebGPU. The recompiler (eerecomp) analyzes control flow and emits functions in 16 KiB guest-code units while preserving the R5900's quirks - 128‑bit registers, multimedia ops, branch delay slots, and the PS2 FPU's non‑IEEE behavior. The EE kernel is implemented with high‑level emulation (threads, semaphores, DMA, SIF), the I/O processor runs disc-shipped IRX modules on an R3000 interpreter, VU1 microprograms are compiled ahead‑of‑time to SIMD C++ (or translated on first encounter to Wasm), and the Graphics Synthesizer is modeled on the GPU with swizzled GS memory and WebGPU compute shaders so effects that read back framebuffers or use palettes behave exactly.

Practical results include Gran Turismo 4 running from boot through races at 50 FPS (PAL) in Chrome on integrated GPUs at twice native resolution, and God of War II reaching combat at steady 48-60 FPS after fixing recompiler, VU timing and IOP gaps. Performance lessons: moving GS to GPU shaders and compiling VU code eliminated major bottlenecks; batching, hoisting texture uploads, a 16 MB GPU cache cut per‑frame data by ~60%, and avoiding browser timing clamping improved stability. A port script automates conversion from an ISO; builds require CMake/Ninja/clang, Emscripten, Python and yield ~300 MB per game.

Read on github.com9 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Web

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.