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

+8 -1
View File
@@ -2,6 +2,8 @@
// 640x480 @ 60 Hz VGA text display: 80x30 cells of 8x16 pixels, 16 colours,
// underline, blink, block cursor and smooth-scroll offset for the scroll region.
// A 320x240 graphics layer (each pixel 2x2) shows through wherever the text is
// background; graphics colour 0 is transparent.
// Runs on the 100 MHz clock with a 25 MHz pixel enable. After each pixel tick:
// clock 1 scanline values registered (row base address, glyph line)
// clock 2 character RAM read
@@ -23,6 +25,8 @@ module text_display #(
input [4:0] sm_off, // pixels the region has moved
output [11:0] ram_addr,
input [17:0] ram_data, // {blink, underline, bg, fg, code}
output [16:0] gfx_addr, // graphics pixel, read a clock later
input [3:0] gfx_pix,
output reg [3:0] red,
output reg [3:0] green,
output reg [3:0] blue,
@@ -75,6 +79,7 @@ module text_display #(
wire [6:0] tcol = h[9:3];
assign ram_addr = row_base + {5'b0, tcol};
assign gfx_addr = {v[8:1], 8'd0} + {2'd0, v[8:1], 6'd0} + {8'd0, h[9:1]};
reg [7:0] font [0:4095];
reg [7:0] glyph;
@@ -97,7 +102,9 @@ module text_display #(
wire visible = h < H_VIS && v < V_VIS;
wire cursor = cur_vis && frame[5] && tcol == cur_col && srow == cur_row;
wire ink = (glyph[~h[2:0]] | (ram_data[16] && line == 4'd15)) && !(ram_data[17] && frame[5]);
wire [3:0] idx = blank_line ? 4'd0 : (ink ^ cursor) ? ram_data[11:8] : ram_data[15:12];
wire fg = !blank_line && (ink ^ cursor);
wire [3:0] idx = fg ? ram_data[11:8] : gfx_pix != 4'd0 ? gfx_pix :
blank_line ? 4'd0 : ram_data[15:12];
always @(posedge clk) begin
if (tick) begin