LibertyFlux

Grand Theft Auto IV's engine, being rewritten in Rust by AI agents one function at a time, so the game can eventually run as a native 64-bit program on Windows, Windows on ARM and macOS.

Phase 0 of 7: measuring the executable. Nothing is rewritten yet and the game is not playable.

The game's code, start to end.

Progress

    How it works, step by step

    AI agents do the rewriting. A machine check, not an agent's opinion, decides when a function is finished. The quality page explains what that check covers, what it cannot see, and every problem known so far.

    1. Measure the executable

      Ghidra, a reverse-engineering tool, analyses the original program. Functions are counted, the compiler's own runtime and third-party library code is set aside, and class names are recovered from the type information the compiler left behind.

    2. Queue the work

      A script orders the functions from easiest to hardest and hands them out one at a time. Agents never choose their own.

    3. Rewrite in Rust

      An agent studies what the function does, with the most similar finished functions as reference, and writes a Rust implementation.

    4. Compare against the original

      The original function and the Rust version are run side by side in a small 32-bit test process, from the same inputs and the same starting memory. If their results, memory writes and outgoing calls agree, the function is accepted. If not, the agent tries again or hands it on.

    5. Swap it into the running game

      Accepted functions are loaded into the original game, each with its own on/off switch. If the game misbehaves, switches are flipped in halves until the faulty function is found.

    6. Cut the original loose

      When every function has a Rust replacement, the Rust code is built on its own, made 64-bit, and given a new renderer.

    What is in the repository, and what never is

    Committed

    • Structures: fields, sizes, offsets, enums, virtual table order
    • Symbols: names, addresses, signatures, hashes, class hierarchy
    • Rust rewrites of the engine's behaviour
    • Tooling, tests and documentation

    Never committed

    • Decompiler output or disassembly, edited or not
    • C or C++ reconstructions of original functions
    • Code copied from other reverse-engineering projects
    • Game executables, data or assets

    Buy the game

    LibertyFlux is not a way to get Grand Theft Auto IV for free, and it never will be. Nothing here contains the game. To use it you need a copy that you paid for: buy it on Steam, from an authorised key seller, or from a retailer.

    Pirated and cracked copies are not supported. This project will never distribute game files, keys, cracks or ways around the game's copy protection. The people who made the game should be paid for it.

    Roadmap

    PhaseWorkFinished whenStatus

    What the rewrite makes possible

    None of this exists yet. These are the reasons for doing the work, and each depends on the phases above it in the roadmap. The pictures are concept images made for this page, not screenshots.

    • Concept painting of a car crossing a suspension bridge at dusk, the bridge streaking past.
      Concept image, not a screenshot.

      Hundreds of frames per second

      The original ties parts of its physics, animation and scripting to the frame rate, which is why it misbehaves above 60. The rewrite runs the simulation at a fixed rate and draws as fast as the hardware allows.

      Planned for phase 6.

    • Concept painting of a row of brownstone buildings, coarse and blocky on the left and resolving to fine detail on the right.
      Concept image, not a screenshot.

      Modern upscaling and frame generation

      DLSS, FSR, XeSS and MetalFX behind one setting. The new renderer is designed from the start to produce the motion and depth information these need, which the original never did.

      Planned for phase 7.

    • Concept painting of a rain-soaked street at night with streetlights reflected in puddles.
      Concept image, not a screenshot.

      Path tracing

      Light that bounces, reflects and casts soft shadows the way it does outdoors, in a city made of wet streets, brick and sodium lamps.

      A stretch goal, after the new renderer exists.

    • Concept painting of a desk with a monitor and two laptops showing the same city skyline.
      Concept image, not a screenshot.

      Native on three platforms

      64-bit Windows, Windows on ARM and macOS on Apple silicon, each as a native build with no emulation layer in between.

      Planned for phases 5 and 6.

    • Concept painting of a busy city intersection seen from a rooftop.
      Concept image, not a screenshot.

      New gameplay and graphics

      Once the engine is Rust that this project wrote, any part of it can change: new mechanics, denser streets, longer draw distances, and mods that reach parts of the engine no script hook can.

      Planned for phase 7.

    • Nothing extra to install. No .NET, no launcher, no Visual C++ or DirectX runtime packages.
    • The game you already own. It uses the data files from your own copy and ships none of them.
    • Old bugs become tests. The community's list of high-frame-rate bugs is the checklist the new simulation has to pass.

    Planned platforms

    PlatformGraphicsUpscaling
    Windows x64Vulkan, with Direct3D 12 optionalDLSS, FSR, XeSS
    Windows on ARMVulkanFSR
    macOS on Apple siliconMoltenVK, then native MetalMetalFX

    Projects this builds on

    The method is borrowed. These projects were studied for how they work, not for their code.

    • Thief 3 decompilation: the work queue, attempt limits, and the rule that workers can only write to scratch space.
    • gta-reversed: replacing functions inside the running game with a switch for each, and compile-time checks on structure sizes.
    • Snowboard Kids 2 decompilation: letting a script pick the next function, and showing agents similar finished work.
    • LibertyRecomp: written-up engine internals from the Xbox 360 version, and what a renderer must supply for modern upscalers.
    • scrDbg: the script engine's layout on the current Steam build.
    • IV-SDK and FusionFix: years of community knowledge about the game's classes and its frame-rate bugs.

    Liberty City deserves a better program around it

    The city, the writing and the physics still hold up. The 2008 PC port around them does not: it is 32-bit, it renders on one thread, and its simulation changes with the frame rate.

    LibertyFlux replaces that program one function at a time, checks each replacement against the original, and keeps the game playing exactly as it did. When the last function is done, everything on this page becomes buildable.

    Background: concept image, not a screenshot.