This repository is used for an attempt at decompiling the original CTR assembly into C code. To learn more about projects in this repo, take a look at the readme in src/README.md.
If you are looking to use mods for CTR, please take a look at this repo instead.
This SDK requires the installation of mateusfavarin's psx-modding-toolchain. You can check the repo's readme for instructions on the installation and additional documentation on its usage. All python and pip steps are mandatory.
After setting up psx-modding-toolchain, clone this repository into the local directory psx-modding-toolchain/games:
$ git clone https://github.com/CTR-tools/CTR-in-C.git
Are you interested in contributing? Have any experience in C programming language? You're welcome to join!
The rewrite is our second (and preferred) attempt at decompiling CTR, with higher code standards and more rigorous testing than the original decompile project (mentioned below). It targets only the NTSC-U build (9/26/99 build date) — there are no considerations for other regional builds.
Like the decompile, the rewrite adopts the Ship of Theseus strategy: using 8MB memory expansion (supported by many PS1 emulators), rewritten functions are loaded alongside the original game, allowing direct comparison between the original and rewritten implementations. The focus is on matching both behavior and API.
Pure functions (no global side effects) must have unit tests that call both the original ASM and the rewritten C at runtime and compare outputs. Impure functions should be verified through rigorous testing, integration tests, and/or matching ASM (from the matching project) with only trivial restructuring. See the src/rewrite/README.md for details on the test framework.
- Make sure you have cloned this repo and installed the requirements (including psx-modding-toolchain).
- The rewrite source lives in src/rewrite/src/exe/. Pick a function to rewrite — you can use the ghidra reference and the
matchingproject as guides. - Write a corresponding test in src/rewrite/src/tests/. See the rewrite README for the testing conventions.
- Note: the
rewriteuses gcc 15.2. If you've installed deps via psx-modding-toolchain, runmipsormips use <version>to switch. - Run
build.batand choose "Compile", "Build ISO", then test in PCSX-Redux. - Once everything is working, feel free to open a pull request!

