gow2-recomp

gow2-recomp is a native macOS port of God of War II HD using static recompilation with Metal graphics.

README

English · Português (Brasil)

God of War II HD — native macOS port by static recompilation

God of War II HD (PS3, NPUA80491) running natively on Apple Silicon: no emulator, no JIT. The PowerPC (PPU) and Cell SPU code is translated ahead of time into C/C++, compiled with clang for arm64, and runs on a reimplementation of the PS3 OS and libraries with Metal for graphics, VideoToolbox for cutscenes and CoreAudio for sound.

This repository contains no game code and no game assets. Like Dusk, you bring your own legally dumped copy, and the setup kit decrypts, translates and builds it on your machine.

Combat in the palace of RhodesThe Colossus of Rhodes through the palace windows
Blades of Chaos effectsVolumetric light in the palace

Captured from the native Metal renderer on an M-series Mac (1280×720 internal, MetalFX upscaled).


Status

AreaState
Boot, intro videos, logos✅ natural path, videos decoded by VideoToolbox
Main menu, New Game, saves✅ memory-card saves on disk
Rhodes gameplay (combat, HUD, particles, lighting)✅ 45–60 fps on Apple Silicon (Mac, Metal; measured numbers in Estado por plataforma e desempenho)
Colossus of Rhodes fight🟡 playable; the bronze drape on its shoulder is skinned with a sheared bone matrix (under investigation)
After the Colossus cutscene✅ fixed 2026-09-22: a lifted SPU program (spu1) was writing into the PPU code segment, which produced ICALL-BAD 0x80029F47; validated with 305 s of New Game → gameplay, 0 ICALL-BAD (log)
iOS (iPhone) and Android (tablet)🟡 experimental; see Estado por plataforma e desempenho (pt-BR)
Audio🟡 music/SFX through the SCREAM mixer SPU program; clock still partly host-driven
Controllers✅ DualShock 4 / DualSense / Xbox / MFi via GameController, keyboard + mouse

The engineering log (every wall, the hypotheses refuted by measurement and the fixes) lives in docs/ and in the engine repository.

How it works

EBOOT.ELF (your copy, decrypted)
   │
   ├── PPU  ── ppu_lifter.py ──► ~650 C++ chunks, 69k functions ──┐
   │          (functions.json: curated function bounds,           │
   │           jump tables, mid-function entry points)            │
   │                                                               ├─► clang -O1/-O2 arm64 ─► g2play
   └── SPU  ── spu_lifter.py ──► SPU jobs / SPURS policy modules ─┘            │
                                                                                ▼
                               ps3recomp runtime (MIT): LV2 syscalls, PPU threads,
                               lwmutex/lwcond, SPURS, FIOS, cellGcm → RSX FIFO walker
                               → Metal backend (MSL from RSX VP/FP), cellVdec → VideoToolbox,
                               cellAudio → CoreAudio, cellPad → GameController

What makes a PS3 title hard to recompile, and what this port had to solve:

  • Cell B.E.: one PPU plus up to six SPUs with their own ISA and 256 KB local store; SPU programs (SPURS workloads, job chains, policy modules) are lifted separately and scheduled on host threads.
  • Indirect control flow: 64-bit PowerPC function descriptors (.opd/TOC), vtables, computed bctr jump tables and mid-function entries, all of which the lifter must resolve statically.
  • RSX: the command FIFO (with CALL/JUMP, wait points and ring wraps) is walked on the host, and the NV40-class vertex/fragment programs are decompiled to Metal Shading Language.
  • Faithfulness over shortcuts: fixes follow console behaviour (RPCS3 is used as a measurement oracle via its GDB stub); diagnostics are gated off by default.

Launcher (macOS)

GoW2 Recomp launcher

GoW2 Recomp.app is a native SwiftUI launcher in the spirit of Dusk: point it at your own EBOOT.ELF and USRDIR, pick graphics/audio/control options, manage mods and play. Build it with:

launcher/macos/build_app.sh     # -> ./GoW2 Recomp.app
  • No Python, no interpreter: validation, config, autosave checks (SHA-256 per file) and mod import run in Swift inside the app.
  • RPCS3-style patches: the launcher computes your executable's RPCS3 PPU hash by streaming the ELF (for NPUA80491 01.00 it is PPU-31e32090ea333902dbf322c24487bab7e8c8d0d1), reads RPCS3's patch.yml (anchors, aliases, configurable values) or any .yml you import, and passes the enabled ones to the runtime (PS3_PATCH_FILE). Data patches (e.g. aspect ratio) take effect; code patches are flagged, because the code was already recompiled and would need a re-lift.
  • Design system in launcher/macos/MASTER.md.

