# martinpiper/bombjack architecture

> Architecture diagram of the GitHub repository martinpiper/bombjack, 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/martinpiper/bombjack
- Repository: https://github.com/martinpiper/bombjack

## Overview

##### Main components
- Video and display pipeline: This encompasses the discrete digital video processing parts laid out in the schematic sheets. For example, separate blocks for “logic analyser & virtual display”, “video timing”, “sprite logic” (parts 1 and 2), “character screen RAM”, “tile/background logic”, “mode7 calculation and pixel logic”, ”scaled sprite logic”, “vector logic” and finally “pixel data combiner & palette lookup” that drives the digital-to-analog conversion via resistor ladders.
- External interface & input bus: The project uses a 24-bit address/data bus coming from the host (an original C64/ or Z80 machine via a dedicated user port address project). This “UserPortTo24BitAddress” module should be depicted as the entry point into the video hardware.
- Test Data & simulation support: There are several projects (e.g., GenerateData, CheckConectivity, GenerateSprite2ScaleLookup, etc.) that provide input patterns and test scenarios. Include a block for “Test Data Generation / Simulation Data” that supplies pre-generated patterns (as described in the README’s “Input data setup” section).
- Software support modules: There is at least one Java-based “DesignUpdater” component that automates aspects of the PCB layout update and possibly merges data between simulation and design. Add a note for “Design/Build automation” to capture that element.

##### Relationships and interactions
– Start with systems that handle “Memory selection & control registers” (which receive writes from the external bus and set control values such as the char control register, palette RAM, layer enable flags, etc.).
– Then break out the video pipeline as separate submodules:
- Video Timing Generator and Sync Signals – including HBLANK/VBLANK generation, raster line counters.
- Sprite Processing Blocks – sprite register reading, pixel shifting, sprite scan-line RAM buffering, and multiplexing logic.
- Character Screen and Tile/Background Generation – handling bitplane reads, scroll registers, and background mode (including the advanced “mode7” block).
- Pixel Data Combiner & Final Output – where the outputs from the various layers (sprites, character screen, tile backgrounds, and mode7) are merged; include the palette lookup and digital-to-analog conversion stage (resistor ladders) that produces the final video signals.

##### Relevant technologies and frameworks
- Software modules such as “DesignUpdater” (Java), “CheckConectivity” (C++/VS solution), and various data generator tools (some using Python, others VB/C++).
- Mention that while simulation is done digitally, the final output must also cater to analog components (e.g., resistor ladder DAC for video and audio).

##### Final touches
- An inset that shows the overall memory map and registers with their addresses (such as palette registers around 0x9c00, mode7 registers at 0xa000, sprite registers at 0x9800, etc.) since that is an essential part of the design.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Main external interface
    A["External Bus Interface\n(24-bit Address/Data Interface)"]:::hardware
    click A "https://github.com/martinpiper/bombjack/blob/master/UserPortTo24BitAddress.pdsprj"
    
    B["Control Registers & Memory Selection"]:::hardware
    A -->|"controlData"| B
    B -->|"memoryAddr"| K["Memory Map & Registers\n(Inset)"]:::info

    %% Video and Display Pipeline Subgraph (Proteus Simulation)
    subgraph "Video and Display Pipeline (Proteus Simulation)"
        C["Video Timing & Sync Generation\n(HBLANK/VBLANK)"]:::simulation
        D["Sprite Processing\n(Pixel shifting & buffering)"]:::simulation
        E["Tile/Background & Mode7 Processing\n(Scrolling & Mode7 calc)"]:::simulation
        F["Pixel Combiner & DAC\n(Resistor Ladders)"]:::simulation
    end
    B -->|"timingSignals"| C
    B -->|"spriteControl"| D
    B -->|"tileControl"| E
    C -->|"pixelTiming"| F
    D -->|"spritePixels"| F
    E -->|"tilePixels"| F
    click F "https://github.com/martinpiper/bombjack/blob/master/BombJack - Video daughter board BGCOLOUR.pdsprj"

    %% Audio Processing
    G["APU (Audio Processing)"]:::hardware
    A -->|"audioControl"| G
    click G "https://github.com/martinpiper/bombjack/blob/master/APU.pdsprj"

    %% Test Data Generation / Simulation Support
    H["Test Data Generator/\nConnectivity Checker"]:::simulation
    H -->|"injectTestPattern"| C
    H -->|"injectTestPattern"| D
    H -->|"injectTestPattern"| E
    click H "https://github.com/martinpiper/bombjack/tree/master/GenerateData/"

    %% PCB Layout / Physical Design Elements
    I["PCB Layout/\nPhysical Design"]:::physical
    F -->|"finalVideoOutput"| I
    J["Design/Build Automation"]:::software
    J -->|"updateLayouts"| I
    click I "https://github.com/martinpiper/bombjack/blob/master/Bill Of Materials Bomb Jack.csv"
    click J "https://github.com/martinpiper/bombjack/tree/master/src/main/java/com/replicanet/DesignUpdater"

    %% Software Support - Additional Utility
    L["Connectivity Checker"]:::software
    L -->|"assistAutomation"| J
    click L "https://github.com/martinpiper/bombjack/tree/master/CheckConectivity/"

    %% Define classes for coloring
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef simulation fill:#98FB98,stroke:#000,stroke-width:1px;
    classDef software fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef physical fill:#DDA0DD,stroke:#000,stroke-width:1px;
    classDef info fill:#F0E68C,stroke:#000,stroke-width:1px;
```
