# grarak/dsvita architecture

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

- Interactive diagram: https://gitdiagram.com/grarak/dsvita
- Repository: https://github.com/grarak/dsvita

## Overview

DSVita is a Nintendo DS emulator for Vita, Linux, and experimental Android. The principal workflow is selecting an NDS ROM, initializing emulated hardware, executing ARM9/ARM7 instructions while coordinating hardware events, and presenting video, audio, and input. The graph also preserves documented 2D/3D rendering, selectable ARM7 emulation modes, settings, save states, cheats, and RetroAchievements. Source excerpts are partial, so subsystem links are limited to documented behavior and visible orchestration; uncertain internal calls are omitted.

Main entry points: [`src/core/emu.rs`](https://github.com/grarak/dsvita/blob/main/src/core/emu.rs) (DS Hardware), [`src/lib.rs`](https://github.com/grarak/dsvita/blob/main/src/lib.rs) (Emulator Loop), [`src/presenter/mod.rs`](https://github.com/grarak/dsvita/blob/main/src/presenter/mod.rs) (Platform Presenter), [`android/app/src/main/kotlin/com/grarak/dsvita/DSVitaActivity.kt`](https://github.com/grarak/dsvita/blob/main/android/app/src/main/kotlin/com/grarak/dsvita/DSVitaActivity.kt) (Android Game UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_presenter["Platform Presenter<br/>[mod.rs]"]
  node_android_ui["Android Game UI<br/>[DSVitaActivity.kt]"]
  node_settings["Settings<br/>[settings.rs]"]
end

subgraph group_emulation["Emulation Core"]
  node_cartridge["ROM and Metadata<br/>[cartridge_io.rs]"]
  node_emulator["Emulator Loop<br/>[lib.rs]"]
  node_hardware["DS Hardware<br/>[emu.rs]"]
  node_memory["Memory and MMU<br/>[mmu.rs]"]
  node_scheduler["Cycle Scheduler<br/>[cycle_manager.rs]"]
  node_arm_exec["ARM Execution<br/>[mod.rs]"]
  node_arm7_hle["ARM7 Emulation Modes<br/>[mod.rs]"]
end

subgraph group_media["Media and Input"]
  node_graphics["2D and 3D GPU<br/>[mod.rs]"]
  node_audio["Sound Processing<br/>[spu.rs]"]
  node_input["Input Handling<br/>[input.rs]"]
end

subgraph group_state["State and Integrations"]
  node_save["Save States<br/>[savestate.rs]"]
  node_cheats["Cheats<br/>[cheats.rs]"]
  node_achievements["RetroAchievements<br/>[ra_context.rs]"]
end

node_player(("Player"))
node_ra_service(("RetroAchievements Service"))

node_player -->|"selects game"| node_presenter
node_player -.->|"selects game"| node_android_ui
node_presenter -->|"starts and controls"| node_emulator
node_android_ui -.->|"starts and controls"| node_emulator
node_emulator -->|"loads ROM"| node_cartridge
node_emulator -->|"runs emulation"| node_hardware
node_settings -->|"configures"| node_emulator
node_hardware -->|"accesses"| node_memory
node_hardware -->|"coordinates cycles"| node_scheduler
node_hardware -->|"executes instructions"| node_arm_exec
node_hardware -->|"uses selected mode"| node_arm7_hle
node_hardware -->|"renders graphics"| node_graphics
node_hardware -->|"processes sound"| node_audio
node_presenter -->|"collects controls"| node_input
node_input -->|"supplies input"| node_hardware
node_graphics -->|"presents frames"| node_presenter
node_audio -->|"outputs audio"| node_presenter
node_emulator -->|"saves and restores"| node_save
node_hardware -->|"applies cheats"| node_cheats
node_emulator -.->|"updates"| node_achievements
node_achievements -.->|"communicates with"| node_ra_service

click node_presenter "https://github.com/grarak/dsvita/blob/main/src/presenter/mod.rs"
click node_android_ui "https://github.com/grarak/dsvita/blob/main/android/app/src/main/kotlin/com/grarak/dsvita/DSVitaActivity.kt"
click node_settings "https://github.com/grarak/dsvita/blob/main/src/settings.rs"
click node_cartridge "https://github.com/grarak/dsvita/blob/main/src/cartridge_io.rs"
click node_emulator "https://github.com/grarak/dsvita/blob/main/src/lib.rs"
click node_hardware "https://github.com/grarak/dsvita/blob/main/src/core/emu.rs"
click node_memory "https://github.com/grarak/dsvita/blob/main/src/core/memory/mmu.rs"
click node_scheduler "https://github.com/grarak/dsvita/blob/main/src/core/cycle_manager.rs"
click node_arm_exec "https://github.com/grarak/dsvita/blob/main/src/jit/mod.rs"
click node_arm7_hle "https://github.com/grarak/dsvita/blob/main/src/core/hle/mod.rs"
click node_graphics "https://github.com/grarak/dsvita/blob/main/src/core/graphics/mod.rs"
click node_audio "https://github.com/grarak/dsvita/blob/main/src/core/spu.rs"
click node_input "https://github.com/grarak/dsvita/blob/main/src/core/input.rs"
click node_save "https://github.com/grarak/dsvita/blob/main/src/savestate.rs"
click node_cheats "https://github.com/grarak/dsvita/blob/main/src/cheats.rs"
click node_achievements "https://github.com/grarak/dsvita/blob/main/src/ra_context.rs"

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_presenter,node_android_ui,node_settings toneBlue
class node_cartridge,node_emulator,node_hardware,node_memory,node_scheduler,node_arm_exec,node_arm7_hle toneAmber
class node_graphics,node_audio,node_input toneMint
class node_save,node_cheats,node_achievements toneRose
class node_player,node_ra_service toneIndigo
```

## Components

### Frontend

- [Platform Presenter](https://github.com/grarak/dsvita/blob/main/src/presenter/mod.rs): `src/presenter/mod.rs`
- [Android Game UI](https://github.com/grarak/dsvita/blob/main/android/app/src/main/kotlin/com/grarak/dsvita/DSVitaActivity.kt): `android/app/src/main/kotlin/com/grarak/dsvita/DSVitaActivity.kt`
- [Settings](https://github.com/grarak/dsvita/blob/main/src/settings.rs): `src/settings.rs`

### Emulation Core

- [ROM and Metadata](https://github.com/grarak/dsvita/blob/main/src/cartridge_io.rs): `src/cartridge_io.rs`
- [Emulator Loop](https://github.com/grarak/dsvita/blob/main/src/lib.rs): `src/lib.rs`
- [DS Hardware](https://github.com/grarak/dsvita/blob/main/src/core/emu.rs): `src/core/emu.rs`
- [Memory and MMU](https://github.com/grarak/dsvita/blob/main/src/core/memory/mmu.rs): `src/core/memory/mmu.rs`
- [Cycle Scheduler](https://github.com/grarak/dsvita/blob/main/src/core/cycle_manager.rs): `src/core/cycle_manager.rs`
- [ARM Execution](https://github.com/grarak/dsvita/blob/main/src/jit/mod.rs): `src/jit/mod.rs`
- [ARM7 Emulation Modes](https://github.com/grarak/dsvita/blob/main/src/core/hle/mod.rs): `src/core/hle/mod.rs`

### Media and Input

- [2D and 3D GPU](https://github.com/grarak/dsvita/blob/main/src/core/graphics/mod.rs): `src/core/graphics/mod.rs`
- [Sound Processing](https://github.com/grarak/dsvita/blob/main/src/core/spu.rs): `src/core/spu.rs`
- [Input Handling](https://github.com/grarak/dsvita/blob/main/src/core/input.rs): `src/core/input.rs`

### State and Integrations

- [Save States](https://github.com/grarak/dsvita/blob/main/src/savestate.rs): `src/savestate.rs`
- [Cheats](https://github.com/grarak/dsvita/blob/main/src/cheats.rs): `src/cheats.rs`
- [RetroAchievements](https://github.com/grarak/dsvita/blob/main/src/ra_context.rs): `src/ra_context.rs`

### Other components

- **Player**
- **RetroAchievements Service**

## Connections

- Player → Platform Presenter: selects game
- Player → Android Game UI: selects game
- Platform Presenter → Emulator Loop: starts and controls
- Android Game UI → Emulator Loop: starts and controls
- Emulator Loop → ROM and Metadata: loads ROM
- Emulator Loop → DS Hardware: runs emulation
- Settings → Emulator Loop: configures
- DS Hardware → Memory and MMU: accesses
- DS Hardware → Cycle Scheduler: coordinates cycles
- DS Hardware → ARM Execution: executes instructions
- DS Hardware → ARM7 Emulation Modes: uses selected mode
- DS Hardware → 2D and 3D GPU: renders graphics
- DS Hardware → Sound Processing: processes sound
- Platform Presenter → Input Handling: collects controls
- Input Handling → DS Hardware: supplies input
- 2D and 3D GPU → Platform Presenter: presents frames
- Sound Processing → Platform Presenter: outputs audio
- Emulator Loop → Save States: saves and restores
- DS Hardware → Cheats: applies cheats
- Emulator Loop → RetroAchievements: updates
- RetroAchievements → RetroAchievements Service: communicates with