Bring your own game (macOS kit)

A Dusk-style kit: point it at your own game folder (PS3_GAME, from RPCS3's dev_hdd0/game/NPUA80491 or your PS3) and your license (UP9000-NPUA80491_00-GODOFWARIIHDUS00.rap), and it builds the native binary on your Mac:

./kit/setup.sh /path/to/PS3_GAME        # finds the .rap in RPCS3's exdata or ~/Downloads
./jogar_g2.sh

setup.sh does the following:

  1. It decrypts EBOOT.BIN itself, the same way RPCS3 does (engine tools/unself).
  2. It recompiles the PPU code with the pinned lifter, the patch scripts and a small delta.
  3. It recompiles the seven SPU programs.
  4. It extracts the movies from your gow2.psarc.
  5. It links ./g2play.

Every generated file is checked against the hashes in kit/. The result is byte-identical to the build the project tests. Details are in kit/README.md.

Controls: WASD move, mouse camera, Space/E/J/K = ✕/○/□/△, Enter = Start, F11 or Cmd+Enter = fullscreen, Esc releases the mouse.

State of the art in game recompilation

ProjectPlatformApproachNotable result
N64RecompNintendo 64 (MIPS)Static recompilation to CZelda 64: Recompiled and many more; modding framework
XenonRecompXbox 360 (PowerPC)Static recompilation to C++Unleashed Recompiled, the first 360 recomp playable start to finish
ReXGlueXbox 360Static recompilationTooling for 360 ports
PS2RecompPlayStation 2 (MIPS R5900)Static recompilationEarly stage
psprecompPSP (Allegrex MIPS)Static recompilation to CToolkit
ps3recompPlayStation 3 (PPU)Static recompilation runtimeThe base of this port's engine
This portPlayStation 3 (PPU + SPU)Static recompilation, PPU and SPU, native MetalA commercial PS3 title in gameplay on macOS/arm64
Dusk / DusklightGameCubeDecompilation (source rebuilt by hand)Twilight Princess native port; you supply the ISO
RPCS3PlayStation 3Emulation (LLVM JIT/AOT)The reference used here as an oracle

Catalogs: Recompendium, decompilation & recompilation list.

Static recompilation sits between emulation and decompilation: like a decompilation it produces native code with no interpreter or JIT (so it can use native APIs such as Metal directly), but like an emulator it needs no hand-written game source. It only needs the original binary, which is why the user has to supply it.

Project Structure

The root holds only entry points; everything else lives in a folder with one purpose. The full map (with the old root path of every moved script) is scripts/README.md, and scripts/check_layout.sh keeps the root clean.

gow2-recomp/
├── jogar_g2.sh rodar_gow2*.sh testar_fix.sh gow2_launcher.py  # launchers
├── env_gow2.sh                 # environment recipe (sourced by launchers, smokes, iOS/Android builds)
├── build_macos.sh              # Mac build; compiles boot_macos.cpp, gow2_boot.h, host_gow2_*, movie_eos_arm.*, gow2_overlay_provider.*
├── functions.json              # curated PPU function bounds (truncation repairs, mid-function targets)
├── apply_all_patches.sh verify_lift.sh accept_relift.sh  # lift pipeline entry points
├── <old paths>                 # deprecated wrappers to the moved scripts (until 2026-12-31)
├── recomp_mid_v2/              # hand-written glue: SPU registration, overrides, mid-asm hooks, patch_*.py (survive re-lifts)
├── config/gow2_recomp.toml     # lifter configuration (hooks)
├── hooks/                      # function overrides and mid-asm hook sources
├── kit/                        # bring-your-own-game installer (kit/setup.sh) and its release tooling
├── launcher/ ios/ android/     # macOS launcher app, iOS app, Android build
├── scripts/
│   ├── smoke/                  # boot/intro/Metal smoke runs
│   ├── lift/                   # relift gates, promotion, bisect, patch helpers
│   ├── diag/                   # Mac diagnostics on a running boot
│   └── archive/windows/        # the 2026 Windows bring-up scripts (machine-bound, not maintained)
├── tools/                      # PKG/SELF extraction, RPCS3 source search
├── claude_runs/                # agent measurement runs (run for N s / until a capture, then sample)
├── tests/ lift_baseline/       # offline tests and the lift baseline
├── notes/                      # dated investigation notes (+ artifacts/)
└── docs/img/                   # README images

Excluded on purpose (see .gitignore): EBOOT.ELF, extracted/, *.psarc, SPU images, lifted PPU/SPU sources, texture dumps and build output. Those are derived from the game and are regenerated from your own copy.

Legal

God of War II is © Sony Interactive Entertainment. This project is not affiliated with or endorsed by Sony. It distributes no copyrighted game code or assets; you must own the game. The engine is MIT licensed (© sp00nznet and contributors).

O APK para Android é compilado localmente a partir do seu próprio dump e instalado somente no seu próprio aparelho; ele nunca é distribuído. As bibliotecas do FFmpeg dentro do app continuam sob a LGPL-2.1 e podem ser copiadas, modificadas e substituídas.


Em português

Port nativo de God of War II HD (PS3) para macOS/Apple Silicon por recompilação estática: o código PowerPC e SPU do jogo é traduzido para C/C++ e compilado para arm64, rodando sobre uma reimplementação do sistema do PS3 com Metal, VideoToolbox e CoreAudio. Nenhum código ou arquivo do jogo é distribuído: como no Dusk, você fornece sua própria cópia e o kit de instalação (kit/setup.sh) descriptografa, traduz e compila tudo na sua máquina.

O APK para Android é compilado localmente a partir do seu próprio dump e instalado somente no seu próprio aparelho; ele nunca é distribuído. As bibliotecas do FFmpeg dentro do app continuam sob a LGPL-2.1 e podem ser copiadas, modificadas e substituídas.

Full technical history lives in the Claude project memory (ps3recomp-feasibility, levas 13-17) and in ps3recomp/docs/.

Estado por plataforma e desempenho (2026-10-02)

Resumo das sessões de 2026-09-30 a 2026-10-02. Cada número diz onde foi medido e com quantas corridas. Classes de evidência: in-boot no aparelho (jogo real no tablet ou no iPhone), Mac (jogo real num MacBook; não vale para o tablet), offline/unit (testes sem o jogo) e não exercitado. Os links apontam para o motor (andrebrumdev/ps3recomp, ramo spurs-bringup).

Estado atual por plataforma
PlataformaBackendProvadoNão provado / em aberto
Mac (Apple Silicon)Metalin-boot: boot → menu → gameplay de Rodes; 44–52 fps p50 no gameplay num M5 na tomada antes do merge (3 corridas por braço, medição)depois do merge de 2026-10-02 só houve 3 corridas com a máquina carregada (load 4,7–14): 26–42 fps, sem valor de comparação; o portão de ~45 fps com a máquina ociosa não foi refeito (merge)
iOS (iPhone 14)Metalin-boot em ramos anteriores: P2 de 2026-09-25 com p50 33 / p5 21 em 195 de 200 s de gameplay, 1 corrida, meta de p5 ≥ 25 não atingida (P2)o spurs-bringup depois do merge não foi compilado nem rodado no iPhone
Android (Galaxy Tab S9 FE, Mali-G68)Vulkanin-boot: gameplay com toque virtual; p50 12 / p5 11 no APK padrão depois do merge (1 corrida); cinemática de abertura a 29–30 fpsa thread do RSX com fragmentos (PS3_RSX_FRAG) dá 17/15, mas continua desligada por padrão (revisão independente pendente)
WindowsD3D12histórico de bring-up (paredes A–G no CLAUDE.md do motor)não compilado nem exercitado nesta leva; lá PS3_RSX_FIFO, PS3_VDEC_ASYNC, PS3_MOVIE_IO e PS3_SPU1 continuam opt-in; a correção do recomp_mid_v2/build_d3d.sh (rsx_frame_notes.c no link) está só no gow2-recomp
Desempenho medido — tablet (Galaxy Tab S9 FE)

In-boot, APK do feat/gow2-android, tablet no USB, PS3_MUTE=1, 100 s de gameplay por run_perf.sh --drive, salvo indicação. Ruído entre corridas de ~±1 fps, não caracterizado. Gargalo medido: a thread principal (PPU + walker do RSX inline) a ~87–91 % de um núcleo; a GPU fica ~9 % ocupada (GPU timing).

MudançaResultado (p50 / p5)nFonte
Baseline → parar de reler memória Vulkan mapeada write-combined (rsx_core_index_fetch, 529f5962)9 / 8 → 11 / 101 por pontoGPU timing
+ as outras leituras mapeadas por draw (c0762b29, 929f607a)12 / 111idem
Cache de pipeline persistente (551bc38e)pso_ms nos primeiros 60 s: 559 → 262 → 4 da 1.ª à 3.ª execução; fps 10/9 → 12/11 → 12/11 (a 1.ª execução é a mais lenta)1 série de 3idem
Thread dedicada do RSX (PS3_RSX_THREAD=1) sozinhamedianas 12 / 11 contra 12 / 11: sem ganho consistente; a Thread-2 cai ~15 pontos, a host:rsx gasta ~45 % de um núcleo e a PPU espera ~17 % de cada segundo no overflow3 paresthread RSX
Thread + fragmentos de 32 KB (PS3_RSX_FRAG=1, etapa 3)17 / 15 contra 13 / 11 (3 de 3 pares a favor; espera de overflow 156–207 → 0 ms/s); na ponta do merge, 17 / 15 em 1 corrida3 pares + 1FRAG
Interpretador SPU S0–S2CPU dos 6 workers SPURS −8 % (2368 → 2178 ms/s), interpretador −23 %, processo −5,4 %; fps igual (12 / 11); áudio sem regressão (3 pares com som)PRE 5, S2 3SPU S0–S2
Dedup de comandos do replay Vulkan (PS3_VK_REPLAY_DEDUP, ligado por padrão)ON 12/11 e 12/11, OFF 12/10 e 11/10: inconclusivo, compatível com um ganho pequeno2 paresGPU timing
Vídeo da cinemática de abertura29–30 fps estáveis com e sem som; os 5–6 fps de uma corrida anterior não se reproduziram (causa não identificada)2idem

Medido sem ganho no tablet (não repetir sem motivo novo): número de workers SPURS (2, 3 ou 6: 9–10 fps, 1 corrida cada); afinidade nos núcleos grandes (PS3_ANDROID_BIG_CORES 1/2: 9/7 e 9/8; o modo 3, PPU sozinha num núcleo, piora para 7/6); lift com -O2 (12/11, igual ao -O1, 2 corridas); desvirtualização das chamadas indiretas (ON 12/11 e 12/11, OFF 12/11 e 13/12, 2 pares, devirt); a terceira leva de otimizações da thread principal (12/11 antes e depois); o dedup de descritores/estado (acima, inconclusivo).

Desempenho medido — Mac (MacBook M5, não vale para o tablet)

Jogo real, na tomada, janela oculta, mudo, 3 corridas por braço alternadas, janela de 60 s de gameplay (medição).

MudançaResultadoLeitura
Interpretador SPU S0–S2 (Metal)fps p50 48 [47..52] contra 44 [43..46]; workers −7 %, interpretador −12 %; áudio igualganho medido no Mac; no tablet o mesmo código não muda o fps
Thread do RSX (Vulkan via MoltenVK)58 [56..59] contra 46 [46..47]o backend de produção do Mac é o Metal, e a thread recusa o Metal: não vale para o Mac distribuído
PS3_RSX_DRAIN=1 PS3_GCM_FIFO_NOLOCK=1 (Metal)48 contra 48sem ganho; fica desligado
Desvirtualização das chamadas indiretas−13 % de CPU por quadro (64,0 → 58,1 ms), 44 → 47 fpsmedido no Mac; no tablet, sem ganho (devirt)

A "regressão" de 10 fps no Mac de 2026-10-01 não era código: um binário de antes das promoções de ambiente rodou sem as 9 variáveis que ele ainda precisava (abaixo); o mesmo binário faz 48 fps com elas (bisect).

Experimentos e variáveis de ambiente

Conferidas no código do spurs-bringup. Sondas e experimentos ficam desligados por padrão.

VariávelPadrãoO que fazEstado
PS3_RSX_THREAD=1desligadawalker do FIFO do RSX numa thread própria (host:rsx)experimental; só com backend Vulkan (recusada no Metal, inexistente no Windows)
PS3_RSX_FRAG=1desligadacontexto padrão em fragmentos de 32 KB como a libgcm (etapa 3); só vale com PS3_RSX_THREAD=1experimental; o maior ganho medido no tablet; revisão independente pendente
PS3_TRACE_RSXT=1desligadasonda [RSXT]: tempos de walk/parse/draw, esperas, kickssonda
PS3_TRACE_SPU_INTERP=1desligadasonda [SPUISTAT] do interpretador SPUsonda; troca o laço rápido pelo instrumentado (spui_run_instr, ~56 ms/s mais caro no tablet): não mede o laço de produção
PS3_SPU_INTERP=0ligado (1)volta a imagem 7 (mixer SCREAM) ao spu6 liftadoA/B
PS3_TRACE_VDEC_PIPE=1desligadasonda [VDECPIPE], uma linha por segundo com filme tocandosonda
PS3_VK_GPU_TIMING=1desligadatempo de GPU por passe ([GPUTIME])sonda
PS3_VK_PCACHE=0ligado=0 desliga o cache de pipeline em disco (precisa do diretório de cache)padrão ligado, provado no Mali-G68
PS3_VK_REPLAY_DEDUP=0ligado=0 desliga o dedup de comandos repetidos do replay Vulkanpadrão ligado (ganho inconclusivo)
PS3_VK_REPLAY_STATS=1desligadacontad