BBC BASIC for the NDR Klein Computer
  • Assembly 94.5%
  • Python 2.1%
  • Makefile 1.9%
  • Shell 1.5%
Find a file
Hans Hübner 0cc21d8e12 build: make RAMBASE and IO-USB port configurable
The BASIC data-RAM base (RAMBASE, default $6000) and the IO-USB card I/O
port (SPIPORT, default $30) are now set at build time via the Makefile
(-DRAMBASE/-DSPIPORT), so a board whose RAM sits elsewhere builds with
e.g. `make RAMBASE=0x8000`.

The boot loader sizes RAM from RAMBASE rather than from the $2000 code
area, so it starts even when the code window ($2000-$5FFF) and the data
RAM are separate regions (no RAM at $6000-$7FFF). On a contiguous board
the probe returns the same top, so behaviour is unchanged there.

config.inc derives MINRAMTOP and the boot size readout from RAMBASE;
vdip.asm takes the SPI port from SPIPORT. Both keep their old defaults
via IFNDEF, so the standard images are byte-identical in layout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 16:59:06 +02:00
.forgejo/workflows release: v0.26 — FLO3 marked experimental, removed from release distribution 2026-06-14 21:56:17 +02:00
.githooks docs: add German CHANGELOG; enforce a changelog entry per release tag 2026-06-11 15:58:53 +02:00
docs/img docs: emulator screenshots for every manual example 2026-06-11 12:41:13 +02:00
examples gdp: flicker-free CLS/MODE + *SCREEN double buffering 2026-06-15 13:27:46 +02:00
src build: make RAMBASE and IO-USB port configurable 2026-06-28 16:59:06 +02:00
tools ci: kill the boot-test emulator with SIGKILL so the release stops hanging 2026-06-15 07:09:56 +02:00
.gitignore flo3: *EXEC read stream (fix line-ending EOF), progress bar full one tick early 2026-06-13 17:46:40 +02:00
CHANGELOG.md build: make RAMBASE and IO-USB port configurable 2026-06-28 16:59:06 +02:00
CLAUDE.md docs: move changelog-maintenance notes out of CHANGELOG.md into CLAUDE.md 2026-06-11 16:04:27 +02:00
FLO3.md release: v0.26 — FLO3 marked experimental, removed from release distribution 2026-06-14 21:56:17 +02:00
INSTALLATION.md build: make RAMBASE and IO-USB port configurable 2026-06-28 16:59:06 +02:00
LICENSE license: MIT for the port, vendor the zlib license for the BBC BASIC core 2026-06-09 16:58:45 +02:00
Makefile build: make RAMBASE and IO-USB port configurable 2026-06-28 16:59:06 +02:00
MANUAL.en.md docs: document double buffering (*SCREEN + flicker-free CLS/MODE) 2026-06-15 13:47:32 +02:00
MANUAL.md docs: document double buffering (*SCREEN + flicker-free CLS/MODE) 2026-06-15 13:47:32 +02:00
README.en.md docs: drop double-buffering bullet from the READMEs 2026-06-15 14:03:46 +02:00
README.md docs: drop double-buffering bullet from the READMEs 2026-06-15 14:03:46 +02:00
SERIAL.md serial: interrupt-driven SER2 (88C681) driver with COM1:/COM2: channels 2026-06-09 16:20:10 +02:00

NKC BBC BASIC (Z80)

Deutsche Fassung: README.md.

A port of R. T. Russell's BBC BASIC (Z80) 3.00 to the NDR-Klein-Computer: it runs on the GDP64 (EF9366) graphics card, the parallel ASCII keyboard, and a pluggable file system for storage — an IO-USB stick or a serial Kermit server (depending on which boot ROM is burned). BASIC runs entirely in RAM and is loaded from the backend at startup. Runs on real hardware and on the SDL2 nkcemu emulator.

See MANUAL.en.md for the full user guide.

