diff --git a/cores/c64/rtl/mist/c64_mist.vhd b/cores/c64/rtl/mist/c64_mist.vhd index 5d978f3..51f8fe3 100644 --- a/cores/c64/rtl/mist/c64_mist.vhd +++ b/cores/c64/rtl/mist/c64_mist.vhd @@ -207,6 +207,13 @@ component user_io generic(STRLEN : integer := 0 ); port ); end component user_io; +-- constants for ioctl_index +constant FILE_BOOT : std_logic_vector(7 downto 0) := x"00"; -- ROM files sent at boot time +constant FILE_PRG : std_logic_vector(7 downto 0) := x"02"; +constant FILE_TAP : std_logic_vector(7 downto 0) := x"42"; +constant FILE_CRT : std_logic_vector(7 downto 0) := x"82"; +constant FILE_ROM : std_logic_vector(7 downto 0) := x"03"; + component data_io port ( clk_sys : in std_logic; @@ -542,6 +549,12 @@ end component cartridge; signal force_erase : std_logic; signal erase_to : std_logic_vector(4 downto 0) := (others => '0'); signal mem_ce : std_logic; + + -- sdram layout + constant C64_MEM_START : std_logic_vector(24 downto 0) := '0' & X"000000"; -- normal C64 RAM + constant CRT_MEM_START : std_logic_vector(24 downto 0) := '0' & X"100000"; -- cartdriges + constant TAP_MEM_START : std_logic_vector(24 downto 0) := '0' & X"200000"; -- .tap files + begin -- 1541/tape activity led @@ -624,7 +637,7 @@ begin ioctl_dout => ioctl_data ); - cart_loading <= '1' when ioctl_download = '1' and ioctl_index = x"82" else '0'; + cart_loading <= '1' when ioctl_download = '1' and ioctl_index = FILE_CRT else '0'; cart : cartridge port map ( @@ -714,7 +727,7 @@ begin end if; if ioctl_wr='1' then - if ioctl_index = x"02" then--prg + if ioctl_index = FILE_PRG then if ioctl_addr = 0 then ioctl_load_addr(7 downto 0) <= ioctl_data; elsif(ioctl_addr = 1) then @@ -724,9 +737,9 @@ begin end if; end if; - if ioctl_index = x"82" then--CRT, e0(MAX) + if ioctl_index = FILE_CRT then -- e0(MAX) if ioctl_addr = 0 then - ioctl_load_addr <= '0' & X"100000"; + ioctl_load_addr <= CRT_MEM_START; cart_blk_len <= (others => '0'); cart_hdr_cnt <= (others => '0'); end if; @@ -766,9 +779,9 @@ begin end if; end if; - if ioctl_index = x"42" then -- TAP + if ioctl_index = FILE_TAP then if ioctl_addr = 0 then - ioctl_load_addr <= '0' & X"200000"; + ioctl_load_addr <= TAP_MEM_START; ioctl_ram_data <= ioctl_data; end if; ioctl_ram_wr <= '1'; @@ -776,7 +789,7 @@ begin end if; - if old_download /= ioctl_download and ioctl_index = x"82" then + if old_download /= ioctl_download and ioctl_index = FILE_CRT then cart_attached <= old_download; erase_cram <= '1'; end if; @@ -804,9 +817,9 @@ begin end if; end process; - c64rom_wr <= ioctl_wr when (((ioctl_index = 0) and (ioctl_addr(14) = '0')) or (ioctl_index = 3)) and (ioctl_download = '1') else '0'; - c64rom_addr <= ioctl_addr(13 downto 0) when ioctl_index = 0 else '1' & ioctl_addr(12 downto 0); - c1541rom_wr <= ioctl_wr when (ioctl_index = 0) and (ioctl_addr(14) = '1') and (ioctl_download = '1') else '0'; + c64rom_wr <= ioctl_wr when (((ioctl_index = FILE_BOOT) and (ioctl_addr(14) = '0')) or (ioctl_index = FILE_ROM)) and (ioctl_download = '1') else '0'; + c64rom_addr <= ioctl_addr(13 downto 0) when ioctl_index = FILE_BOOT else '1' & ioctl_addr(12 downto 0); + c1541rom_wr <= ioctl_wr when (ioctl_index = FILE_BOOT) and (ioctl_addr(14) = '1') and (ioctl_download = '1') else '0'; process(clk_c64) begin @@ -941,7 +954,7 @@ begin reset_counter <= 1000000; reset_n <= '0'; elsif buttons(1)='1' or st_detach_cartdrige='1' or reset_key = '1' or reset_crt='1' or - (ioctl_download='1' and (ioctl_index = 3 or ioctl_index = x"82")) then -- kernal or crt + (ioctl_download='1' and (ioctl_index = FILE_ROM or ioctl_index = FILE_CRT)) then reset_counter <= 255; reset_n <= '0'; elsif ioctl_download ='1' then @@ -1214,21 +1227,21 @@ begin -- TAP playback controller cass_sense <= not tap_play; - tap_play_btn <= st_tap_play_btn; - + tap_play_btn <= st_tap_play_btn; + process(clk_c64, reset_n) begin if reset_n = '0' then - tap_play_addr <= '0' & X"200000"; - tap_last_addr <= '0' & X"200000"; + tap_play_addr <= TAP_MEM_START; + tap_last_addr <= TAP_MEM_START; tap_play <= '0'; tap_reset <= '1'; tap_mem_ce <= '0'; elsif rising_edge(clk_c64) then tap_reset <= '0'; - if ioctl_download = '1' and ioctl_index = x"42" then + if ioctl_download = '1' and ioctl_index = FILE_TAP then tap_play <= '0'; - tap_play_addr <= '0' & X"200000"; + tap_play_addr <= TAP_MEM_START; tap_last_addr <= ioctl_load_addr; tap_reset <= '1'; if ioctl_addr = x"00000C" and ioctl_wr = '1' then