summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2025-12-25 05:59:08 +1100
committer Vas Crabb <vas@vastheman.com>2025-12-25 05:59:08 +1100
commit5eb65aa67c2e5e9898a7e618c6bb1b36412a78a5 (patch)
treee7d740aa4ad881807bf9a98b5a6e0d0f8268cbb3
parentc21edf7fc9af2504f16c6b14d6b7021ea6cc67ae (diff)
seibu/sei25x_rise1x_spr.cpp: Separate plotting logic from sprite loop.
-rw-r--r--src/mame/seibu/feversoc.cpp2
-rw-r--r--src/mame/seibu/raiden2.cpp1
-rw-r--r--src/mame/seibu/raiden2.h1
-rw-r--r--src/mame/seibu/raiden2_v.cpp15
-rw-r--r--src/mame/seibu/sei25x_rise1x_spr.cpp149
-rw-r--r--src/mame/seibu/sei25x_rise1x_spr.h16
-rw-r--r--src/mame/seibu/seibuspi.cpp1
-rw-r--r--src/mame/seibu/seibuspi.h1
-rw-r--r--src/mame/seibu/seibuspi_v.cpp9
9 files changed, 108 insertions, 87 deletions
diff --git a/src/mame/seibu/feversoc.cpp b/src/mame/seibu/feversoc.cpp
index 34594d2f016..54fae7c87ee 100644
--- a/src/mame/seibu/feversoc.cpp
+++ b/src/mame/seibu/feversoc.cpp
@@ -152,7 +152,7 @@ uint32_t feversoc_state::screen_update(screen_device &screen, bitmap_ind16 &bitm
{
bitmap.fill(m_palette->pen(0), cliprect); //black pen
- m_spritegen->draw_sprites(screen, bitmap, cliprect, m_spriteram, m_spriteram.bytes());
+ m_spritegen->draw(bitmap, cliprect, m_spriteram, m_spriteram.bytes());
return 0;
}
diff --git a/src/mame/seibu/raiden2.cpp b/src/mame/seibu/raiden2.cpp
index c8eb357aa6a..82cf0ac35d1 100644
--- a/src/mame/seibu/raiden2.cpp
+++ b/src/mame/seibu/raiden2.cpp
@@ -1063,7 +1063,6 @@ void raiden2_state::base_video(machine_config &config)
m_spritegen->set_pix_raw_shift(4);
m_spritegen->set_pri_raw_shift(14);
m_spritegen->set_transpen(15);
- m_spritegen->set_allocate_sprite_bitmap(true);
}
void raiden2_state::raiden2(machine_config &config)
diff --git a/src/mame/seibu/raiden2.h b/src/mame/seibu/raiden2.h
index 61ede656887..d0c8ffb9dc8 100644
--- a/src/mame/seibu/raiden2.h
+++ b/src/mame/seibu/raiden2.h
@@ -104,6 +104,7 @@ protected:
const s32 *m_cur_spri = nullptr; // cfg
bitmap_ind16 m_tile_bitmap;
+ bitmap_ind16 m_sprite_bitmap;
void sprite_prot_x_w(u16 data);
void sprite_prot_y_w(u16 data);
diff --git a/src/mame/seibu/raiden2_v.cpp b/src/mame/seibu/raiden2_v.cpp
index 9d8a8cf2755..80b7f238dd3 100644
--- a/src/mame/seibu/raiden2_v.cpp
+++ b/src/mame/seibu/raiden2_v.cpp
@@ -197,6 +197,7 @@ TILE_GET_INFO_MEMBER(raiden2_state::get_text_tile_info)
void raiden2_state::video_start()
{
m_screen->register_screen_bitmap(m_tile_bitmap);
+ m_screen->register_screen_bitmap(m_sprite_bitmap);
m_back_data = make_unique_clear<u16[]>(0x800/2);
m_fore_data = make_unique_clear<u16[]>(0x800/2);
@@ -256,39 +257,37 @@ u32 raiden2_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, co
bitmap.fill(m_palette->black_pen(), cliprect);
if (BIT(~m_tilemap_enable, 4))
{
- m_spritegen->draw_sprites(screen, bitmap, cliprect, m_spriteram->buffer(), m_spriteram->bytes());
+ m_spritegen->draw_raw(m_sprite_bitmap, cliprect, m_spriteram->buffer(), m_spriteram->bytes());
- blend_layer(bitmap, cliprect, m_spritegen->get_sprite_temp_bitmap(), m_cur_spri[0]);
+ blend_layer(bitmap, cliprect, m_sprite_bitmap, m_cur_spri[0]);
}
if (BIT(~m_tilemap_enable, 0))
tilemap_draw_and_blend(screen, bitmap, cliprect, m_background_layer);
if (BIT(~m_tilemap_enable, 4))
- blend_layer(bitmap, cliprect, m_spritegen->get_sprite_temp_bitmap(), m_cur_spri[1]);
+ blend_layer(bitmap, cliprect, m_sprite_bitmap, m_cur_spri[1]);
if (BIT(~m_tilemap_enable, 1))
tilemap_draw_and_blend(screen, bitmap, cliprect, m_midground_layer);
if (BIT(~m_tilemap_enable, 4))
- blend_layer(bitmap, cliprect, m_spritegen->get_sprite_temp_bitmap(), m_cur_spri[2]);
+ blend_layer(bitmap, cliprect, m_sprite_bitmap, m_cur_spri[2]);
if (BIT(~m_tilemap_enable, 2))
tilemap_draw_and_blend(screen, bitmap, cliprect, m_foreground_layer);
if (BIT(~m_tilemap_enable, 4))
- blend_layer(bitmap, cliprect, m_spritegen->get_sprite_temp_bitmap(), m_cur_spri[3]);
+ blend_layer(bitmap, cliprect, m_sprite_bitmap, m_cur_spri[3]);
if (BIT(~m_tilemap_enable, 3))
tilemap_draw_and_blend(screen, bitmap, cliprect, m_text_layer);
if (BIT(~m_tilemap_enable, 4))
- blend_layer(bitmap, cliprect, m_spritegen->get_sprite_temp_bitmap(), m_cur_spri[4]);
+ blend_layer(bitmap, cliprect, m_sprite_bitmap, m_cur_spri[4]);
if (machine().input().code_pressed_once(KEYCODE_Z))
if (m_raiden2cop) m_raiden2cop->dump_table();
return 0;
}
-
-
diff --git a/src/mame/seibu/sei25x_rise1x_spr.cpp b/src/mame/seibu/sei25x_rise1x_spr.cpp
index ce6968a5a73..cdef1037ce5 100644
--- a/src/mame/seibu/sei25x_rise1x_spr.cpp
+++ b/src/mame/seibu/sei25x_rise1x_spr.cpp
@@ -40,7 +40,6 @@ sei25x_rise1x_device::sei25x_rise1x_device(const machine_config &mconfig, device
, m_yoffset(0)
, m_transpen(0)
, m_pix_raw_shift(4)
- , m_allocate_bitmap(false)
{
}
@@ -53,12 +52,6 @@ void sei25x_rise1x_device::device_start()
{
m_pri_cb.resolve();
m_gfxbank_cb.resolve();
-
- if (m_allocate_bitmap && !m_pri_cb.isnull())
- fatalerror("m_sprite_bitmap && m_pri_cb is invalid");
-
- if (m_allocate_bitmap)
- screen().register_screen_bitmap(m_sprite_bitmap);
}
void sei25x_rise1x_device::device_reset()
@@ -87,26 +80,9 @@ Unmarked bits are unused/unknown.
===============================================================
*/
-template <class T>
-void sei25x_rise1x_device::draw(screen_device &screen, T &bitmap, const rectangle cliprect, u16 *spriteram, u16 size)
+template <typename T, typename U>
+inline void sei25x_rise1x_device::draw_sprites(const u16 *spriteram, int start, int end, int inc, T &&set_pri_col, U &&plot)
{
- if (m_sprite_bitmap.valid())
- m_sprite_bitmap.fill(0xffff, cliprect);
-
- int start, end, inc;
- if (!m_pri_cb.isnull())
- {
- start = 0;
- end = (size / 2);
- inc = 4;
- }
- else
- {
- start = (size / 2) - 4;
- end = -4;
- inc = -4;
- }
-
for (int i = start; i != end; i += inc)
{
u32 code = spriteram[i + 1];
@@ -130,12 +106,7 @@ void sei25x_rise1x_device::draw(screen_device &screen, T &bitmap, const rectangl
x += m_xoffset;
y += m_yoffset;
- u32 pri_mask = 0;
-
- if (!m_pri_cb.isnull())
- pri_mask = m_pri_cb(pri);
- else if (m_sprite_bitmap.valid())
- color |= pri << (m_pri_raw_shift - m_pix_raw_shift); // for manual mixing
+ set_pri_col(pri, color);
if (!m_gfxbank_cb.isnull())
code = m_gfxbank_cb(code, ext);
@@ -146,44 +117,96 @@ void sei25x_rise1x_device::draw(screen_device &screen, T &bitmap, const rectangl
for (int ay = 0; ay < sizey; ay++)
{
const int sy = flipy ? (y + 16 * (sizey - ay - 1)) : (y + 16 * ay);
- if (m_sprite_bitmap.valid())
- {
- gfx(0)->transpen_raw(m_sprite_bitmap, cliprect,
- code++,
- color << m_pix_raw_shift,
- flipx, flipy,
- sx, sy,
- m_transpen);
- }
- else if (!m_pri_cb.isnull())
- {
- gfx(0)->prio_transpen(bitmap, cliprect,
- code++,
- color,
- flipx, flipy,
- sx, sy,
- screen.priority(), pri_mask, m_transpen);
- }
- else
- {
- gfx(0)->transpen(bitmap, cliprect,
- code++,
- color,
- flipx, flipy,
- sx, sy,
- m_transpen);
- }
+ plot(code++, color, flipx, flipy, sx, sy);
}
}
}
}
-void sei25x_rise1x_device::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle cliprect, u16 *spriteram, u16 size)
+void sei25x_rise1x_device::draw(bitmap_ind16 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size)
{
- draw(screen, bitmap, cliprect, spriteram, size);
+ draw_sprites(
+ spriteram, (size / 2) - 4, -4, -4,
+ [] (u8 pri, u32 &color) { },
+ [this, &bitmap, &cliprect] (u32 code, u32 color, bool flipx, bool flipy, s32 sx, s32 sy)
+ {
+ gfx(0)->transpen(bitmap, cliprect,
+ code,
+ color,
+ flipx, flipy,
+ sx, sy,
+ m_transpen);
+ });
}
-void sei25x_rise1x_device::draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle cliprect, u16 *spriteram, u16 size)
+void sei25x_rise1x_device::draw(bitmap_rgb32 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size)
{
- draw(screen, bitmap, cliprect, spriteram, size);
+ draw_sprites(
+ spriteram, (size / 2) - 4, -4, -4,
+ [] (u8 pri, u32 &color) { },
+ [this, &bitmap, &cliprect] (u32 code, u32 color, bool flipx, bool flipy, s32 sx, s32 sy)
+ {
+ gfx(0)->transpen(bitmap, cliprect,
+ code,
+ color,
+ flipx, flipy,
+ sx, sy,
+ m_transpen);
+ });
+}
+
+void sei25x_rise1x_device::draw_prio(screen_device &screen, bitmap_ind16 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size)
+{
+ assert(!m_pri_cb.isnull());
+
+ u32 pri_mask;
+ draw_sprites(
+ spriteram, 0, size / 2, 4,
+ [this, &pri_mask] (u8 pri, u32 &color) { pri_mask = m_pri_cb(pri); },
+ [this, &screen, &bitmap, &cliprect, &pri_mask] (u32 code, u32 color, bool flipx, bool flipy, s32 sx, s32 sy)
+ {
+ gfx(0)->prio_transpen(bitmap, cliprect,
+ code,
+ color,
+ flipx, flipy,
+ sx, sy,
+ screen.priority(), pri_mask, m_transpen);
+ });
+}
+
+void sei25x_rise1x_device::draw_prio(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size)
+{
+ assert(!m_pri_cb.isnull());
+
+ u32 pri_mask;
+ draw_sprites(
+ spriteram, 0, size / 2, 4,
+ [this, &pri_mask] (u8 pri, u32 &color) { pri_mask = m_pri_cb(pri); },
+ [this, &screen, &bitmap, &cliprect, &pri_mask] (u32 code, u32 color, bool flipx, bool flipy, s32 sx, s32 sy)
+ {
+ gfx(0)->prio_transpen(bitmap, cliprect,
+ code,
+ color,
+ flipx, flipy,
+ sx, sy,
+ screen.priority(), pri_mask, m_transpen);
+ });
+}
+
+void sei25x_rise1x_device::draw_raw(bitmap_ind16 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size)
+{
+ // for manual mixing
+ bitmap.fill(0xffff, cliprect);
+ draw_sprites(
+ spriteram, (size / 2) - 4, -4, -4,
+ [this] (u8 pri, u32 &color) { color = (color << m_pix_raw_shift) | (u32(pri) << m_pri_raw_shift); },
+ [this, &bitmap, &cliprect] (u32 code, u32 color, bool flipx, bool flipy, s32 sx, s32 sy)
+ {
+ gfx(0)->transpen_raw(bitmap, cliprect,
+ code,
+ color,
+ flipx, flipy,
+ sx, sy,
+ m_transpen);
+ });
}
diff --git a/src/mame/seibu/sei25x_rise1x_spr.h b/src/mame/seibu/sei25x_rise1x_spr.h
index 89f356d997e..1e35d8edd7e 100644
--- a/src/mame/seibu/sei25x_rise1x_spr.h
+++ b/src/mame/seibu/sei25x_rise1x_spr.h
@@ -30,12 +30,12 @@ public:
void set_transpen(u32 transpen) { m_transpen = transpen; }
void set_pix_raw_shift(u32 raw_shift) { m_pix_raw_shift = raw_shift; }
void set_pri_raw_shift(u32 raw_shift) { m_pri_raw_shift = raw_shift; }
- void set_allocate_sprite_bitmap(bool allocate) { m_allocate_bitmap = allocate; }
- void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle cliprect, u16 *spriteram, u16 size);
- void draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle cliprect, u16 *spriteram, u16 size);
-
- bitmap_ind16 &get_sprite_temp_bitmap() { assert(m_sprite_bitmap.valid()); return m_sprite_bitmap; }
+ void draw(bitmap_ind16 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size);
+ void draw(bitmap_rgb32 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size);
+ void draw_prio(screen_device &screen, bitmap_ind16 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size);
+ void draw_prio(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size);
+ void draw_raw(bitmap_ind16 &bitmap, const rectangle cliprect, const u16 *spriteram, u16 size);
protected:
sei25x_rise1x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
@@ -44,8 +44,8 @@ protected:
virtual void device_reset() override ATTR_COLD;
private:
- template <class T>
- void draw(screen_device &screen, T &bitmap, const rectangle cliprect, u16 *spriteram, u16 size);
+ template <typename T, typename U>
+ void draw_sprites(const u16 *spriteram, int start, int end, int inc, T &&set_pri_col, U &&plot);
pri_cb_delegate m_pri_cb;
gfxbank_cb_delegate m_gfxbank_cb;
@@ -55,8 +55,6 @@ private:
u32 m_transpen;
u32 m_pix_raw_shift;
u32 m_pri_raw_shift;
- bool m_allocate_bitmap;
- bitmap_ind16 m_sprite_bitmap;
};
DECLARE_DEVICE_TYPE(SEI25X_RISE1X, sei25x_rise1x_device)
diff --git a/src/mame/seibu/seibuspi.cpp b/src/mame/seibu/seibuspi.cpp
index 0c4195772de..7767af2bbcf 100644
--- a/src/mame/seibu/seibuspi.cpp
+++ b/src/mame/seibu/seibuspi.cpp
@@ -1795,7 +1795,6 @@ void seibuspi_tilemap_state::base_video(machine_config &config)
m_spritegen->set_pix_raw_shift(6);
m_spritegen->set_pri_raw_shift(14);
m_spritegen->set_transpen(63);
- m_spritegen->set_allocate_sprite_bitmap(true);
seibu_crtc_device &crtc(SEIBU_CRTC(config, "crtc", 0));
crtc.decrypt_key_callback().set(FUNC(seibuspi_tilemap_state::tile_decrypt_key_w));
diff --git a/src/mame/seibu/seibuspi.h b/src/mame/seibu/seibuspi.h
index a7372b19780..c01699d419c 100644
--- a/src/mame/seibu/seibuspi.h
+++ b/src/mame/seibu/seibuspi.h
@@ -116,6 +116,7 @@ public:
protected:
required_device<gfxdecode_device> m_gfxdecode;
memory_share_creator<u32> m_tilemap_ram;
+ bitmap_ind16 m_sprite_bitmap;
tilemap_t *m_text_layer = nullptr;
tilemap_t *m_back_layer = nullptr;
diff --git a/src/mame/seibu/seibuspi_v.cpp b/src/mame/seibu/seibuspi_v.cpp
index 89ba30fb25b..4250d9dcd04 100644
--- a/src/mame/seibu/seibuspi_v.cpp
+++ b/src/mame/seibu/seibuspi_v.cpp
@@ -385,11 +385,10 @@ void seibuspi_tilemap_state::blend_sprite(bitmap_rgb32 &bitmap, const rectangle
if (BIT(m_layer_enable, 4))
return;
- bitmap_ind16 &sprite_bitmap = m_spritegen->get_sprite_temp_bitmap();
pri <<= 14;
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
- const u16 *src = &sprite_bitmap.pix(y, cliprect.min_x);
+ const u16 *src = &m_sprite_bitmap.pix(y, cliprect.min_x);
u32 *dest = &bitmap.pix(y);
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
{
@@ -449,7 +448,7 @@ u32 seibuspi_tilemap_state::screen_update_spi(screen_device &screen, bitmap_rgb3
}
if (BIT(~m_layer_enable, 4))
- m_spritegen->draw_sprites(screen, bitmap, cliprect, m_sprite_ram, m_sprite_ram.bytes());
+ m_spritegen->draw_raw(m_sprite_bitmap, cliprect, m_sprite_ram, m_sprite_ram.bytes());
if (m_layer_enable & 1)
bitmap.fill(0, cliprect);
@@ -490,7 +489,7 @@ u32 seibuspi_base_state::screen_update_sys386f(screen_device &screen, bitmap_rgb
{
bitmap.fill(0, cliprect);
- m_spritegen->draw_sprites(screen, bitmap, cliprect, m_sprite_ram, m_sprite_ram.bytes());
+ m_spritegen->draw(bitmap, cliprect, m_sprite_ram, m_sprite_ram.bytes());
return 0;
}
@@ -562,6 +561,8 @@ void seibuspi_tilemap_state::video_start()
{
seibuspi_base_state::video_start();
+ m_spritegen->screen().register_screen_bitmap(m_sprite_bitmap);
+
m_video_dma_length = 0;
m_video_dma_address = 0;
m_layer_enable = 0;