﻿WHAT IS ULAPLUS?
ULAplus is the standard for enhanced colour on the ZX Spectrum, increasing the
total palette to 256 colours. It is available as a plug-in replacement ULA or
external HDMI interface for original hardware. It is also supported in clones
and emulation.

HOW DID ULAPLUS COME ABOUT?
ULAplus was conceived as part of the ZX Spectrum SE project in 1999 on Usenet’s
comp.sys.sinclair. When Chris Smith reimplemented the ULA, having reverse
engineered it for his book "How to Create a Microcomputer", he realized there
was room to implement palette support. A small group of enthusiasts collaborated
on Google Wave to create the standard and ensure it was as simple, powerful and
compatible as possible.

HOW IS ULAPLUS LICENCED?
ULAplus is a royalty-free open format. The official specification is released
under the Creative Commons Attribution-Share Alike License. ULAplus is a
trademark of Chloe Corporation. A license is required for commercial use of the
trademark, but not to implement the mode.

HOW DOES THIS DIFFER FROM OTHER PALETTE SYSTEMS?
The most popular alternative to ULAplus has only 21 titles available. Every
single title ever released for the ZX Spectrum (around 20,000 titles) can make
use of a palette file without any need to modify the original program.

WHICH EMULATORS SUPPORT ULAPLUS?
Almost all of them.

DOES SWITCHING ON ULAPLUS GIVE GAMES MORE COLOURS?
Not by magic. Unless the game has been created or modified to use ULAplus, you
need to load a palette file first.

HOW DO I USE PALETTE FILES?
To get the full 64 colours on screen a certain amount of hacking is required as
most games do not use the FLASH and BRIGHT bits. However, up to around 32
colours are possible with no hacking at all. Simply load a palette file then
load the game. In certain emulators you may need to switch-off auto-load to
prevent the machine being reset.
 
HOW DO I RECOLOUR A GAME?
A palette editor is available to enable you to create your own palettes. Spud
and ZXSpin also have built-in palette editors. The palette format is a BASIC
file with an embedded machine code routine and the colour data. Just load the
palette then load the game.

CAN I USE IT FROM BASIC?
Yes. Guesser has kindly produced a guide to using the mode in BASIC. If you're
interested in the dark art of custom ROMs, you can install the SE Basic ROM
which provides a default palette and a PALETTE command to switch the mode on and
off and set the colours. The Derby++ ROM set also sets a default palette and
provides a PALETTE command in 128 BASIC. 

IS IT JUST A SIMPLE PALETTE SWAP?
Yes.

IS THERE A WAY FOR THE SPECTRUM TO AUTOMATICALLY DETECT IF ULAPLUS IS PRESENT?
Yes. Write a palette register, PAUSE 1, and then read it back. If 255 is
returned then it's a normal ULA. OUT 48955,0: OUT 65339,0: PAUSE 1: IN 65339
will return 0 if ULAplus is present. However, this is not supported by the ZXHD
interface.

DOES IT REMOVE ATTRIBUTE CLASH?
No.

DOES ULAPLUS WORK ON REAL HARDWARE?
ULAplus is designed to work on real hardware. It has been available as an FPGA
core since February 2011, and plug-in replacements have been available since
2017.

HOW FAR ADVANCED IS THE DEVELOPMENT OF THE ULAPLUS HARDWARE?
The original ULA has been replicated with 100% accuracy in a CPLD. Current
implementations are based on FPGAs.

HOW IS THE BORDER COLOUR DETERMINED?
In the standard Spectrum display it has the same value as the equivalent BRIGHT
0/FLASH 0 PAPER colour. In the Timex hi-res display it has the same value as the
equivalent BRIGHT 1/FLASH 0 PAPER colour.

DOES ULAPLUS SUPPORT MODELS BESIDES THE 48K?
In emulation all models are supported. In hardware you will need a different
version depending on your machine. The 48K ULA is the base level of support.

WHEN CAN I GET A REAL ONE TO PLUG INTO MY SPECTRUM?
Right now. SLAM+, SLAM+128 are internal replacement ULAs for those respective
models, or you can connect ZXHD externally to any model.

HOW WILL GAMES THAT MAKE ACTIVE USE OF FLASH BE AFFECTED?
FLASH doesn't work in the 64-colour mode. You get extra colours instead.

HOW DO YOU SWITCH ON THE 64-COLOUR MODE?
OUT 48955,64: OUT 65339,1.

HOW DO YOU SWITCH OFF THE 64-COLOUR MODE?
OUT 48955,64: OUT 65339,0.

WHY IS MY SCREEN BLACK?
The hardware can't set the palette registers by itself. By default the whole
palette is black. Set some colours before switching on 64-colour mode.

HOW MANY COLOURS CAN I HAVE ON SCREEN AT ONCE?
A static screen using no CPU time can have 64 colours on screen at once.
Changing the palette while the screen is drawing enables you to have 256 colours
on screen at once.

