# Tenchu 2 (Japan) decompilation [![CI](https://github.com/Fuuzetsu/tenchu-2-decomp/actions/workflows/ci.yml/badge.svg)](https://github.com/Fuuzetsu/tenchu-2-decomp/actions/workflows/ci.yml) A work-in-progress matching decompilation of **Rittai Ninja Katsugeki: Tenchu 2** for PlayStation, Japanese release **SLPS-03040**. The aim is readable source that compiles to the original code and data bytes, following [Tenchu 1's decompilation](https://github.com/Fuuzetsu/tenchu-decomp). The scope covers Tenchu-authored gameplay, engine, menus, save/ending, trial/editor, boot and loadable modules. Sony PsyQ/SDK/CRT implementations are preserved dependencies, excluded from the completion target. There are no known T2 debug symbols: similarities to T1 inform recovery but require verification against T2. **This is not finished.** Matching the remaining code takes priority over further humanisation. Original behavior, arithmetic order, ABI and gameplay glitches are preserved. Completion is readable matching source; runtime playthroughs and emulator checks are not an additional requirement. ## Progress As of 2026-11-28: **1,438 matching game C function instances**, **62 nonmatching drafts**, and **20 reviewed handwritten game assembly functions**, across thirteen images. Shared functions count separately in each image. Another 36 existing matching SDK instances are tracked separately and excluded from these counts. | Image | Matching game C functions | Remaining drafts | | --- | ---: | ---: | | GAME.EXE | 496 | 18 | | TRIAL.EXE | 505 | 18 | | MENU.EXE | 125 | 8 | | SAVE.EXE | 75 | 4 | | SLPS_030.40 (boot) | 50 | 3 | | game/event.bin | 39 | 0 | | game/datamng.bin | 7 | 0 | | game/movie.bin | 11 | 0 | | trial/datamng.bin | 47 | 3 | | trial/mapmake.bin | 38 | 4 | | trial/menulay.bin | 23 | 4 | | menu/movie.bin | 11 | 0 | | open/movie.bin | 11 | 0 | These are reviewed, provisional code inventories. Complete data ownership, boundary auditing and humanisation remain unfinished, even where all currently identified functions match. Preserved original bytes and nonmatching drafts do not count as recovered C. Each full build retains uncovered spans from the user's original files, so an exact rebuilt image alone does not mean complete recovery. Generate the current per-image report without any game files: ```sh python3 tools/progress.py ``` CI publishes the same metadata as the objdiff v2 `jp_report/report.json` artifact, following the Tenchu 1 reporting convention. It measures committed C matching, not humanisation or whole-project completion. ## Build Install [Nix](https://nixos.org/download/) with flakes enabled. The checked-in `flake.lock` pins the compiler, assembler and Python tooling. Sibling Tenchu repositories are research references and are not required to build. Supply your own Japanese disc. **Disc images, extracted game executables, assets, BIOS and captured RAM are not included.** The importer accepts a ZIP, CUE/raw BIN, ISO or extracted disc directory and checks the expected revision. ```sh ./dev.sh python3 tools/extract.py '/path/to/Tenchu 2 (Japan).cue' ./dev.sh ./Build check # GAME.EXE ./dev.sh ./Build check-all # all five executables and eight modules ./dev.sh ./Build test # build-tool tests and Python lint/format ``` Imported files stay in ignored `discs/jp/`. Build products stay in ignored `.build/`. The build compiles declared C units with GCC 2.8.1 and maspsx, assembles reviewed handwritten source, links at retail addresses and compares every output byte. A few retained complete SDK objects use their separately recorded GCC 2.7.2 profile. Source units must fit their declared code/data spans. Public GitHub Actions CI uses no game files. It scans Git contents and history, checks for secrets, runs build-tool tests and lint, and compiles all declared source with the pinned toolchain. Exact retail comparison remains the local `check-all` step. CI uploads only the progress JSON, never executable build output. ## Repository layout - `src/`, `include/`: matching source, shared implementations and declarations. - `nonmatching/`: complete drafts still needing instruction-level matches. - `config/`: source ownership, image hashes, symbols and provisional code regions. - `reference/`: reviewed function names, extents and evidence. - `tools/`: importer, build, matching, reporting and research utilities. - [PLAN.md](PLAN.md): current status, remaining work and development journal. - [SOURCES.md](SOURCES.md): provenance, consulted revisions and evidence. - [Historical progress notes](docs/PROGRESS_HISTORY.md): detailed earlier results; old runtime/fixture commands there are historical records, not the current workflow. See [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md) before making changes. Keep original files, generated outputs and private research out of Git.