diff options
author | 2021-03-17 11:30:19 +0000 | |
---|---|---|
committer | 2021-03-17 12:30:19 +0100 | |
commit | c9daa42aa97012bc55b90228dc6926cd5b42184b (patch) | |
tree | 4e7e70342b2c4aaacb1adcdf53505bde3c2a9bf0 | |
parent | d4c18136b8c83d59e98349699d51e11488a6ddb7 (diff) |
momoko: fixed glitches on high score table after memory system updates (was reading past end of region)
-rw-r--r-- | src/mame/includes/momoko.h | 4 | ||||
-rw-r--r-- | src/mame/video/momoko.cpp | 281 |
2 files changed, 137 insertions, 148 deletions
diff --git a/src/mame/includes/momoko.h b/src/mame/includes/momoko.h index 984b65b772e..856d87f7dfe 100644 --- a/src/mame/includes/momoko.h +++ b/src/mame/includes/momoko.h @@ -75,6 +75,10 @@ private: virtual void machine_reset() override; u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void draw_bg_pri(bitmap_ind16 &bitmap, int chr, int col, int flipx, int flipy, int x, int y, int pri); + void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int end, int flip); + void draw_text_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip); + void draw_fg_romtilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip); + void draw_bg_romtilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip, bool high); required_device<cpu_device> m_maincpu; required_device<gfxdecode_device> m_gfxdecode; required_device<palette_device> m_palette; diff --git a/src/mame/video/momoko.cpp b/src/mame/video/momoko.cpp index de5e4a5982d..f6fd65d1d42 100644 --- a/src/mame/video/momoko.cpp +++ b/src/mame/video/momoko.cpp @@ -4,9 +4,17 @@ Momoko 120% (c) 1986 Jaleco - Video hardware driver by Uki + Video hardware driver by Uki 02/Mar/2001 - 02/Mar/2001 - + Video consists of + - Sprites + - 2x ROM based tilemaps (bg and fg) with priority over some sprites + - 1x RAM based tilemap (text layer) (no wrapping?) + + TODO: + - update to use tilemap system? + - check if any of this is common Jaleco/NMK etc. hardware and use shared + devices if possible *******************************************************************************/ @@ -94,123 +102,15 @@ void momoko_state::draw_bg_pri(bitmap_ind16 &bitmap, int chr, int col, int flipx } } -/****************************************************************************/ -u32 momoko_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +void momoko_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int end, int flip) { - int px, py, col; - - const int flip = m_flipscreen ^ (m_io_fake->read() & 0x01); - - /* draw BG layer */ - int dx = (7 - m_bg_scrollx[0]) & 7; - int dy = (7 - m_bg_scrolly[0]) & 7; - int rx = (m_bg_scrollx[0] + m_bg_scrollx[1] * 256) >> 3; - int ry = (m_bg_scrolly[0] + m_bg_scrolly[1] * 256) >> 3; - - if (m_bg_mask == 0) - { - for (int y = 0; y < 29; y++) - { - for (int x = 0; x < 32; x++) - { - const int radr = ((ry + y + 2) & 0x3ff) * 128 + ((rx + x) & 0x7f); - u32 chr = m_bg_map[radr]; - col = m_bg_col_map[chr + m_bg_select * 512 + m_bg_priority * 256] & 0x0f; - chr = chr + m_bg_select * 512; - - if (flip == 0) - { - px = 8 * x + dx - 6; - py = 8 * y + dy + 9; - } - else - { - px = 248 - (8 * x + dx - 8); - py = 248 - (8 * y + dy + 9); - } - - m_gfxdecode->gfx(1)->opaque(bitmap,cliprect, - chr, - col, - flip,flip, - px,py); - } - } - } - else - bitmap.fill(256, cliprect); - - - /* draw sprites (momoko) */ - for (int offs = 0; offs < 9 * 4; offs +=4) - { - u32 chr = m_spriteram[offs + 1] | ((m_spriteram[offs + 2] & 0x60) << 3); - chr = ((chr & 0x380) << 1) | (chr & 0x7f); - col = m_spriteram[offs + 2] & 0x07; - const int fx = ((m_spriteram[offs + 2] & 0x10) >> 4) ^ flip; - const int fy = ((m_spriteram[offs + 2] & 0x08) >> 3) ^ flip; /* ??? */ - int x = m_spriteram[offs + 3]; - int y = m_spriteram[offs + 0]; - - if (flip == 0) - { - px = x; - py = 239 - y; - } - else - { - px = 248 - x; - py = y + 1; - } - - m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, - chr, - col, - !fx,fy, - px,py,0); - } - - - /* draw BG layer */ - if (m_bg_mask == 0) - { - for (int y = 0; y < 29; y++) - { - for (int x = 0; x < 32; x++) - { - const int radr = ((ry + y + 2) & 0x3ff) * 128 + ((rx + x) & 0x7f); - u32 chr = m_bg_map[radr]; - col = m_bg_col_map[chr + m_bg_select * 512 + m_bg_priority * 256]; - const u8 pri = (col & 0x10) >> 1; - - if (flip == 0) - { - px = 8 * x + dx - 6; - py = 8 * y + dy + 9; - } - else - { - px = 248 - (8 * x + dx - 8); - py = 248 - (8 * y + dy + 9); - } - if (pri != 0) - { - col = col & 0x0f; - chr = chr + m_bg_select * 512; - draw_bg_pri(bitmap, chr, col, flip, flip, px, py, pri); - } - } - } - } - - - /* draw sprites (others) */ - for (int offs = 9 * 4; offs < m_spriteram.bytes(); offs += 4) + for (int offs = start; offs < end; offs += 4) { + int px, py; u32 chr = m_spriteram[offs + 1] | ((m_spriteram[offs + 2] & 0x60) << 3); chr = ((chr & 0x380) << 1) | (chr & 0x7f); - col = m_spriteram[offs + 2] & 0x07; + int col = m_spriteram[offs + 2] & 0x07; const int fx = ((m_spriteram[offs + 2] & 0x10) >> 4) ^ flip; const int fy = ((m_spriteram[offs + 2] & 0x08) >> 3) ^ flip; /* ??? */ int x = m_spriteram[offs + 3]; @@ -226,19 +126,21 @@ u32 momoko_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, con px = 248 - x; py = y + 1; } - m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, + m_gfxdecode->gfx(3)->transpen(bitmap, cliprect, chr, col, - !fx,fy, - px,py,0); + !fx, fy, + px, py, 0); } +} - - /* draw text layer */ +void momoko_state::draw_text_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip) +{ for (int y = 16; y < 240; y++) { for (int x = 0; x < 32; x++) { + int px, py, col; int sy = y; if (m_text_mode == 0) col = m_proms[(sy >> 3) + 0x100] & 0x0f; @@ -248,7 +150,7 @@ u32 momoko_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, con sy += m_text_scrolly; col = (m_proms[y] & 0x07) + 0x10; } - dy = sy & 7; + int dy = sy & 7; if (flip == 0) { px = x * 8; @@ -259,46 +161,129 @@ u32 momoko_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, con px = 248 - x * 8; py = 255 - y; } - m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, - m_videoram[(sy >> 3) * 32 + x] * 8 + dy, - col, - flip,0, - px,py,0); + int ramoffset = (sy >> 3) * 32 + x; + + if (ramoffset < 0x400) // high score table, no wrapping? + m_gfxdecode->gfx(0)->transpen(bitmap, cliprect, + m_videoram[ramoffset] * 8 + dy, + col, + flip, 0, + px, py, 0); } } +} +void momoko_state::draw_fg_romtilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip) +{ + int dx = (7 - m_fg_scrollx) & 7; + int dy = (7 - m_fg_scrolly) & 7; + int rx = m_fg_scrollx >> 3; + int ry = m_fg_scrolly >> 3; - /* draw FG layer */ - if (m_fg_mask == 0) + for (int y = 0; y < 29; y++) { - dx = (7 - m_fg_scrollx) & 7; - dy = (7 - m_fg_scrolly) & 7; - rx = m_fg_scrollx >> 3; - ry = m_fg_scrolly >> 3; + for (int x = 0; x < 32; x++) + { + int px, py; + const int radr = ((ry + y + 34) & 0x3f) * 0x20 + ((rx + x) & 0x1f) + (m_fg_select & 3) * 0x800; + const u32 chr = m_fg_map[radr]; + if (flip == 0) + { + px = 8 * x + dx - 6; + py = 8 * y + dy + 9; + } + else + { + px = 248 - (8 * x + dx - 8); + py = 248 - (8 * y + dy + 9); + } + m_gfxdecode->gfx(2)->transpen(bitmap,cliprect, + chr, + 0, /* color */ + flip,flip, /* flip */ + px,py,0); + } + } +} + +void momoko_state::draw_bg_romtilemap(screen_device& screen, bitmap_ind16& bitmap, const rectangle& cliprect, int flip, bool high) +{ + int dx = (7 - m_bg_scrollx[0]) & 7; + int dy = (7 - m_bg_scrolly[0]) & 7; + int rx = (m_bg_scrollx[0] + m_bg_scrollx[1] * 256) >> 3; + int ry = (m_bg_scrolly[0] + m_bg_scrolly[1] * 256) >> 3; - for (int y = 0; y < 29; y++) + for (int y = 0; y < 29; y++) + { + for (int x = 0; x < 32; x++) { - for (int x = 0; x < 32; x++) + int px, py; + const int radr = ((ry + y + 2) & 0x3ff) * 128 + ((rx + x) & 0x7f); + u32 chr = m_bg_map[radr]; + int col = m_bg_col_map[chr + m_bg_select * 512 + m_bg_priority * 256]; + chr = chr + m_bg_select * 512; + + if (flip == 0) { - const int radr = ((ry + y + 34) & 0x3f) * 0x20 + ((rx + x) & 0x1f) + (m_fg_select & 3) * 0x800; - const u32 chr = m_fg_map[radr]; - if (flip == 0) - { - px = 8 * x + dx - 6; - py = 8 * y + dy + 9; - } - else + px = 8 * x + dx - 6; + py = 8 * y + dy + 9; + } + else + { + px = 248 - (8 * x + dx - 8); + py = 248 - (8 * y + dy + 9); + } + + if (!high) + { + m_gfxdecode->gfx(1)->opaque(bitmap,cliprect, + chr, + col, + flip,flip, + px,py); + } + else + { + const u8 pri = (col & 0x10) >> 1; + if (pri != 0) { - px = 248 - (8 * x + dx - 8); - py = 248 - (8 * y + dy + 9); + col = col & 0x0f; + draw_bg_pri(bitmap, chr, col, flip, flip, px, py, pri); } - m_gfxdecode->gfx(2)->transpen(bitmap,cliprect, - chr, - 0, /* color */ - flip,flip, /* flip */ - px,py,0); } } } +} + +/****************************************************************************/ + +u32 momoko_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + const int flip = m_flipscreen ^ (m_io_fake->read() & 0x01); + + /* draw BG layer - all tiles */ + + if (m_bg_mask == 0) + draw_bg_romtilemap(screen, bitmap, cliprect, flip, false); + else + bitmap.fill(256, cliprect); + + /* draw sprites (momoko) */ + draw_sprites(screen, bitmap, cliprect, 0, 9 * 4, flip); + + /* draw BG layer - high priority tiles */ + if (m_bg_mask == 0) + draw_bg_romtilemap(screen, bitmap, cliprect, flip, true); + + /* draw sprites (others) */ + draw_sprites(screen, bitmap, cliprect, 9*4, m_spriteram.bytes(), flip); + + /* draw text layer */ + draw_text_tilemap(screen, bitmap, cliprect, flip); + + /* draw FG layer */ + if (m_fg_mask == 0) + draw_fg_romtilemap(screen, bitmap, cliprect, flip); + return 0; } |