ZX Spectrum: How Klive’s Accuracy Is Tested
Over the years the ZX Spectrum community has written test programs that run on a real Spectrum and measure it to the T-state: how long each instruction takes in contended memory, when the ULA reads the screen, where a border change lands, what an unattached port reads. Their authors ran them on real machines, so each program’s expected result comes from hardware.
Klive runs these programs on its own 48K, 128K and +2A/+3 cores in its slow test tier. The expectations are always the real machines’ results (a program’s own PASS/FAIL, its author’s tables or photos, or the World of Spectrum FAQ), never Klive’s own output. Every screen on this page was produced by those test runs, and a test fails if Klive’s screen no longer matches the picture published here.
For the mechanisms these programs check - the frame, contention, the floating bus, snow, early and late machines - read ZX Spectrum: How the Screen Is Drawn.
Results at a glance
| Program | Author, year | What it checks | Klive |
|---|---|---|---|
| ZX Spectrum Timing Tests 48K | Richard and Tim Butler, 2010 | 37 tests of instruction groups and port I/O, in uncontended and contended memory, against a real 48K | 100% pass |
| ZX Spectrum Timing Tests 128K | Richard and Tim Butler, 2015 | the same suite on a real (late-timing) 128K | every test passes, with late timing |
| HALT2INT v3 | Mark Woodmass, 2022 | when a HALT meets the interrupt; early or late ULA | matches the author’s photos of a real early and a real late 48K |
| Float48K, Float128K | Mark Woodmass, 2008 | the floating bus, T-state by T-state | the documented pattern |
| FloatSpy v0.33 | RAMSOFT, 2002 | the floating bus and the ULA type | finds a 48K ULA; passes on both machines |
| Border Time, Screen Time | Jan Bobrowski, 2011 | when a border change and a screen write take effect | where the WoS FAQ puts them |
| Timing Test v0.3 | Patrik Rak, 2013 | how long code takes when it starts at each T-state | the FAQ’s contention pattern |
| ULA 48 Simple, ULA 128 Timing, ULA 128E +3 | azesmbog, 2012 | a picture drawn by timed border writes, on the 48K, the 128K and the +2A/+3 | the real machines’ pictures, row for row |
| IR Contention, IR Contention 128 | Mark Woodmass, 2023 | contention while the I register points into screen memory | symmetrical border bars, as on the real 48K and 128K |
| Snow tests (Snow, Snow48, SnowTests, Snow Hold) | various, 2014-2025 | the snow effect | snow shows; not yet as on a real machine |
The test programs’ screens below are their authors’ work, shown running in Klive.
ZX Spectrum Timing Tests
Richard and Tim Butler’s suite runs 37 tests, each a group of instructions (INC dd, the block
instructions, IX/IY indexing, RST, port I/O and so on), twice: once in uncontended memory and
once in contended memory. Each test counts how many times its loop runs in a fixed number of
T-states and compares the count with the result of its authors’ real machine. A test prints Pass
or Fail, and the 48K version ends with a summary.
Left: the 48K’s test 23, LD A,(IX+n), BIT/RES/SET (IX+n), passing in contended memory.
Right: the last page, “All Tests Complete 100% Pass”.
The 128K version is a snapshot of the same suite, compared with its authors’ 128K. That machine had the late timing, and Klive passes every test with Late ULA Timing on. With early timing, five contended tests fail, as they would on an early 128K.
The 128K with late timing: the suite’s last tests, OUTI/OTIR and RST 18, passing.
HALT2INT: early and late machines
Mark Woodmass’s HALT2INT runs a HALT at six addresses, in and out of contended memory, starting at
five different T-states, and reads the R register afterwards: R counts the instructions (and the
halted cycles) the CPU went through before the interrupt took it. It also reads the floating bus. It
compares both with its tables of a real early and a real late machine, and prints which one it is.
Its author photographed his own 48Ks running it, one early and one late. Klive’s screens show the same values, number for number.
Early timing: Klive (left) and a real early 48K (right). Photo: Mark Woodmass, shipped with HALT2INT under the GPLv2; his photo of his own machine.
Late timing: Klive with Late ULA Timing on (left) and a real late 48K (right). Note the rows at 14,335 and 57,239, where the two machines differ. Photo: Mark Woodmass.
The program’s 128K version has no photo, but it has its own early and late tables, and Klive’s 128K matches both.
HALT2INT 128 on Klive’s 128K with late timing.
Early and late
Real Spectrums do not all agree to the T-state: on many, everything the ULA does comes one T-state later against the interrupt than the documented figures, and a warm ULA can drift from early to late. HALT2INT tells the two apart, and so does Timing Tests 128K, which only passes with late timing. Klive follows both with one model, “everything one T-state later”, switched by Late ULA Timing in the machine’s menu or Settings › Machine (Early and late machines).
The floating bus
Float48K and Float128K read an unattached port at a run of single T-states and list what they get:
255 in the border and between the ULA’s reads, and the screen’s bytes while the ULA reads them.
On the 48K, the bitmap byte of $4000 appears at 14,338, its attribute at 14,339, the next cell’s
two bytes at 14,340 and 14,341, then four T-states of 255, and the pattern repeats. RAMSOFT’s
FloatSpy finds the ULA type from the same bus, and identifies Klive’s 48K as a 48K.
Float48K: bitmap, attribute, bitmap, attribute, then four idle T-states, from 14,338.
Border Time, Screen Time and Timing Test
Jan Bobrowski’s two programs repeat one action at a T-state shown on the screen (Q and A change it)
and draw its effect at the top left of the paper. Border Time changes the border on the line above
the paper; the WoS FAQ says an OUT ending 14,339 to 14,342 T-states after the interrupt changes the
border exactly at the paper’s left edge, and only once per 8 pixels. Screen Time writes to $4000;
the ULA reads that byte three T-states into its contention window, so a write cycle one T-state
later is too late. Both programs number a machine cycle one higher than the FAQ does.
Left: Border Time at 14,336; the change on the line above the paper starts at the paper’s left
edge. Right: Screen Time at 14,335; the write reached $4000 before the ULA read it. One T-state
later, it does not (the test checks both).
Patrik Rak’s Timing Test, built on Bobrowski’s tests, times a piece of code started at every T-state
of a stretch of the frame. Its test 0 times a NOP in contended memory: 4 T-states plus the FAQ’s
delays of 6, 5, 4, 3, 2, 1, 0, 0, repeating every 8 T-states.
Timing Test, contended NOP: the contention pattern from the first contended T-state on.
Pictures drawn by the border
azesmbog’s ULA tests draw a picture with a long run of OUT instructions to the border port, timed
to the T-state from the interrupt, over the border and the paper alike. A machine whose timing is off
by even a few T-states shows the stripes in the wrong place, the letters cut or wrapped. Their wiki
pages show each picture on real machines; Klive draws them the same, row for row.
Left: ULA 128 Timing Test on the 128K. Right: ULA 128E +3 Test on the +3, where the gate array contends no I/O cycle: its border writes run at full speed through the display.
Mark Woodmass’s IR Contention programs run code through the display while the I register points into screen memory, then draw four bars in the top and the bottom border. They say what to expect: the bars in the lower border are symmetrical to those in the top border on a real machine.
IR Contention 128 on the 128K: the bottom bars line up with the top ones.
Snow
When a program sets the I register to $40-$7F, every refresh cycle looks like an access to the
screen memory, and the ULA reads wrong bytes where the two meet: the Spectrum’s snow. The snow
programs draw a picture and set I so that it snows. Klive shows snow in them, but not yet where a
real machine does (see Not yet proven).
azesmbog’s Snow48 with Snow Effect on (left) and off (right).
Not yet proven
- Snow. A real 48K running Snow48 (variation b5) shows every second character cell repeating the one before it, all over the picture; Klive shows almost none of it. Which T-states of a refresh the ULA takes as its own read is not settled yet.
- Where the +2A/+3’s contention starts. The World of Spectrum reference puts the first 7 at 14,367, the Sinclair Wiki at 14,363. ULA 128E +3 Test draws the same picture either way, and no program in the kit decides it; Klive keeps it at 14,364, in between.
- The +2A/+3’s floating bus is not checked against a real machine.
- Snow R, Snow128N and Snow Contention have no real-machine picture to compare with yet, and Time to First INT has photos of a real 48K that are still to be compared.
Run them yourself
The test programs are in the repository, in
dev/vendor/spectrum-tests/,
with their sources, licences and links to their wiki pages. Each is a .tap (or an .szx) that
loads in Klive like any other program: open it, pick the machine, and compare what you see with the
pictures here.
To run the whole kit as tests, in a clone of the repository:
npm run test:slowIt writes every program’s screen to .local/spectrum-kit/. The pictures on this page come from the same
runs.
The test programs belong to their authors and are not part of Klive or its MIT licence; Klive never ships them. Their catalogue, with the real-machine results each one is known for, is the ZXE wiki’s list of tests .
















