diff --git a/SNES.sv b/SNES.sv index 9a0146a..816cc3b 100644 --- a/SNES.sv +++ b/SNES.sv @@ -182,18 +182,20 @@ parameter CONF_STR = { "OH,Multitap,Disabled,Port2;", "-;", "OPQ,Super Scope,Disabled,Joy1,Joy2,Mouse;", - "OR,Super Scope Btn,Joy,Mouse;", - "OST,Cross,Small,Big,None;", + "D4OR,Super Scope Btn,Joy,Mouse;", + "D4OST,Cross,Small,Big,None;", + "-;", + "D3O4,Turbo,Disable,Enable;", "-;", "R0,Reset;", "J1,A(SS Fire),B(SS Cursor),X(SS TurboSw),Y(SS Pause),LT(SS Cursor),RT(SS Fire),Select,Start;", "V,v",`BUILD_DATE }; -// free bits: 4,L,M,U,V +// free bits: L,M,U,V wire [1:0] buttons; wire [31:0] status; -wire [15:0] status_menumask = {~gg_available, ~GSU_ACTIVE, ~bk_ena}; +wire [15:0] status_menumask = {!GUN_MODE, ~turbo_allow, ~gg_available, ~GSU_ACTIVE, ~bk_ena}; wire forced_scandoubler; reg [31:0] sd_lba; reg sd_rd = 0; @@ -339,6 +341,7 @@ end //////////////////////////// SYSTEM /////////////////////////////////// wire GSU_ACTIVE; +wire turbo_allow; main main ( @@ -417,6 +420,9 @@ main main .GG_CODE(gg_code), .GG_RESET((code_download && ioctl_wr && !ioctl_addr) || cart_download), .GG_AVAILABLE(gg_available), + + .TURBO(status[4] & turbo_allow), + .TURBO_ALLOW(turbo_allow), .AUDIO_L(AUDIO_L), .AUDIO_R(AUDIO_R) diff --git a/src/CPU.vhd b/src/CPU.vhd index f8afd96..aff64e4 100644 --- a/src/CPU.vhd +++ b/src/CPU.vhd @@ -39,8 +39,10 @@ entity SCPU is JOY2_DI : in std_logic_vector(1 downto 0); JOY_STRB : out std_logic; JOY1_CLK : out std_logic; - JOY2_CLK : out std_logic; - + JOY2_CLK : out std_logic; + + TURBO : in std_logic; + DBG_CPU_BRK : out std_logic; DBG_REG : in std_logic_vector(7 downto 0); DBG_DAT : out std_logic_vector(7 downto 0); @@ -58,7 +60,10 @@ architecture rtl of SCPU is signal INT_CLKR_CE, INT_CLKF_CE, DOT_CLK_CE : std_logic; signal P65_CLK_CNT : unsigned(3 downto 0); signal DMA_CLK_CNT : unsigned(2 downto 0); + signal DMA_LAST_CLOCK : unsigned(2 downto 0); + signal DMA_MID_CLOCK : unsigned(2 downto 0); signal CPU_LAST_CLOCK : unsigned(3 downto 0); + signal CPU_MID_CLOCK : unsigned(3 downto 0); signal CPU_ACTIVEr, DMA_ACTIVEr : std_logic; signal H_CNT : unsigned(8 downto 0); signal V_CNT : unsigned(8 downto 0); @@ -228,9 +233,17 @@ begin DMA_ACTIVE <= DMA_RUN or HDMA_RUN; - process( SPEED, MEMSEL, REFRESHED, CPU_ACTIVEr ) + process( SPEED, MEMSEL, REFRESHED, CPU_ACTIVEr, TURBO ) begin - if REFRESHED = '1' and CPU_ACTIVEr = '1' then + CPU_MID_CLOCK <= x"2"; + DMA_MID_CLOCK <= "011"; + DMA_LAST_CLOCK <= "111"; + if TURBO = '1' then + CPU_LAST_CLOCK <= x"3"; + CPU_MID_CLOCK <= x"1"; + DMA_LAST_CLOCK <= "011"; + DMA_MID_CLOCK <= "001"; + elsif REFRESHED = '1' and CPU_ACTIVEr = '1' then CPU_LAST_CLOCK <= x"7"; elsif SPEED = FAST or (SPEED = SLOWFAST and MEMSEL = '1') then CPU_LAST_CLOCK <= x"5"; @@ -250,13 +263,17 @@ begin CPU_ACTIVEr <= '1'; DMA_ACTIVEr <= '0'; elsif rising_edge(CLK) then - DMA_CLK_CNT <= DMA_CLK_CNT + 1; + DMA_CLK_CNT <= DMA_CLK_CNT + 1; + if DMA_CLK_CNT = DMA_LAST_CLOCK then + DMA_CLK_CNT <= (others => '0'); + end if; + P65_CLK_CNT <= P65_CLK_CNT + 1; if P65_CLK_CNT = CPU_LAST_CLOCK then P65_CLK_CNT <= (others => '0'); end if; - - if DMA_ACTIVEr = '0' and DMA_ACTIVE = '1' and DMA_CLK_CNT = 7 and REFRESHED = '0' then + + if DMA_ACTIVEr = '0' and DMA_ACTIVE = '1' and DMA_CLK_CNT = DMA_LAST_CLOCK and REFRESHED = '0' then DMA_ACTIVEr <= '1'; elsif DMA_ACTIVEr = '1' and DMA_ACTIVE = '0' and REFRESHED = '0' then DMA_ACTIVEr <= '0'; @@ -269,13 +286,13 @@ begin end if; if DMA_ACTIVEr = '1' or ENABLE = '0' then - if DMA_CLK_CNT = 4-1 then + if DMA_CLK_CNT = DMA_MID_CLOCK then INT_CLK <= '1'; - elsif DMA_CLK_CNT = 8-1 then + elsif DMA_CLK_CNT = DMA_LAST_CLOCK then INT_CLK <= '0'; end if; - elsif CPU_ACTIVEr = '1' then - if P65_CLK_CNT = 3-1 then + elsif CPU_ACTIVEr = '1' then + if P65_CLK_CNT = CPU_MID_CLOCK then INT_CLK <= '1'; elsif P65_CLK_CNT = CPU_LAST_CLOCK then INT_CLK <= '0'; @@ -295,17 +312,17 @@ begin if DMA_CLK_CNT(1 downto 0) = 4-1 then DOT_CLK_CE <= '1'; end if; - + INT_CLKF_CE <= '0'; INT_CLKR_CE <= '0'; if DMA_ACTIVEr = '1' or ENABLE = '0' then - if DMA_CLK_CNT = 4-1 then + if DMA_CLK_CNT = DMA_MID_CLOCK then INT_CLKR_CE <= '1'; - elsif DMA_CLK_CNT = 8-1 then + elsif DMA_CLK_CNT = DMA_LAST_CLOCK then INT_CLKF_CE <= '1'; end if; elsif CPU_ACTIVEr = '1' then - if P65_CLK_CNT = 3-1 then + if P65_CLK_CNT = CPU_MID_CLOCK then INT_CLKR_CE <= '1'; elsif P65_CLK_CNT = CPU_LAST_CLOCK then INT_CLKF_CE <= '1'; diff --git a/src/SNES.vhd b/src/SNES.vhd index 298b82d..97bfab2 100644 --- a/src/SNES.vhd +++ b/src/SNES.vhd @@ -95,6 +95,8 @@ entity SNES is GG_CODE : in std_logic_vector(128 downto 0); GG_RESET : in std_logic; GG_AVAILABLE: out std_logic; + + TURBO : in std_logic; AUDIO_L : out std_logic_vector(15 downto 0); AUDIO_R : out std_logic_vector(15 downto 0) @@ -229,8 +231,10 @@ begin JOY2_DI => JOY2_DI, JOY_STRB => JOY_STRB, JOY1_CLK => JOY1_CLK, - JOY2_CLK => JOY2_CLK, - + JOY2_CLK => JOY2_CLK, + + TURBO => TURBO, + DBG_CPU_BRK => CPU_BRK, DBG_REG => DBG_REG, DBG_DAT => DBG_SCPU_DAT, diff --git a/src/main.v b/src/main.v index 3eeb20f..d54a894 100644 --- a/src/main.v +++ b/src/main.v @@ -84,6 +84,9 @@ module main input GG_RESET, output GG_AVAILABLE, + input TURBO, + output TURBO_ALLOW, + output [15:0] AUDIO_L, output [15:0] AUDIO_R ); @@ -183,6 +186,8 @@ SNES SNES .gg_code(GG_CODE), .gg_reset(GG_RESET), .gg_available(GG_AVAILABLE), + + .turbo(TURBO), .audio_l(AUDIO_L), .audio_r(AUDIO_R) @@ -487,6 +492,8 @@ SA1Map SA1Map assign MAP_ACTIVE[3] = 0; `endif +assign TURBO_ALLOW = ~(MAP_ACTIVE[3] | MAP_ACTIVE[1]); + always @(*) begin case (MAP_ACTIVE) `ifdef USE_CX4