Files
CoCo3_Plus_MiSTer/rtl/cassette.v
T
shodge12 1da70a7929 Core changes and CSAVE support.
1.	Added support for cassette save.  To use: A) You have to have a file [anyname.cas]
	which is larger than needed.  B) Select the file through the UI Menu 'Save
	Cassette'.  C)Set 'Cass Rwd=0 / Rec=1' to 1. D) Issue your 'CSAVE "NAME"'
	E) When done, set 'Cass Rwd=0 / Rec=1' to 0 to complete the write.  The file can
	now be loaded or copied.  Note a dummy file of a specific size can be created in
	the MiSTer SSH shell in the /media/fat/games/coco3 with the command:
	'truncate -s 65536 tapefileame.cas'. [Note do NOT use over 65536 file length]
2.	Fixed serial interrupt [6551] to not be functional on slot 3 [carts].
3.	Modification of sys_top.v to override use of USER_IO for HDMI - so it can be used
	for logic analyzer debug.  This will only occur when `define	Config_Debug is
	enabled in config.v.
4.	Fixed MUGS of powerup issue occurring on some MiSTer units.
5.	Fixed incorrect application of GIME_IRQ on legacy interrupts.  Fixed race condition
	on reading IRQ status vs clearing the interrupt.
6.	Improved Castle of Tharoggad.  App now loads but locks as the graphics animate.  This
	change improved mmu usage through to CARTS.
7.	Builds now keep track of multiple builds in the same date.  It shows as V240512-001 in
	the menus.  Its also exposed to BASIC and a boot.vhd which can be enabled to autorun is
	supplied in the archive to show how it works.
8.	Additionally, on the boot.vhd disk, is a program which demonstrated how to load a font -
	IBMFONT.BAS. Run it and it maps a font much like the IBM font to the 80 column format.
	Also, a file called TESTRTC.BAS pulls the MiSTer RTC values exposed in BASIC to display
	a clock.
9.	Large improvement in the Timer function.  Code closer emulates COCO3 Timer. Fixes
	Sliphead cart.
10.	In the 20231023 release the wd1773 instances were reduced to 1 for the FDC and one for
	the FDC.  This saved space but introduced a bug when using multiple drives at the same
	time - like a copy command.  This change was removed and the copy command works again.

To Do...
1.	Add Speech / Music cart
2.	Fix Castle of Tharoggad
2024-05-14 23:00:16 -04:00

118 lines
2.0 KiB
Verilog

module cassette(
input clk,
input Q,
input rewind,
input en,
output reg [15:0] sdram_addr,
input [7:0] sdram_data,
// output reg sdram_rd,
output data
// output [2:0] status
);
//assign status = state;
reg old_en;
reg ffrewind;
reg [23:0] seq;
reg [7:0] ibyte;
reg [2:0] state;
reg sq_start;
reg [1:0] eof;
reg name;
wire done;
reg [18:0] hold;
parameter
IDLE = 3'h0,
NEXT = 3'h2,
READ1 = 3'h3,
READ2 = 3'h4,
READ3 = 3'h5,
READ4 = 3'h6,
WAIT = 3'h7;
reg q_r;
always @(posedge clk) begin
if (Q==1 && q_r ==0) begin
old_en <= en;
if (old_en ^ en) begin
state <= state == IDLE ? WAIT : IDLE;
hold <= 19'd445000;
seq <= 24'd0;
end
ffrewind <= rewind;
case (state)
WAIT: begin
ibyte <= 8'd0;
hold <= hold - 19'd1;
state <= hold == 0 ? NEXT : WAIT;
end
NEXT: begin
state <= READ1;
// sdram_rd <= 1'b0;
if (seq == 24'h553c00) name <= 1'd1;
if (seq == 24'h555555 && name) begin
name <= 1'd0;
state <= WAIT;
hold <= 19'd445000; // 0.5s
sdram_addr <= sdram_addr - 16'd3;
end
if (seq == 24'h553cff) eof <= 2'd1;
if (seq == 24'h00ff55 && eof == 2'd1) eof <= 2'd2;
if (~en) state <= IDLE;
end
READ1: begin
// sdram_rd <= 1'b1;
state <= READ2;
end
READ2: begin
ibyte <= sdram_data;
// sdram_rd <= 1'b0;
state <= READ3;
sq_start <= 1'b1;
end
READ3: begin
sq_start <= 1'b0;
state <= done ? READ4 : READ3;
end
READ4: begin
seq <= { seq[15:0], sdram_data };
sdram_addr <= sdram_addr + 16'd1;
state <= eof == 2'd2 ? IDLE : NEXT;
end
endcase
if (ffrewind ^ rewind) begin
seq <= 24'd0;
sdram_addr <= 16'd0;
state <= IDLE;
eof <= 2'd0;
end
end
q_r <= Q;
end
square_gen sq(
.clk(clk),
.Q(Q),
.start(sq_start),
.din(ibyte),
.done(done),
.dout(data)
);
endmodule