From GitHub · · 2m
ZX Desk: A 48K Spectrum Desktop in Z80 Assembly
A functional desktop environment for the 1982 ZX Spectrum 48K built entirely in Z80 assembly, running in under 69,888 T states per frame.
In brief
A functional desktop environment for the 1982 ZX Spectrum 48K built entirely in Z80 assembly, running in under 69,888 T states per frame. ZX Desk fits a full desktop interface into 48K RAM on the ZX Spectrum 48K, achieving 50Hz frame rates through precise hardware timing. Originally reported by GitHub.
What is ZX Desk
A graphical desktop for the ZX Spectrum 48K written in Z80 assembly with overlapping windows, pull down menus, and a heap.
Why Build It
The creator wanted GEM-like desktop features on the Spectrum but couldn't afford an Atari ST, so built a functional alternative.
Key Features
Overlapping z ordered windows, pull down menus, input handling for Kempston mouse and keyboard, and a storage layer with swappable backends.
Performance
Runs in 69,888 T states per frame on a 3.5 MHz Z80, achieving 50Hz frame rates with precise timing.
How It Works
Uses frame discipline with interrupt handling, event queues, and z ordered windows to manage the desktop interface.
Memory Map
Divides 64K RAM into slow and fast regions with specific uses for panels, the calendar, file managers, and the heap.
Measured Performance
Contention costs 14.7% of screen writes, with window drawing taking 71,274 T states per frame.
Interrupt Handling
Fixes interrupt loss during screen fills by ensuring the stack pointer doesn't interfere with interrupt handling.
Drag Performance
Achieves 50Hz frame rates by using damage rectangles and narrow desktop fills to minimize redraws.
Clock Accuracy
Uses interrupt counting to maintain clock accuracy with 50.0801 Hz on 48K machines and 50.0211 Hz on 128K machines.
Calendar System
Counts days from 1 January 1980 without division by using modulo 7 arithmetic for leap years.
Known Bugs
Fixed bugs include heap corruption, register clobbering, and raster timing issues that affected screen display.
Development Process
Follows three passes: research, build, and critique with one commit per verified piece of work.
What's Not Finished
No Next system port, clock behind windows, and no clipboard or selection features in the notepad.
ZX Spectrum Next
A separate system for the ZX Spectrum Next that tiles windows instead of overlapping them.
Repository Structure
Organized into source files for desktop, events, input, storage, and UI components with build scripts.
The big picture
ZX Desk fits a full desktop interface into 48K RAM on the ZX Spectrum 48K, achieving 50Hz frame rates through precise hardware timing.





