791e321b43
TT_000 is the first overlay from PlayStation 1 that we are now able to compile from the source and produce a 1:1 binary. This lead me to start exploring the same overlay from the game Castlevania: Dracula X Chronicles, which contains a PSP re-build of Symphony of the Night. This PR adds all the infrastructure to add the same flow for a PSP matching decomp. Use `export VERSION=pspeu` and then the usual `sotn` command to splat the overlay, build it and check if it matches. Running `make extract_disk` should not be necessary as the same ISO used from `VERSION=hd` is also used for `pspeu`, so you will probably have it extracted already. Some important notes about the PSP build: * The whole PSP build seems to be compiled with `-O0`, which makes it much easier to decompile * Having ŧhe PSX, PSP and Saturn builds will allow to easily cross-reference the code and reduce fake matches * `disks/pspeu/PSP_GAME/USRDIR/res/ps/hdbin/tt_000.bin` is the HD PSX build * `disks/pspeu/PSP_GAME/USRDIR/res/ps/PSPBIN/tt_000.bin` has the same code from the HD build, but for PSP * `disks/pspeu/PSP_GAME/USRDIR/res/ps/PACK_E/TP00.BIN` is the same as above, but it packs both overlay and graphics. This is the file the PSP game seems to actually use * The PSP build uses the Metrowerk CodeWarrior's C compiler, which is very different from the GCC one used on PSX. * Thanks to @mkst lead, we found a way to still use the GNU assembler and linker * MWCC uses [wibo](https://github.com/decompals/WiBo/), a think compatibility layer to run Windows CLI tools on Linux. It is much more lightweight than Wine. * MWCC does not support the `INCLUDE_ASM` dialect, so the custom pre-processor `tools/mwcpp` had to be created * The exact MWCC compiler version is unknown, but I suspect it is `build 147` * I am not yet sure of any implications for using GNU AS and GNU LD instead of the MW correspondent tools * Not all the functions can be correctly disassembled, spimdisasm will just produce a bunch of `.word 0x________` due to the in-progress effort of adding the Allegrex-specific opcodes support --- TO-DO list before marking the PR as ready: - [X] Add PSP build to the CI - [x] Add progress reporting to the PSP build - [x] Integrate source file from `src/servant/tt_000_psp` to `src/servant/tt_000` to promote the psp build as first-citizen --- TO-DO in a follow-up PR: * Figure out what `header` is: can we extract it as assembly code? or maybe as custom re-compilable asset via splat? Is it a MW stuff or a Castlevania-specific file? * Get rid of the last line in `Makefile.psp.mk` |
||
---|---|---|
.github/workflows | ||
.vscode | ||
bin | ||
cmake | ||
config | ||
disks | ||
docs | ||
include | ||
src | ||
tools | ||
.clang-format | ||
.gitignore | ||
.gitmodules | ||
CMakeLists.txt | ||
CNAME | ||
CONTRIBUTING.md | ||
diff_settings.py | ||
Dockerfile | ||
go.work | ||
Makefile | ||
Makefile.psp.mk | ||
Makefile.psx.mk | ||
Makefile.saturn.mk | ||
README.md | ||
weapon0.ld | ||
weapon1.ld |
Castlevania: Symphony of the Night Decompilation
A work-in-progress decompilation of Castlevania Symphony of the Night for Sony PlayStation 1, Sony PlayStation Portable and Sega Saturn. It aims to recreate the source code from the existing binaries using static and/or dynamic analysis. The code compiles byte-for-byte to the same binaries of the game, effectively being a matching decompilation.
It currently supports the following versions of the game:
us
the reference build with the serial number SLUS-00067hd
an unreleased PS1 Japanese build found in Castlevania: Dracula X Chronicles game datapspeu
European build from Castlevania: Dracula X Chroniclessaturn
the port created by an external development team
This repo does not include any assets or assembly code necessary for compiling the binaries. A prior copy of the game is required to extract the required assets.
Bins decomp progress
Code coverage means how many bytes of code have been successfully converted from assembly into C code, while decomp function is how many functions have been successfully decompiled.
Useful links
Decompiling a game is a mastodontic task. If you have some basic programming skills, please join us in this journey. Any contribution will be very appreciated!
Special thanks
This project is possible thanks to the hard work of tools provided by the Decompilation community:
- mips2c from @matt-kempster to decompile MIPS assembly into C. This has proven to be more accurate than Hexrays IDA and Ghidra.
- splat from @ethteck to disassemble code and extract data with a symbol map. This tool provides the fundamentals of the SOTN decomp.
- asm-differ from @simonlindholm to know how the decompiled code compares to the original binary.
- decomp-permuter from @simonlindholm to pick different versions of the same code that better matches the original binary.
- maspsx by @mkst to replicate the customized assembler used in the official PSX SDK.
- decomp.me by @ethteck, @nanaian and @mkst to provide a collaborative decompilation site to share and contribute to work-in-progress decompiled functions.
- frogress by @ethteck to store and retrieve progression data.
- esa-new by @mkst as an inspiration on how to set-up a PS1 decompilation project.
- oot as an inspiration of what it is possible to achieve with a complete decompiled video game.