# skoolkid/skoolkit architecture

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

- Interactive diagram: https://gitdiagram.com/skoolkid/skoolkit
- Repository: https://github.com/skoolkid/skoolkit

## Overview

SkoolKit is a ZX Spectrum software analysis and disassembly toolkit. Its central workflow turns a snapshot or raw memory into a control file and then an annotated skool disassembly, which can be rendered as HTML or exported as assembler source. Separate utilities inspect and convert snapshots, tapes and graphics; emulation and execution tracing support code analysis. The graph follows documented capabilities and the supplied source index; some internal relationships are omitted where excerpts do not establish the calling path.

Main entry points: [`skoolkit/snaskool.py`](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/snaskool.py) (Snapshot disassembly), [`skoolkit/skoolparser.py`](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolparser.py) (Annotated skool source), [`skoolkit/rzxplay.py`](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/rzxplay.py) (RZX playback), [`skoolkit/skoolctl.py`](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolctl.py) (Control-file generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Analysis and disassembly"]
  node_sna2ctl["Control-file generation<br/>[skoolctl.py]"]
  node_sna2skool["Snapshot disassembly<br/>[snaskool.py]"]
  node_ctlparser["Control-file parsing<br/>[ctlparser.py]"]
  node_disassembler["Z80 disassembly<br/>[disassembler.py]"]
  node_skool["Annotated skool source<br/>[skoolparser.py]"]
end

subgraph group_emulation["Emulation and tracing"]
  node_execution["Execution tracing<br/>[trace.py]"]
  node_rzxplay["RZX playback<br/>[rzxplay.py]"]
  node_simulator["Z80 simulator<br/>[simulator.py]"]
  node_cmiosimulator["Timing-aware simulation<br/>[cmiosimulator.py]"]
  node_pagingtracer["Paging tracer<br/>[pagingtracer.py]"]
end

subgraph group_outputs["Disassembly outputs"]
  node_html["HTML disassembly<br/>[skoolhtml.py]"]
  node_assembler["Assembler export<br/>[skoolasm.py]"]
  node_ctl_export["Control-file export<br/>[skoolctl.py]"]
  node_binary_export["Raw-memory export<br/>[skool2bin.py]"]
end

subgraph group_media["Snapshot and media tools"]
  node_snapshot_store[("Snapshot handling<br/>[snapshot.py]")]
  node_tap2sna["Tape to snapshot<br/>[tap2sna.py]"]
  node_tapeinfo["Tape analysis<br/>[tapinfo.py]"]
  node_rzxinfo["RZX analysis<br/>[rzxinfo.py]"]
  node_snapinfo["Snapshot analysis<br/>[snapinfo.py]"]
  node_snapmod["Snapshot editing<br/>[snapmod.py]"]
  node_image["Graphics to PNG<br/>[sna2img.py]"]
end

subgraph group_runtime["Shared runtime"]
  node_components["Configurable components<br/>[components.py]"]
  node_textutils["Text parsing helpers<br/>[textutils.py]"]
  node_z80["Z80 instruction utilities<br/>[z80.py]"]
  node_skoolmacro["Skool macros<br/>[skoolmacro.py]"]
end

node_user(("Spectrum analyst"))
node_snapshot["Snapshot input"]

node_user -->|"generates control"| node_sna2ctl
node_snapshot -->|"analyzes memory"| node_sna2ctl
node_user -->|"requests disassembly"| node_sna2skool
node_sna2ctl -->|"supplies control file"| node_sna2skool
node_snapshot -->|"provides memory"| node_sna2skool
node_sna2skool -.->|"parses directives"| node_ctlparser
node_sna2skool -.->|"disassembles code"| node_disassembler
node_sna2skool -->|"produces source"| node_skool
node_user -->|"traces execution"| node_execution
node_user -->|"plays RZX trace"| node_rzxplay
node_rzxplay -->|"executes frames"| node_simulator
node_rzxplay -->|"uses timing model"| node_cmiosimulator
node_rzxplay -->|"tracks paging"| node_pagingtracer
node_execution -->|"provides execution map"| node_sna2ctl
node_rzxplay -->|"provides execution map"| node_sna2ctl
node_user -->|"renders disassembly"| node_html
node_skool -->|"converts to HTML"| node_html
node_user -->|"exports assembly"| node_assembler
node_skool -->|"converts to assembly"| node_assembler
node_skool -->|"converts to control"| node_ctl_export
node_skool -->|"exports memory"| node_binary_export
node_user -->|"converts tape"| node_tap2sna
node_tap2sna -->|"creates snapshot"| node_snapshot_store
node_user -->|"analyzes tape"| node_tapeinfo
node_user -->|"analyzes RZX"| node_rzxinfo
node_user -->|"inspects snapshot"| node_snapinfo
node_user -->|"modifies snapshot"| node_snapmod
node_user -->|"creates PNG"| node_image
node_skoolmacro -->|"loads configurable tools"| node_components
node_skoolmacro -->|"runs simulation macros"| node_simulator
node_skoolmacro -->|"supports audio timing"| node_cmiosimulator
node_z80 -->|"uses text parsing"| node_textutils
node_skoolmacro -.->|"uses text helpers"| node_textutils

click node_sna2ctl "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolctl.py"
click node_sna2skool "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/snaskool.py"
click node_ctlparser "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/ctlparser.py"
click node_disassembler "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/disassembler.py"
click node_skool "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolparser.py"
click node_execution "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/trace.py"
click node_rzxplay "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/rzxplay.py"
click node_simulator "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/simulator.py"
click node_cmiosimulator "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/cmiosimulator.py"
click node_pagingtracer "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/pagingtracer.py"
click node_html "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolhtml.py"
click node_assembler "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolasm.py"
click node_ctl_export "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolctl.py"
click node_binary_export "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skool2bin.py"
click node_snapshot_store "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/snapshot.py"
click node_tap2sna "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/tap2sna.py"
click node_tapeinfo "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/tapinfo.py"
click node_rzxinfo "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/rzxinfo.py"
click node_snapinfo "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/snapinfo.py"
click node_snapmod "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/snapmod.py"
click node_image "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/sna2img.py"
click node_components "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/components.py"
click node_textutils "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/textutils.py"
click node_z80 "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/z80.py"
click node_skoolmacro "https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolmacro.py"

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_sna2ctl,node_sna2skool,node_ctlparser,node_disassembler,node_skool toneBlue
class node_execution,node_rzxplay,node_simulator,node_cmiosimulator,node_pagingtracer toneAmber
class node_html,node_assembler,node_ctl_export,node_binary_export toneMint
class node_snapshot_store,node_tap2sna,node_tapeinfo,node_rzxinfo,node_snapinfo,node_snapmod,node_image toneRose
class node_components,node_textutils,node_z80,node_skoolmacro,node_user,node_snapshot toneIndigo
```

## Components

### Analysis and disassembly

- [Control-file generation](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolctl.py): `skoolkit/skoolctl.py`
- [Snapshot disassembly](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/snaskool.py): `skoolkit/snaskool.py`
- [Control-file parsing](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/ctlparser.py): `skoolkit/ctlparser.py`
- [Z80 disassembly](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/disassembler.py): `skoolkit/disassembler.py`
- [Annotated skool source](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolparser.py): `skoolkit/skoolparser.py`

### Emulation and tracing

- [Execution tracing](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/trace.py): `skoolkit/trace.py`
- [RZX playback](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/rzxplay.py): `skoolkit/rzxplay.py`
- [Z80 simulator](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/simulator.py): `skoolkit/simulator.py`
- [Timing-aware simulation](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/cmiosimulator.py): `skoolkit/cmiosimulator.py`
- [Paging tracer](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/pagingtracer.py): `skoolkit/pagingtracer.py`

### Disassembly outputs

- [HTML disassembly](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolhtml.py): `skoolkit/skoolhtml.py`
- [Assembler export](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolasm.py): `skoolkit/skoolasm.py`
- [Control-file export](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolctl.py): `skoolkit/skoolctl.py`
- [Raw-memory export](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skool2bin.py): `skoolkit/skool2bin.py`

### Snapshot and media tools

- [Snapshot handling](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/snapshot.py): `skoolkit/snapshot.py`
- [Tape to snapshot](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/tap2sna.py): `skoolkit/tap2sna.py`
- [Tape analysis](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/tapinfo.py): `skoolkit/tapinfo.py`
- [RZX analysis](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/rzxinfo.py): `skoolkit/rzxinfo.py`
- [Snapshot analysis](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/snapinfo.py): `skoolkit/snapinfo.py`
- [Snapshot editing](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/snapmod.py): `skoolkit/snapmod.py`
- [Graphics to PNG](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/sna2img.py): `skoolkit/sna2img.py`

### Shared runtime

- [Configurable components](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/components.py): `skoolkit/components.py`
- [Text parsing helpers](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/textutils.py): `skoolkit/textutils.py`
- [Z80 instruction utilities](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/z80.py): `skoolkit/z80.py`
- [Skool macros](https://github.com/skoolkid/skoolkit/blob/master/skoolkit/skoolmacro.py): `skoolkit/skoolmacro.py`

### Other components

- **Spectrum analyst**
- **Snapshot input**

## Connections

- Spectrum analyst → Control-file generation: generates control
- Snapshot input → Control-file generation: analyzes memory
- Spectrum analyst → Snapshot disassembly: requests disassembly
- Control-file generation → Snapshot disassembly: supplies control file
- Snapshot input → Snapshot disassembly: provides memory
- Snapshot disassembly → Control-file parsing: parses directives
- Snapshot disassembly → Z80 disassembly: disassembles code
- Snapshot disassembly → Annotated skool source: produces source
- Spectrum analyst → Execution tracing: traces execution
- Spectrum analyst → RZX playback: plays RZX trace
- RZX playback → Z80 simulator: executes frames (evidence: `skoolkit/rzxplay.py`)
- RZX playback → Timing-aware simulation: uses timing model (evidence: `skoolkit/rzxplay.py`)
- RZX playback → Paging tracer: tracks paging (evidence: `skoolkit/rzxplay.py`)
- Execution tracing → Control-file generation: provides execution map
- RZX playback → Control-file generation: provides execution map
- Spectrum analyst → HTML disassembly: renders disassembly
- Annotated skool source → HTML disassembly: converts to HTML
- Spectrum analyst → Assembler export: exports assembly
- Annotated skool source → Assembler export: converts to assembly
- Annotated skool source → Control-file export: converts to control
- Annotated skool source → Raw-memory export: exports memory (evidence: `skoolkit/skoolparser.py`)
- Spectrum analyst → Tape to snapshot: converts tape
- Tape to snapshot → Snapshot handling: creates snapshot (evidence: `skoolkit/tap2sna.py`)
- Spectrum analyst → Tape analysis: analyzes tape
- Spectrum analyst → RZX analysis: analyzes RZX
- Spectrum analyst → Snapshot analysis: inspects snapshot
- Spectrum analyst → Snapshot editing: modifies snapshot
- Spectrum analyst → Graphics to PNG: creates PNG
- Skool macros → Configurable components: loads configurable tools (evidence: `skoolkit/skoolmacro.py`)
- Skool macros → Z80 simulator: runs simulation macros (evidence: `skoolkit/skoolmacro.py`)
- Skool macros → Timing-aware simulation: supports audio timing (evidence: `skoolkit/skoolmacro.py`)
- Z80 instruction utilities → Text parsing helpers: uses text parsing (evidence: `skoolkit/z80.py`)
- Skool macros → Text parsing helpers: uses text helpers
