# itsveenee/snesticleaurora architecture

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

- Interactive diagram: https://gitdiagram.com/itsveenee/snesticleaurora
- Repository: https://github.com/itsveenee/snesticleaurora

## Overview

#### Purpose and entry points
SNESticle Aurora is a native PlayStation 2 multi-system emulator focused on CRT-oriented 240p output and hardware-specific integration. The EE application starts at `src/app/main.cpp`, with application-level shell, ROM, movie, and system coordination in `src/app/emushell.cpp`, `src/app/emurom.cpp`, and `src/app/emusys.cpp`. `Makefile` is the top-level build entry point; the produced PS2 ELF runs directly on PS2 hardware.

#### Runtime orchestration
The PS2 main loop is decomposed into initialization, IOP setup, input, browser/menu, loading, emulation execution, rendering, persistence, and network/SMB phases. The architectural control center is `src/platform/ps2/system/mainloop.cpp`, split across `mainloop_init.cpp`, `mainloop_exec.cpp`, `mainloop_load.cpp`, and `mainloop_render.cpp`. This layer owns runtime transitions: boot/init → UI/browser → select media/system → load ROM/core → frame loop → return to UI.

#### Frontend, UI, and storage boundary
The frontend presents a console-native browser and settings UI rather than a web application. UI components include `src/platform/ps2/ui/uiBrowser.cpp`, `src/platform/ps2/ui/uiMenu.cpp`, and `src/platform/ps2/ui/uiVideo.cpp`. ROM selection and persistence flow through shared file/path APIs (`src/common/base/file.cpp`, `src/common/base/path.h`) to PS2 storage/media backends. Memory-card save support is isolated in `src/platform/ps2/memcard/memcard.cpp`; runtime loading also supports USB/MX4SIO, CD/DVD, and experimental SMB paths.

#### Emulator-system adapters and cores
A common frontend dispatches to system-specific ROM and core adapters:
- SNES: `src/snes/core/snes.cpp`, `src/snes/rom/snrom.cpp`, `src/snes/state/snstate.cpp`.
- NES/FDS: `src/nes/system/nessystem.cpp`, `src/nes/quicknes/quicknes_bridge.cpp`, `src/nes/fceumm/fceumm_fds_bridge.cpp`.
- Sega platforms: `src/sega/system/segarom.cpp`, `src/sega/picodrive/picodrive_bridge.cpp`.
- PC Engine: `src/pce/system/pcerom.cpp`, `src/pce/beetle/pce_bridge.cpp`.

These adapters are the compatibility boundary between Aurora’s input/video/save conventions and bundled or submodule-based third-party emulation cores. CD-capable PCE and Sega loading is intentionally constrained to `.cue` paths and user-provided firmware.

#### Frame I/O and PS2 hardware integration
Each emulation frame consumes normalized controller/mouse input, produces video surfaces and audio samples, then routes them to PS2 hardware backends. Input is implemented at `src/platform/ps2/input/input.cpp`; graphics target the PS2 Graphics Synthesizer through `src/platform/ps2/gs/gs.c`, `src/platform/ps2/gs/gskit_backend.c`, and common surfaces/textures in `src/common/render/rendersurface.cpp`. Audio mixing is shared in `src/common/render/audmixbuffer.cpp` and emitted through the PS2 audio service implementation `src/modules/audio/audio_audsrv.c`.

#### EE/IOP modules and external dependencies
The project spans PS2 EE application code plus IOP-resident IRX modules embedded/loaded by `src/platform/ps2/system/embedded_irx.cpp` and runtime IOP control in `src/platform/ps2/system/mainloop_iop.cpp`. Prebuilt modules in `irx/` provide controller, memory-card, USB mass-storage, CD streaming, SMB, and block-device functions. Network play is a separate EE protocol stack under `src/modules/netplay/netplay_ee.c` and `src/modules/netplay/protocol/`. Major external cores are pinned Git submodules under `src/third_party/`, including QuickNES, FCEUmm FDS, PicoDrive, Beetle PCE Fast, and experimental Snes9x 2010.

