# Rugrats in Paris: The Movie, recompiled A **static recompilation** of the Game Boy Color game *Rugrats in Paris: The Movie* (THQ / Software Creations, 2000) into native C. It runs as a Windows program built from **your own ROM**. ![Title screen, the Reptar-bot factory stage and the plane stage running in the recompiled build](docs/screenshots.png) The game's SM83 machine code is translated to C ahead of time and compiled with clang. [SameBoy](https://github.com/LIJI32/SameBoy)'s core provides the Game Boy Color hardware: picture processor, sound, timers, DMA and cartridge mapper. SameBoy is one of the most accurate GBC emulators available. The recompiled code drives that hardware with the same bus accesses at the same clock cycles as a real CPU. Every build can be checked **frame by frame against SameBoy's interpreter**, and the two have to match exactly. > **No game data is in this repository.** No ROM, no graphics, no generated code. You need your own legally obtained copy of the US cartridge dump. The build reads it locally, and everything derived from it stays on your machine (`generated/`, `work/` and `build/` are git-ignored). --- ## Status | | | |---|---| | Boots to the title screen in a window | ✅ | | Full-speed gameplay (menus, minigames, Reptar-bot stages, plane stage) | ✅ | | Recompiled output identical to the interpreter (screen + all RAM, every frame) | ✅ 6,000 idle frames + 20,000 and 30,000 frames of randomised play | | Share of traced ROM instructions that are recompiled | **100 %** (6,369 blocks) | | Interpreter fallback for anything not recompiled | ✅ logs it so the next build covers it | | Keyboard + game controller, integer-scaled window, fullscreen, fast-forward | ✅ | | Audio | ✅ | | Saves | Not needed: the cartridge has no save RAM (the game uses passwords). Save states and rewind are built in. | | Research tools | Collision overlay, level collision map, tile/map viewer, sprite boxes, RAM search, disassembler | What still runs in the interpreter: the boot ROM; `HALT`/`STOP` (they do nothing between interrupts); the game's OAM-DMA routine, which it copies to HRAM and so isn't ROM code; and any ROM path the code discovery hasn't seen yet. In a 30,000-frame random-input run that last group came to 137 dispatches. ## Download [**Releases**](https://github.com/goblinbutler-was-taken/RugratsParisRecomp/releases) are built by GitHub Actions on every `v*` tag: * **`…-windows-x64-interpreter.zip`**: ready to play with your own ROM. It runs the game through SameBoy's interpreter and includes every tool below (collision overlay, level viewer, save states, rewind, cheats). It contains no game code, which is why it can be distributed. * **`RugratsParisRecomp--windows-x64.zip`**: the build kit, meaning this repository with SameBoy bundled under one top-level folder. Unzip it and double-click **`Setup.exe`**: pick or drop in your ROM (it checks the SHA-1), press Build, watch the progress, then press Play. Or run `build.ps1 -Rom -NoPrompt` (unattended: no prompts or windows; exit code 0 only when `build\RugratsParis.exe` exists). Launchers such as Recompendium use exactly this. For [RecompLauncher](https://recomplauncher.com) the kit includes a `recomplauncher.json`: it asks for the ROM, runs `Setup.exe --prepare ` (the same build, no window), then starts `build\RugratsParis.exe --data {data}`. The **natively recompiled** exe is never offered as a download, because it contains the game's code translated to C. You build it on your machine from your own ROM. ## Building Requirements (Windows 10/11, x64): * **Your ROM**: `Rugrats in Paris - The Movie (USA)` for Game Boy Color, SHA-1 `f4cdc771299e9e6539443a9c9d62d3842877e618`. * Nothing else needs to be installed. The build downloads its own pinned tools into `.tools/`: llvm-mingw clang, SDL2, Ninja, a portable CMake and the python.org embeddable Python. Every download is checked against a pinned SHA-256, and nothing is installed system-wide or needs admin rights. * Git only if you clone. The release zip `RugratsParisRecomp--windows-x64.zip` already includes the SameBoy sources. ```powershell git clone --recursive https://github.com/goblinbutler-was-taken/RugratsParisRecomp.git cd RugratsParisRecomp .\build.ps1 -Rom "D:\path\to\Rugrats in Paris - The Movie (USA).gbc" .\build\RugratsParis.exe ``` The first build takes a minute or two, mostly downloading the tools. The code addresses the recompiler needs ship in `data/code-seeds.txt` (addresses only, no game bytes), so setup skips tracing. `-Retrace` rediscovers them from your ROM instead. Later `.\build.ps1` runs reuse the ROM path saved in `build\RugratsParis.ini`. Add `-Verify` to finish with the differential test against the interpreter. ## Controls | Game Boy | Keyboard | Controller | |---|---|---| | D-pad | Arrow keys | D-pad / left stick | | A | X | A | | B | Z | B / X | | Start | Enter | Start | | Select | Backspace / Right Shift | Back | | Key | Extra | |---|---| | F1 | help overlay with every key | | F2 | **viewer window**: VRAM tiles, both BG maps with the visible screen marked, and the whole level's collision map with the camera marked. **Click the level map to warp there.** | | F3 | sprite boxes (every OAM sprite outlined) | | F4 | info panel: fps, recompiled share, level map, camera metatile, banks | | F8 | **collision overlay**: red solid, green one-way platform, blue slope, other colours for special tiles (ladders, switches, hazards) | | F9 / F10 | hide sprites / hide background | | F5 / F7, 1–9 | save / load state, pick a slot (saved in `states\` next to the exe, or in `--data DIR` / `RECOMPLAUNCHER_DATA` when set) | | hold R | rewind (up to 60 s) | | F6 | cheats on/off: infinite energy, frozen timer, invincibility, all collectibles, infinite retries, max tickets, plus your `cheats.txt` codes | | Home | moon jump (hold B) + mid-air jump (tap B) on/off | | End | walking speed: 3 (normal) → 4 → 5 → 6 → 1 → 2 px per step; Shift+End steps back | | PgUp / PgDn | level select, on any stage's briefing screen (then START) | | F12 | screenshot (saved in `screenshots\`) | | Tab | fast-forward | | F11 / Alt+Enter | fullscreen | | Esc | quit | ![Collision overlay (F8) and sprite boxes (F3) in the Reptar-bot factory](docs/overlay.png) ### Cheats Put a `cheats.txt` next to the exe with one cheat per line: `Name = CODE[, CODE…]`. GameShark codes (`01VVAAAA`) work as-is and are toggled with F6. They work through SameBoy's cheat engine, so they also apply to recompiled code. Game Genie codes patch ROM *reads*. They affect data, but not instructions that have already been recompiled into C. Built in, all found by reverse-engineering and verified in-game ([docs/reverse-engineering.md](docs/reverse-engineering.md)): | Cheat | Key | How | |---|---|---| | Infinite energy | F6 | vetoes writes that lower energy (`C04E`) | | Frozen timer | F6 | puts the ASCII clock (`C1D6`) back when it ticks down | | Invincibility | F6 | holds the post-hit immunity timer (`C18B`); Tommy blinks | | All collectibles | F6 | collected (`C174`) = stage quota (`C1B3`), so the exit advances you | | Infinite retries | F6 | keeps continues (`DA25`) at 5 | | Max tickets | F6 | keeps tickets (`DA0B`) at 50, the game's cap | | Moon jump / mid-air jump | Home | resets the jump-hold counter (`C12B`) while B is held / restarts the jump state on a B tap in the air | | Walking speed | End | 1–6 px per step instead of 3, on the ground and in the air. The speed is an operand in the game's code (`00:2302`, `2357`, `26EC`, `2725`), so the recompiler emits a variable there; see below | | Level select | PgUp/PgDn | sets the activity (`DA11`) on the briefing screen | **Walking speed.** Tommy moves 3 px per step, and a stage steps every third frame, so normal walking is 60 px a second. End cycles 3 → 4 → 5 → 6 → 1 → 2; the F4 panel shows the current value. 1 and 2 are for lining up pixel-exact positions, 4–6 for getting around. Nothing in RAM holds this speed, and changing ROM bytes can't reach code that is already C. So for these four operands only, `tools/recomp.py` emits a read of a runtime variable in place of the constant, and the interpreter gets the same value through a read hook. Both builds behave the same with the cheat on, and with it off the build is still frame-identical to the interpreter. What was checked, and why the range stops at 6: * Walls: the game tests one point at the new position, so a step of up to 16 px can't skip a 16 px tile. Tested at 1–12 px from a range of starting offsets: Tommy never enters a wall. He stops up to (speed − 1) px short of it, because a blocked step doesn't move him at all. * Slopes: up and down at 1–12 px he stays on the surface, pixel for pixel, and never drops into the falling state. * Camera: it scrolls at most 8 px per step. At 6 Tommy still runs in the trailing half of the screen; at 8 he is in the middle with the camera flat out, and beyond that he leaves the screen, where the game freezes everything. That's the reason for the cap. * Slow speeds and conveyors: a jump keeps the conveyor's ±2 px momentum, and the game's 8-bit arithmetic there wraps X by 256 px when the walking speed is below 3 (at 1 or 2, a jump against the belt teleported Tommy off the map). While he carries that momentum, speeds 1 and 2 therefore act as 3 in the air. * Jumps cover more or less ground with the speed, so some gaps become crossable and others stop being so. A conveyor moves Tommy 2 px per step, so at 1 or 2 he can't walk against one. Jump is **B**; A pulls levers. Passwords aren't encoded. The game compares against 8 plain-text strings, so here they are: | Password | Difficulty | Unlocks | |---|---|---| | `QPRCHJNY` / `WQBTYPFG` | 1 / 2 | chapter 1 done, 3 tickets | | `HCRGLWXS` / `ZPWXVYDG` | 1 / 2 | chapter 2, 6 tickets | | `ZKHMRTBS` / `YHGMSWCK` | 1 / 2 | chapter 3, 10 tickets | | `KFTYCBNW` / `RGJVBTYL` | 1 / 2 | everything; straight to the final stage's briefing | ## Glitch hunting The overlay and the level viewer come from reverse-engineering the game's collision system ([details](docs/reverse-engineering.md)). Levels are grids of 16×16 metatiles. Each metatile ID has a solidity type (`D500` table) and a special type (`D600` table). The game also **never pushes the player out of solid tiles**, so anything that gets Tommy inside a wall keeps him there. Two **confirmed, reproducible glitches** in the Reptar-bot factory tower (found by warping to candidate spots and running scripted and random input; step-by-step reproduction in [docs/glitches.md](docs/glitches.md)): 1. **Wall climb into the void (softlock).** At the top of the tower, by the one-way ledge on row 17 (column 9; mirrored at column 32), Tommy can jump up *into* the stepped solid outer wall. There's no ceiling bump, and the game never pushes him back out, so each further jump carries him about two rows higher inside the wall. He ends above the drawn level, in empty space, where he can't move until the timer runs out. You can reach it by playing normally (random input found it on its own about 40 times). 2. **Lift clip-through.** Riding the lift beam at columns 20–21 *down* over the machine block (rows 37–38, and the copy at rows 189–190) carries Tommy straight through the solid block and the spike row with no damage, onto the floor below. It doesn't work going up. Ruled out: - The pillar gap on row 72 can't be reached. - The slope-to-corner seams held up through about 2,300 test runs. - The single-cell ledges cut into the outer walls always block him. - The yellow columns are lift beams, not ladders. - Dropping through the one-way starting floor doesn't work. ## How it works ``` your ROM ──► tracer (SameBoy interpreter, headless, scripted + random input) │ coverage: every ROM address executed, and which ones were jumped to ▼ tools/recomp.py ── recursive-descent disassembly from those seeds, │ bank-aware, SM83 → C, one function per block ▼ generated/*.c (git-ignored, contains the game's code) │ ▼ RugratsParis.exe = generated C + runtime (dispatcher, SDL2 frontend) + SameBoy core (PPU, APU, timers, DMA, MBC5, interpreter) ``` **1. Code discovery ("tracing").** A Game Boy ROM mixes code and data (graphics, music, maps) with nothing marking which is which. Much of this game's code is only reachable through jump tables and computed jumps (`jp hl`), whose targets exist only at run time. Static disassembly from the entry points finds about 300 blocks; tracing adds about 6,000. The trace results ship as `data/code-seeds.txt` (13 runs: idle plus 12 random-input runs of 40,000 frames), so installs don't repeat them. The build first runs the game in an interpreter-only build (`RugratsParis_trace.exe`), headless at several times real-time speed. That includes an idle run through the attract mode and credits, plus several runs of random input that reach the menus, minigames and stages. Each run records every ROM address the CPU executed, together with the active MBC5 bank, and marks the ones it reached by a jump. Those become the seeds. `recomp.py` then follows control flow statically from the seeds and the interrupt and `RST` vectors to find more code. It also tracks simple `ld a,N / ld ($2000),a` bank switches to resolve far calls. **2. Recompiler.** Each *block* is a run of instructions at a given (bank, address), and becomes a C function. A block ends at an unconditional jump, call, return or another block's entry. Because ROM never changes, a block is a correct translation of its bytes however it was found; discovery only decides how much is covered. The one exception is a short list of *live immediates* (`LIVE_IMM` in `recomp.py`, currently the four walking-speed operands): there the C code reads a runtime variable whose default is the ROM byte, so a cheat can change it while the game runs. Each instruction is emitted as calls to small inline helpers. These mirror SameBoy's `sm83_cpu.c` M-cycle by M-cycle: opcode fetch, operand fetch, the read/write timing including SameBoy's write-conflict handling, and the internal cycles. Self-loops become `goto`s, and flags are computed exactly as SameBoy computes them. `EI` is compiled with its one-instruction delay. After each instruction the code checks for a pending interrupt. Code running from a switchable bank checks after a write whether the bank changed under it. **3. Runtime.** A dispatcher looks up the function for `(current bank, PC)` in a direct table and runs it. Interrupt entry, `HALT`, `STOP`, the boot ROM, code in RAM and unknown addresses go to SameBoy's own interpreter, one instruction at a time. Control returns to recompiled code as soon as it reaches a known block. SameBoy also paces the game to real time. The frontend is SDL2: a window with integer scaling and colour correction, audio, keyboard and controller. **4. Coverage feedback.** Any ROM code the interpreter had to run while you play is appended to `build/coverage-play.txt`. The next `.\build.ps1` feeds it to the recompiler, so coverage grows as you play. **5. Differential verification.** `tools/verify.ps1` runs the recompiled build and the pure interpreter (`--interp`) with identical deterministic input. It compares an FNV hash of the framebuffer plus all WRAM and HRAM after every frame. `--steplog` with `tools/stepdiff.py` finds the first block whose CPU state or cycle count differs from the interpreter. That's how the remaining timing bugs were found: a conditional `RET` charged one M-cycle too many, and the `EI`-while-IME-already-on case. ## Command line ``` RugratsParis.exe [rom.gbc] [options] --interp everything through the interpreter (reference mode) --headless no window/audio, run as fast as possible --frames N quit after N frames --screenshot FILE save the last frame as BMP (with --every N: FILE_.bmp every N frames) --hash-log FILE per-frame hash of screen + RAM (for diffing runs) --coverage FILE write the ROM addresses the interpreter executed (recompiler input) --input FILE scripted input, lines of " ", e.g. "3000 START" / "3010 -" --fuzz-from N random input from frame N (deterministic, --seed N) --steplog FILE log CPU state at every step between --steplog-from/--steplog-to frames --scale N initial window scale (default 4) --overlay LIST collision,sprites overlays, also drawn into screenshots --load-state FILE load a save state at start; --save-state FILE save one at exit --poke F:ADDR=HEX write bytes to RAM at frame F (repeatable) --cheat LIST built-in cheats, comma-separated: energy,timer,retries,tickets,invincible, items,moonjump,airjump,speed=N (walking speed 1-6, normal 3), e.g. --cheat speed=5,energy --dump-ram PREFIX dump WRAM+HRAM every --dump-every N frames (for tools/ramsearch.py) --read-trace FILE interpreter mode: log which code reads which ROM/RAM ranges ``` `RugratsParis_cli.exe` is the same program as a console app, for logs and headless runs. ## Repository layout ``` build.ps1 one-command build (tools → trace → recompile → compile) tools/recomp.py the SM83 → C static recompiler tools/verify.ps1 recompiled-vs-interpreter differential test tools/stepdiff.py finds the first diverging block in two step logs tools/disasm.py small SM83 disassembler (reverse engineering) tools/ramsearch.py RAM search over --dump-ram dumps tools/levelmap.py renders a level's full collision map from a RAM dump tools/wallgaps.py scans a level for gaps in its outer walls runtime/tools.c overlays, viewer window, collision decoding, built-in cheats runtime/text.c overlay text (GDI) tools/setup-tools.ps1 fetches llvm-mingw, SDL2 and Ninja (pinned SHA-256) runtime/rc_runtime.h helpers the generated code calls (cycle-exact bus access, ALU) runtime/rc_bridge.c builds SameBoy's interpreter and exposes its cycle_write() runtime/rc_dispatch.c block dispatcher, interpreter fallback, coverage logging runtime/main.c SDL2 frontend + headless/test modes runtime/cgb_boot.h SameBoy's open-source CGB boot ROM (MIT), not Nintendo's third_party/SameBoy git submodule, v1.0.5 ``` ## Known gaps * Code paths that neither the traces nor static analysis reached run in the interpreter until a play session logs them and you rebuild. They still run correctly, just interpreted. * Code that crosses the boundary between banks, or between the fixed and switchable regions, is handed to the interpreter at that point. * If the cartridge bank changes while code runs from the switchable bank, the block exits and re-dispatches. That's correct, but not the fastest path. * Windows x64 only for now. The runtime is portable C and SDL2, so Linux and macOS builds should be straightforward. * No in-game menu yet: options are keyboard shortcuts and command-line flags. * The collision overlay and level viewer understand the side-scrolling stages. The minigames and the plane stage use other layouts that aren't decoded yet. ## Roadmap * **Done:** tile and map viewer, level collision map, collision overlay, sprite boxes, layer toggles, save states, rewind, fast-forward, screenshots, GameShark cheats. * **Also done:** warp (click the level map), infinite energy, timer freeze, Setup.exe GUI, walking-speed cheat (the recompiler's first live immediates). * **Next:** the same glitch hunt in the other stages (jungle, temple, cave, warehouse, tower, plane); a per-object hitbox overlay from the object table; a RAM watch for position and speed. * **Widescreen:** the game redraws a 160 px-wide tile buffer each frame (`C280`), so widescreen means widening that buffer and the camera, not just showing more of VRAM. It's possible, but it needs the camera code patched. * **Quality of life:** remappable controls, an in-game options menu, Linux and macOS builds. ## Credits and legal * **[SameBoy](https://github.com/LIJI32/SameBoy)** by Lior Halphon (MIT). Hardware emulation, interpreter and boot ROM. * **[SDL2](https://libsdl.org)** (zlib). Window, audio and input. * **[llvm-mingw](https://github.com/mstorsjo/llvm-mingw)** by Martin Storsjö. Compiler toolchain. * Inspired by the wider static-recompilation scene, including N64Recomp and [gb-recompiled](https://github.com/arcanite24/gb-recompiled). *Rugrats in Paris: The Movie* is © Paramount Pictures and Viacom International. Rugrats is a trademark of Viacom International and was created by Klasky Csupo. The game was published by THQ and developed by Software Creations. This project isn't affiliated with or endorsed by any of them. It contains no copyrighted game data, and you need your own copy of the game to use it. The code in this repository is MIT licensed (see `LICENSE`). Third-party components keep their own licenses.