A field guide · Cambridge to São Paulo

The Spectrum story

A computer built to a price by a man who cared more about electric cars, sold in its millions, coloured in 8×8 squares, and copied chip for chip in Brazil. It is the machine K-Prompt emulates, along with Microdigital's TK90X and TK95.

  1. Sir Clive
  2. Built to be cheap
  3. Ferranti and the ULA
  4. Colour clash
  5. Bedroom coders and the fans
  6. Brazil: Microdigital's TK90X and TK95
  7. The TK90X and the 48K, side by side
  8. America: Timex Sinclair
  9. How K-Prompt emulates the ULA
  10. The siblings
  11. Sources
1972Sinclair Executive pocket calculator
Feb 1980ZX80, £99.95 built
1981ZX81; Microdigital founded in São Paulo
23 Apr 1982ZX Spectrum: £125 (16K), £175 (48K)
1983Clive Sinclair knighted; Sinclair loses its case against Microdigital
Nov 1983Timex Sinclair 2068 in the US
Dec 1984The scuffle at the Baron of Beef
10 Jan 1985Sinclair C5
Jun 1985Microdigital TK90X
7 Apr 1986Amstrad buys the Sinclair computers, £5 million
1986TK95
2010Chris Smith's book on the ULA; TBBlue starts in Brazil
2017ZX Spectrum Next on Kickstarter

1Sir Clive

Clive Sinclair (1940–2021) left school at 18 and sold miniature electronics kits to hobbyists by post. His company, Sinclair Radionics, made the Sinclair Executive in 1972, "the world's first slimline electronic pocket calculator", and then the Black Watch, a digital watch that was inaccurate and hard to service.

Computers came next and sold by the hundred thousand. The ZX80 (1980) cost £99.95 built. The ZX81 cost £69.95 built, or £49.95 as a kit, and sold more than 1.5 million. The Spectrum (1982) sold over five million. He was knighted in 1983 "for his contributions to the personal computer industry", and he chaired Mensa from 1980 to 1997.

His heart was elsewhere. Jimmy Maher writes that he "really didn't know that much about computers, nor did he care all that much about them". The computers paid for his pocket televisions and his electric vehicle. The C5, a one-seat electric tricycle with a top speed of 15 mph, was launched on 10 January 1985 at a snowy Alexandra Palace, built by Hoover in a washing-machine factory, and was in receivership by October. About 14,000 were made, and sources disagree on how few were sold. The QL, unveiled in January 1984, was promised within 28 days before a working one existed.

On 7 April 1986 Sinclair Research sold its computers and the Sinclair name to Amstrad for £5 million. Sir Clive went on with folding bikes (the A-bike), an electric car that never shipped (the X-1), televised poker, and in 2014 a warning that thinking machines would make it "very difficult for us to survive". In 2010 he said he did not use computers.

2Built to be cheap

The Spectrum was launched on 23 April 1982 at £125 for 16K and £175 for 48K, cut to £99 and £129 the next year. A Commodore 64 or a BBC Model B cost over £300. Everything about it served that price.

One custom chipRichard Altwasser put the video, keyboard, sound and tape logic into a single Ferranti ULA (chapter 3). Beside it: a Z80A at 3.5 MHz, a 16K ROM, the RAM, and very little else.
Half-bad memoryThe 48K's upper 32K is eight 64K chips with one faulty half, sold cheaply as 32K parts (TI TMS4532, OKI MSM3732). A link on the board picks which half works; all eight must agree.
Rubber keys40 rubber keys over a membrane, likened to "dead flesh". One reviewer wrote that "you need to squeeze the keys rather than press them". Hard keys only came with the Spectrum+ in 1984.
Keywords on the keysSteve Vickers's 16K ROM holds a whole BASIC. Each keyword is one keypress and one byte (P is PRINT), which saved memory and typing; the cursor's K means "a keyword comes next".
A beeperNo sound chip: one bit of port FEh drives a small speaker, and the CPU makes every sound by toggling it at the right moments. The manual promised ten octaves.
Your TV and your tapeThe picture went to a home TV through an RF lead and programs to an ordinary cassette recorder, at about 1,500 baud.
The rainbowRick Dickinson's black case, with a rainbow stripe across one corner. Thirty-five years later he designed the Next's case too.
Made by TimexThe machines were assembled by Timex in Dundee, which also led to the American Timex Sinclairs (chapter 8).

Altwasser and Vickers left soon after the launch to found Jupiter Cantab, whose Jupiter Ace ran Forth instead of BASIC. One name suggested for the Spectrum was "Not the BBC Micro".

3Ferranti and the ULA

A ULA, an uncommitted logic array, is a gate array. The chip is made in advance with transistors that do nothing yet, and a customer's design is added as the final metal wiring layers. That is far cheaper than a fully custom chip. Ferranti, the British electronics firm, pioneered bipolar ULAs. Its first notable customer was a Rollei camera in 1972, and its arrays went into the ZX81, the Spectrum, the BBC Micro and the Acorn Electron.