Main entry points: [`src/platform/ps2/system/mainloop.cpp`](https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/system/mainloop.cpp) (Runtime state machine), [`src/common/render/rendersurface.cpp`](https://github.com/itsveenee/snesticleaurora/blob/main/src/common/render/rendersurface.cpp) (Render surfaces), [`src/snes/core/snes.cpp`](https://github.com/itsveenee/snesticleaurora/blob/main/src/snes/core/snes.cpp) (SNES adapter and core), [`src/nes/system/nessystem.cpp`](https://github.com/itsveenee/snesticleaurora/blob/main/src/nes/system/nessystem.cpp) (NES/FDS adapters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["EE Application"]
  node_build["Make build<br/>build entry"]
  node_main["EE entry point<br/>application entry<br/>[main.cpp]"]
  node_app_shell["App shell<br/>application coordination<br/>[emushell.cpp]"]
end

subgraph group_runtime["PS2 Runtime"]
  node_mainloop["Runtime state machine<br/>PS2 orchestration<br/>[mainloop.cpp]"]
  node_mainloop_stages["Loop stages<br/>runtime phases<br/>[mainloop_init.cpp]"]
  node_ui["Browser and settings UI<br/>console frontend<br/>[uiBrowser.cpp]"]
  node_file_path["File and path APIs<br/>shared storage API<br/>[file.cpp]"]
  node_memcard[("Memory-card saves<br/>PS2 persistence<br/>[memcard.cpp]")]
end

subgraph group_systems["System Adapters"]
  node_snes["SNES adapter and core<br/>system adapter<br/>[snes.cpp]"]
  node_nes["NES/FDS adapters<br/>system adapter<br/>[nessystem.cpp]"]
  node_sega["Sega adapter<br/>system adapter<br/>[segarom.cpp]"]
  node_pce["PC Engine adapter<br/>system adapter<br/>[pcerom.cpp]"]
  node_third_party["Pinned core submodules<br/>external dependencies"]
end

subgraph group_io["Frame I/O"]
  node_input["Normalized input<br/>PS2 input<br/>[input.cpp]"]
  node_render_surface["Render surfaces<br/>shared video surface<br/>[rendersurface.cpp]"]
  node_gs["GS video backend<br/>PS2 graphics output<br/>[gs.c]"]
  node_audio_mix["Audio mixer<br/>shared audio buffer<br/>[audmixbuffer.cpp]"]
end

subgraph group_iop["IOP &amp; Services"]
  node_audsrv["Audio service<br/>PS2 audio output<br/>[audio_audsrv.c]"]
  node_iop_control["IOP control and embedded IRX<br/>EE-to-IOP bootstrap<br/>[embedded_irx.cpp]"]
  node_irx["Prebuilt IRX modules<br/>IOP services"]
  node_netplay["Netplay EE stack<br/>network protocol<br/>[netplay_ee.c]"]
end

node_build -->|"builds"| node_main
node_main -->|"starts"| node_app_shell
node_app_shell -->|"drives"| node_mainloop
node_mainloop -->|"uses"| node_mainloop_stages
node_mainloop -->|"enters browser/menu"| node_ui
node_ui -->|"browses media"| node_file_path
node_mainloop -->|"loads ROMs"| node_file_path
node_mainloop -->|"loads and saves state"| node_memcard
node_mainloop -->|"dispatches selected system"| node_snes
node_mainloop -->|"dispatches selected system"| node_nes
node_mainloop -->|"dispatches selected system"| node_sega
node_mainloop -->|"dispatches selected system"| node_pce
node_snes -.->|"uses core dependency"| node_third_party
node_nes -.->|"uses core dependency"| node_third_party
node_sega -.->|"uses core dependency"| node_third_party
node_pce -.->|"uses core dependency"| node_third_party
node_mainloop -->|"consumes each frame"| node_input
node_snes -->|"produces video"| node_render_surface
node_nes -->|"produces video"| node_render_surface
node_sega -->|"produces video"| node_render_surface
node_pce -->|"produces video"| node_render_surface
node_render_surface -->|"presents to GS"| node_gs
node_snes -->|"produces audio"| node_audio_mix
node_audio_mix -->|"emits samples"| node_audsrv
node_mainloop -->|"initializes IOP"| node_iop_control
node_iop_control -->|"loads services"| node_irx
node_mainloop -.->|"runs optional networking"| node_netplay

click node_build "https://github.com/itsveenee/snesticleaurora/blob/main/Makefile"
click node_main "https://github.com/itsveenee/snesticleaurora/blob/main/src/app/main.cpp"
click node_app_shell "https://github.com/itsveenee/snesticleaurora/blob/main/src/app/emushell.cpp"
click node_mainloop "https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/system/mainloop.cpp"
click node_mainloop_stages "https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/system/mainloop_init.cpp"
click node_ui "https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/ui/uiBrowser.cpp"
click node_file_path "https://github.com/itsveenee/snesticleaurora/blob/main/src/common/base/file.cpp"
click node_memcard "https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/memcard/memcard.cpp"
click node_snes "https://github.com/itsveenee/snesticleaurora/blob/main/src/snes/core/snes.cpp"
click node_nes "https://github.com/itsveenee/snesticleaurora/blob/main/src/nes/system/nessystem.cpp"
click node_sega "https://github.com/itsveenee/snesticleaurora/blob/main/src/sega/system/segarom.cpp"
click node_pce "https://github.com/itsveenee/snesticleaurora/blob/main/src/pce/system/pcerom.cpp"
click node_input "https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/input/input.cpp"
click node_render_surface "https://github.com/itsveenee/snesticleaurora/blob/main/src/common/render/rendersurface.cpp"
click node_gs "https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/gs/gs.c"
click node_audio_mix "https://github.com/itsveenee/snesticleaurora/blob/main/src/common/render/audmixbuffer.cpp"
click node_audsrv "https://github.com/itsveenee/snesticleaurora/blob/main/src/modules/audio/audio_audsrv.c"
click node_iop_control "https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/system/embedded_irx.cpp"
click node_netplay "https://github.com/itsveenee/snesticleaurora/blob/main/src/modules/netplay/netplay_ee.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_build,node_main,node_app_shell toneBlue
class node_mainloop,node_mainloop_stages,node_ui,node_file_path,node_memcard toneAmber
class node_snes,node_nes,node_sega,node_pce,node_third_party toneMint
class node_input,node_render_surface,node_gs,node_audio_mix toneRose
class node_audsrv,node_iop_control,node_irx,node_netplay toneIndigo
```

## Components

### EE Application

- [Make build](https://github.com/itsveenee/snesticleaurora/blob/main/Makefile): build entry · Builds the PS2 ELF for hardware. · `Makefile`
- [EE entry point](https://github.com/itsveenee/snesticleaurora/blob/main/src/app/main.cpp): application entry · `src/app/main.cpp`
- [App shell](https://github.com/itsveenee/snesticleaurora/blob/main/src/app/emushell.cpp): application coordination · Coordinates shell, ROM, movie, and system actions. · `src/app/emushell.cpp`

### PS2 Runtime

- [Runtime state machine](https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/system/mainloop.cpp): PS2 orchestration · Transitions boot, UI, loading, frame execution, and return. · `src/platform/ps2/system/mainloop.cpp`
- [Loop stages](https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/system/mainloop_init.cpp): runtime phases · Initialization, execution, loading, and rendering are split across companion files. · `src/platform/ps2/system/mainloop_init.cpp`
- [Browser and settings UI](https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/ui/uiBrowser.cpp): console frontend · `src/platform/ps2/ui/uiBrowser.cpp`
- [File and path APIs](https://github.com/itsveenee/snesticleaurora/blob/main/src/common/base/file.cpp): shared storage API · `src/common/base/file.cpp`
- [Memory-card saves](https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/memcard/memcard.cpp): PS2 persistence · `src/platform/ps2/memcard/memcard.cpp`

### System Adapters

- [SNES adapter and core](https://github.com/itsveenee/snesticleaurora/blob/main/src/snes/core/snes.cpp): system adapter · ROM, state, and SNES core integration. · `src/snes/core/snes.cpp`
- [NES/FDS adapters](https://github.com/itsveenee/snesticleaurora/blob/main/src/nes/system/nessystem.cpp): system adapter · Dispatches QuickNES and FCEUmm FDS bridges. · `src/nes/system/nessystem.cpp`
- [Sega adapter](https://github.com/itsveenee/snesticleaurora/blob/main/src/sega/system/segarom.cpp): system adapter · Integrates PicoDrive for Sega platforms. · `src/sega/system/segarom.cpp`
- [PC Engine adapter](https://github.com/itsveenee/snesticleaurora/blob/main/src/pce/system/pcerom.cpp): system adapter · Integrates Beetle PCE; CD loading requires CUE and firmware. · `src/pce/system/pcerom.cpp`
- **Pinned core submodules**: external dependencies · Provides bundled third-party emulation cores.

### Frame I/O

- [Normalized input](https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/input/input.cpp): PS2 input · `src/platform/ps2/input/input.cpp`
- [Render surfaces](https://github.com/itsveenee/snesticleaurora/blob/main/src/common/render/rendersurface.cpp): shared video surface · `src/common/render/rendersurface.cpp`
- [GS video backend](https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/gs/gs.c): PS2 graphics output · `src/platform/ps2/gs/gs.c`
- [Audio mixer](https://github.com/itsveenee/snesticleaurora/blob/main/src/common/render/audmixbuffer.cpp): shared audio buffer · `src/common/render/audmixbuffer.cpp`

### IOP & Services

- [Audio service](https://github.com/itsveenee/snesticleaurora/blob/main/src/modules/audio/audio_audsrv.c): PS2 audio output · `src/modules/audio/audio_audsrv.c`
- [IOP control and embedded IRX](https://github.com/itsveenee/snesticleaurora/blob/main/src/platform/ps2/system/embedded_irx.cpp): EE-to-IOP bootstrap · Loads embedded modules and controls IOP runtime services. · `src/platform/ps2/system/embedded_irx.cpp`
- **Prebuilt IRX modules**: IOP services · Controller, storage, CD, SMB, and block-device modules.
- [Netplay EE stack](https://github.com/itsveenee/snesticleaurora/blob/main/src/modules/netplay/netplay_ee.c): network protocol · `src/modules/netplay/netplay_ee.c`

## Connections

- Make build → EE entry point: builds
- EE entry point → App shell: starts
- App shell → Runtime state machine: drives
- Runtime state machine → Loop stages: uses
- Runtime state machine → Browser and settings UI: enters browser/menu
- Browser and settings UI → File and path APIs: browses media
- Runtime state machine → File and path APIs: loads ROMs
- Runtime state machine → Memory-card saves: loads and saves state
- Runtime state machine → SNES adapter and core: dispatches selected system
- Runtime state machine → NES/FDS adapters: dispatches selected system
- Runtime state machine → Sega adapter: dispatches selected system
- Runtime state machine → PC Engine adapter: dispatches selected system
- SNES adapter and core → Pinned core submodules: uses core dependency
- NES/FDS adapters → Pinned core submodules: uses core dependency
- Sega adapter → Pinned core submodules: uses core dependency
- PC Engine adapter → Pinned core submodules: uses core dependency
- Runtime state machine → Normalized input: consumes each frame
- SNES adapter and core → Render surfaces: produces video
- NES/FDS adapters → Render surfaces: produces video
- Sega adapter → Render surfaces: produces video
- PC Engine adapter → Render surfaces: produces video
- Render surfaces → GS video backend: presents to GS
- SNES adapter and core → Audio mixer: produces audio
- Audio mixer → Audio service: emits samples
- Runtime state machine → IOP control and embedded IRX: initializes IOP
- IOP control and embedded IRX → Prebuilt IRX modules: loads services
- Runtime state machine → Netplay EE stack: runs optional networking
