Skip to content

Building the Game

XiONDiGiTaL edited this page Nov 23, 2026 · 2 revisions

Building the Game

EmblemWeave is an ahead-of-time recompiler. "Build the game" translates the game's AArch64 code to C++, compiles it with a native runtime, and links fefw.exe. After that, Play starts the built executable. The dump is read, never modified.

The pipeline

Stage What happens
Validate Locate the dump and check its modules against the title's hashes and build ID.
Prepare Unpack the compressed main (ZBIC) and serve the RomFS from a folder, .nsp, .xci, .nx or .nup.
Recompile Decode every AArch64 instruction, recover functions and control flow, and emit C++ for each module.
Compile and link clang-cl compiles the emitted code and the runtime, then links fefw.exe for the CPU target and hook sites this PC needs.
Run Map the modules, start them the way the console SDK does, serve their system calls natively, and drive NVN on the host GPU.

The Recompilation page exposes the nine stages it runs: parse, decompress, decode, recover, analyse, emit C, compile, verify, prepare. Each stage reports progress and writes its own log.

Before the first build

  1. Game Setup has a validated dump and main is decoded.
  2. Requirements is green (or the launcher has fetched the pieces it can).
  3. Enough disk space: roughly 30 GB for game data, plus build output and caches.
  4. Close other memory-heavy programs if the machine is small.

The launcher probes Visual Studio through vswhere, reads the MSVC toolset and Windows SDK from vcvars, and checks LLVM, CMake, Ninja and Python. It also compiles and links a one-file probe with the detected compiler before starting, so a mismatched toolchain fails in seconds, not twenty minutes in.

What a build produces

  • engine/fefw-recomp/game-build/fefw/build/release/fefw.exe
  • the lifted sources and static libraries under engine/fefw-recomp/work/build/fefw
  • translated shaders under engine/fefw-recomp/work/shaders/spirv
  • the texture cache under engine/fefw-recomp/work/bc7_cache
  • a build record the launcher uses to decide whether a rebuild is needed

The launcher writes the run settings to data/play/fefw.ini before every start.

Build concurrency

The launcher chooses compiler jobs from the machine it is on: it leaves two logical CPUs and 2 GiB of physical memory for Windows and the launcher, then budgets 1.5 GiB per compiler. A 16 GB machine with 8 GB free uses four jobs even if it has sixteen logical CPUs.

Override it for one build with:

$env:NX_JOBS = 6

Valid values are 1–64; an invalid value is ignored and named in the log rather than silently becoming one job. The chosen count and the reason are written to the job log.

Only one build can run at a time. A second one stops with the process id holding engine/fefw-recomp/work/build/.build.lock.

When a rebuild is needed

A build is reused unless something it depends on changed:

  • the engine revision;
  • the selected toolchain or CPU target;
  • the active ExeFS patches (installing, editing, enabling, disabling or removing one makes Play unavailable until the game is rebuilt);
  • code mods that bring hook sites (exefs/*.sites);
  • shader corpus changes or a missing SPIR-V cache.

The Mods page shows the patch state, the build reason and any conflict before Play.

Shaders

The build translates the game's shader corpus to SPIR-V and verifies that every expected block has an entry in spirv/results.tsv. A build that still has missing shaders stops with the count and the first hashes instead of producing a game that silently skips draws and shows a black picture.

If a build was interrupted mid-translation, the cache may hold a few files and no report; Build the game detects that and translates what is missing.

First launch

The launcher watches the first minute of each run. A run that exits early, or that plays sound for 90 seconds without presenting a frame, is reported with the GPU it selected. The engine log is play/fefw.log.

Related

Clone this wiki locally