# bear2305/x86-snake_game architecture

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

- Interactive diagram: https://gitdiagram.com/bear2305/x86-snake_game
- Repository: https://github.com/bear2305/x86-snake_game

## Overview

BIOS Snake is a small second-stage real-mode game. A boot-stage loader transfers control to its main loop; the loop polls BIOS keyboard services, dispatches movement, updates the snake’s in-memory coordinates, redraws it through BIOS video services, and waits between moves. The README documents these routine relationships, but no source excerpts were available, so the graph reflects documented behavior only. Food, growth, collision handling, and scoring are not implemented capabilities.

Main entry points: [`snakegame.asm`](https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm) (Game loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Game control"]
  node_entry["Game loop<br/>[snakegame.asm]"]
  node_key["Key polling<br/>[snakegame.asm]"]
  node_dispatch["Direction dispatch<br/>[snakegame.asm]"]
end

subgraph group_movement["Movement and state"]
  node_movement["Direction routines<br/>[snakegame.asm]"]
  node_update["Body update<br/>[snakegame.asm]"]
  node_state["Snake coordinates<br/>[snakegame.asm]"]
end

subgraph group_output["Display and timing"]
  node_render["Body rendering<br/>[snakegame.asm]"]
  node_delay["Movement delay<br/>[snakegame.asm]"]
end

node_loader(("Boot-stage loader"))
node_player(("Player"))
node_bios["BIOS services"]

node_loader -->|"jumps to"| node_entry
node_entry -->|"polls"| node_key
node_player -->|"presses keys"| node_bios
node_key -->|"reads keys"| node_bios
node_key -->|"stores direction"| node_dispatch
node_dispatch -->|"dispatches"| node_movement
node_movement -->|"updates"| node_update
node_update -->|"shifts coordinates"| node_state
node_update -->|"redraws"| node_render
node_render -->|"draws via"| node_bios
node_entry -->|"waits via"| node_delay
node_delay -->|"requests delay"| node_bios

click node_entry "https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm"
click node_key "https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm"
click node_dispatch "https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm"
click node_movement "https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm"
click node_update "https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm"
click node_state "https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm"
click node_render "https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm"
click node_delay "https://github.com/bear2305/x86-snake_game/blob/main/snakegame.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_entry,node_key,node_dispatch toneBlue
class node_movement,node_update,node_state toneAmber
class node_render,node_delay toneMint
class node_loader,node_player,node_bios toneIndigo
```

## Components

### Game control

- [Game loop](https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm): `snakegame.asm`
- [Key polling](https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm): `snakegame.asm`
- [Direction dispatch](https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm): `snakegame.asm`

### Movement and state

- [Direction routines](https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm): `snakegame.asm`
- [Body update](https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm): `snakegame.asm`
- [Snake coordinates](https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm): `snakegame.asm`

### Display and timing

- [Body rendering](https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm): `snakegame.asm`
- [Movement delay](https://github.com/bear2305/x86-snake_game/blob/main/snakegame.asm): `snakegame.asm`

### Other components

- **Boot-stage loader**
- **Player**
- **BIOS services**

## Connections

- Boot-stage loader → Game loop: jumps to
- Game loop → Key polling: polls
- Player → BIOS services: presses keys
- Key polling → BIOS services: reads keys
- Key polling → Direction dispatch: stores direction
- Direction dispatch → Direction routines: dispatches
- Direction routines → Body update: updates
- Body update → Snake coordinates: shifts coordinates
- Body update → Body rendering: redraws
- Body rendering → BIOS services: draws via
- Game loop → Movement delay: waits via
- Movement delay → BIOS services: requests delay
