INSIDE ZIMUL80R / HOW IT WORKS

Chip by chip, the way they were built.

A computer from 1977 isn’t one thing. It’s a processor, a handful of support chips and some clever wiring, and each part has habits that the software of the day came to rely on. Zimul80r rebuilds those parts one at a time and wires them together the way each machine did. These notes describe how that’s done, how far it can be trusted, and where it still falls short.

One emulator, many machines

Zimul80r runs 25 machines, from Intel’s 1974 development system to the home computers of the mid-80s. It began with the Tatung Einstein and grew one machine at a time, and each new machine adds whichever chips it needs to a shared box of parts. The Sord M5, the ColecoVision and the MSX share a video chip, so fixing a fault in it fixes all three. It’s written in C# for modern .NET, with downloads for Windows, Linux and macOS.

Every chip keeps time in processor cycles. A machine runs its processor one instruction at a time and lets each chip catch up by the same number of cycles. That simple rule is why the timing-sensitive tricks of the period, such as raster effects, tape loaders and border stripes, come out right.

The processors

Four processor cores sit at the heart of it, and each has been checked against the test suites that people who know these chips use to catch emulators out.

The Zilog Z80 passes all of zexdoc and zexall, the exhaustive exercisers that check every instruction’s result and flags against real hardware. That includes the undocumented flag bits, the hidden MEMPTR register and the oddities of SCF and CCF. The full run takes a minute and a half, which works out at the equivalent of a Z80 running at around 500 MHz. On the Spectrum it times each memory and I/O cycle of every instruction separately, so the ULA can hold it up exactly when the real one did.

The Intel 8080 is its own core, not a Z80 pretending. It passes 8080EXM, whose checksums come from a real 8080, as well as TST8080, 8080PRE and Supersoft’s CPUTEST, which identifies it correctly as an 8080. It keeps the 8080’s own flag rules: parity rather than overflow, its peculiar half-carry for subtraction, and the fixed bits.

The MOS 6502 makes every bus access the real chip makes, one per clock cycle and in the same order, including the dummy reads and writes most emulators skip. Cycle counts are therefore exact by construction. It passes Klaus Dormann’s functional tests and every case of Tom Harte’s per-cycle SingleStepTests checked, all 256 opcodes, undocumented ones and decimal mode included. The 65C02 variant differs only where that test data disagrees with WDC’s own documentation.

The Intel 8086 is waiting for its machine, the CPT Phoenix. It already passes all 646,000 cases of the SingleStepTests suite, which were captured from a real 80C86A, undocumented opcodes included.

The chips around them

The processor is rarely what gives a machine its character. That comes from the chips around it. These are the shared ones and some of the machines that use them.

Video

TMS9918A family
The Texas Instruments video chip with sprites: TMS9918A, 9928A, 9929A and 9129.EINSTEIN, MSX, MEMOTECH, SORD M5, COLECOVISION
Yamaha V9938
Its big successor, with 128K of video memory and bitmap modes.MSX2, EINSTEIN 256
6845 CRTC and Gate Array
Motorola’s display controller, with Amstrad’s custom chip for the colours.AMSTRAD CPC
ULAs
Each machine’s own custom chip, drawing the screen and sharing the bus with the processor.ZX SPECTRUM, ORIC
VIC-I and VIC-II
Commodore’s video chips; the VIC-II brings sprites and raster interrupts.VIC-20, COMMODORE 64

Sound

AY-3-8910
General Instrument’s three-voice sound chip, also used for keyboards and joysticks.AMSTRAD CPC, SPECTRUM 128, MSX, ORIC
SN76489
TI’s three tones and noise.MEMOTECH, SORD M5, COLECOVISION
SID 6581
The Commodore 64’s synthesiser on a chip.COMMODORE 64
Konami SCC
Five more voices, inside some MSX game cartridges.MSX
Speakers and beepers
One bit at a time, as the hardware drove them.SPECTRUM, JUPITER ACE, PET, H8, SOL-20 MUSIC

Timers, ports and interrupts

Z80 CTC and PIO
Counter-timers and parallel ports, chained to give the Z80 its prioritised interrupts.EINSTEIN, MEMOTECH, SORD M5 AMONG OTHERS
8255 PPI
Intel’s parallel interface, usually reading the keyboard.MSX, AMSTRAD CPC
Serial chips
The 8251, the INS8250 and their kin, for terminals, printers and tapes.IMSAI, ALTAIR, H8, H89
6520 PIA, 6522 VIA, 6526 CIA
The 6502 world’s interface chips, with their timers and handshakes.PET, VIC-20, ORIC, COMMODORE 64
8253 and 8257
Intel’s timers and DMA controller.CPT WORD PROCESSORS

