Hardware sprites: 32 x 16x16 from 64 shapes, collisions, frame counter
rtl/sprites.v draws sprites between the graphics and the text from a pair of line buffers filled one graphics line ahead. Ports 70h-77h set position, shape, flip and on/off and load shapes; 78h is a frame counter; 80h-87h report sprite-sprite and sprite-graphics collisions per frame. The graphics fill (CLS) turns sprites off unless bit 7 is set. Testbench checks pixels, priority, flip, edge clipping, collisions and CLS. Manual, README and basic/examples/sprites.bas demo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c78073320b
commit
13373244e8
9 files changed
+480
-7
No files matched your search
@@ -12,6 +12,7 @@
|
||||
// 30 out graphics X bits 7:0 31 out X bit 8 32 out Y
|
||||
// 33 out plot colour at (X,Y), then X+1 in colour at (X,Y)
|
||||
// 34 out fill the whole graphics screen in bit 0 = fill busy
|
||||
// (also turns the sprites off unless bit 7 is set)
|
||||
// 40 SPI flash control, 41 SPI flash data (see flash_spi.v)
|
||||
// 60 out bit 0 = monitor bank in; bit 1 (with bit 0 = 0) = stop again after
|
||||
// one instruction of the program
|
||||
@@ -22,6 +23,7 @@
|
||||
// 64 in main-memory byte at the debug address, then address + 1
|
||||
// 65 out breakpoint 0 low 66 high 68 out breakpoint 1 low 69 high
|
||||
// 67 out bit 0 = breakpoint 0 on, bit 1 = breakpoint 1 on
|
||||
// 70-78, 80-87 sprites (see sprites.v)
|
||||
//
|
||||
// The monitor: an NMI (Pause key, port 61, a breakpoint or the step counter)
|
||||
// pushes the program's PC and jumps to 0066h, where both BASIC and the monitor
|
||||
@@ -56,6 +58,14 @@ module z80_system #(
|
||||
input vclk,
|
||||
input [16:0] gfx_vaddr,
|
||||
output reg [3:0] gfx_vpix,
|
||||
// sprites, on the video clock (see sprites.v)
|
||||
input sp_go,
|
||||
input [7:0] sp_line,
|
||||
input sp_buf,
|
||||
input [8:0] sp_x,
|
||||
input sp_on,
|
||||
output [3:0] sp_pix,
|
||||
input sp_ftick,
|
||||
// configuration flash (SPI)
|
||||
output fl_cs_n,
|
||||
output fl_sck,
|
||||
@@ -145,6 +155,15 @@ module z80_system #(
|
||||
end
|
||||
end
|
||||
|
||||
// ------------------------------------------------------------- sprites
|
||||
wire [7:0] spr_q;
|
||||
sprites spr (
|
||||
.clk(clk), .rst(rst),
|
||||
.io_wr(io_wr), .io_port(io_addr[7:0]), .io_wd(io_wd), .io_q(spr_q),
|
||||
.vclk(vclk), .go(sp_go), .line(sp_line), .rd_buf(sp_buf), .rd_x(sp_x),
|
||||
.rd_on(sp_on), .pix(sp_pix), .gfx_pix(gfx_vpix), .ftick(sp_ftick)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------- flash
|
||||
wire [7:0] fl_ctl_q, fl_dat_q;
|
||||
flash_spi flash (
|
||||
@@ -235,6 +254,8 @@ module z80_system #(
|
||||
8'h41: io_din = fl_dat_q;
|
||||
8'h60: io_din = {5'd0, why};
|
||||
8'h64: io_din = dbg_q;
|
||||
8'h78, 8'h80, 8'h81, 8'h82, 8'h83, 8'h84, 8'h85, 8'h86, 8'h87:
|
||||
io_din = spr_q;
|
||||
default: io_din = 8'hFF;
|
||||
endcase
|
||||
|
||||
|
||||
Reference in new issue
Block a user