diff --git a/Source/QuartusProject/Max10_SD/atari_rom.vhd b/Source/QuartusProject/Max10_SD/atari_rom.vhd index 13a0c7f..e7fe240 100644 --- a/Source/QuartusProject/Max10_SD/atari_rom.vhd +++ b/Source/QuartusProject/Max10_SD/atari_rom.vhd @@ -87,6 +87,7 @@ ARCHITECTURE structure OF atari_rom IS constant CART_TYPE_TURBOSOFT : integer := 36; constant CART_TYPE_ATRAX_128K : integer := 37; constant CART_TYPE_4K : integer := 38; + constant CART_TYPE_DCART : integer := 39; constant CART_TYPE_XEX : integer := 254; constant CART_TYPE_NONE : integer := 255; @@ -125,6 +126,9 @@ ARCHITECTURE structure OF atari_rom IS -- SIC d500 byte signal sic_d500_byte : std_logic_vector(7 downto 0); signal sic_read_d500 : boolean := false; + + -- DCART read + signal dcart_read_d500 : boolean := false; -- XEX access signal file_offset: std_logic_vector(15 downto 0); @@ -207,7 +211,7 @@ BEGIN CART_RD5 <= high_bank_enabled; CART_RD4 <= low_bank_enabled; - CART_DATA <= data_out when ((CART_S5 = '0' and high_bank_enabled = '1') or (CART_S4 = '0' and low_bank_enabled = '1') or (CART_CTL = '0' and (sic_read_d500 or xex_read_d500))) + CART_DATA <= data_out when ((CART_S5 = '0' and high_bank_enabled = '1') or (CART_S4 = '0' and low_bank_enabled = '1') or (CART_CTL = '0' and (sic_read_d500 or xex_read_d500 or dcart_read_d500))) else "ZZZZZZZZ"; sram_cart_bus_enabled <= '0' when cart_type = CART_TYPE_BOOT else '1'; @@ -227,6 +231,9 @@ BEGIN -- SIC D500-D51F read ? sic_read_d500 <= (cart_type = CART_TYPE_SIC and CART_CTL = '0' and CART_RW = '1' and CART_ADDR(7 downto 5) = "000"); + -- DCART D500-D5FF read? + dcart_read_d500 <= (cart_type = CART_TYPE_DCART and CART_CTL = '0' and CART_RW = '1'); + -- XEX D500-D5FF read ? xex_read_d500 <= (cart_type = CART_TYPE_XEX and CART_CTL = '0' and CART_RW = '1'); end if; @@ -404,6 +411,10 @@ BEGIN bank_out <= "00" & CART_DATA(4 downto 0); sic_d500_byte <= CART_DATA; end if; + -- DCART bankswitching + when CART_TYPE_DCART => + high_bank_enabled <= not cart_addr_reg(7); + bank_out <= '0' & cart_addr_reg(5 downto 0); -- xex loader support - D500,D501 are lo-byte hi-byte of file offset (in 256 byte chunks) when CART_TYPE_XEX => if (cart_addr_reg(7 downto 0) = x"00") then @@ -450,7 +461,7 @@ BEGIN -- When we get a new address from the cartridge port, set up the RAM address bus -- to get the correct data process (cart_addr_reg, cart_s4_reg, cart_s5_reg, cart_ctl_reg, - cart_type, bank_out, bounty_bob_bank8, bounty_bob_bank9, oss_bank) + cart_type, bank_out, bounty_bob_bank8, bounty_bob_bank9, oss_bank,dcart_read_d500) begin fpga_address_in <= (others => '0'); sram_address_in <= (others => '0'); @@ -467,7 +478,7 @@ BEGIN elsif (cart_type /= CART_TYPE_NONE) then - if (cart_s5_reg = '0' or cart_s4_reg = '0') then + if (cart_s5_reg = '0' or cart_s4_reg = '0' or dcart_read_d500) then sram_ce <= '1'; end if; @@ -541,6 +552,11 @@ BEGIN end if; when CART_TYPE_4k => sram_address_in <= "00000000" & cart_addr_reg(11 downto 0); -- 0xB000 access + when CART_TYPE_DCART => + if dcart_read_d500 then + -- Map to what is B5xx + sram_address_in <= bank_out & "10101" & cart_addr_reg(7 downto 0); + end if; when others => null; end case; diff --git a/Source/QuartusProject/Max10_SD/software/sdcard/ultimate.c b/Source/QuartusProject/Max10_SD/software/sdcard/ultimate.c index d277142..8aabc5b 100644 --- a/Source/QuartusProject/Max10_SD/software/sdcard/ultimate.c +++ b/Source/QuartusProject/Max10_SD/software/sdcard/ultimate.c @@ -69,6 +69,7 @@ static int ledVal = 0x1E; #define CART_TYPE_TURBOSOFT 36 // 64k,128k #define CART_TYPE_ATRAX_128K 37 // 128k #define CART_TYPE_4_K 38 // 4k +#define CART_TYPE_DCART 39 // 4k #define CART_TYPE_XEX 254 #define CART_TYPE_NONE 255 @@ -331,6 +332,7 @@ int load_cart(char *filename) cart_type = CART_TYPE_4_K; memset(dst32, 255, 4096); } + else if (car_type == 112) cart_type = CART_TYPE_DCART; else { cart_type = -2; break; } // unsupported car type bytesToCopy -= 16; src32 += 4;