ZX Spectrum Next

The ZX Spectrum Next is emulated from its FPGA core: the Z80N CPU at 3.5 to 28 MHz, 1 or 2 MB of RAM, layer 2, sprites, the tilemap, LoRes, the copper, the DMA, hardware IM2 and the CTC, three AY chips with DACs, the clock and the Wi-Fi module. Like the real machine, it starts from an SD card: its firmware loads the ROMs and NextZXOS from the card’s files.

NextZXOS on the ZX Spectrum Next

The machine

Pick ZX Spectrum Next in Machine > Model or on the Machine page of Options. It has a group of its own, after the Sinclair and Amstrad models. On the command line, use -m zxnext.

The Next sets its own CPU speed, 3.5, 7, 14 or 28 MHz, as programs ask. It also sets its sound chips, joysticks, contention and the rest from NextZXOS’s settings. So the Machine page of Options shows what the machine has set, in groups of the Next’s own (see On the ZX Spectrum Next). The picture always shows at least the full border (see View menu).

The Next has three buttons on its side, RESET, DRIVE and NMI:

  • RESET: Machine > Reset or F12 presses it. This is a soft reset, which keeps the memory and the card. Soft Reset in the Reset menu does the same; on the Next it takes the place of the other machines’ choices. Hard Reset switches the Next off and on: the firmware starts again and loads everything from the card. On a real Next, holding RESET for a second gives a hard reset.

  • NMI: Machine > NMI presses it. NextZXOS stops the program and shows its NMI menu: snapshots, screenshots, pokes and the like (see NMI).

  • DRIVE: the divMMC’s NMI button. Only esxDOS uses it, when the Next boots a machine with esxDOS in place of NextZXOS. NextZXOS turns it off. Xpeccy+ boots the Next with NextZXOS only, so the menus have no DRIVE command. F10 presses it, as on the Next’s own PS/2 keyboard (see Keyboard and joysticks).

You set Memory on the Machine page of Options to 2048 KB or 1024 KB. The base model of the first Nexts had 1 MB and room for 1 MB more. Later boards all have 2 MB. A program meant for every Next should run on 1 MB: NextZXOS then has 768 KB for programs, banks 0 to 47, and the Pentagon 1024 mode reaches 768 KB. If you change Memory, the Next is switched off and on, because NextZXOS counts the memory when it starts.

On 1 MB, a write past the first megabyte is lost. A read there gets what the data bus still holds: the last byte that went over that half of the bus - an instruction, a byte the program wrote, a layer 2 pixel. This follows from how the board is wired. It has not been measured on a real 1 MB Next, where the bus may also lose its charge after a while. If layer 2 is shown from banks past the first megabyte, it shows bytes #FF.

The divMMC and the Multiface are built into the Next, so the divMMC setting of other machines is not shown for it. The Next has no floppy drives, and a tape does not start by itself on it.

The SD card

The Next starts from a card with System/Next on it: the official release of its ROMs, NextZXOS and the programs that come with it. System/Next is not part of Xpeccy+. The emulator makes a card from the official release when the Next needs one.

The ZX Spectrum Next SD Card window

The ZX Spectrum Next SD Card window opens by itself when the Next has no card to start from: the first time, or when its card was moved or deleted, or has no System/Next on it. If a card of yours without System/Next is in the slot, and the Next has no card of its own, the window opens on your card, and its first line names that card. You can open the window at any time with Media > SD Card > System/Next Card….

Field

What it sets

Path

a card you have, or where to make a new one; the button beside it picks a Folder… or an Image…

Size

for a new image, 1 to 16 GB; on the disk it takes only what is written to it

Release

the System/Next release to put on a new card

From

where the release comes from: an archive downloaded before, one beside the emulator, or gitlab.com, about 51 MB

The line under Path says what the window will do with it:

Path

The window

a folder or an image with System/Next on it

Found: Use This Card puts it in as it is

a new or empty folder

New card: Create Card makes the card in it

a new name ending in .img

New card: Create Card makes an image of the size chosen

a folder with other files

leaves it alone; a link makes the card in next-sd inside it

a file without System/Next

leaves it alone; pick another, or type a new name

Create Card downloads the release, checks it, and makes the card. By default the card is a folder, next-sd, in the settings folder. The release goes onto the card unchanged. If Xpeccy+ knows no checksum for a release, the release is marked (not checked).

The new card goes in right away, and the Next starts from it. Xpeccy+ downloads and unpacks the archive itself, with a progress bar and Cancel. On Linux the download uses the system’s libcurl, which nearly every distribution has. If a .tar.gz or a .zip is beside the emulator, no download is needed at all.

