# szymor/yatka architecture

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

- Interactive diagram: https://gitdiagram.com/szymor/yatka
- Repository: https://github.com/szymor/yatka

## Overview

##### Main System Components

a. Core Game Engine
- Main game loop (main.c)
- To state management components

b. State Management System
- Main Menu (state_mainmenu.c)
- Game Over (state_gameover.c)
- Settings (state_settings.c)

c. Input/Output Systems
- Input: Joystick handling system (joystick.h)
- Output: Video rendering system (video.c)
- Audio System (sound.c)

d. Game Logic Components
- Randomizer system (randomizer.c) - Show all supported algorithms
- Data Persistence (data_persistence.c)
- Skin Management (skin.c)

e. Resource Management
- Create sections for:
- Skins system (multiple themes)
- Music assets
- Sound effects
- Game configurations

##### Component Relationships

- Main game loop → State Management
- State Management → Input/Output Systems
- Game Logic → Resource Management
- Resource Management → Output Systems

##### Technical Details

- Supported platforms (Bittboy, JZ4760-based consoles)
- Key dependencies (SDL libraries)
- File formats supported for music/resources
- Configuration options

##### Architecture Patterns

Following patterns:
- State pattern for game state management
- Factory pattern for randomizer implementation
- Observer pattern for input handling
- Strategy pattern for skin system

##### Resource Flow

How resources are loaded and managed:
- Skin loading pipeline
- Music/SFX loading system
- Configuration file processing
- Save data management

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        Main["Main Game Loop"]:::core
        click Main "https://github.com/szymor/yatka/blob/master/src/main.c"
    end

    subgraph "State Management"
        MainMenu["Main Menu State"]:::state
        GameOver["Game Over State"]:::state
        Settings["Settings State"]:::state
        click MainMenu "https://github.com/szymor/yatka/blob/master/src/state_mainmenu.c"
        click GameOver "https://github.com/szymor/yatka/blob/master/src/state_gameover.c"
        click Settings "https://github.com/szymor/yatka/blob/master/src/state_settings.c"
    end

    subgraph "Input/Output Systems"
        Input["Joystick Handler"]:::io
        Video["Video Renderer"]:::io
        Audio["Audio System"]:::io
        click Input "https://github.com/szymor/yatka/blob/master/inc/joystick.h"
        click Video "https://github.com/szymor/yatka/blob/master/src/video.c"
        click Audio "https://github.com/szymor/yatka/blob/master/src/sound.c"
    end

    subgraph "Game Logic"
        Randomizer["Randomizer System"]:::logic
        DataPersist["Data Persistence"]:::logic
        SkinMgr["Skin Manager"]:::logic
        click Randomizer "https://github.com/szymor/yatka/blob/master/src/randomizer.c"
        click DataPersist "https://github.com/szymor/yatka/blob/master/src/data_persistence.c"
        click SkinMgr "https://github.com/szymor/yatka/blob/master/src/skin.c"
    end

    subgraph "Resource Management"
        Skins["Skins"]:::resource
        Music["Music Assets"]:::resource
        SFX["Sound Effects"]:::resource
        Speech["Speech Resources"]:::resource
        Config["Game Configurations"]:::resource
        click Skins "https://github.com/szymor/yatka/tree/master/skins/"
        click Music "https://github.com/szymor/yatka/tree/master/music/"
        click SFX "https://github.com/szymor/yatka/tree/master/sfx/"
        click Speech "https://github.com/szymor/yatka/tree/master/res/speech/"
    end

    subgraph "Platform Support"
        Bittboy["Bittboy Build"]:::platform
        GCW0["GCW0 Build"]:::platform
        RetroFW["RetroFW Build"]:::platform
        MinGW["MinGW Build"]:::platform
        click Bittboy "https://github.com/szymor/yatka/blob/master/Makefile.bittboy"
        click GCW0 "https://github.com/szymor/yatka/blob/master/Makefile.gcw0"
        click RetroFW "https://github.com/szymor/yatka/blob/master/Makefile.retrofw"
        click MinGW "https://github.com/szymor/yatka/blob/master/Makefile.mingw"
    end

    %% Core Relationships
    Main --> MainMenu
    Main --> GameOver
    Main --> Settings
    Main --> Input
    Main --> Video
    Main --> Audio

    %% State Management Relationships
    MainMenu --> Video
    GameOver --> Video
    Settings --> Video
    MainMenu --> Audio
    GameOver --> Audio

    %% Game Logic Relationships
    Main --> Randomizer
    Main --> DataPersist
    Main --> SkinMgr

    %% Resource Management Relationships
    SkinMgr --> Skins
    Audio --> Music
    Audio --> SFX
    Audio --> Speech
    DataPersist --> Config

    %% Style Definitions
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef state fill:#9b59b6,stroke:#8e44ad,color:white
    classDef io fill:#2ecc71,stroke:#27ae60,color:white
    classDef logic fill:#e67e22,stroke:#d35400,color:white
    classDef resource fill:#f1c40f,stroke:#f39c12,color:black
    classDef platform fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["State Management"]:::state
        L3["Input/Output"]:::io
        L4["Game Logic"]:::logic
        L5["Resources"]:::resource
        L6["Platform Support"]:::platform
    end
```
