From 6984dcc5a01ae0b88845b3c3508cacaa7baa753c Mon Sep 17 00:00:00 2001 From: Gyorgy Szombathelyi Date: Thu, 12 Mar 2020 23:55:36 +0100 Subject: [PATCH] IremM62: slow down sprite fetching to reserve SDRAM slots to bg fetch --- .../IremM62 Hardware/rtl/sprite_array.vhd | 32 +++++++++++++++---- .../IremM62 Hardware/rtl/spritectl.vhd | 4 ++- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Arcade_MiST/IremM62 Hardware/rtl/sprite_array.vhd b/Arcade_MiST/IremM62 Hardware/rtl/sprite_array.vhd index 807353ce..953b995c 100644 --- a/Arcade_MiST/IremM62 Hardware/rtl/sprite_array.vhd +++ b/Arcade_MiST/IremM62 Hardware/rtl/sprite_array.vhd @@ -60,6 +60,7 @@ architecture SYN of sprite_array is signal ctl_o : ctl_o_a_t(0 to N_SPRITES-1); signal ld_r : std_logic_vector(N_SPRITES-1 downto 0); + signal ld_en : std_logic; begin -- Sprite Data Load Arbiter @@ -78,14 +79,31 @@ begin elsif rising_edge(clk) and clk_ena = '1' then if video_ctl.hblank = '0' then i := 0; - ld_r(ld_r'left) <= '1'; - ld_r(ld_r'left-1 downto 0) <= (others => '0'); - else - ld_r <= ld_r(ld_r'left-1 downto 0) & ld_r(ld_r'left); - if (i = 31 and hwsel /= HW_HORIZON) or i = N_SPRITES-1 then - i := 0; + ld_r(ld_r'left downto 0) <= (others => '0'); + if hwsel = HW_HORIZON then + ld_r(ld_r'left) <= '1'; else - i := i + 1; + ld_r(31) <= '1'; + end if; + ld_en <= '1'; + else + if hwsel /= HW_HORIZON then + -- there are 128 pixels in HBLANK + -- fetch one word in every pixel clock when 64 sprites/line used (HORIZON) + -- fetch one word in every two pixels when 32 sprites/line in use (every other games) + ld_en <= not ld_en; + end if; + if ld_en = '1' then + if hwsel = HW_HORIZON then + ld_r <= ld_r(ld_r'left-1 downto 0) & ld_r(ld_r'left); + else + ld_r(31 downto 0) <= ld_r(30 downto 0) & ld_r(31); + end if; + if (i = 31 and hwsel /= HW_HORIZON) or i = N_SPRITES-1 then + i := 0; + else + i := i + 1; + end if; end if; end if; row_a <= ctl_o(i).a; diff --git a/Arcade_MiST/IremM62 Hardware/rtl/spritectl.vhd b/Arcade_MiST/IremM62 Hardware/rtl/spritectl.vhd index 91a63729..d6b3d8d1 100644 --- a/Arcade_MiST/IremM62 Hardware/rtl/spritectl.vhd +++ b/Arcade_MiST/IremM62 Hardware/rtl/spritectl.vhd @@ -41,6 +41,7 @@ architecture SYN of spritectl is alias clk_ena : std_logic is video_ctl.clk_ena; signal rowStore : std_logic_vector(47 downto 0); -- saved row of spt to show during visibile period + signal ld_r : std_logic; begin @@ -64,6 +65,7 @@ begin if rising_edge(clk) then if clk_ena = '1' then + ld_r <= ctl_i.ld; if video_ctl.hblank = '1' then yMat := yMatNext; else @@ -126,7 +128,7 @@ begin end if; end if; -- hblank='0' - if ctl_i.ld = '1' then + if ctl_i.ld = '1' and ld_r = '0' then xMat := false; ctl_o.a(4) <= not ctl_o.a(4); -- switch sprite half if yMat then