# klorfmorf/goemon64recomp architecture

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

- Interactive diagram: https://gitdiagram.com/klorfmorf/goemon64recomp
- Repository: https://github.com/klorfmorf/goemon64recomp

## Overview

##### Main Components
- Game Engine & Rendering: At the core, the project leverages RT64 for advanced rendering. This is a central component that handles graphics, shaders, and high-framerate support.
- Static Recompilation & Game Patches: The static recompilation process takes original N64 elements and converts them. The “patches” directory (with files such as patches/main.c and several headers in patches/) indicates extensive modifications to the game logic and memory layout. This module is responsible for bridging original game code to natively running code.
- Game Logic & Core Modules: Inside the “src” directory, the “game” subfolder contains components for game configuration, controls, debugging, quicksaving, and other gameplay elements. The “src/main” folder handles the application’s initialization, registration of patches/overlays, and integration with the engine.
- UI & Launcher: The UI components (located in “src/ui” and under the “assets” folder, which also includes menu and font assets) are built with RmlUi. This includes the in-game configuration menus and the launcher interface that provides an accessible user front-end.
- External Libraries & Dependencies: The project depends on several external libraries such as:
- RT64 for rendering
- RmlUi (and related packages such as lunasvg and FreeType) for UI rendering
- Gamepad Motion Helpers and moodycamel::ConcurrentQueue for input processing and concurrency
- Additional support from libraries included in the “lib” directory for specific functionalities (e.g., a reference to Ares emulator’s RSP implementation for vector instruction support)
- Build & Configuration: Tools such as CMake (with files like CMakeLists.txt, CMakeSettings.json), GitHub workflows, and scripts (build_debug.bat, etc.) represent the build system and continuous integration components.

##### Representing Relationships & Interactions
- The Launcher (src/main) initializes and configures the system, then calls into the Game Engine.
- The Game Engine (RT64) processes rendering and acts on input from the UI.
- The Static Recompilation/Patches layer acts as an intermediary to adapt the original game logic into a form suitable for modern hardware.
- The UI layer, built with RmlUi, communicates with both the engine and game logic modules for settings and user interactions.
- External libraries and tools (listed in the “lib” folder) interact with various modules (e.g., input handling, concurrency, or shader management).

##### Architectural Patterns and Design Principles
- Modular Separation: The separation into directories like “src/game”, “src/main”, “src/ui”, and “assets” clearly separates game logic, initialization, and the user interface. This separation supports maintainability and clarity.
- Integration of External Libraries: Emphasize dependency injection and integration points for libraries like RT64 and RmlUi.

##### Detailed Elements
- Clear, descriptive labels for each element.
- The launcher initializing RT64 and registering patches.
- The UI feeding configuration changes back into the game logic.
- Assets being loaded at startup to supply themes and fonts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    BC("Build & Configuration"):::build
    EL("External Libraries"):::external
    LI("Launcher/Initialization Module (src/main)"):::core
    GE("Game Engine (RT64)"):::core
    SRP("Static Recompilation & Patches (patches/)"):::core
    GL("Game Logic & Core Modules (src/game)"):::core
    UIL("UI & Launcher (src/ui)"):::ui
    AT("Assets & Themes (assets)"):::assets

    BC -->|"initializes"| LI
    LI -->|"initializes"| GE
    LI -->|"registers"| SRP
    LI -->|"configures"| GL
    GE -->|"executes"| GL
    GE -->|"integrates"| SRP
    UIL -->|"configures"| GL
    UIL -->|"commands"| GE
    AT -->|"supplies"| UIL
    EL -->|"supports"| GE
    EL -->|"supports"| GL
    EL -->|"supports"| UIL

    click BC "https://github.com/klorfmorf/goemon64recomp/blob/modding/CMakeLists.txt"
    click BC "https://github.com/klorfmorf/goemon64recomp/blob/modding/CMakeSettings.json"
    click BC "https://github.com/klorfmorf/goemon64recomp/tree/modding/.github/workflows/"
    click LI "https://github.com/klorfmorf/goemon64recomp/tree/modding/src/main/"
    click LI "https://github.com/klorfmorf/goemon64recomp/blob/modding/src/main/main.cpp"
    click GE "https://github.com/klorfmorf/goemon64recomp/tree/modding/lib/rt64"
    click GE "https://github.com/klorfmorf/goemon64recomp/blob/modding/src/main/rt64_render_context.cpp"
    click SRP "https://github.com/klorfmorf/goemon64recomp/tree/modding/patches/"
    click GL "https://github.com/klorfmorf/goemon64recomp/tree/modding/src/game/"
    click UIL "https://github.com/klorfmorf/goemon64recomp/tree/modding/src/ui/"
    click AT "https://github.com/klorfmorf/goemon64recomp/tree/modding/assets/"
    click EL "https://github.com/klorfmorf/goemon64recomp/tree/modding/lib/"

    classDef build fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef external fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef ui fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef assets fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
