Resident Evil 4 on GameCube decompiled byte for byte into C and C++

A GitHub project has turned the debug build of the GameCube Resident Evil 4 into readable, compilable C and C++ that reproduces the original disc exactly, byte for byte.

AI-drafted from 5 sources. This story was written with AI from the outside reporting listed under Sources, and checked by automated tools before it went up. The originals have the full detail.

A project on GitHub has finished a complete decompilation of Resident Evil 4 for the GameCube, meaning every line of the game's original machine code has been rewritten as readable C and C++ that compiles back into the exact same bytes as the disc. The repository, run by a developer using the handle adonis-singh, targets the G4BE08 debug build of the game, sometimes called the “Nov 25 2004” prototype, and covers both of its discs.

Decompilation is different from emulation. An emulator translates a game's original code on the fly, guessing at hardware behaviour as it goes. A decompilation instead reconstructs the source code itself, so it can be recompiled, read, and modified like any other software project. Doing that for a commercial console game usually means matching the compiler's exact output, register by register, which is fiddly and often incomplete. According to the project's GitHub page, this one claims something stronger: every one of the game's 1,083 build objects and 15,641 functions compiles back to bytes identical to the original disc, verified by a checksum file that the build system runs automatically.

Why byte-identical matters here

The debug build shipped with its own Bio4.sym symbol files, which name every function Capcom's programmers wrote. That gave the project real names to work from rather than guesswork, and the source tree that results, around 555,000 lines of code plus 33,000 lines of headers, keeps Capcom's own module layout: one REL file (a relocatable overlay used to load extra code at runtime) per room, separate folders for enemies, weapons and player characters, and the in-game debug editors Capcom used during development.

The trickier part was the compilers. Capcom's own code was built with an old version of GCC via Sony's SN Systems ProDG toolchain, while the CRI middleware libraries and Nintendo's SDK used Metrowerks CodeWarrior. Both are notoriously picky about how source code has to be shaped to produce a specific instruction sequence. The project's documentation says an earlier version of the tree patched around this with roughly 200 hand-placed assembly instructions; those have since been replaced with ordinary C, leaving only a small number of documented compiler workaround comments and the handful of routines, mostly low-level math kernels and hardware-specific code, that Capcom's own programmers wrote in assembly in the first place.

What it opens up

None of this includes any of Capcom's actual game files. Anyone wanting to build the project still needs their own copy of the debug discs, which the build reads from at configure time, so this is a toolkit for working with the game's logic rather than a way to get the game itself. What it does hand over is a fully readable engine: every enemy behaviour, every scripted room event, every weapon calculation, in ordinary code that can be studied, ported or extended.

That is already happening elsewhere. A separate effort covered by Retro Dodo has developer Alessio Tosto, known as Rinnegatamante, working on a PS Vita port of the GameCube version, which he has said is “a debug build so there might be some extra work to do to strip off extra bloat”. Whether that project draws directly on this decompilation isn't confirmed, but the timing and the shared debug build are hard to ignore.

What's still unclear is how Capcom might react. Decompilation projects for commercial games occupy a legal grey area: the code is original writing, not copied from the disc, but the practice has drawn takedown requests for other games in the past. The discussion thread on Hacker News has developers picking through the project's compiler notes rather than debating that risk, for now. For preservationists, the appeal is straightforward: a byte-identical decompilation is about as close as anyone gets to having the original developers' source code without actually having it.

Sources

Image: Illustration: AI-generated for Gaming World

More news from Gaming World