Z ZX Spectrum Emulator

The Z ZX Spectrum Emulator allows you to load and run ZX Spectrum Basic programs on an MTX. You appear to have a ZX Spectrum with 40KB of usable memory. Not bad for 2.5KB of code.

How it works

When Z loads, it loads itself into the top 8KB of memory.

Z then loads an image of the Spectrum ROM saved in Sinclair tape format to low memory. Z didn't include a copy of the Spectrum ROM because this was (C) Sinclair Research. The idea was the customer would buy a tape with my code on it, then save their own copy of the Sinclair ROM, from their own ZX Spectrum, onto the end of it, thus neatly avoiding any licensing issue. As it turns out, Z was never sold. Nowadays, Amstrad allow the distribution of the Spectrum ROM, and many emulators do. There is also an improved replacement known as the Gosh Wonderful ROM.

Z would then patch key ZX Spectrum specific portions of the ROM with equivelent MTX code. For example, the code in the Sinclair ROM to read the Spectrum keyboard would be replaced by the code to read the MTX keyboard. I even had code to load and save Sinclair format tapes, and to print to the DMX-80 printer.

Z also includes an interrupt handler, called on a regular basis, which read ZX Spectrum screen memory and converted it and sent it to the MTX VDP chip. This handler also read the MTX keyboard and computed scan values to be given to Spectrum Basic when it reads the Spectrum keyboard.

Limitations

Games written in machine code, which don't use a recognised Sinclair ROM entrypoint to access hardware won't work properly. Z doesn't know where to patch them, and can't intercept direct port accesses to Spectrum hardware.

Z runs in IM 2 whereas a real Spectrum usually runs in IM 1. This means that if you use MEMU to take a .sna snapshot of Z the result won't work in other emulators, and vice versa. Some monkeying around with the .sna header is required.

ROM board

For fun, I made ROM board where the first ROM contained Z and the next two ROMs contained the Spectrum ROM. The Z ROM was an autoboot ROM which loaded the Spectrum ROM from the other two ROMs.

Net result: A Memotech MTX that boots directly to Spectrum Basic.

Z2

Z2 is a slightly updated version of Z, with the following changes :-

Here is the keyboard map screen :-

Z2 supports these hotkeys :-

Z will remain frozen as a record of what I built all those years ago, but Z2 will likely evolve further as I think of ways to improve it.

Use in MEMU

Z can be assembled so that rather than access real cassette tape hardware, it asks MEMU to load or save a block of data from a .tap file. This is a assembly time choice.

Z2 allows you to toggle between MEMU mode and real tape mode using F2. Of course on real hardware, MEMU isn't there to help, and on MEMU, the cassette ports aren't emulated at present.

Yes, you can run Sinclair BASIC, on virtualised MTX, on Linux or Windows.

eg:

$ cat ZXSpectrumGoshWonderful.tap program.tap > memu.tap
$ memu -s -v Z.COM
LOAD ""

eg:

$ cat program.tap > memu.tap
$ memu -s -v -mw Z2.COM
LOAD ""

Speculator

Tony Brewer made a product called the "Speculator". This was a hardware and software combination. The hardware provided memory behind Spectrum ports, and a mechanism to convert the maskable interrupt signal /INT into /NMI. The software includes loaders and an NMI handler to update the fake Spectrum keyboard from the Memotech keyboard, and Memotech VDP from the Spectrum screen.

REMEMOrizer now includes Speculator hardware, and includes a program called REZSPEC, based upon Z2, which exploits it. This can not only load and run Spectrum BASIC programs, it can also run many games which make direct access to Spectrum hardware.

Package

The Z package includes :-

Download

Z can be downloaded from http://www.nyangau.org/z/z.zip.

Copying of this program is encouraged, as it is fully public domain. Even the source code is included in the package. It was created on the authors time and equipment. Caveat Emptor.

The author of Z and this documentation is Andy Key (email andy.z.key@googlemail.com).

{{{ Andy