# d0nm/vinnie architecture

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

- Interactive diagram: https://gitdiagram.com/d0nm/vinnie
- Repository: https://github.com/d0nm/vinnie

## Overview

##### Project Type and Purpose
- This is a native, monolithic 2D platformer game (“Super Vinnie-Pooh”, 1995), written in C/C++ with inline and separate x86 assembly modules.
- It includes a custom script engine (.FMS/.FML scripts), a graphics library, audio playback (MOD tracker), input handling (joystick, mouse, keyboard), and build/deployment scripts for DOS/Windows consoles.

##### High-Level File Structure Analysis
- Source code:
- .CPP/.C files (GAME.CPP, DIALOG.CPP, EMS.CPP, FAMELIB.CPP, etc.)
- .H headers (JOY.H, EMS.H, FAMEGRAF.H, etc.)
- .ASM modules (FAMEGRAF.ASM, VOICE.ASM, JOYSTICK.ASM)
- Scripts & assets:
- Script files (.FMS, .FML) for levels, dialogs, AI triggers
- Binary level data (LEVELS/*.BIN, .DEF, .demo)
- Graphics data (.PCX imports, custom font, sprites)
- modmusic subfolder: third-party tracker playback code
- Build/deployment:
- .BAT scripts (MAKEFON.BAT, MAKELIB.BAT, asmbuild.bat, winbuild.bat)
- PRJ and .DSK project files for different modules

##### Key Components
a. Core Game Engine
– Main loop (GAME.CPP)
– Frame/timing manager (EMS.CPP)
– Resource loader (FLIB.CPP, FAMELIB.CPP)
b. Rendering Subsystem
– Graphics routines in FAMEGRAF.*
– Font/sprite renderer (MINIFONT.CPP)
– PCX to internal bitmap converter (PCX2REC.CPP)
c. Input Handling
– Keyboard (KEYS.CPP/H), joystick (JOY.CPP/H, JOYSTICK.ASM), mouse (MOUSE.CPP/H)
d. Audio Subsystem
– Sound effects via VOICE.ASM/H
– Music playback via modmusic/*.c/.h
e. Scripting Engine
– Script parser/interpreter (.FMS/.FML files handled by CUTSPR.CPP, FML.CPP)
– Level logic dispatcher (LEVELS/ definitions)
f. Asset Management
– Level data (.BIN, .DEF)
– Graphics assets (sprites, backgrounds)
– Sound/music data
g. Build System
– Compiler and assembler invocation (.BAT scripts)
– Multi-platform targets (DOS, Windows, GamePark32 port)

##### Relationships and Data Flows
- Input events → Input Handler → Event Queue → Game Logic
- Game Logic ↔ Scripting Engine (executes level scripts, triggers animations)
- Game Logic → Audio Subsystem (play SFX & music commands)
- Asset Manager loads binary data → Game Logic, Renderer, Audio
- Build System compiles all modules into a single executable

##### Architectural Patterns and Principles
- Modular engine split by concern: input, logic, rendering, audio, scripting
- Data-driven levels via external script and binary files
- Layered design: low-level hardware access (ASM) underneath C/C++ wrappers
- Single responsibility per module (e.g., FAMEGRAF only handles graphics)

##### Technologies and Frameworks
- Language: C, C++, x86 Assembly
- Custom script interpreter (.FMS, .FML)
- DOS/Windows batch scripts for builds
- External modmusic tracker code
- Graphics: custom PCX converter and blitter routines

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Game Engine
    subgraph "Core Game Engine"
        ML["Main Loop — GAME.CPP"]:::engine
        FMcpp["EMS.CPP"]:::engine
        FMh["EMS.H"]:::engine
        FLIB["FLIB.CPP"]:::engine
        FAMELIB["FAMELIB.CPP"]:::engine
        ML --> FMcpp
        ML --> FLIB
        ML --> FAMELIB
    end

    %% Rendering Subsystem
    subgraph "Rendering Subsystem"
        GLasm["FAMEGRAF.ASM"]:::render
        GLh["FAMEGRAF.H"]:::render
        Cimpl["famegraf.c"]:::render
        Spr["FAMESPR.CPP"]:::render
        Font["MINIFONT.CPP"]:::render
        Conv["PCX2REC.CPP"]:::render
    end

    %% Input Handling
    subgraph "Input Handling"
        KeyCPP["KEYS.CPP"]:::input
        KeyH["KEYS.H"]:::input
        JoyCPP["JOY.CPP"]:::input
        JoyH["JOY.H"]:::input
        JOYASM["JOYSTICK.ASM"]:::input
        MouseCPP["MOUSE.CPP"]:::input
        MouseH["MOUSE.H"]:::input
        IH["Input Handler"]:::input
        KeyCPP --> IH
        KeyH --> IH
        JoyCPP --> IH
        JoyH --> IH
        JOYASM --> IH
        MouseCPP --> IH
        MouseH --> IH
    end

    %% Audio Subsystem
    subgraph "Audio Subsystem"
        VoiceASM["VOICE.ASM"]:::audio
        VoiceH["VOICE.H"]:::audio
        ModC["modmusic.c"]:::audio
        ModH["modmusic.h"]:::audio
        In2["in2.h"]:::audio
        Out["out.h"]:::audio
    end

    %% Scripting Engine
    subgraph "Scripting Engine"
        SP["CUTSPR.CPP"]:::script
        FML["FML.CPP"]:::script
    end

    %% Asset Management
    subgraph "Asset Management"
        Levels["Level Data — LEVELS/"]:::asset
        Scripts["Script Files — .FMS/.FML"]:::asset
        Graphics["Graphics Assets"]:::asset
        Sounds["Sound/Music Data"]:::asset
    end

    %% Build System
    subgraph "Build System"
        BS1["asmbuild.bat"]:::build
        BS2["winbuild.bat"]:::build
        BS3["MAKEFON.BAT"]:::build
        BS4["MAKELIB.BAT"]:::build
        Projects["*.PRJ & *.DSK"]:::build
        BS1 --> BSys
        BS2 --> BSys
        BS3 --> BSys
        BS4 --> BSys
        Projects --> BSys
    end
    BSys["Build System"]:::build

    %% Data and Event Flows
    IH -->|"events"| ML
    ML -->|"render calls"| GLasm
    ML -->|"render calls"| Cimpl
    ML -->|"render calls"| Spr
    ML -->|"render calls"| Font
    ML -->|"render calls"| Conv
    ML -->|"audio cmds"| VoiceASM
    ML -->|"audio cmds"| ModC
    ML -->|"exec scripts"| SP
    SP -->|"results"| ML
    Levels -->|"loaded by"| FLIB
    Scripts -->|"parsed by"| SP
    Graphics -->|"used by"| GLasm
    Sounds -->|"played by"| VoiceASM
    Sounds -->|"played by"| ModC
    BSys -->|"compiles"| ML
    BSys -->|"compiles"| FMcpp
    BSys -->|"compiles"| FLIB
    BSys -->|"compiles"| GLasm
    BSys -->|"compiles"| KeyCPP
    BSys -->|"compiles"| VoiceASM
    BSys -->|"compiles"| SP

    %% Click Events
    click ML "https://github.com/d0nm/vinnie/blob/main/GAME.CPP"
    click FMcpp "https://github.com/d0nm/vinnie/blob/main/EMS.CPP"
    click FMh "https://github.com/d0nm/vinnie/blob/main/EMS.H"
    click FLIB "https://github.com/d0nm/vinnie/blob/main/FLIB.CPP"
    click FAMELIB "https://github.com/d0nm/vinnie/blob/main/FAMELIB.CPP"
    click GLasm "https://github.com/d0nm/vinnie/blob/main/FAMEGRAF.ASM"
    click GLh "https://github.com/d0nm/vinnie/blob/main/FAMEGRAF.H"
    click Cimpl "https://github.com/d0nm/vinnie/blob/main/famegraf.c"
    click Spr "https://github.com/d0nm/vinnie/blob/main/FAMESPR.CPP"
    click Font "https://github.com/d0nm/vinnie/blob/main/MINIFONT.CPP"
    click Conv "https://github.com/d0nm/vinnie/blob/main/PCX2REC.CPP"
    click KeyCPP "https://github.com/d0nm/vinnie/blob/main/KEYS.CPP"
    click KeyH "https://github.com/d0nm/vinnie/blob/main/KEYS.H"
    click JoyCPP "https://github.com/d0nm/vinnie/blob/main/JOY.CPP"
    click JoyH "https://github.com/d0nm/vinnie/blob/main/JOY.H"
    click JOYASM "https://github.com/d0nm/vinnie/blob/main/JOYSTICK.ASM"
    click MouseCPP "https://github.com/d0nm/vinnie/blob/main/MOUSE.CPP"
    click MouseH "https://github.com/d0nm/vinnie/blob/main/MOUSE.H"
    click VoiceASM "https://github.com/d0nm/vinnie/blob/main/VOICE.ASM"
    click VoiceH "https://github.com/d0nm/vinnie/blob/main/VOICE.H"
    click ModC "https://github.com/d0nm/vinnie/blob/main/modmusic/modmusic.c"
    click ModH "https://github.com/d0nm/vinnie/blob/main/modmusic/modmusic.h"
    click In2 "https://github.com/d0nm/vinnie/blob/main/modmusic/in2.h"
    click Out "https://github.com/d0nm/vinnie/blob/main/modmusic/out.h"
    click SP "https://github.com/d0nm/vinnie/blob/main/CUTSPR.CPP"
    click FML "https://github.com/d0nm/vinnie/blob/main/FML.CPP"
    click Levels "https://github.com/d0nm/vinnie/tree/main/LEVELS/"
    click BS1 "https://github.com/d0nm/vinnie/blob/main/asmbuild.bat"
    click BS2 "https://github.com/d0nm/vinnie/blob/main/winbuild.bat"
    click BS3 "https://github.com/d0nm/vinnie/blob/main/MAKEFON.BAT"
    click BS4 "https://github.com/d0nm/vinnie/blob/main/MAKELIB.BAT"
    click Projects "https://github.com/d0nm/vinnie/blob/main/*.PRJ & *.DSK"

    %% Styles
    classDef engine fill:#f9f,stroke:#333,stroke-width:2px
    classDef render fill:#bbf,stroke:#333,stroke-width:2px
    classDef input fill:#bfb,stroke:#333,stroke-width:2px
    classDef audio fill:#fbf,stroke:#333,stroke-width:2px
    classDef script fill:#ffb,stroke:#333,stroke-width:2px
    classDef asset fill:#ffd,stroke:#333,stroke-width:2px
    classDef build fill:#dff,stroke:#333,stroke-width:2px
```
