Egghead.page Logo

How Sinclair QL Managed Screen Memory Allocation

The Sinclair QL utilized a unique approach to video display that differed significantly from its contemporaries like the ZX Spectrum or Commodore 64. This article explores the technical mechanisms behind the QL’s screen memory allocation, detailing how the Motorola 68008 processor interacted with the custom gate array to render graphics. Readers will learn about the specific memory addresses, the shared RAM strategy, and the implications for programming and system performance.

Integrated Memory Architecture

Unlike many home computers of the 1980s that featured dedicated video RAM (VRAM) separate from the main system memory, the Sinclair QL used a unified memory architecture. The display data was stored directly within the main dynamic RAM (DRAM) pool available to the CPU. This design choice reduced hardware costs and complexity but introduced specific challenges regarding bandwidth and access speeds. The standard configuration included 128 KB or 512 KB of RAM, from which a portion was reserved for the display buffer depending on the selected graphics mode.

The Role of the Custom Gate Array

Central to the QL’s memory management was a custom uncommitted logic array (ULA), often referred to as the gate array. This chip handled DRAM refresh cycles, video signal generation, and memory arbitration. Instead of the CPU having unrestricted access to the RAM at all times, the gate array prioritized video data retrieval to ensure a stable screen image without tearing. It accessed the main memory directly to fetch pixel data during the horizontal and vertical blanking intervals, as well as during active display lines, effectively acting as a bus master for video operations.

CPU Contention and Performance

Because the CPU and the video logic shared the same memory bus, contention occurred when both attempted to access RAM simultaneously. The gate array was designed to halt the Motorola 68008 processor periodically to allow video data to be read. This cycle stealing meant that the CPU effectively ran slower than its rated 7.5 MHz clock speed when the display was active. The impact on performance was noticeable in memory-intensive operations, as the processor had to wait for the video circuitry to release the bus before it could execute instructions or access variables stored in RAM.

Operating System Management

The QDOS operating system managed the logical allocation of this memory. Rather than having a fixed hardware address for the screen buffer, QDOS utilized pointers to define where the display memory began within the RAM map. This allowed for some flexibility, such as supporting multiple screens or changing resolution modes without altering the physical hardware layout. Programmers accessing screen memory directly had to query these system variables to ensure they were writing to the correct address range, preventing data corruption in other areas of the application or operating system.