Bastion Raid: isometric scrolling shooter, graphics scroll and border
Ports 35h-37h scroll the graphics layer (wrapping at 320 x 240); bit 1 of 36h hides a border (4 columns, 2 rows) where a program draws the strip coming into view unseen. The video loads its own column/row counters from the scroll registers each line and frame. CLS resets both. Testbench checks scroll, wrap and border. games/raid: an original Zaxxon-style game in C - fly over a fortress that scrolls diagonally, climb over low walls and through doorways in tall ones, shoot turrets, fuel tanks, radar and fighters, destroy the reactor. The world is drawn pixel by pixel from a formula, two columns and a row a frame (about 40% of the Z-80). test-raid.py flies the level with an autopilot and checks the frame budget; tools/boardemu.py is now shared by both games' tests. send-hex.py sets the date before saving. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
743071cff3
commit
62d0883a7f
19 files changed
+1807
-163
No files matched your search
+32
-7
@@ -8,7 +8,10 @@
|
||||
// Hardware sprites (sprites.v) sit between the graphics and the text.
|
||||
// A 320x240 graphics layer (each pixel 4x4, the top 960 lines, so 80-column
|
||||
// text row r still starts at graphics line 8(r-1)) shows through wherever the
|
||||
// text is background; colour 0 is transparent.
|
||||
// text is background; colour 0 is transparent. It scrolls: the picture starts
|
||||
// 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.
|
||||
// One pixel per clock, pipelined:
|
||||
// clock 0 position -> row, column, glyph line (registered)
|
||||
// clock 1 character RAM and graphics reads
|
||||
@@ -32,6 +35,9 @@ module text_display #(
|
||||
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,
|
||||
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
|
||||
// sprites: the line to prepare next, and the pixel on screen
|
||||
output reg sp_go,
|
||||
output reg [7:0] sp_line,
|
||||
@@ -72,6 +78,22 @@ module text_display #(
|
||||
h <= h + 1'b1;
|
||||
end
|
||||
|
||||
// graphics pixel for this h, v with the scroll added: counters set from
|
||||
// the scroll registers at the end of each line and each frame
|
||||
reg [8:0] g_col = 9'd0;
|
||||
reg [7:0] g_row = 8'd0;
|
||||
reg [1:0] g_sub = 2'd0;
|
||||
always @(posedge clk)
|
||||
if (h == H_TOTAL - 1) begin
|
||||
g_col <= scroll_x;
|
||||
g_sub <= 2'd0;
|
||||
if (v == V_TOTAL - 1) g_row <= scroll_y;
|
||||
else if (v[1:0] == 2'd3) g_row <= g_row == 8'd239 ? 8'd0 : g_row + 1'b1;
|
||||
end else begin
|
||||
g_sub <= g_sub + 1'b1;
|
||||
if (g_sub == 2'd3) g_col <= g_col >= 9'd319 ? 9'd0 : g_col + 1'b1;
|
||||
end
|
||||
|
||||
// ---- clock 0: where this pixel is in the text, in font units
|
||||
// yl counts font lines (a 16-line font: 32 pixels a row in 80 columns)
|
||||
wire [9:0] yl = wide ? v[9:0] : {1'b0, v[9:1]};
|
||||
@@ -88,7 +110,9 @@ module text_display #(
|
||||
reg [7:0] a_col;
|
||||
reg [3:0] a_line;
|
||||
reg [2:0] a_bit;
|
||||
reg a_blank, a_text, a_vis, a_cur, a_hs, a_vs, a_gon;
|
||||
reg a_blank, a_text, a_vis, a_cur, a_hs, a_vs, a_gon, a_ghide;
|
||||
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 [8:0] a_spx;
|
||||
reg a_spbuf;
|
||||
@@ -104,7 +128,8 @@ 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_gfx <= {v[9:2], 8'd0} + {2'd0, v[9:2], 6'd0} + {8'd0, h[10:2]};
|
||||
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_spx <= h[10:2];
|
||||
a_spbuf <= v[2];
|
||||
end
|
||||
@@ -117,10 +142,10 @@ module text_display #(
|
||||
assign sp_on = a_gon;
|
||||
reg [3:0] b_line;
|
||||
reg [2:0] b_bit;
|
||||
reg b_blank, b_text, b_vis, b_cur, b_hs, b_vs, b_gon;
|
||||
reg b_blank, b_text, b_vis, b_cur, b_hs, b_vs, b_gon, b_ghide;
|
||||
always @(posedge clk)
|
||||
{b_line, b_bit, b_blank, b_text, b_vis, b_cur, b_hs, b_vs, b_gon} <=
|
||||
{a_line, a_bit, a_blank, a_text, a_vis, a_cur, a_hs, a_vs, a_gon};
|
||||
{b_line, b_bit, b_blank, b_text, b_vis, b_cur, b_hs, b_vs, b_gon, b_ghide} <=
|
||||
{a_line, a_bit, a_blank, a_text, a_vis, a_cur, a_hs, a_vs, a_gon, a_ghide};
|
||||
|
||||
// ---- clock 2: font ROM
|
||||
reg [7:0] font [0:4095];
|
||||
@@ -133,7 +158,7 @@ module text_display #(
|
||||
always @(posedge clk) begin
|
||||
glyph <= font[{ram_data[7:0], b_line}];
|
||||
c_cell <= ram_data;
|
||||
c_gfx <= b_gon ? gfx_pix : 4'd0;
|
||||
c_gfx <= b_gon && !b_ghide ? gfx_pix : 4'd0;
|
||||
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};
|
||||
|
||||
Reference in new issue
Block a user