CS 181-AR

Vital Constants

In designing your ZX Spectrum emulator, there are several constants that represent key aspects of the ZX Spectrum hardware. These constants help define when various things happen in the ZX Spectrum's operation, and other key aspects of the ZX Spectrum's hardware.

The following resources provide information on the ZX Spectrum's hardware and how it works:

  • ZX Spectrum 48K Reference — This is perhaps the most comprehensive reference on the ZX Spectrum's hardware.
  • PAL TV Timing — This background information on the PAL TV standard is useful for understanding how the analog TV signal worked (see also this page for similar information).

Timing and Dimensions

What is the clock speed of the ZX Spectrum's Z80 CPU in Hz (cyles per second)?

Ticks of the clock are often called "T-states" in the ZX Spectrum documentation.

How many T-states make up one horizontal scanline on the ZX Spectrum?

How many T-states make up an entire frame? (Technically, it's actually a field in PAL terms; a PAL frame consists of two interlaced fields. The ZX Spectrum (and similar systems) violate the PAL standard by repeatedly sending only the first field of a PAL frame.)

Calculate the exact frame rate of the ZX Spectrum in Hz. (Hint: It's not exactly 50Hz)

Calculate how many scanlines are in a complete frame? (i.e., the single field that the ZX Spectrum sends)

When the ZX Spectrum is generating the screen, how many T-states does it take to produce a run of eight pixels?

Screen Dimensions

The ZX Spectrum display has two key areas, the screen area and the border area. The screen area is where individually addressable pixels are displayed, while the border surrounds the screen area and has a color defined by an internal register on the ZX Spectrum's ULA.

What are the screen area dimensions in pixels (width × height)?

How wide is the border in pixels on each side of the screen area?

How many scan lines are generated before we reach the screen area? (include all scan lines, including the blanking lines)

At least how many of these before-the-screen-area scan lines are showing the border color?

The technical documentation claims how many scan lines are in the bottom border area?

A Contradition and a Choice

Note that according to the technical documentation, there are 64 scan lines in the top border area (of which only 48 may be visible), 192 scan lines in the screen area, and 56 scan lines in the bottom border area. This adds up to 312 scan lines, which is the total number of scan lines in a frame. However, if you check the PAL documentation above, you'll find that the final three scan lines of a PAL frame are used to send the vertical sync pulse, which is not visible on the screen. Thus there cannot be 56 border lines visible in the bottom border area.

In practice, you have an aesthetic choice to make regarding how much of the border to show. Actual PAL TVs had a property called "overscan" where the edges of the screen were not visible. Thus you probably want not to show some of the border that might technically be visible according to the PAL standard.

Memory Organization

The ZX Spectrum's screen memory for pixels starts at what memory address? (Write it in hexadecimal, prefaced by 0x)

This memory is followed by the color attribute memory. What is the memory address where the color attributes start? (Write it in hexadecimal, prefaced by 0x)

Interrupts and Timing

The ZX Spectrum generates a timed interrupt signal that can be used to synchronize with the screen display. This interrupt is generated during the first scan line of the PAL frame.

When does the interrupt occur?

How long does the interrupt signal stay active? (This is an important detail to get right, but you may struggle to find the any answer in the technical documentation! However, the following LLMs do seem to give the correct answer to this question if given the options below: claude-sonnet-2.7, chatgpt-4o, gemini-2.0-pro-exp-02-05; some other LLMs, including grok3-2, give the wrong answer.)

A Visualization

These numbers may seem a bit abstact, so here's a visualization of the ZX Spectrum's screen layout:

(When logged in, completion status appears here.)