# ly05010419/macnativegames architecture

> Architecture diagram of the GitHub repository ly05010419/macnativegames, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ly05010419/macnativegames
- Repository: https://github.com/ly05010419/macnativegames

## Overview

MacNativeGames builds native Apple-silicon ports of Tears of the Kingdom and Breath of the Wild from a player's own Switch files. The main user journey is to provide a game image and keys, build an app, then run the game's ARM64 code with host implementations of Switch services and graphics/audio. The graph includes the documented shader preparation and contribution workflow. Source excerpts are partial, so internal links not established by those excerpts or the README are omitted or marked unverified.

Main entry points: [`games/totk/runtime/loader.c`](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/loader.c) (Guest loader), [`games/totk/runtime/ipc.h`](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/ipc.h) (Horizon IPC), [`build_app.py`](https://github.com/ly05010419/macnativegames/blob/main/build_app.py) (App builder), [`games/totk/scripts/shader_list.py`](https://github.com/ly05010419/macnativegames/blob/main/games/totk/scripts/shader_list.py) (Shared shader list)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Game preparation"]
  node_game_inputs["Game image and keys"]
  node_app_builder["App builder<br/>[build_app.py]"]
  node_game_extraction["Game extraction"]
  node_module_prep["Module preparation<br/>[prepare_modules.py]"]
end

subgraph group_runtime["Native runtime"]
  node_guest_loader["Guest loader<br/>[loader.c]"]
  node_ipc["Horizon IPC<br/>[ipc.h]"]
  node_host_services["Host services<br/>[services.c]"]
  node_settings["Settings service<br/>[settings_service.c]"]
  node_threads["Thread compatibility<br/>[threads.c]"]
  node_romfs["Game filesystem<br/>[romfs.c]"]
  node_game_patches["Game patches<br/>[game_patches.c]"]
end

subgraph group_media["Graphics and audio"]
  node_graphics["Metal graphics bridge<br/>[gfx_bridge.c]"]
  node_audio_service["Audio renderer<br/>[audio_renderer.c]"]
  node_audio_mixer["Audio mixer<br/>[audio_mixer.c]"]
end

subgraph group_shader["Shader workflow"]
  node_shader_list["Shared shader list<br/>[shader_list.py]"]
  node_shader_translator["Shader translator<br/>[Program.cs]"]
  node_ios_shader_fill["iOS shader fill<br/>[fill_shaders.py]"]
  node_shader_contributions["Shader contributions"]
end

node_player(("Player"))

node_player -->|"provides"| node_game_inputs
node_game_inputs -->|"builds with"| node_app_builder
node_app_builder -.->|"prepares game data"| node_game_extraction
node_app_builder -.->|"prepares modules"| node_module_prep
node_module_prep -.->|"loads game code"| node_guest_loader
node_guest_loader -.->|"dispatches services"| node_ipc
node_host_services -->|"serves requests"| node_ipc
node_settings -->|"handles requests"| node_ipc
node_threads -->|"uses IPC handles"| node_ipc
node_guest_loader -.->|"accesses game files"| node_romfs
node_guest_loader -.->|"applies patches"| node_game_patches
node_graphics -.->|"translates at runtime"| node_shader_translator
node_audio_service -->|"mixes audio"| node_audio_mixer
node_player -->|"contributes shader data"| node_shader_list
node_shader_list -.->|"seeds shader preparation"| node_shader_translator
node_ios_shader_fill -->|"requests translation"| node_shader_translator
node_ios_shader_fill -->|"updates cache index"| node_shader_list
node_shader_contributions -->|"requests submission"| node_player

click node_app_builder "https://github.com/ly05010419/macnativegames/blob/main/build_app.py"
click node_game_extraction "https://github.com/ly05010419/macnativegames/blob/main/games/totk/scripts/extract_update_romfs.py"
click node_module_prep "https://github.com/ly05010419/macnativegames/blob/main/games/totk/scripts/prepare_modules.py"
click node_guest_loader "https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/loader.c"
click node_ipc "https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/ipc.h"
click node_host_services "https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/services.c"
click node_settings "https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/settings_service.c"
click node_threads "https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/threads.c"
click node_romfs "https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/romfs.c"
click node_game_patches "https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/game_patches.c"
click node_graphics "https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/gfx_bridge.c"
click node_audio_service "https://github.com/ly05010419/macnativegames/blob/main/games/by3/runtime/audio_renderer.c"
click node_audio_mixer "https://github.com/ly05010419/macnativegames/blob/main/games/by3/runtime/audio_mixer.c"
click node_shader_list "https://github.com/ly05010419/macnativegames/blob/main/games/totk/scripts/shader_list.py"
click node_shader_translator "https://github.com/ly05010419/macnativegames/blob/main/games/totk/tools/totk_xlate/Program.cs"
click node_ios_shader_fill "https://github.com/ly05010419/macnativegames/blob/main/games/totk/ios/tools/fill_shaders.py"
click node_shader_contributions "https://github.com/ly05010419/macnativegames/blob/main/games/totk/ios/tools/shader_contrib_watch.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_game_inputs,node_app_builder,node_game_extraction,node_module_prep toneBlue
class node_guest_loader,node_ipc,node_host_services,node_settings,node_threads,node_romfs,node_game_patches toneAmber
class node_graphics,node_audio_service,node_audio_mixer toneMint
class node_shader_list,node_shader_translator,node_ios_shader_fill,node_shader_contributions toneRose
class node_player toneIndigo
```

## Components

### Game preparation

- **Game image and keys**
- [App builder](https://github.com/ly05010419/macnativegames/blob/main/build_app.py): `build_app.py`
- [Game extraction](https://github.com/ly05010419/macnativegames/blob/main/games/totk/scripts/extract_update_romfs.py): `games/totk/scripts/extract_update_romfs.py`
- [Module preparation](https://github.com/ly05010419/macnativegames/blob/main/games/totk/scripts/prepare_modules.py): `games/totk/scripts/prepare_modules.py`

### Native runtime

- [Guest loader](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/loader.c): `games/totk/runtime/loader.c`
- [Horizon IPC](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/ipc.h): `games/totk/runtime/ipc.h`
- [Host services](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/services.c): `games/totk/runtime/services.c`
- [Settings service](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/settings_service.c): `games/totk/runtime/settings_service.c`
- [Thread compatibility](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/threads.c): `games/totk/runtime/threads.c`
- [Game filesystem](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/romfs.c): `games/totk/runtime/romfs.c`
- [Game patches](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/game_patches.c): `games/totk/runtime/game_patches.c`

### Graphics and audio

- [Metal graphics bridge](https://github.com/ly05010419/macnativegames/blob/main/games/totk/runtime/gfx_bridge.c): `games/totk/runtime/gfx_bridge.c`
- [Audio renderer](https://github.com/ly05010419/macnativegames/blob/main/games/by3/runtime/audio_renderer.c): `games/by3/runtime/audio_renderer.c`
- [Audio mixer](https://github.com/ly05010419/macnativegames/blob/main/games/by3/runtime/audio_mixer.c): `games/by3/runtime/audio_mixer.c`

### Shader workflow

- [Shared shader list](https://github.com/ly05010419/macnativegames/blob/main/games/totk/scripts/shader_list.py): `games/totk/scripts/shader_list.py`
- [Shader translator](https://github.com/ly05010419/macnativegames/blob/main/games/totk/tools/totk_xlate/Program.cs): `games/totk/tools/totk_xlate/Program.cs`
- [iOS shader fill](https://github.com/ly05010419/macnativegames/blob/main/games/totk/ios/tools/fill_shaders.py): `games/totk/ios/tools/fill_shaders.py`
- [Shader contributions](https://github.com/ly05010419/macnativegames/blob/main/games/totk/ios/tools/shader_contrib_watch.py): `games/totk/ios/tools/shader_contrib_watch.py`

### Other components

- **Player**

## Connections

- Player → Game image and keys: provides (evidence: `README.md`)
- Game image and keys → App builder: builds with (evidence: `README.md`)
- App builder → Game extraction: prepares game data
- App builder → Module preparation: prepares modules
- Module preparation → Guest loader: loads game code
- Guest loader → Horizon IPC: dispatches services
- Host services → Horizon IPC: serves requests (evidence: `games/totk/runtime/services.c`)
- Settings service → Horizon IPC: handles requests (evidence: `games/totk/runtime/settings_service.c`)
- Thread compatibility → Horizon IPC: uses IPC handles (evidence: `games/totk/runtime/threads.c`)
- Guest loader → Game filesystem: accesses game files
- Guest loader → Game patches: applies patches
- Metal graphics bridge → Shader translator: translates at runtime
- Audio renderer → Audio mixer: mixes audio (evidence: `games/by3/runtime/audio_renderer.c`)
- Player → Shared shader list: contributes shader data (evidence: `README.md`)
- Shared shader list → Shader translator: seeds shader preparation
- iOS shader fill → Shader translator: requests translation (evidence: `games/totk/ios/tools/fill_shaders.py`)
- iOS shader fill → Shared shader list: updates cache index (evidence: `games/totk/ios/tools/fill_shaders.py`)
- Shader contributions → Player: requests submission (evidence: `games/totk/ios/tools/shader_contrib_watch.py`)
