PS2 games in the browser: static recompilation to WebAssembly with a native runtime
C++
port.sh: explore with an empty memory card in slot 1
Samir Nuri2540e3cf9b88
diff --git a/README.md b/README.mdindex 5626d76..277dabe 100644--- a/README.md+++ b/README.md@@ -61,7 +61,7 @@ python3 scripts/serve.py build/web-mygame games/mygame/disc.iso # http://loca`port.sh` takes a disc image (an ISO, or a ZIP or 7z archive holding one) and does the whole job. It reads the boot program named in the disc's `SYSTEM.CNF`, translates its machine code to C++, and then runs the game headless a few times. Static analysis cannot see every function a game reaches through pointers, so each run writes down the addresses it could not find, the script adds them as entry points and translates again, until a run gets through without new ones. The same runs record the vector unit microprograms the game uploads, which are compiled ahead of time as well. Last it builds the page into `build/web-mygame`. God of War II goes from ISO to page in three and a half minutes on an 8-core laptop.-The exploring runs press start and then cross every five seconds, which gets most games through their title screens. `--press 900:cross` replaces that with your own inputs and `--frames` sets how long each run lasts. Frames from the last run land in `games/mygame/shots`, which is the quickest way to see how far a new game gets. `scripts/build_web.sh mygame` rebuilds only the page.+The exploring runs press start and then cross every five seconds, which gets most games through their title screens, and put an empty memory card in slot 1 the way the page does, so they follow the path a player takes. `--press 900:cross` replaces that with your own inputs and `--frames` sets how long each run lasts. Frames from the last run land in `games/mygame/shots`, which is the quickest way to see how far a new game gets. `scripts/build_web.sh mygame` rebuilds only the page.Set your expectations accordingly: two games have been brought up so far. Another game will most likely stop at a system call or an IOP library function nobody implemented yet, which the runner logs as `[sys] unhandled syscall` or `[iop] missing <library> #<n>`, or use a GS feature the renderer does not handle yet.diff --git a/scripts/port.sh b/scripts/port.shindex 32f9321..e4a85bd 100755--- a/scripts/port.sh+++ b/scripts/port.sh@@ -104,8 +104,8 @@ if [ "$explore" = 1 ]; thenfifor ((round = 1; round <= rounds; round++)); doninja -C "$native" ps2run > "$native/ninja.log" 2>&1 || { tail -30 "$native/ninja.log"; exit 1; }- rm -f "$game/misses.txt"- PS2_GPU_LOW_POWER=1 PS2_VU_RECORD="$game/vu1" "$native/ps2run" "$elf" --disc "$iso" --misses "$game/misses.txt" \+ rm -f "$game/misses.txt" "$game/explore.ps2"+ PS2_GPU_LOW_POWER=1 PS2_VU_RECORD="$game/vu1" "$native/ps2run" "$elf" --disc "$iso" --misses "$game/misses.txt" --memcard "$game/explore.ps2" \--frames "$frames" "${presses[@]}" --frames-dir "$game/shots" --frame-every 300 > "$game/explore.log" 2>&1 || truereason=$(sed -n 's/^\[ee\] halted: //p' "$game/explore.log" | head -1)added=$(python3 -I - "$game/entries.txt" "$game/misses.txt" <<'EOF'