WIP matching decomp of LEGIE 2009.
- Borland Delphi 7 (Object Pascal)
- FMOD 3.75
- GLScene 1.0.0.0714
legie.exeis packed with UPX; unpacked binary islegie_unpacked.exe- Data files:
legie.sud/demo.sub(custom PACK format)- TGA, JPEG, BMP textures
- OGG audio (music, dialogue, SFX)
- MD2, 3DS models (use Noesis; two models exceed 2k verts)
_prulet.txtcutscene scripts (debugging leftover)
- Install Borland Delphi 7
- On first run, open the IDE empty, then
File -> Openglscene/Delphi7/GLScene7.dpk, thenCompile -> Install - Install Python 3.x, then
pip install -r requirements.txt - Place
legie.sudandfmod.dllinbin/
src Compilable project
raw_idr Interactive Delphi Reconstructor output
analysis Take a guess..
tools Python tooling
bin "playable" game
pak_extracted Extracted game assets (see unpack_sud.py)
glscene GLScene 1.0.0.0714 source
fmod-3.75 FMOD 3.75 API
This project uses a matching-decomp approach: write Pascal code that compiles to identical assembly as the original binary, verified function-by-function.
Check what needs work:
python tools/progress.py # show match status for all functions
python tools/annotate_funcs.py --missing # list functions not yet in sourceStart with small functions (fewer instructions = easier to match).
python tools/asm_differ.py 00561B60 # by original address
python tools/asm_differ.py --list # see all functions with addressesOr read the IDR output directly in raw_idr/Unit1.pas -- search for the address. Each function has its full x86 assembly inside {* *} comment blocks with IDR annotations for strings, global variables, and call targets.
Edit src/UnitX.pas. Add or replace the function body. Annotate it with the original address:
procedure MyFunction; { 00561B60 }
begin
// decompiled code here
end;The { XXXXXXXX } comment links the function to its original for diffing.
python tools/build.py --diff MyFunction # compile + diff in one step
python tools/build.py # just compile
python tools/asm_differ.py MyFunction # just diff (no recompile)The differ shows a side-by-side comparison with color:
- Green (OK): instruction matches
- Yellow (OPS): mnemonic matches, operands differ
- Red (DIFF): mnemonic mismatch
- Cyan (REC+): extra instruction in recompiled (often alignment padding)
Fix discrepancies shown by the differ. Common issues:
- Wrong variable types (e.g.,
BytevsIntegerchanges register sizealvseax) - Wrong calling convention or parameter order
- Missing
varparameter (pass-by-reference vs pass-by-value) - Compiler generating different control flow for equivalent logic
- String literals at wrong addresses (check ordering in source)
python tools/progress.py --report # full report, saves to analysis/
python tools/build.py --diff-all # build + show all function status# Re-extract original assembly (after updating raw_idr files)
python tools/extract_asm.py
# Unpack game data for reference
python tools/unpack_sud.py legie.sud pak_extracted
# Check which functions lack address annotations
python tools/annotate_funcs.py
# Generate function address mapping file
python tools/annotate_funcs.py --gen-mapThis project is licensed under the MIT license.