Skip to content

Latest commit

 

History

5,790 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

khdays-decomp

A work-in-progress matching decompilation of Kingdom Hearts 358/2 Days (Nintendo DS). The goal is C source that recompiles to a binary byte-for-byte identical to the original game code.

Disclaimer

This repository does NOT contain the game ROM, any game assets, or any of the original binary/assembly. An existing, legally-obtained copy of the game is required to extract and build it.

This repository is a matching decompilation only. It does not contain or produce a playable build or any redistributable game binary, and building it requires an original, legally-obtained copy of the game. All trademarks and the original game are property of their respective owners.

Status

This project is in an early bootstrapping phase. Progress is intentionally split into separate categories so inline ASM placeholders and SDK byte-match identifications are not counted as real C decompilation.

Category Count Meaning
Real C-decompiled matched functions 23,060 / ~23,233 (~99.3% by function count) Functions implemented in C and verified byte-exact
Complete functions (C + verified original library assembly) 23,166 / ~23,233 (~99.7%) Real C, plus library functions whose original source is assembly (NitroSDK/MSL asm, BIOS veneers): C cannot express them, so they count once integrated as that assembly and byte-verified with source evidence in config/arm9/report_asm_matches.json.
Real C-decompiled matched bytes 4,653,930 / 4,728,788 (~98.42% by code bytes) Real-C-only byte progress; asm_stubs/, inline ASM and nonmatching/ are excluded. decomp.dev additionally counts source-hashed, verified SDK assembly and authorized CLZ exceptions as matching, not as C. See progress policy.
Inline ASM / ASM stub matched functions 129 / ~23,233 (~0.6%) ASM implementations, including temporary game stubs, canonical library assembly and authorized inline exceptions; never counted as real C. Only explicitly verified manifest entries contribute to decomp.dev matching coverage.
SDK/library byte-match identifications 3 / ~23,233 (~0.0%) NitroSDK or library functions identified separately by byte matching
Named but not decompiled 41 / ~23,233 (~0.2%) Functions known to the project but not implemented as C
Initialized DATA 188,340 / 188,340 (100.00%) Byte/relocation-verified .rodata/.data; includes the separately reported MobiClip executable payload at 26,012/26,012 bytes.
Total known functions 23,240 Function index for the EU YKGP target
Region EU (YKGP)
Compiler CodeWarrior mwccarm 3.0 build 139 Fully-decompiled modules now include ov031, ov188 and ov189; see PROGRESS.md for the complete generated list. A few precompiled-middleware translation units (e.g. the ov028 anti-tamper crypto core) build with an older mwccarm via a per-file compiler override (config/arm9/file_compilers.json).

The current counts are generated by python tools/audit_progress.py. See docs/PROGRESS_POLICY.md for what counts as real decompiled progress.

Progress reporting policy

Only real C implementations are counted as C-decompiled progress.

Inline ASM, ASM stubs, INLINE_ASM, NON_MATCHING, or similar placeholder code may be used temporarily for bootstrapping and verification, but these are not counted as decompiled C progress.

SDK/library byte-match identifications are tracked separately from game-code decompilation. See sdk/README.md for the SDK identification workflow.

Repository layout

src/auto/           real C leaf functions (byte-exact, no external calls)
src/calls/          real C functions with calls (byte-exact)
src/asm_stubs/auto/   ASM / inline-asm bootstrap stubs, leaf functions
src/asm_stubs/calls/  ASM / inline-asm bootstrap stubs with calls
config/             dsd project config (symbols / delinks / relocs per module)
macros/             assembler macros (function.inc)
tools/              Python tooling (extraction, matching, candidate finders)
sdk/                NitroSDK byte-match identification harness (see sdk/README.md)
build/              generated manifests and reports; build output is git-ignored

Files under src/asm_stubs/ may match the original bytes, but they are temporary ASM-based matches (asm void, __asm, hand-written ARM) that were used to bootstrap the project. They are counted separately from real C decompilation progress, see docs/PROGRESS_POLICY.md.

The ROM, the extracted data (dsd_extract/, asm/), build artifacts, and the proprietary toolchain are intentionally not tracked; see .gitignore. Some temporary ASM stubs or handwritten inline assembly may exist while the project is being bootstrapped. These are not original extracted assembly files and are not counted as real C-decompiled progress.

Building / verifying

You need your own copy of the game plus the toolchain (see CONTRIBUTING.md for setup). Then, to verify a single function:

python tools/getcand.py func_XXXXXXXX        # prints disasm + the verify command
python tools/match.py <your.c> <...>          # compiles and byte-compares

A green >>> MATCH <<< means your C reproduces the original exactly.

Toolchain

  • dsd - DS ROM extraction / delinking
  • mwccarm 3.0 (CodeWarrior for Nintendo DS) - the matching compiler
  • arm-none-eabi-as (GNU binutils) - assembling the not-yet-decompiled .s
  • Python 3 with capstone, pyelftools, ndspy

See the Nintendo DS decompilation guide.

Contributing

Contributions are very welcome; see CONTRIBUTING.md. Every matching function must pass byte-exact verification, and public C decompilation progress only counts real C implementations. Progress per module and how to claim one is in PROGRESS.md.

License

The decompilation and tooling in this repository are dedicated to the public domain under CC0 1.0. This applies only to the contributors' own work; the original game and its assets remain the property of their owners.

About

Work-in-progress matching decompilation of Kingdom Hearts 358/2 Days (Nintendo DS)

Topics

Resources

Contributing

Stars

39 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages