Skip to content
Open-ApePublic

About

Experimental static recompilation of Ape Escape 3 (PS2), used as a research tool. The PC port will be built from ae3-decomp.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

reape3

reape3 is an experimental static recompilation of Ape Escape 3 (PlayStation 2, NTSC-U SCUS_975.01), part of Open-Ape, my umbrella project for the Ape Escape games on PC.

reape3 is a research tool, not the PC version. It runs the game's original program on a model of the console, which makes it useful for tracing and checking how the real game behaves. The planned PC version is a native port built from the ae3-decomp decompilation, the way OpenGOAL and OpenRAC brought their games to PC: the game's own code rebuilt as a normal PC program with its own renderer, no emulation.

You cannot build the game from this repository, even with your own disc. The recompiled game code and the scripts that produced it are not published, there is no launcher yet, and the repository contains no prebuilt program and no game files.

Its build boots to gameplay but is slow (see the status below), and its findings feed the decompilation.

reape3 and Open-Ape are unofficial projects. They are not affiliated with or endorsed by Sony Interactive Entertainment. Ape Escape is the property of Sony Interactive Entertainment; the names Ape Escape and PlayStation are used here only to identify the game and the console this software targets.

Status

This table describes my own build as I tested it on 2026-11-29 and 2026-11-30. That build includes parts that are not in this repository (see below the table), so it is not what a checkout gives you.

Area State
Boot, logos, opening movies (picture) Works
Title, name entry, character select, tutorial stage, hub Reached and played
Hub shopping area Loads (fixed 2026-11-29; before that, a black screen). Only its first text box was seen
Warp Pad, first stage Loads (fixed 2026-11-30; before that, a white screen). Walked around briefly; distant windmills fixed on the GPU renderer the same day
Saving and loading (memory card) Works: the game's own card code runs; saving at the hub and loading back were verified
Controller Tested with a PS5 DualSense; follows the controller that was last used
Sound Plays. The game's own sound driver runs against an emulated SPU2. A 73-second recording (logos, title, loading a save, hub) was judged correct by ear, and reverb is audible in a second recording. At the current speed, live playback comes in bursts with gaps
Speed Slow, improving. On 2026-11-30, with the optional GPU renderer, the GS render thread and the optional vector-unit thread: about 28% of real PS2 speed in the menus and about 25% in the first stage. On 2026-11-29 it was about 12% in the hub
Rest of the game Not tested

The status above cannot be reproduced from this repository. The recompiled game code is derived from the game and is not published, and neither are the scripts that produced it or the small hand-written hook that connects the movie decoder to the game's movie player. What is here is the recompiler and the runtime (the part that stands in for the console) with my changes, plus the function map and recompiler configuration I used. AE3.md lists what is left out, the test machine, and the changes made on top of upstream.

What "accuracy first" means here

These are aims. Where the project does not meet them yet, it says so.

  • The game's own code is preferred over hand-written replacements. The memory card is an example: the game's card library runs unmodified and is answered at the driver level. This is not yet true everywhere: the game's CD library calls are bound to runtime handlers (see ae3-config.toml), and movie pictures are decoded by FFmpeg through a small hand-written hook instead of the game's own MPEG library.
  • Emulated hardware is meant to be exact before it is made fast. The vector-unit interpreter's pipeline-timing model comes from PS2Recomp. My speed-ups to it were written to leave its results unchanged, but only some were tested for that: three arithmetic rewrites were compared with the old code on very large numbers of inputs without a difference, using test programs that are not in this repository. The other speed-ups rest on reasoning and on in-game frames; no bit-for-bit comparison of a whole run was made. The optional GPU renderer, which the speed figures above use, is not bit-identical to the software renderer.
  • The aim is a test that fails before a fix and passes after it. The dispatcher and memory-card fixes have such tests in this repository (ps2xTest/src/ps2x_dispatch_yield_regression.cpp, ps2xTest/src/ae3_host_memory_card_regression.cpp). Not every fix has one: some earlier fixes were checked only by running the game, and the tests that link recompiled game code are not published.
  • Claims are limited to what was measured. "Works" in the table above means it was observed working on the test machine, not that it is finished.

Roadmap

There are two tracks. The first exists; the second is the long-term goal.

