The Spectrum Dispatch News

technology

Developer Recreates Desktop Environment for 1982 ZX Spectrum in 48K

A graphical UI with windows, menus, and applications fits entirely on the original home computer, running on real hardware with detailed performance measurements.

Developer Recreates Desktop Environment for 1982 ZX Spectrum in 48K

A developer has built a complete graphical desktop environment for the ZX Spectrum 48K, a home computer from 1982, entirely in Z80 assembly. The project, named zxdesk, includes overlapping windows with z-order and focus management, pull-down menus, a file manager, notepad, clock, calendar, and settings panel—all within the machine’s 48 kilobytes of RAM.

Developer Recreates Desktop Environment for 1982 ZX Spectrum in 48K

The desktop runs on actual hardware, not just emulators. According to the source, it can drag a window within a single 69,888 T-state frame, demonstrating efficient use of the 3.5 MHz processor’s limited cycles.

The creator was inspired by Atari ST’s GEM desktop environment in the 1980s but lacked the funds for that hardware. After decades, the project explores how much of that vision could be realized on a Spectrum’s constraints: a 3.5 MHz Z80 processor, 48K RAM, a one-bit display with attribute clash limitations, and a video chip that steals CPU cycles during rendering.

Key features include input handling via Kempston mouse and joystick, a 16-slot event queue, configurable storage backends (RAM, tape via the original ROM loader, and 128K RAM disk), and a real heap allocator for window buffers. Applications are modular, with descriptor tables defining initialization, event handling, and painting routines. Settings persist using a magic byte and version system.

The implementation emphasizes careful measurement over theoretical optimization. The developer notes that performance answers “turned out to be more interesting than the question, and nearly all of them came from measuring the machine rather than reasoning about it.” Hit testing uses a five-byte row per control in z-order, refilled before each search. Windows are records swapped into live copies to avoid stale position references. The storage system uses a registry of backends with dispatch costing only ten T-states.

Memory is divided into slow and fast regions based on video chip cycle stealing. The slow region ($6000-$727C) holds panels and file data. The fast region ($8000-$B1B7) contains the core system. The heap occupies 8,112 bytes ($DF50-$FEFF).

The toolchain uses pasmo 0.5.5 and can build to tape format. Build scripts support demo modes with reproducible captures, scripted input for regression testing, and Kempston mouse diagnostics. The project includes notes on emulator-specific behavior, such as Fuse for macOS stopping mouse movement delivery while buttons are held.

Key facts

  • The graphical desktop fits entirely within the ZX Spectrum’s 48K RAM
  • It runs on real hardware, not just emulators
  • Features include overlapping windows, menus, file manager, notepad, clock, and calendar
  • Built entirely in Z80 assembly language
  • Includes a 16-slot event queue and real heap allocator with 8,112 bytes
  • Can drag windows within a single 69,888 T-state frame on a 3.5 MHz processor
  • Storage backends support RAM, tape, and 128K RAM disk modes
  • Designed with performance measurements as primary optimization approach

Sources

← All posts