How snuri00/ps2-web-recomp works
PS2 Web Recomp turns a user-supplied game disc image into ahead-of-time recompiled C++ and runs it as a browser-hosted PS2 system. The main runtime path is generated game code through the EE system and its emulated hardware/services to graphics, sound, and video output. The README documents major capabilities and worker boundaries; source excerpts and the index provide only partial implementation wiring, so uncertain links are omitted.
Main entry points: system.cpp PS2 system · gs.cpp Graphics Synthesizer · web.cpp Browser integration · generated.hpp Generated game code
Components 25
Game preparation
- Disc preparation
scripts/disc.py - ELF reader
recomp/elf.cpp - Code analysis
recomp/analysis.cpp - EE code generation
recomp/codegen.cpp - VU compilation
recomp/vurecomp.cpp - Generated game code
runtime/include/ps2/generated.hpp
EE runtime
- PS2 system
runtime/src/system.cpp - EE hardware
runtime/src/hw.cpp - EE kernel
runtime/src/kernel.cpp - Vector units
runtime/src/vu_micro.cpp - VU JIT
runtime/src/vu_jit.cpp
IOP services
- IOP processor
runtime/src/iop/cpu.cpp - IOP kernel and libraries
runtime/src/iop/kernel.cpp - SIF bridge
runtime/src/iop/sif.cpp - Disc access
runtime/src/disc.cpp - SPU2 audio
runtime/src/iop/spu2.cpp - MPEG-2 decoder
runtime/src/ipu/ipu.cpp
Graphics pipeline
- Graphics Synthesizer
runtime/src/gs/gs.cpp - Software rasterizer
runtime/src/gs/raster.cpp - WebGPU renderer
runtime/src/gs/gpu/gpu.cpp - Graphics command queue
runtime/src/gs/queue.cpp
Browser output
- Runtime host
host/main.cpp - Browser integration
host/web.cpp - Window output
host/window.cpp
Other components
- Game owner
Connections 26
- Game owner → Disc preparation: provides image
- Disc preparation → ELF reader: extracts executable
- ELF reader → Code analysis: reads executable
- Code analysis → EE code generation: provides program
- EE code generation → Generated game code: emits C++
- VU compilation → Generated game code: emits SIMD code
- Generated game code → Runtime host: registers code
host/main.cpp - Runtime host → PS2 system: starts runtime
host/main.cpp - PS2 system → EE hardware: models hardware
- PS2 system → EE kernel: provides EE services
- PS2 system → IOP processor: runs IOP
- IOP processor → IOP kernel and libraries: uses kernel services
- IOP kernel and libraries → SIF bridge: dispatches SIF calls
runtime/src/iop/sif.cpp - SIF bridge → Disc access: requests disc data
- PS2 system → Vector units: runs microprograms
- Vector units → VU JIT: compiles unseen programs
runtime/src/vu_micro.cpp - PS2 system → Graphics Synthesizer: sends graphics work
- Graphics Synthesizer → Software rasterizer: draws reference output
runtime/src/gs/gs.cpp - Graphics Synthesizer → WebGPU renderer: dispatches rendering
runtime/src/gs/gs.cpp - Graphics Synthesizer → Graphics command queue: posts commands
runtime/src/gs/gs.cpp - Graphics command queue → Browser integration: delivers render work
- PS2 system → SPU2 audio: emulates sound
- SPU2 audio → Browser integration: streams audio
- PS2 system → MPEG-2 decoder: decodes movies
- WebGPU renderer → Browser integration: presents frames
- Browser integration → Window output: targets display