kar-recomp

kar-recomp is a port of Kirby Air Riders for Nintendo Switch.

README

kar-recomp

Static recompilation of Kirby Air Riders (Nintendo Switch 2, SOL-AVES 0.28.1 / Aurora renderer, Title ID 040077201BE50000, v1.3.3 / v458752) to native x86-64 Linux and Windows PC executables with Vulkan 1.3 rendering, AMD FSR 1 / FSR 3.1-4 / DLSS upscaling, and SDL3 audio/input.

Repository: https://gitlab.com/gooner-team/kar-recomp
RecompLauncher: recomplauncher.com/game/kar-recomp
License: MIT (see LICENSE and LEGAL.md).

Legal Notice: This repository contains zero copyrighted game assets, executable code, shaders, keys, decryption tools, screenshots, or generated C/SPIR-V derived from the game. You must supply your own legally obtained, already-decrypted dump of the game to extract shaders, lift AArch64 binaries, and build a local binary. See LEGAL.md for full details.


Architecture & Highlights

kar-recomp is an ahead-of-time static recompilation (no CPU interpreter/JIT, no GPU emulation below NVN2):

  1. AArch64 -> C Static Lifter (recomp/)
    • Lifts all 3 game NSO modules (main, effect_script, sdk — 269,346 functions, 0 unsupported instructions) directly into x86-64-v3 C translation units.
  2. Horizon OS / NintendoSDK 20.5.26 HLE Runtime (runtime/sdk/)
    • Switch 2 OS, memory, threads, persistent save transactions (nn::fs::CommitSaveData, KAR_APPLICATION_ID, ShowUserSelector), nn::hid, nn::oe, nn::ro (runtime NRO modules), nn::fs (.nup / loose RomFS), nn::codec (libvpx VP9 video + libopus single-stream and multi-stream Opus decoders), nn::audio (AudioOut + OutputStream via SDL3 with 5.1-to-stereo fold-down), and POSIX clock_gettime/gettimeofday hooks.
  3. Offline SM86 SASS -> GLSL -> SPIR-V Translator (sm86/, tools/shaders/)
    • Extracts all 19,711 unique SM86 shader stages from SOL-AVES .ndsr and assets.cat (PARC/PDAT/PMAP) archives via tools/shaders/extract_kar.py.
    • Translates Ampere SM86 instructions including Vulkan 1.2 descriptor-indexed bindless texture/sampler access (set = 2), LDC.IS, MUFU.F16, F2FP.MERGE_C, HMUL2, HFMA2, F2F, BREV, ATOMS, ULEA carry-out, and CSMTEST.
    • Achieves 19,624 / 19,711 valid SPIR-V (99.6% total / 99.94% of VS+PS+CS) verified with glslc --target-env=vulkan1.3 and spirv-val --target-env vulkan1.3.
  4. NVN2 -> Vulkan 1.3 Backend & Zero-OOM Shader Prewarm (runtime/gfx/)
    • Native Vulkan 1.2 global bindless descriptor set (set = 2: 32,768 texture slots x 9 view types, 4,096 samplers, 4,096 shadow samplers, metadata SSBO for TXQ.B), per-stage NVNprogram binding (stage_prog[8]), 7-entry NVN2 compute c[0] resource tables, and Graphics Pipeline Library (GPL) fast linking.
    • Chunked Zero-OOM Shader Prewarm (--prewarm-kar): offline precompilation of 27,830+ shader stages (pipeline-cache.bin + pipeline-unions.bin) with bounded RAM usage, eliminating mid-gameplay shader compilation stutter.
    • Native SOL-AVES Resolution Scaling & AMD FSR 4.1.2 Lite: supports 540p–2160p tiers (including crisp 720p 3D + native 1080p UI scaling without cropping) and live upscaler toggling from the in-game menu (F1 / Esc).
    • Procedural Vector UI Font: optional crisp TrueType font generation (kar-ui-font.ttf) for the in-game overlay/menu.
    • Tested on AMD Radeon 880M (RADV, Mesa 26.3.x, Vulkan 1.4) at 720p/1080p/1440p with 0 Vulkan validation errors.

Building from Your Own Game Dump

Prerequisites
  • Linux x86-64 with Vulkan 1.3+ GPU driver (Mesa RADV / NVIDIA)
  • clang, ninja, uv (Python 3.12+), glslc, spirv-val
  • System libraries: SDL3, libopus, libvpx, zstd, vulkan-headers
Steps
  1. (Optional, recommended) Build the native Rust PyO3 accelerators (rust/kar-sm86 & rust/kar-recomp, abi3 Python 3.12+):

    make rust
    
    • kar_sm86: accelerates 128-bit SM86 SASS decoding by ~246x and full SM86 → GLSL translation (including structured control flow & BLAKE2b oracle verification) by ~7.2x with 0/400 byte-for-byte mismatches.
    • kar_recomp: accelerates AArch64 local register allocation and NZCV flag dataflow/rewriting by ~1.7x end-to-end with 0/3,000 byte-for-byte mismatches.
    • Pure Python remains available as an automatic fallback (or force it via KAR_NO_RUST=1).
  2. Place your legally dumped game archive and decrypted ExeFS (main, effect_script, sdk) under game/ (gitignored):

    • game/romfs (symlink or directory pointing to your game .nup / RomFS)
    • game/exefs/{main,effect_script,sdk}
  3. Extract shaders and translate SM86 -> SPIR-V offline:

    uv run tools/shaders/extract_kar.py --romfs game/romfs --out build/shaders
    uv run tools/shaders/translate.py --shaders build/shaders --out build/spirv --progress
    
  4. Lift AArch64 modules and build build/kar:

    make generated
    make build
    
  5. (Recommended) Prewarm Vulkan shader pipelines once offline:

    KAR_GPU=vulkan KAR_SPIRV=build/spirv ./build/kar --prewarm-kar
    
  6. Run verification suites:

    ./build/kar --selftest
    ./build/kar --probe-gfx-abi
    ./build/kar --probe-cfg
    KAR_VK_VALIDATION=1 ./build/kar --probe-vkexec
    make check
    
  7. Play:

    KAR_GPU=vulkan KAR_LANG=en-US KAR_SPIRV=build/spirv ./build/kar --profile build/profile --play
    

Settings are stored in kar.ini beside the binary (with automatic backward compatibility for legacy mkw.ini and MKW_* environment variables), and logs are written to logs/kar.log.


DMCA & Repository Hygiene

Before making any commit, enable the bundled pre-commit hook and run make check:

git config core.hooksPath tools/git
make check

This automatically blocks any accidental commit of game dumps, console binaries, keys, .spv shaders, screenshots, lifted game-derived C files, personal paths, or tokens. The same checks are enforced in .gitlab-ci.yml.


Credits & Upstream MIT Attribution

kar-recomp adapts and extends MIT-licensed work from: