Reference machines

From SpecNext official Wiki
Jump to: navigation, search

Reference Machines

The Spectrum Next is based on five reference machines:

  • ZX Spectrum 16k: The cut-down version of the original Spectrum. Has no memory after $7fff, so all memory is contended. Not simulated by the Next since the 48k version is identical but has more memory.
  • ZX Spectrum 48k: The original Spectrum. Does not support memory remapping.
  • ZX Spectrum 128k: The first enhanced Spectrum made by Sinclair. Supports memory remapping and the shadow screen.
  • ZX Spectrum +2A/+3: The enhanced Spectrums after Amstrad rebranding. This is also the "native" personality of the next.
  • Pentagon: A Russion-made homebrew Spectrum that eliminated contended memory and doubled the clock speed.

Video Timing

The video timing of the Next is determined by four factors:

  • The video timing of the reference machine selected by the config personality (readable at Machine Type Register ($03))
  • The frame rate, 50hz or 60hz (readable from Peripheral 1 Register ($05)). This can be freely adjusted except that the Pentagon can only run at 50Hz.
  • The configured video output type, VGA or HDMI (readable from Video Timing Register ($11)). If HDMI is selected, the video timing of the selected machine type is completely overridden, so this is considered an alternative machine type below, although not by the Next firmware (which means that if Pentagon is selected, a 60Hz frame rate can be chosen if the output type is HDMI)

The video output is divided into four phases, starting from the first line of the addressable screen (not the top left corner of the whole screen, which is part of the border):

  • The actual display is 192 lines in all configurations.
  • The bottom border is 57 lines at 50Hz or 33 at 60Hz on standard machines; on the Pentagon, it is slightly smaller, 49 lines. On HDMI, it is 40 lines at 50Hz or 20 at 60Hz.
  • The vertical blanking period is the time taken for the drawing line on CRT monitors to return from the bottom of the screen to the top, which is simulated on modern non-CRT monitors. It is determined entirely by video output standard: 14 lines on VGA, and 40 or 33 lines on HDMI depending on the frame rate.
  • The ULA VBLANK Interrupt is the point at which the ULA sends an interrupt to the Z80 causing it to wake from HALT instructions and run the frame service routine. On all non-HDMI machines, this happens immediately before the blanking period begins, except for Pentagon where it happens 1 line earlier. On HDMI, because of the longer blanking period, it happens during the blanking period rather than before. At 50Hz, it happens 25 lines into the blanking period, leaving 15 lines between the interrupt and the actual start of the top border (close to the 14 lines it would be on VGA output). At 60Hz, it happens 24 lines into blanking, leaving only 9 lines.
  • The top border is 49 lines at 50hz or 23 lines at 60Hz on 48k Spectrum; on 128k Spectrum, it is exactly one line shorter at both frame rates. On Pentagon, it's substantially longer, 65 lines. On HDMI, it's 40 lines at 50Hz and 17 at 60Hz.

(values in table are based on core 2.x timings, the core 3.x slightly modified some 60Hz modes, for example VGA Spectrum +3 has 264 total lines - but I don't have full set of data at this moment to edit the table, so keeping it as is, you can use my code-snippet measuring number of lines to figure out dynamically lines count of user's mode)

Machine Frame Rate Output Total output lines Display lines Bottom border lines Blanking period lines Top border lines Total non-display lines ULA interrupt timing
Spectrum 48k 50Hz VGA 312 192 57 14 49 120 1 line before blanking
Spectrum 128k, +2A, +3 50Hz VGA 311 192 57 14 48 119 1 line before blanking
Pentagon 50Hz VGA 320 192 49 14 65 128 2 lines before blanking
Spectrum 48k 60Hz VGA 262 192 33 14 23 70 1 line before blanking
Spectrum 128k, +2A, +3 60Hz VGA 261 192 33 14 22 69 1 line before blanking
Any 50Hz HDMI 312 192 40 40 40 120 25 lines into blanking
Any 60Hz HDMI 262 192 20 33 17 70 24 lines into blanking