Skip to content
mstanPublic

About

NES game static recompiler ecosystem · Part of the R.A.I.D. community

Resources

Contributing

Stars

154 stars

Watchers

5 watching

Forks

Repository files navigation

NESRecomp

NESRecomp

A beta static-recompilation framework for NES and Famicom games. NESRecomp translates 6502 code into native C and supplies the PPU, APU, mapper, input and save systems around it. Each port integrates and validates its own cartridge revision.

Famicom Disk System support lives in fdsrecomp. That separate engine uses nesrecomp as a submodule for shared NES hardware, compilation and host code. Start there for FDS disk-image projects.

The ecosystem includes four-player Mario co-op with rollback netplay, adaptive ultrawide views, optional voxel presentation, runtime translations and modern controller support. Features are title-specific, and the framework's beta status does not make every game or mod complete.

Cycle-backend desktop builds with recomp-ui include a save-state browser (F7) and rewind (F8). The browser has twelve thumbnail slots; rewind lets you preview earlier moments and resume from one. Controller shortcuts are Back + L3 and Back + R3. History starts enabled and can be adjusted in the launcher. Local state changes are unavailable during online play.

Desktop cycle titles with HD packs can choose HD resolution in Graphics. Compatible OpenGL contexts render shared jobs on the GPU from 1x to 64x; Pack resolution remains the default. 32x/64x are experimental. Unsupported contexts use the portable CPU path at pack resolution. Zelda Remastered's 16x path is qualified on the owner PC; higher density samples the existing artwork without adding detail.

Play a game · Start a new port without AI

Super Mario Bros.: four players, one adventure

Mario, Luigi, Wario and Waluigi share the same level in the optional Simultaneous Co-op mod. Play with two to four people locally or through rollback netplay; the room settles the shared player count and rules before boot. Team lives, scarce pickups and a shared camera keep it one adventure.

Mario, Luigi, Wario and Waluigi together in World 1-1
Super Mario Bros. — four-player co-op. Local capture of the same game mode available over netplay.

Co-op uses a shared 4:3 camera and excludes widescreen, voxel display and character-replacement mods. See the co-op rules and netplay setup and validation limits.

Ultra-wide NES views

Separately, Mario's experimental renderer offers Fit window, 16:9, 21:9 and 32:9. It extends level terrain, authored enemy loading and independent platforms, with title-specific limits for special spawners and linked objects. Metroid has its own adaptive renderer, showing adjacent room scenery and optional viewport actors. These views preserve the original pixel artwork.

Super Mario Bros. World 1-1 in 32:9, revealing pipes, terrain and enemies beyond the original viewport
Super Mario Bros. — 32:9 single-player view, separate from co-op.
Metroid in 32:9 with Samus, enemies and an item visible across the expanded room
Metroid — experimental 32:9 room view.

Screenshot provenance and feature qualifications are recorded in the showcase sources.

How to use NESRecomp

Use the Windows CLI

  1. Open the Releases page.
  2. Download nesrecomp-cli-windows-x86_64.zip. Do not download GitHub's "Source code" archives.
  3. Extract the zip to its own folder.
  4. Open PowerShell in that folder.
  5. Run:
.\nesrecomp.exe build `
  --rom "C:\Games\MyGame.nes" `
  --output "C:\Projects\MyGameRecomp"

Cartridge projects need no BIOS. For Famicom Disk System projects, use fdsrecomp with a supported disk-system BIOS. The cartridge CLI's output folder contains generated C source, a proposed game.toml, CMake files, and build scripts.

To check that the generated source compiles:

cd "C:\Projects\MyGameRecomp"
.\build.ps1

This builds a static library. It does not create a playable game by itself. Each game still needs game-specific configuration and runner integration. Use one of the Game Projects as a starting point for a full port. Output is generated/<name>_cyc*.c for the cycle runtime (runner/cyc).

If you already have a game.toml, pass it to the build command:

