# diehard-stv Functional decompilation of **Die Hard Arcade** / *Dynamite Deka* (Sega ST-V "Titan" arcade hardware, 1996; dual Hitachi SH-2), plus an in-progress **decompilation-based native PC port** built on a Saturn static recompiler. Personal, non-commercial preservation / research project. ## How this was made (AI agents) I don't write code. This project was built by AI coding agents — primarily Anthropic's **Claude**, run through Claude Code — working under my direction. The agents did the functional decompilation (disassembly triage, m2c/Ghidra first drafts, and the equivalence-verified C in `project/src_functional/`), wrote the home-grown toolchain in `tools/decomp/`, produced the reverse-engineering notes in `notes/`, and drove the native port: the SH-2→C++ recompilation harness, the Saturn runtime bug-fixes, and the HLE/boot bridging. My role was direction, decisions, hardware/ROM provisioning, and review. This public repo is a cleaned, squashed snapshot, so per-commit authorship isn't visible here; the full step-by-step history (with per-commit AI co-author trailers going forward) lives in a private working repo. ## What this is - **Functional decomp** (not byte-matching): behaviorally-equivalent, compilable C for the game's functions. Byte-perfect matching is capped because the exact 1996 Hitachi SHC compiler build is lost, so the target is equivalence-verified C — the foundation for the port and for mods. - **Port**: the game's SH-2 code is statically recompiled to C++ and run on a reusable Saturn runtime (VDP1/VDP2/SCSP/SMPC/dual-SH-2). Boots, renders backgrounds + sprites, takes input, and drives the scene state machine; a fully playable round is still in progress. ## Layout - `project/` — the decomp: `src/` (byte-exact), `src_nonmatching/`, `src_functional/` (the main body), shared headers, build + progress scripts. - `tools/decomp/` — the home-grown toolchain: function splitter, m2c drivers, PIC branch/pointer resolvers, real-entry finder, bounded decompiler, progress counters. - `port/` — the native-port harness (`main_stv.cpp`) built beside the Saturn recompiler runtime. - `tools/saturn-recomp/` — the SH-2→C++ static recompiler + runtime (source only). - `notes/` — reverse-engineering notes, the symbol table, per-batch reports, asset maps, and port status writeups. - `scripts/` — Ghidra headless scripts. ## Not in the repo (regenerable / third-party) `cart.bin` and the other ROM images are **not committed** — reconstruct `cart.bin` from a MAME romset with `build_cart.py`. Toolchain installs (Ghidra, JDK, binutils, the SHC compiler, the Python venv), all build outputs, extracted media (audio/models/frames), and scratch dirs are git-ignored; they live on disk and are referenced by path.