BASIC graphics: 320x240 16-colour layer, manual and demo

- z80_system: dual-clock graphics RAM behind ports 30h-34h (X/Y, plot
  with auto-increment, read-back, hardware fill); text_display overlays it
  under the text, colour 0 transparent.
- BASIC: CLS COLOR PLOT LINE RECT FILL CIRCLE POINT, LOCATE and INK;
  faster keyword tokenizing.
- docs/basic-manual.md (+ PDF via docs/build-manual.sh).
- basic/examples/graphics-demo.bas and tools/send-bas.py to load programs
  over the serial port.
- Simulation checks drawing and saves a frame; the emulator models the
  graphics and timer ports and can stop when BASIC waits for input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-11-27 21:09:43 -08:00
1 parent 59d5e617f2
commit dc7c7c22c5
14 files changed
+5205 -4141

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
"""Type a BASIC program into the Basys 3 Z-80 over the serial port.
The board needs SW15 and SW14 up (Z-80 mode, PC serial linked), and nothing
else may be using the port (stop the getty first). The baud rate must match
SW1:0. Sends NEW first unless --keep is given, then the program, then RUN
if --run is given.
tools/send-bas.py basic/examples/graphics-demo.bas --baud 9600 --run
"""
import argparse
import os
import termios
import time
BAUDS = {9600: termios.B9600, 19200: termios.B19200, 57600: termios.B57600,
115200: termios.B115200}
ap = argparse.ArgumentParser()
ap.add_argument("file")
ap.add_argument("--port", default="/dev/ttyUSB1")
ap.add_argument("--baud", type=int, default=115200, choices=sorted(BAUDS))
ap.add_argument("--keep", action="store_true", help="don't send NEW first")
ap.add_argument("--run", action="store_true", help="send RUN at the end")
a = ap.parse_args()
fd = os.open(a.port, os.O_RDWR | os.O_NOCTTY)
t = termios.tcgetattr(fd)
t[0] = termios.IXON # honour XON/XOFF
t[1] = 0
t[2] = termios.CS8 | termios.CREAD | termios.CLOCAL
t[3] = 0
t[4] = t[5] = BAUDS[a.baud]
termios.tcsetattr(fd, termios.TCSANOW, t)
lines = [l.rstrip() for l in open(a.file) if l.strip()]
if not a.keep:
lines.insert(0, "NEW")
if a.run:
lines.append("RUN")
for n, line in enumerate(lines, 1):
os.write(fd, line.encode("ascii") + b"\r")
termios.tcdrain(fd)
time.sleep(0.02) # let BASIC store the line
print("\r%d/%d lines" % (n, len(lines)), end="", flush=True)
print()
os.close(fd)