# notaz/pcsx_rearmed architecture

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

- Interactive diagram: https://gitdiagram.com/notaz/pcsx_rearmed
- Repository: https://github.com/notaz/pcsx_rearmed

## Overview

Based on your provided file structure and README, this project is clearly an emulator – a fork of PCSX-ReARMed (derived from PCSX-Reloaded) that is optimized for ARM devices with specialized support for various platforms (e.g., Pandora, 3DS, WiiU, etc.). It takes advantage of multiple architectural elements such as a dynamic recompiler (MIPS to ARM), a NEON-accelerated GPU plugin, and a flexible plugin interface (PSEMU) to support audio, video, and other emulation functions.

##### Main Components

- Emulator Core (libpcsxcore)
- Represents the heart of the emulation logic. This is where the CPU emulation (including the new dynamic recompiler in the “new_dynarec” directory), GPU processing, and overall game state management are handled.
- Sub-components for the recompiler (MIPS→ARM, including NEON support), CPU emulation routines, and critical utility functions such as memory mapping and BIOS integration.

- Frontend Modules (frontend)
- These directories contain platform-specific adaptations and interfaces. They are responsible for handling input, rendering, and platform-specific configuration.
- Separate blocks for different target systems (e.g., “320240”, “3ds”, “pandora”, “switch”, “vita”, “wiiu”) should be drawn.

- Plugin System (plugins)
- The project uses a modular plugin architecture (PSEMU interface) to provide functionality for GPU emulation, sound (e.g., dfsound, spunull), input, and more.
- Each plugin type (GPU plugins like “gpu-gles”, “gpu_unai”, “gpu_neon”, audio plugins, etc.) should appear as separate, interacting blocks.

- Auxiliary Libraries & Dependencies
- “deps” and “include” directories house libraries that support the core and plugins (e.g., libchdr, libretro-common, lightning, lightrec, mman).

- Build & Configuration Infrastructure
- Configuration files such as Makefiles, “configure”, and CI workflows in the “.github” directory. These are not runtime components, but they illustrate the system’s build and deployment pipelines.
- Optionally, present these as supporting infrastructure that ensures cross-platform builds and continuous integration.

##### Relationships and Interactions

- Data Flow

- Dependency Relationships

- Configuration and Build
- Build scripts and CI pipelines as an external system related to all subcomponents. This designates how the system is maintained and deployed.

##### Architectural Patterns and Design Principles

- Modular Plugin Architecture
- Plugin system separation: the core emulator logic is modular and extends functionalities through interchangeable plugins.

- Multi-Platform Design
- Clearly delineate the frontend layers for different platforms; this stands as a key architectural choice, ensuring the emulator adapts to various device constraints.

- Performance-Oriented Enhancements
- Use of the dynamic recompiler and NEON GPU enhancements; these are optimized paths in the processing pipeline.

