Skip to content

mstan/ZeldaAlttPSNESRecomp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZeldaAlttPSNESRecomp

Static recompilation of The Legend of Zelda: A Link to the Past (SNES) into native C, using the snesrecomp framework. This repo is the per-game side: the runtime, the recompiled C output, the per-game .cfg, and the build glue.

What "static recompilation" means here

The 65816 CPU code from the ROM is statically translated to C — every function the game runs on the SNES's main CPU is a real generated C function in src/gen/. The rest of the SNES is not recompiled — it's hardware. PPU rendering, the APU/SPC700 audio coprocessor, DMA and HDMA channels, hardware register I/O, and bank-mapping all run through an embedded copy of snes9x's emulator core (snesrecomp/runner/snes9x-core/). Same model as N64Recomp and similar projects: recompile the CPU, emulate the silicon.

The ROM is never redistributed — you supply your own legally-dumped copy.

Current status: playable through early dungeon

Hand-verified end-to-end through:

  • Boot → attract demo → file select → in-game.
  • Module 09 (Overworld) reachable and traversable.
  • Module 07 (Dungeon) including sword combat against Green Knife Guards — the bug from v0.1.0's release-note investigation (camera axis-swap on sword hit) is fixed.
  • Audio (HLE SPC upload of the cartridge's stock sound engine) plays through title, gameplay, sword/item SFX, and music transitions.

No catastrophic visible regressions surfaced through the verified content. Later content (Hyrule Castle interior past the prologue, Sanctuary onward, the Dark World) is not yet hand-verified but is expected to play similarly. If you hit a visible regression, please open an issue with a savestate.

Active development; expect:

  • Some branches don't build; only main is guaranteed to build.
  • Internal docs (ISSUES.md) assume context.
  • APIs and recompiler output change without notice.

Quick start (pre-built release)

  1. Download the latest release zip from Releases and extract it.
  2. Run zelda.exe. On first launch a file picker asks for your legally-obtained Legend of Zelda: A Link to the Past (USA) ROM (.sfc / .smc). The expected CRC32 is 0x777AAC2F (no-intro canonical USA dump, 1 MiB, LoROM). 512-byte SMC copier headers are auto-stripped before hashing, so headered or unheadered both work.
  3. Edit keybinds.ini (auto-generated next to the exe on first run) to remap keys, then restart.

The path you pick is cached to rom.cfg next to the exe so subsequent launches skip the picker.

Controls (default keybinds.ini)

SNES button Default key
D-Pad Arrow keys
A X
B Z
X S
Y A
L C
R V
Start Enter
Select Right Shift

Player 2 is unbound by default — fill in keys in keybinds.ini to enable a second keyboard player.

Xbox / PlayStation / Switch Pro controllers are auto-detected via SDL_GameController (XInput on Windows). Plug it in before launching, or hot-plug after.

System shortcuts (configured in zelda.ini's [KeyMap] section):

Action Default
Save state 1-10 Shift+F1..F10
Load state 1-10 F1..F10
Toggle pause P
Reset Ctrl+R
Toggle fullscreen Alt+Enter
Turbo (fast-forward) Tab

Building from source

Prerequisites: Windows 10+, Visual Studio 2022 (with C++ desktop workload), Python 3.9+ on PATH.

git clone https://github.com/mstan/ZeldaAlttPSNESRecomp
git clone https://github.com/mstan/snesrecomp
cd ZeldaAlttPSNESRecomp

The snesrecomp/ directory is a sibling repo accessed via a junction/symlink to the clone next to this repo.

Build:

# From a Developer Command Prompt for VS 2022, or with MSBuild on PATH:
msbuild zelda.sln /p:Configuration=Oracle /p:Platform=x64 /m

The recompiled C in src/gen/ is not committed — contributors must regenerate it from a local ROM before the first build. See the next section.

Regenerating the recompiled C (contributors)

  1. Drop a legally-obtained zelda.sfc at the repo root (.gitignore excludes it).
  2. Run:
    python ../snesrecomp/tools/v2_regen.py --rom zelda.sfc --cfg-dir recomp --out-dir src/gen --prefix zelda
  3. Rebuild as above.

Repo layout

Path Purpose
src/ Runtime C (CPU state glue, NMI orchestration, hand-written bodies for things the framework doesn't recompile).
src/gen/ Recompiler output (gitignored; regenerated from ROM).
recomp/bank*.cfg Per-bank function declarations + hardware hints the framework cannot derive from the ROM alone.
recomp/funcs.h Auto-regenerated by v2_regen.py; never hand-edit.
snesrecomp/ Symlink to a sibling clone of the snesrecomp framework.
third_party/ Vendored deps (gl_core, stb_image) with their own licenses.
zelda.sln + src/zelda.vcxproj Visual Studio build glue.
zelda.ini Sample config; the runtime auto-copies a fresh one next to the exe on first run.

License

Not yet declared. Code in this repo is original; vendored dependencies under third_party/ retain their own licenses.

The Legend of Zelda: A Link to the Past ROM and any data extracted from it are not in this repo and are not licensed for redistribution.

About

Static recompilation of The Legend of Zelda: A Link to the Past (SNES) using the snesrecomp framework

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages