Skip to content

Commit

Permalink
Merge pull request #2 from vossstef/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vossstef authored Oct 17, 2024
2 parents 4a8ff2e + 019c54c commit 0e0a932
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 51 deletions.
93 changes: 51 additions & 42 deletions src/A2601top.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ entity A2601top is
p_color : in std_logic;

sc : in std_logic; --SuperChip enable
force_bs : in std_logic_vector(3 downto 0); -- forced bank switch type
force_bs : in std_logic_vector(4 downto 0); -- forced bank switch type
rom_a : out std_logic_vector(15 downto 0);
rom_do : in std_logic_vector(7 downto 0);
rom_size : in std_logic_vector(16 downto 0);
Expand Down Expand Up @@ -127,7 +127,7 @@ signal sc_d_out: std_logic_vector(7 downto 0);
signal sc_a: std_logic_vector(10 downto 0);
signal clr_a: std_logic_vector(10 downto 0);

subtype bss_type is std_logic_vector(3 downto 0);
subtype bss_type is std_logic_vector(4 downto 0);

signal bank: std_logic_vector(3 downto 0) := "0000";
signal banks32: std_logic_vector(4 downto 0) := "00000";
Expand All @@ -138,29 +138,37 @@ signal e0_bank0: std_logic_vector(2 downto 0) := "000";
signal e0_bank1: std_logic_vector(2 downto 0) := "000";
signal e0_bank2: std_logic_vector(2 downto 0) := "000";

signal FE_latch: std_logic;
signal FE_latch: std_logic := '0';

signal e7_bank0: std_logic_vector(2 downto 0); -- 1000-17ff
signal e7_rambank: std_logic_vector(1 downto 0); -- 1800-19ff

signal cpu_a: std_logic_vector(12 downto 0);
signal cpu_d: std_logic_vector(7 downto 0);

constant BANK00: bss_type := "0000";
constant BANKF8: bss_type := "0001";
constant BANKF6: bss_type := "0010";
constant BANKFE: bss_type := "0011";
constant BANKE0: bss_type := "0100";
constant BANK3F: bss_type := "0101";
constant BANKF4: bss_type := "0110";
constant BANKP2: bss_type := "0111";
constant BANKFA: bss_type := "1000";
constant BANKCV: bss_type := "1001";
constant BANK2K: bss_type := "1010";
constant BANKUA: bss_type := "1011";
constant BANKE7: bss_type := "1100";
constant BANKF0: bss_type := "1101";
constant BANK32: bss_type := "1110";
constant BANK00: bss_type := "00000";
constant BANKF8: bss_type := "00001";
constant BANKF6: bss_type := "00010";
constant BANKFE: bss_type := "00011";
constant BANKE0: bss_type := "00100";
constant BANK3F: bss_type := "00101";
constant BANKF4: bss_type := "00110";
constant BANKP2: bss_type := "00111";
constant BANKFA: bss_type := "01000"; -- CBS RAM Plus 12k
constant BANKCV: bss_type := "01001";
constant BANK2K: bss_type := "01010";
constant BANKUA: bss_type := "01011";
constant BANKE7: bss_type := "01100"; -- M-network 16k
constant BANKF0: bss_type := "01101"; -- Megaboy 64K
constant BANK32: bss_type := "01110"; -- Multicart
constant BANKAR: bss_type := "01111"; -- Aracdia Super charger
constant BANK3E: bss_type := "10000"; -- 512K ROM 256k RAM
constant BANKSB: bss_type := "10001"; -- Super Banking
constant BANKWD: bss_type := "10010";
constant BANKEF: bss_type := "10011"; -- 16k
constant BANKDPCP:bss_type := "10100"; -- Harmony DPC+
constant BANKCTY: bss_type := "10101";
constant BANKCDF: bss_type := "10110";

signal bss: bss_type := BANK00; --bank switching method

Expand Down Expand Up @@ -516,7 +524,8 @@ begin
end if;
end if;
end if;
when BANKFE => -- BANK FE fixed by Victor Trucco - 24/05/2018
when BANKFE => -- BANK FE fixed by Victor Trucco - 24/05/2018
-- Decathlon, Robot Tank, Thwocke
-- If was latched, check the 5th bit of the data bus for the bank-switch
if FE_latch = '1' then
bank <= "000"& not cpu_d(5);
Expand Down Expand Up @@ -572,30 +581,30 @@ begin
end process;

-- derive banking scheme from cartridge size
process(rom_size, force_bs)
begin
if(force_bs /= "0000") then
--process(rom_size, force_bs)
--begin
-- if(force_bs /= "00000") then
bss <= force_bs;
elsif(rom_size = '0'&x"0000") then
bss <= BANK00;
elsif(rom_size <= '0'&x"0800") then -- 2k and less
bss <= BANK2K;
elsif(rom_size <= '0'&x"1000") then -- 4k and less
bss <= BANK00;
elsif(rom_size <= '0'&x"2000") then -- 8k and less
bss <= BANKF8;
elsif(rom_size <= '0'&x"3000") then -- 12k and less
bss <= BANKFA;
elsif(rom_size <= '0'&x"4000") then -- 16k and less
bss <= BANKF6;
elsif(rom_size <= '0'&x"8000") then -- 32k and less
bss <= BANKF4;
elsif(rom_size <= '1'&x"0000") then -- 64k and less
bss <= BANK32;
else
bss <= BANK00;
end if;
end process;
-- elsif(rom_size = '0'&x"0000") then
-- bss <= BANK00;
-- elsif(rom_size <= '0'&x"0800") then -- 2k and less
-- bss <= BANK2K;
-- elsif(rom_size <= '0'&x"1000") then -- 4k and less
-- bss <= BANK00;
-- elsif(rom_size <= '0'&x"2000") then -- 8k and less
-- bss <= BANKF8;
-- elsif(rom_size <= '0'&x"3000") then -- 12k and less
-- bss <= BANKFA;
-- elsif(rom_size <= '0'&x"4000") then -- 16k and less
-- bss <= BANKF6;
-- elsif(rom_size <= '0'&x"8000") then -- 32k and less
-- bss <= BANKF4;
-- elsif(rom_size <= '1'&x"0000") then -- 64k and less
-- bss <= BANK32;
-- else
-- bss <= BANK00;
-- end if;
--end process;

process (clk)
begin
Expand Down
30 changes: 21 additions & 9 deletions src/a2600_top_tn20k.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ signal system_sc : std_logic_vector(1 downto 0);
signal sc : std_logic;
signal scdetect : std_logic;
signal decomb : std_logic;
signal p_1 : std_logic;
signal p_2 : std_logic;
signal p_dif1 : std_logic;
signal p_dif2 : std_logic;
signal p_color : std_logic;
Expand All @@ -204,7 +202,7 @@ signal paddle_2a : std_logic_vector(7 downto 0);
signal p_start : std_logic;
signal p_select : std_logic;
signal vblank_regen : std_logic;
signal force_bs : std_logic_vector(3 downto 0) :="0000";
signal force_bs : std_logic_vector(4 downto 0);
signal joystick0ax : signed(7 downto 0);
signal joystick0ay : signed(7 downto 0);
signal joystick1ax : signed(7 downto 0);
Expand All @@ -220,6 +218,9 @@ signal img_size_crt : std_logic_vector(31 downto 0);
signal paddle_inv : std_logic;
signal joyswap : std_logic;
signal paldetect : std_logic;
signal reset_detect : std_logic;
signal cart_download_d : std_logic;
signal cart_download : std_logic;

component CLKDIV
generic (
Expand Down Expand Up @@ -563,14 +564,14 @@ leds(0) <= '0';
-- BTN_START 11
joyDS2 <= key_rstick & key_lstick & key_r2 & key_l2 & key_start & key_select & key_r1 & key_l1 &
key_square & key_triangle & key_cross & key_circle & key_up & key_down & key_left & key_right;
joyDigital <= not(x"FF" & "111" & io(4) & io(0) & io(1) & io(2) & io(3));
joyDigital <= not(x"FF" & "111" & io(0) & io(1) & io(2) & io(3) & io(4));
joyUsb1 <= extra_button0 & joystick1(7 downto 4) & joystick1(3) & joystick1(2) & joystick1(1) & joystick1(0);
joyUsb2 <= extra_button1 & joystick2(7 downto 4) & joystick2(3) & joystick2(2) & joystick2(1) & joystick2(0);
joyNumpad <= x"00" & "000" & numpad(4) & numpad(0) & numpad(1) & numpad(2) & numpad(3);
joyMouse <= x"0000";

-- send external DB9 joystick port to µC
db9_joy <= not(io(5) & io(4), io(0), io(1), io(2), io(3));
db9_joy <= not('1' & io(0) & io(1) & io(2) & io(3) & io(4));

process(clk)
begin
Expand Down Expand Up @@ -847,16 +848,27 @@ a2601_inst: entity work.A2601top
p_start <= '0' when (joyA(11) = '1' or joyB(11) = '1' or numpad(6) = '1') else '1';-- BTN_SELECT / F11
p_select <= '0' when (joyA(10) = '1' or joyB(10) = '1' or numpad(7) = '1') else '1';-- BTN_START / PAGE UP

cart_download <= ioctl_download and load_crt;
process(clk)
begin
if rising_edge(clk) then
reset_detect <= '0';
cart_download_d <= cart_download;
if (not cart_download_d and cart_download) then
reset_detect <= '1';
end if;
end if;
end process;

detect_inst: entity work.detect2600
port map(
clk => clk,
reset => reset2600,
reset => reset_detect,
addr => dl_addr(15 downto 0),
enable => ioctl_download and load_crt,
enable => ioctl_wr and cart_download,
cart_size => img_size_crt,
data => dl_data,
force_bs(3 downto 0) => force_bs,
force_bs(4) => open,
force_bs => force_bs,
sc => scdetect
);

Expand Down

0 comments on commit 0e0a932

Please sign in to comment.