Decompilation of Sly Cooper and the Thievius Raccoonus for the PS2
Go to file
2024-07-24 01:14:01 -04:00
.github/workflows Update workflows 2024-07-14 03:00:34 +00:00
config Miscellaneous 2024-07-24 01:14:01 -04:00
disc Cleanup and update documentation 2024-06-28 13:12:12 -04:00
docs Update contributing guide 2024-07-10 18:52:19 +00:00
include Miscellaneous 2024-07-24 01:14:01 -04:00
reference Misc project cleanup 2024-07-14 19:27:24 +00:00
scripts Update setup script 2024-07-14 19:35:14 +00:00
src/P2 Merge pull request #92 from LordBozo/Bozo-working 2024-07-21 23:11:44 -04:00
tools/codematcher Splat configuration & necessary includes 2024-04-26 10:50:10 -06:00
.gitattributes Add .gitignore and .gitattributes. 2021-11-08 19:59:05 -05:00
.gitignore Add missing files 2024-07-05 06:21:09 +00:00
checksum.sha1 Add checksum 2024-06-28 01:53:45 -05:00
configure.py Util Function Match 2024-07-21 22:39:51 -04:00
logo.png Update readme and add logo 2023-12-01 04:27:35 -05:00
README.md Update readme 2024-07-14 20:34:18 +00:00
requirements.txt Add frogress upload script and workflow 2024-07-14 02:00:34 +00:00

Sly Cooper and the Thievius Raccoonus

Build code-progress-badge data-progress-badge Contributors Discord Channel Docs Wiki

Sly 1 Decompilation Logo by Cooper941

This is a work-in-progress decompilation of Sly Cooper and the Thievius Raccoonus for the PlayStation 2. It builds the NTSC-U version of the game, SCUS_971.98 (SHA1: 57dc305d).

The goal of this project is to better understand the game engine. This repo does not contain any game assets or code from the game's executable; It requires your own copy of the game to build and run.

Documentation of the code can be found at theonlyzac.github.io/sly1. For further reading on the game's internal structures and mechanics, visit the SlyMods Wiki.

New contributors are welcome and encouraged to make a pull request! If you would like to help but aren't sure where to start, check out CONTRIBUTING.md and feel free to join our Discord server for guidance.

Quickstart

git clone https://github.com/theonlyzac/sly1 && \
cd sly1 && \
pip install -U -r requirements.txt && \
sudo ./scripts/setup_build_environment.sh

Copy the SCUS_971.98 file from your game disc to the disc directory of the project. Then build with:

./scripts/build.sh

If it works, you will see this:

[XXX/XXX] sha1sum checksum.sha1
out/SCUS_971.98: OK

If you have any issues, or you prefer to set up the project manually, follow the instructions below. Instructions to run the game are also provided below.

Manual Setup

Clone the repo

Clone the repository to your local machine:

git clone https://github.com/TheOnlyZac/sly1
cd sly1

Install Python packages

Splat is used for binary splitting, and Ninja is used for building the project. You will need Python 3. Install dependencies with pip:

pip install -U -r requirements.txt

Setup build environment

The project can be built on Windows (using WSL) or Linux. Follow the instructions below to set up the build environment.

  1. Setup wine:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install wine32
  1. Install MIPS assembler:
sudo apt-get install binutils-mips-linux-gnu
  1. Setup compiler:
cd scripts
./setup-progd-linux.sh

Setup binary splitting

To build the project you will need to extract the original ELF file from your own legally obtained copy of the game. Mount the disc on your PC and copy the file SCUS_971.98 from your disc to the disc directory of this project.

Build the project

The project can be built on Linux (or Windows using WSL). It builds the executable SCUS_971.98.

python configure.py
ninja

If you update the config files, you will need run a clean reconfigure:

python configure.py --clean

To only clean without reconfiguring (i.e. delete build files) use:

python configure.py --only-clean

Running

Running the executable requires PCSX2 2.0. You must have your own copy of the original game and the BIOS from your own PS2. They are not included in this repo and we cannot provide them for you.

Once you have those and you have built the executable, you can run it in one of these three ways:

1. Autorun script

The run.sh script in the scripts dir will automatically rebuild the executable and run it in the PCSX2 emulator. To use it, you must first edit the script to set the PCSX2_PATH and ISO_PATH variables to the correct paths on your system.

2. Run from command line

To boot the elf in PCSX2 from the command line, use the following command:

pcsx2-1.7.exe -elf ".../sly1/bin/debug/SCUS_971.98" "/path/to/game/backup.iso"

Replace pcsx2-1.7.exe with the path to your PCSX2 v1.7 executable (for Linux it will be an .appimage file).

  • The -elf parameter specifies the path to the SCUS_971.98 you built from this project. Replace ... with the path to this repository. The emulator will use this ELF to boot the game.
  • The last argument is the path to your game ISO. Replace /path/to/game/backup.iso with the path to a backup of your own game disc. This is where the game will load the assets from.

3. Run from PCSX2 GUI

Copy SCUS_971.98 from the out dir to your PCSX2 Games folder and rename it to SCUS_971.98.elf. Right click on the game in PCSX2 and click "Properties...". Go to "Disc Path", click "Browse", and select the ISO of your game backup. Then click "Close" and start the game as normal.

Project Structure

The project is divided into the following directories:

  • include - Header files for the game engine.
  • src - The decompiled source code.
    • All of the code for the game engine is in src/P2.
    • Code for the game's scripting engine is in src/P2/splice.
  • config - Config files for Splat (binary splitting tool).
  • scripts - Utility scripts for setting up the build environment.
  • docs - Documentation and instructions for contributing.
  • tools - Utilities for function matching.
  • reference - Reference files for functions and data structures.

When you build the executable, the following directories will be created:

  • asm - Disassembled assembly code from the elf.
  • assets- Binary data extracted from the elf.
  • obj - Compiled object files.
  • out - Compiled executables.

FAQ

What is a decompilation?

When the developers created the game, they wrote source code and compiled it to assembly code that can run on the PS2. A decompilation involves reverse-engineering the assembly code to produce new, original code that compiles to matching assembly. This process leaves us with source code that is similar to and behaves the same as the source code (though not necessarily identical), which helps us understand what the programmers were thinking when they made the game.

How does it work?

We use a tool called Splat to split the binary into assembly files representing each individual function. We then reimplement every function and data structure by writing C++ code that compiles to the same assembly code. We do not include any data or code from the original game binary in the decompilation.

Has this ever been done before?

This was one the first PS2 decompilations; Several others have been started since we began in 2020. Our main inspiration was other projects such as the Super Mario 64 decomp for the N64 and the Breath of the Wild decomp for the Wii U (the latter being more similar in scope to this project). There is also a Jak & Daxter decomp/PC port called OpenGOAL, though that game is 98% GOAL language rather than C/C++.

Is this a matching decomp?

Yes. This was the first PS2 decompilation project that targeted the PS2 and utilized function matching, before it was even possible to produce a byte-matching executable. We have built a matching elf since July 2024. The ultimate goal is to match 100% of the game's functions.

How can I help?

If you want to contribute, check out CONTRIBUTING.md and feel free to join our discord server if you have any questions!

Star History

Star History Chart