$ show GensokyoClub/th06
This repository is a bit-exact decompilation of Touhou Koumakyou ~ the Embodiment of Scarlet Devil (TH06) for Windows, aiming to reconstruct the original executable from scratch using reverse engineering. It is primarily an applicationβa full game reimplementation with subsystems for graphics (Direct3D8), audio (DirectSound, MIDI), input (DirectInput), enemy scripting (ECL), sprite animations (ANM), replay recording, menu UI, and more. The build system uses MSVC 7.0 and DirectX 8.0 SDK, orchestrated by Python scripts and Ghidra for analysis and comparison. While the core purpose is binary-matching reconstruction, the project also functions as a research repository for understanding the game's internals, with extensive mapping data (CSV files) and Ghidra export scripts. The codebase is large, tightly coupled via global singletons, but contains several self-contained reusable components such as the Chain callback system, PBG3 archive parser, DirectSound wrapper, MIDI player, and a standalone PE file parser (pefile.py). Active development and CI indicate ongoing work to complete the decompilation.
The LLM identified 5 files worth highlighting for reuse:
A standalone, MIT-licensed Portable Executable file parser, backported to Python 3.4. It is used by the build system to extract binary structure and symbols from the original game executable. It is fully self-contained, well-documented, and could be reused in any project requiring PE file analysis.
PBG3 archive reader with LZSS decompression. This class provides a clean interface for opening and reading from the game's custom archive format. It is isolated within its own directory and depends only on standard library types and a simple abstraction interface. It can be extracted and reused in other projects that need to read PBG3 files.
A generic ordered callback registration system used throughout the game for update and draw chains. It is a single header file with a simple template-based design that allows adding and removing callbacks with priority ordering. It demonstrates a clean separation of concerns and could be reused in other game or simulation projects.
DirectSound wrapper classes (CSoundManager, CSound, CStreamingSound) for playing WAV files with streaming and notifications. This code is adapted from DirectX SDK samples but is self-contained and well-structured. It can be reused in any Windows application requiring DirectSound audio playback.
MIDI playback implementation using Windows multimedia timers and standard MIDI output. It parses SMF files and schedules note events with timer callbacks. This is a clean, self-contained module that could be extracted for any project needing real-time MIDI playback on Windows.