Civ 1 period accurate decompilation
- Source
- github.com
- Author
- crc32
- Date
Context
Decompilation works backward from a program's machine code to source code a person can read and rebuild. The civd repository does this for the 1991 MS-DOS version of Sid Meier's Civilization, and "period accurate" refers to how the result is checked. The reconstructed C and assembly are built with the tools of the time: Microsoft C 5.1, MASM 5.10 and LINK 5.01 under Microsoft MAKE 4.07, running inside the DOSBox-X emulator. The README says the resulting CIV.EXE matches version 474.05 byte for byte, and that verification also checks the raw linker output, the MCGA graphics driver, the AdLib sound driver and MISC.EXE against pinned hashes.
Using the original compiler makes the match a demanding test. The project's build notes explain that compiler options, segment names, declarations and link order all change the output. With this toolchain, even the spelling of an identifier can affect how local variables are allocated. Some awkward names were kept because changing them would change the compiled layout, and two large modules are compiled with limited available memory because that also affects the code Microsoft C 5.1 produces. Source that only behaves like the game would not survive this check. To pass, it has to compile to the same bytes.
There is one exception. The raw linker output is not quite the shipped file, so a small checked program rewrites the destination of one far call, leaving four bytes different. In the original executable, that call skips the runtime's environment initialization and jumps to a function that immediately returns. In the Hacker News post, the author says this appears to be a patch applied after linking. The build notes say the reason is unknown.
The project is careful about what the match proves. The README warns that it is a reconstruction, not MicroProse's original source, and that names, comments and some type declarations are inferred. It says LLMs from OpenAI, Anthropic and Google were used for code and documentation, followed by editing and build verification. It also credits earlier decompilation work, particularly OpenCiv1. The author says OpenCiv1 probably deserves most of the credit and was almost certainly in the models' training data. Matching executables is the same standard the community Melee decompilation reached for that game's main executable after six years, where developer banteg also credited language models with speeding up the work. Alongside the source, the author has published a technical book on the game's systems, a source-reading story and a separate reciv repository that rebuilds the game for modern platforms.
- LLM — A large language model — the neural network behind tools like Claude and ChatGPT, trained on huge amounts of text to predict what comes next.
Checking sign-in…
Loading comments…

