# libretro/genesis-plus-gx architecture

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

- Interactive diagram: https://gitdiagram.com/libretro/genesis-plus-gx
- Repository: https://github.com/libretro/genesis-plus-gx

## Overview

Genesis Plus GX is a portable Sega 8/16-bit emulator, exposed through platform frontends such as libretro, SDL, and GameCube/Wii. The primary workflow is to load a game, run the selected emulated system, and present its audio/video while accepting controller input; save states and cartridge/CD hardware extend that workflow. The graph preserves major hardware and frontend capabilities from the README and tree. Internal links are limited to relationships shown in excerpts or documented by the README; unsampled subsystem wiring is not assumed.

Main entry points: [`core/system.c`](https://github.com/libretro/genesis-plus-gx/blob/master/core/system.c) (System Runtime), [`core/genesis.c`](https://github.com/libretro/genesis-plus-gx/blob/master/core/genesis.c) (Console Control), [`gx/main.c`](https://github.com/libretro/genesis-plus-gx/blob/master/gx/main.c) (GX Game Loop), [`libretro/libretro.c`](https://github.com/libretro/genesis-plus-gx/blob/master/libretro/libretro.c) (Libretro Frontend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontends["Platform Frontends"]
  node_libretro["Libretro Frontend<br/>[libretro.c]"]
  node_sdl["SDL Frontend<br/>[main.c]"]
  node_gamecube["GameCube/Wii Frontend<br/>[main.c]"]
  node_sdl_game["SDL Game Loop<br/>[main.c]"]
  node_gx_game["GX Game Loop<br/>[main.c]"]
  node_gx_files["GX File Selection<br/>[file_slot.c]"]
  node_gx_gui["GX Menus<br/>[menu.c]"]
end

subgraph group_runtime["Emulation Runtime"]
  node_system["System Runtime<br/>[system.c]"]
  node_genesis["Console Control<br/>[genesis.c]"]
  node_m68k["M68000 CPU<br/>[m68kcpu.c]"]
  node_z80["Z80 CPU<br/>[z80.c]"]
  node_memory["Memory Mapping<br/>[mem68k.c]"]
  node_video["Video Rendering<br/>[vdp_render.c]"]
  node_audio["Audio Synthesis<br/>[sound.c]"]
  node_ntsc["NTSC Filters<br/>[md_ntsc.c]"]
end

subgraph group_hardware["System Hardware"]
  node_input["Input Devices<br/>[input.c]"]
  node_cart["Cartridge Hardware<br/>[md_cart.c]"]
  node_sms_cart["8-bit Cartridge<br/>[sms_cart.c]"]
  node_cd["CD Hardware<br/>[scd.c]"]
end

subgraph group_media["Media And State"]
  node_rom["ROM Loading<br/>[loadrom.c]"]
  node_state["Save States<br/>[state.c]"]
end

node_user(("Player"))

node_user -->|"uses"| node_libretro
node_user -->|"uses"| node_sdl
node_user -->|"uses"| node_gamecube
node_sdl -->|"runs"| node_sdl_game
node_sdl_game -->|"advances frames"| node_system
node_gamecube -->|"starts"| node_gx_game
node_gx_game -->|"advances frames"| node_system
node_libretro -.->|"runs emulation"| node_system
node_gx_files -->|"opens selection"| node_gx_gui
node_gx_game -.->|"loads games"| node_gx_files
node_system -.->|"dispatches runtime"| node_genesis
node_genesis -.->|"runs CPU"| node_m68k
node_genesis -.->|"runs CPU"| node_z80
node_genesis -.->|"uses mappings"| node_memory
node_system -.->|"renders frames"| node_video
node_system -.->|"generates audio"| node_audio
node_system -.->|"reads controls"| node_input
node_system -.->|"supports hardware"| node_cart
node_system -.->|"supports hardware"| node_sms_cart
node_system -.->|"supports CD"| node_cd
node_system -.->|"loads software"| node_rom
node_system -.->|"saves state"| node_state
node_video -.->|"filters output"| node_ntsc

click node_libretro "https://github.com/libretro/genesis-plus-gx/blob/master/libretro/libretro.c"
click node_sdl "https://github.com/libretro/genesis-plus-gx/blob/master/sdl/sdl2/main.c"
click node_gamecube "https://github.com/libretro/genesis-plus-gx/blob/master/gx/main.c"
click node_sdl_game "https://github.com/libretro/genesis-plus-gx/blob/master/sdl/sdl2/main.c"
click node_gx_game "https://github.com/libretro/genesis-plus-gx/blob/master/gx/main.c"
click node_rom "https://github.com/libretro/genesis-plus-gx/blob/master/core/loadrom.c"
click node_system "https://github.com/libretro/genesis-plus-gx/blob/master/core/system.c"
click node_genesis "https://github.com/libretro/genesis-plus-gx/blob/master/core/genesis.c"
click node_m68k "https://github.com/libretro/genesis-plus-gx/blob/master/core/m68k/m68kcpu.c"
click node_z80 "https://github.com/libretro/genesis-plus-gx/blob/master/core/z80/z80.c"
click node_memory "https://github.com/libretro/genesis-plus-gx/blob/master/core/mem68k.c"
click node_video "https://github.com/libretro/genesis-plus-gx/blob/master/core/vdp_render.c"
click node_audio "https://github.com/libretro/genesis-plus-gx/blob/master/core/sound/sound.c"
click node_input "https://github.com/libretro/genesis-plus-gx/blob/master/core/input_hw/input.c"
click node_cart "https://github.com/libretro/genesis-plus-gx/blob/master/core/cart_hw/md_cart.c"
click node_sms_cart "https://github.com/libretro/genesis-plus-gx/blob/master/core/cart_hw/sms_cart.c"
click node_cd "https://github.com/libretro/genesis-plus-gx/blob/master/core/cd_hw/scd.c"
click node_state "https://github.com/libretro/genesis-plus-gx/blob/master/core/state.c"
click node_gx_files "https://github.com/libretro/genesis-plus-gx/blob/master/gx/fileio/file_slot.c"
click node_gx_gui "https://github.com/libretro/genesis-plus-gx/blob/master/gx/gui/menu.c"
click node_ntsc "https://github.com/libretro/genesis-plus-gx/blob/master/core/ntsc/md_ntsc.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_libretro,node_sdl,node_gamecube,node_sdl_game,node_gx_game,node_gx_files,node_gx_gui toneBlue
class node_system,node_genesis,node_m68k,node_z80,node_memory,node_video,node_audio,node_ntsc toneAmber
class node_input,node_cart,node_sms_cart,node_cd toneMint
class node_rom,node_state toneRose
class node_user toneIndigo
```

## Components

### Platform Frontends

- [Libretro Frontend](https://github.com/libretro/genesis-plus-gx/blob/master/libretro/libretro.c): `libretro/libretro.c`
- [SDL Frontend](https://github.com/libretro/genesis-plus-gx/blob/master/sdl/sdl2/main.c): `sdl/sdl2/main.c`
- [GameCube/Wii Frontend](https://github.com/libretro/genesis-plus-gx/blob/master/gx/main.c): `gx/main.c`
- [SDL Game Loop](https://github.com/libretro/genesis-plus-gx/blob/master/sdl/sdl2/main.c): `sdl/sdl2/main.c`
- [GX Game Loop](https://github.com/libretro/genesis-plus-gx/blob/master/gx/main.c): `gx/main.c`
- [GX File Selection](https://github.com/libretro/genesis-plus-gx/blob/master/gx/fileio/file_slot.c): `gx/fileio/file_slot.c`
- [GX Menus](https://github.com/libretro/genesis-plus-gx/blob/master/gx/gui/menu.c): `gx/gui/menu.c`

### Emulation Runtime

- [System Runtime](https://github.com/libretro/genesis-plus-gx/blob/master/core/system.c): `core/system.c`
- [Console Control](https://github.com/libretro/genesis-plus-gx/blob/master/core/genesis.c): `core/genesis.c`
- [M68000 CPU](https://github.com/libretro/genesis-plus-gx/blob/master/core/m68k/m68kcpu.c): `core/m68k/m68kcpu.c`
- [Z80 CPU](https://github.com/libretro/genesis-plus-gx/blob/master/core/z80/z80.c): `core/z80/z80.c`
- [Memory Mapping](https://github.com/libretro/genesis-plus-gx/blob/master/core/mem68k.c): `core/mem68k.c`
- [Video Rendering](https://github.com/libretro/genesis-plus-gx/blob/master/core/vdp_render.c): `core/vdp_render.c`
- [Audio Synthesis](https://github.com/libretro/genesis-plus-gx/blob/master/core/sound/sound.c): `core/sound/sound.c`
- [NTSC Filters](https://github.com/libretro/genesis-plus-gx/blob/master/core/ntsc/md_ntsc.c): `core/ntsc/md_ntsc.c`

### System Hardware

- [Input Devices](https://github.com/libretro/genesis-plus-gx/blob/master/core/input_hw/input.c): `core/input_hw/input.c`
- [Cartridge Hardware](https://github.com/libretro/genesis-plus-gx/blob/master/core/cart_hw/md_cart.c): `core/cart_hw/md_cart.c`
- [8-bit Cartridge](https://github.com/libretro/genesis-plus-gx/blob/master/core/cart_hw/sms_cart.c): `core/cart_hw/sms_cart.c`
- [CD Hardware](https://github.com/libretro/genesis-plus-gx/blob/master/core/cd_hw/scd.c): `core/cd_hw/scd.c`

### Media And State

- [ROM Loading](https://github.com/libretro/genesis-plus-gx/blob/master/core/loadrom.c): `core/loadrom.c`
- [Save States](https://github.com/libretro/genesis-plus-gx/blob/master/core/state.c): `core/state.c`

### Other components

- **Player**

## Connections

- Player → Libretro Frontend: uses
- Player → SDL Frontend: uses
- Player → GameCube/Wii Frontend: uses
- SDL Frontend → SDL Game Loop: runs (evidence: `sdl/sdl2/main.c`)
- SDL Game Loop → System Runtime: advances frames (evidence: `sdl/sdl2/main.c`)
- GameCube/Wii Frontend → GX Game Loop: starts (evidence: `gx/main.c`)
- GX Game Loop → System Runtime: advances frames (evidence: `gx/main.c`)
- Libretro Frontend → System Runtime: runs emulation
- GX File Selection → GX Menus: opens selection (evidence: `gx/fileio/file_slot.c`)
- GX Game Loop → GX File Selection: loads games
- System Runtime → Console Control: dispatches runtime
- Console Control → M68000 CPU: runs CPU
- Console Control → Z80 CPU: runs CPU
- Console Control → Memory Mapping: uses mappings
- System Runtime → Video Rendering: renders frames
- System Runtime → Audio Synthesis: generates audio
- System Runtime → Input Devices: reads controls
- System Runtime → Cartridge Hardware: supports hardware
- System Runtime → 8-bit Cartridge: supports hardware
- System Runtime → CD Hardware: supports CD
- System Runtime → ROM Loading: loads software
- System Runtime → Save States: saves state
- Video Rendering → NTSC Filters: filters output
