A work-in-progress matching decompilation of Shin Megami Tensei: Devil Summoner (Raidou Kuzunoha vs. the Soulless Army) and Shin Megami Tensei: Devil Summoner 2 (Raidou Kuzunoha vs. King Abaddon) for PlayStation 2. Both versions are built from one tree. The build setup comes from smt3-decomp.
Each translation unit is one file: src/shared/<unit>.c where the unit is
identical in both games and is compiled into each version, else
src/<version>/<unit>.c.
Building requires your own copy of the games. Disc images and retail executables are not included, and nothing derived from them is committed.
Both versions rebuild byte-identical to the retail executables. Most code is
still assembly split from them (INCLUDE_ASM).
Functions and code bytes from C, from python3 tools/progress.py --markdown.
Units in src/shared build both games and are counted once; "only" rows are a
game's own units in src/<version>, and "asm gaps" are code no unit claims yet.
A game's total is the shared units as that game builds them plus its own units
and gaps. "Game" units are Atlus code, "sdk" units are the Sony libraries and C
runtime. Hand-written assembly is not counted; the "vu" row is VU microcode
bytes assembled from src/shared/sdf/vu, outside the totals.
| Units | Kind | Functions in C | Code bytes in C |
|---|---|---|---|
| shared | game | 3,435 / 5,151 (66.7%) | 554,060 / 971,528 (57.0%) |
| shared | sdk | 367 / 605 (60.7%) | 70,032 / 124,372 (56.3%) |
| shared | all | 3,802 / 5,756 (66.1%) | 624,092 / 1,095,900 (56.9%) |
| shared | vu | - / - (n/a) | 16,488 / 16,488 (100.0%) |
| raidou1 only | game | 365 / 1,106 (33.0%) | 34,528 / 210,360 (16.4%) |
| raidou1 asm gaps | game | 0 / 5,172 (0.0%) | 0 / 1,425,844 (0.0%) |
| raidou1 total | all | 4,186 / 12,003 (34.9%) | 663,040 / 2,724,384 (24.3%) |
| raidou2 only | game | 342 / 1,162 (29.4%) | 31,156 / 249,388 (12.5%) |
| raidou2 only | sdk | 1 / 54 (1.9%) | 8 / 9,688 (0.1%) |
| raidou2 only | all | 343 / 1,216 (28.2%) | 31,164 / 259,076 (12.0%) |
| raidou2 asm gaps | game | 0 / 6,744 (0.0%) | 0 / 1,866,376 (0.0%) |
| raidou2 total | all | 4,152 / 13,707 (30.3%) | 656,144 / 3,222,296 (20.4%) |
Matching is checked by the build, not by this script. ninja report runs
objdiff over every unit (objdiff.json is generated by configure.py, with
the categories game and sdk for each version, and shared or own by
where the unit's source lives); it needs the retail executables.
| Version | Game | Serial | ELF SHA-1 |
|---|---|---|---|
raidou1 |
Shin Megami Tensei: Devil Summoner - Raidou Kuzunoha vs. the Soulless Army (USA) | SLUS_214.31 |
a005ff18213eb72017119c7d666312507ad3b5ea |
raidou2 |
Shin Megami Tensei: Devil Summoner 2 - Raidou Kuzunoha vs. King Abaddon (USA) | SLUS_218.45 |
bc0d30b35a40324db1f6d43bb652c6ca1dab3629 |
Both ELFs have entry 0x00100008 and keep their section headers. gp is
0x00471770 in raidou1 and 0x004E4170 in raidou2. The VU0 and VU1
microcode is assembled from the listings in src/<version>/sdf/vu/.
The build uses ee-gcc 2.96 (2.96-ee-001003-1) for
game code and ee-gcc 2.9 (991111-01) for the Sony libraries. Evidence that
this is right for both games, so far:
- Both link Sony EE libraries, all tagged
PsII... 2500(SDK 2.5.0): libgraph, libdma, libpad, libcdvd, libmrpc, libipu, libmc, libkernl, plus libsdr. raidou2contains C++ with exceptions (a 0x904-byte.eh_frameand a.gcc_except_table); its CIE has an empty augmentation string, which is GCC 2.x output (GCC 3 writeszR).raidou1's.eh_frameis only the 4-byte terminator.
The build compiles the C and checks the linked result against the retail SHA-1.
Requirements: Linux x86-64 or WSL2 with 32-bit i386 support, Python 3.10+,
ninja, cpp and git.
python -m venv .venv && . .venv/bin/activate
python -m pip install -r requirements.txt
python tools/download_tools.py
# Copy the disc images into the repository root or orig/, then:
python tools/extract.py # or copy each ELF to orig/<version>/<serial>, IRX to orig/<version>/irx/
python configure.py # every version with an ELF in orig/, or name one
ninja # or: ninja raidou1
python tools/progress.py # source coverageninja ends by checking each linked ELF against config/<version>/checksum.sha1
and each IOP module against its retail file (docs/irx-modules.md).
tools/check_unit.py <unit.c> compares one unit's objects with retail.
CI checks the scripts and source layout without retail executables. When the
private inputs are available, it also verifies both builds and publishes the
progress site on pushes to
main. Badges count matched game and engine code bytes and functions, excluding
SDK code and assembly. tools/progress.py also includes SDK in its totals.
Set ORIG_REPO to Megami-Decomps/raidou-orig and ORIG_DEPLOY_KEY to a
read-only deploy key for that private repository. It must contain
orig/raidou1/SLUS_214.31 and orig/raidou2/SLUS_218.45. Set the repository
Pages source to GitHub Actions. Without these secrets, CI runs only the checks
that do not need retail inputs.
- docs/CONTRIBUTING.md: matching rules, claims, non-matching drafts, verification.
- docs/shared-c.md: units compiled into both versions, names carried over from smt3-decomp, and how
.textis split into translation units. - docs/irx-modules.md: the IOP modules (
USERIRX/,SOUNDIRX/), which of them are SMT3's, and how each game's sound driver differs. - docs/batch-workflow.md: landing a drafted batch with
tools/batch/land_batch.py, and checking a header's includers. config/xgame/r1_r2_pairs.tsv: functions present in both games, by address and unit, so none is matched twice.config/xgame/r1_r2_data_pairs.tsv: data symbols present in both games. A pair has one name in both (naming rule).config/<version>/claims.tsv: advisory unit claims.
- smt3-decomp, whose build
(
configure.py, the tools undertools/, the VU listings) this repository starts from, and dds-decomp and its author redthing1, whose machinery smt3-decomp in turn vendors. - splat, spimdisasm and objdiff.
- decomp.me for the ee-gcc toolchain packaging.