summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cam900 <dbtlrchl@naver.com>2020-01-23 00:02:03 +0900
committer cam900 <dbtlrchl@naver.com>2020-01-23 00:02:03 +0900
commit4b428e5bca190914558e20c7f0e34cb8323ebb49 (patch)
tree4f48c64fafe4339a62891c486e545594a9e1754d
parent05c427f41397c0c24f2b66ab03ca0d9035c99b54 (diff)
kaneko_spr.cpp : Fix drawing behavior
Fix priority in enabled 'keep sprite' function, Split 'Copy temporary bitmap into screen bitmap' function and Getting sprite function kaneko16.cpp : Fix sprite delay, Add notes, Correct explbrkr OKI bankswitching (tied into m_ym2149[0] port B), Remove outdated note
-rw-r--r--src/mame/drivers/expro02.cpp3
-rw-r--r--src/mame/drivers/galpanic_ms.cpp3
-rw-r--r--src/mame/drivers/kaneko16.cpp13
-rw-r--r--src/mame/video/galpani2.cpp6
-rw-r--r--src/mame/video/kaneko16.cpp4
-rw-r--r--src/mame/video/kaneko_spr.cpp89
-rw-r--r--src/mame/video/kaneko_spr.h20
7 files changed, 65 insertions, 73 deletions
diff --git a/src/mame/drivers/expro02.cpp b/src/mame/drivers/expro02.cpp
index 875febac064..494d384efa3 100644
--- a/src/mame/drivers/expro02.cpp
+++ b/src/mame/drivers/expro02.cpp
@@ -390,7 +390,8 @@ uint32_t expro02_state::screen_update_backgrounds(screen_device &screen, bitmap_
uint32_t expro02_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
screen_update_backgrounds(screen, bitmap, cliprect);
- m_kaneko_spr->render_sprites(bitmap,cliprect, screen.priority(), m_spriteram, m_spriteram.bytes());
+ m_kaneko_spr->render_sprites(cliprect, m_spriteram, m_spriteram.bytes());
+ m_kaneko_spr->copybitmap(bitmap, cliprect, screen.priority());
return 0;
}
diff --git a/src/mame/drivers/galpanic_ms.cpp b/src/mame/drivers/galpanic_ms.cpp
index 01d62d747b1..d74847c5b40 100644
--- a/src/mame/drivers/galpanic_ms.cpp
+++ b/src/mame/drivers/galpanic_ms.cpp
@@ -154,7 +154,8 @@ uint32_t galspanic_ms_state::screen_update_backgrounds(screen_device &screen, bi
uint32_t galspanic_ms_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
screen_update_backgrounds(screen, bitmap, cliprect);
-// m_kaneko_spr->render_sprites(bitmap,cliprect, screen.priority(), m_spriteram, m_spriteram.bytes());
+// m_kaneko_spr->render_sprites(cliprect, m_spriteram, m_spriteram.bytes());
+// m_kaneko_spr->copybitmap(bitmap, cliprect, screen.priority());
return 0;
}
diff --git a/src/mame/drivers/kaneko16.cpp b/src/mame/drivers/kaneko16.cpp
index b2be12a98b0..3c420532105 100644
--- a/src/mame/drivers/kaneko16.cpp
+++ b/src/mame/drivers/kaneko16.cpp
@@ -86,7 +86,6 @@ Dip locations verified from manual for:
[general]
- interrupt timing/behaviour
-- replace sample bank copying with new ADDRESS MAP system for OKI and do banking like CPUs
Non-Bugs (happen on real PCB)
@@ -308,9 +307,7 @@ void kaneko16_state::bakubrkr_map(address_map &map)
{
map(0x000000, 0x07ffff).rom(); // ROM
map(0x100000, 0x10ffff).ram(); // Work RAM
- map(0x400000, 0x40001f).r(FUNC(kaneko16_state::ym2149_r<0>)); // Sound
- map(0x400000, 0x40001d).w(FUNC(kaneko16_state::ym2149_w<0>));
- map(0x40001f, 0x40001f).w(FUNC(kaneko16_state::oki_bank0_w<7>)); // OKI bank Switch
+ map(0x400000, 0x40001f).rw(FUNC(kaneko16_state::ym2149_r<0>), FUNC(kaneko16_state::ym2149_w<0>)); // Sound
map(0x400200, 0x40021f).rw(FUNC(kaneko16_state::ym2149_r<1>), FUNC(kaneko16_state::ym2149_w<1>)); // Sound
map(0x400401, 0x400401).rw(m_oki[0], FUNC(okim6295_device::read), FUNC(okim6295_device::write)); //
map(0x500000, 0x503fff).m(m_view2[0], FUNC(kaneko_view2_tilemap_device::vram_map));
@@ -1659,6 +1656,8 @@ TIMER_DEVICE_CALLBACK_MEMBER(kaneko16_state::interrupt)
// main vblank interrupt
if (scanline == 224)
{
+ // 2 frame delayed normaly; differs per PCB?
+ m_kaneko_spr->render_sprites(m_screen->visible_area(), m_spriteram->buffer(), m_spriteram->bytes());
m_spriteram->copy();
m_maincpu->set_input_line(5, HOLD_LINE);
}
@@ -1789,6 +1788,7 @@ void kaneko16_state::bakubrkr(machine_config &config)
YM2149(config, m_ym2149[0], XTAL(12'000'000)/6); /* verified on pcb */
m_ym2149[0]->add_route(ALL_OUTPUTS, "mono", 1.0);
+ m_ym2149[0]->port_b_write_callback().set(FUNC(kaneko16_state::oki_bank0_w<7>)); /* outputs B: OKI bank Switch */
YM2149(config, m_ym2149[1], XTAL(12'000'000)/6); /* verified on pcb */
m_ym2149[1]->add_route(ALL_OUTPUTS, "mono", 1.0);
@@ -2139,8 +2139,8 @@ TIMER_DEVICE_CALLBACK_MEMBER(kaneko16_shogwarr_state::shogwarr_interrupt)
if (scanline == 224)
{
- m_spriteram->copy(); // TODO : shogwarr sprites are 1 frame delayed? reference : https://youtu.be/aj4ayOc4MuI
- // the code for this interrupt is provided by the MCU..
+ m_kaneko_spr->render_sprites(m_screen->visible_area(), m_spriteram->buffer(), m_spriteram->bytes());
+ m_spriteram->copy();
m_maincpu->set_input_line(4, HOLD_LINE);
}
@@ -2924,7 +2924,6 @@ ROM_START( bloodwar )
ROM_REGION( 0x020000, "mcudata", 0 ) /* MCU Code */
ROM_LOAD16_WORD_SWAP( "ofd0x3.124", 0x000000, 0x020000, CRC(399f2005) SHA1(ff0370724770c35963953fd9596d9f808ba87d8f) )
-
ROM_REGION( 0x1e00000, "kan_spr", 0 ) /* Sprites */
ROM_LOAD ( "of-200-0201.8", 0x0000000, 0x200000, CRC(bba63025) SHA1(daec5285469ee953f6f838fe3cb3903524e9ac39) )
ROM_LOAD ( "of-201-0202.9", 0x0200000, 0x200000, CRC(4ffd9ddc) SHA1(62bc8c0ed2efab407fc2956c514c3e732bcc47ee) )
diff --git a/src/mame/video/galpani2.cpp b/src/mame/video/galpani2.cpp
index ec950a0a7b6..63bf9edb0b4 100644
--- a/src/mame/video/galpani2.cpp
+++ b/src/mame/video/galpani2.cpp
@@ -140,6 +140,10 @@ if (machine().input().code_pressed(KEYCODE_Z))
if (layers_ctrl & 0x1) copybg15(screen, bitmap, cliprect);
if (layers_ctrl & 0x2) copybg8(screen, bitmap, cliprect, 0);
if (layers_ctrl & 0x4) copybg8(screen, bitmap, cliprect, 1);
- if (layers_ctrl & 0x8) m_kaneko_spr->render_sprites(bitmap, cliprect, screen.priority(), m_spriteram, m_spriteram.bytes());
+ if (layers_ctrl & 0x8)
+ {
+ m_kaneko_spr->render_sprites(cliprect, m_spriteram, m_spriteram.bytes());
+ m_kaneko_spr->copybitmap(bitmap, cliprect, screen.priority());
+ }
return 0;
}
diff --git a/src/mame/video/kaneko16.cpp b/src/mame/video/kaneko16.cpp
index c978c061f02..1ac1ee998c8 100644
--- a/src/mame/video/kaneko16.cpp
+++ b/src/mame/video/kaneko16.cpp
@@ -83,7 +83,7 @@ u32 kaneko16_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, c
if (!m_disp_enable) return 0;
screen_update_common(screen, bitmap, cliprect);
- m_kaneko_spr->render_sprites(bitmap,cliprect, screen.priority(), m_spriteram->buffer(), m_spriteram->bytes());
+ m_kaneko_spr->copybitmap(bitmap, cliprect, screen.priority());
return 0;
}
@@ -229,6 +229,6 @@ u32 kaneko16_berlwall_state::screen_update(screen_device &screen, bitmap_rgb32 &
if (!m_disp_enable) return 0;
screen_update_common(screen, bitmap, cliprect);
- m_kaneko_spr->render_sprites(bitmap,cliprect, screen.priority(), m_spriteram->buffer(), m_spriteram->bytes()/2);
+ m_kaneko_spr->copybitmap(bitmap, cliprect, screen.priority());
return 0;
}
diff --git a/src/mame/video/kaneko_spr.cpp b/src/mame/video/kaneko_spr.cpp
index 598c005f9cd..d55557f69b5 100644
--- a/src/mame/video/kaneko_spr.cpp
+++ b/src/mame/video/kaneko_spr.cpp
@@ -70,12 +70,14 @@ void kaneko16_sprite_device::device_start()
m_first_sprite = std::make_unique<struct tempsprite_t[]>(0x400);
m_sprites_regs = make_unique_clear<u16[]>(0x20/2);
screen().register_screen_bitmap(m_sprites_bitmap);
+ screen().register_screen_bitmap(m_sprites_maskmap);
save_item(NAME(m_sprite_flipx));
save_item(NAME(m_sprite_flipy));
save_pointer(NAME(m_sprites_regs), 0x20/2);
save_item(NAME(m_keep_sprites));
save_item(NAME(m_sprites_bitmap));
+ save_item(NAME(m_sprites_maskmap));
}
@@ -238,12 +240,11 @@ int kaneko16_sprite_device::parse_sprite_type012(int i, struct tempsprite_t *s,
// custom function to draw a single sprite. needed to keep correct sprites - sprites and sprites - tilemaps priorities
-template<class _BitmapClass>
-void kaneko16_sprite_device::draw_sprites_custom(_BitmapClass &dest_bmp,const rectangle &clip,gfx_element *gfx,
+void kaneko16_sprite_device::draw_sprites_custom(const rectangle &clip,gfx_element *gfx,
u32 code,u32 color,bool flipx,bool flipy,int sx,int sy,
- bitmap_ind8 &priority_bitmap, int priority)
+ int priority)
{
- const pen_t pen_base = gfx->colorbase() + gfx->granularity() * (color % gfx->colors());
+ const pen_t pen_base = gfx->granularity() * (color % gfx->colors());
const u8 *source_base = gfx->get_data(code % gfx->elements());
int dx, dy;
@@ -301,17 +302,11 @@ void kaneko16_sprite_device::draw_sprites_custom(_BitmapClass &dest_bmp,const re
if (ex > sx)
{ /* skip if inner loop doesn't draw anything */
- typename _BitmapClass::pixel_t *dest;
- int rgb;
- if (sizeof(*dest) == 2) rgb = 0;
- else rgb = 1;
-
- const pen_t *pal = gfx->palette().pens();
for (int y = sy; y < ey; y++)
{
const u8 *source = source_base + y_index * gfx->rowbytes();
- dest = &dest_bmp.pix(y);
- u8 *pri = &priority_bitmap.pix8(y);
+ u16 *dest = &m_sprites_bitmap.pix16(y);
+ u8 *pri = &m_sprites_maskmap.pix8(y);
int x_index = x_index_base;
for (int x = sx; x < ex; x++)
@@ -319,11 +314,9 @@ void kaneko16_sprite_device::draw_sprites_custom(_BitmapClass &dest_bmp,const re
const u8 c = source[x_index];
if (c != 0)
{
- if (pri[x] < priority)
- {
- if (!rgb) dest[x] = pen_base + c;
- else dest[x] = pal[pen_base + c];
- }
+ if (pri[x] == 0)
+ dest[x] = ((pen_base + c) & 0x3fff) + ((priority & 3) << 14);
+
pri[x] = 0xff; // mark it "already drawn"
}
x_index += dx;
@@ -335,8 +328,7 @@ void kaneko16_sprite_device::draw_sprites_custom(_BitmapClass &dest_bmp,const re
/* Build a list of sprites to display & draw them */
-template<class _BitmapClass>
-void kaneko16_sprite_device::draw_sprites(_BitmapClass &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, u16* spriteram16, int spriteram16_bytes)
+void kaneko16_sprite_device::draw_sprites(const rectangle &cliprect, u16* spriteram16, int spriteram16_bytes)
{
/* Sprites *must* be parsed from the first in RAM to the last,
because of the multisprite feature. But they *must* be drawn
@@ -442,18 +434,13 @@ void kaneko16_sprite_device::draw_sprites(_BitmapClass &bitmap, const rectangle
for (s--; s >= m_first_sprite.get(); s--)
{
- const int curr_pri = s->priority;
-
- const u32 primask = m_priority.sprite[curr_pri];
-
draw_sprites_custom(
- bitmap,cliprect,gfx(0),
+ cliprect,gfx(0),
s->code,
s->color,
s->flipx, s->flipy,
s->x, s->y,
- priority_bitmap,
- primask);
+ s->priority);
}
}
@@ -556,49 +543,53 @@ void kaneko16_sprite_device::regs_w(offs_t offset, u16 data, u16 mem_mask)
}
-void kaneko16_sprite_device::copybitmap(bitmap_ind16 &bitmap, const rectangle &cliprect)
-{
- copybitmap_trans(bitmap,m_sprites_bitmap,0,0,0,0,cliprect,0);
-}
+void kaneko16_sprite_device::copybitmap(bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap) { copybitmap_common(bitmap, cliprect, priority_bitmap); }
+void kaneko16_sprite_device::copybitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap) { copybitmap_common(bitmap, cliprect, priority_bitmap); }
-void kaneko16_sprite_device::copybitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect)
+template<class _BitmapClass>
+void kaneko16_sprite_device::copybitmap_common(_BitmapClass &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap)
{
const pen_t *pal = gfx(0)->palette().pens();
+ typename _BitmapClass::pixel_t *dstbitmap;
+ int rgb;
+ if (sizeof(*dstbitmap) == 2) rgb = 0;
+ else rgb = 1;
+
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
+ dstbitmap = &bitmap.pix(y);
+ u8 *dstprimap = &priority_bitmap.pix8(y);
u16* srcbitmap = &m_sprites_bitmap.pix16(y);
- u32* dstbitmap = &bitmap.pix32(y);
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
{
- const u16 pix = srcbitmap[x];
- if (pix) dstbitmap[x] = pal[pix];
+ const u16 pri = (srcbitmap[x] & 0xc000) >> 14;
+ const u16 pix = srcbitmap[x] & 0x3fff;
+ if (m_priority.sprite[pri] > dstprimap[x])
+ {
+ if (pix & 0x3fff)
+ {
+ if (!rgb) dstbitmap[x] = m_colbase + pix;
+ else dstbitmap[x] = pal[m_colbase + pix];
+ }
+ }
}
}
}
-void kaneko16_sprite_device::render_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, u16* spriteram16, int spriteram16_bytes) { render_sprites_common(bitmap, cliprect, priority_bitmap, spriteram16, spriteram16_bytes); }
-void kaneko16_sprite_device::render_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, u16* spriteram16, int spriteram16_bytes) { render_sprites_common(bitmap, cliprect, priority_bitmap, spriteram16, spriteram16_bytes); }
-
-template<class _BitmapClass>
-void kaneko16_sprite_device::render_sprites_common(_BitmapClass &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, u16* spriteram16, int spriteram16_bytes)
+void kaneko16_sprite_device::render_sprites(const rectangle &cliprect, u16* spriteram16, int spriteram16_bytes)
{
/* Sprites last (rendered with pdrawgfx, so they can slip
in between the layers) */
- if (m_keep_sprites)
- {
- /* keep sprites on screen - used by mgcrystl when you get the first gem and it shows instructions */
- draw_sprites(m_sprites_bitmap, cliprect, priority_bitmap, spriteram16, spriteram16_bytes);
- copybitmap(bitmap,cliprect);
- }
- else
- {
+ m_sprites_maskmap.fill(0, cliprect);
+ /* keep sprites on screen - used by mgcrystl when you get the first gem and it shows instructions */
+ if (!m_keep_sprites)
m_sprites_bitmap.fill(0, cliprect);
- draw_sprites(bitmap,cliprect, priority_bitmap, spriteram16, spriteram16_bytes);
- }
+
+ draw_sprites(cliprect, spriteram16, spriteram16_bytes);
}
kaneko_vu002_sprite_device::kaneko_vu002_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
diff --git a/src/mame/video/kaneko_spr.h b/src/mame/video/kaneko_spr.h
index 00ea0c7640f..69539361711 100644
--- a/src/mame/video/kaneko_spr.h
+++ b/src/mame/video/kaneko_spr.h
@@ -46,16 +46,16 @@ public:
// (legacy) used in the bitmap clear functions
virtual int get_sprite_type(void) =0;
- void render_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, u16* spriteram16, int spriteram16_bytes);
- void render_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, u16* spriteram16, int spriteram16_bytes);
+ void render_sprites(const rectangle &cliprect, u16* spriteram16, int spriteram16_bytes);
+ void copybitmap(bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap);
+ void copybitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap);
template<class _BitmapClass>
- void render_sprites_common(_BitmapClass &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, u16* spriteram16, int spriteram16_bytes);
+ void copybitmap_common(_BitmapClass &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap);
void bootleg_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, u16* spriteram16, int spriteram16_bytes);
-
u16 regs_r(offs_t offset);
void regs_w(offs_t offset, u16 data, u16 mem_mask);
@@ -97,21 +97,17 @@ private:
std::unique_ptr<struct tempsprite_t[]> m_first_sprite;
int m_keep_sprites;
bitmap_ind16 m_sprites_bitmap;
+ bitmap_ind8 m_sprites_maskmap;
- template<class _BitmapClass>
- void draw_sprites(_BitmapClass &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, u16* spriteram16, int spriteram16_bytes);
+ void draw_sprites(const rectangle &cliprect, u16* spriteram16, int spriteram16_bytes);
- template<class _BitmapClass>
- void draw_sprites_custom(_BitmapClass &dest_bmp,const rectangle &clip,gfx_element *gfx,
+ void draw_sprites_custom(const rectangle &clip,gfx_element *gfx,
u32 code,u32 color,bool flipx,bool flipy,int sx,int sy,
- bitmap_ind8 &priority_bitmap, int priority);
+ int priority);
int parse_sprite_type012(int i, struct tempsprite_t *s, u16* spriteram16, int spriteram16_bytes);
-
- void copybitmap(bitmap_ind16 &bitmap, const rectangle &cliprect);
- void copybitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect);
};
//extern const device_type KANEKO16_SPRITE;