# Silent Hill: Homecoming decompilation A matching decompilation of *Silent Hill: Homecoming* (PC, 2008; Double Helix's "Slayer" engine). The goal is C++ source that the original compiler, given the original flags, turns into object code identical to the retail game DLL `g_SilentHill.sgl`, function by function, and that reads like the code the original team wrote. The repository holds only reconstructed source, the project's own tools and their configuration. It contains no game executable, asset, data or original source code; to build and check anything you need your own copy of the game files listed under [Inputs](#inputs). ## How it works - **Target.** The retail DLL of the PC release of 2008-10-22: 76,516 game functions (14.1 MB of code) in 1,103 objects, plus 11,590 library functions (Havok, CRT) that are not targets. The game code was built with Visual C++ 2005 SP1 (`cl` 14.00.50727.762) with the optimiser off, so code generation is close to deterministic. [docs/target.md](docs/target.md) says why this binary was chosen over the Xbox 360 and PS3 builds. - **Evidence.** The Xbox 360 build of June 2008 shipped with its PDB (`Slayer_r.pdb`), which gives the original class layouts, function signatures, parameter and local names, source files and line numbers. The PC binary's linker map gives every function's address and decorated name. - **Byte gate.** `gate.exe` compiles every unit with the original compiler and flags and compares each claimed function with retail, byte for byte, with relocations checked against their targets. Only the gate banks a match, and only on a committed tree. - **Reader test.** A byte-identical function counts only when its source is something a programmer on the original team would have typed: no fakematches (dummy locals, stray casts, reordered statements to shape the output). The rules are the `decomp-code-rules` skill plus the project's own rules in [AGENTS.md](AGENTS.md), checked by `rules.exe`. - **Line-faithful layout.** Asserts embed `__LINE__` and `__FILE__`, so units keep the original line numbers (taken from the PDB) and compile through a junction at the original build path, `c:\slayer\PC`. Per-function progress is in [config/ledger.tsv](config/ledger.tsv) (written by `report.exe --write`); `build\tools\report.exe` prints the totals. The progress is also published as an objdiff report, [progress/report.json](progress/report.json), which [decmp.dev](https://decmp.dev/lemiur/shh-decomp) and [ByteMatch](https://bytematch.dev/lemiur/shh-decomp) read: [![decmp](https://api.decmp.dev/badge/lemiur/shh-decomp.svg?measure=matched_code_percent&label=code)](https://decmp.dev/lemiur/shh-decomp) [![ByteMatch](https://bytematch.dev/lemiur/shh-decomp.svg?measure=matched_code_percent&label=code)](https://bytematch.dev/lemiur/shh-decomp) ## Repository layout | path | what | |---|---| | `src/` | reconstructed source, laid out as the original tree (`Slayer\`, `SrcCore\`, `SrcSilentHill\`, `3rdparty\`, ...) | | `config/target.tsv` | the contract: the retail files' SHA-256, image base, compiler flags, original build paths | | `config/ledger.tsv` | every annotated function's status and best score | | `config/vendored.tsv` | vendored third-party files and their upstream references | | `config/local.example.tsv` | template for this machine's paths (`config/local.tsv`, not versioned) | | `tools/` | the project's tools, in C (`tools/c`), and the setup and build scripts | | `docs/` | [tools](docs/tools.md), [PDB reader](docs/pdb-tool.md), [target choice](docs/target.md), [lane brief](docs/lane-brief.md) | | `AGENTS.md` | the project guide: toolchain, annotations, gate, code rules, style, lanes, agents | | `.claude/skills/` | the matching skills the guide uses (matcher, decomp-code-rules, helper-recovery, wall-identifier, permute, orchestrator, codex) | ## Inputs Not in the repository, and needed on every machine. The tools check each file's SHA-256 against `config/target.tsv`. | file | from | goes to (default) | |---|---|---| | `g_SilentHill.sgl`, `g_SilentHill.map` | the PC release, 2008-10-22, with its linker map | `_extracted\WIN\` | | `Slayer_r.pdb`, `Slayer_r.map` | the Xbox 360 build of 2008-06-19, with its PDB | `_extracted\X360\` | `_extracted\` is below the main checkout and ignored by git. To keep the files elsewhere, set `retail_dir` and `x360_dir` in `config/local.tsv`. ## Setting up a machine Windows 10 or 11, x64. Install: | what | why | notes | |---|---|---| | Git | the tools read the checkout through git | | | Visual Studio 2026 with "Desktop development with C++" and "C++ CMake tools for Windows" | builds the tools | found with vswhere; set `SHH_VCVARS` to another `vcvars64.bat` to choose | | Visual Studio 2005 with Service Pack 1 (Visual C++, Platform SDK) | the original compiler, `cl` 14.00.50727.762 | default `C:\Program Files (x86)\Microsoft Visual Studio 8`; a copied install folder works too (it needs `VC\bin`, `VC\include`, `VC\PlatformSDK\Include` and `Common7\IDE`), named by `vc8_dir` | | DirectX SDK (June 2010) | `d3d9.h` and friends for the renderer units | found through `DXSDK_DIR`; or set `include_extra` | | 7-Zip | `setup.cmd` extracts the inputs with it | optional if you place the files yourself | Then: ```bat git clone https://github.com/lemiur/shh-decomp.git cd shh-decomp tools\setup.cmd D:\path\to\your\archives ``` `setup.cmd` builds the tools into `build\tools\`, extracts the four input files from any `.7z` in the folder you name (default: the checkout), and runs `build\tools\doctor.exe`. Doctor checks every prerequisite and prints one line each, with the fix for anything missing: ``` ok retail DLL ...\_extracted\WIN\g_SilentHill.sgl (sha256 ok) ok VC8 compiler ...\VC\bin\cl.exe, 14.00.50727.762 (VS80COMNTOOLS) ok DirectX headers ...\Microsoft DirectX SDK (June 2010)\Include (DXSDK_DIR) ok original build path c:\slayer\PC: the first compile creates the junction (in c:\slayer) ``` When it says ready, build and gate everything: ```bat build\tools\match.exe --all --summary build\tools\gate.exe ``` Notes: - The compile driver creates the junction `c:\slayer\PC` and points it at the checkout that is compiling. No administrator rights are needed; `c:\slayer\PC` must not already exist as an ordinary folder. - Paths a machine needs that differ from the defaults go in `config/local.tsv` (copy `config/local.example.tsv`). Notes about one machine (where its Ghidra or emulators are) go in `config/local.md`. Both are ignored by git. - From Git Bash, prefix a command that passes `--flags` or `--variant` with `MSYS_NO_PATHCONV=1`, or Git Bash rewrites `/Oi` into a path (the tools stop when that happens). - `tools\c\tests\run.cmd` runs the tools' regression checks. The upstream sources of the vendored third-party code (Tremor, miniLZO, Parsifal) go in the ignored `ref\` folder; without them, `rules` checks those files in full and the test that reads every reference fails. AGENTS.md, "Third-party code", lists where each comes from. ## Working on a unit The loop, with every tool in `build\tools\`: 1. `index.exe obj ` lists the object's functions; `skeleton.exe --write` writes a line-faithful unit skeleton from the PC map and the X360 PDB. 2. `pdb.exe header ` generates the class header from the PDB, placed where its `// home:` comment says. 3. Write bodies from `disasm.exe 0x` and the PDB's names, then iterate with `match.exe src\.cpp --summary` and `--diff `. 4. Mark a function `// FUNCTION: SHH 0x` only when it matches and passes the reader test; until then it is `// STUB:`. `vtables.exe` checks every vtable the unit emits. 5. `rules.exe `, then commit, then `gate.exe` on the committed tree. [AGENTS.md](AGENTS.md) has the annotation forms, the code rules, the style profile and the evidence for each compiler flag; [docs/tools.md](docs/tools.md) has every tool's options. ## Working across machines and with others - `main` on GitHub is the shared history. Pull before you start (`git pull --ff-only`) and push banked work soon after it is committed. - Work on a branch per lane (a set of units), and claim the units first, in an issue or a draft pull request, so two machines or people don't reconstruct the same functions. - Before pushing to `main`, rebase on it and run `match.exe --all --summary`, `rules.exe` and `gate.exe`: every function claimed on `main` must stay matching. A clean rebase can still duplicate a definition another lane added, and only a full build catches it. - Commit messages name the change (`match: GO.cpp TGO accessors`, `tools: check base relocations`). The repository is public, so commit with an address you are willing to publish, such as your GitHub noreply address (`git config user.email`). - Generated output stays in the ignored `build\`; tools are written in C, not Python. ## AI agents The project is set up to be worked on by coding agents as well as people. - [AGENTS.md](AGENTS.md) is the guide every agent reads first (`CLAUDE.md` points to it). It takes precedence over the skills. - The skills it uses are versioned in `.claude/skills/`, so Claude Code loads them as project skills on any clone. - Parallel work runs in lanes: one git worktree per lane beside the main checkout, briefed from [docs/lane-brief.md](docs/lane-brief.md). AGENTS.md, "Lanes and worktrees" and "Models and effort", covers slot layout, model choice and the `codex exec` recipe for Codex lanes, whose brief starts with [config/codex-preface.md](config/codex-preface.md). ## Third-party code Some units are third-party libraries the studio compiled into the game: Tremor (Xiph's integer Vorbis decoder), miniLZO, the Parsifal XML parser and the ubiqx MD4/MD5 code. Those files keep their original authors' copyright and licences (miniLZO is GPL v2). The tools vendor capstone 5.0.7 (`tools/c/third_party/capstone`, BSD licence). The project's own tools and reconstructed engine source do not yet carry a licence. *Silent Hill* is a trademark of Konami Digital Entertainment. This is an unofficial research and preservation project with no affiliation to Konami or Double Helix Games.