The Spectrum's ULA does almost everything that is not the CPU. It reads the screen from RAM and turns it into a TV picture, 50 times a second. It raises the Z80's interrupt at the start of each frame. On I/O port FEh it reads the keyboard, sets the border colour, drives the beeper, and reads and writes the cassette.

The screen RAM is shared. While the ULA reads it, a CPU access to 4000h–7FFFh has to wait, in the pattern 6, 5, 4, 3, 2, 1, 0, 0 T-states repeating every 8 T-states across each line of the picture. This is "contention", and programs that count cycles (border effects, multicolour, some loaders) depend on it. When the Z80's I register points into that memory, its refresh cycles upset the ULA's fetches and the screen fills with "snow", though the machine keeps running.

In 2010 Chris Smith published The ZX Spectrum ULA: How to Design a Microcomputer, the result of reverse-engineering the chip. Its account of the timing, such as the interrupt being held for exactly 32 T-states, is what emulators now rely on.

4Colour clash

The screen is 256×192 pixels, but colour comes in 8×8 cells. The bitmap takes 6,144 bytes, one bit per pixel. Then 768 bytes give each cell one attribute: an ink colour, a paper colour (eight each), BRIGHT, and FLASH, which swaps ink and paper every 0.64 s. Colour for every pixel would have cost several kilobytes more, on a 16K machine.

So a cell can hold two colours. When a yellow sprite walks over a green tree, the tree's cells turn yellow or the sprite turns green: "large ugly fringes of rapidly changing colours". Games answered in several ways: colour only for borders and scores around a monochrome play area; two colours for everything, as in Ultimate's Knight Lore; very careful design, as in Light Force; or monochrome sprites over coloured backgrounds, as in Double Dragon.

The bitmap's odd layout (rows in thirds, lines interleaved) was decided under time pressure. It is why Spectrum screens load from tape in that famous venetian-blind order.

5Bedroom coders and the fans

A cheap machine with BASIC in ROM and a tape recorder to sell games on started the British games industry. Matthew Smith wrote Manic Miner at 17. Tim and Chris Stamper's Ultimate Play the Game (Jetpac, Knight Lore) became Rare. Ocean in Manchester began as mail-order "Spectrum Games". The Darling brothers founded Codemasters in 1986 for budget games "with the quality of full-priced games".

Magazines carried the scene: Sinclair User (1982–93), Crash (1984–92) with Oliver Frey's painted covers, and Your Sinclair (1984–93, born as Your Spectrum), known for its jokes. Programs were printed as listings to type in, for hours, and errors were corrected in the next issue.

The fans call it the Speccy, and they never left. World of Spectrum (1995) set out to be "a completely free museum" of its software. Spectrum Computing and its open ZXDB database still add new titles, since new games are written and sold on tape every year. The playground argument with Commodore 64 owners has never quite ended.

6Brazil: Microdigital's TK90X and TK95

From 1979, Brazil reserved its computer market for national companies through the SEI, the Special Secretariat for Informatics. Lei 7.232 of October 1984 made the policy law (the same reserva de mercado that shaped Brazil's MSXs, told on Ok-Prompt's page). Foreign computers could not be imported, but they could be copied.

Microdigital Eletrônica was founded in São Paulo in 1981 by the brothers Tomas and Jorge (George) Kovari; "TK" is their initials. Its first machines copied Sinclair's: the TK80 (a ZX80), then the TK82C and TK85 (ZX81s). Those had no ULA. A dozen TTL chips did its work, so they ran warmer. In 1983 Sinclair Research sued Microdigital in Brazil for copyright infringement and lost: the court treated the ROM as part of the hardware, not as protected software. Brazil's software law only came in 1987.

The TK90X followed in June 1985: a 48K Spectrum in a slightly taller case, with 40 rubber keys, a built-in joystick port on an Atari connector, and sound through the TV instead of a speaker. It sold about 2,500 a month in late 1986. The TK95 (1986) put the same machine in a case borrowed from the Commodore Plus/4, with a 57-key keyboard. Its introductory price was Cz$ 4,559. Brazil's MSXs, the Expert and the Hotbit, overshadowed both, and Microdigital was gone by 1990.

Cloning the ULA

This time Microdigital made a chip. The TK90X's ULA, marked MC16845, is its own design. Wikipedia says it was reverse-engineered as CMOS from Ferranti's bipolar original. It fits the same socket pin for pin, with one addition: pin 1 selects 50 or 60 Hz. Former Microdigital engineer Cláudio Cassens says the "national ULA" took about a year. Who fabricated it is not known: the documentation "seems to be irretrievably lost".

