David Erik García Arenas
← All projects

Sonic 4: Episode II Research

Rebuilding a 2012 Sonic game in modern C++, checked against the original.

Rebuilding an engine's behaviour and checking it against the original code

Engineering research · Jul 2026 – present

At a glance

Challenge
Rebuild a 2012 game engine whose file formats are undocumented, and show the rebuilt code behaves like the original, not just that it looks right.
Solution
A C++17 engine and Direct3D 9 renderer; selected routines from the original code run in a CPU emulator and are compared with the rebuilt versions.
Result
Zero recorded differences in the compared routines, 52 native, 423 managed and 51 Python tests passing, and a native Direct3D 9 preview of the first act. Prototype.

The problem

The game runs on the AliceNN engine, whose assets use undocumented formats, and reconstructed game code can look right on screen while its results drift from the original's. The work is only worth having if its behaviour can be checked against the original code.

Approach

Original 2012executableMy C++17reconstructionRoutine runs ina CPU emulatorSame routine, 32-and 64-bit buildsResults compared:0 recorded differencesOriginal 2012executableMy C++17reconstructionRoutine runs ina CPU emulatorSame routine, 32-and 64-bit buildsResults compared:0 recorded differences
How behaviour is checked: selected routines from the original run in an emulator and are compared with the rebuilt ones. It covers individual routines, not whole scenes.

Outcome

A native Direct3D 9 preview (15 Sep 2026) renders the first act from a user-supplied copy, using the game's own compiled shaders, with Sonic's movement, rings, sounds and particles connected. An earlier C#/MonoGame prototype (July, phase 1) ran Zone 1 Act 1 from start to goal.

Evidence

Zero recorded differences in the emulator comparisons of the selected routines. 52 native, 423 managed and 51 Python tests pass on synthetic inputs (24 Sep 2026); the repository contains no executables, game archives, audio or disassembly.

Limitations

A prototype. Springs, a complete act, Tails, the HUD and bosses are not done, the comparisons cover individual routines rather than whole scenes, and complete engine and game compatibility are not claimed.

Built with

RepositoryRead the x87 write-up