# harbourmasters/ghostship architecture

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

- Interactive diagram: https://gitdiagram.com/harbourmasters/ghostship
- Repository: https://github.com/harbourmasters/ghostship

## Overview

Ghostship is a Super Mario 64 port and launcher that extracts game resources from a user-supplied supported ROM, then runs the game with custom assets, audio, rendering, and platform support. The main flow is ROM selection, extraction, engine initialization, and gameplay; mods and saves are additional user-facing capabilities. The source excerpts show the engine’s extraction and graphics-command handling, while the README documents Android setup and mod/save management. Several subsystem links are documented or implied but their implementation was not sampled, so those links are omitted or marked unverified.

Main entry points: [`src/port/Engine.cpp`](https://github.com/harbourmasters/ghostship/blob/develop/src/port/Engine.cpp) (Game engine), [`src/game/main.c`](https://github.com/harbourmasters/ghostship/blob/develop/src/game/main.c) (Game loop), [`src/port/GameExtractor.cpp`](https://github.com/harbourmasters/ghostship/blob/develop/src/port/GameExtractor.cpp) (ROM extractor), [`src/engine/level_script.c`](https://github.com/harbourmasters/ghostship/blob/develop/src/engine/level_script.c) (Level scripts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_launch["Launch and assets"]
  node_engine["Game engine<br/>[Engine.cpp]"]
  node_extractor["ROM extractor<br/>[GameExtractor.cpp]"]
  node_assets[("Asset archives")]
end

subgraph group_runtime["Game runtime"]
  node_game_loop["Game loop<br/>[main.c]"]
  node_player_state["Player movement<br/>[mario.c]"]
  node_objects["Object behaviors<br/>[behavior_data.c]"]
  node_level_runtime["Level scripts<br/>[level_script.c]"]
  node_scene_graph["Scene graph"]
  node_render["Graphics output"]
end

subgraph group_content["Game content"]
  node_levels["Level definitions"]
  node_menus["Menus and saves<br/>[file_select.c]"]
end

subgraph group_port["Port services"]
  node_audio["Audio system"]
  node_events["Engine events<br/>[EngineEvent.h]"]
  node_interpolation["Frame interpolation"]
  node_randomizer["Randomizer"]
  node_network["Satella client<br/>[SatellaClient.cpp]"]
end

subgraph group_android["Android app"]
  node_android_launcher["Android launcher"]
  node_android_game["SDL game activity<br/>[SDLActivity.java]"]
  node_android_mods["Mod management<br/>[ModsActivity.kt]"]
  node_android_saves[("Save management<br/>[SaveStore.kt]")]
end

node_player(("Player"))
node_rom["Supported ROM"]

node_player -->|"provides"| node_rom
node_player -->|"selects ROM"| node_android_launcher
node_android_launcher -.->|"starts game"| node_android_game
node_engine -->|"runs extraction"| node_extractor
node_extractor -->|"creates archive"| node_assets
node_engine -.->|"initializes runtime"| node_game_loop
node_game_loop -.->|"updates"| node_player_state
node_game_loop -.->|"processes behaviors"| node_objects
node_game_loop -.->|"runs levels"| node_level_runtime
node_level_runtime -.->|"dispatches scripts"| node_levels
node_game_loop -.->|"builds scene"| node_scene_graph
node_engine -->|"processes graphics"| node_render
node_game_loop -->|"uses audio"| node_audio
node_engine -.->|"dispatches events"| node_events
node_events -->|"defines scene hooks"| node_scene_graph
node_engine -->|"uses interpolation"| node_interpolation
node_player -->|"manages mods"| node_android_mods
node_player -->|"manages saves"| node_android_saves
node_engine -.->|"offers randomizer"| node_randomizer
node_engine -.->|"optional service"| node_network

click node_engine "https://github.com/harbourmasters/ghostship/blob/develop/src/port/Engine.cpp"
click node_extractor "https://github.com/harbourmasters/ghostship/blob/develop/src/port/GameExtractor.cpp"
click node_assets "https://github.com/harbourmasters/ghostship/tree/develop/src/port/importer"
click node_game_loop "https://github.com/harbourmasters/ghostship/blob/develop/src/game/main.c"
click node_player_state "https://github.com/harbourmasters/ghostship/blob/develop/src/game/mario.c"
click node_objects "https://github.com/harbourmasters/ghostship/blob/develop/data/behavior_data.c"
click node_level_runtime "https://github.com/harbourmasters/ghostship/blob/develop/src/engine/level_script.c"
click node_scene_graph "https://github.com/harbourmasters/ghostship/blob/develop/src/engine/graph_node_manager.c"
click node_render "https://github.com/harbourmasters/ghostship/blob/develop/src/game/rendering_graph_node.c"
click node_levels "https://github.com/harbourmasters/ghostship/tree/develop/levels"
click node_menus "https://github.com/harbourmasters/ghostship/blob/develop/src/menu/file_select.c"
click node_audio "https://github.com/harbourmasters/ghostship/tree/develop/src/audio"
click node_events "https://github.com/harbourmasters/ghostship/blob/develop/src/port/events/list/EngineEvent.h"
click node_interpolation "https://github.com/harbourmasters/ghostship/blob/develop/src/port/interpolation/FrameInterpolation.h"
click node_randomizer "https://github.com/harbourmasters/ghostship/tree/develop/src/port/Rando"
click node_network "https://github.com/harbourmasters/ghostship/blob/develop/src/port/net/SatellaClient.cpp"
click node_android_launcher "https://github.com/harbourmasters/ghostship/blob/develop/android/app/src/main/java/dev/net64/ghostship/LauncherActivity.kt"
click node_android_game "https://github.com/harbourmasters/ghostship/blob/develop/android/app/src/main/java/org/libsdl/app/SDLActivity.java"
click node_android_mods "https://github.com/harbourmasters/ghostship/blob/develop/android/app/src/main/java/dev/net64/ghostship/ModsActivity.kt"
click node_android_saves "https://github.com/harbourmasters/ghostship/blob/develop/android/app/src/main/java/dev/net64/ghostship/SaveStore.kt"

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_engine,node_extractor,node_assets toneBlue
class node_game_loop,node_player_state,node_objects,node_level_runtime,node_scene_graph,node_render toneAmber
class node_levels,node_menus toneMint
class node_audio,node_events,node_interpolation,node_randomizer,node_network toneRose
class node_android_launcher,node_android_game,node_android_mods,node_android_saves,node_player,node_rom toneIndigo
```

## Components

### Launch and assets

- [Game engine](https://github.com/harbourmasters/ghostship/blob/develop/src/port/Engine.cpp): `src/port/Engine.cpp`
- [ROM extractor](https://github.com/harbourmasters/ghostship/blob/develop/src/port/GameExtractor.cpp): `src/port/GameExtractor.cpp`
- [Asset archives](https://github.com/harbourmasters/ghostship/tree/develop/src/port/importer): `src/port/importer`

### Game runtime

- [Game loop](https://github.com/harbourmasters/ghostship/blob/develop/src/game/main.c): `src/game/main.c`
- [Player movement](https://github.com/harbourmasters/ghostship/blob/develop/src/game/mario.c): `src/game/mario.c`
- [Object behaviors](https://github.com/harbourmasters/ghostship/blob/develop/data/behavior_data.c): `data/behavior_data.c`
- [Level scripts](https://github.com/harbourmasters/ghostship/blob/develop/src/engine/level_script.c): `src/engine/level_script.c`
- [Scene graph](https://github.com/harbourmasters/ghostship/blob/develop/src/engine/graph_node_manager.c): `src/engine/graph_node_manager.c`
- [Graphics output](https://github.com/harbourmasters/ghostship/blob/develop/src/game/rendering_graph_node.c): `src/game/rendering_graph_node.c`

### Game content

- [Level definitions](https://github.com/harbourmasters/ghostship/tree/develop/levels): `levels`
- [Menus and saves](https://github.com/harbourmasters/ghostship/blob/develop/src/menu/file_select.c): `src/menu/file_select.c`

### Port services

- [Audio system](https://github.com/harbourmasters/ghostship/tree/develop/src/audio): `src/audio`
- [Engine events](https://github.com/harbourmasters/ghostship/blob/develop/src/port/events/list/EngineEvent.h): `src/port/events/list/EngineEvent.h`
- [Frame interpolation](https://github.com/harbourmasters/ghostship/blob/develop/src/port/interpolation/FrameInterpolation.h): `src/port/interpolation/FrameInterpolation.h`
- [Randomizer](https://github.com/harbourmasters/ghostship/tree/develop/src/port/Rando): `src/port/Rando`
- [Satella client](https://github.com/harbourmasters/ghostship/blob/develop/src/port/net/SatellaClient.cpp): `src/port/net/SatellaClient.cpp`

### Android app

- [Android launcher](https://github.com/harbourmasters/ghostship/blob/develop/android/app/src/main/java/dev/net64/ghostship/LauncherActivity.kt): `android/app/src/main/java/dev/net64/ghostship/LauncherActivity.kt`
- [SDL game activity](https://github.com/harbourmasters/ghostship/blob/develop/android/app/src/main/java/org/libsdl/app/SDLActivity.java): `android/app/src/main/java/org/libsdl/app/SDLActivity.java`
- [Mod management](https://github.com/harbourmasters/ghostship/blob/develop/android/app/src/main/java/dev/net64/ghostship/ModsActivity.kt): `android/app/src/main/java/dev/net64/ghostship/ModsActivity.kt`
- [Save management](https://github.com/harbourmasters/ghostship/blob/develop/android/app/src/main/java/dev/net64/ghostship/SaveStore.kt): `android/app/src/main/java/dev/net64/ghostship/SaveStore.kt`

### Other components

- **Player**
- **Supported ROM**

## Connections

- Player → Supported ROM: provides (evidence: `README.md`)
- Player → Android launcher: selects ROM (evidence: `README.md`)
- Android launcher → SDL game activity: starts game
- Game engine → ROM extractor: runs extraction (evidence: `src/port/Engine.cpp`)
- ROM extractor → Asset archives: creates archive (evidence: `README.md`)
- Game engine → Game loop: initializes runtime
- Game loop → Player movement: updates
- Game loop → Object behaviors: processes behaviors
- Game loop → Level scripts: runs levels
- Level scripts → Level definitions: dispatches scripts
- Game loop → Scene graph: builds scene
- Game engine → Graphics output: processes graphics (evidence: `src/port/Engine.cpp`)
- Game loop → Audio system: uses audio (evidence: `src/game/main.c`)
- Game engine → Engine events: dispatches events
- Engine events → Scene graph: defines scene hooks (evidence: `src/port/events/list/EngineEvent.h`)
- Game engine → Frame interpolation: uses interpolation (evidence: `src/port/Engine.cpp`)
- Player → Mod management: manages mods (evidence: `README.md`)
- Player → Save management: manages saves (evidence: `README.md`)
- Game engine → Randomizer: offers randomizer
- Game engine → Satella client: optional service
