1
0
mirror of https://github.com/Gehstock/Mist_FPGA.git synced 2026-01-20 01:34:38 +00:00

IremM62: implement sprite/tilemap priority handling

This commit is contained in:
Gyorgy Szombathelyi 2020-03-19 12:32:01 +01:00
parent c978469c62
commit f83fe1c554
7 changed files with 40 additions and 10 deletions

View File

@ -28,6 +28,7 @@ entity Graphics is
sprite_ctl_i : in to_SPRITE_CTL_t;
sprite_ctl_o : out from_SPRITE_CTL_t;
spr0_hit : out std_logic;
sprite_pri : in std_logic;
sprite_rgb : in RGB_t;
graphics_i : in to_GRAPHICS_t;
@ -47,8 +48,6 @@ architecture SYN of Graphics is
signal bitmap_ctl_o_s : from_BITMAP_CTL_a(1 to PACE_VIDEO_NUM_BITMAPS);
signal tilemap_ctl_o_s : from_TILEMAP_CTL_a(1 to PACE_VIDEO_NUM_TILEMAPS);
signal sprite_ctl_o_s : from_SPRITE_CTL_t;
signal sprite_pri : std_logic;
signal rgb_data : RGB_t;
-- before OSD is mixed in
@ -229,7 +228,6 @@ begin
GEN_NO_SPRITES : if PACE_VIDEO_NUM_SPRITES = 0 generate
sprite_ctl_o_s <= ((others => '0'), '0', (others => '0'));
sprite_pri <= '0';
spr0_hit <= '0';
end generate GEN_NO_SPRITES;
@ -261,7 +259,6 @@ begin
pal_a => sprite_ctl_o_s.pal_a,
set => sprite_ctl_o_s.set,
pri => sprite_pri,
spr0_set => spr0_hit
);

View File

@ -74,6 +74,7 @@ architecture SYN of PACE is
signal to_sprite_ctl2 : to_SPRITE_CTL_t;
signal from_sprite_ctl : from_SPRITE_CTL_t;
signal spr0_hit : std_logic;
signal sprite_pri : std_logic;
signal to_graphics : to_GRAPHICS_t;
signal from_graphics : from_GRAPHICS_t;
@ -132,6 +133,7 @@ begin
sprite_o => to_sprite_ctl,
spr0_hit => spr0_hit,
sprite_rgb => sprite_rgb,
sprite_pri => sprite_pri,
graphics_i => from_graphics,
graphics_o => to_graphics,
@ -173,6 +175,7 @@ begin
sprite_ctl_i => to_sprite_ctl,
sprite_ctl_o => from_sprite_ctl,
spr0_hit => spr0_hit,
sprite_pri => sprite_pri,
sprite_rgb => sprite_rgb,
graphics_i => to_graphics,

View File

@ -44,6 +44,7 @@ entity platform is
sprite_i : in from_SPRITE_CTL_t;
sprite_o : out to_SPRITE_CTL_t;
spr0_hit : in std_logic;
sprite_pri : out std_logic;
sprite_rgb : out RGB_t;
-- various graphics information
@ -854,7 +855,6 @@ begin
hwsel = HW_LDRUN or
hwsel = HW_LDRUN2 or
hwsel = HW_LDRUN3 or
hwsel = HW_LDRUN4 or
hwsel = HW_BATTROAD
else sprite_i.pal_a;
@ -928,6 +928,36 @@ begin
);
sp_pal_b_wr <= '1' when dl_wr = '1' and dl_addr(11 downto 8) = x"2" else '0'; -- 200-2FF
-- 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
process(hwsel, tilemap_i(1).pal_a, sprite_i.pal_a)
variable bg_trans: std_logic;
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;
end if;
end process;
-- unused outputs
sprite_o.ld <= '0';

View File

@ -41,7 +41,7 @@ entity sprite_array is
-- video data
pal_a : out std_logic_vector(7 downto 0);
set : out std_logic;
pri : out std_logic;
--pri : out std_logic;
spr0_set : out std_logic
);
end entity sprite_array;
@ -141,7 +141,7 @@ begin
end loop;
end if;
set <= spr_on_v;
pri <= spr_pri_v;
--pri <= spr_pri_v;
end process;
-- for NES, and perhaps others

View File

@ -80,7 +80,6 @@ package sprite_pkg is
-- video data
pal_a : out std_logic_vector(7 downto 0);
set : out std_logic;
pri : out std_logic;
spr0_set : out std_logic
);
end component sprite_array;

View File

@ -154,6 +154,7 @@ begin
hwsel = HW_LOTLOT or
hwsel = HW_LDRUN or
hwsel = HW_LDRUN2 or
hwsel = HW_LDRUN3 or
hwsel = HW_BATTROAD
then
flipx := attr_d_r(5);

View File

@ -52,8 +52,8 @@ begin
sprite_rgb when sprite_set = '1' else
bg_rgb;
elsif PACE_VIDEO_NUM_TILEMAPS = 2 generate
rgb_o <= sprite_rgb when sprite_set = '1' and sprite_pri = '1' else
tilemap_ctl_o(2).rgb when tilemap_ctl_o(2).set = '1' else
rgb_o <= tilemap_ctl_o(2).rgb when tilemap_ctl_o(2).set = '1' else
sprite_rgb when sprite_set = '1' and sprite_pri = '1' else
tilemap_ctl_o(1).rgb when tilemap_ctl_o(1).set = '1' else
sprite_rgb when sprite_set = '1' else
bg_rgb;