Disk controllers

WD1770, FD1771, FD1791, FD1793
Western Digital’s floppy controllers, from single to double density.EINSTEIN, IMSAI, KAYPRO, CPT
uPD765
NEC’s controller, as used in the Amstrads.AMSTRAD CPC, SPECTRUM +3
Boards of their own
Controllers built from discrete logic, each emulated from its documentation.ALTAIR 88-DCDD, DISK JOCKEY 2D, NORTH STAR MDS-A-D, HEATH H-17

Interrupts on the Z80 machines run through a model of Zilog’s daisy chain, where each chip passes priority to the next and a RETI instruction releases the one being served. It sounds like a detail, but it isn’t: a mistake there recently left the Sord M5’s keyboard dead after one keypress, and fixing it put right every machine with those chips.

Disks, tapes and paper

Old software survives in a tangle of file formats, and Zimul80r reads most of them: raw disk images, CPC and +3 .dsk, ImageDisk, Teledisk, TRS-80 JV1, JV3 and DMK, Heath .h8d, Solace’s North Star disks and tapes, Spectrum TAP and TZX, Commodore PRG, and plain WAV and MP3 recordings of real cassettes.

Disks are writable wherever the format allows. ImageDisk files are saved back with each track’s density and sector order intact, and the previous file is kept as a .bak. Teledisk images stay read-only. Disks in the IMSAI, Kaypro and TRS-80 drives can be exported as ImageDisk to take them to a real drive or a floppy emulator, and blank disks for many of the machines are ready to use without formatting. Every machine with drives also reads and writes the universal disk image, Zimul80r’s own open format.

Tapes come in two speeds. Where it can, Zimul80r answers the computer’s own tape routines straight from the file, so a TRS-80 or Spectrum program loads in an instant. Where a program uses its own loader, the tape plays in real time into the cassette input, sound and all, and warp speed is there for the wait. The Apple-1, the Oric, the Memotech and the IMSAI’s MIO card load real recordings this way, and the MIO will even take a cassette played into a sound card.

The earliest machines used paper. The Intellec 8 and the IMSAI’s Teletype read and punch paper tape, and the printers on the H8, H89 and IMSAI print into text files you can keep.

Front panels

The Altair, the IMSAI, the Intellec 8 and the Heathkit H8 were built to be programmed at their front panels, with switches or a keypad and rows of lights. Each panel is drawn from the machine’s own manuals and works: you can stop the processor, toggle in a program, single-step it and watch the lights. The pictures on their pages show the panel above the screen, both taken from the same running machine.

The workbench

Every machine can be paused and examined. The debugger (Shift+F12) disassembles around the program counter and shows the registers and an editable view of memory. It sets breakpoints, memory watchpoints and port breakpoints, steps over and into calls, and records the last 200,000 instructions. It reads symbol files, so a listing’s labels appear in place of bare addresses. Reading a chip’s registers in the debugger doesn’t disturb it: a waiting keypress or a tape stays where it was.

Snapshots save the whole machine at any moment, every chip included, and bring it back exactly. Page Up and Page Down give a quick save and load.

What had to be rebuilt

Some of these machines have lost pieces over the years, and putting them back is archive work in its own right.

  • The Disk Jockey 2D’s firmware for the IMSAI circulates with one data line stuck. It was rebuilt from a clean copy of the same program assembled for another address, checked bit by bit against the damaged one.
  • The CPT word processors were rebuilt from CPT’s 1979 program listings and its system disks. Since then one of the CPT 8000’s original programmers has sent its autoload PROM, which the 8000, 8100 and 8800 now run, and CPT’s own character design pages, read off their disk to give the screen its real font.
  • The Intellec 8’s console follows Intel’s operator’s manual, switch by switch.
  • The Heathkit H8 and H89 follow Heath’s manuals and the PAM-8 listing. The one thing missing is the H19 terminal’s character ROM, so its graphics symbols are drawn as close approximations.
  • The PET 2001’s keyboard is laid out from the key table inside its own ROM.

What isn’t there yet

An honest list. The Commodore machines don’t yet have their tape decks or disk drives, so PET, VIC-20 and C64 software comes in as quick-load programs. The Memotech’s disk systems, the Sord M5’s tapes and disks and TRS-80 Level I tapes are missing too. Some early MSX1 disk games won’t run under MSX-DOS2. And a machine runs only the software its ROMs allow: the PET 2001 has its original BASIC 1, so programs written for later PETs won’t run, just as they wouldn’t on the real one.