# nukep/smbvanilla architecture

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

- Interactive diagram: https://gitdiagram.com/nukep/smbvanilla
- Repository: https://github.com/nukep/smbvanilla

## Overview

SMB Vanilla is a playable C/C++ reconstruction of Super Mario Bros. and Super Mario Bros. 2 Japan. The user supplies a ROM and launches the SDL frontend; the frontend initializes the game, gathers keyboard or movie input, advances the core, and presents frames through a renderer. The core contains shared gameplay and area logic plus game-specific SMB1 and SMB2J implementations. The README documents the two supported games and audio; source excerpts show frontend setup and renderer dispatch, but do not expose the complete frame loop or audio callback wiring, so uncertain links are omitted.

Main entry points: [`src/platform/main_sdl.c`](https://github.com/nukep/smbvanilla/blob/main/src/platform/main_sdl.c) (SDL Application), [`src/smbcore/smbcore.c`](https://github.com/nukep/smbvanilla/blob/main/src/smbcore/smbcore.c) (Game API), [`src/platform/config.h`](https://github.com/nukep/smbvanilla/blob/main/src/platform/config.h) (Runtime Config), [`src/smbcore/common.c`](https://github.com/nukep/smbvanilla/blob/main/src/smbcore/common.c) (Shared Gameplay)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["SDL Frontend"]
  node_sdl_app["SDL Application<br/>[main_sdl.c]"]
  node_config["Runtime Config<br/>[config.h]"]
  node_timer["SDL Timer<br/>[timer_sdl.c]"]
end

subgraph group_core["Game Core"]
  node_game_api["Game API<br/>[smbcore.c]"]
  node_shared_logic["Shared Gameplay<br/>[common.c]"]
  node_area_logic["Area Processing<br/>[area.c]"]
  node_smb1_logic["SMB1 Logic<br/>[smb1only.c]"]
  node_smb2j_logic["SMB2J Logic<br/>[smb2jonly.c]"]
end

subgraph group_render["Presentation"]
  node_opengl["OpenGL Renderer<br/>[render_opengl.c]"]
  node_raster["Raster Renderer<br/>[render_raster.c]"]
end

subgraph group_media["Input and Audio"]
  node_movie["Movie Playback<br/>[movie.c]"]
  node_audio["SDL Audio<br/>[audio_sdl.cpp]"]
end

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

node_player -->|"launches"| node_sdl_app
node_rom -->|"loads"| node_sdl_app
node_sdl_app -->|"reads settings"| node_config
node_config -->|"configures"| node_sdl_app
node_sdl_app -->|"initializes game"| node_game_api
node_sdl_app -->|"plays input"| node_movie
node_sdl_app -->|"dispatches rendering"| node_opengl
node_sdl_app -->|"dispatches rendering"| node_raster
node_sdl_app -.->|"uses timing"| node_timer
node_sdl_app -.->|"outputs audio"| node_audio
node_game_api -.->|"runs gameplay"| node_shared_logic
node_game_api -.->|"selects SMB1"| node_smb1_logic
node_game_api -.->|"selects SMB2J"| node_smb2j_logic
node_shared_logic -.->|"uses area logic"| node_area_logic

click node_sdl_app "https://github.com/nukep/smbvanilla/blob/main/src/platform/main_sdl.c"
click node_config "https://github.com/nukep/smbvanilla/blob/main/src/platform/config.h"
click node_game_api "https://github.com/nukep/smbvanilla/blob/main/src/smbcore/smbcore.c"
click node_shared_logic "https://github.com/nukep/smbvanilla/blob/main/src/smbcore/common.c"
click node_area_logic "https://github.com/nukep/smbvanilla/blob/main/src/smbcore/area.c"
click node_smb1_logic "https://github.com/nukep/smbvanilla/blob/main/src/smbcore/smb1only.c"
click node_smb2j_logic "https://github.com/nukep/smbvanilla/blob/main/src/smbcore/smb2jonly.c"
click node_movie "https://github.com/nukep/smbvanilla/blob/main/src/platform/movie.c"
click node_audio "https://github.com/nukep/smbvanilla/blob/main/src/platform/audio_sdl.cpp"
click node_opengl "https://github.com/nukep/smbvanilla/blob/main/src/platform/render_opengl.c"
click node_raster "https://github.com/nukep/smbvanilla/blob/main/src/platform/render_raster.c"
click node_timer "https://github.com/nukep/smbvanilla/blob/main/src/platform/timer_sdl.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_sdl_app,node_config,node_timer toneBlue
class node_game_api,node_shared_logic,node_area_logic,node_smb1_logic,node_smb2j_logic toneAmber
class node_opengl,node_raster toneMint
class node_movie,node_audio toneRose
class node_player,node_rom toneIndigo
```

## Components

### SDL Frontend

- [SDL Application](https://github.com/nukep/smbvanilla/blob/main/src/platform/main_sdl.c): `src/platform/main_sdl.c`
- [Runtime Config](https://github.com/nukep/smbvanilla/blob/main/src/platform/config.h): `src/platform/config.h`
- [SDL Timer](https://github.com/nukep/smbvanilla/blob/main/src/platform/timer_sdl.c): `src/platform/timer_sdl.c`

### Game Core

- [Game API](https://github.com/nukep/smbvanilla/blob/main/src/smbcore/smbcore.c): `src/smbcore/smbcore.c`
- [Shared Gameplay](https://github.com/nukep/smbvanilla/blob/main/src/smbcore/common.c): `src/smbcore/common.c`
- [Area Processing](https://github.com/nukep/smbvanilla/blob/main/src/smbcore/area.c): `src/smbcore/area.c`
- [SMB1 Logic](https://github.com/nukep/smbvanilla/blob/main/src/smbcore/smb1only.c): `src/smbcore/smb1only.c`
- [SMB2J Logic](https://github.com/nukep/smbvanilla/blob/main/src/smbcore/smb2jonly.c): `src/smbcore/smb2jonly.c`

### Presentation

- [OpenGL Renderer](https://github.com/nukep/smbvanilla/blob/main/src/platform/render_opengl.c): `src/platform/render_opengl.c`
- [Raster Renderer](https://github.com/nukep/smbvanilla/blob/main/src/platform/render_raster.c): `src/platform/render_raster.c`

### Input and Audio

- [Movie Playback](https://github.com/nukep/smbvanilla/blob/main/src/platform/movie.c): `src/platform/movie.c`
- [SDL Audio](https://github.com/nukep/smbvanilla/blob/main/src/platform/audio_sdl.cpp): `src/platform/audio_sdl.cpp`

### Other components

- **Player**
- **Game ROM**

## Connections

- Player → SDL Application: launches (evidence: `README.md`)
- Game ROM → SDL Application: loads (evidence: `README.md`)
- SDL Application → Runtime Config: reads settings (evidence: `src/platform/main_sdl.c`)
- Runtime Config → SDL Application: configures (evidence: `src/platform/main_sdl.c`)
- SDL Application → Game API: initializes game (evidence: `src/platform/main_sdl.c`)
- SDL Application → Movie Playback: plays input (evidence: `src/platform/main_sdl.c`)
- SDL Application → OpenGL Renderer: dispatches rendering (evidence: `src/platform/main_sdl.c`)
- SDL Application → Raster Renderer: dispatches rendering (evidence: `src/platform/main_sdl.c`)
- SDL Application → SDL Timer: uses timing
- SDL Application → SDL Audio: outputs audio
- Game API → Shared Gameplay: runs gameplay
- Game API → SMB1 Logic: selects SMB1
- Game API → SMB2J Logic: selects SMB2J
- Shared Gameplay → Area Processing: uses area logic
