Skip to main content

Spectranext Module

This page is a short guide for developers who ship Z80 code (modules, demos, or tests) that run on the Spectrum and talk to the Spectranext controller over the cartridge interface.

Spectranext exposes its controller as Spectranet page 0x48. This is a 4 KiB memory-mapped page containing executable Z80 code, request/response workspaces, and command/status registers. The C library and ROM calls use this same page.

Controller page 0x48​

The ROM gateway maps page 0x48 into page B ($2000–$2FFF), calls the controller entry at $2000, then restores the previous page-B mapping. With that mapping, the layout is:

AddressContents
$2000–$27FFZ80 controller code; entry at $2000
$2800–$2BFBChannel 0 request/response workspace (1,020 bytes)
$2BFC–$2BFFReserved
$2C00–$2FFBChannel 1 request/response workspace (1,020 bytes)
$2FFC / $2FFDChannel 1 command / status
$2FFE / $2FFFChannel 0 command / status

The SDK and ROM interface use channel 0 and wait for completion. Channel 1 supports direct memory access so a program can submit a request and check its completion later. Direct access to the controller page is supported; see Controller channels for payloads, submission order, and polling examples.

For direct access, page in the cartridge and select 0x48 with SETPAGEB. Preserve and restore the previous page-B mapping, and keep calling code, buffers, and the stack outside $2000–$2FFF. The workspace and registers belong to the selected controller page; they are not fixed registers in permanent Spectranet RAM.

Fill an idle channel's workspace, write $FF to its status register, then write the command number to its command register. Poll status: $FF means pending/running, 0 means success, and 1 means error. Read the response before reusing the channel, and leave its workspace and registers untouched while it is busy.

The source definitions are common/spectranext_controller_layout.h; the ROM gateway is spectranet-firmware/rom/spectranext.asm, and the Z80 controller implementation is spectranet-firmware/rom/spxcontroller.asm.


C (z88dk)​

Use spectranext.h: controller status, Wi‑Fi scan/connect/disconnect, and DNS. The header lists constants, return conventions, and __z88dk_callee signatures.

Full reference: spectranext.h — C API

There you will find:

  • spectranext_detect, spectranext_get_controller_status, spectranext_wifi_*, spectranext_gethostbyname
  • WIFI_*, GETHOSTBYNAME_*, and port/status macros
  • Notes on linking libspectranet vs libspectranet_np and paging

Assembly​

Spectranext operations are issued through the Spectranet ROM jump table entry SPECTRANEXT ($3EF0) with an operation ID in A, typically reached via IXCALL ($3FFD). Return paths, PAGEOUT, and register inputs/outputs for each operation are documented in one place:

Syscalls

For direct command/status access on page 0x48, see Controller channels. The page-selection I/O ports are documented in I/O Ports.