What it does

  • Integer + floating point, full strings — the complete BBC BASIC language.
  • Graphics on the GDP64: MOVE/DRAW/PLOT with software fills (filled triangle/rectangle, points), GCOL, MODE, CLS/CLG.
  • EF9366 attributes via VDU 23 (line style, text orientation, char size) and * aliases; VDU 5 text on the graphics plane; filled blocks.
  • Filing: SAVE/LOAD, *SPOOL/*EXEC (text), and full data files (OPENIN/OPENOUT/OPENUP, BGET#/BPUT#/PTR#/EXT#/EOF#/CLOSE#) on the IO-USB and Kermit backends.
  • * commands (*DIR, *ERA, *RENA, *RESET, …) via an extensible table.
  • Copy-cursor line editing (arrows + COPY), clear-line (Ctrl-U / ESC), real TIME, and autostart (autostart.exec on the stick).
  • RAM auto-sizing at startup: uses exactly the RAM that's fitted (from $4000 up), 48K downward — HIMEM is set automatically.

Layout

Sources live in src/, build artifacts in build/.

File Role
src/mos.asm Machine-OS layer: the 21 BBC BASIC host entry points, the VDU/OSWRCH console + the OSLINE editor, OSCLI/* commands, filing shims.
src/nkcdev.asm GDP64/EF9366 graphics + parallel-keyboard drivers (transcribed from the Grundprogramm 3.1 MCP31.ASM).
src/vdip.asm IO-USB driver (VDIP1/VNC1L SPI): whole-file LOAD/SAVE + channel-based data files.
src/kermit.asm Kermit driver (serial backend over COM1): LOAD/SAVE, *EXEC/*SPOOL, file channels and *DIR/*ERA/*RENA over Kermit REMOTE commands.
src/diskjt.asm Disk jump table: fixed-address slots through which BASIC, the loader and the monitor reach the selected backend — so one BASIC.BIN runs on every boot ROM.
src/hwgdp.asm GDP-native graphics/screen layer (replaces the distribution's TMS9918 hardware.asm): MOVE/DRAW/PLOT/fills, EF9366 attributes, VDU 5 text.
src/serial.asm SER2 driver (88C681 DUART): interrupt-buffered COM1:/COM2: channels. See SERIAL.md.
src/boot.asm Stage-0 EPROM at $0000: paints the banner, verifies the BASIC at $2000 by its embedded checksum (in ROM, or kept in RAM across a reset), loads BASIC.BIN from the backend only when that fails, then jumps in.
src/config.inc Single source of truth for the memory map.
src/bbcbasic/ The vendored BBC BASIC core (main/exec/eval/fpp/ram.asm) from https://github.com/jblang/bbcbasic-z80 (zlib). cpm.asm and hardware.asm are unused — replaced by mos.asm/nkcdev.asm/hwgdp.asm.
examples/ Sample programs (EF9366.TXT exercises every graphics feature; SER2.TXT/SERCHAT.TXT for the serial card).

Build

make            # -> build/BASIC.BIN, boot_{usb,kermit}.rom (burn one),
                #    basic_{2000,4000}.rom (ROM variant)
make clean

Toolchain: z88dk-z80asm.

Run (emulator)

The SDL2 nkcemu emulator lives in the sibling directory ../nkcemu:

cd ../nkcemu && cmake -B build && cmake --build build
# the stick can be a merge of several directories (repeat -u), e.g. the build
# output + the examples -- no copying or symlinks:
./build/nkcemu -b ../nkc-bbc-basic/build/boot_usb.rom \
               -u ../nkc-bbc-basic/build -u ../nkc-bbc-basic/examples

Licence / provenance

  • This port — the MOS/host layer, the serial driver, the GDP-native graphics layer, the boot loader, the examples, build and docs — is under the MIT licence: see LICENSE.
  • The vendored BBC BASIC (Z80) interpreter core in src/bbcbasic/ is © R. T. Russell / J. B. Langston, under the zlib licence: see src/bbcbasic/LICENSE.
  • The GDP/keyboard/VDIP drivers (nkcdev.asm, parts of vdip.asm) are transcribed from the Grundprogramm 3.1 source (MCP31.ASM).