From 83723a8d4c8f0622c4ddf994ab3f767fba5b57cb Mon Sep 17 00:00:00 2001 From: cam900 Date: Fri, 10 May 2019 15:51:30 +0900 Subject: decmxc06.cpp : Updates Use callback for colour masking and priority behavior, Move configuration into handlers, Reduce unnecessary lines, Unnecessary configuration values decbac06.cpp : Implement priority dec0.cpp : Add notes --- src/mame/drivers/actfancr.cpp | 16 ++--- src/mame/drivers/dec0.cpp | 20 +++--- src/mame/drivers/dec8.cpp | 5 +- src/mame/drivers/madmotor.cpp | 16 ++--- src/mame/drivers/stadhero.cpp | 2 - src/mame/drivers/thedeep.cpp | 3 - src/mame/drivers/vaportra.cpp | 9 ++- src/mame/includes/actfancr.h | 2 + src/mame/includes/dec0.h | 6 ++ src/mame/includes/dec8.h | 1 + src/mame/includes/vaportra.h | 3 + src/mame/video/actfancr.cpp | 2 +- src/mame/video/dec0.cpp | 131 ++++++++++++++++---------------------- src/mame/video/dec8.cpp | 14 ++++- src/mame/video/decbac06.cpp | 4 +- src/mame/video/decmxc06.cpp | 143 ++++++++++++++++++++---------------------- src/mame/video/decmxc06.h | 23 +++---- src/mame/video/stadhero.cpp | 2 +- src/mame/video/thedeep.cpp | 2 +- src/mame/video/vaportra.cpp | 40 ++++++------ 20 files changed, 208 insertions(+), 236 deletions(-) diff --git a/src/mame/drivers/actfancr.cpp b/src/mame/drivers/actfancr.cpp index b9d21bdbadb..14dc844e182 100644 --- a/src/mame/drivers/actfancr.cpp +++ b/src/mame/drivers/actfancr.cpp @@ -283,20 +283,18 @@ void actfancr_state::actfancr(machine_config &config) screen.screen_vblank().set_inputline(m_maincpu, 0, HOLD_LINE); /* VBL */ screen.set_palette("palette"); - GFXDECODE(config, "gfxdecode", "palette", gfx_actfan); + GFXDECODE(config, m_gfxdecode, "palette", gfx_actfan); PALETTE(config, "palette").set_format(palette_device::xBGR_444, 768); DECO_BAC06(config, m_tilegen[0], 0); m_tilegen[0]->set_gfx_region_wide(2, 2, 2); - m_tilegen[0]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[0]->set_gfxdecode_tag(m_gfxdecode); DECO_BAC06(config, m_tilegen[1], 0); m_tilegen[1]->set_gfx_region_wide(0, 0, 0); - m_tilegen[1]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[1]->set_gfxdecode_tag(m_gfxdecode); DECO_MXC06(config, m_spritegen, 0); - m_spritegen->set_gfx_region(1); - m_spritegen->set_gfxdecode_tag("gfxdecode"); /* sound hardware */ SPEAKER(config, "mono").front_center(); @@ -343,20 +341,18 @@ void actfancr_state::triothep(machine_config &config) screen.screen_vblank().set_inputline(m_maincpu, 0, HOLD_LINE); /* VBL */ screen.set_palette("palette"); - GFXDECODE(config, "gfxdecode", "palette", gfx_triothep); + GFXDECODE(config, m_gfxdecode, "palette", gfx_triothep); PALETTE(config, "palette").set_format(palette_device::xBGR_444, 768); DECO_BAC06(config, m_tilegen[0], 0); m_tilegen[0]->set_gfx_region_wide(2, 2, 0); - m_tilegen[0]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[0]->set_gfxdecode_tag(m_gfxdecode); DECO_BAC06(config, m_tilegen[1], 0); m_tilegen[1]->set_gfx_region_wide(0, 0, 0); - m_tilegen[1]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[1]->set_gfxdecode_tag(m_gfxdecode); DECO_MXC06(config, m_spritegen, 0); - m_spritegen->set_gfx_region(1); - m_spritegen->set_gfxdecode_tag("gfxdecode"); /* sound hardware */ SPEAKER(config, "mono").front_center(); diff --git a/src/mame/drivers/dec0.cpp b/src/mame/drivers/dec0.cpp index 5cd6700491b..24379f03050 100644 --- a/src/mame/drivers/dec0.cpp +++ b/src/mame/drivers/dec0.cpp @@ -1752,19 +1752,17 @@ void dec0_state::dec0_base(machine_config &config) DECO_BAC06(config, m_tilegen[0], 0); m_tilegen[0]->set_gfx_region_wide(0, 0, 0); - m_tilegen[0]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[0]->set_gfxdecode_tag(m_gfxdecode); DECO_BAC06(config, m_tilegen[1], 0); m_tilegen[1]->set_gfx_region_wide(0, 1, 0); - m_tilegen[1]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[1]->set_gfxdecode_tag(m_gfxdecode); DECO_BAC06(config, m_tilegen[2], 0); m_tilegen[2]->set_gfx_region_wide(0, 2, 0); - m_tilegen[2]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[2]->set_gfxdecode_tag(m_gfxdecode); DECO_MXC06(config, m_spritegen, 0); - m_spritegen->set_gfx_region(3); - m_spritegen->set_gfxdecode_tag("gfxdecode"); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -1898,8 +1896,7 @@ void dec0_automat_state::automat(machine_config &config) m_tilegen[2]->set_gfxdecode_tag("gfxdecode"); DECO_MXC06(config, m_spritegen, 0); - m_spritegen->set_gfx_region(3); - m_spritegen->set_gfxdecode_tag("gfxdecode"); + m_spritegen->set_colpri_callback(FUNC(dec0_automat_state::robocop_colpri_cb), this); PALETTE(config, m_palette).set_format(palette_device::xBGR_444, 1024); GFXDECODE(config, m_gfxdecode, m_palette, gfx_automat); @@ -1975,8 +1972,6 @@ void dec0_automat_state::secretab(machine_config &config) m_tilegen[2]->set_gfxdecode_tag("gfxdecode"); DECO_MXC06(config, m_spritegen, 0); - m_spritegen->set_gfx_region(3); - m_spritegen->set_gfxdecode_tag("gfxdecode"); PALETTE(config, m_palette).set_format(palette_device::xBGR_444, 1024); @@ -2027,6 +2022,7 @@ void dec0_state::hbarrel(machine_config &config) /* video hardware */ m_screen->set_screen_update(FUNC(dec0_state::screen_update_hbarrel)); + m_spritegen->set_colpri_callback(FUNC(dec0_state::hbarrel_colpri_cb), this); } void dec0_state::bandit(machine_config &config) @@ -2052,6 +2048,7 @@ void dec0_state::bandit(machine_config &config) /* video hardware */ m_screen->set_screen_update(FUNC(dec0_state::screen_update_bandit)); + m_spritegen->set_colpri_callback(FUNC(dec0_state::bandit_colpri_cb), this); } void dec0_state::baddudes(machine_config &config) @@ -2109,6 +2106,7 @@ void dec0_state::robocop(machine_config &config) /* video hardware */ m_screen->set_screen_update(FUNC(dec0_state::screen_update_robocop)); + m_spritegen->set_colpri_callback(FUNC(dec0_state::robocop_colpri_cb), this); } void dec0_state::robocopb(machine_config &config) @@ -2117,6 +2115,7 @@ void dec0_state::robocopb(machine_config &config) /* video hardware */ m_screen->set_screen_update(FUNC(dec0_state::screen_update_robocop)); + m_spritegen->set_colpri_callback(FUNC(dec0_state::robocop_colpri_cb), this); } void dec0_state::hippodrm(machine_config &config) @@ -2198,6 +2197,7 @@ void dec0_state::midres(machine_config &config) /* video hardware */ m_screen->set_screen_update(FUNC(dec0_state::screen_update_midres)); + m_spritegen->set_colpri_callback(FUNC(dec0_state::midres_colpri_cb), this); m_gfxdecode->set_info(gfx_midres); } @@ -3980,8 +3980,8 @@ GAME( 1988, robocop, 0, robocop, robocop, dec0_state, empty_init GAME( 1988, robocopw, robocop, robocop, robocop, dec0_state, empty_init, ROT0, "Data East Corporation", "Robocop (World revision 3)", MACHINE_SUPPORTS_SAVE ) GAME( 1988, robocopj, robocop, robocop, robocop, dec0_state, empty_init, ROT0, "Data East Corporation", "Robocop (Japan)", MACHINE_SUPPORTS_SAVE ) GAME( 1988, robocopu, robocop, robocop, robocop, dec0_state, empty_init, ROT0, "Data East USA", "Robocop (US revision 1)", MACHINE_SUPPORTS_SAVE ) -GAME( 1989, bandit, 0, bandit, bandit, dec0_state, init_hbarrel, ROT90, "Data East USA", "Bandit (US)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) GAME( 1988, robocopu0, robocop, robocop, robocop, dec0_state, empty_init, ROT0, "Data East USA", "Robocop (US revision 0)", MACHINE_SUPPORTS_SAVE ) +GAME( 1989, bandit, 0, bandit, bandit, dec0_state, init_hbarrel, ROT90, "Data East USA", "Bandit (US)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) GAME( 1989, hippodrm, 0, hippodrm, hippodrm, dec0_state, init_hippodrm, ROT0, "Data East USA", "Hippodrome (US)", MACHINE_SUPPORTS_SAVE ) GAME( 1989, ffantasy, hippodrm, hippodrm, ffantasy, dec0_state, init_hippodrm, ROT0, "Data East Corporation", "Fighting Fantasy (Japan revision 3)", MACHINE_SUPPORTS_SAVE ) GAME( 1989, ffantasyj, hippodrm, hippodrm, ffantasy, dec0_state, init_hippodrm, ROT0, "Data East Corporation", "Fighting Fantasy (Japan revision 2)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/dec8.cpp b/src/mame/drivers/dec8.cpp index e2cbc84a3c0..c474cb8e1b1 100644 --- a/src/mame/drivers/dec8.cpp +++ b/src/mame/drivers/dec8.cpp @@ -2307,8 +2307,6 @@ void dec8_state::oscar(machine_config &config) m_tilegen[0]->set_gfxdecode_tag(m_gfxdecode); DECO_MXC06(config, m_spritegen_mxc, 0); - m_spritegen_mxc->set_gfx_region(1); - m_spritegen_mxc->set_gfxdecode_tag(m_gfxdecode); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); // m_screen->set_refresh_hz(58); @@ -2413,8 +2411,7 @@ void dec8_state::cobracom(machine_config &config) m_tilegen[1]->set_gfxdecode_tag(m_gfxdecode); DECO_MXC06(config, m_spritegen_mxc, 0); - m_spritegen_mxc->set_gfx_region(1); - m_spritegen_mxc->set_gfxdecode_tag(m_gfxdecode); + m_spritegen_mxc->set_colpri_callback(FUNC(dec8_state::cobracom_colpri_cb), this); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); // m_screen->set_refresh_hz(58); diff --git a/src/mame/drivers/madmotor.cpp b/src/mame/drivers/madmotor.cpp index 9e6ed44361c..71039e11a01 100644 --- a/src/mame/drivers/madmotor.cpp +++ b/src/mame/drivers/madmotor.cpp @@ -40,7 +40,8 @@ public: m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), m_tilegen(*this, "tilegen%u", 1), - m_spritegen(*this, "spritegen") + m_spritegen(*this, "spritegen"), + m_gfxdecode(*this, "gfxdecode") { } void madmotor(machine_config &config); @@ -60,6 +61,7 @@ private: required_device m_audiocpu; required_device_array m_tilegen; required_device m_spritegen; + required_device m_gfxdecode; }; @@ -251,7 +253,7 @@ uint32_t madmotor_state::screen_update(screen_device &screen, bitmap_ind16 &bitm m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 0); m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); - m_spritegen->draw_sprites(bitmap, cliprect, m_spriteram, 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_spriteram, 0x800/2); m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); return 0; } @@ -279,24 +281,22 @@ void madmotor_state::madmotor(machine_config &config) screen.set_screen_update(FUNC(madmotor_state::screen_update)); screen.set_palette("palette"); - GFXDECODE(config, "gfxdecode", "palette", gfx_madmotor); + GFXDECODE(config, m_gfxdecode, "palette", gfx_madmotor); PALETTE(config, "palette").set_format(palette_device::xBGR_444, 1024); DECO_BAC06(config, m_tilegen[0], 0); m_tilegen[0]->set_gfx_region_wide(0, 0, 0); - m_tilegen[0]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[0]->set_gfxdecode_tag(m_gfxdecode); DECO_BAC06(config, m_tilegen[1], 0); m_tilegen[1]->set_gfx_region_wide(0, 1, 0); - m_tilegen[1]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[1]->set_gfxdecode_tag(m_gfxdecode); DECO_BAC06(config, m_tilegen[2], 0); m_tilegen[2]->set_gfx_region_wide(0, 2, 1); - m_tilegen[2]->set_gfxdecode_tag("gfxdecode"); + m_tilegen[2]->set_gfxdecode_tag(m_gfxdecode); DECO_MXC06(config, m_spritegen, 0); - m_spritegen->set_gfx_region(3); - m_spritegen->set_gfxdecode_tag("gfxdecode"); /* sound hardware */ SPEAKER(config, "mono").front_center(); diff --git a/src/mame/drivers/stadhero.cpp b/src/mame/drivers/stadhero.cpp index 0c81fab55b3..1015a6c44a6 100644 --- a/src/mame/drivers/stadhero.cpp +++ b/src/mame/drivers/stadhero.cpp @@ -213,8 +213,6 @@ void stadhero_state::stadhero(machine_config &config) m_tilegen->set_gfxdecode_tag(m_gfxdecode); DECO_MXC06(config, m_spritegen, 0); - m_spritegen->set_gfx_region(2); - m_spritegen->set_gfxdecode_tag(m_gfxdecode); /* sound hardware */ SPEAKER(config, "mono").front_center(); diff --git a/src/mame/drivers/thedeep.cpp b/src/mame/drivers/thedeep.cpp index aaa1006805c..672fe1de008 100644 --- a/src/mame/drivers/thedeep.cpp +++ b/src/mame/drivers/thedeep.cpp @@ -435,9 +435,6 @@ void thedeep_state::thedeep(machine_config &config) PALETTE(config, m_palette, FUNC(thedeep_state::thedeep_palette), 512); DECO_MXC06(config, m_spritegen, 0); - m_spritegen->set_gfx_region(0); - m_spritegen->set_gfxdecode_tag(m_gfxdecode); - m_spritegen->set_ram_size(0x400); /* sound hardware */ SPEAKER(config, "mono").front_center(); diff --git a/src/mame/drivers/vaportra.cpp b/src/mame/drivers/vaportra.cpp index 373baa71c97..f19667d6b41 100644 --- a/src/mame/drivers/vaportra.cpp +++ b/src/mame/drivers/vaportra.cpp @@ -229,7 +229,7 @@ void vaportra_state::vaportra(machine_config &config) screen.set_screen_update(FUNC(vaportra_state::screen_update)); screen.set_palette(m_palette); - GFXDECODE(config, "gfxdecode", m_palette, gfx_vaportra); + GFXDECODE(config, m_gfxdecode, m_palette, gfx_vaportra); PALETTE(config, m_palette).set_entries(1280); DECO16IC(config, m_deco_tilegen[0], 0); @@ -245,7 +245,7 @@ void vaportra_state::vaportra(machine_config &config) m_deco_tilegen[0]->set_bank2_callback(FUNC(vaportra_state::bank_callback), this); m_deco_tilegen[0]->set_pf12_8x8_bank(0); m_deco_tilegen[0]->set_pf12_16x16_bank(1); - m_deco_tilegen[0]->set_gfxdecode_tag("gfxdecode"); + m_deco_tilegen[0]->set_gfxdecode_tag(m_gfxdecode); DECO16IC(config, m_deco_tilegen[1], 0); m_deco_tilegen[1]->set_pf1_size(DECO_64x32); @@ -260,11 +260,10 @@ void vaportra_state::vaportra(machine_config &config) m_deco_tilegen[1]->set_bank2_callback(FUNC(vaportra_state::bank_callback), this); m_deco_tilegen[1]->set_pf12_8x8_bank(2); m_deco_tilegen[1]->set_pf12_16x16_bank(3); - m_deco_tilegen[1]->set_gfxdecode_tag("gfxdecode"); + m_deco_tilegen[1]->set_gfxdecode_tag(m_gfxdecode); DECO_MXC06(config, m_spritegen, 0); - m_spritegen->set_gfx_region(4); - m_spritegen->set_gfxdecode_tag("gfxdecode"); + m_spritegen->set_colpri_callback(FUNC(vaportra_state::vaportra_colpri_cb), this); /* sound hardware */ SPEAKER(config, "mono").front_center(); diff --git a/src/mame/includes/actfancr.h b/src/mame/includes/actfancr.h index 0907eb9e12b..f4f36c9306c 100644 --- a/src/mame/includes/actfancr.h +++ b/src/mame/includes/actfancr.h @@ -19,6 +19,7 @@ public: driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), + m_gfxdecode(*this, "gfxdecode"), m_tilegen(*this, "tilegen%u", 1U), m_spritegen(*this, "spritegen"), m_soundlatch(*this, "soundlatch") { } @@ -32,6 +33,7 @@ public: /* devices */ required_device m_maincpu; required_device m_audiocpu; + required_device m_gfxdecode; required_device_array m_tilegen; required_device m_spritegen; required_device m_soundlatch; diff --git a/src/mame/includes/dec0.h b/src/mame/includes/dec0.h index d3ccfe67c48..43a600f0387 100644 --- a/src/mame/includes/dec0.h +++ b/src/mame/includes/dec0.h @@ -87,6 +87,8 @@ protected: DECLARE_READ16_MEMBER(slyspy_controls_r); DECLARE_WRITE16_MEMBER(priority_w); + void robocop_colpri_cb(u32 &colour, u32 &pri_mask); + void set_screen_raw_params_data_east(machine_config &config); private: @@ -149,6 +151,10 @@ private: uint32_t screen_update_slyspy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); uint32_t screen_update_midres(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void hbarrel_colpri_cb(u32 &colour, u32 &pri_mask); + void bandit_colpri_cb(u32 &colour, u32 &pri_mask); + void midres_colpri_cb(u32 &colour, u32 &pri_mask); + void baddudes_i8751_write(int data); void birdtry_i8751_write(int data); void dec0_i8751_write(int data); diff --git a/src/mame/includes/dec8.h b/src/mame/includes/dec8.h index b35d71c8dfe..f3a1ea0c225 100644 --- a/src/mame/includes/dec8.h +++ b/src/mame/includes/dec8.h @@ -202,6 +202,7 @@ private: DECLARE_WRITE_LINE_MEMBER(shackled_coin_irq); void srdarwin_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &primap); void gondo_colpri_cb(u32 &colour, u32 &pri_mask); + void cobracom_colpri_cb(u32 &colour, u32 &pri_mask); DECLARE_WRITE_LINE_MEMBER(csilver_adpcm_int); void set_screen_raw_params_data_east(machine_config &config); diff --git a/src/mame/includes/vaportra.h b/src/mame/includes/vaportra.h index d64154bf24b..728d1e2ecf3 100644 --- a/src/mame/includes/vaportra.h +++ b/src/mame/includes/vaportra.h @@ -27,6 +27,7 @@ public: , m_deco_tilegen(*this, "tilegen%u", 1U) , m_spritegen(*this, "spritegen") , m_spriteram(*this, "spriteram") + , m_gfxdecode(*this, "gfxdecode") , m_palette(*this, "colors") , m_soundlatch(*this, "soundlatch") , m_paletteram(*this, "palette") @@ -44,6 +45,7 @@ private: required_device_array m_deco_tilegen; required_device m_spritegen; required_device m_spriteram; + required_device m_gfxdecode; required_device m_palette; required_device m_soundlatch; @@ -62,6 +64,7 @@ private: virtual void machine_start() override; virtual void machine_reset() override; + void vaportra_colpri_cb(u32 &colour, u32 &pri_mask); uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void update_palette( int offset ); diff --git a/src/mame/video/actfancr.cpp b/src/mame/video/actfancr.cpp index de397cdd92b..f56c166a641 100644 --- a/src/mame/video/actfancr.cpp +++ b/src/mame/video/actfancr.cpp @@ -26,7 +26,7 @@ uint32_t actfancr_state::screen_update(screen_device &screen, bitmap_ind16 &bitm m_spritegen->set_flip_screen(flip); m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 0); - m_spritegen->draw_sprites(bitmap, cliprect, m_spriteram16.get(), 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(1), m_spriteram16.get(), 0x800/2); m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); return 0; diff --git a/src/mame/video/dec0.cpp b/src/mame/video/dec0.cpp index d59f30942bb..3c4508fec77 100644 --- a/src/mame/video/dec0.cpp +++ b/src/mame/video/dec0.cpp @@ -14,6 +14,14 @@ /******************************************************************************/ +void dec0_state::hbarrel_colpri_cb(u32 &colour, u32 &pri_mask) +{ + pri_mask = 0; // above background, foreground + if (colour & 8) + { + pri_mask |= GFX_PMASK_2; // behind foreground + } +} uint32_t dec0_state::screen_update_hbarrel(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { @@ -25,18 +33,26 @@ uint32_t dec0_state::screen_update_hbarrel(screen_device &screen, bitmap_ind16 & m_spritegen->set_flip_screen(flip); m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, 0x08, 0x0f); m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); /* HB always keeps pf2 on top of pf3, no need explicitly support priority register */ - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); return 0; } /******************************************************************************/ +void dec0_state::bandit_colpri_cb(u32 &colour, u32 &pri_mask) +{ + pri_mask = 0; // above all + if (m_pri == 0) + { + pri_mask |= GFX_PMASK_4; // behind foreground + } +} + uint32_t dec0_state::screen_update_bandit(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { screen.priority().fill(0,cliprect); @@ -46,20 +62,10 @@ uint32_t dec0_state::screen_update_bandit(screen_device &screen, bitmap_ind16 &b m_tilegen[2]->set_flip_screen(flip); m_spritegen->set_flip_screen(flip); - if (m_pri==0) - { - m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); - m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 4); - } - else - { - m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); - m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 4); - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); - } + m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); + m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); + m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 4); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); return 0; } @@ -82,7 +88,7 @@ uint32_t dec0_state::screen_update_baddudes(screen_device &screen, bitmap_ind16 if (m_pri & 2) m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0,0x08,0x08,0x08,0x08, 0); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */ - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); if (m_pri & 4) m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,0,0x08,0x08,0x08,0x08); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */ @@ -95,7 +101,7 @@ uint32_t dec0_state::screen_update_baddudes(screen_device &screen, bitmap_ind16 if (m_pri & 2) m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,0,0x08,0x08,0x08,0x08, 0); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */ - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); if (m_pri & 4) m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0,0x08,0x08,0x08,0x08, 0); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */ @@ -107,10 +113,20 @@ uint32_t dec0_state::screen_update_baddudes(screen_device &screen, bitmap_ind16 /******************************************************************************/ +void dec0_state::robocop_colpri_cb(u32 &colour, u32 &pri_mask) +{ + pri_mask = 0; // above background, foreground + if (m_pri & 0x02) + { + const u32 trans = (m_pri & 0x04) ? 0x08 : 0x00; + if ((colour & 0x08) == trans) + pri_mask |= GFX_PMASK_2; // behind foreground + } +} + uint32_t dec0_state::screen_update_robocop(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { screen.priority().fill(0,cliprect); - int trans; bool flip = m_tilegen[0]->get_flip_state(); m_tilegen[0]->set_flip_screen(flip); @@ -118,11 +134,6 @@ uint32_t dec0_state::screen_update_robocop(screen_device &screen, bitmap_ind16 & m_tilegen[2]->set_flip_screen(flip); m_spritegen->set_flip_screen(flip); - if (m_pri & 0x04) - trans = 0x08; - else - trans = 0x00; - if (m_pri & 0x01) { /* WARNING: inverted wrt Midnight Resistance */ @@ -130,27 +141,15 @@ uint32_t dec0_state::screen_update_robocop(screen_device &screen, bitmap_ind16 & /* completely wrong. The top 8 bits of the register might mean */ /* something (they are 0x80 in midres, 0x00 here) */ m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - - if (m_pri & 0x02) - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, trans, 0x0f); - m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); } else { m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - - if (m_pri & 0x02) - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, trans, 0x0f); - m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); } - if (m_pri & 0x02) - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, trans^0x08, 0x0f); - else - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); - + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); return 0; } @@ -159,7 +158,6 @@ uint32_t dec0_state::screen_update_robocop(screen_device &screen, bitmap_ind16 & uint32_t dec0_automat_state::screen_update_automat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { screen.priority().fill(0,cliprect); - int trans; // layer enables seem different... where are they? @@ -196,35 +194,18 @@ uint32_t dec0_automat_state::screen_update_automat(screen_device &screen, bitmap m_tilegen[2]->set_flip_screen(flip); m_spritegen->set_flip_screen(flip); - if (m_pri & 0x04) - trans = 0x08; - else - trans = 0x00; - if (m_pri & 0x01) { m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - - if (m_pri & 0x02) - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, trans, 0x0f); - m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); } else { m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - - if (m_pri & 0x02) - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, trans, 0x0f); - m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); } - if (m_pri & 0x02) - m_spritegen->draw_sprites_bootleg(bitmap, cliprect, m_buffered_spriteram, 0x08, trans^0x08, 0x0f); - else - m_spritegen->draw_sprites_bootleg(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); - + m_spritegen->draw_sprites_bootleg(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); // TODO : RAM size m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); return 0; } @@ -268,7 +249,7 @@ uint32_t dec0_automat_state::screen_update_secretab(screen_device &screen, bitma m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 0); m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); - m_spritegen->draw_sprites_bootleg(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites_bootleg(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); // TODO : RAM size /* Redraw top 8 pens of top 8 palettes over sprites */ if (m_pri & 0x80) @@ -292,7 +273,7 @@ uint32_t dec0_state::screen_update_birdtry(screen_device &screen, bitmap_ind16 & the palette does show through. */ bitmap.fill(m_palette->pen(768), cliprect); m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); return 0; } @@ -318,7 +299,7 @@ uint32_t dec0_state::screen_update_hippodrm(screen_device &screen, bitmap_ind16 m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); } - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); return 0; } @@ -336,7 +317,7 @@ uint32_t dec0_state::screen_update_slyspy(screen_device &screen, bitmap_ind16 &b m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 0); m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); /* Redraw top 8 pens of top 8 palettes over sprites */ if (m_pri & 0x80) @@ -348,10 +329,20 @@ uint32_t dec0_state::screen_update_slyspy(screen_device &screen, bitmap_ind16 &b /******************************************************************************/ +void dec0_state::midres_colpri_cb(u32 &colour, u32 &pri_mask) +{ + pri_mask = 0; // above background, foreground + if (m_pri & 0x02) + { + const u32 trans = (m_pri & 0x04) ? 0x00 : 0x08; + if ((colour & 0x08) == trans) + pri_mask |= GFX_PMASK_2; // behind foreground + } +} + uint32_t dec0_state::screen_update_midres(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { screen.priority().fill(0,cliprect); - int trans; bool flip = m_tilegen[0]->get_flip_state(); m_tilegen[0]->set_flip_screen(flip); @@ -359,34 +350,18 @@ uint32_t dec0_state::screen_update_midres(screen_device &screen, bitmap_ind16 &b m_tilegen[2]->set_flip_screen(flip); m_spritegen->set_flip_screen(flip); - if (m_pri & 0x04) - trans = 0x00; - else trans = 0x08; - if (m_pri & 0x01) { m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - - if (m_pri & 0x02) - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, trans, 0x0f); - m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); } else { m_tilegen[2]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - - if (m_pri & 0x02) - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, trans, 0x0f); - m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); } - if (m_pri & 0x02) - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x08, trans ^ 0x08, 0x0f); - else - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); - + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(3), m_buffered_spriteram, 0x800/2); m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 0); return 0; } diff --git a/src/mame/video/dec8.cpp b/src/mame/video/dec8.cpp index f570129fcdf..d58a6b33d71 100644 --- a/src/mame/video/dec8.cpp +++ b/src/mame/video/dec8.cpp @@ -206,6 +206,15 @@ void dec8_state::srdarwin_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cl /******************************************************************************/ +void dec8_state::cobracom_colpri_cb(u32 &colour, u32 &pri_mask) +{ + pri_mask = 0; // above foreground, background + if ((colour & 4) == 0) + pri_mask |= GFX_PMASK_2; // behind foreground, above background + + colour &= 3; +} + uint32_t dec8_state::screen_update_cobracom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { screen.priority().fill(0,cliprect); @@ -216,9 +225,8 @@ uint32_t dec8_state::screen_update_cobracom(screen_device &screen, bitmap_ind16 m_fix_tilemap->set_flip(flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 1); - m_spritegen_mxc->draw_sprites(bitmap, cliprect, m_buffered_spriteram16.get(), 0x04, 0x00, 0x03); m_tilegen[1]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00, 2); - m_spritegen_mxc->draw_sprites(bitmap, cliprect, m_buffered_spriteram16.get(), 0x04, 0x04, 0x03); + m_spritegen_mxc->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(1), m_buffered_spriteram16.get(), 0x800/2); m_fix_tilemap->draw(screen, bitmap, cliprect, 0, 0); return 0; } @@ -296,7 +304,7 @@ uint32_t dec8_state::screen_update_oscar(screen_device &screen, bitmap_ind16 &bi // we mimic the priority scheme in dec0.cpp, this was originally a bit different, so this could be wrong m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 0); - m_spritegen_mxc->draw_sprites(bitmap, cliprect, m_buffered_spriteram16.get(), 0x00, 0x00, 0x0f); + m_spritegen_mxc->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(1), m_buffered_spriteram16.get(), 0x800/2); m_tilegen[0]->deco_bac06_pf_draw(screen,bitmap,cliprect,0, 0x08,0x08,0x08,0x08, 0); m_fix_tilemap->draw(screen, bitmap, cliprect, 0, 0); return 0; diff --git a/src/mame/video/decbac06.cpp b/src/mame/video/decbac06.cpp index 92ae9fbe815..137dbf730b5 100644 --- a/src/mame/video/decbac06.cpp +++ b/src/mame/video/decbac06.cpp @@ -389,7 +389,7 @@ void deco_bac06_device::deco_bac06_pf_draw(screen_device &screen,bitmap_ind16 &b } if (tm) - custom_tilemap_draw(bitmap,screen.priority(),cliprect,tm,m_pf_rowscroll.get(),m_pf_colscroll.get(),m_pf_control_0,m_pf_control_1,flags, penmask, pencondition, colprimask, colpricondition, bppmult, bppmask); + custom_tilemap_draw(bitmap,screen.priority(),cliprect,tm,m_pf_rowscroll.get(),m_pf_colscroll.get(),m_pf_control_0,m_pf_control_1,flags, penmask, pencondition, colprimask, colpricondition, bppmult, bppmask, pri, primask); } // used for pocket gal bootleg, which doesn't set registers properly and simply expects a fixed size tilemap. @@ -410,7 +410,7 @@ void deco_bac06_device::deco_bac06_pf_draw_bootleg(screen_device &screen,bitmap_ bppmask = m_bppmask_16x16; } - custom_tilemap_draw(bitmap,screen.priority(),cliprect,tm,m_pf_rowscroll.get(),m_pf_colscroll.get(),nullptr,nullptr,flags, 0, 0, 0, 0, bppmult, bppmask); + custom_tilemap_draw(bitmap,screen.priority(),cliprect,tm,m_pf_rowscroll.get(),m_pf_colscroll.get(),nullptr,nullptr,flags, 0, 0, 0, 0, bppmult, bppmask, pri, primask); } diff --git a/src/mame/video/decmxc06.cpp b/src/mame/video/decmxc06.cpp index fbf91e3cbaa..621e5e1d161 100644 --- a/src/mame/video/decmxc06.cpp +++ b/src/mame/video/decmxc06.cpp @@ -47,35 +47,37 @@ DEFINE_DEVICE_TYPE(DECO_MXC06, deco_mxc06_device, "deco_mxc06", "DECO MXC06 Spri deco_mxc06_device::deco_mxc06_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, DECO_MXC06, tag, owner, clock) , device_video_interface(mconfig, *this) - , m_gfxregion(0) - , m_ramsize(0x800) - , m_gfxdecode(*this, finder_base::DUMMY_TAG) { } /* this implementation was originally from Mad Motor */ -void deco_mxc06_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, uint16_t* spriteram, int pri_mask, int pri_val, int col_mask ) +void deco_mxc06_device::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, u16* spriteram, int size) { - int offs; + const bool priority = !m_colpri_cb.isnull(); + int start, end, inc; + if (priority) { start = size - 4; end = -4; inc = -4; } + else { start = 0; end = size; inc = +4; } - offs = 0; - while (offs < m_ramsize / 2) + for (int offs = start; offs != end; offs += inc) { - int sx, sy, code, color, w, h, flipx, flipy, incy, flash, mult, x, y, parentFlipY; + u32 pri_mask = 0; + int flipy, incy, mult, parentFlipY; - sy = spriteram[offs]; - sx = spriteram[offs + 2]; - color = sx >> 12; + const u16 data0 = spriteram[offs]; + const u16 data2 = spriteram[offs + 2]; + u32 colour = data2 >> 12; + if (priority) + m_colpri_cb(colour, pri_mask); - flash = sx & 0x800; + const bool flash = data2 & 0x800; - flipx = sy & 0x2000; - parentFlipY = flipy = sy & 0x4000; - h = (1 << ((sy & 0x1800) >> 11)); /* 1x, 2x, 4x, 8x height */ - w = (1 << ((sy & 0x0600) >> 9)); /* 1x, 2x, 4x, 8x width */ + int flipx = data0 & 0x2000; + parentFlipY = flipy = data0 & 0x4000; + const u16 h = (1 << ((data0 & 0x1800) >> 11)); /* 1x, 2x, 4x, 8x height */ + const u16 w = (1 << ((data0 & 0x0600) >> 9)); /* 1x, 2x, 4x, 8x width */ - sx = sx & 0x01ff; - sy = sy & 0x01ff; + int sx = data2 & 0x01ff; + int sy = data0 & 0x01ff; if (sx >= 256) sx -= 512; if (sy >= 256) sy -= 512; sx = 240 - sx; @@ -92,19 +94,14 @@ void deco_mxc06_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cli else mult = -16; - // thedeep strongly suggests that this check goes here, otherwise the radar breaks if (!(spriteram[offs] & 0x8000)) - { - offs += 4; continue; - } - - for (x = 0; x < w; x++) + for (int x = 0; x < w; x++) { // maybe, birdie try appears to specify the base code for each part.. - code = spriteram[offs + 1] & 0x1fff; + u16 code = spriteram[offs + 1] & 0x1fff; code &= ~(h - 1); @@ -117,88 +114,82 @@ void deco_mxc06_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cli incy = 1; } - for (y = 0; y < h; y++) + for (int y = 0; y < h; y++) { + if (!flash || (screen.frame_number() & 1)) { - int draw = 0; - if (!flash || (screen().frame_number() & 1)) + if (priority) { - if (m_priority_type == 0) // most cases - { - if ((color & pri_mask) == pri_val) - { - draw = 1; - } - } - else if (m_priority_type == 1) // vaportra - { - if (pri_mask && (color >= pri_val)) - continue; - - if (!pri_mask && !(color >= pri_val)) - continue; - - draw = 1; - } + gfx->prio_transpen(bitmap, cliprect, + code - y * incy, + colour, + flipx, flipy, + sx + (mult * x), sy + (mult * y), screen.priority(), pri_mask, 0); } - - if (draw) + else { - m_gfxdecode->gfx(m_gfxregion)->transpen(bitmap, cliprect, + gfx->transpen(bitmap, cliprect, code - y * incy, - color & col_mask, + colour, flipx, flipy, sx + (mult * x), sy + (mult * y), 0); } } } - - offs += 4; - if (offs >= m_ramsize / 2) - return; - - } } } /* this is used by the automat bootleg, it seems to have greatly simplified sprites compared to the real chip */ /* spriteram is twice the size tho! */ -void deco_mxc06_device::draw_sprites_bootleg( bitmap_ind16 &bitmap, const rectangle &cliprect, uint16_t* spriteram, int pri_mask, int pri_val, int col_mask ) +void deco_mxc06_device::draw_sprites_bootleg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, u16* spriteram, int size) { - int offs; + const bool priority = !m_colpri_cb.isnull(); + int start, end, inc; + if (priority) { start = size - 4; end = -4; inc = -4; } + else { start = 0; end = size; inc = +4; } - offs = 0; - while (offs < m_ramsize / 2) + for (int offs = start; offs != end; offs += inc) { - int sx, sy, code, color, flipx, flipy; - - code = spriteram[offs]; - sy = 240-spriteram[offs + 1]; // 241- will align robocop with the ground but causes other issues too - sx = spriteram[offs + 2]; + u32 pri_mask = 0; + u32 code = spriteram[offs]; + int sy = 240-spriteram[offs + 1]; // 241- will align robocop with the ground but causes other issues too + int sx = spriteram[offs + 2]; code |= (spriteram[offs + 3] &0x0f)<<8; - flipx = !(spriteram[offs + 3] &0x20); - flipy = (spriteram[offs + 3] &0x40); - color = (spriteram[offs + 0x400]&0xf0)>>4; - sx |= (spriteram[offs + 0x400]&0x01)<<8; + const bool flipx = !(spriteram[offs + 3] &0x20); + const bool flipy = (spriteram[offs + 3] &0x40); + u32 colour = (spriteram[offs + 0x400] & 0xf0) >> 4; + if (priority) + m_colpri_cb(colour, pri_mask); + + sx |= (spriteram[offs + 0x400] & 0x01) << 8; sx -= 16; sx &=0x1ff; sx -= 0x100; - m_gfxdecode->gfx(m_gfxregion)->transpen(bitmap,cliprect, - code, - color & col_mask, - flipx,flipy, - sx,sy,0); - - offs += 4; + if (priority) + { + gfx->prio_transpen(bitmap,cliprect, + code, + colour, + flipx,flipy, + sx,sy,screen.priority(),pri_mask,0); + } + else + { + gfx->transpen(bitmap,cliprect, + code, + colour, + flipx,flipy, + sx,sy,0); + } } } void deco_mxc06_device::device_start() { - m_priority_type = 0; + m_colpri_cb.bind_relative_to(*owner()); m_flip_screen = false; save_item(NAME(m_flip_screen)); diff --git a/src/mame/video/decmxc06.h b/src/mame/video/decmxc06.h index 19d6c304e81..5df8e00720b 100644 --- a/src/mame/video/decmxc06.h +++ b/src/mame/video/decmxc06.h @@ -5,6 +5,9 @@ #pragma once +#include "screen.h" + +typedef device_delegate decmxc06_colpri_cb_delegate; class deco_mxc06_device : public device_t, public device_video_interface { @@ -12,27 +15,19 @@ public: deco_mxc06_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // configuration - template void set_gfxdecode_tag(T &&tag) { m_gfxdecode.set_tag(std::forward(tag)); } - void set_gfx_region(int region) { m_gfxregion = region; } - void set_ram_size(int size) { m_ramsize = size; } - - void set_gfxregion(int region) { m_gfxregion = region; }; - void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, uint16_t* spriteram16, int pri_mask, int pri_val, int col_mask); - void draw_sprites_bootleg(bitmap_ind16 &bitmap, const rectangle &cliprect, uint16_t* spriteram, int pri_mask, int pri_val, int col_mask); - void set_pri_type(int type) { m_priority_type = type; } + template void set_colpri_callback(T &&... args) { m_colpri_cb = decmxc06_colpri_cb_delegate(std::forward(args)...); } + + void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, u16* spriteram, int size); + void draw_sprites_bootleg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, u16* spriteram, int size); void set_flip_screen(bool flip) { m_flip_screen = flip; } protected: virtual void device_start() override; virtual void device_reset() override; - uint8_t m_gfxregion; - int m_priority_type; // just so we can support the existing drivers without converting everything to pdrawgfx just yet - int m_ramsize; - bool m_flip_screen; - private: - required_device m_gfxdecode; + decmxc06_colpri_cb_delegate m_colpri_cb; + bool m_flip_screen; }; DECLARE_DEVICE_TYPE(DECO_MXC06, deco_mxc06_device) diff --git a/src/mame/video/stadhero.cpp b/src/mame/video/stadhero.cpp index 0810b7bcabd..6a18766b51a 100644 --- a/src/mame/video/stadhero.cpp +++ b/src/mame/video/stadhero.cpp @@ -28,7 +28,7 @@ uint32_t stadhero_state::screen_update(screen_device &screen, bitmap_ind16 &bitm m_pf1_tilemap->set_flip(flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); m_tilegen->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00, 0); - m_spritegen->draw_sprites(bitmap, cliprect, m_spriteram, 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(2), m_spriteram, 0x800/2); m_pf1_tilemap->draw(screen, bitmap, cliprect, 0,0); return 0; } diff --git a/src/mame/video/thedeep.cpp b/src/mame/video/thedeep.cpp index 6338b6fdaeb..28a06b5d713 100644 --- a/src/mame/video/thedeep.cpp +++ b/src/mame/video/thedeep.cpp @@ -131,7 +131,7 @@ uint32_t thedeep_state::screen_update(screen_device &screen, bitmap_ind16 &bitma bitmap.fill(m_palette->black_pen(), cliprect); m_tilemap_0->draw(screen, bitmap, cliprect, 0,0); - m_spritegen->draw_sprites(bitmap, cliprect, reinterpret_cast(m_spriteram.target()), 0x00, 0x00, 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(0), reinterpret_cast(m_spriteram.target()), 0x400/2); m_tilemap_1->draw(screen, bitmap, cliprect, 0,0); return 0; } diff --git a/src/mame/video/vaportra.cpp b/src/mame/video/vaportra.cpp index db5f1b95a6a..c48c16424ea 100644 --- a/src/mame/video/vaportra.cpp +++ b/src/mame/video/vaportra.cpp @@ -50,50 +50,54 @@ WRITE16_MEMBER(vaportra_state::palette_ext_w) /******************************************************************************/ +void vaportra_state::vaportra_colpri_cb(u32 &colour, u32 &pri_mask) +{ + pri_mask = 0; // above back, mid, foreground + if (colour >= m_priority[1]) + { + pri_mask |= GFX_PMASK_4; // behind foreground + } +} uint32_t vaportra_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { uint16_t flip = m_deco_tilegen[0]->pf_control_r(0); int pri = m_priority[0] & 0x03; + screen.priority().fill(0, cliprect); flip_screen_set(!BIT(flip, 7)); m_deco_tilegen[0]->pf_update(nullptr, nullptr); m_deco_tilegen[1]->pf_update(nullptr, nullptr); m_spritegen->set_flip_screen(!BIT(flip, 7)); - m_spritegen->set_pri_type(1); // force priorities to be handled in a different way for this driver for now /* Draw playfields */ if (pri == 0) { - m_deco_tilegen[1]->tilemap_2_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); - m_deco_tilegen[1]->tilemap_1_draw(screen, bitmap, cliprect, 0, 0); - m_spritegen->draw_sprites(bitmap, cliprect, m_spriteram->buffer(), 0, m_priority[1], 0x0f); - m_deco_tilegen[0]->tilemap_2_draw(screen, bitmap, cliprect, 0, 0); + m_deco_tilegen[1]->tilemap_2_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1); + m_deco_tilegen[1]->tilemap_1_draw(screen, bitmap, cliprect, 0, 2); + m_deco_tilegen[0]->tilemap_2_draw(screen, bitmap, cliprect, 0, 4); } else if (pri == 1) { - m_deco_tilegen[1]->tilemap_1_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); - m_deco_tilegen[1]->tilemap_2_draw(screen, bitmap, cliprect, 0, 0); - m_spritegen->draw_sprites(bitmap, cliprect, m_spriteram->buffer(), 0, m_priority[1], 0x0f); - m_deco_tilegen[0]->tilemap_2_draw(screen, bitmap, cliprect, 0, 0); + m_deco_tilegen[1]->tilemap_1_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1); + m_deco_tilegen[1]->tilemap_2_draw(screen, bitmap, cliprect, 0, 2); + m_deco_tilegen[0]->tilemap_2_draw(screen, bitmap, cliprect, 0, 4); } else if (pri == 2) { - m_deco_tilegen[1]->tilemap_2_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); - m_deco_tilegen[0]->tilemap_2_draw(screen, bitmap, cliprect, 0, 0); - m_spritegen->draw_sprites(bitmap, cliprect, m_spriteram->buffer(), 0, m_priority[1], 0x0f); - m_deco_tilegen[1]->tilemap_1_draw(screen, bitmap, cliprect, 0, 0); + m_deco_tilegen[1]->tilemap_2_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1); + m_deco_tilegen[0]->tilemap_2_draw(screen, bitmap, cliprect, 0, 2); + m_deco_tilegen[1]->tilemap_1_draw(screen, bitmap, cliprect, 0, 4); } else { - m_deco_tilegen[1]->tilemap_1_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); - m_deco_tilegen[0]->tilemap_2_draw(screen, bitmap, cliprect, 0, 0); - m_spritegen->draw_sprites(bitmap, cliprect, m_spriteram->buffer(), 0, m_priority[1], 0x0f); - m_deco_tilegen[1]->tilemap_2_draw(screen, bitmap, cliprect, 0, 0); + m_deco_tilegen[1]->tilemap_1_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1); + m_deco_tilegen[0]->tilemap_2_draw(screen, bitmap, cliprect, 0, 2); + m_deco_tilegen[1]->tilemap_2_draw(screen, bitmap, cliprect, 0, 4); } - m_spritegen->draw_sprites(bitmap, cliprect, m_spriteram->buffer(), 1, m_priority[1], 0x0f); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(4), m_spriteram->buffer(), 0x800 / 2); m_deco_tilegen[0]->tilemap_1_draw(screen, bitmap, cliprect, 0, 0); return 0; } -- cgit v1.2.3