Skip to Content

LoRes and Radastan: Big Pixels in the ULA’s Place

A 128 × 96 screen sounds like a step backwards. The Spectrum’s own screen has four times as many dots, so why would anyone want fewer? Because on the Spectrum every 8 × 8 cell of the screen can show only two colours, and you have to draw your picture around that. On a LoRes screen, every pixel can be any of 256 colours, the whole screen fits in 12K, and it scrolls in both directions without your program copying a single byte. I would trade a few dots for that any day.

Why does that matter? Think of a game or a demo that wants colour more than detail, on a CPU that has to redraw the screen 50 times a second. Fewer, fatter pixels, each in a colour of its own, is a very good trade for it. The Next has two such modes. LoRes stores a byte per pixel. Radastan, a mode first made for the ZX-Uno, stores 4 bits per pixel: 16 colours in half the memory. Neither is a layer of its own. Switch one on, and it takes the ULA’s place, and the rest of the machine treats its picture as the ULA’s. That is why the big picture calls LoRes the understudy, and I cannot think of a better name: when it steps on stage, it wears the costume of the ULA, the veteran, stands on the veteran’s mark, and the audience, the rest of the machine, never notices the swap.

Read the big picture and colours and palettes first: everything here leans on the layers and the palettes they introduce. The ULA chapter helps when we get to the ULA’s clip window and border.

The road ahead

We start with what a LoRes pixel is, four dots of one colour, and how 128 × 96 of them cover the display area. Then we look for the bytes in bank 5, in two neat halves, and see how LoRes reads them without ever getting in the CPU’s way. Next, a byte becomes a colour through the ULA’s palette and a palette offset. Radastan comes after that, with its 16 colours in 6K and the two screens it can flip between. The key idea is the one that follows: LoRes is not a layer of its own but the ULA in disguise, with the ULA’s clip window, border and transparency. We end with scrolling by half a pixel and with what a full screen costs to redraw, which is where the whole point of the mode becomes plain.

The pictures show the Next with only the ULA layer on, at 128K/+3 timing and 50 Hz, with the ULA’s palette set so that entry i holds the colour whose RGB332 value is i. Each picture is written by a test that first checks the dots the text describes.

A pixel is four dots

You switch LoRes on with bit 7 of the Sprite and Layers System register, NextReg $15. Its screen is 128 pixels across and 96 down, and it fills the same display area as the Spectrum’s screen, 256 × 192 dots. So each LoRes pixel covers 2 dots across and 2 lines down, four dots of one colour. I like to think of it as a mosaic laid with big square stones:

A LoRes picture: 128 × 96 pixels, each any of 256 colours. It takes 12K.

Come closer, and the four-dot blocks are plain to see. Each square of the solid grid is one pixel, and so one byte in memory:

one LoRes pixel= one byte in memory= 2 dots across ×2 lines down4 dots,one colour128 × 96 pixels fillthe display areaof 256 × 192 dots
The hilltop close up. The dashed lines separate the dots; every square of the solid grid is one LoRes pixel, four dots of one colour.

Like the ULA’s screen, LoRes covers only the display area. The border around it stays the ULA’s border, as you will see in the section In the ULA’s place.

Where the bytes are

LoRes keeps its picture in bank 5, the bank that holds the Spectrum’s screen, in two halves of 6,144 bytes. The understudy, in other words, also borrows the ULA’s dressing room:

bank 5, 16K, to scaletop half: rows 0–47$4000–$57FF, 6,144 bytesnot used2Kbottom half: rows 48–95$6000–$77FF, 6,144 bytesnot used2K$4000$5800$6000$7800$8000rows 0–47rows 48–95the screen128 bytes a row,left to rightfor comparison, the same addresses in the ULA’s and the Timex modes’ screens:the ULA’s bitmapattrsthe Timex second bitmap
Where LoRes keeps its 12K, to scale. Each half sits exactly where the ULA and the Timex modes keep a bitmap.
  • The top half, rows 0–47, is at $4000–$57FF.
  • The bottom half, rows 48–95, is at $6000–$77FF.
  • Inside a half the rows are stored one after the other, 128 bytes a row, left to right. Pixel (x, y) of the top half is at $4000 + 128y + x; of the bottom half, at $6000 + 128(y − 48) + x.

Did you spot what is missing? The scrambling. Unlike the ULA’s bitmap, the next byte is the next pixel, and the next 128 bytes are the next row. If you have ever written a Spectrum plot routine, you will know why I find that a relief. The gap between the halves is where the ULA keeps its attributes, at $5800, and the two halves are exactly where the Timex modes keep their two bitmaps.

LoRes always reads bank 5, even while a 128K program shows the shadow screen in bank 7.

How LoRes reads bank 5