COULD SINCLAIR HAVE DONE THIS BACK IN THE DAY?
Yes, but more than one ULA would have been required and it would have been much
more complicated and therefore expensive. It would take "...gazillions of gates
and flip-flops. 64 * 8 Flip-Flop/latches for the palette storage = 512, plus a
640 2-input-nor gates for the multiplexing (4*16*8 + 16*8 ). That would take 832
matrix cells of the ULA, plus the other necessary circuitry. The 5C000 ULA had
440 matrix cells in total, so you'd need at least two ULAs of that size. This is
so impractical that external memory would have been required for the palette.
Propagation delay will have been the major issue, leading to other colour
effects similar to the two-levels-of-intensity effect and the edge-artifact with
flashing cells." -- Chris Smith.

HOW DOES ULAPLUS WORK AND HOW DO YOU GET 256 COLOURS ON SCREEN AT ONCE?
"It's not actually that complicated. Imagine there's a little imp, whose job it
is to paint whatever is in the Spectrum's memory onto your TV. He starts at the
top left of the screen, looks in the first screen memory location and discovers
which colour he should be painting the first pixel. He then moves onto the
second pixel on the first row, looks up the colour for that pixel, paints it,
and moves on and on across the first row. When he's done all that, he has a
little break, then moves onto the second row, and so on. On a normal Spectrum,
the imp's got a paintbox which has 16 colours in it, and you can't give him new
colours. The new ULA gives two new capabilities: firstly, it expands the imp's
paintbox from 16 to 64 colours, and secondly it lets the programmer change the
paintbox. The second effect is what's going on here: because the imp doesn't
draw the entire screen at once, but takes a certain amount of time to do it, you
can change his paintbox while he's in the middle of drawing the screen. If you
switch his paintbox for a different one when he's a half way down the screen,
he'll paint the lower half of the screen with different colours from the top
half, and you can then switch it back again before he paints the top half. That
gets you from 64 to 128 colours - to get to 256, you just need to switch his
paintbox when he's 1/4, 1/2 and 3/4 of the way down the screen. (The new ULA has
a limit of 256 colours it can ever display, so you can't do any better than that
)." -- Philip Kendall

HOW MANY COLOURS DO YOU GET IN A REMAPPED GAME WITHOUT HACKING?
From 17 to 32 colours in games that use BRIGHT, up to 64 for those that also use
FLASH.

WHAT ABOUT TIMINGS AND CONTENTION?
Standard ULA timings do not change. Timings for reading and writing the palette
registers are the same (and have the same contention) as reading and writing
port #FE. Don't spend hours creating wonderful colour effects using palette
updates until emulators have been updated to reflect the correct timing and
contention. SpecEmu has correct timing on all models except the Timex models.

WILL ANY SOLDERING BE REQUIRED?
No. You don’t even have to open your case if you use ZXHD.

DOES ULAPLUS CLASH WITH ANY EXISTING HARDWARE?
It clashes with the ZX Printer, MB02 and nothing else due to the use of ZXI
compliant ports. This can be partially resolved by making sure the ZX Printer is
fully decoded on port #FB, perhaps with a small hardware bridge. MB03+ is
compatible with ULAplus.

WILL THE SPECIFICATION CHANGE?
The only significant change in the specification is how the 2-bits of blue are
transformed into 3-bits. In version 1.1 the palette is now a superset of the
standard palette. In practice the change is very minor and games written for the
1.0 specification do not need updating. Any future updates will be backwards
compatible but when adding new screen modes you should not use the reserved
ports.

WILL ULAPLUS SUPPORT ANY EXTRA MODES?
ULAplus does not specify screen modes, only the palette system. The ZX-Uno’s
Radastan mode uses ULAplus palettes, but it is not part of the ULAplus
specification.

WHAT'S A CLUT?
It's an acronym for Colour Look-Up Table. ULAplus uses four separate CLUTs,
selected using the attribute bits formerly used to select BRIGHT and FLASH.

HOW WAS THE 256 COLOUR PALETTE CHOSEN?
The palette gives you half of the 9-bit RGB palette. It does this by using eight
levels for red and green but only four levels for blue. This is because the
human eye is less sensitive to the colour blue. This palette was also used in 
he MSX and Uzebox console. The full 9-bit palette was used in the Atari ST.

IS THERE SOME WAY TO ENABLE FLASH?
Use palette cycling instead.

WHY DON'T YOU USE A MORE EFFICIENT I/O SYSTEM USING THE HIGH BYTE?
Because of the limitations of the original ZX Spectrum. A lot of thought went
into ULAplus.

WHAT IS HAM256 MODE?
This is a software video mode that changes the palette while the screen is being
drawn. By restricting each of the 24 screen rows to two of the four CLUTs it is
possible to update one pair of CLUTs while the other is being displayed. This
gives a maximum of 32 colours per row and a theoretical limit of 256 colours on
screen at once. 

WHAT IS HAM8X1 MODE?
Very similar to HAM256 except using the Timex 8x1 attribute mode. The 32 colours
per row restriction still applies.

This document is licensed under the Creative Commons Attribution-Share Alike
License 3.0 (Unported), except for the quote from Philip Kendall which is
copyright (c) 2009 Philip Kendall, and the quote from Chris Smith which is
copyright (c) 2009 Chris Smith.