Track 1: static recompilation (what this repository holds today). The game's machine code is translated to C++ by a tool and runs against a runtime that stands in for the console.

  1. Known accuracy bugs in the recompiler's output. The first one is fixed: sign-test branches (BLTZ, BLEZ, BGTZ, BGEZ and their likely and link variants) compared 32 bits where the PS2's CPU compares 64. The recompiler now emits the 64-bit test, with a regression test. I found out that my build had this bug from the fix list of Yuukii-i/ApeEscape3_Recomp. Others will be listed here as they are found.
  2. Sound: done as far as the game has asked for it (voices, envelopes, volumes, mixing, reverb, output). Not modelled: streamed sound input and the SPU2 interrupt, which the game has not used so far. Three reverb details that the documentation leaves open are my choices and are not checked against a console (see the changelog).
  3. Speed, without giving up exactness. The vector unit (VU1) is the bottleneck. A record / replay harness checks every faster path against recorded runs of the game, register for register and cycle for cycle. So far: a cache of instruction timing, a faster exact register path, and running the vector unit on its own thread while the game only ever sees the values it would see on a PS2. Together they roughly doubled the game's speed (see the status above), with 0 differences on the recordings. Generated native code for the vector unit, held to the same check, is the next step; it is not started.

Track 2: matching decompilation (started: ae3-decomp). Source code that compiles back to the original game's code byte for byte, so the share of the game that is reconstructed is a number anyone can check. The original compiler is identified (Sony's EE GCC 3.2 with -Os), and about a third of the game's roughly 25,000 functions match, most of them small ones (about 5% of the code by size). It is a long project.

After that

  • Launcher: point it at an image of your own disc and play. New code, written for this project, and not designed yet. How a player would get the game's code is an open question; nothing derived from the game is published here.
  • Other games: Ape Escape 2 and Ape Escape: Pumped & Primed are ideas for later. Nothing has been done on them, and nothing in this repository supports them.

No dates are promised. Progress is recorded in AE3_CHANGELOG.md.

History

This repository starts from my own build as it stood on 2026-11-29. The tag baseline-2026-11-29 marks that state (my build predates finding the other AE3 recomp mentioned below); AE3.md and the changelog explain how it was fixed and why the commit dates are later.

Related projects

  • PS2Recomp by ran-j and contributors is the recompiler and runtime reape3 is built on. Its original README is kept as README.PS2Recomp.md.

  • Yuukii-i/ApeEscape3_Recomp is a separate recompilation of the same game, also built on PS2Recomp, and it is much further along on speed: built on my PC on 2026-11-29, it ran the hub at about 60 frames per second. If you want to play Ape Escape 3 on PC today, look at that project. reape3 is independent of it (my build predates finding it, see History) and uses none of its files.

    How the two differ. As far as I can tell from its code and documentation, much of its speed comes from running the game's vector-unit programs through a fast hand-written model that reproduces what those programs produce (the graphics data and memory they write), with the exact path as a fallback. That is a legitimate choice and it works. reape3 makes a different one: the vector unit stays an exact model of the hardware (every register, flag and cycle), and it is made faster only in ways that a recording of the original behaviour can prove changed nothing. The same rule applies elsewhere, for example the game's own memory-card code runs instead of a replacement. This is why reape3 is slower today; the aim is to close that gap without giving up exactness, and the matching decompilation (track 2) is a second, long-term route to the same game.

    Comparing the two builds taught me things: for example, the sign-test bug at the top of the roadmap (now fixed) was found by checking that project's list of fixes against my generated code. Anything learned this way is credited in the changelog when it is used.

  • OpenRAC, a matching decompilation and PC port of the Ratchet & Clank series, is the inspiration for track 2 and for the launcher goal.

Building

A checkout configures with CMake's default options. From a clean checkout I built the runtime library, the IOP emulator and three of the tests that need no game code (memory card, controller backend, dispatcher) with Visual Studio 2026 (MSVC, x64), and those three tests pass. I did not build the other targets from a clean checkout. See README.PS2Recomp.md for the upstream build instructions.

Licence and credits

GPL-3.0, the same as PS2Recomp. See LICENSE.

  • PS2Recomp by ran-j and contributors.
  • SIO2 / DualShock 2 device files adapted from TaylorNAlbarnaz's PS2Recomp fork (noted in the file headers).
  • parallel-gs by Hans-Kristian Arntzen (LGPL-3.0-or-later) and Granite (MIT), used through their public API for the optional GPU renderer.
  • FFmpeg for MPEG-2 decoding; raylib, Dear ImGui and the other libraries upstream already uses.
  • The psx-spx documentation for the SPU's sample decoding, Gaussian interpolation table, envelope and noise behaviour.
  • Most of the analysis and implementation was done with Claude Code (Anthropic), using the Claude Fable 5.2 and Claude Opus 5.5 models, directed and play-tested by me.

About

Experimental static recompilation of Ape Escape 3 (PS2), used as a research tool. The PC port will be built from ae3-decomp.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages