Apps & Software

Architecture of the TotK PC Recompilation Project for Windows x86-64

· GlobeWire Daily Editorial Desk · Source: github.com

3 min read

Key takeawaysThe totk-pc-recomp project documents how the Nintendo Switch build of The Legend of Zelda: Tears of the Kingdom is transformed into a native Windows x86-64 program. Rather than running through an emulator, the project builds upon upstream open-source repositories—primarily combining the CPU lifting components of LAS Recomp with game-handling components…
Architecture of the TotK PC Recompilation Project for Windows x86-64

Image: GitHub · Photo source · Resized and letterboxed to 16:9; no AI generation

Overview of the Native Windows Port

The `totk-pc-recomp` project documents how the Nintendo Switch build of *The Legend of Zelda: Tears of the Kingdom* is transformed into a native Windows x86-64 program. Rather than running through an emulator, the project builds upon upstream open-source repositories—primarily combining the CPU lifting components of LAS Recomp with game-handling components from MacNativeGames—alongside custom implementations for missing functionality, such as a Vulkan back end for the NVN graphics front end.

Prerequisites and Build Requirements

To build the native program, users must supply specific assets from a legally owned Nintendo Switch console:

  • Base game version 1.0.0 (`0100F2C0115B6000`) and one cumulative update (`0100F2C0115B6800`), provided as NSP or XCI files.
  • Console keys required for decryption and extraction.

The build pipeline extracts ExeFS and RomFS data using MacNativeGames' Python-based extractor, merges updates via a custom-built version of `hactool` utilizing BKTR patches, and verifies file integrity using expected hash manifests.

CPU Recompilation and Code Generation

Handling TotK Scale

While LAS Recomp provides a hand-written decoder and NEON/FP lowering routines, the project rewrites and expands these components to handle the scale of *Tears of the Kingdom*:

  • Parallel Processing: The code generator runs in parallel processes with bounded memory per worker.
  • Jump Tables: Resolved via an internal symbolic pass instead of Unicorn, keeping GPL code out of the shipped generator.
  • Architecture Support: Supports 128-bit exclusive pairs (`LDXP`/`STXP`), loads `subsdk*` modules, and removes the 64 MB limit on the main module.
  • Register Management: Frequently used general registers and `NZCV` flags are kept in C local variables rather than the virtual CPU structure, optimizing performance.

Threading and Kernel Simulation

TotK assumes the Horizon operating system's scheduler behavior, which the host models via `runtime/kernel.c`:

  • Models three virtual cores and manages thread priority, preemption, and core affinity.
  • Implements spin-wait handling and core handoffs to prevent game stalls during synchronization.

Graphics and Audio Back End

Vulkan 1.3 Integration

Replacing MacNativeGames' Metal back end, the project uses a Vulkan 1.3 back end for Windows:

  • Memory Pools: Imports host memory via `VK_EXT_external_memory_host`. On discrete GPUs, memory pools are mirrored in device-local memory with CPU write-watching to optimize uploads.
  • Replay Mechanisms: Supports chunked replay and optional asynchronous replay features to balance performance and latency.
  • Pipelines and Shaders: Translates Ryujinx shader translator output to SPIR-V, utilizing `VK_EXT_graphics_pipeline_library` where supported for fast pipeline linking.

Resolution, Aspect Ratios, and Enhancements

  • Resolution Scaling: Adapts output, swapchain, and scene sizes according to user configurations.
  • Aspect Ratio Patches: Supports ultrawide and alternative aspect ratios by adjusting the camera view and repositioning the HUD elements.
  • HDR and DLAA Support: Provides optional HDR10 output paths and integration for NVIDIA DLAA using runtime NGX loading.

Player Installation and Verification

The project installer builds the game executable locally on the user's machine using a bundled `llvm-mingw` toolchain, ensuring that no pre-compiled recompiled code is distributed. Users can verify the original architecture announcements and documentation directly via the project's official GitHub repository.

Share this article
Read the original source: totk-pc-recomp/docs/architecture.md at main · valentderah/totk-pc-recomp - GitHub

AI-assisted reporting; source claims are attributed and have not been independently verified.

About the author

GlobeWire Daily Editorial Desk — AI-assisted news based on attributed published sources.

More to read