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:
1 parent
59d5e617f2
commit
dc7c7c22c5
14 files changed
+5205
-4141
No files matched your search
@@ -10,8 +10,10 @@ serial terminal with ANSI colour:
|
||||
- **Serial line**: the micro-USB **PROG/UART** port (the FTDI chip), 8N1. Bytes
|
||||
received there are drawn on the screen. Keystrokes are sent out there.
|
||||
|
||||
It also contains a **Z-80 computer running Dartmouth-style BASIC**. Flip SW15 up
|
||||
and the terminal becomes its console (see [Z-80 BASIC](#z-80-basic)).
|
||||
It also contains a **Z-80 computer running Dartmouth-style BASIC with 320×240
|
||||
colour graphics**. Flip SW15 up and the terminal becomes its console (see
|
||||
[Z-80 BASIC](#z-80-basic) and the full manual,
|
||||
[docs/basic-manual.pdf](docs/basic-manual.pdf)).
|
||||
|
||||
Plug the micro-USB into a PC and open the serial port (`/dev/ttyUSB1` is usually
|
||||
the UART; `ttyUSB0` is JTAG). For example:
|
||||
@@ -162,6 +164,9 @@ edit the line being typed.
|
||||
`STOP`
|
||||
- Data: `DIM`, `DEF FNx(v) = expr`, `READ`/`DATA`/`RESTORE`, `REM`
|
||||
- Machine access: `RANDOMIZE`, `POKE addr,v`, `OUT port,v`
|
||||
- Graphics: `CLS`, `COLOR c`, `PLOT x,y[,c]`, `LINE`, `RECT`, `FILL`
|
||||
(`x1,y1,x2,y2[,c]`), `CIRCLE x,y,r[,c]`
|
||||
- Text placement: `LOCATE row,col`, `INK fg[,bg]`
|
||||
- Several statements can share a line, separated by `:`.
|
||||
- **Variables**:
|
||||
- Numbers: a letter or a letter and digit (`X`, `A1`), single-precision
|
||||
@@ -172,13 +177,34 @@ edit the line being typed.
|
||||
- **Functions**:
|
||||
- Numeric: `SIN COS TAN ATN EXP LOG ABS SQR INT RND SGN`, `FNx`
|
||||
- Strings: `LEN VAL ASC`, `CHR$ STR$ LEFT$ RIGHT$ MID$`
|
||||
- Machine: `PEEK(addr)`, `INP(port)`, `TIM` (seconds since reset)
|
||||
- Machine: `PEEK(addr)`, `INP(port)`, `TIM` (seconds since reset),
|
||||
`POINT(x,y)` (graphics pixel colour)
|
||||
- Spaces are optional, as at Dartmouth: `FORI=1TO10` works.
|
||||
- `DATA` takes the rest of its line.
|
||||
|
||||
About 22 KB of program space is free. To paste a program from the PC, flip SW14
|
||||
up too (stop the getty first, or it will talk to BASIC), then paste into
|
||||
`picocom`. The terminal holds the PC back with XON/XOFF while BASIC catches up.
|
||||
About 22 KB of program space is free.
|
||||
|
||||
**Graphics:** the layer is 320×240 pixels in the 16 terminal colours, each
|
||||
pixel a 2×2 block, with (0,0) at the top left. Colour 0 is transparent. Text is
|
||||
drawn on top, and the graphics show through blank text.
|
||||
|
||||
**Manual:** [docs/basic-manual.md](docs/basic-manual.md) describes every
|
||||
statement and function, with examples, error messages and limits.
|
||||
`docs/build-manual.sh` rebuilds the PDF from it.
|
||||
|
||||
**Loading programs from the PC:**
|
||||
|
||||
1. Flip SW14 and SW15 up.
|
||||
2. Stop the getty: `sudo systemctl stop serial-getty@ttyUSB1`.
|
||||
3. Send the program at the SW1:0 baud rate:
|
||||
|
||||
```bash
|
||||
tools/send-bas.py basic/examples/graphics-demo.bas --baud 9600 --run
|
||||
```
|
||||
|
||||
The terminal holds the PC back with XON/XOFF while BASIC catches up.
|
||||
`basic/examples/graphics-demo.bas` shows off the graphics: colour bars,
|
||||
circles, lines, curves, random shapes, a bouncing ball and a Mandelbrot set.
|
||||
|
||||
### The Z-80
|
||||
|
||||
@@ -198,6 +224,11 @@ up too (stop the getty first, or it will talk to BASIC), then paste into
|
||||
forms, `SLL` and the DDCB register copies, with the undocumented X/Y flags.
|
||||
- There are no interrupts and HALT stops it until reset.
|
||||
|
||||
The 320×240×4-bit graphics layer is a separate dual-clock block RAM: the Z-80
|
||||
writes it on its own clock, and the video reads it on the 100 MHz clock.
|
||||
`rtl/text_display.v` overlays it on the text. A hardware fill clears it in
|
||||
76,800 clocks.
|
||||
|
||||
Memory is 64 KB of block RAM loaded with BASIC at configuration. Writes below
|
||||
8000h are ignored, so the interpreter can't be damaged. BASIC's data and the
|
||||
stack fill the top half.
|
||||
@@ -208,6 +239,9 @@ stack fill the top half.
|
||||
| 01h | key | character to the screen |
|
||||
| 10h–13h | millisecond counter (reading 10h latches the rest) | |
|
||||
| 20h / 21h | | 7-segment display, right / left byte |
|
||||
| 30h, 31h, 32h | | graphics X low byte, X bit 8, Y |
|
||||
| 33h | colour at X,Y | plot at X,Y, then X+1 |
|
||||
| 34h | bit 0: fill busy | fill the whole graphics layer with a colour |
|
||||
|
||||
BASIC is C (`basic/basic.c`) compiled with SDCC (`sudo apt install sdcc`):
|
||||
|
||||
|
||||
Reference in new issue
Block a user