Bank 5 is block RAM inside the FPGA with two ports. The ULA and the tilemap share one; the CPU and LoRes share the other. LoRes reads one byte for every dot, through the CPU’s port, and the CPU always goes first. In each dot there is time for the CPU’s access and for LoRes’s, so LoRes never delays the CPU and always gets its byte. Polite, and on time: I could not ask more of a guest at the door.

The ULA keeps running underneath. It still fetches its screen through its own port, and only its picture is replaced by LoRes. So the timing of the machine, contention included, is the same with LoRes on or off. The veteran is still in the building, reading its lines in the wings; it is only the understudy you see. My advice: if your program counts on contention timing, you can switch LoRes on without recounting a thing.

From a byte to a colour

A LoRes byte is a palette index. It goes through the ULA’s palette, the first or the second one as bit 1 of the Palette Control register, NextReg $43, selects, and so any of the 256 entries can be used. The ULA’s ways of reading an attribute, ULANext and ULA+, do not apply: a LoRes byte is never an attribute. No ink, no paper, no bright, no flash. I find that refreshingly simple.

The LoRes Control register, NextReg $6A, holds a palette offset in bits 3–0. It is added to the byte’s high nibble before the lookup, as for an 8-bit Layer 2 dot: offset 1 turns byte $25 into index $35. With offset 0, the byte is the index. Radastan uses the same offset differently, as the next section shows:

LoResthe byteHHHH LLLLHHHH + offset, LLLLoffset: NextReg $6A bits 3–0Radastanthe pixel’snibble NNNNoffset, NNNNwith ULA+: 11, offset bits 1–0, NNNNthe ULA palettefirst or second: NextReg $43 bit 1the ULA layerthen NextReg $14 applies
From memory to a colour. Both modes use the ULA’s palette; only the index is made differently.

The colour then goes to the ULA layer like a ULA dot’s, and the same transparency test applies: a LoRes dot whose colour equals the Global Transparency Colour register, NextReg $14, is transparent (the palettes chapter’s Transparency and the fallback colour).

Radastan: 16 colours in 6K

Bit 5 of the LoRes Control register, NextReg $6A, switches LoRes to Radastan mode. The screen is still 128 × 96 pixels of 2 × 2 dots, but each pixel is 4 bits, so a byte holds two of them and the screen takes half the memory. Radastan is the understudy on a budget: same stage, same mark, half the wardrobe:

one byte, two pixels76543210left pixelright pixela row: 64 bytes, 128 pixels; 96 rows: 6,144 bytes… 48 more bytesbank 5display file 0: $4000–$57FFdisplay file 1: $6000–$77FFthe screen shows one of them: port $FF bit 0 XOR NextReg $6A bit 4
Radastan: two pixels a byte, half of LoRes’s memory, and room for two screens in bank 5.
  • A row is 64 bytes. The left pixel of a pair is the byte’s high nibble, the right one its low nibble.
  • The rows follow one another with no gap: 96 rows of 64 bytes, 6,144 bytes, in one block.
  • The pixel’s 4 bits are the low half of the palette index. The high half is the palette offset, NextReg $6A bits 3–0, so the offset picks which 16 entries of the ULA palette the picture uses.
  • With ULA+ switched on (the ULA Control register, NextReg $68, bit 3, or port $FF3B) and ULANext off, the high half is 11 followed by the offset’s bits 1–0, so the picture takes one of the four 16-colour groups of the ULA+ palette, entries 192–255.

Sixteen colours sound like a sacrifice after 256. But be honest: how many colours does your picture really use? Rarely more than a few dozen, if you ask me. Here is the same sunset in both modes, so you can judge for yourself:

LoRes: 12K, 256 colours to choose fromRadastan: 6K, 16 colours
The same picture in both modes. Radastan keeps the 16 most common colours of the LoRes picture; the glow and the sea lose their finest steps.

Two Radastan screens

A Radastan screen takes 6K, so bank 5 holds two, at $4000 and at $6000: display file 0 and display file 1. Which one is shown is decided by bit 0 of the Timex control port, port $FF, the same bit that picks the Timex modes’ second display file, exclusive-or’ed with bit 4 of the LoRes Control register, NextReg $6A.

That makes double buffering simple. Draw the next picture into the screen that is not shown, then flip one bit, and the new picture is there at once. The XOR bit is there so that your program can keep port $FF set the way other code expects, and still choose either screen. I like that kind of courtesy in a design: it lets your code change the picture without stepping on anyone else’s toes.

Plain LoRes does not look at port $FF: its two halves are one screen, and the Timex mode does not move them.

In the ULA’s place