The Next’s own card. The card you make or pick in this window is the Next’s own: it goes in whenever the Next runs. If a card of yours with System/Next on it is in the slot, that card is used instead. A card without System/Next is put aside while the Next runs, the message no System/Next: the Next’s card in appears, and your card comes back for the next machine. On the Next, Media > SD Card > Eject puts its own card back.

The SD Card menu has the same items as on the ZX Evolution: Open Image…, Open Folder…, Eject, Refresh and Write Protect (see SD card). You can also set the card with the --sdcard option on the command line.

Writing. A card made here takes what NextZXOS writes, without asking. A folder of your own follows the Folder as a disk settings, and Xpeccy+ asks the first time (see Writing to a folder). An image is written to directly. A folder keeps files, not everything a card holds (see What a folder cannot do), so for full compatibility, use an image card.

The card’s config.ini and menu.ini choose the ROMs, and the timing= line of config.ini chooses the video timing, VGA 0 or VGA 1. The other settings of config.ini are not read.

Starting programs

Open .nex programs and .snx snapshots like any other file: with File > Open, by dropping them on the window, or on the command line (see File menu). They need the Next, so on another machine Xpeccy+ switches to it. On the Next, .sna snapshots of the 48K and the 128K open the same way. Snapshots of other machines switch to a machine that runs them. A .z80 names its model, so with Auto on the File types page, Xpeccy+ switches to that model. With Keep current, or with the Next picked for .z80 there, it opens on the Next too.

Xpeccy+ does not load a program into the Next’s memory directly, because the firmware would start over anything put there. Instead, Xpeccy+ types the commands on the keyboard, as you would: NextZXOS’s NextBASIC, .cd to the program’s folder, and .nexload for a .nex or SPECTRUM for a snapshot. While it types, the picture stays blank, in fast mode.

Whatever is in the slot - an image, a folder, the Next’s own card or none, write-protected or not - a program starts on a card of its own:

  • System/Next as its release has it. The first time a program starts, Xpeccy+ unpacks the release into next-system in the settings folder, from the archive that the ZX Spectrum Next SD Card window downloaded, or from one beside the emulator. Its NextZXOS settings are the release’s, not your card’s, and what NextZXOS writes there stays in memory.

  • The program’s folder, in the card’s root, with everything in it, for the files that a program reads from beside itself. What the program saves there goes into that folder on your disk. If the folder has over 2000 files and folders, or is a collection, or the program is a .sna or .z80, only the program’s file is put there, and what it writes stays in memory. A program that comes with System/Next, of any release in next-system, starts where it is on that release, and what it writes stays in memory too.

First the Next is switched off and on, so that NextZXOS starts from the new card. Your card is put aside while the program’s card is in. Media > SD Card shows Card for and the program’s name, and Eject there puts your card back. Your card also comes back when you open another card or switch machines, and the settings keep it all along. If you open an .szx snapshot saved while a program was running, the program’s card is made again.

If there is no System/Next at all, Xpeccy+ offers to download it (about 51 MB) and then starts the program. If a file or folder name has a space or letters that cannot be typed in NextZXOS, its short name is used on the card instead. If even that fails, the message is The file’s name cannot be typed in NextZXOS, and the card in the slot stays as it was, with whatever program is running from it.

Snapshots

File > Save… saves the whole Next as an .szx snapshot: its memory, the nextregs, copper, palettes, sprites, layers, DMA, the clock chip and the ESP-01. Quick Save, the autosaves, Resume Last Session and RZX recording work on it as on other machines (see Quick saves and RZX). Other programs cannot open these files: the SZX format has no ZX Spectrum Next. If you open a snapshot taken on 1 MB on a 2 MB Next, the Next runs on 1 MB, and the other way round, until you choose another machine or close Xpeccy+. Memory in Options still shows the machine’s own size. If you pick the other size there, it becomes the machine’s own.

The SD card is not in the snapshot - it is far too big - but NextZXOS keeps in memory what it read from the card. So the snapshot names the card, and the folder of a program opened from elsewhere, and loading the snapshot puts them back. If the files on the card have changed since the save - added, removed, renamed or written - a line on the screen says so, because what the program had open on the card may read wrong. A card moved or copied with its files’ dates kept counts as the same card. A snapshot that names no card - from another program, or of another machine - leaves the card in as it is. The ESP-01’s network connections are not in the snapshot either: after loading, the program finds them closed.

Keyboard and joysticks

