# viny182/mystery-sdl architecture

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

- Interactive diagram: https://gitdiagram.com/viny182/mystery-sdl
- Repository: https://github.com/viny182/mystery-sdl

## Overview

mystery-sdl is an SDL2/Linux recreation of the Mystery screensaver. Its main workflow loads the user's original Mystery.dll, initializes the scene and actors, advances sprite animations, and renders video and sound through SDL; options include wide-screen and headless frame-dump modes. A separate optional tool extracts scene tables and sprite artwork into JSON and an interactive viewer. The single C source is only partially excerpted, so internal runtime links not established by the excerpts or README are omitted.

Main entry points: [`tools/dump_scene.py`](https://github.com/viny182/mystery-sdl/blob/main/tools/dump_scene.py) (Scene extraction), [`mystery_sdl.c`](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c) (DLL resource loader), [`tools/viewer_template.html`](https://github.com/viny182/mystery-sdl/blob/main/tools/viewer_template.html) (Viewer template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Screensaver runtime"]
  node_cli["Options and startup<br/>[mystery_sdl.c]"]
  node_loader["DLL resource loader<br/>[mystery_sdl.c]"]
  node_decoder["DCL bitmap decoder<br/>[mystery_sdl.c]"]
  node_scene["Scene tables<br/>[mystery_sdl.c]"]
  node_static["Static scenery<br/>[mystery_sdl.c]"]
  node_actors["Actor state machine<br/>[mystery_sdl.c]"]
  node_sprites["Sprite paths<br/>[mystery_sdl.c]"]
  node_audio["Sound playback<br/>[mystery_sdl.c]"]
  node_render["Frame rendering<br/>[mystery_sdl.c]"]
end

subgraph group_viewer["Scene viewer"]
  node_dump_tool["Scene extraction<br/>[dump_scene.py]"]
  node_scene_json["Scene JSON"]
  node_template["Viewer template"]
  node_viewer_html["Interactive scene viewer"]
end

node_user(("User"))
node_dll["Mystery.dll"]
node_sdl["SDL video and audio"]
node_display["Screen output"]
node_speaker["Audio output"]
node_exe["Built mystery executable"]
node_magick["ImageMagick"]

node_user -->|"starts"| node_cli
node_cli -->|"loads"| node_loader
node_dll -->|"provides resources"| node_loader
node_loader -->|"decodes bitmaps"| node_decoder
node_loader -->|"reads tables"| node_scene
node_scene -.->|"defines scenery"| node_static
node_scene -->|"defines actors"| node_actors
node_actors -.->|"advances animations"| node_sprites
node_sprites -->|"plays step sounds"| node_audio
node_static -.->|"draws scenery"| node_render
node_sprites -.->|"draws sprites"| node_render
node_render -->|"outputs frames"| node_sdl
node_audio -->|"queues sound"| node_sdl
node_sdl -->|"presents video"| node_display
node_sdl -->|"outputs audio"| node_speaker
node_user -->|"runs optionally"| node_dump_tool
node_dump_tool -->|"reads"| node_dll
node_dump_tool -->|"writes"| node_scene_json
node_dump_tool -->|"loads"| node_template
node_dump_tool -->|"runs for reference frame"| node_exe
node_dump_tool -->|"converts frame"| node_magick
node_dump_tool -->|"builds"| node_viewer_html

click node_cli "https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c"
click node_loader "https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c"
click node_decoder "https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c"
click node_scene "https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c"
click node_static "https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c"
click node_actors "https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c"
click node_sprites "https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c"
click node_audio "https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c"
click node_render "https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c"
click node_dump_tool "https://github.com/viny182/mystery-sdl/blob/main/tools/dump_scene.py"
click node_template "https://github.com/viny182/mystery-sdl/blob/main/tools/viewer_template.html"

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_cli,node_loader,node_decoder,node_scene,node_static,node_actors,node_sprites,node_audio,node_render,node_user,node_display toneBlue
class node_dump_tool,node_scene_json,node_template,node_viewer_html toneAmber
class node_dll,node_sdl,node_speaker,node_exe,node_magick toneIndigo
```

## Components

### Screensaver runtime

- [Options and startup](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c): `mystery_sdl.c`
- [DLL resource loader](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c): `mystery_sdl.c`
- [DCL bitmap decoder](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c): `mystery_sdl.c`
- [Scene tables](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c): `mystery_sdl.c`
- [Static scenery](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c): `mystery_sdl.c`
- [Actor state machine](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c): `mystery_sdl.c`
- [Sprite paths](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c): `mystery_sdl.c`
- [Sound playback](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c): `mystery_sdl.c`
- [Frame rendering](https://github.com/viny182/mystery-sdl/blob/main/mystery_sdl.c): `mystery_sdl.c`

### Scene viewer

- [Scene extraction](https://github.com/viny182/mystery-sdl/blob/main/tools/dump_scene.py): `tools/dump_scene.py`
- **Scene JSON**
- [Viewer template](https://github.com/viny182/mystery-sdl/blob/main/tools/viewer_template.html): `tools/viewer_template.html`
- **Interactive scene viewer**

### Other components

- **User**
- **Mystery.dll**
- **SDL video and audio**
- **Screen output**
- **Audio output**
- **Built mystery executable**
- **ImageMagick**

## Connections

- User → Options and startup: starts (evidence: `README.md`)
- Options and startup → DLL resource loader: loads (evidence: `README.md`)
- Mystery.dll → DLL resource loader: provides resources (evidence: `README.md`)
- DLL resource loader → DCL bitmap decoder: decodes bitmaps (evidence: `mystery_sdl.c`)
- DLL resource loader → Scene tables: reads tables (evidence: `README.md`)
- Scene tables → Static scenery: defines scenery (evidence: `mystery_sdl.c`)
- Scene tables → Actor state machine: defines actors (evidence: `README.md`)
- Actor state machine → Sprite paths: advances animations (evidence: `mystery_sdl.c`)
- Sprite paths → Sound playback: plays step sounds (evidence: `mystery_sdl.c`)
- Static scenery → Frame rendering: draws scenery (evidence: `mystery_sdl.c`)
- Sprite paths → Frame rendering: draws sprites (evidence: `mystery_sdl.c`)
- Frame rendering → SDL video and audio: outputs frames (evidence: `README.md`)
- Sound playback → SDL video and audio: queues sound (evidence: `mystery_sdl.c`)
- SDL video and audio → Screen output: presents video (evidence: `README.md`)
- SDL video and audio → Audio output: outputs audio (evidence: `README.md`)
- User → Scene extraction: runs optionally (evidence: `README.md`)
- Scene extraction → Mystery.dll: reads (evidence: `tools/dump_scene.py`)
- Scene extraction → Scene JSON: writes (evidence: `tools/dump_scene.py`)
- Scene extraction → Viewer template: loads (evidence: `tools/dump_scene.py`)
- Scene extraction → Built mystery executable: runs for reference frame (evidence: `tools/dump_scene.py`)
- Scene extraction → ImageMagick: converts frame (evidence: `tools/dump_scene.py`)
- Scene extraction → Interactive scene viewer: builds (evidence: `README.md`)