- Separation of Concerns
- Clear boundaries between the core emulation engine, platform-specific frontends, and the plugin-based subsystems.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Emulator Core
    subgraph "Emulator Core"
        ECore["Emulator Core (PCSX Core)"]:::core
        DRec["Dynamic Recompiler (MIPS→ARM with NEON)"]:::core
        ECore -->|"uses"| DRec
    end

    %% Platform Frontends
    subgraph "Platform Frontends"
        FEGeneral["General Frontend"]:::frontend
        FEPandora["Frontend – Pandora"]:::frontend
        FE3DS["Frontend – 3DS"]:::frontend
        FE320240["Frontend – 320240"]:::frontend
        FESwitch["Frontend – Switch"]:::frontend
        FEVita["Frontend – Vita"]:::frontend
        FEWiiU["Frontend – WiiU"]:::frontend
    end

    %% Plugin System
    subgraph "Plugin System"
        PluginsDir["Plugins Directory"]:::plugin
        P_DFSound["Audio Plugin – dfsound"]:::plugin
        P_GPUNeon["GPU Plugin – NEON accelerated"]:::plugin
        P_GOPengles["GPU Plugin – OpenGL ES"]:::plugin
        P_GPUUnai["GPU Plugin – Unai"]:::plugin
        P_CDRCIMG["Plugin – cdrcimg"]:::plugin
        P_DFXVideo["Plugin – dfxvideo"]:::plugin
        P_Spunull["Plugin – spunull"]:::plugin
        P_GPULib["Plugin – gpulib"]:::plugin
    end

    %% Auxiliary Libraries & Dependencies
    subgraph "Auxiliary Libraries & Dependencies"
        AuxDeps["Dependencies (deps)"]:::auxiliary
        AuxHeaders["Shared Headers (include)"]:::auxiliary
    end

    %% Build & Configuration Infrastructure
    subgraph "Build & Configuration"
        BuildCI["CI & Build Scripts (.github)"]:::build
        BuildConfig["Build Config Files (Makefile, configure, etc.)"]:::build
    end

    %% Relationships: Frontends initiating Emulator Core
    FEGeneral -->|"initiate"| ECore
    FEPandora -->|"initiate"| ECore
    FE3DS -->|"initiate"| ECore
    FE320240 -->|"initiate"| ECore
    FESwitch -->|"initiate"| ECore
    FEVita -->|"initiate"| ECore
    FEWiiU -->|"initiate"| ECore

    %% Relationships: Emulator Core interacting with Plugins
    ECore -->|"calls"| P_DFSound
    ECore -->|"calls"| P_GPUNeon
    ECore -->|"calls"| P_GOPengles
    ECore -->|"calls"| P_GPUUnai
    ECore -->|"calls"| P_CDRCIMG
    ECore -->|"calls"| P_DFXVideo
    ECore -->|"calls"| P_Spunull
    ECore -->|"calls"| P_GPULib

    %% Optional feedback loops from Plugins to Emulator Core
    P_DFSound -->|"feedback"| ECore
    P_GPUNeon -->|"feedback"| ECore
    P_GOPengles -->|"feedback"| ECore
    P_GPUUnai -->|"feedback"| ECore
    P_CDRCIMG -->|"feedback"| ECore
    P_DFXVideo -->|"feedback"| ECore
    P_Spunull -->|"feedback"| ECore
    P_GPULib -->|"feedback"| ECore

    %% Dependencies (dotted lines)
    AuxDeps ---|"dependency"| ECore
    AuxDeps ---|"dependency"| PluginsDir
    AuxHeaders ---|"dependency"| ECore
    AuxHeaders ---|"dependency"| PluginsDir
    AuxDeps ---|"dependency"| FEGeneral
    AuxDeps ---|"dependency"| FEPandora
    AuxDeps ---|"dependency"| FE3DS
    AuxDeps ---|"dependency"| FE320240
    AuxDeps ---|"dependency"| FESwitch
    AuxDeps ---|"dependency"| FEVita
    AuxDeps ---|"dependency"| FEWiiU

    %% Build & Configuration links (dotted lines)
    BuildCI ---|"build"| ECore
    BuildCI ---|"build"| FEGeneral
    BuildCI ---|"build"| FEPandora
    BuildCI ---|"build"| FE3DS
    BuildCI ---|"build"| FE320240
    BuildCI ---|"build"| FESwitch
    BuildCI ---|"build"| FEVita
    BuildCI ---|"build"| FEWiiU
    BuildCI ---|"build"| PluginsDir
    BuildConfig ---|"config"| ECore
    BuildConfig ---|"config"| PluginsDir
    BuildConfig ---|"config"| FEGeneral
    BuildConfig ---|"config"| FEPandora
    BuildConfig ---|"config"| FE3DS
    BuildConfig ---|"config"| FE320240
    BuildConfig ---|"config"| FESwitch
    BuildConfig ---|"config"| FEVita
    BuildConfig ---|"config"| FEWiiU

    %% Click Events for Component Mapping
    click ECore "https://github.com/notaz/pcsx_rearmed/tree/master/libpcsxcore/"
    click DRec "https://github.com/notaz/pcsx_rearmed/tree/master/libpcsxcore/new_dynarec/"
    click FEGeneral "https://github.com/notaz/pcsx_rearmed/tree/master/frontend/"
    click FEPandora "https://github.com/notaz/pcsx_rearmed/tree/master/frontend/pandora/"
    click FE3DS "https://github.com/notaz/pcsx_rearmed/tree/master/frontend/3ds/"
    click FE320240 "https://github.com/notaz/pcsx_rearmed/tree/master/frontend/320240/"
    click FESwitch "https://github.com/notaz/pcsx_rearmed/tree/master/frontend/switch/"
    click FEVita "https://github.com/notaz/pcsx_rearmed/tree/master/frontend/vita/"
    click FEWiiU "https://github.com/notaz/pcsx_rearmed/tree/master/frontend/wiiu/"
    click PluginsDir "https://github.com/notaz/pcsx_rearmed/tree/master/plugins/"
    click P_DFSound "https://github.com/notaz/pcsx_rearmed/tree/master/plugins/dfsound/"
    click P_GPUNeon "https://github.com/notaz/pcsx_rearmed/tree/master/plugins/gpu_neon/"
    click P_GOPengles "https://github.com/notaz/pcsx_rearmed/tree/master/plugins/gpu-gles/"
    click P_GPUUnai "https://github.com/notaz/pcsx_rearmed/tree/master/plugins/gpu_unai/"
    click P_CDRCIMG "https://github.com/notaz/pcsx_rearmed/tree/master/plugins/cdrcimg/"
    click P_DFXVideo "https://github.com/notaz/pcsx_rearmed/tree/master/plugins/dfxvideo/"
    click P_Spunull "https://github.com/notaz/pcsx_rearmed/tree/master/plugins/spunull/"
    click P_GPULib "https://github.com/notaz/pcsx_rearmed/tree/master/plugins/gpulib/"
    click AuxDeps "https://github.com/notaz/pcsx_rearmed/tree/master/deps/"
    click AuxHeaders "https://github.com/notaz/pcsx_rearmed/tree/master/include/"
    click BuildCI "https://github.com/notaz/pcsx_rearmed/tree/master/.github/"
    click BuildConfig "https://github.com/notaz/pcsx_rearmed/tree/master/Makefile"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1.5px;
    classDef frontend fill:#C1E1C1,stroke:#000,stroke-width:1.5px;
    classDef plugin fill:#FFECB3,stroke:#000,stroke-width:1.5px;
    classDef auxiliary fill:#E0E0E0,stroke:#000,stroke-width:1.5px;
    classDef build fill:#F4CCCC,stroke:#000,stroke-width:1.5px;
```
