# melonds-emu/melonds architecture

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

- Interactive diagram: https://gitdiagram.com/melonds-emu/melonds
- Repository: https://github.com/melonds-emu/melonds

## Overview

melonDS is a Nintendo DS/DSi emulator with a Qt/SDL frontend. A user selects a game and boot mode; the emulator runs CPU instructions and device behavior, then produces graphics and audio for the frontend. It also supports DSi NAND/title management, storage, and networking. The graph reflects the README and shown source-index references; several runtime modules were not sampled, so their internal calls and frontend wiring are omitted rather than assumed.

Main entry points: [`src/NDS.cpp`](https://github.com/melonds-emu/melonds/blob/master/src/NDS.cpp) (DS System), [`src/frontend/qt_sdl/EmuInstance.cpp`](https://github.com/melonds-emu/melonds/blob/master/src/frontend/qt_sdl/EmuInstance.cpp) (Emulator Instance), [`src/ARMJIT.h`](https://github.com/melonds-emu/melonds/blob/master/src/ARMJIT.h) (ARM JIT), [`src/DSi.h`](https://github.com/melonds-emu/melonds/blob/master/src/DSi.h) (DSi Devices)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["Qt SDL Frontend<br/>[main.cpp]"]
  node_emu_instance["Emulator Instance<br/>[EmuInstance.cpp]"]
  node_screen["Screen Output<br/>[Screen.cpp]"]
end

subgraph group_emulation["Emulation Core"]
  node_system["DS System<br/>[NDS.cpp]"]
  node_arm_cpu["ARM CPU<br/>[ARM.h]"]
  node_interpreter["ARM Interpreter<br/>[ARMInterpreter.cpp]"]
  node_jit["ARM JIT<br/>[ARMJIT.h]"]
  node_jit_memory["JIT Memory<br/>[ARMJIT_Memory.h]"]
  node_jit_emitters["JIT Emitters<br/>[Arm64Emitter.h]"]
  node_dsp_cpu["DSP Interpreter<br/>[interpreter.h]"]
  node_gpu["Graphics Engine<br/>[GPU.h]"]
  node_spu["Audio Engine<br/>[SPU.h]"]
end

subgraph group_devices["Devices and Media"]
  node_cartridge["Game Cartridges<br/>[NDSCart.h]"]
  node_dsi["DSi Devices<br/>[DSi.h]"]
  node_nand[("DSi NAND<br/>[DSi_NAND.h]")]
  node_firmware["Firmware<br/>[SPI_Firmware.h]"]
  node_fat_storage["FAT Storage<br/>[FATStorage.cpp]"]
  node_fatfs["FatFs<br/>[ff.h]"]
end

subgraph group_runtime["Runtime Services"]
  node_platform["Platform Services<br/>[Platform.h]"]
  node_cheats["Action Replay<br/>[AREngine.cpp]"]
  node_save_state["Save States<br/>[Savestate.h]"]
end

subgraph group_connectivity["Connectivity"]
  node_network["Network Features<br/>[Netplay.cpp]"]
end

node_user(("Player"))

node_user -.->|"selects game"| node_frontend_app
node_frontend_app -.->|"starts emulation"| node_emu_instance
node_emu_instance -.->|"controls runtime"| node_system
node_system -->|"runs CPU"| node_arm_cpu
node_system -->|"uses JIT"| node_jit
node_system -->|"uses graphics"| node_gpu
node_system -->|"uses audio"| node_spu
node_system -->|"uses cartridge"| node_cartridge
node_system -->|"uses DSi devices"| node_dsi
node_system -->|"runs cheats"| node_cheats
node_arm_cpu -.->|"interprets instructions"| node_interpreter
node_jit -->|"uses memory layer"| node_jit_memory
node_jit -.->|"emits native code"| node_jit_emitters
node_dsi -->|"uses NAND"| node_nand
node_dsi -->|"uses firmware"| node_firmware
node_nand -->|"uses filesystem"| node_fatfs
node_fat_storage -->|"uses filesystem"| node_fatfs
node_fat_storage -->|"accesses host files"| node_platform
node_emu_instance -.->|"uses platform services"| node_platform
node_gpu -.->|"produces frames"| node_screen
node_system -.->|"uses DSP core"| node_dsp_cpu
node_emu_instance -.->|"manages state"| node_save_state
node_emu_instance -.->|"configures networking"| node_network

click node_frontend_app "https://github.com/melonds-emu/melonds/blob/master/src/frontend/qt_sdl/main.cpp"
click node_emu_instance "https://github.com/melonds-emu/melonds/blob/master/src/frontend/qt_sdl/EmuInstance.cpp"
click node_screen "https://github.com/melonds-emu/melonds/blob/master/src/frontend/qt_sdl/Screen.cpp"
click node_system "https://github.com/melonds-emu/melonds/blob/master/src/NDS.cpp"
click node_arm_cpu "https://github.com/melonds-emu/melonds/blob/master/src/ARM.h"
click node_interpreter "https://github.com/melonds-emu/melonds/blob/master/src/ARMInterpreter.cpp"
click node_jit "https://github.com/melonds-emu/melonds/blob/master/src/ARMJIT.h"
click node_jit_memory "https://github.com/melonds-emu/melonds/blob/master/src/ARMJIT_Memory.h"
click node_jit_emitters "https://github.com/melonds-emu/melonds/blob/master/src/dolphin/Arm64Emitter.h"
click node_dsp_cpu "https://github.com/melonds-emu/melonds/blob/master/src/teakra/src/interpreter.h"
click node_gpu "https://github.com/melonds-emu/melonds/blob/master/src/GPU.h"
click node_spu "https://github.com/melonds-emu/melonds/blob/master/src/SPU.h"
click node_cartridge "https://github.com/melonds-emu/melonds/blob/master/src/NDSCart.h"
click node_dsi "https://github.com/melonds-emu/melonds/blob/master/src/DSi.h"
click node_nand "https://github.com/melonds-emu/melonds/blob/master/src/DSi_NAND.h"
click node_firmware "https://github.com/melonds-emu/melonds/blob/master/src/SPI_Firmware.h"
click node_fat_storage "https://github.com/melonds-emu/melonds/blob/master/src/FATStorage.cpp"
click node_fatfs "https://github.com/melonds-emu/melonds/blob/master/src/fatfs/ff.h"
click node_platform "https://github.com/melonds-emu/melonds/blob/master/src/Platform.h"
click node_cheats "https://github.com/melonds-emu/melonds/blob/master/src/AREngine.cpp"
click node_save_state "https://github.com/melonds-emu/melonds/blob/master/src/Savestate.h"
click node_network "https://github.com/melonds-emu/melonds/blob/master/src/net/Netplay.cpp"

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_frontend_app,node_emu_instance,node_screen toneBlue
class node_system,node_arm_cpu,node_interpreter,node_jit,node_jit_memory,node_jit_emitters,node_dsp_cpu,node_gpu,node_spu toneAmber
class node_cartridge,node_dsi,node_nand,node_firmware,node_fat_storage,node_fatfs toneMint
class node_platform,node_cheats,node_save_state toneRose
class node_network,node_user toneIndigo
```

## Components

### Frontend

- [Qt SDL Frontend](https://github.com/melonds-emu/melonds/blob/master/src/frontend/qt_sdl/main.cpp): `src/frontend/qt_sdl/main.cpp`
- [Emulator Instance](https://github.com/melonds-emu/melonds/blob/master/src/frontend/qt_sdl/EmuInstance.cpp): `src/frontend/qt_sdl/EmuInstance.cpp`
- [Screen Output](https://github.com/melonds-emu/melonds/blob/master/src/frontend/qt_sdl/Screen.cpp): `src/frontend/qt_sdl/Screen.cpp`

### Emulation Core

- [DS System](https://github.com/melonds-emu/melonds/blob/master/src/NDS.cpp): `src/NDS.cpp`
- [ARM CPU](https://github.com/melonds-emu/melonds/blob/master/src/ARM.h): `src/ARM.h`
- [ARM Interpreter](https://github.com/melonds-emu/melonds/blob/master/src/ARMInterpreter.cpp): `src/ARMInterpreter.cpp`
- [ARM JIT](https://github.com/melonds-emu/melonds/blob/master/src/ARMJIT.h): `src/ARMJIT.h`
- [JIT Memory](https://github.com/melonds-emu/melonds/blob/master/src/ARMJIT_Memory.h): `src/ARMJIT_Memory.h`
- [JIT Emitters](https://github.com/melonds-emu/melonds/blob/master/src/dolphin/Arm64Emitter.h): `src/dolphin/Arm64Emitter.h`
- [DSP Interpreter](https://github.com/melonds-emu/melonds/blob/master/src/teakra/src/interpreter.h): `src/teakra/src/interpreter.h`
- [Graphics Engine](https://github.com/melonds-emu/melonds/blob/master/src/GPU.h): `src/GPU.h`
- [Audio Engine](https://github.com/melonds-emu/melonds/blob/master/src/SPU.h): `src/SPU.h`

### Devices and Media

- [Game Cartridges](https://github.com/melonds-emu/melonds/blob/master/src/NDSCart.h): `src/NDSCart.h`
- [DSi Devices](https://github.com/melonds-emu/melonds/blob/master/src/DSi.h): `src/DSi.h`
- [DSi NAND](https://github.com/melonds-emu/melonds/blob/master/src/DSi_NAND.h): `src/DSi_NAND.h`
- [Firmware](https://github.com/melonds-emu/melonds/blob/master/src/SPI_Firmware.h): `src/SPI_Firmware.h`
- [FAT Storage](https://github.com/melonds-emu/melonds/blob/master/src/FATStorage.cpp): `src/FATStorage.cpp`
- [FatFs](https://github.com/melonds-emu/melonds/blob/master/src/fatfs/ff.h): `src/fatfs/ff.h`

### Runtime Services

- [Platform Services](https://github.com/melonds-emu/melonds/blob/master/src/Platform.h): `src/Platform.h`
- [Action Replay](https://github.com/melonds-emu/melonds/blob/master/src/AREngine.cpp): `src/AREngine.cpp`
- [Save States](https://github.com/melonds-emu/melonds/blob/master/src/Savestate.h): `src/Savestate.h`

### Connectivity

- [Network Features](https://github.com/melonds-emu/melonds/blob/master/src/net/Netplay.cpp): `src/net/Netplay.cpp`

### Other components

- **Player**

## Connections

- Player → Qt SDL Frontend: selects game (evidence: `README.md`)
- Qt SDL Frontend → Emulator Instance: starts emulation
- Emulator Instance → DS System: controls runtime
- DS System → ARM CPU: runs CPU
- DS System → ARM JIT: uses JIT
- DS System → Graphics Engine: uses graphics
- DS System → Audio Engine: uses audio
- DS System → Game Cartridges: uses cartridge
- DS System → DSi Devices: uses DSi devices
- DS System → Action Replay: runs cheats (evidence: `src/AREngine.cpp`)
- ARM CPU → ARM Interpreter: interprets instructions
- ARM JIT → JIT Memory: uses memory layer (evidence: `src/ARMJIT.h`)
- ARM JIT → JIT Emitters: emits native code
- DSi Devices → DSi NAND: uses NAND (evidence: `src/DSi.h`)
- DSi Devices → Firmware: uses firmware (evidence: `src/DSi.h`)
- DSi NAND → FatFs: uses filesystem (evidence: `src/DSi_NAND.h`)
- FAT Storage → FatFs: uses filesystem
- FAT Storage → Platform Services: accesses host files (evidence: `src/FATStorage.cpp`)
- Emulator Instance → Platform Services: uses platform services
- Graphics Engine → Screen Output: produces frames
- DS System → DSP Interpreter: uses DSP core
- Emulator Instance → Save States: manages state
- Emulator Instance → Network Features: configures networking
