# codepdbh/nfsu2-recompiled architecture

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

- Interactive diagram: https://gitdiagram.com/codepdbh/nfsu2-recompiled
- Repository: https://github.com/codepdbh/nfsu2-recompiled

## Overview

This repository provides a statically recompiled Need for Speed: Underground 2 game, with a playable Android ARM64 runtime and a Windows bring-up host. The principal Android workflow runs from launcher configuration and game-data selection through native guest startup, rendering, input, and audio. Supporting branches cover GPU-driver management and diagnostics, plus the Windows host’s runtime hooks and widescreen support. Several Android subsystems are documented in the README but their implementation was not sampled, so those connections are shown as unverified rather than asserted as inspected calls.

Main entry points: [`android/app/src/main/cpp/guest_runtime.cpp`](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/guest_runtime.cpp) (Guest execution), [`android/app/src/main/java/com/nfsu2/androidevolved/LauncherActivity.java`](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/LauncherActivity.java) (Launcher and settings), [`src/host/main.c`](https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/host/main.c) (Windows game host), [`android/app/src/main/java/com/nfsu2/androidevolved/GameActivity.java`](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/GameActivity.java) (Game activity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android_app["Android app"]
  node_launcher["Launcher and settings"]
  node_options["Game options<br/>[GameOptions.java]"]
  node_game_activity["Game activity<br/>[GameActivity.java]"]
  node_touch_controls["Touch controls"]
  node_game_data["Game data<br/>[game_data.h]"]
end

subgraph group_guest_runtime["Guest runtime"]
  node_native_entry["Native entry and renderer<br/>[main.cpp]"]
  node_boot_worker["Guest boot worker"]
  node_guest_execution["Guest execution<br/>[guest_runtime.cpp]"]
  node_guest_memory["Guest memory<br/>[guest_memory.h]"]
  node_guest_heap["Guest heap<br/>[guest_heap.h]"]
  node_audio["Audio streaming<br/>[audio_mixer.h]"]
  node_input["Gamepad input<br/>[gamepad_input.h]"]
end

subgraph group_graphics["Graphics"]
  node_d3d_bridge["D3D9 bridge<br/>[d3d9_bridge.cpp]"]
  node_vulkan["Vulkan driver<br/>[vulkan_driver.cpp]"]
  node_dxvk["DXVK Android port<br/>[android_wsi.cpp]"]
end

subgraph group_windows_host["Windows host"]
  node_windows_host["Windows game host<br/>[main.c]"]
  node_windows_runtime["Windows runtime<br/>[nfs_runtime.c]"]
  node_d3d_trace["D3D9 hooks and trace<br/>[d3d9_trace.c]"]
  node_widescreen["Widescreen and pacing<br/>[widescreen.c]"]
  node_logging["Runtime logging<br/>[nfs_log.c]"]
end

subgraph group_device_support["Device support"]
  node_driver_management["GPU driver management<br/>[GpuDrivers.java]"]
  node_diagnostics["Diagnostics and updates<br/>[Diagnostics.java]"]
end

node_player(("Player"))
node_gpu_device(("Vulkan device"))

node_player -->|"opens"| node_launcher
node_launcher -->|"reads and sets"| node_options
node_launcher -->|"launches"| node_game_activity
node_game_activity -->|"updates controls"| node_touch_controls
node_game_activity -->|"reads settings"| node_options
node_game_activity -.->|"configures native runtime"| node_native_entry
node_native_entry -->|"loads game data"| node_game_data
node_native_entry -->|"starts guest"| node_boot_worker
node_boot_worker -->|"connects runtime"| node_guest_execution
node_guest_execution -->|"uses guest memory"| node_guest_memory
node_guest_execution -->|"uses guest heap"| node_guest_heap
node_guest_execution -->|"calls graphics bridge"| node_d3d_bridge
node_guest_execution -->|"uses display hooks"| node_widescreen
node_guest_execution -.->|"streams audio"| node_audio
node_guest_execution -.->|"dispatches input"| node_input
node_d3d_bridge -.->|"translates rendering"| node_vulkan
node_vulkan -.->|"uses DXVK port"| node_dxvk
node_dxvk -.->|"renders on"| node_gpu_device
node_launcher -->|"manages drivers"| node_driver_management
node_launcher -->|"opens diagnostics"| node_diagnostics
node_driver_management -->|"persists selection"| node_options
node_windows_host -->|"runs guest runtime"| node_windows_runtime
node_windows_host -->|"hooks graphics"| node_d3d_trace
node_windows_host -->|"applies display fixes"| node_widescreen
node_d3d_trace -->|"sets resolution"| node_widescreen
node_windows_host -->|"records runtime events"| node_logging
node_windows_runtime -->|"reports runtime events"| node_logging

click node_launcher "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/LauncherActivity.java"
click node_options "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/GameOptions.java"
click node_game_activity "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/GameActivity.java"
click node_touch_controls "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/RacingControlsView.java"
click node_game_data "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/game_data.h"
click node_native_entry "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/main.cpp"
click node_boot_worker "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/guest_boot_worker.h"
click node_guest_execution "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/guest_runtime.cpp"
click node_guest_memory "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/guest_memory.h"
click node_guest_heap "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/guest_heap.h"
click node_audio "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/audio_mixer.h"
click node_input "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/gamepad_input.h"
click node_d3d_bridge "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/d3d9_bridge.cpp"
click node_vulkan "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/vulkan_driver.cpp"
click node_dxvk "https://github.com/codepdbh/nfsu2-recompiled/blob/main/ports/dxvk_android/android_wsi.cpp"
click node_driver_management "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/GpuDrivers.java"
click node_diagnostics "https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/Diagnostics.java"
click node_windows_host "https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/host/main.c"
click node_windows_runtime "https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/runtime/nfs_runtime.c"
click node_d3d_trace "https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/runtime/d3d9_trace.c"
click node_widescreen "https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/runtime/widescreen.c"
click node_logging "https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/platform/nfs_log.c"

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_launcher,node_options,node_game_activity,node_touch_controls,node_game_data toneBlue
class node_native_entry,node_boot_worker,node_guest_execution,node_guest_memory,node_guest_heap,node_audio,node_input toneAmber
class node_d3d_bridge,node_vulkan,node_dxvk toneMint
class node_windows_host,node_windows_runtime,node_d3d_trace,node_widescreen,node_logging toneRose
class node_driver_management,node_diagnostics,node_player,node_gpu_device toneIndigo
```

## Components

### Android app

- [Launcher and settings](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/LauncherActivity.java): `android/app/src/main/java/com/nfsu2/androidevolved/LauncherActivity.java`
- [Game options](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/GameOptions.java): `android/app/src/main/java/com/nfsu2/androidevolved/GameOptions.java`
- [Game activity](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/GameActivity.java): `android/app/src/main/java/com/nfsu2/androidevolved/GameActivity.java`
- [Touch controls](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/RacingControlsView.java): `android/app/src/main/java/com/nfsu2/androidevolved/RacingControlsView.java`
- [Game data](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/game_data.h): `android/app/src/main/cpp/game_data.h`

### Guest runtime

- [Native entry and renderer](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/main.cpp): `android/app/src/main/cpp/main.cpp`
- [Guest boot worker](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/guest_boot_worker.h): `android/app/src/main/cpp/guest_boot_worker.h`
- [Guest execution](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/guest_runtime.cpp): `android/app/src/main/cpp/guest_runtime.cpp`
- [Guest memory](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/guest_memory.h): `android/app/src/main/cpp/guest_memory.h`
- [Guest heap](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/guest_heap.h): `android/app/src/main/cpp/guest_heap.h`
- [Audio streaming](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/audio_mixer.h): `android/app/src/main/cpp/audio_mixer.h`
- [Gamepad input](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/gamepad_input.h): `android/app/src/main/cpp/gamepad_input.h`

### Graphics

- [D3D9 bridge](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/d3d9_bridge.cpp): `android/app/src/main/cpp/d3d9_bridge.cpp`
- [Vulkan driver](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/cpp/vulkan_driver.cpp): `android/app/src/main/cpp/vulkan_driver.cpp`
- [DXVK Android port](https://github.com/codepdbh/nfsu2-recompiled/blob/main/ports/dxvk_android/android_wsi.cpp): `ports/dxvk_android/android_wsi.cpp`

### Windows host

- [Windows game host](https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/host/main.c): `src/host/main.c`
- [Windows runtime](https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/runtime/nfs_runtime.c): `src/runtime/nfs_runtime.c`
- [D3D9 hooks and trace](https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/runtime/d3d9_trace.c): `src/runtime/d3d9_trace.c`
- [Widescreen and pacing](https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/runtime/widescreen.c): `src/runtime/widescreen.c`
- [Runtime logging](https://github.com/codepdbh/nfsu2-recompiled/blob/main/src/platform/nfs_log.c): `src/platform/nfs_log.c`

### Device support

- [GPU driver management](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/GpuDrivers.java): `android/app/src/main/java/com/nfsu2/androidevolved/GpuDrivers.java`
- [Diagnostics and updates](https://github.com/codepdbh/nfsu2-recompiled/blob/main/android/app/src/main/java/com/nfsu2/androidevolved/Diagnostics.java): `android/app/src/main/java/com/nfsu2/androidevolved/Diagnostics.java`

### Other components

- **Player**
- **Vulkan device**

## Connections

- Player → Launcher and settings: opens (evidence: `README.md`)
- Launcher and settings → Game options: reads and sets (evidence: `android/app/src/main/java/com/nfsu2/androidevolved/LauncherActivity.java`)
- Launcher and settings → Game activity: launches (evidence: `android/app/src/main/java/com/nfsu2/androidevolved/LauncherActivity.java`)
- Game activity → Touch controls: updates controls (evidence: `android/app/src/main/java/com/nfsu2/androidevolved/GameActivity.java`)
- Game activity → Game options: reads settings (evidence: `android/app/src/main/java/com/nfsu2/androidevolved/GameActivity.java`)
- Game activity → Native entry and renderer: configures native runtime
- Native entry and renderer → Game data: loads game data (evidence: `android/app/src/main/cpp/main.cpp`)
- Native entry and renderer → Guest boot worker: starts guest (evidence: `android/app/src/main/cpp/main.cpp`)
- Guest boot worker → Guest execution: connects runtime (evidence: `android/app/src/main/cpp/guest_boot_worker.h`)
- Guest execution → Guest memory: uses guest memory (evidence: `android/app/src/main/cpp/guest_runtime.cpp`)
- Guest execution → Guest heap: uses guest heap (evidence: `android/app/src/main/cpp/guest_runtime.cpp`)
- Guest execution → D3D9 bridge: calls graphics bridge (evidence: `android/app/src/main/cpp/guest_runtime.cpp`)
- Guest execution → Widescreen and pacing: uses display hooks (evidence: `android/app/src/main/cpp/guest_runtime.cpp`)
- Guest execution → Audio streaming: streams audio
- Guest execution → Gamepad input: dispatches input
- D3D9 bridge → Vulkan driver: translates rendering
- Vulkan driver → DXVK Android port: uses DXVK port
- DXVK Android port → Vulkan device: renders on
- Launcher and settings → GPU driver management: manages drivers (evidence: `android/app/src/main/java/com/nfsu2/androidevolved/LauncherActivity.java`)
- Launcher and settings → Diagnostics and updates: opens diagnostics (evidence: `android/app/src/main/java/com/nfsu2/androidevolved/LauncherActivity.java`)
- GPU driver management → Game options: persists selection (evidence: `android/app/src/main/java/com/nfsu2/androidevolved/GpuDrivers.java`)
- Windows game host → Windows runtime: runs guest runtime (evidence: `src/host/main.c`)
- Windows game host → D3D9 hooks and trace: hooks graphics (evidence: `src/host/main.c`)
- Windows game host → Widescreen and pacing: applies display fixes (evidence: `src/host/main.c`)
- D3D9 hooks and trace → Widescreen and pacing: sets resolution (evidence: `src/runtime/d3d9_trace.c`)
- Windows game host → Runtime logging: records runtime events (evidence: `src/host/main.c`)
- Windows runtime → Runtime logging: reports runtime events (evidence: `src/runtime/nfs_runtime.c`)
