Timing fixes, Video mode fixes, Sound cleanup, and enabling RS-232 to physical SNAC pins.

1.	Overlay support for the detection of no rom loading on power up AND misc
    debugging. [done]
2.	Fix video HSCREEN 4 mode which is used in some demos and rs-232 terminal
	programs. [done]
3.	Reworked sound output to faithfully emulate the analog muxing in the coco.
	[done]
4.	Routing RS-232 tx/rx lines to the SNAC port for initial serial debugging
	of Fuji-Net interface. [done - untested]
This commit is contained in:
shodge12 committed 2026-10-02 00:49:54 -04:00
1 parent 77ee8b8c8c
commit ede23da6b0
9 files changed
+750 -105

No files matched your search

+2 -2
View File
@@ -233,7 +233,7 @@ begin
st_2:
begin
if (timer[18] == 1'b1) // 300ms time passed
if (timer[17] == 1'b1) // 300ms time passed
begin
key_up_down <= RELEASE_KEY;
state <= st_3;
@@ -242,7 +242,7 @@ begin
st_3:
begin
if (timer[18] == 1'b0) // 300ms time passed
if (timer[17] == 1'b0) // 300ms time passed
begin
shift <= 1'b0;
timer_enable <= 1'b0;
+43 -19
View File
@@ -125,7 +125,9 @@ HBORDER,
VBORDER,
HBORDER_INT,
VBORDER_INT,
art
art,
PIXEL_COUNT,
LINE
);
input MASTER_CLK;
@@ -133,6 +135,11 @@ output PIX_CLK;
reg PIX_CLK;
input RESET_N;
output [10:0] PIXEL_COUNT;
reg [10:0] PIXEL_COUNT;
output [9:0] LINE;
reg [9:0] LINE;
output [9:0] COLOR;
reg [9:0] COLOR;
output HSYNC_N;
@@ -184,10 +191,8 @@ reg VBORDER_INT;
input [1:0] art;
//reg HBLANKING;
reg [9:0] LINE;
reg [3:0] VLPR;
//reg [3:0] COCO_VLPR;
reg [10:0] PIXEL_COUNT;
reg [15:0] CHAR_LATCH_0_TMP;
reg [15:0] CHAR_LATCH_1_TMP;
reg [15:0] CHAR_LATCH_2_TMP;
@@ -1508,22 +1513,41 @@ assign PIXEL_X =
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11110101001) ? {6'h00,CHAR_LATCH_0[9:8]}:
//4 Color 512/640 = 640/4 = 160
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00000101101) ? {6'h00,CHAR_LATCH_0[7:6]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00010101101) ? {6'h00,CHAR_LATCH_0[7:6]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00100101101) ? {6'h00,CHAR_LATCH_0[5:4]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00110101101) ? {6'h00,CHAR_LATCH_0[5:4]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01000101101) ? {6'h00,CHAR_LATCH_0[3:2]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01010101101) ? {6'h00,CHAR_LATCH_0[3:2]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01100101101) ? {6'h00,CHAR_LATCH_0[1:0]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01110101101) ? {6'h00,CHAR_LATCH_0[1:0]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10000101101) ? {6'h00,CHAR_LATCH_0[15:14]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10010101101) ? {6'h00,CHAR_LATCH_0[15:14]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10100101101) ? {6'h00,CHAR_LATCH_0[13:12]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10110101101) ? {6'h00,CHAR_LATCH_0[13:12]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11000101101) ? {6'h00,CHAR_LATCH_0[11:10]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11010101101) ? {6'h00,CHAR_LATCH_0[11:10]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11100101101) ? {6'h00,CHAR_LATCH_0[9:8]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11110101101) ? {6'h00,CHAR_LATCH_1[9:8]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00000101101) ? {6'h00,CHAR_LATCH_0[7:6]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00010101101) ? {6'h00,CHAR_LATCH_0[7:6]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00100101101) ? {6'h00,CHAR_LATCH_0[5:4]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00110101101) ? {6'h00,CHAR_LATCH_0[5:4]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01000101101) ? {6'h00,CHAR_LATCH_0[3:2]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01010101101) ? {6'h00,CHAR_LATCH_0[3:2]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01100101101) ? {6'h00,CHAR_LATCH_0[1:0]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01110101101) ? {6'h00,CHAR_LATCH_0[1:0]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10000101101) ? {6'h00,CHAR_LATCH_0[15:14]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10010101101) ? {6'h00,CHAR_LATCH_0[15:14]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10100101101) ? {6'h00,CHAR_LATCH_0[13:12]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10110101101) ? {6'h00,CHAR_LATCH_0[13:12]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11000101101) ? {6'h00,CHAR_LATCH_0[11:10]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11010101101) ? {6'h00,CHAR_LATCH_0[11:10]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11100101101) ? {6'h00,CHAR_LATCH_0[9:8]}:
//({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11110101101) ? {6'h00,CHAR_LATCH_1[9:8]}:
// Update by G. Becker on 4/18/26 to fix HSCREEN 4 mode (640 x 192) 4 color mode.
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00000101101) ? {6'h00,CHAR_LATCH_0[7:6]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00010101101) ? {6'h00,CHAR_LATCH_0[5:4]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00100101101) ? {6'h00,CHAR_LATCH_0[3:2]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00110101101) ? {6'h00,CHAR_LATCH_0[1:0]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01000101101) ? {6'h00,CHAR_LATCH_0[15:14]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01010101101) ? {6'h00,CHAR_LATCH_0[13:12]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01100101101) ? {6'h00,CHAR_LATCH_0[11:10]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b01110101101) ? {6'h00,CHAR_LATCH_0[9:8]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10000101101) ? {6'h00,CHAR_LATCH_1[7:6]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10010101101) ? {6'h00,CHAR_LATCH_1[5:4]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10100101101) ? {6'h00,CHAR_LATCH_1[3:2]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b10110101101) ? {6'h00,CHAR_LATCH_1[1:0]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11000101101) ? {6'h00,CHAR_LATCH_1[15:14]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11010101101) ? {6'h00,CHAR_LATCH_1[13:12]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11100101101) ? {6'h00,CHAR_LATCH_1[11:10]}:
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b11110101101) ? {6'h00,CHAR_LATCH_1[9:8]}:
//16 Color 32/40 = 40/2 = 20
({PIXEL_COUNT[3:0],COCO1,BP,HRES[3:1],CRES} == 11'b00000100010) ? {4'h0,CHAR_LATCH_0[7:4]}:
+195
View File
@@ -0,0 +1,195 @@
--------------------------------------------------------------------------------
-- Overlay
--------------------------------------------------------------------------------
-- DO 10/2017
-- SH 5/15/26 Modified for COCO3
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY ovo IS
GENERIC (
COLS : natural :=32;
LINES : natural :=2;
RGB : unsigned(23 DOWNTO 0) :=x"FFFFFF";
H_OFFSET : natural :=4;
V_OFFSET : natural :=45
);
PORT (
-- VGA IN
i_r : IN unsigned(7 DOWNTO 0);
i_g : IN unsigned(7 DOWNTO 0);
i_b : IN unsigned(7 DOWNTO 0);
-- i_hs : IN std_logic;
-- i_vs : IN std_logic;
-- i_de : IN std_logic;
-- i_en : IN std_logic;
i_clk : IN std_logic;
i_Hcount : IN unsigned(10 DOWNTO 0);
i_VCount : IN unsigned(9 DOWNTO 0);
-- VGA_OUT
o_r : OUT unsigned(7 DOWNTO 0);
o_g : OUT unsigned(7 DOWNTO 0);
o_b : OUT unsigned(7 DOWNTO 0);
-- o_hs : OUT std_logic;
-- o_vs : OUT std_logic;
-- o_de : OUT std_logic;
-- Control
ena : IN std_logic; -- Overlay ON/OFF
-- Probes
in0 : IN unsigned(COLS*5-1 downto 0);
in1 : IN unsigned(COLS*5-1 downto 0)
);
END ENTITY ovo;
--##############################################################################
ARCHITECTURE rtl OF ovo IS
TYPE arr_slv8 IS ARRAY (natural RANGE <>) OF unsigned(7 DOWNTO 0);
CONSTANT chars : arr_slv8 :=(
x"3E", x"63", x"73", x"7B", x"6F", x"67", x"3E", x"00", -- 0
x"0C", x"0E", x"0C", x"0C", x"0C", x"0C", x"3F", x"00", -- 1
x"1E", x"33", x"30", x"1C", x"06", x"33", x"3F", x"00", -- 2
x"1E", x"33", x"30", x"1C", x"30", x"33", x"1E", x"00", -- 3
x"38", x"3C", x"36", x"33", x"7F", x"30", x"78", x"00", -- 4
x"3F", x"03", x"1F", x"30", x"30", x"33", x"1E", x"00", -- 5
x"1C", x"06", x"03", x"1F", x"33", x"33", x"1E", x"00", -- 6
x"3F", x"33", x"30", x"18", x"0C", x"0C", x"0C", x"00", -- 7
x"1E", x"33", x"33", x"1E", x"33", x"33", x"1E", x"00", -- 8
x"1E", x"33", x"33", x"3E", x"30", x"18", x"0E", x"00", -- 9
x"0C", x"1E", x"33", x"33", x"3F", x"33", x"33", x"00", -- A
x"3F", x"66", x"66", x"3E", x"66", x"66", x"3F", x"00", -- B
x"3C", x"66", x"03", x"03", x"03", x"66", x"3C", x"00", -- C
x"1F", x"36", x"66", x"66", x"66", x"36", x"1F", x"00", -- D
x"7F", x"46", x"16", x"1E", x"16", x"46", x"7F", x"00", -- E
x"7F", x"46", x"16", x"1E", x"16", x"06", x"0F", x"00", -- F
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", --' ' 10
x"00", x"00", x"3F", x"00", x"00", x"3F", x"00", x"00", -- = 11
x"00", x"0C", x"0C", x"3F", x"0C", x"0C", x"00", x"00", -- + 12
x"00", x"00", x"00", x"3F", x"00", x"00", x"00", x"00", -- - 13
x"18", x"0C", x"06", x"03", x"06", x"0C", x"18", x"00", -- < 14
x"06", x"0C", x"18", x"30", x"18", x"0C", x"06", x"00", -- > 15
x"08", x"1C", x"36", x"63", x"41", x"00", x"00", x"00", -- ^ 16
x"08", x"1C", x"36", x"63", x"41", x"00", x"00", x"00", -- v 17
x"18", x"0C", x"06", x"06", x"06", x"0C", x"18", x"00", -- ( 18
x"06", x"0C", x"18", x"18", x"18", x"0C", x"06", x"00", -- ) 19
x"00", x"0C", x"0C", x"00", x"00", x"0C", x"0C", x"00", -- : 1A
-- x"00", x"00", x"00", x"00", x"00", x"0C", x"0C", x"00", -- . 1B
-- x"00", x"00", x"00", x"00", x"00", x"0C", x"0C", x"06", -- , 1C
-- x"1E", x"33", x"30", x"18", x"0C", x"00", x"0C", x"00", -- ? 1D
-- x"18", x"18", x"18", x"00", x"18", x"18", x"18", x"00", -- | 1E
x"41", x"43", x"45", x"49", x"51", x"61", x"41", x"00", -- N 1B
x"3E", x"41", x"41", x"41", x"41", x"41", x"3E", x"00", -- O 1C
x"3F", x"41", x"41", x"3F", x"11", x"21", x"41", x"00", -- R 1D
x"41", x"63", x"55", x"49", x"41", x"41", x"41", x"00", -- M 1E
x"36", x"36", x"7F", x"36", x"7F", x"36", x"36", x"00"); -- # 1F
SIGNAL vcpt,hcpt,hcpt2 : natural RANGE 0 TO 4095;
SIGNAL vin0,vin1 : unsigned(0 TO COLS*5-1);
SIGNAL t_r,t_g,t_b : unsigned(7 DOWNTO 0);
SIGNAL t_hs,t_vs,t_de : std_logic;
SIGNAL col : unsigned(7 DOWNTO 0);
SIGNAL de : std_logic;
SIGNAL in0s,in1s : unsigned(in0'range);
BEGIN
in0s<=in0 WHEN rising_edge(i_clk);
in1s<=in1 WHEN rising_edge(i_clk);
----------------------------------------------------------
Megamix:PROCESS(i_clk) IS
VARIABLE vin_v : unsigned(0 TO 32*5-1);
VARIABLE char_v : unsigned(4 DOWNTO 0);
BEGIN
IF rising_edge(i_clk) THEN
--IF i_en='1' THEN
----------------------------------
-- Propagate VGA signals. 2 cycles delay
t_r<=i_r;
t_g<=i_g;
t_b<=i_b;
-- t_hs<=i_hs;
-- t_vs<=i_vs;
-- t_de<=i_de;
o_r<=t_r;
o_g<=t_g;
o_b<=t_b;
-- o_hs<=t_hs;
-- o_vs<=t_vs;
-- o_de<=t_de;
----------------------------------
-- Latch sampled values during vertical sync
-- IF i_vs='1' THEN
IF (i_Hcount="000000000" and i_VCount="000000000") THEN
vin0<=in0s;
vin1<=in1s;
END IF;
----------------------------------
-- IF i_vs='1' THEN
-- vcpt<=0;
-- de<='0';
-- ELSIF i_hs='1' AND t_hs='0' AND de='1' THEN
-- vcpt<=(vcpt+1) MOD 4096;
-- END IF;
-- if (i_Hcount < 148) then -- 148 = video left border
-- if (i_Hcount < 148) then -- 148 = video left border
if (i_Hcount < H_OFFSET) then -- 4 = video left border
hcpt <= COLS*8;
else
hcpt <= to_integer(i_Hcount)-H_OFFSET;
end if;
-- if (i_Vcount < 16) then
-- if (i_Vcount < 16) then
if (i_Vcount < V_OFFSET) then
vcpt <= 512;
else
vcpt <= to_integer(i_Vcount)-V_OFFSET;
end if;
----------------------------------
IF (vcpt/8) MOD 2=0 THEN
vin_v:=vin0;
ELSE
vin_v:=vin1;
END IF;
-- IF i_hs='1' THEN
-- hcpt<=0;
-- ELSIF i_de='1' THEN
-- hcpt<=(hcpt+1) MOD 4096;
-- de<='1';
-- END IF;
hcpt2<=hcpt;
----------------------------------
-- Pick characters
IF hcpt<COLS * 8 AND vcpt<LINES * 8 THEN
-- no=> need to reverse string so 0-4 is left (not right!)
char_v:=vin_v((hcpt/8)*5 TO (hcpt/8)*5+4);
-- char_v:=vin_v(((COLS-1) - (hcpt/8))*5 TO ((COLS-1) - (hcpt/8))*5+4);
ELSE
char_v:="10000"; -- " " : Blank character
END IF;
col<=chars(to_integer(char_v)*8+(vcpt MOD 8));
----------------------------------
-- Insert Overlay
IF ena='1' THEN
IF col(hcpt2 MOD 8)='1' THEN
o_r<=RGB(23 DOWNTO 16);
o_g<=RGB(15 DOWNTO 8);
o_b<=RGB( 7 DOWNTO 0);
END IF;
END IF;
--END IF;
END IF;
END PROCESS Megamix;
END ARCHITECTURE rtl;
+251 -56
View File
@@ -87,9 +87,9 @@ input COCO_RESET_N,
// Video
output reg [7:0] RED,
output reg [7:0] GREEN,
output reg [7:0] BLUE,
output reg [7:0] RED_O,
output reg [7:0] GREEN_O,
output reg [7:0] BLUE_O,
output reg H_SYNC,
output reg V_SYNC,
@@ -106,6 +106,8 @@ input ps2_data,
input [24:0] ps2_mouse,
input Display_Debug,
// RS-232
output UART_TXD,
input UART_RXD,
@@ -170,7 +172,8 @@ inout [7:0] GPIO,
// Misc
input EE_N,
input PHASE,
output [31:0] PROBE,
output [6:0] PROBE_O,
input [6:0] PROBE_I,
// Cassette Input linkage
output clk_Q_out,
@@ -685,18 +688,28 @@ rtc #(50000000) CC3_rtc(
// Probe's defined
//assign PROBE[6:0] = {CART1_POL, CART1_BUF_RESET_N, CART1_FIRQ_STAT_N, CART1_CLK_N, CART1_FIRQ_N, RESET_N, PH_2};
//assign PROBE[7:0] = {1'b0, CART1_POL, CART1_FIRQ_N, CART1_FIRQ_BUF[0], CART1_CLK_N_D, CART1_FIRQ_RESET_N, CART1_CLK_N, PH_2};
assign PROBE[7:0] = {1'b0, TMR_CLK, DATA_IN[5], RST_FF93_N_SFT[0], RST_FF93_N, !TIMER3_FIRQ_N, VSYNC_INT_N, TIMER_INT_N};
assign PROBE[15:8] = 8'h00;
assign PROBE[23:16] = 8'h00;
//assign PROBE[31:24] = {3'b000, DATA_OUT[3], MOTOR, DRIVE_SEL_EXT[0], HDD_EN, ADDRESS[0]};
assign PROBE[31:24] = {8'h00};
assign PROBE_O[6:0] = {TMR_CLK, DATA_IN[5], RST_FF93_N_SFT[0], RST_FF93_N, !TIMER3_FIRQ_N, 1'b1, UART_TXD};
assign clk_sys = CLK_57;
assign BUTTON_N[3:0] = {COCO_RESET_N, 2'b1,EE_N};
wire UART_TXD_I;
wire UART_RXD_I;
assign UART_TXD = SWITCH[4]? coco_rs232_out:
UART_TXD_I;
assign uart_input = SWITCH[8]? PROBE_I[1]:
UART_RXD;
wire uart_input;
assign coco_rs232_in = uart_input;
assign UART_RXD_I = uart_input;
/*****************************************************************************
* RAM signals
@@ -771,9 +784,9 @@ assign CART_SEL = (ADDRESS[15:8] == 8'b1
//11 32 External
assign FLASH_ADDRESS = ENA_DSK ? {9'b000000100, ADDRESS[12:0]}: //8K Disk BASIC 8K Slot 4
ENA_DISK2 ? {9'b000000100, ADDRESS[12:0]}: //[maps to same disk rom]
({ENA_PAK, ROM[1]} == 2'b10) ? {5'b00000,ROM_BANK, ADDRESS[13:0]}: //16K External R CART ROM
assign FLASH_ADDRESS = ENA_DSK ? {9'b000000000, ADDRESS[12:0]}: //8K Disk BASIC 8K Slot 4
ENA_DISK2 ? {9'b000000000, ADDRESS[12:0]}: //[maps to same disk rom]
({ENA_PAK, ROM[1]} == 2'b10) ? {5'b00000,ROM_BANK, ADDRESS[13:0]}: //16K External R CART ROM
({ENA_PAK, ROM} == 3'b111) ? {4'b0000,ROM_BANK, ~ADDRESS[14], ADDRESS[13:0]}: //32K External R CART ROM
{7'b0000000,ADDRESS[14:0]}; //32K Internal COCO3 ROM
@@ -804,6 +817,25 @@ wire COCO3_ROM_WRITE = (ioctl_index[7:0] == {BOOT0, BOOT}) & ioctl_wr;
wire COCO3_DISKROM_WRITE = (ioctl_index[7:0] == {BOOT1, BOOT}) & ioctl_wr;
wire COCO3_CART_WRITE = (ioctl_index[5:0] == 6'd1) & ioctl_wr & !cart_lock;
reg rom_loaded = 1'b0;
always @(negedge clk_sys)
begin
if({ioctl_addr[14], COCO3_ROM_WRITE} == 2'b11)
rom_loaded <= 1'b1;
end
// A decision.
// Looking at this logic it is fairly obvious that the 8Kx8 ROM is not needed.
// Physically (bus wise) it sits in the same place as the CART rom and is obviously
// smaller. I have made these changes at least twice during the development of
// this code. While it works and saves the resources of a 8kx8 sram, it does not
// work well from a systems perspective. With only 1 rom, when you load a cart
// then go back to a slot 2/4 disk system you have no os. So now you have to load
// boot1.bin as a cart from slot 3, then change back to 2/4 to restore dos. No real
// way to fix it. I could put dos at the top 8K of the 128K, then only 128K carts
// would cause a issue. But there still is an issue which would need to be explained.
// I choose not, along with this explanation why. SRH 5/29/26
COCO_ROM_32K CC3_ROM(
.ADDR(FLASH_ADDRESS[14:0]),
@@ -814,6 +846,8 @@ COCO_ROM_32K CC3_ROM(
.WRITE(COCO3_ROM_WRITE)
);
// DOS Cart for slot 2/4
COCO_ROM_8K CC3_DISK_ROM(
.ADDR(FLASH_ADDRESS[12:0]),
.DATA(COCO3_DISK_ROM_DATA),
@@ -824,10 +858,9 @@ COCO_ROM_8K CC3_DISK_ROM(
);
assign FLASH_DATA = ENA_PAK ? CART_DATA:
(FLASH_ADDRESS[15] == 1'b0) ? COCO3_ROM_DATA:
(FLASH_ADDRESS[15:13] == 3'b100) ? COCO3_DISK_ROM_DATA:
8'b00000000;
assign FLASH_DATA = ENA_PAK ? CART_DATA:
(ENA_DSK || ENA_DISK2) ? COCO3_DISK_ROM_DATA:
COCO3_ROM_DATA;
COCO_ROM_CART CC3_ROM_CART(
@@ -863,7 +896,10 @@ assign SDC_EN_CS = ({MPI_SCS, ADDRESS[15:5]} == 13'b0111111111010) ? 1'b1:
1'b0;
`endif
assign RS232_EN = ({MPI_SCS, ADDRESS[15:2]} == 16'b0011111111011010) ? 1'b1: //FF68-FF6B - Now in slot 1
//assign RS232_EN = ({MPI_SCS, ADDRESS[15:2]} == 16'b0011111111011010) ? 1'b1: //FF68-FF6B - Now in slot 1
// 1'b0 ;
assign RS232_EN = ({MPI_SCS[0], ADDRESS[15:2]} == 15'b111111111011010) ? 1'b1: //FF68-FF6B - Now in slot 2 and 4
1'b0;
assign SLOT3_HW = ({SWITCH[2:1], ADDRESS[15:5]} == 13'b1011111111010) ? 1'b1: // FF40-FF5F Ensure this only appears in slot 3 PHYSICALLY
@@ -1134,13 +1170,13 @@ assign DATA_REG2 = !DDR2 ? DD_REG2:
KEY_COLUMN;
assign DATA_REG3 = !DDR3 ? DD_REG3:
{DTOA_CODE, 1'b1, casdout};
{DTOA_CODE, coco_rs232_out, casdout};
// A 0 in the DDR makes that pin an input
assign BIT3 = !DD_REG4[3] ? 1'b0:
CSS;
assign DATA_REG4 = !DDR4 ? DD_REG4:
{VDG_CONTROL, BIT3, KEY_COLUMN[6], SBS, 1'b1};
{VDG_CONTROL, BIT3, KEY_COLUMN[6], SBS, coco_rs232_in};
/********************************************************************************
* GPIO
*********************************************************************************/
@@ -2642,6 +2678,9 @@ end
//end
reg sync_rst1;
reg coco_rs232_out;
wire coco_rs232_in;
wire coco_rs232_cd;
// Most of the latches for settings
always @ (negedge clk_sys or negedge RESET_N)
@@ -2667,6 +2706,7 @@ begin
SEL[1] <= 1'b0;
// FF20
DD_REG3 <= 8'h00;
coco_rs232_out <= 1'b0;
DTOA_CODE <= 6'b000000;
SOUND_DTOA <= 6'b000000;
// BBTXD <= 1'b0;
@@ -2855,8 +2895,9 @@ begin
case ({SOUND_EN,SEL})
3'b100:
SOUND_DTOA <= DTOA_CODE;
3'b111:
SOUND_DTOA <= 6'b000000;
// This is still no sound as it just holds the previous DTOA Value
// 3'b111:
// SOUND_DTOA <= 6'b000000;
endcase
if(!RW_N)
@@ -2931,6 +2972,7 @@ begin
DD_REG3 <= DATA_OUT;
else
begin
coco_rs232_out <= DATA_OUT[1];
DTOA_CODE <= DATA_OUT[7:2];
end
end
@@ -3511,7 +3553,12 @@ end
// Internal Sound generation
//assign SOUND = {SBS, 7'b0000000} + {SOUND_DTOA, SOUND_DTOA[5:4]};
assign SOUND = {SBS, SOUND_DTOA, SOUND_DTOA[5]};
//assign SOUND = {SBS, SOUND_DTOA, SOUND_DTOA[5]};
//assign SOUND = {SBS || SOUND_DTOA[5], SOUND_DTOA[4:0], SOUND_DTOA[1:0]};
// Ver 3 of the sound arch
assign SOUND = SOUND_EN ? {SOUND_DTOA, 2'b00}:
{SBS,SBS,SBS,SBS,SBS,SBS, 2'b00};
assign SOUND_LEFT = {ORCH_LEFT, ORCH_LEFT} + {SOUND, SOUND};
assign SOUND_RIGHT = {ORCH_RIGHT, ORCH_RIGHT} + {SOUND, SOUND};
@@ -3817,24 +3864,40 @@ wire PIX_CLK_D;
// The VBOARDER is used as a VBLANK as is [inverted]
reg [3:0] MISTER_HBLANK_D;
assign HBLANK = MISTER_HBLANK_D[2]; // This is 2 clock delay on the ~HBORDER...
assign HBLANK_ORG = MISTER_HBLANK_D[2]; // This is 2 clock delay on the ~HBORDER...
// KEY: 01/14/26
//assign HBLANK = MISTER_HBLANK_D[2]; // This is 2 clock delay on the ~HBORDER...
//assign VBLANK = ~VBORDER;
wire VBLANK_PRIME;
assign VBLANK = ~VBLANK_PRIME;
assign RED[3:0] = RED[7:4];
assign GREEN[3:0] = GREEN[7:4];
assign BLUE[3:0] = BLUE[7:4];
assign VBLANK_ORG = ~VBLANK_PRIME;
// KEY: 01/14/26
//assign VBLANK = ~VBLANK_PRIME;
assign RED_ORG[3:0] = RED_ORG[7:4];
assign GREEN_ORG[3:0] = GREEN_ORG[7:4];
assign BLUE_ORG[3:0] = BLUE_ORG[7:4];
// KEY: 01/14/26
//assign RED[3:0] = RED[7:4];
//assign GREEN[3:0] = GREEN[7:4];
//assign BLUE[3:0] = BLUE[7:4];
// Video DAC
always @ (negedge clk_sys)
begin
PIX_CLK_D <= PIX_CLK;
if (PIX_CLK == 1'b1 & PIX_CLK_D == 1'b0)
// PIX_CLK_D <= PIX_CLK;
// if (PIX_CLK == 1'b1 & PIX_CLK_D == 1'b0)
// KEY: 01/14/26
PIX_CLK_D <= PIX_CLK_ORG;
if (PIX_CLK_ORG == 1'b1 & PIX_CLK_D == 1'b0)
begin
COLOR_BUF <= COLOR; // Delay COLOR by 1 clock cycle to align with 256 Color SRAM
H_SYNC <= !H_SYNC_N; // Delay H_SYNC by 1 clock cycle
V_SYNC <= !V_SYNC_N; // Delay V_SYNC by 1 clock cycle
H_SYNC_ORG <= !H_SYNC_N; // Delay H_SYNC by 1 clock cycle
V_SYNC_ORG <= !V_SYNC_N; // Delay V_SYNC by 1 clock cycle
// H_SYNC <= !H_SYNC_N; // Delay H_SYNC by 1 clock cycle
// V_SYNC <= !V_SYNC_N; // Delay V_SYNC by 1 clock cycle
// KEY: 01/14/26
// RED[3:0] <= 4'B0000;
// GREEN[3:0] <= 4'B0000;
// BLUE[3:0] <= 4'B0000;
@@ -3846,27 +3909,48 @@ begin
if(COLOR_BUF[8])
begin
{RED[7], GREEN[7], BLUE[7], RED[6], GREEN[6], BLUE[6], RED[5], GREEN[5], BLUE[5], RED[4], GREEN[4], BLUE[4]} <= VDAC_OUT[11:0];
// KEY: 01/14/26
// {RED[7], GREEN[7], BLUE[7], RED[6], GREEN[6], BLUE[6], RED[5], GREEN[5], BLUE[5], RED[4], GREEN[4], BLUE[4]} <= VDAC_OUT[11:0];
{RED_ORG[7], GREEN_ORG[7], BLUE_ORG[7], RED_ORG[6], GREEN_ORG[6], BLUE_ORG[6], RED_ORG[5], GREEN_ORG[5], BLUE_ORG[5], RED_ORG[4], GREEN_ORG[4], BLUE_ORG[4]} <= VDAC_OUT[11:0];
end
else
begin
RED[7] <= PALETTE[COLOR_BUF[4:0]][11];
RED[6] <= PALETTE[COLOR_BUF[4:0]][8];
RED[5] <= PALETTE[COLOR_BUF[4:0]][5];
RED[4] <= PALETTE[COLOR_BUF[4:0]][2];
GREEN[7] <= PALETTE[COLOR_BUF[4:0]][10];
GREEN[6] <= PALETTE[COLOR_BUF[4:0]][7];
GREEN[5] <= PALETTE[COLOR_BUF[4:0]][4];
GREEN[4] <= PALETTE[COLOR_BUF[4:0]][1];
BLUE[7] <= PALETTE[COLOR_BUF[4:0]][9];
BLUE[6] <= PALETTE[COLOR_BUF[4:0]][6];
BLUE[5] <= PALETTE[COLOR_BUF[4:0]][3];
BLUE[4] <= PALETTE[COLOR_BUF[4:0]][0];
// KEY: 01/14/26
// RED[7] <= PALETTE[COLOR_BUF[4:0]][11];
// RED[6] <= PALETTE[COLOR_BUF[4:0]][8];
// RED[5] <= PALETTE[COLOR_BUF[4:0]][5];
// RED[4] <= PALETTE[COLOR_BUF[4:0]][2];
// GREEN[7] <= PALETTE[COLOR_BUF[4:0]][10];
// GREEN[6] <= PALETTE[COLOR_BUF[4:0]][7];
// GREEN[5] <= PALETTE[COLOR_BUF[4:0]][4];
// GREEN[4] <= PALETTE[COLOR_BUF[4:0]][1];
// BLUE[7] <= PALETTE[COLOR_BUF[4:0]][9];
// BLUE[6] <= PALETTE[COLOR_BUF[4:0]][6];
// BLUE[5] <= PALETTE[COLOR_BUF[4:0]][3];
// BLUE[4] <= PALETTE[COLOR_BUF[4:0]][0];
// end
// RED[4] = RED[6];
// GREEN[4] = GREEN[6];
// BLUE[5] = BLUE[7];
// BLUE[4] = BLUE[6];
RED_ORG[7] <= PALETTE[COLOR_BUF[4:0]][11];
RED_ORG[6] <= PALETTE[COLOR_BUF[4:0]][8];
RED_ORG[5] <= PALETTE[COLOR_BUF[4:0]][5];
RED_ORG[4] <= PALETTE[COLOR_BUF[4:0]][2];
GREEN_ORG[7] <= PALETTE[COLOR_BUF[4:0]][10];
GREEN_ORG[6] <= PALETTE[COLOR_BUF[4:0]][7];
GREEN_ORG[5] <= PALETTE[COLOR_BUF[4:0]][4];
GREEN_ORG[4] <= PALETTE[COLOR_BUF[4:0]][1];
BLUE_ORG[7] <= PALETTE[COLOR_BUF[4:0]][9];
BLUE_ORG[6] <= PALETTE[COLOR_BUF[4:0]][6];
BLUE_ORG[5] <= PALETTE[COLOR_BUF[4:0]][3];
BLUE_ORG[4] <= PALETTE[COLOR_BUF[4:0]][0];
end
RED[4] = RED[6];
GREEN[4] = GREEN[6];
BLUE[5] = BLUE[7];
BLUE[4] = BLUE[6];
RED_ORG[4] = RED_ORG[6];
GREEN_ORG[4] = GREEN_ORG[6];
BLUE_ORG[5] = BLUE_ORG[7];
BLUE_ORG[4] = BLUE_ORG[6];
end
end
@@ -3874,7 +3958,9 @@ end
VDAC VDAC_inst (
.data ( {4'h0,PALETTE[0][11:0]} ),
.rdaddress ( COLOR[7:0] ),
.rdclock ( PIX_CLK ),
.rdclock ( PIX_CLK_ORG ),
// .rdclock ( PIX_CLK ),
// KEY: 01/14/26
.wraddress ( DATA_OUT ),
.wrclock ( clk_sys ),
.wren ( VDAC_EN & PH_2 ),
@@ -3890,11 +3976,35 @@ wire VBLANK_1;
wire HBLANK_1;
wire double, buff_bank;
//
// Sync to pos edge of ck_sys
// Key: 01/14/26
//
reg HBLANK_ORG, VBLANK_ORG, PIX_CLK_ORG, H_SYNC_ORG, V_SYNC_ORG;
reg [7:0] RED_ORG;
reg [7:0] GREEN_ORG;
reg [7:0] BLUE_ORG;
always @ (posedge clk_sys)
begin
HBLANK <= HBLANK_ORG;
VBLANK <= VBLANK_ORG;
PIX_CLK <= PIX_CLK_ORG;
H_SYNC <= H_SYNC_ORG;
V_SYNC <= V_SYNC_ORG;
RED <= RED_ORG;
GREEN <= GREEN_ORG;
BLUE <= BLUE_ORG;
end
// Video timing and modes
COCO3VIDEO MISTER_COCOVID(
// Clocks / RESET
.MASTER_CLK(clk_sys),
.PIX_CLK(PIX_CLK), //14.32 MHz = 69.3 nS
.PIX_CLK(PIX_CLK_ORG), //14.32 MHz = 69.3 nS
.RESET_N(RESET_N),
// Video Out
@@ -3952,9 +4062,15 @@ COCO3VIDEO MISTER_COCOVID(
.HBORDER(HBORDER),
.VBORDER(VBORDER),
.art(SWITCH[7:6])
.art(SWITCH[7:6]),
.PIXEL_COUNT(PIXEL_COUNT),
.LINE(LINE)
);
reg [10:0] PIXEL_COUNT;
reg [9:0] LINE;
parameter SHDOW_FONT_LOCK_REG = 16'hfff0;
parameter SHDOW_FONT_DATA_REG = 16'hfff1;
@@ -4066,7 +4182,9 @@ coco3_Char_ROM coco3_Char_ROM(
.WE(((ioctl_index[5:0] == 6'd3) & ioctl_wr) | Font_ROM_Mach_WE), // Can be just Font_ROM_Mach_WE if no MISTer
.ADDR_W(Font_ROM_Adrs_Buf),
.DATA_W(Font_ROM_Data_Buf),
.RD_CLK(PIX_CLK),
.RD_CLK(PIX_CLK_ORG),
// .RD_CLK(PIX_CLK),
// KEY: 01/14/26
.ADDR_R({(COCO1 ^ Font_ROM_Upper_Select), font_adrs}),
.DATA_R(font_data)
);
@@ -4114,8 +4232,8 @@ glb6551 RS232(
.CS({1'b0, RS232_EN}),
.RW_N(RW_N),
.RS(ADDRESS[1:0]),
.TXDATA_OUT(UART_TXD),
.RXDATA_IN(UART_RXD),
.TXDATA_OUT(UART_TXD_I),
.RXDATA_IN(UART_RXD_I),
.RTS(UART_RTS),
.CTS(UART_CTS),
.DCD(1'b1),
@@ -4150,5 +4268,82 @@ Cassette_Write CoCo3_Cassette_Write(
.sd_buff_wr(sd_buff_wr)
);
wire [7:0] RED;
wire [7:0] GREEN;
wire [7:0] BLUE;
assign RED_O = RED | CN_R;
assign GREEN_O = GREEN;
assign BLUE_O = BLUE;
wire [159:0]NOrom1;
wire [159:0]NOrom2;
reg [7:0] CN_R ;
reg pixel_clk_d, clk_7Mhz;
always @ (negedge clk_sys)
begin
pixel_clk_d <= PIX_CLK_ORG;
if (PIX_CLK_ORG==1'b1 && pixel_clk_d==1'b0)
clk_7Mhz <= !clk_7Mhz;
end
ovo #(.COLS(32), .LINES(23)) NOROMOVO
(
.i_r(8'd0),
.i_g(8'd0),
.i_b(8'd0),
.i_clk(PIX_CLK_ORG),
.i_Hcount({1'b0, PIXEL_COUNT[10:1]}),
.i_VCount(LINE),
.o_r(CN_R),
.ena(Display_Debug || ((!rom_loaded) && SEC[0])),
.in0(NOrom1),
.in1(NOrom2)
);
assign NOrom2 = {
{32{5'b10000}}
};
assign NOrom1 = {
//{17{5'b10000}},
5'b10000, // space
5'b11011, // N
5'b11100, // O
5'b10000, // space
5'b11101, // R
5'b11100, // O
5'b11110, // M
5'b10000, // space
5'b10011, // -
5'b10000, // space
5'b11011, // N
5'b11100, // O
5'b10000, // space
5'b11101, // R
5'b11100, // O
5'b11110, // M
5'b10000, // space
5'b11011, // N
5'b11100, // O
5'b10000, // space
5'b11101, // R
5'b11100, // O
5'b11110, // M
5'b10000, // space
5'b10011, // -
5'b10000, // space
5'b11011, // N
5'b11100, // O
5'b10000, // space
5'b11101, // R
5'b11100, // O
5'b11110 // M
};
endmodule