A work-in-progress matching decompilation of Ratchet: Deadlocked (Ratchet: Gladiator in PAL regions; Insomniac Games, 2005) for the PlayStation 2, part of the OpenRAC initiative.
The objective is to produce C/C++ source code that, when compiled with the original toolchain, generates a byte-identical copy of the retail programs: the main program, the front end and the 47 level programs, each read straight from the disc. The primary target is the NTSC-U disc (SCUS_974.65), which the existing C was matched against; the PAL disc, Ratchet: Gladiator (SCES_532.85), is the second version, built and counted the same way, and the same C counts there wherever it builds to the PAL bytes too. Matched code is then refactored toward readable, idiomatic C++ with accurate types and naming, using matching builds as continuous regression tests.
Note
This repository contains no game assets, retail executables, or disassembly. To build, you must provide your own legally obtained copy of the game. Please review LEGAL.md before contributing.
Progress is published on ByteMatch for both versions (US by default) and on openrac.dev.
| Version | Region | Target ID | Code Matched | Functions Matched |
|---|---|---|---|---|
| v1.00 (primary) | NTSC-U | SCUS_974.65 |
||
| PAL | Europe (Ratchet: Gladiator) | SCES_532.85 |
A function counts as matched on a version when its C, built with its file's own flags, gives that disc's bytes of the function with only the fields its object relocates masked (tools/match_map.py, config/<version>/map.tsv); the fuzzy figure adds what the near misses in nonmatching/ get right. There is no C in the programs' build yet: every program builds byte-identical from its assembly (docs/levels.md), and tools/audit_matches.py checks every function of src/ against the US bytes.
The counts
NTSC-U (SCUS_974.65)
| Functions (exact) | Code (exact) | Fuzzy | |
|---|---|---|---|
| Main program | 2,131 of 8,948 | 158,076 of 2,193,280 bytes (7.21%) | 7.39% |
| Engine core (core.text) | 706 of 1,695 | 67,092 of 298,900 bytes (22.45%) | 22.71% |
| libgcc | 2 of 2 | 16 of 16 bytes (100.00%) | 100.00% |
| Network (net.text) | 376 of 2,441 | 11,132 of 465,620 bytes (2.39%) | 2.56% |
| Resident menus (.text) | 1,044 of 4,785 | 79,032 of 1,416,576 bytes (5.58%) | 5.75% |
| frontbin's own code | 3 of 25 | 804 of 12,168 bytes (6.61%) | 6.61% |
| Shared level code | 1,082 of 5,076 | 83,504 of 1,980,204 bytes (4.22%) | 4.90% |
| Level-specific code | 609 of 4,061 | 63,396 of 1,608,940 bytes (3.94%) | 4.61% |
| Level 00: Multiplayer Menu | 447 of 2,798 | 45,056 of 943,140 bytes (4.78%) | 5.64% |
| Level 01: Dreadzone Station (and 21) | 35 of 356 | 3,444 of 188,848 bytes (1.82%) | 1.82% |
| Level 02: Catacrom Graveyard (and 22) | 2 of 35 | 124 of 26,596 bytes (0.47%) | 0.47% |
| Level 04: Sarathos Swamp (and 24) | 2 of 19 | 196 of 11,708 bytes (1.67%) | 1.67% |
| Level 05: Dark Cathedral (and 25) | 3 of 102 | 288 of 59,824 bytes (0.48%) | 0.64% |
| Level 06: Temple Of Shaar (and 26) | 3 of 31 | 168 of 9,360 bytes (1.79%) | 1.79% |
| Level 07: Valix Lighthouse (and 27) | 4 of 46 | 464 of 28,304 bytes (1.64%) | 1.64% |
| Level 08: Mining Facility (and 28) | 4 of 48 | 180 of 24,400 bytes (0.74%) | 0.74% |
| Level 10: Torval Ruins (and 30) | 3 of 37 | 256 of 20,140 bytes (1.27%) | 1.27% |
| Level 11: Tempus Station (and 31) | 2 of 17 | 104 of 8,804 bytes (1.18%) | 1.18% |
| Level 13: Maraxus Prison (and 33) | 4 of 34 | 444 of 16,916 bytes (2.62%) | 2.62% |
| Level 14: Ghost Station (and 34) | 6 of 29 | 444 of 14,548 bytes (3.05%) | 3.05% |
| Level 15: Control Level (and 35) | 13 of 135 | 932 of 116,368 bytes (0.80%) | 0.80% |
| Level 41: Battledome Tower (all 22 multiplayer maps) | 81 of 374 | 11,296 of 139,984 bytes (8.07%) | 9.93% |
| Total | 3,822 of 18,085 | 304,976 of 5,782,424 bytes (5.27%) | 5.76% |
Each distinct function counts once: frontbin's copy of the menus is the main image's, and a level function counts once however many of the 47 levels have it. 158,076 bytes (2.73%) are in units with nothing left to decompile.
PAL (SCES_532.85)
| Functions (exact) | Code (exact) | Fuzzy | |
|---|---|---|---|
| Main program | 2,135 of 8,945 | 159,896 of 2,202,512 bytes (7.26%) | 7.43% |
| Engine core (core.text) | 706 of 1,699 | 67,072 of 299,052 bytes (22.43%) | 22.70% |
| libgcc | 2 of 2 | 16 of 16 bytes (100.00%) | 100.00% |
| Network (net.text) | 376 of 2,441 | 11,132 of 465,620 bytes (2.39%) | 2.56% |
| Resident menus (.text) | 1,051 of 4,786 | 81,676 of 1,422,048 bytes (5.74%) | 5.90% |
| frontbin's own code | 0 of 17 | 0 of 15,776 bytes (0.00%) | 0.00% |
| Shared level code | 1,091 of 5,088 | 87,076 of 2,008,520 bytes (4.34%) | 5.00% |
| Level-specific code | 616 of 4,080 | 64,028 of 1,601,892 bytes (4.00%) | 4.56% |
| Level 00: Multiplayer Menu | 451 of 2,826 | 45,324 of 943,820 bytes (4.80%) | 5.48% |
| Level 01: Dreadzone Station (and 21) | 36 of 357 | 3,604 of 189,772 bytes (1.90%) | 1.90% |
| Level 02: Catacrom Graveyard (and 22) | 2 of 29 | 124 of 21,232 bytes (0.58%) | 0.58% |
| Level 04: Sarathos Swamp (and 24) | 2 of 19 | 196 of 11,868 bytes (1.65%) | 1.65% |
| Level 05: Dark Cathedral (and 25) | 3 of 106 | 288 of 61,960 bytes (0.46%) | 0.62% |
| Level 06: Temple Of Shaar (and 26) | 3 of 31 | 168 of 9,440 bytes (1.78%) | 1.78% |
| Level 07: Valix Lighthouse (and 27) | 4 of 44 | 464 of 27,640 bytes (1.68%) | 1.68% |
| Level 08: Mining Facility (and 28) | 4 of 48 | 180 of 24,900 bytes (0.72%) | 0.72% |
| Level 10: Torval Ruins (and 30) | 4 of 38 | 396 of 20,392 bytes (1.94%) | 1.94% |
| Level 11: Tempus Station (and 31) | 2 of 17 | 104 of 9,024 bytes (1.15%) | 1.15% |
| Level 13: Maraxus Prison (and 33) | 5 of 34 | 508 of 15,996 bytes (3.18%) | 3.18% |
| Level 14: Ghost Station (and 34) | 6 of 23 | 444 of 8,884 bytes (5.00%) | 5.00% |
| Level 15: Control Level (and 35) | 13 of 134 | 932 of 116,624 bytes (0.80%) | 0.80% |
| Level 41: Battledome Tower (all 22 multiplayer maps) | 81 of 374 | 11,296 of 140,340 bytes (8.05%) | 9.91% |
| Total | 3,842 of 18,113 | 311,000 of 5,812,924 bytes (5.35%) | 5.80% |
Each distinct function counts once: frontbin's copy of the menus is the main image's, and a level function counts once however many of the 47 levels have it. 159,896 bytes (2.75%) are in units with nothing left to decompile.
Each level carries its own program: its code, data and dispatch tables, loaded over the main image's menus when the level starts. Each disc has 47 of them but only 14 distinct programs: the 12 split-screen campaign levels are byte-identical copies of their single-player levels, and all 22 multiplayer maps run one program (level 41's). Their functions are counted once each: under Shared level code when two or more distinct programs have them, else in their level's own row; a function the resident menus have too is counted there (docs/levels.md).
Per level
- Linux & macOS: Docker or Podman (uses the prebuilt Wine container via GitHub Container Registry), and Python 3.10+.
- Windows: Git Bash, Python 3.10+, and community toolchain mirrors.
The compilers run natively (no Wine or container needed). The venv's interpreter is
venv/Scripts/python.exe: use it wherever these docs sayvenv/bin/python.
-
Clone the repository:
git clone https://github.com/OpenRAC/rac-deadlocked-decomp.git cd rac-deadlocked-decomp -
Provide your original executable: Copy
SCUS_974.65from your disc image intobaserom/:# Expected SHA-1: aa91b1c3b9b1a244320c47580b77342ef9856e95 cp /path/to/SCUS_974.65 baserom/SCUS_974.65 -
Generate the disassembly and fetch toolchains:
bash tools/setup_asm.sh # unpack, split, splat -> asm/ git clone https://github.com/AngheloAlf/SN-Systems-ProDG_for_PS2_3.01 toolchain/sn-prodg-3.01 git clone https://github.com/AngheloAlf/sce_ps2_sdk_24 toolchain/sn-prodg-24 -
Build and verify:
# Windows (native): bash tools/build.sh # Linux & macOS (via container): bash tools/docker/run.sh bash tools/build.sh # Then compare every function with retail: venv/bin/python tools/audit_matches.py # and write the progress reports (needs the dumps, see below): python3 tools/match_map.py --write && python3 tools/progress.py --write
Each disc's programs are read from your own baserom/SCUS_974.65.iso (or baserom/SCES_532.85.iso
with --version pal; the SHA-1s are in config/<version>/programs.tsv and levels.tsv), built
from their assembly, and counted (docs/levels.md):
python3 tools/levels.py dump # baserom/us/ (add --version pal for baserom/pal/)
python3 tools/build_levels.py --asm -P 16 # 49 targets, one MATCH each (ee-as/ee-ld; Linux, or the container)
JOBS=16 bash tools/docker/run.sh bash tools/build.sh # then build_libgcc.sh, build_libm.sh
python3 tools/match_map.py --write # where src/ matches (and --version pal)
python3 tools/progress.py --write # progress/report.json and its table (and --version pal)
python3 tools/check_func.py func_L01_XXXXXXXX try.c # one function against its US bytes (--version pal: PAL)For detailed documentation:
docs/WORKFLOW.md– Setup in full, and the step-by-step function matching guidedocs/TOOLCHAIN.md– Compiler, flags, assembler passes, libraries and the containerdocs/RESEARCH.md– How the retail executable is packed and taken apartdocs/levels.md– Both discs' programs, their build, how the functions are counted, and the old against the new totalsdocs/OVERLAYS.md– The 47 US level overlays the existing C was matched against
Contributions are warmly welcome! Whether you are interested in decompiling functions, researching engine quirks, or improving documentation:
- See
CONTRIBUTING.mdfor contribution guidelines and rules. - See
docs/WORKFLOW.mdfor the step-by-step function matching guide. - Join our Discord Community to discuss progress, ask questions, and collaborate!
This project builds upon years of dedicated reverse-engineering research and tooling by the community:
- GFI (Game Fuckery Inc.) – Special thanks to the GFI Discord community for years of reverse engineering, game research, and technical insights that made this decompilation possible.
- rac1-decomp – Repository layout, README, progress workflow and report generator, toolchain notes, the libgcc build recipe, and
tools/ps2eeas_nops.py/tools/ps2eeas_dli.py(the nops and constant sequences of SN's assembler). - rac3-uya-decomp-pal – The PAL treatment this repository follows: reading the levels from the disc, the function inventory (rac1-decomp's rules), the catalogue and the report (
tools/inventory.py,tools/level_catalogue.py,tools/progress.pyare adapted from it). - rac3-uya-decomp by vetusmagnus – Up Your Arsenal, the closest engine relative. Compiler research (SN ee-gcc 2.95.3 v1.36) and the
-fopt-stack,-G8and global-declaration findings. - OpenRAC – Status of Deadlocked, sourcing policy, and the sibling decompilations of the engine family.
- Lombyte by mateuszklysz – R&C1 NTSC decomp, checked for Deadlocked coverage (none).
- Wrench by chaoticgd – PS2 Ratchet & Clank modding tools; its documentation of the packed image (
docs/file_loading.md, "WAD Compression") and the executable's layout, and the level overlays it unpacks. - GCC and newlib – The library sources in
src/libgcc/andsrc/libm/(seeTHIRD_PARTY_NOTICES.md). - Decompilation Tooling & Ecosystem:
- splat & spimdisasm – Binary splitting and MIPS disassembly.
- m2c & asm-differ – Assembly-to-C translation and diffing.
- objdiff – Object diffing tool.
- ByteMatch, decomp.dev & decomp.wiki – Progress tracking and decompilation knowledge base.
- AngheloAlf – PS2 toolchain mirrors.
- Code written for this project is licensed under the GNU General Public License v3.0.
- Reconstructed libraries and third-party components retain their original licenses (see
THIRD_PARTY_NOTICES.mdandLEGAL.md). - Ratchet: Deadlocked is a registered trademark of Sony Interactive Entertainment. This project is not affiliated with or endorsed by Sony or Insomniac Games.