From 6674d988d8e779ccddee869b4d88462f5b3f5c43 Mon Sep 17 00:00:00 2001 From: cam900 Date: Wed, 5 Jun 2019 12:49:24 +0900 Subject: excellent_spr.cpp : Updates Internalize gfxdecode, Use callback for priority behavior, Reduce unnecessary lines, Simplify handlers, Fix spacings aquarium.cpp, gcpinbal.cpp : Updates Simplify handlers, gfxdecodes, Reduce unnecessary lines, Runtime tag lookups, Fix namings, Use shorter / correct type values, Move virtuals under protected:, Rearrange devices under values in .h files gcpinbal.cpp : Make tilemap dirty when tilebank is changed --- src/mame/drivers/aquarium.cpp | 132 +++++++++++++--------------- src/mame/drivers/gcpinbal.cpp | 72 ++++++++-------- src/mame/includes/aquarium.h | 50 ++++++----- src/mame/includes/gcpinbal.h | 77 +++++++++-------- src/mame/video/aquarium.cpp | 86 +++++++------------ src/mame/video/excellent_spr.cpp | 180 +++++++++++++++++++++++++-------------- src/mame/video/excellent_spr.h | 20 +++-- src/mame/video/gcpinbal.cpp | 56 +++++------- 8 files changed, 348 insertions(+), 325 deletions(-) diff --git a/src/mame/drivers/aquarium.cpp b/src/mame/drivers/aquarium.cpp index d4379d9181f..7a9306c2131 100644 --- a/src/mame/drivers/aquarium.cpp +++ b/src/mame/drivers/aquarium.cpp @@ -59,16 +59,16 @@ Notes: #include "speaker.h" -WRITE8_MEMBER(aquarium_state::aquarium_watchdog_w) +void aquarium_state::watchdog_w(u8 data) { m_watchdog->write_line_ck(BIT(data, 7)); // bits 0 & 1 also used } -WRITE8_MEMBER(aquarium_state::aquarium_z80_bank_w) +void aquarium_state::z80_bank_w(u8 data) { // uses bits ---x --xx - data = bitswap<8>(data, 7, 6, 5, 2, 3, 1, 4, 0); + data = bitswap<8>(data, 7, 6, 5, 2, 3, 1, 4, 0); //printf("aquarium bank %04x %04x\n", data, mem_mask); // aquarium bank 0003 00ff - correct (title) 011 @@ -76,35 +76,32 @@ WRITE8_MEMBER(aquarium_state::aquarium_z80_bank_w) // aquarium bank 0005 00ff - level 1 (correct) // (all music seems correct w/regards the reference video) - - membank("bank1")->set_entry(data & 0x7); + m_audiobank->set_entry(data & 0x7); } -uint8_t aquarium_state::aquarium_snd_bitswap( uint8_t scrambled_data ) +u8 aquarium_state::snd_bitswap(u8 scrambled_data) { return bitswap<8>(scrambled_data, 0, 1, 2, 3, 4, 5, 6, 7); } -READ8_MEMBER(aquarium_state::aquarium_oki_r) +u8 aquarium_state::oki_r() { - return aquarium_snd_bitswap(m_oki->read()); + return snd_bitswap(m_oki->read()); } -WRITE8_MEMBER(aquarium_state::aquarium_oki_w) +void aquarium_state::oki_w(u8 data) { - logerror("%s:Writing %04x to the OKI M6295\n", machine().describe_context(), aquarium_snd_bitswap(data)); - m_oki->write(aquarium_snd_bitswap(data)); + logerror("%s:Writing %04x to the OKI M6295\n", machine().describe_context(), snd_bitswap(data)); + m_oki->write(snd_bitswap(data)); } - - void aquarium_state::main_map(address_map &map) { map(0x000000, 0x07ffff).rom(); - map(0xc00000, 0xc00fff).ram().w(FUNC(aquarium_state::aquarium_mid_videoram_w)).share("mid_videoram"); - map(0xc01000, 0xc01fff).ram().w(FUNC(aquarium_state::aquarium_bak_videoram_w)).share("bak_videoram"); - map(0xc02000, 0xc03fff).ram().w(FUNC(aquarium_state::aquarium_txt_videoram_w)).share("txt_videoram"); + map(0xc00000, 0xc00fff).ram().w(FUNC(aquarium_state::mid_videoram_w)).share("mid_videoram"); + map(0xc01000, 0xc01fff).ram().w(FUNC(aquarium_state::bak_videoram_w)).share("bak_videoram"); + map(0xc02000, 0xc03fff).ram().w(FUNC(aquarium_state::txt_videoram_w)).share("txt_videoram"); map(0xc80000, 0xc81fff).rw(m_sprgen, FUNC(excellent_spr_device::read), FUNC(excellent_spr_device::write)).umask16(0x00ff); map(0xd00000, 0xd00fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); map(0xd80014, 0xd8001f).writeonly().share("scroll"); @@ -113,7 +110,7 @@ void aquarium_state::main_map(address_map &map) map(0xd80082, 0xd80083).nopr(); /* stored but not read back ? check code at 0x01f440 */ map(0xd80084, 0xd80085).portr("INPUTS"); map(0xd80086, 0xd80087).portr("SYSTEM"); - map(0xd80088, 0xd80088).w(FUNC(aquarium_state::aquarium_watchdog_w)); + map(0xd80088, 0xd80088).w(FUNC(aquarium_state::watchdog_w)); map(0xd8008b, 0xd8008b).w(m_soundlatch, FUNC(generic_latch_8_device::write)); map(0xff0000, 0xffffff).ram(); } @@ -129,10 +126,10 @@ void aquarium_state::snd_portmap(address_map &map) { map.global_mask(0xff); map(0x00, 0x01).rw("ymsnd", FUNC(ym2151_device::read), FUNC(ym2151_device::write)); - map(0x02, 0x02).rw(FUNC(aquarium_state::aquarium_oki_r), FUNC(aquarium_state::aquarium_oki_w)); + map(0x02, 0x02).rw(FUNC(aquarium_state::oki_r), FUNC(aquarium_state::oki_w)); map(0x04, 0x04).r(m_soundlatch, FUNC(generic_latch_8_device::read)); map(0x06, 0x06).w(m_soundlatch, FUNC(generic_latch_8_device::acknowledge_w)); // only written with 0 for some reason - map(0x08, 0x08).w(FUNC(aquarium_state::aquarium_z80_bank_w)); + map(0x08, 0x08).w(FUNC(aquarium_state::z80_bank_w)); } static INPUT_PORTS_START( aquarium ) @@ -208,9 +205,9 @@ static const gfx_layout char5bpplayout = 16,16, /* 16*16 characters */ RGN_FRAC(1,2), 5, /* 4 bits per pixel */ - { RGN_FRAC(1,2), 0, 1, 2, 3 }, - { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4, 2*4+32, 3*4+32, 0*4+32, 1*4+32, 6*4+32, 7*4+32, 4*4+32, 5*4+32 }, - { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, + { RGN_FRAC(1,2), STEP4(0,1) }, + { STEP16(0,4) }, + { STEP16(0,4*16) }, 128*8 /* every sprite takes 128 consecutive bytes */ }; @@ -219,44 +216,33 @@ static const gfx_layout char_8x8_layout = 8,8, /* 8*8 characters */ RGN_FRAC(1,1), 4, /* 4 bits per pixel */ - { 0, 1, 2, 3 }, - { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4 }, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, + { STEP4(0,1) }, + { STEP8(0,4) }, + { STEP8(0,4*8) }, 32*8 /* every sprite takes 32 consecutive bytes */ }; -static const gfx_layout tilelayout = -{ - 16,16, /* 16*16 sprites */ - RGN_FRAC(1,1), - 4, /* 4 bits per pixel */ - { 48, 16, 32, 0 }, - { 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7 }, - { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, - 128*8 /* every sprite takes 128 consecutive bytes */ -}; - void aquarium_state::init_aquarium() { - uint8_t *Z80 = memregion("audiocpu")->base(); + u8 *Z80 = memregion("audiocpu")->base(); /* The BG tiles are 5bpp, this rearranges the data from the roms containing the 1bpp data so we can decode it correctly */ - uint8_t *DAT2 = memregion("gfx1")->base() + 0x080000; - uint8_t *DAT = memregion("user1")->base(); + u8 *DAT2 = memregion("gfx1")->base() + 0x080000; + u8 *DAT = memregion("user1")->base(); int len = 0x0200000; for (len = 0; len < 0x020000; len++) { - DAT2[len * 4 + 1] = (DAT[len] & 0x80) << 0; - DAT2[len * 4 + 1] |= (DAT[len] & 0x40) >> 3; - DAT2[len * 4 + 0] = (DAT[len] & 0x20) << 2; - DAT2[len * 4 + 0] |= (DAT[len] & 0x10) >> 1; - DAT2[len * 4 + 3] = (DAT[len] & 0x08) << 4; - DAT2[len * 4 + 3] |= (DAT[len] & 0x04) << 1; - DAT2[len * 4 + 2] = (DAT[len] & 0x02) << 6; - DAT2[len * 4 + 2] |= (DAT[len] & 0x01) << 3; + DAT2[len * 4 + 0] = (DAT[len] & 0x80) << 0; + DAT2[len * 4 + 0] |= (DAT[len] & 0x40) >> 3; + DAT2[len * 4 + 1] = (DAT[len] & 0x20) << 2; + DAT2[len * 4 + 1] |= (DAT[len] & 0x10) >> 1; + DAT2[len * 4 + 2] = (DAT[len] & 0x08) << 4; + DAT2[len * 4 + 2] |= (DAT[len] & 0x04) << 1; + DAT2[len * 4 + 3] = (DAT[len] & 0x02) << 6; + DAT2[len * 4 + 3] |= (DAT[len] & 0x01) << 3; } DAT2 = memregion("gfx4")->base() + 0x080000; @@ -264,27 +250,26 @@ void aquarium_state::init_aquarium() for (len = 0; len < 0x020000; len++) { - DAT2[len * 4 + 1] = (DAT[len] & 0x80) << 0; - DAT2[len * 4 + 1] |= (DAT[len] & 0x40) >> 3; - DAT2[len * 4 + 0] = (DAT[len] & 0x20) << 2; - DAT2[len * 4 + 0] |= (DAT[len] & 0x10) >> 1; - DAT2[len * 4 + 3] = (DAT[len] & 0x08) << 4; - DAT2[len * 4 + 3] |= (DAT[len] & 0x04) << 1; - DAT2[len * 4 + 2] = (DAT[len] & 0x02) << 6; - DAT2[len * 4 + 2] |= (DAT[len] & 0x01) << 3; + DAT2[len * 4 + 0] = (DAT[len] & 0x80) << 0; + DAT2[len * 4 + 0] |= (DAT[len] & 0x40) >> 3; + DAT2[len * 4 + 1] = (DAT[len] & 0x20) << 2; + DAT2[len * 4 + 1] |= (DAT[len] & 0x10) >> 1; + DAT2[len * 4 + 2] = (DAT[len] & 0x08) << 4; + DAT2[len * 4 + 2] |= (DAT[len] & 0x04) << 1; + DAT2[len * 4 + 3] = (DAT[len] & 0x02) << 6; + DAT2[len * 4 + 3] |= (DAT[len] & 0x01) << 3; } /* configure and set up the sound bank */ - membank("bank1")->configure_entries(0, 0x8, &Z80[0x00000], 0x8000); - membank("bank1")->set_entry(0x00); + m_audiobank->configure_entries(0, 0x8, &Z80[0x00000], 0x8000); + m_audiobank->set_entry(0x00); } static GFXDECODE_START( gfx_aquarium ) - GFXDECODE_ENTRY( "gfx3", 0, tilelayout, 0x300, 32 ) - GFXDECODE_ENTRY( "gfx1", 0, char5bpplayout, 0x400, 32 ) - GFXDECODE_ENTRY( "gfx2", 0, char_8x8_layout, 0x200, 32 ) - GFXDECODE_ENTRY( "gfx4", 0, char5bpplayout, 0x400, 32 ) + GFXDECODE_ENTRY( "gfx1", 0, char5bpplayout, 0x400, 32 ) + GFXDECODE_ENTRY( "gfx2", 0, char_8x8_layout, 0x200, 16 ) + GFXDECODE_ENTRY( "gfx4", 0, char5bpplayout, 0x400, 32 ) GFXDECODE_END void aquarium_state::aquarium(machine_config &config) @@ -307,13 +292,16 @@ void aquarium_state::aquarium(machine_config &config) m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0)); m_screen->set_size(64*8, 64*8); m_screen->set_visarea(2*8, 42*8-1, 2*8, 34*8-1); - m_screen->set_screen_update(FUNC(aquarium_state::screen_update_aquarium)); + m_screen->set_screen_update(FUNC(aquarium_state::screen_update)); m_screen->set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_aquarium); PALETTE(config, m_palette).set_format(palette_device::RRRRGGGGBBBBRGBx, 0x1000/2); EXCELLENT_SPRITE(config, m_sprgen, 0); + m_sprgen->set_palette(m_palette); + m_sprgen->set_color_base(0x300); + m_sprgen->set_colpri_callback(FUNC(aquarium_state::aquarium_colpri_cb), this); /* sound hardware */ SPEAKER(config, "lspeaker").front_left(); @@ -341,22 +329,22 @@ ROM_START( aquarium ) ROM_LOAD( "excellent_5.10c", 0x000000, 0x40000, CRC(fa555be1) SHA1(07236f2b2ba67e92984b9ddf4a8154221d535245) ) ROM_REGION( 0x100000, "gfx1", 0 ) /* BG Tiles */ - ROM_LOAD( "excellent_1.15b", 0x000000, 0x080000, CRC(575df6ac) SHA1(071394273e512666fe124facdd8591a767ad0819) ) // 4bpp + ROM_LOAD16_WORD_SWAP( "excellent_1.15b", 0x000000, 0x080000, CRC(575df6ac) SHA1(071394273e512666fe124facdd8591a767ad0819) ) // 4bpp /* data is expanded here from USER1 */ ROM_REGION( 0x100000, "user1", 0 ) /* BG Tiles */ ROM_LOAD( "excellent_6.15d", 0x000000, 0x020000, CRC(9065b146) SHA1(befc218bbcd63453ea7eb8f976796d36f2b2d552) ) // 1bpp ROM_REGION( 0x100000, "gfx4", 0 ) /* BG Tiles */ - ROM_LOAD( "excellent_8.14g", 0x000000, 0x080000, CRC(915520c4) SHA1(308207cb20f1ed6df365710c808644a6e4f07614) ) // 4bpp + ROM_LOAD16_WORD_SWAP( "excellent_8.14g", 0x000000, 0x080000, CRC(915520c4) SHA1(308207cb20f1ed6df365710c808644a6e4f07614) ) // 4bpp /* data is expanded here from USER2 */ ROM_REGION( 0x100000, "user2", 0 ) /* BG Tiles */ ROM_LOAD( "excellent_7.17g", 0x000000, 0x020000, CRC(b96b2b82) SHA1(2b719d0c185d1eca4cd9ea66bed7842b74062288) ) // 1bpp ROM_REGION( 0x060000, "gfx2", 0 ) /* FG Tiles */ - ROM_LOAD( "excellent_2.17e", 0x000000, 0x020000, CRC(aa071b05) SHA1(517415bfd8e4dd51c6eb03a25c706f8613d34a09) ) + ROM_LOAD16_WORD_SWAP( "excellent_2.17e", 0x000000, 0x020000, CRC(aa071b05) SHA1(517415bfd8e4dd51c6eb03a25c706f8613d34a09) ) - ROM_REGION( 0x200000, "gfx3", 0 ) /* Sprites? */ - ROM_LOAD( "d23c8000.1f", 0x000000, 0x0100000, CRC(14758b3c) SHA1(b372ccb42acb55a3dd15352a9d4ed576878a6731) ) // PCB denotes 23C16000 but a 23C8000 MASK is used + ROM_REGION( 0x200000, "spritegen", 0 ) /* Sprites? */ + ROM_LOAD16_WORD_SWAP( "d23c8000.1f", 0x000000, 0x0100000, CRC(14758b3c) SHA1(b372ccb42acb55a3dd15352a9d4ed576878a6731) ) // PCB denotes 23C16000 but a 23C8000 MASK is used ROM_REGION( 0x100000, "oki", 0 ) /* Samples */ ROM_LOAD( "excellent_4.7d", 0x000000, 0x80000, CRC(9a4af531) SHA1(bb201b7a6c9fd5924a0d79090257efffd8d4aba1) ) @@ -370,22 +358,22 @@ ROM_START( aquariumj ) ROM_LOAD( "excellent_5.10c", 0x000000, 0x40000, CRC(fa555be1) SHA1(07236f2b2ba67e92984b9ddf4a8154221d535245) ) ROM_REGION( 0x100000, "gfx1", 0 ) /* BG Tiles */ - ROM_LOAD( "excellent_1.15b", 0x000000, 0x080000, CRC(575df6ac) SHA1(071394273e512666fe124facdd8591a767ad0819) ) // 4bpp + ROM_LOAD16_WORD_SWAP( "excellent_1.15b", 0x000000, 0x080000, CRC(575df6ac) SHA1(071394273e512666fe124facdd8591a767ad0819) ) // 4bpp /* data is expanded here from USER1 */ ROM_REGION( 0x100000, "user1", 0 ) /* BG Tiles */ ROM_LOAD( "excellent_6.15d", 0x000000, 0x020000, CRC(9065b146) SHA1(befc218bbcd63453ea7eb8f976796d36f2b2d552) ) // 1bpp ROM_REGION( 0x100000, "gfx4", 0 ) /* BG Tiles */ - ROM_LOAD( "excellent_8.14g", 0x000000, 0x080000, CRC(915520c4) SHA1(308207cb20f1ed6df365710c808644a6e4f07614) ) // 4bpp + ROM_LOAD16_WORD_SWAP( "excellent_8.14g", 0x000000, 0x080000, CRC(915520c4) SHA1(308207cb20f1ed6df365710c808644a6e4f07614) ) // 4bpp /* data is expanded here from USER2 */ ROM_REGION( 0x100000, "user2", 0 ) /* BG Tiles */ ROM_LOAD( "excellent_7.17g", 0x000000, 0x020000, CRC(b96b2b82) SHA1(2b719d0c185d1eca4cd9ea66bed7842b74062288) ) // 1bpp ROM_REGION( 0x060000, "gfx2", 0 ) /* FG Tiles */ - ROM_LOAD( "excellent_2.17e", 0x000000, 0x020000, CRC(aa071b05) SHA1(517415bfd8e4dd51c6eb03a25c706f8613d34a09) ) + ROM_LOAD16_WORD_SWAP( "excellent_2.17e", 0x000000, 0x020000, CRC(aa071b05) SHA1(517415bfd8e4dd51c6eb03a25c706f8613d34a09) ) - ROM_REGION( 0x200000, "gfx3", 0 ) /* Sprites? */ - ROM_LOAD( "d23c8000.1f", 0x000000, 0x0100000, CRC(14758b3c) SHA1(b372ccb42acb55a3dd15352a9d4ed576878a6731) ) // PCB denotes 23C16000 but a 23C8000 MASK is used + ROM_REGION( 0x200000, "spritegen", 0 ) /* Sprites? */ + ROM_LOAD16_WORD_SWAP( "d23c8000.1f", 0x000000, 0x0100000, CRC(14758b3c) SHA1(b372ccb42acb55a3dd15352a9d4ed576878a6731) ) // PCB denotes 23C16000 but a 23C8000 MASK is used ROM_REGION( 0x100000, "oki", 0 ) /* Samples */ ROM_LOAD( "excellent_4.7d", 0x000000, 0x80000, CRC(9a4af531) SHA1(bb201b7a6c9fd5924a0d79090257efffd8d4aba1) ) diff --git a/src/mame/drivers/gcpinbal.cpp b/src/mame/drivers/gcpinbal.cpp index 72ca5c21482..5fd6fb4c820 100644 --- a/src/mame/drivers/gcpinbal.cpp +++ b/src/mame/drivers/gcpinbal.cpp @@ -94,13 +94,12 @@ NOTE: Mask ROMs from Power Flipper Pinball Shooting have not been dumped, but as TIMER_DEVICE_CALLBACK_MEMBER(gcpinbal_state::scanline_cb) { + if (param >= 16) + m_screen->update_partial(m_screen->vpos() - 1); - if (param>=16) - m_screen->update_partial(m_screen->vpos()-1); - - if (param==240) + if (param == 240) m_maincpu->set_input_line(1, HOLD_LINE); // V-blank - else if ((param>=16) && (param<240)) + else if ((param >= 16) && (param < 240)) m_maincpu->set_input_line(4, HOLD_LINE); // H-blank? (or programmable, used for raster effects) // IRQ level 3 is sound related, hooked up to MSM6585 @@ -110,24 +109,24 @@ TIMER_DEVICE_CALLBACK_MEMBER(gcpinbal_state::scanline_cb) IOC ***********************************************************/ -WRITE16_MEMBER(gcpinbal_state::d80010_w) +void gcpinbal_state::d80010_w(offs_t offset, u16 data, u16 mem_mask) { //logerror("CPU #0 PC %06x: warning - write ioc offset %06x with %04x\n", m_maincpu->pc(), offset, data); COMBINE_DATA(&m_d80010_ram[offset]); } -WRITE8_MEMBER(gcpinbal_state::d80040_w) +void gcpinbal_state::d80040_w(offs_t offset, u8 data) { logerror("Writing byte value %02X to offset %X\n", data, offset); } -WRITE16_MEMBER(gcpinbal_state::d80060_w) +void gcpinbal_state::d80060_w(offs_t offset, u16 data, u16 mem_mask) { //logerror("CPU #0 PC %06x: warning - write ioc offset %06x with %04x\n", m_maincpu->pc(), offset, data); COMBINE_DATA(&m_d80060_ram[offset]); } -WRITE8_MEMBER(gcpinbal_state::bank_w) +void gcpinbal_state::bank_w(u8 data) { // MSM6585 bank, coin LEDs, maybe others? if (m_msm_bank != ((data & 0x10) >> 4)) @@ -138,8 +137,21 @@ WRITE8_MEMBER(gcpinbal_state::bank_w) } m_oki->set_rom_bank((data & 0x20) >> 5); - m_bg0_gfxset = (data & 0x04) ? 0x1000 : 0; - m_bg1_gfxset = (data & 0x08) ? 0x1000 : 0; + u32 old = m_bg0_gfxset; + u32 newbank = (data & 0x04) ? 0x1000 : 0; + if (old != newbank) + { + m_bg0_gfxset = (data & 0x04) ? 0x1000 : 0; + m_tilemap[0]->mark_all_dirty(); + } + + old = m_bg1_gfxset; + newbank = (data & 0x08) ? 0x1000 : 0; + if (old != newbank) + { + m_bg1_gfxset = (data & 0x04) ? 0x1000 : 0; + m_tilemap[1]->mark_all_dirty(); + } m_watchdog->write_line_ck(BIT(data, 7)); @@ -147,7 +159,7 @@ WRITE8_MEMBER(gcpinbal_state::bank_w) // machine().bookkeeping().coin_lockout_w(1, ~data & 0x02); } -WRITE8_MEMBER(gcpinbal_state::eeprom_w) +void gcpinbal_state::eeprom_w(u8 data) { // 93C46 serial EEPROM (status read at D80087) m_eeprom->di_write(BIT(data, 2)); @@ -155,7 +167,7 @@ WRITE8_MEMBER(gcpinbal_state::eeprom_w) m_eeprom->cs_write(BIT(data, 0)); } -WRITE8_MEMBER(gcpinbal_state::es8712_reset_w) +void gcpinbal_state::es8712_reset_w(u8 data) { // This probably works by resetting the ES-8712 m_essnd->reset(); @@ -169,7 +181,7 @@ WRITE8_MEMBER(gcpinbal_state::es8712_reset_w) void gcpinbal_state::gcpinbal_map(address_map &map) { map(0x000000, 0x1fffff).rom(); - map(0xc00000, 0xc03fff).rw(FUNC(gcpinbal_state::gcpinbal_tilemaps_word_r), FUNC(gcpinbal_state::gcpinbal_tilemaps_word_w)).share("tilemapram"); + map(0xc00000, 0xc03fff).ram().w(FUNC(gcpinbal_state::tilemaps_word_w)).share("tilemapram"); map(0xc80000, 0xc81fff).rw(m_sprgen, FUNC(excellent_spr_device::read), FUNC(excellent_spr_device::write)).umask16(0x00ff); map(0xd00000, 0xd00fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); map(0xd80010, 0xd8002f).ram().w(FUNC(gcpinbal_state::d80010_w)).share("d80010"); @@ -305,22 +317,9 @@ static const gfx_layout char_8x8_layout = 8*8*4 /* every sprite takes 32 consecutive bytes */ }; -static const gfx_layout tilelayout = -{ - 16,16, /* 16*16 sprites */ - RGN_FRAC(1,1), - 4, /* 4 bits per pixel */ -// { 16, 48, 0, 32 }, - { 48, 16, 32, 0 }, - { STEP16(0,1) }, - { STEP16(0,16*4) }, - 16*16*4 /* every sprite takes 128 consecutive bytes */ -}; - static GFXDECODE_START( gfx_gcpinbal ) - GFXDECODE_ENTRY( "sprite", 0, tilelayout, 0, 256 ) // sprites & playfield - GFXDECODE_ENTRY( "bg0", 0, charlayout, 0, 256 ) // sprites & playfield - GFXDECODE_ENTRY( "fg0", 0, char_8x8_layout, 0, 256 ) // sprites & playfield + GFXDECODE_ENTRY( "bg0", 0, charlayout, 0, 0x60 ) // playfield + GFXDECODE_ENTRY( "fg0", 0, char_8x8_layout, 0x700, 0x10 ) // playfield GFXDECODE_END @@ -339,9 +338,7 @@ void gcpinbal_state::machine_start() void gcpinbal_state::machine_reset() { - int i; - - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { m_scrollx[i] = 0; m_scrolly[i] = 0; @@ -370,13 +367,16 @@ void gcpinbal_state::gcpinbal(machine_config &config) m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0) /* frames per second, vblank duration */); m_screen->set_size(40*8, 32*8); m_screen->set_visarea(0*8, 40*8-1, 2*8, 30*8-1); - m_screen->set_screen_update(FUNC(gcpinbal_state::screen_update_gcpinbal)); + m_screen->set_screen_update(FUNC(gcpinbal_state::screen_update)); m_screen->set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_gcpinbal); - PALETTE(config, m_palette).set_format(palette_device::RRRRGGGGBBBBRGBx, 4096); + PALETTE(config, m_palette).set_format(palette_device::RRRRGGGGBBBBRGBx, 0x1000/2); EXCELLENT_SPRITE(config, m_sprgen, 0); + m_sprgen->set_palette(m_palette); + m_sprgen->set_color_base(0x600); + m_sprgen->set_colpri_callback(FUNC(gcpinbal_state::gcpinbal_colpri_cb), this); /* sound hardware */ SPEAKER(config, "mono").front_center(); @@ -414,7 +414,7 @@ ROM_START( pwrflip ) /* Updated version of Grand Cross Pinball or semi-sequel? * ROM_REGION( 0x020000, "fg0", 0 ) /* FG0 (8 x 8) */ ROM_LOAD16_WORD_SWAP( "p.f.u10", 0x000000, 0x020000, CRC(50e34549) SHA1(ca1808513ff3feb8bcd34d9aafd7b374e4244732) ) - ROM_REGION( 0x200000, "sprite", 0 ) /* Sprites (16 x 16) */ + ROM_REGION( 0x200000, "spritegen", 0 ) /* Sprites (16 x 16) */ ROM_LOAD16_WORD_SWAP( "u13", 0x000000, 0x200000, CRC(62f3952f) SHA1(7dc9ccb753d46b6aaa791bcbf6e18e6d872f6b79) ) /* 23C16000 mask ROM */ ROM_REGION( 0x080000, "oki", 0 ) /* M6295 acc to Raine */ @@ -442,7 +442,7 @@ ROM_START( gcpinbal ) ROM_REGION( 0x020000, "fg0", 0 ) /* FG0 (8 x 8) */ ROM_LOAD16_WORD_SWAP( "1_excellent.u10", 0x000000, 0x020000, CRC(79321550) SHA1(61f1b772ed8cf95bfee9df8394b0c3ff727e8702) ) - ROM_REGION( 0x200000, "sprite", 0 ) /* Sprites (16 x 16) */ + ROM_REGION( 0x200000, "spritegen", 0 ) /* Sprites (16 x 16) */ ROM_LOAD16_WORD_SWAP( "u13", 0x000000, 0x200000, CRC(62f3952f) SHA1(7dc9ccb753d46b6aaa791bcbf6e18e6d872f6b79) ) /* 23C16000 mask ROM */ ROM_REGION( 0x080000, "oki", 0 ) /* M6295 acc to Raine */ diff --git a/src/mame/includes/aquarium.h b/src/mame/includes/aquarium.h index a5ef0d04b21..d66944177e9 100644 --- a/src/mame/includes/aquarium.h +++ b/src/mame/includes/aquarium.h @@ -21,6 +21,7 @@ public: m_bak_videoram(*this, "bak_videoram"), m_txt_videoram(*this, "txt_videoram"), m_scroll(*this, "scroll"), + m_audiobank(*this, "bank1"), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), m_oki(*this, "oki"), @@ -32,11 +33,20 @@ public: m_watchdog(*this, "watchdog") { } + void init_aquarium(); + + void aquarium(machine_config &config); + +protected: + virtual void video_start() override; + +private: /* memory pointers */ - required_shared_ptr m_mid_videoram; - required_shared_ptr m_bak_videoram; - required_shared_ptr m_txt_videoram; - required_shared_ptr m_scroll; + required_shared_ptr m_mid_videoram; + required_shared_ptr m_bak_videoram; + required_shared_ptr m_txt_videoram; + required_shared_ptr m_scroll; + required_memory_bank m_audiobank; /* video-related */ tilemap_t *m_txt_tilemap; @@ -54,23 +64,21 @@ public: required_device m_soundlatch; required_device m_watchdog; - DECLARE_WRITE8_MEMBER(aquarium_watchdog_w); - DECLARE_WRITE8_MEMBER(aquarium_z80_bank_w); - DECLARE_READ8_MEMBER(aquarium_oki_r); - DECLARE_WRITE8_MEMBER(aquarium_oki_w); - DECLARE_WRITE16_MEMBER(aquarium_txt_videoram_w); - DECLARE_WRITE16_MEMBER(aquarium_mid_videoram_w); - DECLARE_WRITE16_MEMBER(aquarium_bak_videoram_w); - void init_aquarium(); - TILE_GET_INFO_MEMBER(get_aquarium_txt_tile_info); - TILE_GET_INFO_MEMBER(get_aquarium_mid_tile_info); - TILE_GET_INFO_MEMBER(get_aquarium_bak_tile_info); - virtual void video_start() override; - uint32_t screen_update_aquarium(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - uint8_t aquarium_snd_bitswap( uint8_t scrambled_data ); - void mix_sprite_bitmap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority_mask, int priority_value); - bitmap_ind16 m_temp_sprite_bitmap; - void aquarium(machine_config &config); + void watchdog_w(u8 data); + void z80_bank_w(u8 data); + u8 oki_r(); + void oki_w(u8 data); + + void txt_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); + void mid_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); + void bak_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); + TILE_GET_INFO_MEMBER(get_txt_tile_info); + TILE_GET_INFO_MEMBER(get_mid_tile_info); + TILE_GET_INFO_MEMBER(get_bak_tile_info); + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + u8 snd_bitswap(u8 scrambled_data); + void aquarium_colpri_cb(u32 &colour, u32 &pri_mask); + void main_map(address_map &map); void snd_map(address_map &map); void snd_portmap(address_map &map); diff --git a/src/mame/includes/gcpinbal.h b/src/mame/includes/gcpinbal.h index 016ca72f9e1..5db19303316 100644 --- a/src/mame/includes/gcpinbal.h +++ b/src/mame/includes/gcpinbal.h @@ -19,45 +19,39 @@ class gcpinbal_state : public driver_device public: gcpinbal_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) + , m_tilemapram(*this, "tilemapram") + , m_d80010_ram(*this, "d80010") + , m_d80060_ram(*this, "d80060") , m_maincpu(*this, "maincpu") , m_eeprom(*this, "eeprom") , m_watchdog(*this, "watchdog") , m_oki(*this, "oki") , m_essnd(*this, "essnd") - , m_tilemapram(*this, "tilemapram") - , m_d80010_ram(*this, "d80010") - , m_d80060_ram(*this, "d80060") - , m_gfxdecode(*this, "gfxdecode") - , m_palette(*this, "palette") , m_sprgen(*this, "spritegen") , m_screen(*this, "screen") + , m_gfxdecode(*this, "gfxdecode") + , m_palette(*this, "palette") { } void gcpinbal(machine_config &config); -private: - - /* devices */ - required_device m_maincpu; - required_device m_eeprom; - required_device m_watchdog; - required_device m_oki; - required_device m_essnd; +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; +private: /* memory pointers */ - required_shared_ptr m_tilemapram; - required_shared_ptr m_d80010_ram; - required_shared_ptr m_d80060_ram; - - required_device m_gfxdecode; - required_device m_palette; + required_shared_ptr m_tilemapram; + required_shared_ptr m_d80010_ram; + required_shared_ptr m_d80060_ram; /* video-related */ tilemap_t *m_tilemap[3]; - uint16_t m_scrollx[3]; - uint16_t m_scrolly[3]; - uint16_t m_bg0_gfxset; - uint16_t m_bg1_gfxset; + u16 m_scrollx[3]; + u16 m_scrolly[3]; + u16 m_bg0_gfxset; + u16 m_bg1_gfxset; #ifdef MAME_DEBUG uint8_t m_dislayer[4]; #endif @@ -65,27 +59,32 @@ private: /* sound-related */ uint32_t m_msm_bank; + /* devices */ + required_device m_maincpu; + required_device m_eeprom; + required_device m_watchdog; + required_device m_oki; + required_device m_essnd; + required_device m_sprgen; + required_device m_screen; + required_device m_gfxdecode; + required_device m_palette; + + void d80010_w(offs_t offset, u16 data, u16 mem_mask = ~0); + void d80040_w(offs_t offset, u8 data); + void d80060_w(offs_t offset, u16 data, u16 mem_mask = ~0); + void bank_w(u8 data); + void eeprom_w(u8 data); + void es8712_reset_w(u8 data); + void tilemaps_word_w(offs_t offset, u16 data, u16 mem_mask = ~0); - DECLARE_WRITE16_MEMBER(d80010_w); - DECLARE_WRITE8_MEMBER(d80040_w); - DECLARE_WRITE16_MEMBER(d80060_w); - DECLARE_WRITE8_MEMBER(bank_w); - DECLARE_WRITE8_MEMBER(eeprom_w); - DECLARE_WRITE8_MEMBER(es8712_reset_w); - DECLARE_READ16_MEMBER(gcpinbal_tilemaps_word_r); - DECLARE_WRITE16_MEMBER(gcpinbal_tilemaps_word_w); TILE_GET_INFO_MEMBER(get_bg0_tile_info); TILE_GET_INFO_MEMBER(get_bg1_tile_info); TILE_GET_INFO_MEMBER(get_fg_tile_info); - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - uint32_t screen_update_gcpinbal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + + void gcpinbal_colpri_cb(u32 &colour, u32 &pri_mask); + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); TIMER_DEVICE_CALLBACK_MEMBER(scanline_cb); - void gcpinbal_core_vh_start( ); - DECLARE_WRITE_LINE_MEMBER(gcp_adpcm_int); - required_device m_sprgen; - required_device m_screen; void gcpinbal_map(address_map &map); }; diff --git a/src/mame/video/aquarium.cpp b/src/mame/video/aquarium.cpp index 89a2929e6b5..af44dddc362 100644 --- a/src/mame/video/aquarium.cpp +++ b/src/mame/video/aquarium.cpp @@ -7,59 +7,53 @@ /* TXT Layer */ -TILE_GET_INFO_MEMBER(aquarium_state::get_aquarium_txt_tile_info) +TILE_GET_INFO_MEMBER(aquarium_state::get_txt_tile_info) { - int tileno, colour; - - tileno = (m_txt_videoram[tile_index] & 0x0fff); - colour = (m_txt_videoram[tile_index] & 0xf000) >> 12; - SET_TILE_INFO_MEMBER(2, tileno, colour, 0); + const u32 tileno = (m_txt_videoram[tile_index] & 0x0fff); + const u32 colour = (m_txt_videoram[tile_index] & 0xf000) >> 12; + SET_TILE_INFO_MEMBER(1, tileno, colour, 0); tileinfo.category = (m_txt_videoram[tile_index] & 0x8000) >> 15; } -WRITE16_MEMBER(aquarium_state::aquarium_txt_videoram_w) +void aquarium_state::txt_videoram_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_txt_videoram[offset]); m_txt_tilemap->mark_tile_dirty(offset); } /* MID Layer */ -TILE_GET_INFO_MEMBER(aquarium_state::get_aquarium_mid_tile_info) +TILE_GET_INFO_MEMBER(aquarium_state::get_mid_tile_info) { - int tileno, colour, flag; - - tileno = (m_mid_videoram[tile_index * 2] & 0x0fff); - colour = (m_mid_videoram[tile_index * 2 + 1] & 0x001f); - flag = TILE_FLIPYX((m_mid_videoram[tile_index * 2 + 1] & 0x300) >> 8); + const u32 tileno = (m_mid_videoram[tile_index * 2] & 0x0fff); + const u32 colour = (m_mid_videoram[tile_index * 2 + 1] & 0x001f); + const int flag = TILE_FLIPYX((m_mid_videoram[tile_index * 2 + 1] & 0x300) >> 8); - SET_TILE_INFO_MEMBER(1, tileno, colour, flag); + SET_TILE_INFO_MEMBER(0, tileno, colour, flag); tileinfo.category = (m_mid_videoram[tile_index * 2 + 1] & 0x20) >> 5; } -WRITE16_MEMBER(aquarium_state::aquarium_mid_videoram_w) +void aquarium_state::mid_videoram_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_mid_videoram[offset]); m_mid_tilemap->mark_tile_dirty(offset / 2); } /* BAK Layer */ -TILE_GET_INFO_MEMBER(aquarium_state::get_aquarium_bak_tile_info) +TILE_GET_INFO_MEMBER(aquarium_state::get_bak_tile_info) { - int tileno, colour, flag; - - tileno = (m_bak_videoram[tile_index * 2] & 0x0fff); - colour = (m_bak_videoram[tile_index * 2 + 1] & 0x001f); - flag = TILE_FLIPYX((m_bak_videoram[tile_index * 2 + 1] & 0x300) >> 8); + const u32 tileno = (m_bak_videoram[tile_index * 2] & 0x0fff); + const u32 colour = (m_bak_videoram[tile_index * 2 + 1] & 0x001f); + const int flag = TILE_FLIPYX((m_bak_videoram[tile_index * 2 + 1] & 0x300) >> 8); - SET_TILE_INFO_MEMBER(3, tileno, colour, flag); + SET_TILE_INFO_MEMBER(2, tileno, colour, flag); tileinfo.category = (m_bak_videoram[tile_index * 2 + 1] & 0x20) >> 5; } -WRITE16_MEMBER(aquarium_state::aquarium_bak_videoram_w) +void aquarium_state::bak_videoram_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_bak_videoram[offset]); m_bak_tilemap->mark_tile_dirty(offset / 2); @@ -67,37 +61,23 @@ WRITE16_MEMBER(aquarium_state::aquarium_bak_videoram_w) void aquarium_state::video_start() { - m_txt_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(aquarium_state::get_aquarium_txt_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); - m_bak_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(aquarium_state::get_aquarium_bak_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); - m_mid_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(aquarium_state::get_aquarium_mid_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); + m_txt_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(aquarium_state::get_txt_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + m_bak_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(aquarium_state::get_bak_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); + m_mid_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(aquarium_state::get_mid_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); m_txt_tilemap->set_transparent_pen(0); m_mid_tilemap->set_transparent_pen(0); m_bak_tilemap->set_transparent_pen(0); - - m_screen->register_screen_bitmap(m_temp_sprite_bitmap); } -void aquarium_state::mix_sprite_bitmap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority_mask, int priority_value) +void aquarium_state::aquarium_colpri_cb(u32 &colour, u32 &pri_mask) { - for (int y = cliprect.top();y <= cliprect.bottom();y++) - { - uint16_t* srcline = &m_temp_sprite_bitmap.pix16(y); - uint16_t* dstline = &bitmap.pix16(y); - - for (int x = cliprect.left();x <= cliprect.right();x++) - { - uint16_t pixel = srcline[x]; - - if (pixel & 0xf) - if ((pixel & priority_mask) == priority_value) - dstline[x] = pixel; - - } - } + pri_mask = 0; + if (colour & 8) + pri_mask |= (GFX_PMASK_2 | GFX_PMASK_4 | GFX_PMASK_8); } -uint32_t aquarium_state::screen_update_aquarium(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +uint32_t aquarium_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { m_mid_tilemap->set_scrollx(0, m_scroll[0]); m_mid_tilemap->set_scrolly(0, m_scroll[1]); @@ -106,19 +86,15 @@ uint32_t aquarium_state::screen_update_aquarium(screen_device &screen, bitmap_in m_txt_tilemap->set_scrollx(0, m_scroll[4]); m_txt_tilemap->set_scrolly(0, m_scroll[5]); + screen.priority().fill(0, cliprect); bitmap.fill(0, cliprect); // WDUD logo suggests this - m_temp_sprite_bitmap.fill(0, cliprect); - m_sprgen->aquarium_draw_sprites(m_temp_sprite_bitmap, cliprect, m_gfxdecode, 16); - - - m_bak_tilemap->draw(screen, bitmap, cliprect, 0, 0); - mix_sprite_bitmap(screen, bitmap, cliprect, 0x80, 0x80); - m_mid_tilemap->draw(screen, bitmap, cliprect, 0, 0); - m_txt_tilemap->draw(screen, bitmap, cliprect, 1, 0); + m_bak_tilemap->draw(screen, bitmap, cliprect, 0, 1); + m_mid_tilemap->draw(screen, bitmap, cliprect, 0, 2); + m_txt_tilemap->draw(screen, bitmap, cliprect, 1, 4); - m_bak_tilemap->draw(screen, bitmap, cliprect, 1, 0); - mix_sprite_bitmap(screen, bitmap, cliprect, 0x80, 0x00); + m_bak_tilemap->draw(screen, bitmap, cliprect, 1, 8); + m_sprgen->aquarium_draw_sprites(screen, bitmap, cliprect, 16); m_mid_tilemap->draw(screen, bitmap, cliprect, 1, 0); m_txt_tilemap->draw(screen, bitmap, cliprect, 0, 0); diff --git a/src/mame/video/excellent_spr.cpp b/src/mame/video/excellent_spr.cpp index 41a8874b2f7..15c31083183 100644 --- a/src/mame/video/excellent_spr.cpp +++ b/src/mame/video/excellent_spr.cpp @@ -24,24 +24,45 @@ DEFINE_DEVICE_TYPE(EXCELLENT_SPRITE, excellent_spr_device, "excellent_spr", "Exc excellent_spr_device::excellent_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, EXCELLENT_SPRITE, tag, owner, clock) + , device_gfx_interface(mconfig, *this, nullptr) , device_video_interface(mconfig, *this) + , m_gfx_region(*this, DEVICE_SELF) + , m_colbase(0) { } void excellent_spr_device::device_start() { - m_ram = make_unique_clear(0x1000); + /* 16x16x4 */ + gfx_layout layout_16x16x4 = + { + 16,16, /* 16*16 sprites */ + 0, + 4, /* 4 bits per pixel */ +// { 16, 48, 0, 32 }, + { 48, 16, 32, 0 }, + { STEP16(0,1) }, + { STEP16(0,16*4) }, + 16*16*4 /* every sprite takes 128 consecutive bytes */ + }; + layout_16x16x4.total = m_gfx_region->bytes() / ((16*16*4) / 8); + + m_colpri_cb.bind_relative_to(*owner()); + m_ram = make_unique_clear(0x1000); + save_pointer(NAME(m_ram), 0x1000); + + set_gfx(0, std::make_unique(&palette(), layout_16x16x4, m_gfx_region->base(), 0, 0x10, m_colbase)); } -READ8_MEMBER(excellent_spr_device::read) +u8 excellent_spr_device::read(offs_t offset) { return m_ram[offset]; } -WRITE8_MEMBER(excellent_spr_device::write) +void excellent_spr_device::write(offs_t offset, u8 data) { m_ram[offset] = data; } @@ -72,34 +93,38 @@ void excellent_spr_device::device_reset() ****************************************************************/ -void excellent_spr_device::aquarium_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs ) +void excellent_spr_device::aquarium_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs) { - int offs, chain_pos; - int x, y, curx, cury; - uint8_t col, flipx, flipy, chain; - uint16_t code; + const bool priority = !m_colpri_cb.isnull(); + + int start, end, inc; + if (priority) { start = 0x1000 - 8; end = -8; inc = -8; } + else { start = 0; end = 0x1000; inc = +8; } - for (offs = 0; offs < 0x1000; offs += 8) + for (int offs = start; offs != end; offs += inc) { - code = ((m_ram[offs + 5]) & 0xff) + (((m_ram[offs + 6]) & 0xff) << 8); + u32 code = ((m_ram[offs + 5]) & 0xff) + (((m_ram[offs + 6]) & 0xff) << 8); code &= 0x3fff; - if (!(m_ram[offs + 4] &0x80)) /* active sprite ? */ + if (!(m_ram[offs + 4] & 0x80)) /* active sprite ? */ { - x = ((m_ram[offs + 0]) &0xff) + (((m_ram[offs + 1]) & 0xff) << 8); - y = ((m_ram[offs + 2]) &0xff) + (((m_ram[offs + 3]) & 0xff) << 8); + int x = ((m_ram[offs + 0]) & 0xff) + (((m_ram[offs + 1]) & 0xff) << 8); + int y = ((m_ram[offs + 2]) & 0xff) + (((m_ram[offs + 3]) & 0xff) << 8); /* Treat coords as signed */ if (x & 0x8000) x -= 0x10000; if (y & 0x8000) y -= 0x10000; - col = ((m_ram[offs + 7]) & 0x0f); - chain = (m_ram[offs + 4]) & 0x07; - flipy = (m_ram[offs + 4]) & 0x10; - flipx = (m_ram[offs + 4]) & 0x20; + u32 pri_mask = 0; + u32 colour = ((m_ram[offs + 7]) & 0x0f); + const u8 chain = (m_ram[offs + 4]) & 0x07; + const bool flipy = (m_ram[offs + 4]) & 0x10; + const bool flipx = (m_ram[offs + 4]) & 0x20; + if (priority) + m_colpri_cb(colour, pri_mask); - curx = x; - cury = y; + int curx = x; + int cury = y; if (((m_ram[offs + 4]) & 0x08) && flipy) cury += (chain * 16); @@ -107,25 +132,44 @@ void excellent_spr_device::aquarium_draw_sprites( bitmap_ind16 &bitmap, const re if (!(((m_ram[offs + 4]) & 0x08)) && flipx) curx += (chain * 16); - - for (chain_pos = chain; chain_pos >= 0; chain_pos--) + for (int chain_pos = chain; chain_pos >= 0; chain_pos--) { - gfxdecode->gfx(0)->transpen(bitmap,cliprect, - code, - col, - flipx, flipy, - curx,cury,0); - - /* wrap around y */ - gfxdecode->gfx(0)->transpen(bitmap,cliprect, - code, - col, - flipx, flipy, - curx,cury + 256,0); + if (priority) + { + gfx(0)->prio_transpen(bitmap,cliprect, + code, + colour, + flipx, flipy, + curx,cury, + screen.priority(),pri_mask,0); + + /* wrap around y */ + gfx(0)->prio_transpen(bitmap,cliprect, + code, + colour, + flipx, flipy, + curx,cury + 256, + screen.priority(),pri_mask,0); + } + else + { + gfx(0)->transpen(bitmap,cliprect, + code, + colour, + flipx, flipy, + curx,cury,0); + + /* wrap around y */ + gfx(0)->transpen(bitmap,cliprect, + code, + colour, + flipx, flipy, + curx,cury + 256,0); + } code++; - if ((m_ram[offs + 4]) &0x08) /* Y chain */ + if ((m_ram[offs + 4]) & 0x08) /* Y chain */ { if (flipy) cury -= 16; @@ -153,54 +197,66 @@ void excellent_spr_device::aquarium_draw_sprites( bitmap_ind16 &bitmap, const re #endif } -void excellent_spr_device::gcpinbal_draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs, int priority ) +void excellent_spr_device::gcpinbal_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs) { - uint8_t *spriteram = m_ram.get(); - int offs, chain_pos; - int x, y, curx, cury; -// int priority = 0; - uint8_t col, flipx, flipy, chain; - uint16_t code; + const bool priority = !m_colpri_cb.isnull(); + int start, end, inc; + if (priority) { start = 0x1000 - 8; end = -8; inc = -8; } + else { start = 0; end = 0x1000; inc = +8; } - for (offs = 0x1000 - 8; offs >= 0; offs -= 8) + for (int offs = start; offs != end; offs += inc) { - code = ((spriteram[offs + 5]) & 0xff) + (((spriteram[offs + 6]) & 0xff) << 8); + u32 code = ((m_ram[offs + 5]) & 0xff) + (((m_ram[offs + 6]) & 0xff) << 8); code &= 0x3fff; - if (!(spriteram[offs + 4] &0x80)) /* active sprite ? */ + if (!(m_ram[offs + 4] & 0x80)) /* active sprite ? */ { - x = ((spriteram[offs + 0]) & 0xff) + (((spriteram[offs + 1]) & 0xff) << 8); - y = ((spriteram[offs + 2]) & 0xff) + (((spriteram[offs + 3]) & 0xff) << 8); + int x = ((m_ram[offs + 0]) & 0xff) + (((m_ram[offs + 1]) & 0xff) << 8); + int y = ((m_ram[offs + 2]) & 0xff) + (((m_ram[offs + 3]) & 0xff) << 8); /* Treat coords as signed */ if (x & 0x8000) x -= 0x10000; if (y & 0x8000) y -= 0x10000; - col = ((spriteram[offs + 7]) & 0x0f) | 0x60; - chain = (spriteram[offs + 4]) & 0x07; - flipy = (spriteram[offs + 4]) & 0x10; - flipx = 0; + u32 pri_mask = 0; + u32 colour = ((m_ram[offs + 7]) & 0x0f); + const u8 chain = (m_ram[offs + 4]) & 0x07; + const bool flipy = (m_ram[offs + 4]) & 0x10; + const bool flipx = 0; + if (priority) + m_colpri_cb(colour, pri_mask); - curx = x; - cury = y; + int curx = x; + int cury = y; - if (((spriteram[offs + 4]) & 0x08) && flipy) + if (((m_ram[offs + 4]) & 0x08) && flipy) cury += (chain * 16); - for (chain_pos = chain; chain_pos >= 0; chain_pos--) + for (int chain_pos = chain; chain_pos >= 0; chain_pos--) { - gfxdecode->gfx(0)->prio_transpen(bitmap,cliprect, - code, - col, - flipx, flipy, - curx,cury, - screen.priority(), - priority ? 0xfc : 0xf0,0); + if (priority) + { + gfx(0)->prio_transpen(bitmap,cliprect, + code, + colour, + flipx, flipy, + curx,cury, + screen.priority(),pri_mask,0); + } + else + { + gfx(0)->transpen(bitmap,cliprect, + code, + colour, + flipx, flipy, + curx,cury, + 0); + } code++; - if ((spriteram[offs + 4]) & 0x08) /* Y chain */ + if ((m_ram[offs + 4]) & 0x08) /* Y chain */ { if (flipy) cury -= 16; else cury += 16; diff --git a/src/mame/video/excellent_spr.h b/src/mame/video/excellent_spr.h index 36c3d002a29..bd9ecabfba0 100644 --- a/src/mame/video/excellent_spr.h +++ b/src/mame/video/excellent_spr.h @@ -5,24 +5,32 @@ #pragma once +typedef device_delegate excellent_spr_colpri_cb_delegate; -class excellent_spr_device : public device_t, public device_video_interface +class excellent_spr_device : public device_t, public device_gfx_interface, public device_video_interface { public: excellent_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - DECLARE_READ8_MEMBER(read); - DECLARE_WRITE8_MEMBER(write); + void set_color_base(u16 base) { m_colbase = base; } + template void set_colpri_callback(T &&... args) { m_colpri_cb = excellent_spr_colpri_cb_delegate(std::forward(args)...); } - void aquarium_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs); - void gcpinbal_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs, int priority); + u8 read(offs_t offset); + void write(offs_t offset, u8 data); + + void aquarium_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs); + void gcpinbal_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs); protected: - std::unique_ptr m_ram; + std::unique_ptr m_ram; virtual void device_start() override; virtual void device_reset() override; + private: + excellent_spr_colpri_cb_delegate m_colpri_cb; + required_memory_region m_gfx_region; + u16 m_colbase; }; DECLARE_DEVICE_TYPE(EXCELLENT_SPRITE, excellent_spr_device) diff --git a/src/mame/video/gcpinbal.cpp b/src/mame/video/gcpinbal.cpp index 95533ecf5da..fd564330797 100644 --- a/src/mame/video/gcpinbal.cpp +++ b/src/mame/video/gcpinbal.cpp @@ -10,44 +10,40 @@ TILE_GET_INFO_MEMBER(gcpinbal_state::get_bg0_tile_info) { - uint16_t tilenum = m_tilemapram[0 + tile_index * 2]; - uint16_t attr = m_tilemapram[1 + tile_index * 2]; + const u16 tile = m_tilemapram[0 + tile_index * 2]; + const u16 attr = m_tilemapram[1 + tile_index * 2]; - SET_TILE_INFO_MEMBER(1, - (tilenum & 0xfff) + m_bg0_gfxset, + SET_TILE_INFO_MEMBER(0, + (tile & 0xfff) + m_bg0_gfxset, (attr & 0x1f), - TILE_FLIPYX( (attr & 0x300) >> 8)); + TILE_FLIPYX((attr & 0x300) >> 8)); } TILE_GET_INFO_MEMBER(gcpinbal_state::get_bg1_tile_info) { - uint16_t tilenum = m_tilemapram[0x800 + tile_index * 2]; - uint16_t attr = m_tilemapram[0x801 + tile_index * 2]; + const u16 tile = m_tilemapram[0x800 + tile_index * 2]; + const u16 attr = m_tilemapram[0x801 + tile_index * 2]; - SET_TILE_INFO_MEMBER(1, - (tilenum & 0xfff) + 0x2000 + m_bg1_gfxset, + SET_TILE_INFO_MEMBER(0, + (tile & 0xfff) + 0x2000 + m_bg1_gfxset, (attr & 0x1f) + 0x30, - TILE_FLIPYX( (attr & 0x300) >> 8)); + TILE_FLIPYX((attr & 0x300) >> 8)); } TILE_GET_INFO_MEMBER(gcpinbal_state::get_fg_tile_info) { - uint16_t tilenum = m_tilemapram[0x1000 + tile_index]; - - SET_TILE_INFO_MEMBER(2, - (tilenum & 0xfff), - (tilenum >> 12) | 0x70, - 0); + const u16 tile = m_tilemapram[0x1000 + tile_index]; + SET_TILE_INFO_MEMBER(1, (tile & 0xfff), (tile >> 12), 0); } -void gcpinbal_state::gcpinbal_core_vh_start( ) +void gcpinbal_state::video_start() { int xoffs = 0; int yoffs = 0; - m_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(gcpinbal_state::get_bg0_tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32); - m_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(gcpinbal_state::get_bg1_tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32); - m_tilemap[2] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(gcpinbal_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS,8,8,64,64); + m_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(gcpinbal_state::get_bg0_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16, 32, 32); + m_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(gcpinbal_state::get_bg1_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16, 32, 32); + m_tilemap[2] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(gcpinbal_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); m_tilemap[0]->set_transparent_pen(0); m_tilemap[1]->set_transparent_pen(0); @@ -62,9 +58,9 @@ void gcpinbal_state::gcpinbal_core_vh_start( ) m_tilemap[2]->set_scrolldy(-yoffs, 0); } -void gcpinbal_state::video_start() +void gcpinbal_state::gcpinbal_colpri_cb(u32 &colour, u32 &pri_mask) { - gcpinbal_core_vh_start(); + pri_mask = (m_d80060_ram[0x8 / 2] & 0x8800) ? 0xf0 : 0xfc; } @@ -72,12 +68,7 @@ void gcpinbal_state::video_start() TILEMAP READ AND WRITE HANDLERS *******************************************************************/ -READ16_MEMBER(gcpinbal_state::gcpinbal_tilemaps_word_r) -{ - return m_tilemapram[offset]; -} - -WRITE16_MEMBER(gcpinbal_state::gcpinbal_tilemaps_word_w) +void gcpinbal_state::tilemaps_word_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_tilemapram[offset]); @@ -90,14 +81,12 @@ WRITE16_MEMBER(gcpinbal_state::gcpinbal_tilemaps_word_w) } - /************************************************************** SCREEN REFRESH **************************************************************/ -uint32_t gcpinbal_state::screen_update_gcpinbal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +uint32_t gcpinbal_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - int i; uint8_t layer[3]; #ifdef MAME_DEBUG @@ -127,7 +116,7 @@ uint32_t gcpinbal_state::screen_update_gcpinbal(screen_device &screen, bitmap_in m_scrollx[2] = m_d80010_ram[0xc / 2]; m_scrolly[2] = m_d80010_ram[0xe / 2]; - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { m_tilemap[i]->set_scrollx(0, m_scrollx[i]); m_tilemap[i]->set_scrolly(0, m_scrolly[i]); @@ -156,8 +145,7 @@ uint32_t gcpinbal_state::screen_update_gcpinbal(screen_device &screen, bitmap_in #endif m_tilemap[layer[2]]->draw(screen, bitmap, cliprect, 0, 4); - int sprpri = (m_d80060_ram[0x8 / 2] & 0x8800) ? 0 : 1; - m_sprgen->gcpinbal_draw_sprites(screen, bitmap, cliprect, m_gfxdecode, 16, sprpri); + m_sprgen->gcpinbal_draw_sprites(screen, bitmap, cliprect, 16); #if 0 { -- cgit v1.2.3