From dbf647a1b28bea956a1d681c3a4e0bcb3aad940b Mon Sep 17 00:00:00 2001 From: cam900 Date: Thu, 26 Mar 2020 00:42:01 +0900 Subject: [PATCH] cave.cpp : Implement hardware sprite limitation, Add notes --- src/mame/includes/cave.h | 1 + src/mame/video/cave.cpp | 84 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 77 insertions(+), 8 deletions(-) diff --git a/src/mame/includes/cave.h b/src/mame/includes/cave.h index d90b2767f6b..1591809daf7 100644 --- a/src/mame/includes/cave.h +++ b/src/mame/includes/cave.h @@ -255,6 +255,7 @@ private: u16 m_sprite_base_pal; u16 m_sprite_granularity; + u32 m_max_sprite_clk[4]; // max usable clock for sprites /* misc */ int m_time_vblank_irq; diff --git a/src/mame/video/cave.cpp b/src/mame/video/cave.cpp index 198134ed84f..9d6ff52caa1 100644 --- a/src/mame/video/cave.cpp +++ b/src/mame/video/cave.cpp @@ -162,15 +162,15 @@ VIDEO_START_MEMBER(cave_state,ppsatan) /*************************************************************************** - Sprites Drawing + Zoomed Sprites Drawing + + Sprite format with zoom, 16 bytes per each sprites Offset: Bits: Value: - 00.w fedc ba98 76-- ---- X Position - ---- ---- --54 3210 + 00.w X Position* - 02.w fedc ba98 76-- ---- Y Position - ---- ---- --54 3210 + 02.w Y Position* 04.w fe-- ---- ---- ---- --dc ba98 ---- ---- Color @@ -189,6 +189,42 @@ VIDEO_START_MEMBER(cave_state,ppsatan) 0E.w Unused + * S.9.6 Fixed point or 10 bit signed integer, + Configured from videoregs + + + Sprites Drawing + + Sprite format without zoom, 16 bytes per each sprites + + Offset: Bits: Value: + + 00.w fe-- ---- ---- ---- + --dc ba98 ---- ---- Color + ---- ---- 76-- ---- + ---- ---- --54 ---- Priority + ---- ---- ---- 3--- Flip X + ---- ---- ---- -2-- Flip Y + ---- ---- ---- --10 Code High Bit(s?) + + 02.w Code Low Bits + + 04.w fedc ba-- ---- ---- + ---- --98 7654 3210 X Position** + + 06.w fedc ba-- ---- ---- + ---- --98 7654 3210 Y Position** + + 08.w fedc ba98 ---- ---- Tile Size X + ---- ---- 7654 3210 Tile Size Y + + 0A.w Unused + + 0C.w Unused + + 0E.w Unused + + ** 10 bit signed only? need verifications. ***************************************************************************/ @@ -211,9 +247,14 @@ void cave_state::get_sprite_info_cave(int chip) const u16 *source = m_spriteram[chip] + (0x4000 / 2) * m_spriteram_bank[chip]; const u16 *finish = source + (0x4000 / 2); + u32 clk = 0; // used clock cycle for sprites for (; source < finish; source += 8) { + clk += 32; // 32 clock per each sprites + if (clk > m_max_sprite_clk[chip]) + break; + int x, y; int total_width_f, total_height_f; @@ -239,6 +280,10 @@ void cave_state::get_sprite_info_cave(int chip) if (!sprite->tile_width || !sprite->tile_height) continue; + clk += sprite->tile_width * sprite->tile_height; // 256 clock per each sprite blocks + if (clk > m_max_sprite_clk[chip]) + break; + /* Bound checking */ code %= code_max; sprite->pen_data = base_gfx + (16 * 16) * code; @@ -334,9 +379,14 @@ void cave_state::get_sprite_info_donpachi(int chip) const u16 *source = m_spriteram[chip] + (0x4000 / 2) * m_spriteram_bank[chip]; const u16 *finish = source + (0x4000 / 2); + u32 clk = 0; // used clock cycle for sprites for (; source < finish; source += 8) { + clk += 32; // 32 clock per each sprites + if (clk > m_max_sprite_clk[chip]) + break; + int y; const u16 attr = source[0]; @@ -364,6 +414,10 @@ void cave_state::get_sprite_info_donpachi(int chip) x + sprite->total_width <= 0 || x >= max_x || y + sprite->total_height <= 0 || y >= max_y) {continue;} + clk += sprite->tile_width * sprite->tile_height; // 256 clock per each sprite blocks + if (clk > m_max_sprite_clk[chip]) + break; + int flipx = attr & 0x0008; int flipy = attr & 0x0004; @@ -422,8 +476,20 @@ void cave_state::sprite_init() for (int chip = 0; chip < 4; chip++) { + m_max_sprite_clk[chip] = 0; if (m_videoregs[chip]) { + for (int screen = 0; screen < 4; screen++) + { + if (m_screen[screen]) + { + const u32 new_clk = (m_screen[screen]->visible_area().width() > 360 ? 512 : 448) * 272 * 2; // whole screen size related? + if (m_max_sprite_clk[chip] < new_clk) + { + m_max_sprite_clk[chip] = new_clk; + } + } + } m_num_sprites[chip] = m_spriteram[chip].bytes() / 0x10 / 2; m_sprite[chip] = std::make_unique(m_num_sprites[chip]); } @@ -840,7 +906,8 @@ void cave_state::do_blit_32(int chip, const sprite_cave *sprite) return; y1--; y2--; } - else { + else + { y1 = sprite->y; y2 = y1 + sprite->total_height; dy = 1; @@ -1038,7 +1105,7 @@ void cave_state::sprite_draw_donpachi_zbuf(int chip, int priority) Screen Drawing - Layers Control Registers (cave_vctrl_0..2) + Layers Control Registers (vctrl_0..3) Offset: Bits: Value: @@ -1069,7 +1136,7 @@ void cave_state::sprite_draw_donpachi_zbuf(int chip, int priority) Row-scroll: a different scroll value is specified for each scan line. - Sprites Registers (cave_videoregs) + Sprites Registers (videoregs) Offset: Bits: Value: @@ -1338,6 +1405,7 @@ void cave_state::get_sprite_info(int chip) } } } + void cave_state::device_post_load() { for (int chip = 0; chip < 4; chip++)