From 1bfda189cdd4b211634af41c1cbcbed11c15e747 Mon Sep 17 00:00:00 2001 From: cam900 Date: Sun, 11 Nov 2018 00:06:58 +0900 Subject: thoop2.cpp : Cleanup duplicate, naming, Reduce runtime tag lookup (#4062) --- src/mame/drivers/thoop2.cpp | 28 +++++++++++++--------------- src/mame/includes/thoop2.h | 9 +++++---- src/mame/video/thoop2.cpp | 23 ++++++----------------- 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/mame/drivers/thoop2.cpp b/src/mame/drivers/thoop2.cpp index 7f636b7eb70..8d15d2a055c 100644 --- a/src/mame/drivers/thoop2.cpp +++ b/src/mame/drivers/thoop2.cpp @@ -75,12 +75,12 @@ Measurements from actual PCB: void thoop2_state::machine_start() { - membank("okibank")->configure_entries(0, 16, memregion("oki")->base(), 0x10000); + m_okibank->configure_entries(0, 16, memregion("oki")->base(), 0x10000); } -WRITE8_MEMBER(thoop2_state::OKIM6295_bankswitch_w) +WRITE8_MEMBER(thoop2_state::oki_bankswitch_w) { - membank("okibank")->set_entry(data & 0x0f); + m_okibank->set_entry(data & 0x0f); } WRITE_LINE_MEMBER(thoop2_state::coin1_lockout_w) @@ -139,7 +139,7 @@ void thoop2_state::thoop2_map(address_map &map) [this](address_space &space, offs_t offset, u8 data, u8 mem_mask) { m_outlatch->write_d0(space, offset >> 3, data, mem_mask); }); - map(0x70000d, 0x70000d).w(FUNC(thoop2_state::OKIM6295_bankswitch_w)); /* OKI6295 bankswitch */ + map(0x70000d, 0x70000d).w(FUNC(thoop2_state::oki_bankswitch_w)); /* OKI6295 bankswitch */ map(0x70000f, 0x70000f).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); /* OKI6295 data register */ map(0xfe0000, 0xfe7fff).ram(); /* Work RAM */ map(0xfe8000, 0xfeffff).ram().share("shareram"); /* Work RAM (shared with D5002FP) */ @@ -237,30 +237,28 @@ INPUT_PORTS_END static const gfx_layout thoop2_tilelayout = { 8,8, /* 8x8 tiles */ - 0x400000/16, /* number of tiles */ + RGN_FRAC(1,2), /* number of tiles */ 4, /* 4 bpp */ - { 0*0x400000*8+8, 0*0x400000*8, 1*0x400000*8+8, 1*0x400000*8 }, - { 0, 1, 2, 3, 4, 5, 6, 7 }, - { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 }, + { 8, 0, RGN_FRAC(1,2)+8, RGN_FRAC(1,2)+0 }, + { STEP8(0,1) }, + { STEP8(0,8*2) }, 16*8 }; static const gfx_layout thoop2_tilelayout_16 = { 16,16, /* 16x16 tiles */ - 0x400000/64, /* number of tiles */ + RGN_FRAC(1,2), /* number of tiles */ 4, /* 4 bpp */ - { 0*0x400000*8+8, 0*0x400000*8, 1*0x400000*8+8, 1*0x400000*8 }, - { 0, 1, 2, 3, 4, 5, 6, 7, - 16*16+0, 16*16+1, 16*16+2, 16*16+3, 16*16+4, 16*16+5, 16*16+6, 16*16+7 }, - { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16, - 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, + { 8, 0, RGN_FRAC(1,2)+8, RGN_FRAC(1,2)+0 }, + { STEP8(0,1), STEP8(8*2*16,1) }, + { STEP16(0,8*2) }, 64*8 }; static GFXDECODE_START( gfx_thoop2 ) - GFXDECODE_ENTRY( "gfx1", 0x000000, thoop2_tilelayout, 0, 64 ) + GFXDECODE_ENTRY( "gfx1", 0x000000, thoop2_tilelayout, 0, 64 ) GFXDECODE_ENTRY( "gfx1", 0x000000, thoop2_tilelayout_16, 0, 64 ) GFXDECODE_END diff --git a/src/mame/includes/thoop2.h b/src/mame/includes/thoop2.h index 0008120ce7b..c311ba62982 100644 --- a/src/mame/includes/thoop2.h +++ b/src/mame/includes/thoop2.h @@ -18,6 +18,7 @@ public: m_outlatch(*this, "outlatch"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), + m_okibank(*this, "okibank"), m_videoram(*this, "videoram"), m_vregs(*this, "vregs"), m_spriteram(*this, "spriteram"), @@ -27,7 +28,7 @@ public: void thoop2(machine_config &config); private: - DECLARE_WRITE8_MEMBER(OKIM6295_bankswitch_w); + DECLARE_WRITE8_MEMBER(oki_bankswitch_w); DECLARE_WRITE_LINE_MEMBER(coin1_lockout_w); DECLARE_WRITE_LINE_MEMBER(coin2_lockout_w); DECLARE_WRITE_LINE_MEMBER(coin1_counter_w); @@ -37,8 +38,7 @@ private: DECLARE_WRITE8_MEMBER(shareram_w); DECLARE_READ8_MEMBER(shareram_r); - TILE_GET_INFO_MEMBER(get_tile_info_screen0); - TILE_GET_INFO_MEMBER(get_tile_info_screen1); + template TILE_GET_INFO_MEMBER(get_tile_info); uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void mcu_hostmem_map(address_map &map); @@ -59,11 +59,12 @@ private: required_device m_outlatch; required_device m_gfxdecode; required_device m_palette; + required_memory_bank m_okibank; required_shared_ptr m_videoram; required_shared_ptr m_vregs; required_shared_ptr m_spriteram; - optional_shared_ptr m_shareram; + required_shared_ptr m_shareram; }; #endif // MAME_INCLUDES_THOOP2_H diff --git a/src/mame/video/thoop2.cpp b/src/mame/video/thoop2.cpp index 86ce5269467..eab176dd317 100644 --- a/src/mame/video/thoop2.cpp +++ b/src/mame/video/thoop2.cpp @@ -38,22 +38,11 @@ 1 | x------- -------- | flip y */ -TILE_GET_INFO_MEMBER(thoop2_state::get_tile_info_screen0) +template +TILE_GET_INFO_MEMBER(thoop2_state::get_tile_info) { - int data = m_videoram[tile_index << 1]; - int data2 = m_videoram[(tile_index << 1) + 1]; - int code = ((data & 0xfffc) >> 2) | ((data & 0x0003) << 14); - - tileinfo.category = (data2 >> 6) & 0x03; - - SET_TILE_INFO_MEMBER(1, code, data2 & 0x3f, TILE_FLIPYX((data2 >> 14) & 0x03)); -} - - -TILE_GET_INFO_MEMBER(thoop2_state::get_tile_info_screen1) -{ - int data = m_videoram[(0x1000/2) + (tile_index << 1)]; - int data2 = m_videoram[(0x1000/2) + (tile_index << 1) + 1]; + int data = m_videoram[(Layer * 0x1000/2) + (tile_index << 1)]; + int data2 = m_videoram[(Layer * 0x1000/2) + (tile_index << 1) + 1]; int code = ((data & 0xfffc) >> 2) | ((data & 0x0003) << 14); tileinfo.category = (data2 >> 6) & 0x03; @@ -81,8 +70,8 @@ WRITE16_MEMBER(thoop2_state::vram_w) void thoop2_state::video_start() { - m_pant[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(thoop2_state::get_tile_info_screen0),this),TILEMAP_SCAN_ROWS,16,16,32,32); - m_pant[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(thoop2_state::get_tile_info_screen1),this),TILEMAP_SCAN_ROWS,16,16,32,32); + m_pant[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(thoop2_state::get_tile_info<0>),this),TILEMAP_SCAN_ROWS,16,16,32,32); + m_pant[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(thoop2_state::get_tile_info<1>),this),TILEMAP_SCAN_ROWS,16,16,32,32); m_pant[0]->set_transmask(0,0xff01,0x00ff); /* pens 1-7 opaque, pens 0, 8-15 transparent */ m_pant[1]->set_transmask(0,0xff01,0x00ff); /* pens 1-7 opaque, pens 0, 8-15 transparent */ -- cgit v1.2.3