ZX Spectrum Color Palette

Retrojen Wiki sitesinden
01.01, 18 Eylül 2026 tarihinde Ref (mesaj | katkılar) tarafından oluşturulmuş 211 numaralı sürüm ("This specific calculations derrived from Chris Smith's "The ZX Spectrum ULA: How to design a microcomputer" book by Ref. == UlaBook: a circuit-derived RGB palette == The '''UlaBook''' palette is an approximate 16-entry RGB palette derived from the analogue Y, U and V circuit calculations in Chris Smith's ''The ZX Spectrum ULA: How to Design a Microcomputer''.<ref name="smith">Chris Smith, ''The ZX Spectrum ULA: How to Design a Microcomputer'', ZX Design..." içeriğiyle yeni sayfa oluşturdu)
(fark) ← Önceki sürüm | Güncel sürüm (fark) | Sonraki sürüm → (fark)
Gezinti kısmına atla Arama kısmına atla

This specific calculations derrived from Chris Smith's "The ZX Spectrum ULA: How to design a microcomputer" book by Ref.

UlaBook: a circuit-derived RGB palette

The UlaBook palette is an approximate 16-entry RGB palette derived from the analogue Y, U and V circuit calculations in Chris Smith's The ZX Spectrum ULA: How to Design a Microcomputer.<ref name="smith">Chris Smith, The ZX Spectrum ULA: How to Design a Microcomputer, ZX Design and Media, 2010, ISBN 978-0-9565071-0-5. See "ULA Analogue YUV Generation", printed pp. 178–200. Bibliographic record.</ref>

The RGB values below are a derived model, not a palette published by Smith, measurements of a Spectrum's displayed colours, or a uniquely determined hardware-accurate palette. The book supplies the circuit calculations and output voltages; the neutral-axis calibration, matrix inversion and 8-bit normalization described here are additional choices made for this palette. The name "UlaBook" identifies this particular reconstruction.

Source data

The calculation uses the following parts of Smith's analysis:

  • Luminance: the normal and highlight /Y output voltages in Table 16-1, pp. 185–186, together with the luminance circuit analysis on pp. 181–187.
  • Chrominance U: the circuit and current calculations on pp. 188–191, and the U output-voltage column in Table 16-2, p. 191.
  • Chrominance V: the circuit and current calculations on pp. 192–194, and the non-inverted V output-voltage entries in Table 16-3, pp. 194–195.
  • Signal selection: the black-to-white input mapping and PAL line-dependent V inversion described on pp. 196–200.<ref name="smith" />

There is an apparent inconsistency in Table 16-2: its colour-current columns contain 0.178, 0.348 and 0.090 mA, whereas the preceding U circuit calculations give 0.216, 0.431 and 0.652 mA. This reconstruction uses the U currents from the equations and the output voltages from the table. It does not treat the inconsistent current columns as U circuit parameters.

Black and white references

The ULA produces inverted luminance, /Y: increasing picture brightness lowers its output voltage. Table 16-1 gives:

  • Black: 2.449 V.
  • Normal white: 0.539 V.
  • Highlight white: 0.259 V.

The corresponding black-referenced picture amplitudes are therefore:

Normal white amplitude    = 2.449 - 0.539 = 1.910 V
Highlight white amplitude = 2.449 - 0.259 = 2.190 V

The 2.190 V figure is a black-to-highlight-white swing, not an absolute output voltage. Smith's highlight calculation includes Q3 saturation, limiting the voltage drop across R2 to 4.041 V and leaving a /Y output of 0.259 V.<ref name="smith" /> With highlight white assigned RGB (255,255,255), normal white becomes:

255 * 1.910 / 2.190 = 222.397... -> (222,222,222)

For chrominance, the model uses the tabulated white/black output levels as separate neutral references: 2.016 V for U and 1.925 V for non-inverted V. These are ULA output references, not the bias voltage at the downstream LM1889 modulator.

Constructing the conversion matrix

The model constructs a matrix whose columns correspond to enabled red, green and blue inputs. Its rows describe black-referenced luminance and sign-corrected chrominance voltage changes. This is a circuit-calibrated inverse model, not a direct application of a standard YUV-to-RGB matrix to raw voltages.

For Y, the normal primary-colour excursions from black are:

y0 = [2.449 - 1.896, 2.449 - 1.370, 2.449 - 2.169]
   = [0.553, 1.079, 0.280] V

Their sum is 1.912 V, slightly different from the tabulated normal-white excursion of 1.910 V. The model rescales this row to sum to 1.910 V:

