sly1/README.md

233 lines
9.6 KiB
Markdown
Raw Normal View History

2021-11-20 01:09:49 +00:00
# Sly Cooper and the Thievius Raccoonus
2022-04-25 23:05:07 +00:00
2024-07-02 15:58:18 +00:00
<!-- Build status shield -->
[build-url]:https://github.com/TheOnlyZac/sly1/actions/workflows/build.yml
[build-badge]: https://img.shields.io/github/actions/workflow/status/theonlyzac/sly1/build.yml?branch=main&label=build
2022-04-25 23:05:07 +00:00
2024-11-07 02:43:52 +00:00
[code-progress-badge]: https://img.shields.io/endpoint?label=progress&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fslycooper1%2Fus%2Fall%2F%3Fmode%3Dshield%26measure%3DP2
2024-11-07 02:43:52 +00:00
<!--[data-progress-badge]: https://img.shields.io/endpoint?label=data&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fslycooper1%2Fus%2Fall%2F%3Fmode%3Dshield%26measure%3Ddata-->
2024-07-02 15:58:18 +00:00
<!-- Contributors shield -->
2022-04-24 23:49:40 +00:00
[contributors-url]: https://github.com/theonlyzac/sly1/graphs/contributors
2023-12-01 09:27:35 +00:00
[contributors-badge]: https://img.shields.io/github/contributors/theonlyzac/sly1?color=%23db6d28
2021-11-20 01:09:49 +00:00
2024-07-02 15:58:18 +00:00
<!-- Discord shield -->
2022-07-01 21:21:20 +00:00
[discord-url]: https://discord.gg/2GSXcEzPJA
2023-12-01 09:27:35 +00:00
[discord-badge]: https://img.shields.io/discord/439454661100175380?color=%235865F2&logo=discord&logoColor=%23FFFFFF
2024-07-02 15:58:18 +00:00
<!-- Docs shield -->
2023-12-01 09:27:35 +00:00
[docs-url]: https://theonlyzac.github.io/sly1
2024-11-07 02:43:52 +00:00
[docs-badge]: https://img.shields.io/badge/docs-github.io-2C4AA8
2022-04-24 23:49:40 +00:00
2024-07-02 15:58:18 +00:00
<!-- Wiki shield -->
[wiki-url]: https://slymods.info
2023-12-01 09:27:35 +00:00
[wiki-badge]: https://img.shields.io/badge/wiki-slymods.info-2C4AA8
2022-04-25 22:43:23 +00:00
2024-07-02 15:58:18 +00:00
<!-- Shields -->
2024-11-07 02:43:52 +00:00
[![Build][build-badge]][build-url] ![code-progress-badge] <!--![data-progress-badge]--> [![Contributors][contributors-badge]][contributors-url] [![Discord Channel][discord-badge]][discord-url] [![Docs][docs-badge]][docs-url] [![Wiki][wiki-badge]][wiki-url]
2024-07-02 15:58:18 +00:00
2024-11-25 01:04:54 +00:00
[<img src=".github/logo.png" style="margin:7px" align="right" width="33%" alt="Sly 1 Decompilation Logo by Cooper941">][docs-url]
2023-12-01 10:08:45 +00:00
2024-06-28 09:04:15 +00:00
This is a work-in-progress decompilation of [*Sly Cooper and the Thievius Raccoonus*](https://en.wikipedia.org/wiki/Sly_Cooper_and_the_Thievius_Raccoonus) for the PlayStation 2. It builds the NTSC-U version of the game, `SCUS_971.98` (SHA1: `57dc305d`).
2023-11-27 01:23:14 +00:00
2024-11-24 23:55:36 +00:00
The goal of this project is to better understand the game engine. This repo does not contain any game assets or original code from the game's executable; It requires your own copy of the game to build and run.
2023-12-01 10:01:16 +00:00
2023-12-05 02:01:14 +00:00
Documentation of the code can be found at [theonlyzac.github.io/sly1](https://theonlyzac.github.io/sly1). For further reading on the game's internal structures and mechanics, visit the [SlyMods Wiki][wiki-url].
2022-04-25 22:43:23 +00:00
2023-12-17 03:29:05 +00:00
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](/docs/CONTRIBUTING.md) and feel free to [join our Discord server][discord-url] for guidance.
2023-11-27 01:23:14 +00:00
2024-07-14 20:34:18 +00:00
## Quickstart
2024-04-29 19:26:58 +00:00
2024-11-24 23:55:36 +00:00
You can quickly setup the project on Linux (or WSL) using the quickstart script. Follow these three steps get started.
2024-10-20 21:03:43 +00:00
2024-11-24 23:55:36 +00:00
### 1. Clone the repo and run quickstart.sh.
Copy and run the following command. It may ask for your password to install dependencies.
2024-10-20 21:03:43 +00:00
2024-07-14 20:34:18 +00:00
```bash
git clone https://github.com/theonlyzac/sly1 && \
cd sly1 && \
2024-11-24 23:55:36 +00:00
./scripts/quickstart.sh
2024-07-14 20:34:18 +00:00
```
2024-11-24 23:55:36 +00:00
### 2. Extract the executable from your disc.
2024-10-20 21:03:43 +00:00
2024-11-24 23:55:36 +00:00
Copy the file `SCUS_971.98` from your Sly 1 game disc to the `disc` directory of the project. It is needed to build.
2024-10-20 21:03:43 +00:00
2024-11-24 23:55:36 +00:00
### 3. Build the project.
2024-10-20 21:03:43 +00:00
```bash
2024-07-14 20:34:18 +00:00
./scripts/build.sh
```
If it works, you will see this:
```
2024-11-25 01:04:54 +00:00
[XXX/XXX] sha1sum config/checksum.sha1
2024-07-14 20:34:18 +00:00
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
2024-10-20 21:03:43 +00:00
The project can be built on Linux (or Windows using WSL). Follow the instructions below to set up the build environment.
2024-08-03 04:25:56 +00:00
2024-10-20 21:03:43 +00:00
### Clone the repository
2024-06-24 22:25:45 +00:00
2024-10-20 21:03:43 +00:00
Clone the repo to your local machine:
```bash
git clone https://github.com/TheOnlyZac/sly1
cd sly1
2024-06-28 03:38:43 +00:00
```
2024-10-20 21:03:43 +00:00
### Extract your original ELF file
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.
2024-08-03 04:25:56 +00:00
### Install python packages
2024-06-28 03:38:43 +00:00
2024-08-03 04:25:56 +00:00
You will need Python 3.8 or higher.
2024-06-28 03:38:43 +00:00
```bash
pip install -U -r requirements.txt
```
2024-06-28 03:38:43 +00:00
### Setup build environment
2024-07-04 03:03:58 +00:00
<!--#### Linux/WSL-->
2023-12-05 02:01:14 +00:00
2024-07-04 03:03:58 +00:00
1. Setup wine:
2024-07-02 15:58:18 +00:00
```bash
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install wine32
```
2024-07-04 03:03:58 +00:00
2. Install MIPS assembler:
2024-07-02 16:02:02 +00:00
```bash
2024-07-04 03:03:58 +00:00
sudo apt-get install binutils-mips-linux-gnu
2024-07-02 16:02:02 +00:00
```
2024-07-14 19:35:14 +00:00
3. Setup compiler:
```bash
2024-04-29 19:26:58 +00:00
cd scripts
2023-12-05 02:01:14 +00:00
./setup-progd-linux.sh
```
2021-11-22 17:19:33 +00:00
2024-07-04 03:03:58 +00:00
<!--#### Windows
2023-11-27 01:23:14 +00:00
2024-07-04 03:03:58 +00:00
*Prerequisites: [Chocolatey](https://chocolatey.org/install)*
2023-11-27 01:23:14 +00:00
2024-07-04 03:03:58 +00:00
1. Install 7zip:
2024-07-02 16:02:02 +00:00
```powershell
2024-07-04 03:03:58 +00:00
choco install 7zip
2024-07-02 16:02:02 +00:00
```
2024-06-28 03:38:43 +00:00
2024-07-04 03:03:58 +00:00
2. Setup build environment:
2023-12-05 02:01:14 +00:00
```powershell
.\scripts\setup-progd-windows.bat
2024-07-04 03:03:58 +00:00
```-->
2024-06-24 22:25:45 +00:00
2024-07-14 20:34:18 +00:00
### Build the project
2024-08-03 04:25:56 +00:00
The project builds the executable `SCUS_971.98`.
2024-06-24 22:51:55 +00:00
```bash
2024-06-28 03:38:43 +00:00
python configure.py
2024-07-04 03:03:58 +00:00
ninja
2024-06-24 22:51:55 +00:00
```
2024-10-20 21:03:43 +00:00
If you update any config files or add any source files, you will need run a clean reconfigure:
2024-06-24 22:25:45 +00:00
```bash
2024-07-04 03:03:58 +00:00
python configure.py --clean
```
2024-07-14 20:34:18 +00:00
To only clean without reconfiguring (i.e. delete build files) use:
2024-07-04 03:03:58 +00:00
```bash
python configure.py --only-clean
2023-12-05 02:01:14 +00:00
```
2023-11-27 01:23:14 +00:00
2023-12-07 18:50:05 +00:00
## Running
2024-07-14 20:34:18 +00:00
Running the executable requires [PCSX2 2.0](https://pcsx2.net/). 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.
2023-12-07 18:50:05 +00:00
2024-08-03 04:25:56 +00:00
Once you have those and you have built the executable, you can run it in one of three ways:
2023-12-17 03:29:05 +00:00
2024-06-24 22:25:45 +00:00
### 1. Autorun script
2023-12-07 18:50:05 +00:00
2023-12-07 19:04:06 +00:00
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.
2023-12-07 18:50:05 +00:00
2024-06-24 22:25:45 +00:00
### 2. Run from command line
2023-12-07 18:50:05 +00:00
2024-04-29 19:26:58 +00:00
To boot the elf in PCSX2 from the command line, use the following command:
2023-12-07 18:50:05 +00:00
2023-12-07 19:04:06 +00:00
```bash
2024-10-20 21:03:43 +00:00
pcsx2.exe -elf ".../sly1/bin/debug/SCUS_971.98" "/path/to/game/backup.iso"
2023-12-07 18:50:05 +00:00
```
2024-10-20 21:03:43 +00:00
Replace `pcsx2.exe` with the path to your PCSX2 v2.0 executable (for Linux it will be an **.appimage** file).
2024-04-29 19:26:58 +00:00
- 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.
2023-12-07 18:50:05 +00:00
2024-06-24 22:25:45 +00:00
### 3. Run from PCSX2 GUI
2023-12-07 18:50:05 +00:00
2024-06-28 07:51:43 +00:00
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.
2023-12-01 09:27:35 +00:00
2023-12-05 02:01:14 +00:00
## Project Structure
2023-12-01 10:01:16 +00:00
2024-04-29 19:26:58 +00:00
The project is divided into the following directories:
2023-12-01 10:01:16 +00:00
2023-12-17 04:01:12 +00:00
* `include` - Header files for the game engine.
2024-04-29 19:26:58 +00:00
* `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`.
2024-06-28 07:51:43 +00:00
* `config` - Config files for Splat (binary splitting tool).
* `scripts` - Utility scripts for setting up the build environment.
* `docs` - Documentation and instructions for contributing.
2024-04-29 19:26:58 +00:00
* `tools` - Utilities for function matching.
2024-06-28 09:04:15 +00:00
* `reference` - Reference files for functions and data structures.
2023-12-17 04:01:12 +00:00
When you build the executable, the following directories will be created:
2023-12-01 10:01:16 +00:00
2024-06-28 03:38:43 +00:00
* `asm` - Disassembled assembly code from the elf.
2024-06-28 07:51:43 +00:00
* `assets`- Binary data extracted from the elf.
2024-06-28 03:38:43 +00:00
* `obj` - Compiled object files.
* `out` - Compiled executables.
2023-12-17 04:01:12 +00:00
2023-12-01 09:27:35 +00:00
## FAQ
#### What is a decompilation?
2024-07-02 15:58:18 +00:00
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.
2023-12-01 09:27:35 +00:00
#### How does it work?
2024-07-02 15:58:18 +00:00
We use a tool called [Splat](https://github.com/ethteck/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.
2023-12-01 09:27:35 +00:00
#### Has this ever been done before?
2024-07-14 20:34:18 +00:00
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](https://github.com/n64decomp/sm64) for the N64 and the [Breath of the Wild decomp](https://github.com/zeldaret/botw) 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](https://github.com/open-goal/jak-project), though that game is 98% GOAL language rather than C/C++.
2023-12-01 09:27:35 +00:00
#### Is this a matching decomp?
2024-07-14 20:34:18 +00:00
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.
2023-12-01 09:27:35 +00:00
#### How can I help?
2024-07-02 15:58:18 +00:00
If you want to contribute, check out [CONTRIBUTING.md](/docs/CONTRIBUTING.md) and feel free to [join our discord server](https://discord.gg/gh5xwfj) if you have any questions!
2023-12-01 09:27:35 +00:00
2023-12-01 10:01:16 +00:00
## Star History
2023-12-01 09:27:35 +00:00
<a href="https://star-history.com/#theonlyzac/sly1&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=theonlyzac/sly1&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=theonlyzac/sly1&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=theonlyzac/sly1&type=Date" />
</picture>
2023-12-01 10:01:16 +00:00
</a>