It is not an exact copy. It runs from a 14.3 MHz crystal (four times Brazil's colour subcarrier), so the Z80 runs at 3.5756 MHz, and every line is 228 T-states, not 224. Brazilian TVs are PAL-M, 60 Hz, so a TK90X draws 262 lines 59.86 times a second (chapter 7). Some TK90Xs built for Argentina carry genuine Ferranti ULAs, one dated January 1985, and how Microdigital got them is a mystery.

In 2012–13 Victor Trucco and Fábio Belavenuto cloned the Microdigital ULA in a CPLD, "the component that until then was irreplaceable", and published it as open hardware.

7The TK90X and the 48K, side by side

Rows marked measured come from the original ROMs running in K-Prompt (tests/zx.test.ts). The timing comes from the Cantinho do TK90X blog's measurements of a real machine.

ZX Spectrum 48KTK90X and TK95
ROM16K, SinclairThe same 16K with 1,980 bytes changed. The TK90X and TK95 ROMs here differ only in their 20-byte banner measured
Power-on© 1982 Sinclair Research Ltd, then a clear screen"TK90X - Color Computer" or "TK Color Computer" with a colour bar. The banner stays at the top while you work measured
Reports0 OK, 0:10 Ok 0:1, in Portuguese: NEXT sem FOR, Sem memoria, Ligue o gravador, digite ENTER measured
SpanishNoneA second, Spanish copy of the messages fills the ROM's spare space ("Conecte grabador, digite ENTER"). How it is selected was not found measured
KeywordsBEEP, GO TO, GO SUB, CONTINUE, RANDOMIZESOUND, GOTO, GOSUB, CONT, RAND: the same tokens, new names measured
SYMBOL SHIFT + X£The UDG command measured
UDGUDGs start as copies of A–UUDG loads Portuguese letters into the UDGs: Á É Í Ó Ú á é í ó ú À à Â â Ê ê ô ã õ Ç ç. UDG 1 loads a set with ñ, Ñ and ü. UDG 2 opens a character editor measured
Clock3.5 MHz3.575611 MHz
Line224 T-states228 T-states
Frame312 lines, 69,888 T, 50.08 Hz262 lines, 59,736 T, 59.86 Hz (PAL-M). With pin 1 switched, 312 lines, 71,136 T, 50.26 Hz
EffectThe referenceGames timed by the interrupt run about a fifth faster, BEEP plays 2% sharp, and border and multicolour effects tuned to the 48K break

pt.wikipedia also mentions a TRACE command and gives 90–95% compatibility with the Spectrum. TRACE is not in the TK90X ROM's keyword table, so K-Prompt has not confirmed it. K-Prompt offers the TK's video as 60 Hz, 50 Hz or a Ferranti ULA.

8America: Timex Sinclair

Timex, which built Sinclair's machines in Dundee, sold them in the United States as a joint venture. The TS1000 (July 1982) was a ZX81 with 2K, "the first home computer to cost under $100", and sold about 550,000 that year. The TS1500 (1983) was a 16K ZX81 in a Spectrum-style case.

The TS2068 (November 1983, $199) was the American Spectrum, with more than a new name. It had an AY-3-8912 sound chip, two joystick ports, a cartridge slot, a 24K ROM, and an SCLD chip in place of the ULA with extra screen modes (dual screen, 512-pixel high resolution). The price of all that was compatibility: fewer than one in ten Spectrum machine-code programs ran on it. Timex left the US market in early 1984, but Timex Portugal carried on with the TC 2048 and TC 2068.

9How K-Prompt emulates the ULA

K-Prompt has no ULA chip to copy. It reproduces what the ULA does, at the moments it does it, counted in the Z80's T-states.

The frameEach frame is 69,888 T-states of Z80 time (59,736 on a TK at 60 Hz). For the first 32 the interrupt line is low, and the CPU takes it if it is listening, as on the real machine. Then the program runs until the frame is spent.
The pictureEach 8-pixel cell is read from memory at the T-state the beam reaches it, so a program that changes the screen mid-line is seen exactly where it acts. The bitmap's thirds and interleaved lines are decoded as the ULA fetches them.
The borderEvery OUT to port FEh is kept with its T-state. Each border pixel takes the colour in force when the beam passed it, so loading stripes and border effects land where they did on a TV.
FLASHInk and paper swap every 16 frames, 0.64 s on a 48K.
The keyboardReading port FEh, the high address byte picks half-rows of keys, and several half-rows AND together, so games that scan the whole keyboard at once work.
The beeperEAR and MIC changes are noted with their T-state. Each sound sample is the average level over its slice of the frame, which keeps the square waves clean.
The tapeStandard blocks are copied in at once by catching the ROM's LD-BYTES. Others play in real time as pulses on the EAR bit: the ROM, or a turbo loader, decodes them itself and the border stripes.
Not yetContention (the 6,5,4,3,2,1,0,0 delays) and the floating bus are not emulated yet. Most software does not notice; multicolour engines and some loaders do.

10The siblings

K-Prompt is the third of a family, each named after the prompt its machine waits at, and all on the same Z80 core. A-Prompt runs CP/M 2.2 and its A>. Ok-Prompt is an MSX, which answers Ok, as the TK90X does. All three have a telnet modem that dials BBSes.

Switch it on →

Sources