Hacker News front pagemindbox7723 min readadvanced
A graphical desktop for the ZX Spectrum
Summary
The author built a full graphical desktop for the 48 KB ZX Spectrum in Z80 assembly, fitting overlapping windows, menus, input handling, and a heap within a single frame. All performance claims are backed by measurements taken on real hardware.
- Overlapping windows with Z‑order and focus are implemented using a 16‑slot ring event queue and a per‑frame scheduler that keeps input handling constant‑time.
- A custom memory map separates contended (slow) and fast RAM, ensuring no time‑critical code runs in the ULA‑stealed region.
- Timing is measured against the 69,888‑T‑state interrupt period, achieving sub‑0.01% error and revealing actual contention cost (~14.7%).
- The storage layer abstracts RAM, tape, and ESXDOS backends via a 14‑byte descriptor table, enabling pluggable persistence.
Engineers building UI or real‑time systems on extreme resource constraints can learn concrete techniques for timing, memory layout, and event handling from this work.
7/10