.\nesrecomp.exe build `
  --rom "C:\Games\MyGame.nes" `
  --game "C:\Projects\MyGamePort\game.toml" `
  --output "C:\Projects\MyGameRecomp"

NESRecomp does not include game ROMs.

Platform Support

Platform Status
Windows (x64, MSVC) Primary / mature
macOS (Apple Silicon + Intel) Experimental — newly added
Other UNIX (Linux) Likely works via the same POSIX path; less tested

macOS support is recent and should be considered experimental. The toolchain (recompiler + runner) builds cleanly with Apple Clang and games run natively — The Legend of Zelda, for example, plays well. Individual titles may show minor behavioral quirks that don't appear on Windows (Super Mario Bros. has some known timing/demo differences); please file an issue if you hit one. The macOS/POSIX port was contributed by Nat Budin (@nbudin) in #10 — thank you! 🙏

Game Projects

These summaries were checked against public documentation and release notes on 21 October 2026. Game/mapper coverage and enabled features vary by build; a title/menu check does not establish a complete playthrough.

Game Project Features and scope
Super Mario Bros. SuperMarioBrosNESRecomp Two-to-four-player local/online co-op; separate adaptive/ultrawide, voxel and donor-ROM character mods.
Duck Hunt DuckHuntNESRecomp Mouse-as-Zapper input and native game presentation.
Dr. Mario DrMarioNesRecomp Playable puzzle port; consult current one/two-player validation notes.
The Legend of Zelda LegendOfZeldaNESRecomp Overworld/dungeon gameplay, battery saves and optional voxel diorama; current cycle build still needs a fresh campaign audit.
Metroid MetroidNESRecomp USA/Europe builds, password saves, adaptive/32:9 room renderer and optional viewport actors/voxel view.
Faxanadu FaxanaduRecomp Action-RPG port and runtime text/localization override showcase.
Yoshi YoshiNESRecomp Native puzzle port; see its release notes for current testing scope.
Yoshi’s Cookie YoshisCookieRecomp MMC3 puzzle port with desktop controls and saves.
Mega Man 3 Megaman3NESRecomp Development preview with title/menu and early-stage gameplay.
Gumshoe GumshoeNESRecomp Mouse-as-Zapper action; end-to-end play reported, with title-specific cosmetic limits.
Super Mario Bros. 2 (Japan / The Lost Levels) SuperMarioBros2JapanFDSRecomp Famicom Disk System development preview; exact disk and BIOS required.
Mother / EarthBound Beginnings Mother1NESRecomp Early standalone bring-up, largely untested beyond initial boot/basic play.

Public game downloads are linked from each project's README. Other local development targets include Super Mario Bros. 2/3 and Kirby's Adventure; they are not advertised here as public releases.

Mapper Support

Public examples exercise NROM (Mario and Duck Hunt), MMC1 (Zelda, Metroid, Dr. Mario, Faxanadu and Yoshi), MMC3 (Yoshi's Cookie and Mega Man 3), and GxROM (Gumshoe). Famicom Disk System support is maintained in fdsrecomp. A mapper implementation does not automatically qualify every board or game using it; follow the selected port's ROM and region requirements.

Voxel 3D presentation

The Legend of Zelda overworld rendered as an optional voxel diorama
The Legend of Zelda — optional voxel presentation.

NESRecomp includes an opt-in, presentation-only Voxel 3D renderer for game projects that can describe their live tile map and sprites. It reconstructs solid tile geometry, camera-facing sprite cards, depth sorting, contact shadows, HUD preservation, and adjustable pitch, yaw, roll, zoom, and sprite scale. The software scene compositor consumes the normal NES frame and game metadata; it does not patch the player's ROM or change save data.

The Legend of Zelda uses the renderer as an orbitable tabletop diorama, while Super Mario Bros. uses it as a forward-facing first-person experiment. Games opt in through trusted mod packages, so ordinary builds and launches remain on the stock rendering path unless the player enables Voxel 3D. See docs/VOXEL_RENDERER.md for the host API and docs/MOD_PACKAGES.md for package integration.

Text Override System

NESRecomp includes a runtime text replacement system that allows modifying in-game text without editing the ROM. The runner exposes writable PRG ROM bank accessors (runner_get_prg_bank_rw()) that game plugins use to patch string data at load time.

FaxanaduRecomp is the first game to exercise this feature, implementing a JSON-driven override system with:

  • Multiple encoding registries (ASCII, tile-based dialogue fonts)
  • PRG ROM patching for all rendering paths (direct PPU writes, DMA queues)
  • Hot-reload — edit text_overrides.json while the game is running and changes apply within ~1 second

This enables localization, retranslation, and accessibility improvements without ROM hacking. See override_text.h in FaxanaduRecomp for the full API.

Architecture

NESRecomp has one backend: the recompiler emits CPU-cycle execution against the cycle hardware runtime in runner/cyc; see the host integration. The native path is the default; -DNESRECOMP_ENGINE_PATH=lle is the one named reference build (LLE PPU dot machine, per-cycle APU, wait loops executed as instructions).

NES ROM (.nes)
    |
    v
nesrecomp.exe build + optional game.toml
    |
    v
generated/<game>_cyc.c       (compiled ROM-view dispatch)
generated/<game>_cyc_b*.c    (6502 instructions expressed as CPU cycles)
    |
    v
Game executable (linked with runner library + SDL2)

Key Components

Component Purpose
recompiler/src/cyc_codegen.c Default cycle-code emitter and generated fallback interpreter
runner/cyc/ Cycle CPU, PPU, APU, mappers, host and enhancement adapters
runner/cyc/project.cmake Default game integration and build-time generation
runner/cyc/cyc_host.c, cyc_sdl.c Host loop, window, audio, input and the TCP debug server (cyc_tcp.c)
runner/src/mod_runtime.cpp Mod packages, trusted plugins and the Mods page provider
runner/src/netplay/ Rollback netplay binding over recomp-net

Configuration Format

Game configuration is TOML (game.toml). The legacy plain-text .cfg format has been removed — passing a .cfg path now prints a migration message and exits. All in-tree game projects already use game.toml; see Dr. Mario's game.toml or Faxanadu's for working examples.

game.toml Directives

The full schema lives in recompiler/src/game_config.c; the most commonly used sections are summarized below.

Section Purpose
[game] Output prefix and recompiler settings
[mapper] bank_switch = [...] Addresses of MMC1/mapper bank-switch routines
[[inline_dispatch]] addr Indexed dispatch via inline address table after JSR
[[inline_pointer]] addr, zp = [lo, hi], call JSR reads 2 inline bytes into zero page; call also invokes the resulting target
[[extra_func]] bank, addr Force-create a function entry at this address
[[extra_label]] bank, addr Secondary entry point within an existing function
[[sram_map]] sram_start, rom_start, bank, size SRAM-to-ROM code mapping
[[nop_jsr]] addr Skip this JSR entirely (stack-manipulation routines incompatible with recompilation)
[[data_region]] bank, start, end Exclude byte range from pointer scanner (known data, not code)
[functions] fixed = [...], bankN = [...] Bulk extra_func lists keyed by bank
[force_interp] fixed = [...], bankN = [...] Seed entries that always execute as interpreter islands

Numeric values may be given in hex (0xC000) or decimal. Address-only directives are TOML arrays of tables; per-bank lists under [functions] and [force_interp] accept plain integer arrays.

Cycle builds can also use [[sram_map]] to declare a ROM copy into fixed SNROM SRAM. bank selects a16KiB input PRG bank; rom_start & 0x3FFF selects its offset. The compiler discovers entry points from ROM calls and jumps and compiles the copied image. Runtime validates folded code bytes, watches code stores and admits only the supported fixed8KiB MMC1 read profile. Changed code or unqualified/banked RAM interprets. Qualified views share device deadlines with native ROM execution and retain general bus, DMA, interrupt and observer fallbacks. Native saves remain ordinary SRAM.

Build NESRecomp from source

CMake 3.20+ is required. The recompiler itself is pure C11 with no external dependencies; game runners additionally need SDL2.

Windows (Visual Studio 2022)

# Build the recompiler
cmake -S recompiler -B build/recompiler -G "Visual Studio 17 2022" -A x64
cmake --build build/recompiler --config Release

# Recompile a game ROM
build/recompiler/Release/NESRecomp.exe <rom.nes> --game <path/to/game.toml>

To build the same self-contained Windows zip published on the Releases page, install Python 3.12 and PyInstaller, then run:

py -3.12 -m pip install pyinstaller
py -3.12 tools/build_cli.py

The zip is written to build/cli-release/.

macOS / Linux

# Install prerequisites (macOS / Homebrew shown; use your distro's packages on Linux)
brew install cmake sdl2 ninja

# Build the recompiler
cmake -S recompiler -B build/recompiler -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build/recompiler

# Recompile a game ROM (note: no .exe suffix)
build/recompiler/NESRecomp <rom.nes> --game <path/to/game.toml>

Game projects build the same way on macOS/Linux. From a recursive clone of the game repository (or after git submodule update --init --recursive):

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_PREFIX_PATH="$(brew --prefix)"
cmake --build build

Adding a New Game

Follow Your first NESRecomp port. It uses the default cycle backend, a separate game configuration and a baseline host. The cycle-project reference documents desktop/UI, hook and netplay integration. Keep title-specific addresses and behavior in the game repository; generated code stays in build output.

Developer references

Guide Contents
Cycle host integration Current game project and runtime integration
Bank extraction ROM analysis
Modding / mod packages Cross-bank sharing, overrides and trusted plugins
Debug protocol Runtime inspection and control
Historical validation Dated audits and bring-up evidence

Cycle-Accurate Mode

Cycle-accurate generation is the only backend (the function/frame backend and its runner were removed; --legacy is refused). It emits one block per ROM instruction with every CPU cycle's bus activity spelled out, against NESRecomp's own cycle-accurate 6502; the fallback interpreter is generated from the same templates. The CPU, PPU, APU, DMAs and mappers are NESRecomp's own (runner/cyc/hw_*.c), and TriCNES's complete machine is kept only as a test oracle. The runner is runner/cyc.

See the mapper catalog for supported cartridge boards. A block is generated per (PRG bank, CPU address) pair and entered only while the cartridge has that bank mapped there, since the bytes a block folded to constants depend on it. A recompiled AccuracyCoin passes 144/144, and scripted playthroughs of Super Mario Bros. 3 (MMC3), Mega Man 2 (MMC1), Mega Man (UxROM) and Donkey Kong Original Edition (CNROM) run at 100% native; all of them match the oracle on every bus access at all four CPU/PPU alignments. AxROM and GxROM have not been run with a game in the original qualification. See runner/cyc/README.md; AccuracyCoin is set up as a test in runner/cyc/tests/accuracycoin.

Acknowledgements

  • TriCNES by Chris Siebert (MIT) — the PPU/APU model behind cycle-accurate mode and its reference oracle (runner/cyc/tric_core.cpp).

  • Nat Budin (@nbudin) — macOS / POSIX build support (#10): POSIX ucontext coroutine backend, cross-platform directory creation, and the compiler-flag groundwork that made native macOS builds possible.


R.A.I.D. — Retro AI Development · a Discord for AI-assisted retro reverse-engineering, decomp & recomp

Join the Retro AI Development (R.A.I.D.) Discord

License

For this project's code covered by the PolyForm Noncommercial License, PERMISSIONS.md grants standing permission for voluntary donations, sponsorships, and advertising revenue, including support for broader development initiatives. Payment must not buy access to the software, games built with it, or their updates, features, or game content, including early access.

Matthew Stanley has authority from the relevant copyright holders to grant these permissions for the project's PolyForm-covered code. Third-party components and code explicitly licensed under other terms retain those terms.

About

NES game static recompiler ecosystem · Part of the R.A.I.D. community

Resources

Contributing

Stars

154 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages