Tutorial

How to build your own emulator with the SPECTRUSTY library.

This project is maintained by royaltm

SPECTRUSTY Tutorial

Sinclair ZX Spectrum is an 8-bit computer that consists of a Central Processing Unit, a clock, some memory, and a custom Sinclair Uncommitted Logic Array (ULA) chip. The chip is responsible for I/O with peripherals such as the keyboard and for generating audio and video output. ULA also generates interrupts. When it needs to read pixel data from video memory, it can pause the clock when the CPU is accessing the same part of RAM (memory contention). Moreover, the raw address, data, and control lines of Z80 CPU (in SPECTRUSTY called “the BUS”) are being exposed to allow external devices to be attached.

Intro 1 Intro 2 Intro 3

S P E C T R U S T Y

SPECTRUSTY is a set of components designed in a way that mimics Spectrum’s hardware parts and peripherals. The components are structs and enums that are often having generic types in their definitions. Every such a generic stand-in needs to be substituted by the concrete sub-component. Functions of components are realized via Rust’s trait system.

In SPECTRUSTY, the base part of the emulated computer is its control chip (e.g. Ula or Ula128). Here is the list of the most important traits:

Other notable traits for peripherals, such as printers, joysticks, serial ports, sound chipsets, microdrives e.t.c. are:

Prerequisites

You’ll need the Rust language compiler with the Cargo package manager.

Both are best served with a RUSTUP utility. If you don’t like the language scoped version managers, some Linux distributions and 3rd party packaging systems also provide appropriate Rust and Cargo packages.

To check if you can continue, you should be able to run the cargo utility by creating a new repository for your emulator program:

cargo new my-spectrum-emu

If you see a message:

Created binary (application) `my-spectrum-emu` package

then you are good to go.

Tutorial steps

ZX Spectrum keyboard layout

Licensing

This tutorial and example sources in this repository are free to use under the terms of the Blue Oak Model License 1.0.0. See: https://blueoakcouncil.org/license/1.0.0.