diff --git a/Arcade_MiST/IremM62 Hardware/rtl/platform.vhd b/Arcade_MiST/IremM62 Hardware/rtl/platform.vhd index 28dfec6c..e5aceaf8 100644 --- a/Arcade_MiST/IremM62 Hardware/rtl/platform.vhd +++ b/Arcade_MiST/IremM62 Hardware/rtl/platform.vhd @@ -227,7 +227,7 @@ begin STD_MATCH(cpu_a, X"A"&"-----------0") else '1' when (hwsel = HW_SPELUNKR or hwsel = HW_SPELUNK2) and STD_MATCH(cpu_a, "101------------0") else - '1' when hwsel /= HW_KUNGFUM and hwsel /= HW_KIDNIKI and + '1' when hwsel /= HW_KUNGFUM and hwsel /= HW_KIDNIKI and hwsel /= HW_SPELUNKR and hwsel /= HW_SPELUNK2 and STD_MATCH(cpu_a, X"D"&"-----------0") else '0'; cram_cs <= '1' when hwsel = HW_KUNGFUM and @@ -236,7 +236,7 @@ begin STD_MATCH(cpu_a, X"A"&"-----------1") else '1' when (hwsel = HW_SPELUNKR or hwsel = HW_SPELUNK2) and STD_MATCH(cpu_a, "101------------1") else - '1' when hwsel /= HW_KUNGFUM and hwsel /= HW_KIDNIKI and + '1' when hwsel /= HW_KUNGFUM and hwsel /= HW_KIDNIKI and hwsel /= HW_SPELUNKR and hwsel /= HW_SPELUNK2 and STD_MATCH(cpu_a, X"D"&"-----------1") else '0'; @@ -936,26 +936,15 @@ begin -- JP1-4 - Tiles with color code >= the value set here have priority over sprites -- J1: selects whether bit 4 of obj color code selects or not high priority over tiles - process(hwsel, tilemap_i(1).pal_a, sprite_i.pal_a) - variable bg_trans: std_logic; + process(hwsel, tilemap_i(1).prio, sprite_i.pal_a) begin - sprite_pri <= '1'; - bg_trans := '0'; - if tilemap_i(1).pal_a(2 downto 0) = "000" then - bg_trans := '1'; - end if; - if (hwsel = HW_YOUJYUDN or hwsel = HW_HORIZON) and tilemap_i(1).pal_a(7 downto 4) >= x"8" then - sprite_pri <= bg_trans; - end if; - if hwsel = HW_LDRUN and tilemap_i(1).pal_a(7 downto 4) >= x"c" then - sprite_pri <= sprite_i.pal_a(7) or bg_trans; - end if; - if (hwsel = HW_LDRUN2 or hwsel = HW_LDRUN3 or hwsel = HW_BATTROAD) and tilemap_i(1).pal_a(7 downto 4) >= x"4" then - sprite_pri <= sprite_i.pal_a(7) or bg_trans; - end if; - if hwsel = HW_KIDNIKI and tilemap_i(1).tile_a(13 downto 11) = "111" then - sprite_pri <= bg_trans; + + sprite_pri <= not tilemap_i(1).prio; + + if (hwsel = HW_LDRUN or hwsel = HW_LDRUN2 or hwsel = HW_LDRUN3 or hwsel = HW_BATTROAD) then + sprite_pri <= sprite_i.pal_a(7) or not tilemap_i(1).prio; end if; + end process; -- unused outputs diff --git a/Arcade_MiST/IremM62 Hardware/rtl/sprite_array.vhd b/Arcade_MiST/IremM62 Hardware/rtl/sprite_array.vhd index f164c951..a722a72f 100644 --- a/Arcade_MiST/IremM62 Hardware/rtl/sprite_array.vhd +++ b/Arcade_MiST/IremM62 Hardware/rtl/sprite_array.vhd @@ -127,17 +127,14 @@ begin begin if rising_edge(clk) and clk_ena = '1' then spr_on_v := '0'; - spr_pri_v := '0'; + --spr_pri_v := '0'; for i in 0 to N_SPRITES-1 loop - -- if highest priority = 0 and pixel on - if spr_pri_v = '0' and ctl_o(i).set = '1' then - -- if no sprite on or this priority = 1 - if spr_on_v = '0' or reg_o(i).pri = '1' then - pal_a <= ctl_o(i).pal_a; - spr_on_v := '1'; -- flag as sprite on - spr_pri_v := reg_o(i).pri; -- store priority + -- higher sprite number has priority + if ctl_o(i).set = '1' then + pal_a <= ctl_o(i).pal_a; + spr_on_v := '1'; -- flag as sprite on + --spr_pri_v := reg_o(i).pri; -- store priority end if; - end if; end loop; end if; set <= spr_on_v; diff --git a/Arcade_MiST/IremM62 Hardware/rtl/tilemapctl.vhd b/Arcade_MiST/IremM62 Hardware/rtl/tilemapctl.vhd index 1491a2bf..26664060 100644 --- a/Arcade_MiST/IremM62 Hardware/rtl/tilemapctl.vhd +++ b/Arcade_MiST/IremM62 Hardware/rtl/tilemapctl.vhd @@ -61,6 +61,7 @@ begin ctl_o.tile_a(ctl_o.tile_a'left downto 15) <= (others => '0'); -- tilemap scroll + x <= std_logic_vector(unsigned(video_ctl.x) - 256 + 128 + 8) when unsigned(y) < 6*8 and hwsel = HW_KUNGFUM else std_logic_vector(unsigned(video_ctl.x) - 256 + unsigned(hscroll(8 downto 0)) + 64 + 10) when hwsel = HW_LDRUN4 else std_logic_vector(unsigned(video_ctl.x) - 256 + unsigned(hscroll(8 downto 0)) + 64 + 8) when hires = '1' else @@ -75,6 +76,7 @@ begin variable attr_d_r : std_logic_vector(7 downto 0); variable flipx : std_logic; variable pel : std_logic_vector(2 downto 0); + variable prio : std_logic; begin @@ -177,7 +179,28 @@ begin pel := tile_d_r(tile_d_r'right) & tile_d_r(tile_d_r'right+8) & tile_d_r(tile_d_r'right+16); end if; + -- sprite priority + -- B Board: + -- J1: selects whether bit 4 of obj color code selects or not high priority over tiles + -- J2: selects whether bit 4 of obj color code goes to A7 of obj color PROMS + -- G Board + -- JP1-4 - Tiles with color code >= the value set here have priority over sprites + -- J1: selects whether bit 4 of obj color code selects or not high priority over tiles + prio := '0'; + if ((hwsel = HW_YOUJYUDN or hwsel = HW_HORIZON) and attr_d_r(4 downto 1) >= x"8") or + (hwsel = HW_LDRUN and attr_d_r(4 downto 1) >= x"c") or + ((hwsel = HW_LDRUN2 or hwsel = HW_LDRUN3 or hwsel = HW_BATTROAD) and attr_d_r(4 downto 1) >= x"4") or + (hwsel = HW_KIDNIKI and attr_d_r(7 downto 5) = "111") + then + prio := '1'; + end if; + + if (pel = "000") then + prio := '0'; + end if; + ctl_o.pal_a <= attr_d_r(4 downto 0) & pel; + ctl_o.prio <= prio; ctl_o.set <= '0'; -- default -- if pel /= "000" then -- pal_rgb(0)(7 downto 5) /= "000" or @@ -245,6 +268,7 @@ begin if clk_ena = '1' then ctl_o.tile_a(14) <= '0'; + ctl_o.prio <= '0'; if hwsel = HW_BATTROAD then -- 8x8 tiles, 32x32 tilemap diff --git a/Arcade_MiST/IremM62 Hardware/rtl/video_controller_pkg.vhd b/Arcade_MiST/IremM62 Hardware/rtl/video_controller_pkg.vhd index 46f9e286..4ae6c479 100644 --- a/Arcade_MiST/IremM62 Hardware/rtl/video_controller_pkg.vhd +++ b/Arcade_MiST/IremM62 Hardware/rtl/video_controller_pkg.vhd @@ -128,6 +128,7 @@ package video_controller_pkg is rgb : RGB_t; set : std_logic; pal_a : std_logic_vector(7 downto 0); + prio : std_logic; end record; type from_TILEMAP_CTL_a is array (natural range <>) of from_TILEMAP_CTL_t;