sotn-decomp/README.md

61 lines
9.6 KiB
Markdown
Raw Normal View History

# Castlevania: Symphony of the Night Decompilation
2022-01-01 17:45:41 +00:00
Add TT_000 overlay from PSP (#1113) 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`
2024-04-21 01:18:10 +00:00
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:
2023-07-02 18:19:35 +00:00
* `us` the reference build with the serial number SLUS-00067
2023-07-02 18:19:35 +00:00
* `hd` an unreleased PS1 Japanese build found in Castlevania: Dracula X Chronicles game data
Add TT_000 overlay from PSP (#1113) 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`
2024-04-21 01:18:10 +00:00
* `pspeu` European build from Castlevania: Dracula X Chronicles
* `saturn` the port created by an external development team
2022-01-01 17:45:41 +00:00
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
2023-02-25 11:43:20 +00:00
| File name | Code coverage | Decomp functions | Description
|------------|----------|-----------|-------------
| SLUS_000.67 | ![code coverage SLUS_000.67](https://img.shields.io/endpoint?label=SLUS_000.67%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dmain) | ![decompiled functions](https://img.shields.io/endpoint?label=SLUS_000.67%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dmain) | Shared libraries
2023-02-25 11:43:20 +00:00
| DRA.BIN | ![code coverage DRA.BIN](https://img.shields.io/endpoint?label=DRA%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Ddra) | ![decompiled functions](https://img.shields.io/endpoint?label=DRA%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Ddra) | Game engine
| BIN/RIC.BIN | ![code coverage RIC.BIN](https://img.shields.io/endpoint?label=RIC%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dric) | ![decompiled functions](https://img.shields.io/endpoint?label=RIC%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dric) | Playable Richter
2023-08-26 07:29:05 +00:00
| BIN/WEAPON0.BIN | ![code coverage WEAPON0.BIN](https://img.shields.io/endpoint?label=WEAPON0%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dweapon) | ![decompiled functions](https://img.shields.io/endpoint?label=WEAPON0%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dweapon) | Equippables
2023-02-25 11:43:20 +00:00
| ST/CEN/CEN.BIN | ![code coverage CEN.BIN](https://img.shields.io/endpoint?label=CEN%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstcen) | ![decompiled functions](https://img.shields.io/endpoint?label=CEN%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstcen) | Center
| ST/DRE/DRE.BIN | ![code coverage DRE.BIN](https://img.shields.io/endpoint?label=DRE%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstdre) | ![decompiled functions](https://img.shields.io/endpoint?label=DRE%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstdre) | Nightmare
| ST/MAD/MAD.BIN | ![code coverage MAD.BIN](https://img.shields.io/endpoint?label=MAD%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstmad) | ![decompiled functions](https://img.shields.io/endpoint?label=MAD%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstmad) | Debug Room
| ST/NO3/NO3.BIN | ![code coverage NO3.BIN](https://img.shields.io/endpoint?label=NO3%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstno3) | ![decompiled functions](https://img.shields.io/endpoint?label=NO3%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstno3) | Entrance (first visit)
| ST/NP3/NP3.BIN | ![code coverage NP3.BIN](https://img.shields.io/endpoint?label=NP3%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstnp3) | ![decompiled functions](https://img.shields.io/endpoint?label=NP3%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstnp3) | Entrance
| ST/NZ0/NZ0.BIN | ![code coverage NZ0.BIN](https://img.shields.io/endpoint?label=NZ0%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstnz0) | ![decompiled functions](https://img.shields.io/endpoint?label=NZ0%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstnz0) | Alchemy Laboratory
| ST/SEL/SEL.BIN | ![code coverage SEL.BIN](https://img.shields.io/endpoint?label=SEL%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstsel) | ![decompiled functions](https://img.shields.io/endpoint?label=SEL%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstsel) | Title screen
| ST/ST0/ST0.BIN | ![code coverage ST0.BIN](https://img.shields.io/endpoint?label=ST0%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstst0) | ![decompiled functions](https://img.shields.io/endpoint?label=ST0%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstst0) | Final Stage: Bloodlines
| ST/WRP/WRP.BIN | ![code coverage WRP.BIN](https://img.shields.io/endpoint?label=WRP%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstwrp) | ![decompiled functions](https://img.shields.io/endpoint?label=WRP%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstwrp) | Warp Room
| ST/RWRP/RWRP.BIN | ![code coverage RWRP.BIN](https://img.shields.io/endpoint?label=RWRP%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dstrwrp) | ![decompiled functions](https://img.shields.io/endpoint?label=RWRP%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dstrwrp) | Warp Room (reverse)
| BOSS/MAR/MAR.BIN | ![code coverage MAR.BIN](https://img.shields.io/endpoint?label=MAR%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dbomar) | ![decompiled functions](https://img.shields.io/endpoint?label=MAR%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dbomar) | Maria cutscene
2023-02-25 11:43:20 +00:00
| SERVANT/TT_000.BIN | ![code coverage TT_000.BIN](https://img.shields.io/endpoint?label=TT_000%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dtt_000) | ![decompiled functions](https://img.shields.io/endpoint?label=TT_000%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dtt_000) | Bat Familiar
| SERVANT/TT_001.BIN | ![code coverage TT_001.BIN](https://img.shields.io/endpoint?label=TT_001%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dtt_001) | ![decompiled functions](https://img.shields.io/endpoint?label=TT_001%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dtt_001) | Ghost Familiar
2023-02-25 11:43:20 +00:00
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.
2022-01-01 17:45:41 +00:00
2023-03-28 21:08:41 +00:00
## Useful links
2023-02-21 01:27:25 +00:00
2023-03-28 21:08:41 +00:00
* [Build guide](https://github.com/Xeeynamo/sotn-decomp/wiki/Build)
* [Decompilation guide](https://github.com/Xeeynamo/sotn-decomp/wiki/Decompilation)
* [Progress report](https://sotn.xee.dev/)
2023-02-21 01:27:25 +00:00
2023-10-28 22:23:18 +00:00
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!
[![Join to our Discord server](https://discord.com/api/guilds/1079389589950705684/widget.png?style=banner2)](https://sotn-discord.xee.dev/)
2023-02-28 15:40:00 +00:00
## Special thanks
This project is possible thanks to the hard work of tools provided by the Decompilation community:
2023-10-27 18:48:18 +00:00
* [mips2c](https://github.com/matt-kempster/m2c) from @matt-kempster to decompile MIPS assembly into C. This has proven to be more accurate than Hexrays IDA and Ghidra.
* [splat](https://github.com/ethteck/splat) from @ethteck to disassemble code and extract data with a symbol map. This tool provides the fundamentals of the SOTN decomp.
2023-02-28 15:40:00 +00:00
* [asm-differ](https://github.com/simonlindholm/asm-differ) from @simonlindholm to know how the decompiled code compares to the original binary.
* [decomp-permuter](https://github.com/simonlindholm/decomp-permuter) from @simonlindholm to pick different versions of the same code that better matches the original binary.
* [maspsx](https://github.com/mkst/maspsx) by @mkst to replicate the customized assembler used in the official PSX SDK.
2023-02-28 15:40:00 +00:00
* [decomp.me](https://github.com/decompme/decomp.me/) by @ethteck, @nanaian and @mkst to provide a collaborative decompilation site to share and contribute to work-in-progress decompiled functions.
* [frogress](https://github.com/decompals/frogress) by @ethteck to store and retrieve progression data.
* [esa-new](https://github.com/mkst/esa-new) by @mkst as an inspiration on how to set-up a PS1 decompilation project.
2023-03-03 18:52:45 +00:00
* [oot](https://github.com/zeldaret/oot) as an inspiration of what it is possible to achieve with a complete decompiled video game.