You've come to the right place! We welcome new contributors of all skill levels. Even if you've never tried game hacking, modding, or reverse-engineering, we have a dedicated community of modders and reverse-engineers to help you get started. Feel feel to join our Discord server and ask for help in #sly-research.
This guide will help you start contributing to the project. This is a 100% volunteer-driven project, all contributions are greatly appreciated. The current goal is to decompile and match as many game functions as possible, while imitating the style and structure of the original code to understand the inner workings of the game engine.
By following this guide, you will learn how to fork the repo on GitHub, choose a function to reverse-engineer, write code to match it, and integrate that code into the project. Once you've done that, and your pull request is merged, you will get the Decomp Contributor role in the Discord Server.
- Getting Started
- Find a function to match
- Match the function using Decomp.me
- Integrate the matched code
- Make a Pull Request
- Conclusion
If you haven't used Git before, follow the Beginner's Guide to learn how to fork the repo, make changes, and submit a pull request when you're done. If you're already familiar with Git, continue on with this guide.
First, follow the instructions in the README to build the project. If you see the following in the terminal, you're ready to start contributing:
[XXX/XXX] sha1sum config/checksum.sha1
out/SCUS_971.98: OK
The goal of this project is to match the original code closely enough that it compiles to a byte-matching executable. This means writing functions that compiles to the same assembly as the original functions. You will know it matches if you build the project and it says SCUS_971.98: OK
with no errors.
First, find a function in the game that you want to match. There are a few ways to do this:
- Browse Ghidra for interesting functions.
- Look through the
src
directory to find functions in.c
files that haven't been matched yet.- Functions that haven't been matched will have an
INCLUDE_ASM
macro as as placeholder.
- Functions that haven't been matched will have an
- Look through the
asm/nonmatchings
folder. - Ask for suggestions on Discord.
Once you have chosen a function, you can use the website decomp.me to match it.
- Go the website and click "Start decomping".
- Click "PS2", then under "Preset", select "Sly Cooper and the Thievius Raccoonus".
- Under "Diff label", enter the name of the function.
- Find the
.s
file corresponding to the function you want to match in theasm/nonmatchings
directory. Copy the contents of the file into the "Target assembly" box. - Copy any functions, global variables, or data types used by the function from the headers in the
include
directory into the "Context" box.- E.g. For the function
void ResetClock(struct CLOCK* pclock, float t)
, you will need to include the definition ofCLOCK
struct, and theTICK
data type since it is used in the CLOCK struct. - You should almost always copy the entirety of "types.h" to ensure you have all the necessary primitive types.
- E.g. For the function
- Click "Create scratch".
- (Recommended) Go to the "Options" tab and under "Debug information" select
-g3 (Macro expansions)
. This will show you which line numbers the source code correspond to each line in the assembly.
Then start writing your code under the "Source code" tab. It will tell you what percent of the code matches the original. Tweak the code until it matches 100%. An example scratch can be found here: https://decomp.me/scratch/hmmyP
Note: You can use the code in the reference
directory to help you during matching. The code in that directory does not match, but it may be useful as an outline for certain functions.
Once the function matches 100%, follow these steps to integrate it into the project:
- Replace the
INCLUDE_ASM
macro in the.c
file with the matched function.- If the function is in a new file, do not create a new file. Creating new
.c
files is done by editing theconfig/sly1.yaml
file to change the file split fromasm
toc
, then runningpython3 configure.py
to generate the new file. If you don't know how to do this, feel free to ask for help in the Discord server.
- If the function is in a new file, do not create a new file. Creating new
- Check
config/symbol_addrs.txt
to see if the mangled name of the function is present.- If it is not, add the mangled name of the function with it's address. The mangled name of the function can be found in the debug symbols for the May 2002 prototype. If you don't know how to find it, ask for help in the Discord server; someone will be able to find it for you easily.
- The symbol_addrs.txt file is grouped alphabetically by filename, then sorted by address within the file.
The project should build and match. Here are some common troubleshooting tips:
undefined reference error
usually means the entry in the symbol_addrs.txt is wrong. Make sure the function name is mangled in symbol_addrs.txt and unmangled in the source code, and the mangled version matches the signature of the function. Also ensure that the address is correct in symbol_addrs.txt.checksum failed
means the compiled elf with your added code doesn't match the original. If it matches on decomp.me but not in the project, it might be an issue with the compiler, so open an issue on GitHub or let someone know on Discord.
Once you add your code to the project and it builds + matches, you can open a pull request to merge your fork into the main branch of the project. A code reviewer will need to approve it before it can be merged into the main branch.
We are a volunteer-driven project, so please be patient while we review your code. These are the main things we will look for in your code:
- It compiles without any errors.
- The compiled elf matches the original elf.
If everything looks good, we will merge your pull request as soon as possible. If anything needs to be addressd, we will let you know.
Thank you for reading, and we appreciate any contributions you make to the project! The project is 100% volunteern-driven, so perfection is not required. The most important thing is to have fun and learn something new about the game.
If you have any questions or concerns, feel free to ask in the Discord server or open an issue on GitHub.