# mstan/supermarioworldrecomp architecture

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

- Interactive diagram: https://gitdiagram.com/mstan/supermarioworldrecomp
- Repository: https://github.com/mstan/supermarioworldrecomp

## Overview

SuperMarioWorldRecomp is a native-C static recompile of Super Mario World: generated CPU-game logic runs against an emulated SNES hardware core, then host rendering and audio present the result. The main user journey is supplying a legal ROM, optionally selecting a mode or mod, and playing; co-op adds ROM patching and synchronized multiplayer. The README documents these product branches, while sampled source gives more detail on Falcon’s controller boundary. Framework internals and several listed subsystems were not sampled, so their internal links are omitted.

Main entry points: [`src/main.c`](https://github.com/mstan/supermarioworldrecomp/blob/main/src/main.c) (Launcher and Boot), [`src/mods/smw_falcon_plugin.c`](https://github.com/mstan/supermarioworldrecomp/blob/main/src/mods/smw_falcon_plugin.c) (Falcon Mod Activation), [`recomp/funcs.h`](https://github.com/mstan/supermarioworldrecomp/blob/main/recomp/funcs.h) (Recompiled Game Logic), [`src/foreign_controller.c`](https://github.com/mstan/supermarioworldrecomp/blob/main/src/foreign_controller.c) (Foreign Controller Registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_launcher["Launcher and Boot<br/>[main.c]"]
  node_settings["Runtime Settings<br/>[config.c]"]
  node_game_logic["Recompiled Game Logic<br/>[funcs.h]"]
  node_snes_core["SNES Hardware Core"]
  node_controller_input["Gamepad Input<br/>[main.c]"]
end

subgraph group_modes["Play Modes"]
  node_coop_patch["Co-op ROM Patch<br/>[coop_patch.c]"]
  node_netplay["Netplay Lobby"]
end

subgraph group_falcon["Falcon Mod"]
  node_foreign_registry["Foreign Controller Registry"]
  node_falcon_plugin["Falcon Mod Activation"]
  node_falcon_controller["Falcon Movement"]
  node_falcon_bridge["SMW Falcon Adapter"]
  node_falcon_presentation["Falcon Presentation"]
end

subgraph group_presentation["Host Presentation"]
  node_renderer["Adaptive Renderer<br/>[smw_renderer.c]"]
  node_renderer_hooks["Renderer Hooks"]
  node_audio["SPC Audio Playback<br/>[smw_spc_player.c]"]
end

subgraph group_integrations["Optional Integrations"]
  node_lua["Lua Fire Stream<br/>[lua_fire_stream.c]"]
  node_msu["MSU-1 Audio Mod<br/>[smw_msu1_plugin.c]"]
end

node_player(("Player"))
node_rom["SMW ROM"]
node_lobby_service["Lobby Service"]
node_owner_rom["Smash Bros. ROM"]

node_player -->|"starts game"| node_launcher
node_rom -->|"loads ROM"| node_launcher
node_launcher -->|"reads settings"| node_settings
node_launcher -->|"runs gameplay"| node_game_logic
node_game_logic -->|"uses hardware emulation"| node_snes_core
node_launcher -->|"prepares co-op ROM"| node_coop_patch
node_coop_patch -->|"patches stock ROM"| node_rom
node_launcher -->|"opens lobby"| node_netplay
node_netplay -.->|"publishes room"| node_lobby_service
node_player -->|"provides controls"| node_controller_input
node_launcher -->|"activates mod"| node_falcon_plugin
node_falcon_plugin -->|"resolves assets"| node_owner_rom
node_falcon_plugin -->|"activates presentation"| node_falcon_presentation
node_falcon_plugin -->|"selects controller"| node_foreign_registry
node_foreign_registry -.->|"registers controller"| node_falcon_controller
node_falcon_bridge -->|"ticks movement"| node_foreign_registry
node_falcon_bridge -->|"hooks physics"| node_game_logic
node_launcher -->|"initializes renderer"| node_renderer
node_renderer_hooks -.->|"hooks rendering"| node_game_logic
node_launcher -->|"initializes audio"| node_audio
node_launcher -->|"enables scripting"| node_lua
node_launcher -.->|"loads optional mod"| node_msu

click node_launcher "https://github.com/mstan/supermarioworldrecomp/blob/main/src/main.c"
click node_settings "https://github.com/mstan/supermarioworldrecomp/blob/main/src/config.c"
click node_game_logic "https://github.com/mstan/supermarioworldrecomp/blob/main/recomp/funcs.h"
click node_coop_patch "https://github.com/mstan/supermarioworldrecomp/blob/main/src/coop_patch.c"
click node_netplay "https://github.com/mstan/supermarioworldrecomp/blob/main/src/smw_netplay_lobby.c"
click node_controller_input "https://github.com/mstan/supermarioworldrecomp/blob/main/src/main.c"
click node_foreign_registry "https://github.com/mstan/supermarioworldrecomp/blob/main/src/foreign_controller.c"
click node_falcon_plugin "https://github.com/mstan/supermarioworldrecomp/blob/main/src/mods/smw_falcon_plugin.c"
click node_falcon_controller "https://github.com/mstan/supermarioworldrecomp/blob/main/src/mods/falcon/captain_falcon_controller.c"
click node_falcon_bridge "https://github.com/mstan/supermarioworldrecomp/blob/main/overrides/falcon/falcon_smw_adapter.c"
click node_falcon_presentation "https://github.com/mstan/supermarioworldrecomp/blob/main/src/mods/falcon/smw_falcon_presentation_runtime.c"
click node_renderer "https://github.com/mstan/supermarioworldrecomp/blob/main/src/smw_renderer.c"
click node_renderer_hooks "https://github.com/mstan/supermarioworldrecomp/blob/main/src/smw_renderer_hooks.c"
click node_audio "https://github.com/mstan/supermarioworldrecomp/blob/main/src/smw_spc_player.c"
click node_lua "https://github.com/mstan/supermarioworldrecomp/blob/main/src/lua_fire_stream.c"
click node_msu "https://github.com/mstan/supermarioworldrecomp/blob/main/src/mods/smw_msu1_plugin.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_settings,node_game_logic,node_snes_core,node_controller_input toneBlue
class node_coop_patch,node_netplay toneAmber
class node_foreign_registry,node_falcon_plugin,node_falcon_controller,node_falcon_bridge,node_falcon_presentation toneMint
class node_renderer,node_renderer_hooks,node_audio toneRose
class node_lua,node_msu,node_player,node_rom,node_lobby_service,node_owner_rom toneIndigo
```

## Components

### Game Runtime

- [Launcher and Boot](https://github.com/mstan/supermarioworldrecomp/blob/main/src/main.c): `src/main.c`
- [Runtime Settings](https://github.com/mstan/supermarioworldrecomp/blob/main/src/config.c): `src/config.c`
- [Recompiled Game Logic](https://github.com/mstan/supermarioworldrecomp/blob/main/recomp/funcs.h): `recomp/funcs.h`
- **SNES Hardware Core**
- [Gamepad Input](https://github.com/mstan/supermarioworldrecomp/blob/main/src/main.c): `src/main.c`

### Play Modes

- [Co-op ROM Patch](https://github.com/mstan/supermarioworldrecomp/blob/main/src/coop_patch.c): `src/coop_patch.c`
- [Netplay Lobby](https://github.com/mstan/supermarioworldrecomp/blob/main/src/smw_netplay_lobby.c): `src/smw_netplay_lobby.c`

### Falcon Mod

- [Foreign Controller Registry](https://github.com/mstan/supermarioworldrecomp/blob/main/src/foreign_controller.c): `src/foreign_controller.c`
- [Falcon Mod Activation](https://github.com/mstan/supermarioworldrecomp/blob/main/src/mods/smw_falcon_plugin.c): `src/mods/smw_falcon_plugin.c`
- [Falcon Movement](https://github.com/mstan/supermarioworldrecomp/blob/main/src/mods/falcon/captain_falcon_controller.c): `src/mods/falcon/captain_falcon_controller.c`
- [SMW Falcon Adapter](https://github.com/mstan/supermarioworldrecomp/blob/main/overrides/falcon/falcon_smw_adapter.c): `overrides/falcon/falcon_smw_adapter.c`
- [Falcon Presentation](https://github.com/mstan/supermarioworldrecomp/blob/main/src/mods/falcon/smw_falcon_presentation_runtime.c): `src/mods/falcon/smw_falcon_presentation_runtime.c`

### Host Presentation

- [Adaptive Renderer](https://github.com/mstan/supermarioworldrecomp/blob/main/src/smw_renderer.c): `src/smw_renderer.c`
- [Renderer Hooks](https://github.com/mstan/supermarioworldrecomp/blob/main/src/smw_renderer_hooks.c): `src/smw_renderer_hooks.c`
- [SPC Audio Playback](https://github.com/mstan/supermarioworldrecomp/blob/main/src/smw_spc_player.c): `src/smw_spc_player.c`

### Optional Integrations

- [Lua Fire Stream](https://github.com/mstan/supermarioworldrecomp/blob/main/src/lua_fire_stream.c): `src/lua_fire_stream.c`
- [MSU-1 Audio Mod](https://github.com/mstan/supermarioworldrecomp/blob/main/src/mods/smw_msu1_plugin.c): `src/mods/smw_msu1_plugin.c`

### Other components

- **Player**
- **SMW ROM**
- **Lobby Service**
- **Smash Bros. ROM**

## Connections

- Player → Launcher and Boot: starts game (evidence: `README.md`)
- SMW ROM → Launcher and Boot: loads ROM (evidence: `README.md`)
- Launcher and Boot → Runtime Settings: reads settings (evidence: `src/main.c`)
- Launcher and Boot → Recompiled Game Logic: runs gameplay (evidence: `README.md`)
- Recompiled Game Logic → SNES Hardware Core: uses hardware emulation (evidence: `README.md`)
- Launcher and Boot → Co-op ROM Patch: prepares co-op ROM (evidence: `README.md`)
- Co-op ROM Patch → SMW ROM: patches stock ROM (evidence: `README.md`)
- Launcher and Boot → Netplay Lobby: opens lobby (evidence: `README.md`)
- Netplay Lobby → Lobby Service: publishes room (evidence: `README.md`)
- Player → Gamepad Input: provides controls (evidence: `README.md`)
- Launcher and Boot → Falcon Mod Activation: activates mod (evidence: `src/main.c`)
- Falcon Mod Activation → Smash Bros. ROM: resolves assets (evidence: `src/mods/smw_falcon_plugin.c`)
- Falcon Mod Activation → Falcon Presentation: activates presentation (evidence: `src/mods/smw_falcon_plugin.c`)
- Falcon Mod Activation → Foreign Controller Registry: selects controller (evidence: `src/mods/smw_falcon_plugin.c`)
- Foreign Controller Registry → Falcon Movement: registers controller
- SMW Falcon Adapter → Foreign Controller Registry: ticks movement (evidence: `overrides/falcon/falcon_smw_adapter.c`)
- SMW Falcon Adapter → Recompiled Game Logic: hooks physics
- Launcher and Boot → Adaptive Renderer: initializes renderer (evidence: `src/main.c`)
- Renderer Hooks → Recompiled Game Logic: hooks rendering (evidence: `README.md`)
- Launcher and Boot → SPC Audio Playback: initializes audio (evidence: `src/main.c`)
- Launcher and Boot → Lua Fire Stream: enables scripting (evidence: `README.md`)
- Launcher and Boot → MSU-1 Audio Mod: loads optional mod (evidence: `README.md`)
