Add a 640x480 two-colour graphics mode; start in white

The graphics memory doubles as 640x480 at a bit a pixel (port 38), four
pixels to an entry, plotted by read-modify-write, in two colours from
port 39 (0 transparent). BASIC gets SCREEN 0 / SCREEN 1 [,set[,clear]];
a plain fill (as every game does) returns to 320x240 and BASIC follows.
The text now starts in white (SW5:4 = 00; 10 is green). The README is
rewritten to stand on its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-12-01 06:06:30 -08:00
1 parent 71fd403294
commit bda9bb67b6
13 files changed
+2985 -2680

No files matched your search

+18 -5
View File
@@ -12,6 +12,9 @@
// at (scroll_x, scroll_y) of the buffer and wraps round at 320 and 240. With
// g_border the graphics are hidden in a border (4 columns each side, 2 rows
// top and bottom), where a scrolling program can draw what comes next unseen.
// With g_hires the same memory is 640x480 at a bit a pixel (each pixel 2x2,
// four pixels to an entry, bit 0 the leftmost), in two colours from g_cols
// ({clear, set}; 0 is transparent); it doesn't scroll or hide in a border.
// One pixel per clock, pipelined:
// clock 0 position -> row, column, glyph line (registered)
// clock 1 character RAM and graphics reads
@@ -38,6 +41,9 @@ module text_display #(
input [8:0] scroll_x, // graphics pixel shown at the top left
input [7:0] scroll_y,
input g_border, // hide 4 graphics columns each side, 2 rows top and bottom
input g_hires, // 640x480, 1 bit a pixel
input [7:0] g_cols, // its colours: {clear, set}
input g_show, // show the graphics layer at all
// sprites: the line to prepare next, and the pixel on screen
output reg sp_go,
output reg [7:0] sp_line,
@@ -114,6 +120,8 @@ module text_display #(
wire [8:0] gcol_s = h[10:2]; // graphics pixel on the screen, unscrolled
wire [7:0] grow_s = v[9:2];
reg [16:0] a_gfx;
reg [1:0] a_gbit;
wire [8:0] hrow = v[9:1]; // 640x480 pixel row
reg [8:0] a_spx;
reg a_spbuf;
always @(posedge clk) begin
@@ -128,8 +136,10 @@ module text_display #(
a_hs <= h >= H_VIS + H_FP && h < H_VIS + H_FP + H_SYNC; // positive sync
a_vs <= v >= V_VIS + V_FP && v < V_VIS + V_FP + V_SYNC;
a_gon <= v < 960;
a_ghide <= g_border && (gcol_s < 9'd4 || gcol_s >= 9'd316 || grow_s < 8'd2 || grow_s >= 8'd238);
a_gfx <= {1'b0, g_row, 8'd0} + {3'd0, g_row, 6'd0} + {8'd0, g_col};
a_ghide <= !g_hires && g_border && (gcol_s < 9'd4 || gcol_s >= 9'd316 || grow_s < 8'd2 || grow_s >= 8'd238);
a_gfx <= g_hires ? {hrow, 7'd0} + {2'd0, hrow, 5'd0} + {9'd0, h[10:3]}
: {1'b0, g_row, 8'd0} + {3'd0, g_row, 6'd0} + {8'd0, g_col};
a_gbit <= h[2:1];
a_spx <= h[10:2];
a_spbuf <= v[2];
end
@@ -141,6 +151,8 @@ module text_display #(
assign sp_buf = a_spbuf;
assign sp_on = a_gon;
reg [3:0] b_line;
reg [1:0] b_gbit;
always @(posedge clk) b_gbit <= a_gbit;
reg [2:0] b_bit;
reg b_blank, b_text, b_vis, b_cur, b_hs, b_vs, b_gon, b_ghide;
always @(posedge clk)
@@ -158,7 +170,8 @@ module text_display #(
always @(posedge clk) begin
glyph <= font[{ram_data[7:0], b_line}];
c_cell <= ram_data;
c_gfx <= b_gon && !b_ghide ? gfx_pix : 4'd0;
c_gfx <= !g_show || !b_gon || b_ghide ? 4'd0 :
!g_hires ? gfx_pix : gfx_pix[b_gbit] ? g_cols[3:0] : g_cols[7:4];
c_spr <= sp_pix;
{c_line, c_bit, c_blank, c_text, c_vis, c_cur, c_hs, c_vs} <=
{b_line, b_bit, b_blank, b_text, b_vis, b_cur, b_hs, b_vs};
@@ -212,8 +225,8 @@ module char_ram (
(* ram_style = "block" *) reg [17:0] hi [0:2 * PAGE - 16384 - 1];
integer i;
initial begin
for (i = 0; i < 16384; i = i + 1) lo[i] = {10'h00A, 8'h20};
for (i = 0; i < 2 * PAGE - 16384; i = i + 1) hi[i] = {10'h00A, 8'h20};
for (i = 0; i < 16384; i = i + 1) lo[i] = {10'h00F, 8'h20};
for (i = 0; i < 2 * PAGE - 16384; i = i + 1) hi[i] = {10'h00F, 8'h20};
end
wire [14:0] aa = {1'b0, a_addr} + (a_alt ? PAGE : 0);