Concept

Recompilation

Recompilation is the process of translating a program already compiled for one processor into code for another. In games, static recompilation converts a console executable into C or C++ ahead of time and compiles it into a native program, so the game runs without an emulator interpreting its instructions.

EmulationStatic recompilationDecompilation
When code is translatedWhile the game runsOnce, before launchBy hand, over years
OutputNone keptGenerated C / C++Readable C / C++
Human effort per gameLowMediumVery high
Typical resultRuns many gamesNative port of one gameSource that rebuilds the original

How static recompilation works

A static recompiler reads the game's executable, finds its functions by following control flow, and emits one block of C or C++ per function. Each machine instruction becomes an equivalent operation on a structure that holds the console's registers. The generated code is compiled with an ordinary modern compiler and linked against a runtime that stands in for the console: memory, the operating system calls, graphics, audio and input.

The translation is literal. A MIPS instruction such as an add-immediate becomes one line of C that adds a constant to a register field. That makes the output hard to read, but it can be produced for an entire game without manual work.

Recompilation versus emulation

An emulator decodes the game's instructions while it runs, either one at a time or through a just-in-time compiler. A recompiled game was translated before it was ever launched. The practical gains are performance and freedom: patches for widescreen, frame rate and controls can be written against native code. The trade-off is coverage, because code the recompiler did not find, or code generated at runtime, needs special handling.

Recompilation versus decompilation

Decompilation aims for readable source code written by people and verified to rebuild the original binary. Recompilation aims for a runnable program and accepts unreadable output. The two are often combined: decomp knowledge identifies functions and data, and recompilation covers what has not been decompiled yet.

Tools used by current projects

N64Recomp targets the Nintendo 64, XenonRecomp targets the Xbox 360 and PS2Recomp targets the PlayStation 2. The projects built with them are listed on the recompiled games list.