Skip to Content
GuidesDebuggingThe paused screen

The Paused Screen

When the machine pauses in the middle of a frame, the emulator screen shows a picture that is half this frame and half the last one. Klive offers two ways to read it: the beam position overlay marks where the raster beam is and which part is old, and the instant screen redraws the whole picture from what the screen memory holds now. Use them when you time mid-frame effects (border stripes, Copper splits, a palette change per line, a sprite updated before the beam reaches it) or when you want to see what your code has just drawn.

Applies to: the ZX Spectrum models (48K, 128K, +2A/+3, +2E/+3E, Pentagon, Scorpion, Timex), the ZX Spectrum Next and the HT-1080Z. The Cambridge Z88 has an LCD and no beam, and the ZX80/ZX81 picture is generated by the CPU itself.

The beam position

While the machine is paused (at a breakpoint, after a step, or after Pause) the emulator screen shows:

The paused ZX Spectrum Next screen with the beam on paper row 94: this frame's border stripes and Copper split above the beam line, the previous frame hatched below it, and the hover readout of a pixel near the bottom

  • a dashed line across the beam’s row and a tick at the pixel it is drawing;
  • a pill with the beam’s position: line 158 · paper row 94 · hc 381 · HC 72,429: the raster line, the row of the paper (or top border, bottom border), the position within the line, and the frame tact;
  • the part of the picture past the beam, hatched and labelled previous frame.

The overlay disappears when the machine runs again.

Why part of the picture is hatched

The emulator draws the screen as the beam does, a little at a time while the CPU runs. When the machine stops in the middle of a frame, the screen holds two frames at once: this frame up to the beam, and the previous frame after it, including pixels your program has already changed in memory, because the beam has not reached them yet.

Without a mark, that second part looks like a bug in your program. So the overlay hatches it: what is under the hatch is real, but it is last frame’s. In the picture above, the border stripes do not line up across the beam line for exactly this reason.

Before it draws the overlay, Klive also brings the paused picture up to the beam: everything the beam has drawn this frame is on the screen, even the part the emulator had not caught up with yet. This is done on a copy of the picture and changes nothing in the machine: running on, the frame is drawn exactly as it would have been without a stop.

With the instant screen on, the paused picture is the whole screen drawn from memory as it is now, so there is no “previous frame” part: the overlay draws only the beam line, and the pill says instant screen.

When the beam is off the screen

The beam spends part of every line, and some lines of every frame, outside the visible picture. Then the overlay marks the edge it left and the pill names where it is:

  • HBLANK: horizontal blanking, between the end of one row and the start of the next. The beam line marks the last row finished, with a marker at the right edge.
  • VBLANK · 12 lines to the top border: vertical blanking, between the bottom of one picture and the top of the next. A line along the top (or bottom) edge marks it.

How far is the beam from a pixel?

Point at the paused screen, and the overlay tells you when the beam gets there:

(432, 267) · line 283 · hc 312 · HC 129,360 · in 56,931 HC

the pixel, its raster line and position, its frame tact, and how many tacts until the beam draws it, or drawn if it already has this frame. That is how long your code has to change something before the beam reaches it.

Units

The ZX Spectrum models count in T-states of the 3.5 MHz CPU clock (T 26,189); the position within the line is called tact. The ZX Spectrum Next counts in 7 MHz pixel-clock units, the hardware’s HC (two per 3.5 MHz T-state), and its position within the line is hc. The Next’s line and frame lengths change with its display timing (48K, 128K, +3, Pentagon, 50 or 60 Hz); the overlay always uses the timing of the frame in progress.

The HT-1080Z counts in T-states of its 1.77 MHz clock, and one T-state is one whole character, 6 dots wide: a line is 112 T-states, of which slots 2 to 65 draw the 64 characters. Its “paper” is the 64 x 16 character screen. HT-1080Z: how the screen is drawn explains its timing.

The ULA & I/O panel’s RAS and POS show the same raster line and position.

The Copper

On the ZX Spectrum Next, when a Copper breakpoint stops the machine, the Copper’s hit gets a second marker, labelled Copper hit $001. The machine stops at the end of the CPU instruction during which the Copper hit its breakpoint, so the Copper’s position and the CPU’s are a few pixels apart; the two markers keep them apart.

Turning it on and off

The overlay is on by default. Turn it off or on with Show/Hide the beam position while paused on the emulator toolbar, with Show the beam position while paused on the Emulator page of Settings, or with the beam command:

beam ; says whether it is shown beam off beam on

The instant screen

The ZX Spectrum draws its picture while the CPU runs, following the beam, so a byte written to the screen memory appears only when the beam next passes it. When the machine pauses, drawing pauses too: what your code has just written may not be on the screen yet.

Turn on Turn on/off instant screen on the emulator toolbar (or Show the instant screen on the Emulator page of Settings). While the machine is paused, the screen is then drawn in full from the current screen memory, as if the beam had drawn a whole frame at this moment. Turn it off to see the beam-accurate picture again. The setting has no effect while the machine runs.

Last updated on