The computer’s keyboard is the Next’s PS/2 keyboard, with the US layout of its core, or the layout the card’s keymap.bin sets. Letters, digits and the keys of the Next’s own row map as below. The PC keyboard setting of other machines is not shown for the Next.

Key

Next key

Shift

CAPS SHIFT

Ctrl

SYMBOL SHIFT

left Alt

EXTEND

right Alt

GRAPH

Esc

BREAK

Backspace

DELETE

Caps Lock

CAPS LOCK

`

EDIT

arrows

the Next’s arrow keys

; ' , .

the Next’s ; " , . keys

/ - =

SYMBOL SHIFT with V, J and L

Type PC Symbols of other machines does not apply here: Shift is CAPS SHIFT with every key, as on the Next’s own PS/2 keyboard.

Some hotkeys of Xpeccy+ use Alt too. If they get in the way, change them on the Hotkeys page of Options.

The F-keys work as on the Next’s PS/2 keyboard:

Key

On the Next

F3

switches between 50 and 60 Hz

F4

soft reset: a short press of RESET

F8

the next CPU speed: 3.5, 7, 14, 28 MHz

F9

the NMI button, when let go within a second

F10

the DRIVE button

As on the Next, if you press a digit while you hold F9 down, the digit acts as a function key instead, 1 to 0 for F1 to F10, and F9 then sends no NMI. F9 with 1 is a hard reset: the firmware starts again and the memory is kept. Machine > NMI presses and releases the button at once, so you cannot hold it with a digit. Hold F9 for that.

An F-key that is a hotkey of Xpeccy+ stays a hotkey: F3, F4, F9 and F10 are hotkeys in both presets. To give them to the Next, turn on Grab Keyboard. F8 is not a hotkey, so it changes the speed even without that. A program can turn F3 and F8 off. The Next’s other function keys change only its video output or the expansion bus, so they do nothing here.

The virtual keyboard has three Next skins: Next (Black), Next (White) and Next (Magenta). With By machine on, the Next gets the skin of the tone you picked last (see Virtual Keyboard). Its arrows, EDIT, DELETE and the other keys of the Next’s own row press those keys, not a key with a shift.

The Next has two joystick ports. Its firmware sets the left one to Kempston 1 and the right one to Sinclair 1. A program may change them. Player 1’s gamepad is the left joystick, and the mouse is the Next’s Kempston mouse, with its wheel (see Input menu).

Wi-Fi and serial ports

The Next has two UARTs: one to the ESP-01 Wi-Fi module, one to the Raspberry Pi’s connector. The ESP UART and Pi UART rows on the Machine page of Options set what is on each UART. They are shown only for the Next (see Machine page).

Choice

Meaning

Not connected

nothing on that UART

ESP-01 (emulated)

ESP UART only, the default: the Wi-Fi module of Xpeccy+

a serial port, such as COM3

a serial port of this computer, with a real module or another device on it

A serial port follows the speed and the format the program sets. The list shows the ports of this computer, and you can also type a name, such as a named pipe \\.\pipe\NAME on Windows. For one run only, you can use --uart-esp PORT and --uart-pi PORT on the command line (esp for the emulated module, - for none).

The emulated ESP-01 answers as Espressif’s AT firmware 1.7.6 does. The connections a program opens go out through this computer’s network, so programs such as Internet NEXTplorer work. The module sees one access point, named Xpeccy+, which takes any password. The computer’s own Wi-Fi is never seen. If the module opens a server, the server takes clients from this computer only, at 127.0.0.1. To let other computers in, tick Server on the network in the row’s window. The module’s settings are kept in the nvram folder of the settings.

Not emulated: secure connections (SSL/TLS), joining the module’s own access point, and updating the module’s firmware.

The ZX Evolution (TSConf) can have the same module on its ZiFi ports (see ZiFi).

The clock. The Next’s clock keeps the time it was set to, in nvram/zxnext.rtc of the settings folder. Until it is set, it shows the computer’s time.

In the Debugger

The Debugger has a ZX Next panel for the Next’s registers, sprites, copper, layers, tilemap, palettes and DMA: see ZX Next panel. The Palette panel is there too. The CMOS, FDC and FDD panels are not.

Not emulated yet

  • the second SD card slot, the Raspberry Pi accelerator and the FPGA flash;

  • devices on the expansion bus;

  • the keys for the Next’s video output (scandoubler, scanlines);

  • video timings other than VGA 0 and VGA 1, and the settings of config.ini other than the ROMs and the timing;

  • Look ahead of the adaptive anti-flicker modes (see View menu).