# veritr1x/recomp-kit architecture

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

- Interactive diagram: https://gitdiagram.com/veritr1x/recomp-kit
- Repository: https://github.com/veritr1x/recomp-kit

## Overview

recomp-kit statically translates 32-bit x86 Windows games into native applications. The principal workflow starts with a game repository and translation inputs, produces translated game code, then loads and runs it through the guest runtime and Windows/DirectX shims; the host renders, presents frames, and supplies input and audio across platforms. Additional product branches cover mods and on-screen controls. The graph follows README statements and SOURCE INDEX references; unsampled implementations and their detailed call paths are not inferred.

Main entry points: [`host/sdl/main.cpp`](https://github.com/veritr1x/recomp-kit/blob/main/host/sdl/main.cpp) (SDL host entry), [`host/d3d_render.cpp`](https://github.com/veritr1x/recomp-kit/blob/main/host/d3d_render.cpp) (D3D renderer), [`runtime/loader.h`](https://github.com/veritr1x/recomp-kit/blob/main/runtime/loader.h) (PE loader), [`runtime/kernel32.cpp`](https://github.com/veritr1x/recomp-kit/blob/main/runtime/kernel32.cpp) (Kernel32 shims)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_translation["Game translation"]
  node_translator["Static translator<br/>[translate.py]"]
  node_launcher["Web launcher<br/>[core.js]"]
end

subgraph group_runtime["Guest runtime"]
  node_loader["PE loader<br/>[loader.h]"]
  node_guest["Guest CPU and memory<br/>[guest.h]"]
  node_imports["Import dispatch<br/>[imports.h]"]
  node_kernel["Kernel32 shims<br/>[kernel32.cpp]"]
  node_win32["Win32 services<br/>[win32.h]"]
end

subgraph group_compat["Compatibility shims"]
  node_dx["DirectX shims<br/>[dx.h]"]
  node_ddraw["DirectDraw shim<br/>[ddraw.cpp]"]
  node_hostapi["Shim callbacks<br/>[host_api.h]"]
end

subgraph group_host["Native host"]
  node_app["SDL host entry<br/>[main.cpp]"]
  node_renderer["D3D renderer<br/>[d3d_render.cpp]"]
  node_gpu["GPU backends<br/>[gpu_factory.cpp]"]
  node_present["Frame presentation<br/>[present.h]"]
  node_audio["Audio mixer<br/>[mixer.cpp]"]
  node_platform["OS abstraction<br/>[os.h]"]
end

subgraph group_extensions["Mods and controls"]
  node_mods["Mod foundation<br/>[mods_internal.h]"]
  node_modapi["Mod API<br/>[pop_mod_api.h]"]
  node_modservices["Host mod services<br/>[host_services.cpp]"]
  node_controls["Touch controls<br/>[router.h]"]
  node_settings["Display settings<br/>[display_settings.h]"]
end

node_game(("Game repository"))

node_game -->|"provides inputs"| node_translator
node_translator -.->|"generates game code"| node_loader
node_app -.->|"starts runtime"| node_loader
node_loader -->|"loads guest"| node_guest
node_guest -.->|"dispatches imports"| node_imports
node_imports -.->|"routes APIs"| node_kernel
node_kernel -->|"uses services"| node_win32
node_kernel -->|"uses loader"| node_loader
node_dx -.->|"includes shim"| node_ddraw
node_ddraw -->|"calls host callbacks"| node_hostapi
node_hostapi -->|"draw callbacks"| node_renderer
node_renderer -->|"uses GPU interface"| node_gpu
node_renderer -->|"submits frames"| node_present
node_app -->|"creates renderer"| node_renderer
node_app -->|"starts presenter"| node_present
node_app -->|"uses audio host"| node_audio
node_audio -->|"uses OS layer"| node_platform
node_mods -->|"exposes API"| node_modapi
node_modservices -->|"uses mod foundation"| node_mods
node_modservices -->|"uses display settings"| node_settings
node_app -->|"loads display defaults"| node_settings
node_app -.->|"routes controls"| node_controls
node_launcher -.->|"launches app"| node_app
node_win32 -.->|"delegates OS calls"| node_platform

click node_translator "https://github.com/veritr1x/recomp-kit/blob/main/tools/recomp/translate.py"
click node_launcher "https://github.com/veritr1x/recomp-kit/blob/main/web/launcher/core.js"
click node_app "https://github.com/veritr1x/recomp-kit/blob/main/host/sdl/main.cpp"
click node_loader "https://github.com/veritr1x/recomp-kit/blob/main/runtime/loader.h"
click node_guest "https://github.com/veritr1x/recomp-kit/blob/main/runtime/guest.h"
click node_imports "https://github.com/veritr1x/recomp-kit/blob/main/runtime/imports.h"
click node_kernel "https://github.com/veritr1x/recomp-kit/blob/main/runtime/kernel32.cpp"
click node_win32 "https://github.com/veritr1x/recomp-kit/blob/main/runtime/win32.h"
click node_dx "https://github.com/veritr1x/recomp-kit/blob/main/dx/dx.h"
click node_ddraw "https://github.com/veritr1x/recomp-kit/blob/main/dx/ddraw.cpp"
click node_hostapi "https://github.com/veritr1x/recomp-kit/blob/main/dx/host_api.h"
click node_renderer "https://github.com/veritr1x/recomp-kit/blob/main/host/d3d_render.cpp"
click node_gpu "https://github.com/veritr1x/recomp-kit/blob/main/host/gpu/gpu_factory.cpp"
click node_present "https://github.com/veritr1x/recomp-kit/blob/main/host/present.h"
click node_audio "https://github.com/veritr1x/recomp-kit/blob/main/host/audio/mixer.cpp"
click node_platform "https://github.com/veritr1x/recomp-kit/blob/main/platform/os.h"
click node_mods "https://github.com/veritr1x/recomp-kit/blob/main/mods/mods_internal.h"
click node_modapi "https://github.com/veritr1x/recomp-kit/blob/main/mods/pop_mod_api.h"
click node_modservices "https://github.com/veritr1x/recomp-kit/blob/main/mods/host_services.cpp"
click node_controls "https://github.com/veritr1x/recomp-kit/blob/main/host/controls/router.h"
click node_settings "https://github.com/veritr1x/recomp-kit/blob/main/mods/display_settings.h"

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_translator,node_launcher toneBlue
class node_loader,node_guest,node_imports,node_kernel,node_win32 toneAmber
class node_dx,node_ddraw,node_hostapi toneMint
class node_app,node_renderer,node_gpu,node_present,node_audio,node_platform toneRose
class node_mods,node_modapi,node_modservices,node_controls,node_settings,node_game toneIndigo
```

## Components

### Game translation

- [Static translator](https://github.com/veritr1x/recomp-kit/blob/main/tools/recomp/translate.py): `tools/recomp/translate.py`
- [Web launcher](https://github.com/veritr1x/recomp-kit/blob/main/web/launcher/core.js): `web/launcher/core.js`

### Guest runtime

- [PE loader](https://github.com/veritr1x/recomp-kit/blob/main/runtime/loader.h): `runtime/loader.h`
- [Guest CPU and memory](https://github.com/veritr1x/recomp-kit/blob/main/runtime/guest.h): `runtime/guest.h`
- [Import dispatch](https://github.com/veritr1x/recomp-kit/blob/main/runtime/imports.h): `runtime/imports.h`
- [Kernel32 shims](https://github.com/veritr1x/recomp-kit/blob/main/runtime/kernel32.cpp): `runtime/kernel32.cpp`
- [Win32 services](https://github.com/veritr1x/recomp-kit/blob/main/runtime/win32.h): `runtime/win32.h`

### Compatibility shims

- [DirectX shims](https://github.com/veritr1x/recomp-kit/blob/main/dx/dx.h): `dx/dx.h`
- [DirectDraw shim](https://github.com/veritr1x/recomp-kit/blob/main/dx/ddraw.cpp): `dx/ddraw.cpp`
- [Shim callbacks](https://github.com/veritr1x/recomp-kit/blob/main/dx/host_api.h): `dx/host_api.h`

### Native host

- [SDL host entry](https://github.com/veritr1x/recomp-kit/blob/main/host/sdl/main.cpp): `host/sdl/main.cpp`
- [D3D renderer](https://github.com/veritr1x/recomp-kit/blob/main/host/d3d_render.cpp): `host/d3d_render.cpp`
- [GPU backends](https://github.com/veritr1x/recomp-kit/blob/main/host/gpu/gpu_factory.cpp): `host/gpu/gpu_factory.cpp`
- [Frame presentation](https://github.com/veritr1x/recomp-kit/blob/main/host/present.h): `host/present.h`
- [Audio mixer](https://github.com/veritr1x/recomp-kit/blob/main/host/audio/mixer.cpp): `host/audio/mixer.cpp`
- [OS abstraction](https://github.com/veritr1x/recomp-kit/blob/main/platform/os.h): `platform/os.h`

### Mods and controls

- [Mod foundation](https://github.com/veritr1x/recomp-kit/blob/main/mods/mods_internal.h): `mods/mods_internal.h`
- [Mod API](https://github.com/veritr1x/recomp-kit/blob/main/mods/pop_mod_api.h): `mods/pop_mod_api.h`
- [Host mod services](https://github.com/veritr1x/recomp-kit/blob/main/mods/host_services.cpp): `mods/host_services.cpp`
- [Touch controls](https://github.com/veritr1x/recomp-kit/blob/main/host/controls/router.h): `host/controls/router.h`
- [Display settings](https://github.com/veritr1x/recomp-kit/blob/main/mods/display_settings.h): `mods/display_settings.h`

### Other components

- **Game repository**

## Connections

- Game repository → Static translator: provides inputs (evidence: `README.md`)
- Static translator → PE loader: generates game code
- SDL host entry → PE loader: starts runtime (evidence: `host/sdl/main.cpp`)
- PE loader → Guest CPU and memory: loads guest (evidence: `runtime/loader.h`)
- Guest CPU and memory → Import dispatch: dispatches imports (evidence: `runtime/imports.h`)
- Import dispatch → Kernel32 shims: routes APIs (evidence: `runtime/kernel32.cpp`)
- Kernel32 shims → Win32 services: uses services (evidence: `runtime/kernel32.cpp`)
- Kernel32 shims → PE loader: uses loader (evidence: `runtime/kernel32.cpp`)
- DirectX shims → DirectDraw shim: includes shim (evidence: `dx/ddraw.cpp`)
- DirectDraw shim → Shim callbacks: calls host callbacks (evidence: `dx/ddraw.cpp`)
- Shim callbacks → D3D renderer: draw callbacks
- D3D renderer → GPU backends: uses GPU interface
- D3D renderer → Frame presentation: submits frames (evidence: `host/d3d_render.cpp`)
- SDL host entry → D3D renderer: creates renderer (evidence: `host/sdl/main.cpp`)
- SDL host entry → Frame presentation: starts presenter (evidence: `host/sdl/main.cpp`)
- SDL host entry → Audio mixer: uses audio host (evidence: `host/sdl/main.cpp`)
- Audio mixer → OS abstraction: uses OS layer (evidence: `host/audio/mixer.cpp`)
- Mod foundation → Mod API: exposes API (evidence: `mods/mods_internal.h`)
- Host mod services → Mod foundation: uses mod foundation (evidence: `mods/host_services.cpp`)
- Host mod services → Display settings: uses display settings (evidence: `mods/host_services.cpp`)
- SDL host entry → Display settings: loads display defaults (evidence: `host/sdl/main.cpp`)
- SDL host entry → Touch controls: routes controls
- Web launcher → SDL host entry: launches app
- Win32 services → OS abstraction: delegates OS calls
