# bemxio/bad-apple-bootloader architecture

> Architecture diagram of the GitHub repository bemxio/bad-apple-bootloader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bemxio/bad-apple-bootloader
- Repository: https://github.com/bemxio/bad-apple-bootloader

## Overview

Bad Apple Bootloader turns grayscale video into a bootable image that plays from disk to the screen. The documented preparation flow converts video frames into palette-indexed data; the boot code then reads frames and displays them, with PIT timing supporting faithful playback. The compressor excerpt confirms palette loading and run-length output. Assembly responsibilities are represented by their filenames and README-level behavior; their internal calls are not shown, so those links are omitted. The README also documents QEMU as a way to run the image.

Main entry points: [`src/bootsector.asm`](https://github.com/bemxio/bad-apple-bootloader/blob/main/src/bootsector.asm) (Bootsector), [`src/compressor.c`](https://github.com/bemxio/bad-apple-bootloader/blob/main/src/compressor.c) (Frame compressor), [`palette.bin`](https://github.com/bemxio/bad-apple-bootloader/blob/main/palette.bin) (Color palette), [`src/disk.asm`](https://github.com/bemxio/bad-apple-bootloader/blob/main/src/disk.asm) (Disk access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Video preparation"]
  node_compressor["Frame compressor<br/>[compressor.c]"]
  node_palette["Color palette<br/>[palette.bin]"]
  node_frame_data["Encoded frames"]
  node_image["Boot image"]
end

subgraph group_playback["Boot playback"]
  node_bootsector["Bootsector<br/>[bootsector.asm]"]
end

subgraph group_io["Machine I/O"]
  node_disk["Disk access<br/>[disk.asm]"]
  node_video["Video output<br/>[video.asm]"]
  node_serial["Serial I/O<br/>[serial.asm]"]
end

node_video_source(("Source video"))
node_qemu["QEMU"]

node_video_source -->|"supplies frames"| node_compressor
node_palette -->|"loads palette"| node_compressor
node_compressor -->|"encodes frames"| node_frame_data
node_frame_data -->|"included in"| node_image
node_bootsector -->|"forms boot code"| node_image
node_bootsector -->|"reads frames"| node_disk
node_bootsector -->|"displays frames"| node_video
node_image -->|"runs in"| node_qemu

click node_compressor "https://github.com/bemxio/bad-apple-bootloader/blob/main/src/compressor.c"
click node_palette "https://github.com/bemxio/bad-apple-bootloader/blob/main/palette.bin"
click node_bootsector "https://github.com/bemxio/bad-apple-bootloader/blob/main/src/bootsector.asm"
click node_disk "https://github.com/bemxio/bad-apple-bootloader/blob/main/src/disk.asm"
click node_video "https://github.com/bemxio/bad-apple-bootloader/blob/main/src/video.asm"
click node_serial "https://github.com/bemxio/bad-apple-bootloader/blob/main/src/serial.asm"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_compressor,node_palette,node_frame_data,node_image toneBlue
class node_bootsector toneAmber
class node_disk,node_video,node_serial toneMint
class node_video_source,node_qemu toneIndigo
```

## Components

### Video preparation

- [Frame compressor](https://github.com/bemxio/bad-apple-bootloader/blob/main/src/compressor.c): `src/compressor.c`
- [Color palette](https://github.com/bemxio/bad-apple-bootloader/blob/main/palette.bin): `palette.bin`
- **Encoded frames**
- **Boot image**

### Boot playback

- [Bootsector](https://github.com/bemxio/bad-apple-bootloader/blob/main/src/bootsector.asm): `src/bootsector.asm`

### Machine I/O

- [Disk access](https://github.com/bemxio/bad-apple-bootloader/blob/main/src/disk.asm): `src/disk.asm`
- [Video output](https://github.com/bemxio/bad-apple-bootloader/blob/main/src/video.asm): `src/video.asm`
- [Serial I/O](https://github.com/bemxio/bad-apple-bootloader/blob/main/src/serial.asm): `src/serial.asm`

### Other components

- **Source video**
- **QEMU**

## Connections

- Source video → Frame compressor: supplies frames (evidence: `README.md`)
- Color palette → Frame compressor: loads palette (evidence: `src/compressor.c`)
- Frame compressor → Encoded frames: encodes frames (evidence: `src/compressor.c`)
- Encoded frames → Boot image: included in (evidence: `README.md`)
- Bootsector → Boot image: forms boot code (evidence: `README.md`)
- Bootsector → Disk access: reads frames (evidence: `README.md`)
- Bootsector → Video output: displays frames (evidence: `README.md`)
- Boot image → QEMU: runs in (evidence: `README.md`)
