How rainchus/quest64-recomp works
1. What this repo is
- This is a native Quest 64 port built by static recompilation, not an emulator.
- The shipped code is the application/runtime; the original US Quest 64 ROM and assets are user-provided and loaded at runtime.
2. Top-level architecture
- The repo splits into three major runtime domains:
- src/main: application bootstrap, platform integration, rendering setup.
- src/game: game-facing systems, config, input, save/load, ROM handling, and recompilation hooks.
- src/ui: launcher, config menus, mod UI, and the custom UI framework.
- Supporting code lives in include/, patches/, lib/, and assets/.
3. Startup and platform boundary
- src/main/main.cpp is the entry point for the native app.
- Platform-specific support is split across desktop targets, with extra glue for Windows/macOS/Linux and packaging in .github/, flatpak/, and Linux/macOS support files.
- The startup path initializes the runtime, registers overlays/patches, and wires the game systems to the renderer and UI.
4. Rendering subsystem
- The rendering engine is RT64 (lib/rt64), which is the main graphics backend for the port.
- src/main/rt64_render_context.cpp and shader files in shaders/ define the rendering bridge and UI/interface rendering path.
- The README’s feature set shows RT64 is responsible for the project’s high-framerate, widescreen, and visual-enhancement behavior.
5. Game/runtime subsystem
- src/game/ contains the Quest 64-specific logic that sits between the recompilation output and the native app.
- Key responsibilities include:
- configuration (config.cpp)
- controls/input (controls.cpp, input.cpp)
- debug and quicksaving
- ROM decompression
- scene and data tables
- API shims (recomp_api.cpp, recomp_data_api.cpp, recomp_actor_api.cpp)
- This layer is the main boundary where recompilation-era calls are adapted into native systems.
6. Patch and overlay system
- patches/ contains source and linker metadata for game patches, hooks, and replacement functions.
- Files like main.c, graphics.h, input.h, sound.h, and ui_funcs.h indicate this repo patches multiple game subsystems rather than only graphics.
- register_overlays.cpp and register_patches.cpp show that overlays are registered into the runtime explicitly during startup.
7. UI subsystem
- src/ui/ is a substantial standalone UI layer built on RmlUi.
- It includes:
- a custom UI core and element model in src/ui/core and src/ui/elements
- launcher, config menus, mod menus, mod detail panels, installer, and prompt dialogs
- API glue for events, images, renderer integration, and state management
- This UI is not just cosmetic; it drives config, mod installation, and launcher flow before gameplay starts.
8. UI data and styling pipeline
- The UI markup lives in assets/*.rml and nested config menu files.
- Styling is split between RML stylesheets and a larger SCSS source tree under assets/scss/, which appears to generate the final visual theme for menus.
- Fonts, icons, and prompt assets are bundled alongside the markup, making the launcher/config experience self-contained.
9. Input and control flow
- Input is handled across game and UI layers:
- the game layer maps controller/keyboard/mouse state into gameplay input
- the UI layer handles menu interactions and clickable widgets
- recompcontrollerdb.txt and include/recomp_input.h suggest a normalized controller mapping layer.
- The included GamepadMotionHelpers library indicates the codebase is prepared for motion/gyro-related controller support, even if that feature is still evolving.
10. Config, saves, and local state
- Game and UI settings are persisted through the runtime config system, with save/config paths described in the README.
- Portable mode is supported by placing portable.txt beside the executable, which changes where saves, configs, and mods are stored.
- This means the app has a clear separation between ephemeral runtime state, user config, and persistent save data.
11. Mod support architecture
- Mod installation and management are first-class subsystems in src/ui/ui_mod_* and mods/.
- The app supports installing mods/texture packs, toggling them in UI, and loading built-in mods such as the d-pad-related mod listed in mods/.
- The mod system is part of the user-facing UI, but it ultimately feeds into the game/runtime layer as content and behavior overrides.
12. Build, dependency, and packaging boundaries
- The project is built with CMake and includes some custom build metadata (CMakeLists.txt, BUILDING.md, CMakeSettings.json).
- Third-party libraries are vendored in lib/, including RmlUi, RT64, lunasvg, FreeType support, and helper libraries used by the runtime.
- CI and release packaging are handled separately in .github/, with platform-specific wrappers for Linux, macOS, Flatpak, and desktop integration.
13. Useful diagram framing
- A clean architecture diagram should show:
- User-provided ROM/assets entering the app boundary
- Startup/bootstrap initializing runtime, renderer, and UI
- UI/config/mod management as a user-facing control plane
- Game/recompilation runtime as the execution core
- RT64 rendering as the graphics backend
- patches/overlays as the bridge for game-specific modifications
- persistent save/config storage as a separate local-state boundary
Main entry points: recomp_api.cpp Recomp API · main.cpp Main · ui_context.cpp UI context · main.c Patch code
Components 27
Runtime
Native app, game systems, and rendering bridge
- Config · Game-side configuration state and persistence
src/game/config.cpp - Input · Normalizes controller, keyboard, and mouse input
src/game/input.cpp - Debug save · Debugging and quicksaving support
src/game/debug.cpp - ROM decode · Decompresses user-provided ROM data for runtime use
src/game/rom_decompression.cpp - Recomp API · General adapter layer for recompilation-era calls
src/game/recomp_api.cpp - Actor API · Actor-specific recompilation bridge
src/game/recomp_actor_api.cpp - Data API · Data access bridge for recompilation output
src/game/recomp_data_api.cpp
UI
Launcher, config, mod management, and custom widgets
- Launcher · Pre-game launcher and entry UI
src/ui/ui_launcher.cpp - Config UI · Main configuration menus and option flow
src/ui/ui_config.cpp - Mods · Mod browsing, toggles, and installation entry point
src/ui/ui_mod_menu.cpp - UI context · Core UI state, resource lifetime, and integration
src/ui/core/ui_context.cpp - UI renderer · Renders the custom UI layer through the rendering backend
src/ui/ui_renderer.cpp
Platform
Startup, overlays, patches, and OS integration
- Main · Native application entry and bootstrap
src/main/main.cpp - Support · Shared desktop/runtime integration helpers
src/main/support.cpp - Overlays · Registers overlay modules into the runtime
src/main/register_overlays.cpp - Patches · Registers game patches during startup
src/main/register_patches.cpp - RT64 bridge · Connects the app runtime to the RT64 renderer
src/main/rt64_render_context.cpp - Patch code · Source and hooks that replace or augment original game functions
patches/main.c - Input patch · Input-related patch hooks and overrides
patches/input.h - Graphics patch · Rendering-related patch hooks and overrides
patches/graphics.h
Assets
Markup, styles, shaders, and bundled UI resources
- Launcher RML · Launcher layout markup
assets/launcher.rml - Config RML · Configuration menu markup set
assets/config_menu.rml - Theme SCSS · Source stylesheet tree for the custom launcher and menus
assets/scss/main.scss - Shaders · Interface shader pair for the rendering bridge
shaders/InterfaceVS.hlsl
Vendor
Bundled third-party libraries and support code
Other components
- ROM + assets · User-provided Quest 64 ROM and original assets loaded at runtime
Connections 31
- ROM + assets → Main: load · User ROM and assets enter through the native bootstrap
- Main → Support: init · Bootstraps platform-specific support and runtime helpers
- Main → Overlays: register · Installs overlay modules into the runtime
- Main → Patches: register · Installs patch set during startup
- Main → RT64 bridge: bind · Connects the app to the rendering backend
- Main → UI context: start UI · Creates the UI runtime context
- Main → Recomp API: launch game · Transfers control into the recompilation runtime
- RT64 bridge → RT64: uses · Rendering bridge targets RT64
- UI context → RmlUi: uses · UI context builds on RmlUi
- UI renderer → RT64: draws via · UI rendering is composited through RT64
- Launcher → Launcher RML: loads · Launcher markup defines the startup UI
- Config UI → Config RML: loads · Config screens are driven by RML markup
- UI renderer → Theme SCSS: styles · Custom theme is sourced from SCSS-generated styling
- Launcher → UI context: runs on · Launcher executes within the shared UI core
- Config UI → UI context: runs on · Config menus use the shared UI core
- Mods → UI context: runs on · Mod management UI uses the shared UI core
- Mods → Config: edits · Mod and launcher choices feed runtime configuration
- Recomp API → Actor API: delegates · General API layer dispatches actor-specific calls
- Recomp API → Data API: delegates · General API layer dispatches data access calls
- Recomp API → Config: reads · Runtime API consults game settings
- Recomp API → Input: reads · Runtime API consumes normalized control state
- Recomp API → ROM decode: loads · Runtime API depends on decompressed ROM data
- Recomp API → Debug save: uses · Debug and quicksave features are exposed through the runtime
- Input → Input patch: patched by · Input handling is extended through patch hooks
- RT64 bridge → Graphics patch: patched by · Rendering behavior is augmented by graphics patches
- Recomp API → Patch code: overridden by · Core runtime behavior is replaced or augmented by patch code
- Patch code → Input patch: includes · Patch code spans multiple game subsystems
- Patch code → Graphics patch: includes · Patch code spans multiple game subsystems
- Patch code → UI renderer: hooks UI · Patch layer exposes UI-facing integration points
- Config UI → Config: persists · Configuration UI writes to runtime settings
- Mods → Recomp API: feeds · Selected mods and content affect runtime behavior