chanbara.cpp - render low priority sprites (#8269)

This commit is contained in:
David Haywood 2021-07-10 18:32:52 +01:00 committed by GitHub
parent 94064e4474
commit c15624e0da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,10 +43,11 @@ Notes:
Driver by Tomasz Slanina & David Haywood Driver by Tomasz Slanina & David Haywood
Inputs and Dip Switches by stephh Inputs and Dip Switches by stephh
ToDo: TODO:
there might still be some sprite banking issues - Support screen flipping for sprites
support screen flipping for sprites - If you force-scroll an enemy off the screen rather than fight them, you'll get graphical
corruption (bad sprites) before a new enemy appears, does this happen on the PCB?
- BGM tempo is incorrect, but clocks are verfied above? ( see https://www.youtube.com/watch?v=pW9nhx1hcLM )
****************************************************************************************/ ****************************************************************************************/
@ -94,7 +95,7 @@ private:
TILE_GET_INFO_MEMBER(get_bg2_tile_info); TILE_GET_INFO_MEMBER(get_bg2_tile_info);
void chanbara_palette(palette_device &palette) const; void chanbara_palette(palette_device &palette) const;
uint32_t screen_update_chanbara(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); uint32_t screen_update_chanbara(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void chanbara_map(address_map &map); void chanbara_map(address_map &map);
/* memory pointers */ /* memory pointers */
@ -179,16 +180,14 @@ void chanbara_state::video_start()
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(chanbara_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS,8, 8, 32, 32); m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(chanbara_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS,8, 8, 32, 32);
m_bg2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(chanbara_state::get_bg2_tile_info)), TILEMAP_SCAN_ROWS,16, 16, 16, 32); m_bg2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(chanbara_state::get_bg2_tile_info)), TILEMAP_SCAN_ROWS,16, 16, 16, 32);
m_bg_tilemap->set_transparent_pen(0); m_bg_tilemap->set_transparent_pen(0);
m_bg2_tilemap->set_transparent_pen(0);
} }
void chanbara_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) void chanbara_state::draw_sprites(screen_device &screen, bitmap_ind16& bitmap, const rectangle& cliprect)
{ {
int offs; for (int offs = 0x80 - 4; offs >= 0x00; offs -= 4)
for (offs = 0; offs < 0x80; offs += 4)
{
if (m_spriteram[offs + 0x80] & 0x80)
{ {
int pri_mask = (m_spriteram[offs + 0x80] & 0x80) ? 0xfffc : 0xfffe;
int attr = m_spriteram[offs + 0]; int attr = m_spriteram[offs + 0];
int code = m_spriteram[offs + 1]; int code = m_spriteram[offs + 1];
int color = m_spriteram[offs + 0x80] & 0x1f; int color = m_spriteram[offs + 0x80] & 0x1f;
@ -199,6 +198,7 @@ void chanbara_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clipre
sy += 16; sy += 16;
// could be simplified by rearranging gfx in loading / init
if (m_spriteram[offs + 0x80] & 0x10) code += 0x200; if (m_spriteram[offs + 0x80] & 0x10) code += 0x200;
if (m_spriteram[offs + 0x80] & 0x20) code += 0x400; if (m_spriteram[offs + 0x80] & 0x20) code += 0x400;
if (m_spriteram[offs + 0x80] & 0x40) code += 0x100; if (m_spriteram[offs + 0x80] & 0x40) code += 0x100;
@ -207,29 +207,33 @@ void chanbara_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clipre
{ {
if (!flipy) if (!flipy)
{ {
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, code, color, flipx, flipy, sx, sy-16, 0); m_gfxdecode->gfx(1)->prio_transpen(bitmap, cliprect, code, color, flipx, flipy, sx, sy - 16, screen.priority(), pri_mask, 0);
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, code+1, color, flipx, flipy, sx, sy, 0); m_gfxdecode->gfx(1)->prio_transpen(bitmap, cliprect, code + 1, color, flipx, flipy, sx, sy, screen.priority(), pri_mask, 0);
} }
else else
{ {
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, code, color, flipx, flipy, sx, sy, 0); m_gfxdecode->gfx(1)->prio_transpen(bitmap, cliprect, code, color, flipx, flipy, sx, sy, screen.priority(), pri_mask, 0);
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, code+1, color, flipx, flipy, sx, sy-16, 0); m_gfxdecode->gfx(1)->prio_transpen(bitmap, cliprect, code + 1, color, flipx, flipy, sx, sy - 16, screen.priority(), pri_mask, 0);
} }
} }
else else
{ {
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, code, color, flipx, flipy, sx, sy, 0); m_gfxdecode->gfx(1)->prio_transpen(bitmap, cliprect, code, color, flipx, flipy, sx, sy, screen.priority(), pri_mask, 0);
}
} }
} }
} }
uint32_t chanbara_state::screen_update_chanbara(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) uint32_t chanbara_state::screen_update_chanbara(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{ {
screen.priority().fill(0, cliprect);
m_bg2_tilemap->set_scrolly(0, m_scroll | (m_scrollhi << 8)); m_bg2_tilemap->set_scrolly(0, m_scroll | (m_scrollhi << 8));
m_bg2_tilemap->draw(screen, bitmap, cliprect, 0, 0); m_bg2_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); // ensure bg pen for each tile gets drawn behind sprites
draw_sprites(bitmap, cliprect); m_bg2_tilemap->draw(screen, bitmap, cliprect, 0, 1);
m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 2);
draw_sprites(screen, bitmap, cliprect);
return 0; return 0;
} }