If you read only one section, read this one. LoRes is not a sixth layer. When bit 7 of the Sprite and Layers System register, NextReg $15, is set, LoRes’s dot replaces the ULA’s on its way into the ULA layer, and from then on the machine cannot tell the two apart. This is the understudy’s whole act: the ULA’s costume, the ULA’s mark on the stage, the ULA’s cues.

  • The clip window. LoRes has no clip window of its own; it uses the ULA’s, the Clip Window ULA register, NextReg $1A, in display-area coordinates. Outside the window the ULA layer is transparent, and whatever is below shows through.
  • The border is the ULA’s: LoRes covers only the display area, and the border around it keeps the colour port $FE gives it.
  • Transparency: the Global Transparency Colour register, NextReg $14, applies to LoRes colours as to ULA colours, as the section From a byte to a colour says.
  • Switching off: bit 7 of the ULA Control register, NextReg $68, which switches the ULA off, switches LoRes off with it.
  • Layer order, stencil and blending treat the LoRes picture as the ULA’s (putting it together).

I think this is the neatest decision in the mode. Every rule you already know about the ULA layer holds for LoRes, so there is nothing new to learn about where it sits among the layers. Let’s see it on the machine, with the clip window set to dots 32–223 across and lines 24–167 down:

LoRes in the ULA’s place: clipped by the ULA’s clip window (grey: transparent, the fallback colour shows through), inside the ULA’s border.

The grey is the Fallback Colour register, NextReg $4A, which shows where no layer is opaque: between the clip window and the edge of the display area, the ULA layer is transparent. Around it the border is the ULA’s, here colour 7 of port $FE.

Scrolling by half a pixel

LoRes has its own scroll registers: the LoRes X Scroll register, NextReg $32, 0–255, and the LoRes Y Scroll register, NextReg $33, 0–191. They count in dots and lines, not in LoRes pixels, so one step is half a pixel, and a scroll moves smoothly. The picture wraps round at 256 dots across and 192 lines down: what leaves on one side comes back on the other, and your program never copies a byte to scroll. I am a big fan of this. Fat pixels usually mean jerky scrolling, and here they do not.

not scrolledNextReg $32 = 101, NextReg $33 = 75
Scrolling. The picture moves by dots, half a LoRes pixel a step, and wraps round at 256 × 192 in both directions.

With an odd X scroll, the 2 × 2 blocks no longer line up with the even dots: each pixel’s two dots across land half in one block of the screen and half in the next. And the two kinds of scroll keep to themselves: the ULA’s own scroll registers do not move LoRes, and LoRes’s do not move the ULA. On this one point, the understudy keeps its own script.

What a screen costs

Now, why bother with a mode like this at all? Memory and time. A program that redraws the whole screen every frame has to copy every byte of it, and at the Spectrum’s 3.5 MHz the Z80’s fastest copy, LDIR, takes 21 T-states a byte. A 128K frame is 70,908 T-states:

bytes for a full screen, and frames at 3.5 MHz to copy them with LDIRULA2 colours per8 × 8 cell6,912 bytes · 2.0 framesRadastan16 colours6,144 bytes · 1.8 framesLoRes256 colours12,288 bytes · 3.6 framesLayer 2, 256 × 192256 colours49,152 bytes · 14.6 framesLayer 2, 320 × 256256 colours81,920 bytes · 24.3 frames
What a full screen costs. LoRes gives every dot-block its own colour for less than twice the ULA’s memory and a quarter of Layer 2’s.

LoRes gives every 2 × 2 block its own colour, out of 256, for less than twice the ULA’s memory, and a full LoRes screen copies in under four frames at 3.5 MHz. Layer 2 at 256 × 192 has four times the dots, and needs four times the memory, more than 14 frames to copy at that speed. Radastan halves LoRes again: a 16-colour screen smaller than the ULA’s own.

The Next can run its CPU at up to 28 MHz, which cuts every copy time. The proportions between the modes stay the same. That is why I keep coming back to LoRes when colour matters more than detail: whatever the speed, it is the cheapest way to fill the screen with colour.

What to take home

Let me gather it all up. LoRes, switched on by NextReg $15 bit 7, draws 128 × 96 pixels of 2 × 2 dots across the display area, a byte per pixel, any of 256 colours, in 12K. The bytes sit in bank 5 in rows of 128 bytes, the top half at $4000–$57FF and the bottom half at $6000–$77FF, with nothing scrambled. LoRes reads a byte per dot through the CPU’s port of bank 5, and never delays the CPU.

A LoRes byte is an index into the ULA’s palette, and NextReg $6A bits 3–0 add a palette offset to its high nibble. Radastan, NextReg $6A bit 5, stores two pixels a byte: 16 colours in 6K, with the offset as the index’s high nibble, or 11 and the offset’s bits 1–0 with ULA+. Bank 5 holds two Radastan screens, and port $FF bit 0 XOR NextReg $6A bit 4 chooses the one you see.

Both modes take the ULA’s place, the understudy in the ULA’s costume: the ULA’s clip window, border, transparency test, switch and position among the layers. NextReg $32 and $33 scroll them by dots, half a pixel a step, wrapping at 256 × 192. Fat pixels, lots of colour, little memory: not a bad deal for a screen that looks like a step backwards.

Last updated on