y = y0 * (1.910 / 1.912)

For U, the calculated colour currents are 0.216, 0.431 and 0.652 mA, and R2 is 1550 ohms. Red and green use inverted control inputs. For the sign convention U_reference minus U_output, this gives:

u0 = [-0.216, -0.431, +0.652] * 1.55

  = [-0.334800, -0.668050, +1.010600] V

For V, the calculated currents are 0.457, 0.383 and 0.078 mA, and R2 is 3100 ohms. Green and blue use inverted control inputs. For V_reference minus V_output:

v0 = [+0.457, -0.383, -0.078] * 3.10

  = [+1.416700, -1.187300, -0.241800] V

The factors 1.55 and 3.10 convert the listed milliamp currents to voltage drops across the respective resistors. The raw chrominance rows do not sum exactly to zero. To make equal RGB inputs lie on a neutral axis, this model subtracts each row's mean from all three coefficients:

u = u0 - sum(u0)/3
v = v0 - sum(v0)/3

This equal-distribution correction is a modelling choice, not a correction specified by Smith. It is not evidence that all deviations in the source are merely rounding errors. Other choices of decoder calibration or chrominance gain can produce different RGB values. The resulting matrix is:

A = [[ 0.552421548117,  1.077871338912,  0.279707112971],
     [-0.337383333333, -0.670633333333,  1.008016666667],
     [ 1.420833333333, -1.183166666667, -0.237666666667]]

For each colour, form a column vector from the tabulated ULA output voltages:

d = [2.449 - Y_output,

    2.016 - U_output,
    1.925 - V_output]

RGB_raw = inverse(A) * d * (255 * 1.910 / 2.190) RGB_8bit = round(clamp(RGB_raw, 0, 255))

Here Y_output denotes the inverted /Y voltage printed in the book. Clamping and rounding are applied independently to each channel. The non-inverted V entries are used consistently; the inverted-line entries must not be substituted without also changing the polarity and reference handling.

Input voltages and highlight behaviour

The following lists contain the source output voltages, in the order black, blue, red, magenta, green, cyan, yellow, white:

Normal /Y:
2.449, 2.169, 1.896, 1.617, 1.370, 1.091, 0.818, 0.539

Highlight /Y:
2.449, 2.082, 1.724, 1.356, 1.033, 0.666, 0.308, 0.259

U, both brightness modes:
2.016, 1.013, 2.358, 1.347, 2.692, 1.681, 3.027, 2.016

V, both brightness modes, non-inverted line:
1.925, 2.153, 0.495, 0.737, 3.099, 3.341, 1.684, 1.925

In the circuits described by Smith, highlight changes Y without changing the colour's U and V outputs.<ref name="smith" /> Because the calibrated matrix has a neutral axis, an increase in Y with unchanged U and V adds the same amount to all three reconstructed RGB channels before clipping. This explains why the highlight entries below can have non-zero values in channels that are nearly zero at normal brightness.

Some reconstructed highlight components exceed 255. For example, highlight green is approximately (40.41,261.50,38.36) before clipping. Highlight cyan and highlight yellow also require clipping. Assigning highlight white to 255 therefore does not preserve every analogue excursion within the available 8-bit range.

Interpretation and limitations

No additional gamma encoding or decoding is applied. The result is a signal-domain palette; it is not a colorimetrically characterized sRGB conversion. The calculation does not model the complete downstream composite-video circuit, the LM1889's gain and bias behaviour, a television decoder, CRT transfer characteristics, or display primaries.

Small residual components and differences of a few code values between nominally equal channels arise from the source voltages and this calibration. They should not be interpreted as precisely measured colour casts. The palette is reproducible under the stated assumptions, but is not a claim that these are the uniquely correct RGB values of every ZX Spectrum.

References

<references />

Resulting 16-entry palette

Indices 0–7 use normal brightness; indices 8–15 use highlight (BRIGHT). Both black entries are identical. Values are rounded, clipped 8-bit channel values.

Index Colour R G B
0 Black 0 0 0
1 Blue 1 0 221
2 Red 224 0 0
3 Magenta 223 0 222
4 Green 1 222 0
5 Cyan 1 222 222
6 Yellow 223 222 0
7 White 222 222 222
8 Highlight black 0 0 0
9 Highlight blue 11 10 232
10 Highlight red 244 20 19
11 Highlight magenta 253 30 252
12 Highlight green 40 255 38
13 Highlight cyan 50 255 255
14 Highlight yellow 255 255 59
15 Highlight white 255 255 255

note: Calculations made by an ai agent.