Rebuilding Games in Rust: AI Turns Binaries Into Portable Source
[!NOTE] TL;DR: The same pipeline that powers pass-through mods can go all the way: decompile a whole game, reimplement it in Rust, and compile it for platforms it never shipped on. The hard part is no longer reading the binary — it is porting the mechanics, and agents are doing that too.
Modding changes a function. Rebuilding replaces the program. The video’s most ambitious segment shows agents taking a compiled binary, producing a clean-room Rust reimplementation, and compiling that for a different platform — the difference between remodeling a room and re-drawing the blueprints.
Table of Contents
From Pseudocode to Compilable Rust
The pipeline reuses the decompilation stack — Ghidra-MCP, IDA-MCP, Cpp2IL — but the goal changes. Instead of patching one function, the agent walks the whole binary and produces a parallel codebase: data structures, game loops, and logic re-expressed as compilable Rust.
Two properties make this feasible now. Context windows are large enough for the agent to keep the original’s semantics in view while writing hundreds of lines of replacement code. And the output is checkable: a rebuild either compiles and reproduces the original behavior, or it doesn’t — giving the agent a tight, automatic feedback loop that decompilation alone never had.
Why Rust Is the Target Language
The choice is deliberate, not fashion:
- Portability. Rust compiles to essentially every target that matters — desktop, console SDKs, handhelds — from one codebase, which is the entire point of a port.
- Memory safety without a runtime. Reimplementing pointer-heavy game logic is where manual ports introduce the most bugs; the borrow checker turns that error class into compile errors the agent must fix.
- Strong typing as a forcing function. Reconstructing vague decompiled types into real
structs andenums is exactly the “make invalid states unrepresentable” work that produces a faithful rebuild rather than a sketch.
Platform Compatibility Is the Real Work
Moving the logic is only half the port — the edges are where projects die. The platform-compatibility layer is everything the original got “for free” from its environment:
- Graphics and API calls. DirectX assumptions have to be re-expressed against Vulkan, Metal, or a console SDK’s graphics API.
- OS surface. File paths, input handling, timing, and threading models differ per platform and all need shims.
- Width and endianness. Code built around a console’s fixed memory layout often carries silent assumptions that break on a different architecture.
This is precisely the kind of systematic, enumerate-every-callsite labor agents are good at — the part human porters describe as weeks of tedium.
Porting Mechanics, Not Just Code
The video’s subtle point: a faithful port reproduces behavior, and behavior lives in mechanics — physics constants, frame-timing quirks, difficulty curves, the accidental-feel of the original. Agents approach this empirically: run both versions, compare behavior, tighten the reimplementation until the mechanics match, not just the call graph. That loop is why AI-built ports are converging faster than the “decompilations are never playable” conventional wisdom predicted.
The PS5 Ports: AnyPS5 and PortPS5
The flagship examples are console ports — AnyPS5 and PortPS5 — projects pushing rebuilt titles onto PS5 hardware. Console ports are the stress test: a fixed platform with a proprietary SDK, strict memory budgets, and no tolerance for abstraction overhead. If an agent-produced Rust rebuild runs there, the portability claim is no longer theoretical.
Frequently Asked Questions
Q: Is the rebuilt game the same code as the original? A: No — it is a reimplementation. The agent reconstructs observable behavior and logic in new Rust source, roughly like a clean-room rewrite. The output compiles independently and shares no files with the original binary.
Q: Why not just emulate the original instead of porting? A: Emulation reproduces the original hardware’s behavior at a constant performance and fidelity cost. A source-level port compiles natively for the target — better performance, moddable code, and no emulator dependency — at the price of the reimplementation work AI now automates.
Q: What breaks when porting to a console like PS5? A: The platform layer: graphics APIs, input, storage, memory model, and the proprietary SDK surface. The game logic ports relatively cleanly once reconstructed — the platform-compatibility layer is where most of the remaining human effort concentrates.
Q: Can the agent port a game it can’t fully decompile? A: It can produce a partial port, and good pipelines report coverage honestly — which subsystems were reconstructed versus approximated. Incomplete decompilation shows up as behavioral mismatches the run-and-compare loop then has to chase down.
Q: Are AI-produced game ports legal to distribute? A: The code may be new, but the game assets, design, and IP are not — distributing a rebuilt game still requires owning the rights or the publisher’s blessing. These projects are most defensible as preservation research or ports for personal use, similar to the decompilation scene’s established norms.