FE3H Recomp

FE3H Recomp is a native Windows port of Fire Emblem: Three Houses built on the LAS Recomp project, offering 60fps gameplay and higher resolutions.

README

FE3H Recomp

A static recompilation of Fire Emblem: Three Houses (Nintendo Switch, 2019) into a native Windows application, built on LAS Recomp by Peiikai.

Important

This is a personal project, and I made it mostly for myself. I wanted to play Three Houses on my PC at a steady 60fps and a higher resolution, and so far emulators haven't given me the experience I'm after. So I built this instead, with a significant amount of help from an AI (Anthropic's Claude wrote most of the FE3H-specific code; I directed and tested).

I'm doing this casually, in my spare time, and I'm not planning to pour a ton of time, energy or resources into it. Honestly, I doubt I'll finish a full playthrough before GTA VI comes out, and once that happens this will probably fall by the wayside for a while. It's shared as-is, and I can't promise any ongoing support. Run it at your own discretion.

Note

No game files are included, and no instructions for obtaining them are provided. You need your own legally obtained copy of the game, version 1.2.0, extracted to exefs and romfs folders (and optionally your DLC).

What this is

Static recompilation translates the game's original Switch (AArch64) code into C ahead of time, then compiles it into a native program. It is not emulation: no CPU emulator runs the game. The Switch system software the game talks to (graphics, audio, files, controllers and so on) is reimplemented in the runtime, and graphics go through Vulkan.

LAS Recomp did the heavy lifting: its recompiler, runtime and Vulkan renderer were built for The Legend of Zelda: Link's Awakening. This fork adds what Three Houses needs on top.

Status

Playable. Tested on Windows with an AMD Radeon RX 9070 and an RX 6800 XT: the opening chapters, battles (combat arts, gambits and their cut-ins), the monastery, cutscenes, the calendar, and the start of Cindered Shadows. It holds 60 fps through the monastery and battles. Longer playthroughs are ongoing. Other platforms LAS supports (macOS, Linux) may build but haven't been tried with this game.

Added for Three Houses:

  • Audio: splitter routing (music, voices and effects reach the right mixes), 8 / 24 / 32-bit and float PCM, I3DL2 room reverb, and the game's own effect send / return.
  • Movies: the nnMedia player the game uses for its cutscenes, decoded with FFmpeg.
  • Lighting: clustered lights work: buffer textures in the shader translator, lane IDs and masks, compute barriers that are safe inside branches, 32-lane compute subgroups, and buffer clears.
  • System services: an always-offline network service (the calendar crashed without it).
  • DLC: the Expansion Pass, Cindered Shadows and the bonus waves, from your own DLC files.
  • Shaders: what FE3H's GPU code uses that Link's Awakening never did: address arithmetic (LEA), atomics and reductions on memory, subroutine calls, and image stores (the battle effects write into textures from compute shaders).
  • Smooth play: shader translations are kept on disk, and every shader and pipeline met before is rebuilt at launch, so areas and battle effects you've seen draw at once instead of popping in or stuttering.
  • Cheats: Atmosphere-format cheat codes from a cheats.txt of your own, switched on and off in the menu's Game tab, including the ones that patch the game's code (see Cheats below).

The start screen and the in-game menu (F1) are FE3H's own: Video, Audio, Controls and Game settings in slate and gold. LAS's Link's Awakening features (its randomizer, cheats, cosmetics, warps) are still in the code, switched off and out of the menus.

The start screen shows your own picture if you put one in the game files folder as extracted/background.png (or .jpg); it isn't part of this repository, and .gitignore keeps it out.

Known issues

  • The first time you see an area or a battle effect on a PC, its shaders are built while it plays: some pop-in or stutter, and once in a while an effect drawn incompletely (a cut-in as outlines). Only the first time.
  • A few very large battle-effect compute shaders (over 4,000 instructions) aren't built: GPU drivers took minutes on them, if they finished at all. Some battle effects may be missing a layer. LARECOMP_VK_BIG_CS=1 builds them anyway.
  • Above 1x internal resolution, a thin vertical line can show in dialogue boxes, where two pieces of the box meet. It's in the game's art: emulators show it too at higher resolutions.
  • Experience multiplier cheats can overflow the EXP bar on the results screen for some classes (archers); the game itself is fine.

Installing a release (Windows)

Requirements: Windows 10 or 11 (64-bit), a CPU with AVX2 (most from 2015 on), a GPU with Vulkan 1.3 drivers, and about 20 GB free for the game files and the build.

  1. Download FE3H-Recomp-<version>-windows.zip from Releases (what changed in each: CHANGELOG.md) and unzip it anywhere you can write to (not Program Files). Everything it makes - saves, settings, caches, the game files - stays in that folder.
  2. Run fe3hrecomp.exe. On the start screen, open Settings > Game Files, choose the folder holding your own extracted copy of the game (version 1.2.0, exefs and romfs), and click Set up game files.
  3. Wait. The setup copies the game files, then recompiles the game's code on your PC. That's a one-time job and takes a while (about 6 minutes on a Ryzen 7 / 12 threads; longer with fewer cores).
  4. Click Play.

DLC: if your game files folder has a dlc folder laid out as in DLC, the setup copies it too. To add DLC later, put it in extracted/dlc in the program's folder the same way.

Cheats: put a cheats.txt next to fe3hrecomp.exe (see Cheats). For cheats that patch the game's code, use Settings > Game Files > Rebuild game code on the start screen instead of make gen-main, then restart.

The first time you enter an area, its shaders are prepared and things may pop in for a moment; from then on they're ready from the start of each session. Moving to another PC? Copy the cache folder along: the shaders are then ready there from the start too.

Building and running (Windows)

Requirements: Windows 10+ x86-64, a CPU with AVX2 and a GPU with Vulkan 1.3.

  1. One-time setup, in PowerShell from the repo root: powershell -ExecutionPolicy Bypass -File tools\setup_windows.ps1 (installs MSYS2 with clang, SDL3, FFmpeg, Vulkan and shaderc, plus Python for the tools). More detail in docs/BUILD-windows.md, which LAS wrote for Link's Awakening; the steps are the same.
  2. Game files: put your extracted exefs/ and romfs/ in extracted/ and set them up on the start screen as in LAS (its game-file setup builds extracted/romfs.bin).
  3. Build, from an MSYS2 UCRT64 shell:
    make gen          # once: recompile the game code from extracted/exefs into generated/
    make -j$(nproc)   # every core: after make gen, hundreds of files compile
    
  4. Run: ./build/fe3hrecomp.exe extracted --play > run.log 2>&1
DLC

Extract each DLC's romfs into a folder named by its content id:

extracted/dlc/010055D009F79001/romfs/...
extracted/dlc/010055D009F79002/romfs/...

The game sees every pack there as installed. The first launch converts each folder into a single image next to it (once; it takes extra disk space about the size of the DLC).

Cheats

Cheats use the Atmosphere format: put them in cheats.txt in the project folder (a [Name] line, then its codes; a {Name} block is a master code, always on; # lines under the name describe it), and they show up in the menu's Game tab to switch on and off. The file stays out of git.

Cheats that only change memory work straight away. Cheats that patch the game's code (most multipliers and "max" cheats) can't be applied to an already-recompiled game at run time, so their patched instructions get compiled in beside the originals: after adding or changing those, run make gen-main and then make. The menu marks any cheat still waiting on that. Switching a cheat off puts back any code it changed; values it already wrote stay. Cheats that patch the same instruction (Exp x2 / x4 / x8, say) exclude each other: switching one on turns the others off.

Settings and logs
  • F1 (or Minus + Plus on a controller) opens the settings overlay. Internal resolution starts at 1x (1080p). On a fast GPU, "Match display" or higher gives a sharper image; on a laptop, a Steam Deck or an older GPU, 75% or Dynamic keeps battles much smoother (the battle lighting's cost grows with the pixel count). 150% or 200% renders above your display and shrinks the image to it: the smoothest edges, if your GPU has room. Sharpening (Default, High, Low or Off) sets how crisp the final image is; Default doesn't sharpen at Match display.
  • Keyboard and mouse: WASD moves, E / Q confirm / back, F / R are X / Y, Z / C are L / R, 1 / 3 are ZL / ZR, Tab / M are Plus / Minus, arrows the d-pad, I / J / K / L the camera. Left click is A, the wheel steps up / down through menus (Shift + wheel, or tilting the wheel, steps left / right). Hold the right mouse button to turn the camera with the mouse, or set Controls > Mouse camera to Always (cursor hidden, right click = B). Every key can be changed in the Controls tab.
  • Saves are in save/, settings in fe3hrecomp.ini (an older larecomp.ini is renamed to it once).
  • run.log is the first place to look when something goes wrong. LARECOMP_* environment variables turn on extra logging for specific systems (audio, textures, shaders); they're documented where they're read in runtime/.
Making a release package

From the MSYS2 UCRT64 shell, once: make deps-windows (an LGPL build of FFmpeg: releases can't ship MSYS2's GPL one), tools/fetch_zig.sh (the compiler players' PCs build the game with) and make gen-helper (the game code generator as a standalone program; needs the python.org Python 3.12 the setup script installs). Then make dist builds build/dist/FE3H-Recomp-<version>-windows.zip (the version is FE3H_VERSION in runtime/ui/launcher.mm). It holds no game code: each player's PC recompiles the game from their own files. make dist rebuilds the generator helper by itself when tools/ changed. If py isn't on the MSYS2 shell's PATH, give the Python for the helper as GEN_PY=/c/Users/<you>/AppData/Local/Programs/Python/Python312/python.exe.

Hurdles along the way

Some of what it took to get from Link's Awakening's recompiler to a playable Three Houses, in case it helps anyone doing the same for another game:

  • Lighting was missing. FE3H culls its lights in compute shaders that count lights per screen tile with subgroup operations. The translator returned 0 for lane IDs and masks, so no tile had any lights; and a barrier inside the shader's branch state machine ran before every wave had added its own lights. Fixed in the shader translator.
  • Audio routing. Music, voices and effects go through the audio renderer's splitters and an I3DL2 reverb that LA never used; until those were implemented, sounds didn't reach the right mixes.
  • Stutter. Each new shader was translated, compiled to SPIR-V and built by the driver in the middle of play. Three layers fixed it: translations cached on disk, draws waiting a few milliseconds a frame for a shader still building instead of skipping it, and a prewarm that rebuilds everything seen in earlier sessions at launch.
  • Battle effects. Combat art and gambit cut-ins are drawn by compute shaders writing into images, with subroutine calls and memory reductions the translator didn't know yet. Some are enormous (9,000-11,000 instructions); building them stalled the driver for minutes and held up every other shader behind them, so the effects never appeared. Large ones now build on threads of their own, and the largest are skipped.
  • Cheats. Many Switch cheats patch the game's code, which a recompiled game no longer runs. Their patched instructions are compiled in beside the originals and picked at run time. One popular "always critical" cheat turned out to zero unit stats (stranding units unable to move); it was replaced with a one-instruction code patch on the crit roll.
  • Setup time. A few of the game's functions are huge (one is 4 MB of C). A compiler can't split one function across cores, so the first setup spent 15 minutes compiling a single file. The generator now writes very long functions as parts that compile in parallel: setup went from about 20 minutes to 6.

Rules for this repository

Nothing owned by Nintendo is ever committed: no game files, no extracted or generated code (extracted/, generated/), no logs or dumps that contain game code, no assets. .gitignore covers the usual folders.

Credits

Legal

This is a fan project, not affiliated with, endorsed by or sponsored by Nintendo, Intelligent Systems or Koei Tecmo. Fire Emblem and Fire Emblem: Three Houses are trademarks of Nintendo. No game files, game code or assets are included in this repository. You must provide your own legally obtained copy of the game.

License

The code is open source under the MIT License, as LAS Recomp's is. Third-party components keep their own licenses (see LAS Recomp's README for the full list, including the Link's Awakening randomizer still in third_party/). The license covers this project's code only; it grants nothing for Nintendo's game.