SDK Setup and Usage
The Spectranext SDK provides everything you need to develop programs for the Spectranext cartridge (and for original Spectranet). It includes the z88dk toolchain, CMake integration, and SPX tools for file transfer.
Installation
- macOS
- Docker
- Linux
- Windows
The easiest option is to use Homebrew:
brew tap spectranext/homebrew-spectranext
brew install spectranext-sdk
Load the SDK environment in your shell:
source "/opt/homebrew/opt/spectranext-sdk/libexec/source.sh"
Or add it to your shell profile:
echo 'source "/opt/homebrew/opt/spectranext-sdk/libexec/source.sh"' >> ~/.zshrc
Configure CMake projects with the z88dk toolchain:
cmake -S . -B build \
-DCMAKE_TOOLCHAIN_FILE="/opt/homebrew/opt/spectranext-sdk/libexec/z88dk/support/cmake/Toolchain-zcc.cmake"
(or manually) clone and install the SDK:
git clone https://github.com/spectranext/spectranext-sdk
cd spectranext-sdk
./install.sh
This will:
- Download and install z88dk toolchain
- Create a Python virtual environment
- Install required Python dependencies
Pre-built images include the full SDK (z88dk, Python venv, SPX tools) at /sdk. Use one as the base image in your project Dockerfile instead of running install.sh yourself.
https://hub.docker.com/u/spectranext
| Image | Base OS | Architecture |
|---|---|---|
spectranext/sdk-alpine:latest | Alpine Linux | amd64 + arm64 |
spectranext/sdk-ubuntu:latest | Ubuntu 24.04 | amd64 + arm64 |
Example Dockerfile of your project
FROM spectranext/sdk-alpine:latest
WORKDIR /build
COPY . .
RUN . /sdk/source.sh && \
cmake -B build -DCMAKE_BUILD_TYPE=Release -DZCCTARGET=zx -DCMAKE_TOOLCHAIN_FILE=/sdk/z88dk/share/z88dk/cmake/Toolchain-zcc.cmake . && \
cmake --build build
For Ubuntu-based projects, use FROM spectranext/sdk-ubuntu:latest instead. Source /sdk/source.sh (or set SPECTRANEXT_SDK_PATH=/sdk) before building—the same as on the host.
Need another base image, extra packages, or a smaller runtime? Use a multi-stage build: build in the SDK image (or copy the SDK into your own stage), then keep only what you need in the final image:
FROM spectranext/sdk-alpine:latest AS sdk
FROM alpine:3.23.4
COPY --from=sdk /sdk /sdk
ENV SPECTRANEXT_SDK_PATH=/sdk
ENV PATH="/sdk/bin:/sdk/z88dk/bin:${PATH}"
# Your project deps and sources
RUN apk add --no-cache cmake git build-base
WORKDIR /build
COPY . .
RUN . /sdk/source.sh && cmake -B build -DCMAKE_BUILD_TYPE=Release -DZCCTARGET=zx -DCMAKE_TOOLCHAIN_FILE=/sdk/z88dk/share/z88dk/cmake/Toolchain-zcc.cmake . && cmake --build build
The first stage can be any spectranext/sdk-* image; the second stage is your distro and tooling. Copy /sdk and set SPECTRANEXT_SDK_PATH wherever you compile.
Clone and install the SDK:
git clone https://github.com/spectranext/spectranext-sdk
cd spectranext-sdk
./install.sh
This will:
- Download and install z88dk toolchain
- Create a Python virtual environment
- Install required Python dependencies
Clone and install the SDK:
PowerShell:
git clone https://github.com/spectranext/spectranext-sdk
cd spectranext-sdk
.\install.bat
(or double-click install.bat)
Command Prompt:
git clone https://github.com/spectranext/spectranext-sdk
cd spectranext-sdk
install.bat
This will:
- Download and install z88dk toolchain
- Create a Python virtual environment
- Install required Python dependencies
Setup
- macOS
- Docker
- Linux
- Windows
If you installed with Homebrew, source the SDK environment from the Homebrew prefix:
source "/opt/homebrew/opt/spectranext-sdk/libexec/source.sh"
Or add it to your shell profile:
echo 'source "/opt/homebrew/opt/spectranext-sdk/libexec/source.sh"' >> ~/.zshrc
For CMake toolchain configuration, Homebrew installs the z88dk toolchain file at:
/opt/homebrew/opt/spectranext-sdk/libexec/z88dk/support/cmake/Toolchain-zcc.cmake
If you installed manually, source the SDK environment from your checkout:
source /path/to/spectranext-sdk/source.sh
You can also select source.sh as your environment file in CLion toolchain settings.
Source the SDK environment inside the container before configuring or building:
source /sdk/source.sh
For Docker builds, use the SDK toolchain file from /sdk:
cmake -S . -B build \
-DCMAKE_TOOLCHAIN_FILE=/sdk/z88dk/share/z88dk/cmake/Toolchain-zcc.cmake
You can also set SPECTRANEXT_SDK_PATH=/sdk in your Dockerfile or build environment.
Source the SDK environment in your shell:
source spectranext-sdk/source.sh
Or add it to your shell configuration file (~/.zshrc or ~/.bashrc):
source /path/to/spectranext-sdk/source.sh
You can also select this file as your environment file, or example in CLion you can select it as an environment file for your toolchain.
Use source.ps1 to set up environment in your projects.
For example, in CLion you can select source.ps1 as an environment file for your toolchain.
Setting Up a CMake Project
Create a CMakeLists.txt file in your project directory:
cmake_minimum_required(VERSION 3.16)
# Import Spectranext SDK - MUST be before project()
include($ENV{SPECTRANEXT_SDK_PATH}/cmake/spectranext_sdk_import.cmake)
spectranext_sdk_init()
project(idetest C)
add_executable(idetest main.c)
target_compile_options(idetest PUBLIC -debug)
target_link_libraries(idetest PUBLIC -lndos -llibspectranet -llibsocket)
target_link_options(idetest PUBLIC -debug -create-app)
# Set boot basic program (optional)
# This creates a boot.zx file that will be uploaded before your program
spectranext_set_boot("
10 %tapein \"idetest.tap\"
20 LOAD \"\"
")
# Add convenience targets (upload_bin, upload_tap, etc.)
spectranext_add_extra_outputs(idetest)
If source.sh is not sourced then SPECTRANEXT_SDK_PATH must be explicitly provided.
Important Notes
spectranext_sdk_init()must be called beforeproject()- This is required because the SDK sets up the CMake toolchain, which must be configured before the project is defined.
Boot BASIC Program
The spectranext_set_boot() function allows you to create a boot BASIC program that will be automatically uploaded before your main program. This is useful for creating loader programs or initialization code.
Usage:
spectranext_set_boot("
10 PRINT \"Booting...\"
20 CLEAR 32767
30 %aload \"myprogram.bin\" CODE 32768
40 RANDOMIZE USR 32768
")
The function:
- Creates
boot.basin the CMake binary directory - Compiles it to
boot.zxusingzmakebas(starting at line 10) - Creates an
upload_boottarget that builds and uploadsboot.zx - When
spectranext_add_extra_outputs()is called,upload_binandupload_taptargets will automatically depend onupload_bootif it exists
Example boot program:
spectranext_set_boot("
10 REM Boot loader
20 %tapein \"myprogram.tap\"
30 LOAD \"\"
40 REM Program will auto-run after loading
")
The boot program is compiled with zmakebas -o boot.zx -a 10 boot.bas, which means it starts at line 10. Make sure your BASIC code includes line numbers or uses labels if you're using zmakebas label mode.
Available Targets
If spectranext_set_boot() was called, the following additional target is available:
upload_boot- Build and uploadboot.zxfile for your BASIC loader program.
After calling spectranext_add_extra_outputs(project_name), the following targets are available:
project_name_upload_bin- Build and upload.binfileproject_name_upload_tap- Build and upload.tapfileproject_name_bin_autoboot- Build, upload.bin, and configure autobootproject_name_tap_autoboot- Build, upload.tap, and configure autoboot
Building and Uploading
# Configure CMake (if not already done)
cmake -B build
# Build and upload .bin file
cmake --build build --target idetest_upload_bin
# Build and upload .tap file
cmake --build build --target idetest_upload_tap
# Build, upload, and configure autoboot
cmake --build build --target idetest_bin_autoboot
SDK Components
- z88dk - Z80 cross-compiler toolchain
- CMake Integration - Automatic toolchain setup and convenience targets
- Headers - Spectranext API headers in
include/ - Libraries - Pre-built libraries in
clibs/
Environment Variables
The SDK sets the following environment variables:
SPECTRANEXT_SDK_PATH- Path to the SDK root directorySPECTRANEXT_TOOLCHAIN- Path to the CMake toolchain fileSPECTRANEXT_INCLUDE_DIR- Path to SDK include directoryZCCTARGET- z88dk target (default:zx)SPX_SDK_DIR- SDK directory for SPX toolsZCCCFG- z88dk configuration pathPATH- Includesz88dk/bin
Development Workflow
Example Project Structure
my-project/
├── CMakeLists.txt
├── main.c
└── build/ # CMake build directory
Complete Example
CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
include($ENV{SPECTRANEXT_SDK_PATH}/cmake/spectranext_sdk_import.cmake)
spectranext_sdk_init()
project(hello C)
add_executable(hello main.c)
target_compile_options(hello PUBLIC -debug)
target_link_libraries(hello PUBLIC -lndos -llibspectranet)
target_link_options(hello PUBLIC -debug -create-app)
# Optional: Set boot BASIC program
spectranext_set_boot("
10 PRINT \"Loading hello...\"
20 %tapein \"hello.tap\"
30 LOAD \"\"
")
spectranext_add_extra_outputs(hello)
main.c:
#include <stdio.h>
#include <spectranet.h>
int main() {
printf("Hello from Spectranext!\n");
return 0;
}
Build and upload:
cmake -B build
cmake --build build --target hello_upload_bin
Next Steps
- Syncing with Computer - Learn about file transfer tools
- XFS Filesystem - Access files from Spectrum programs
- Memory Architecture - Understand memory mapping