From 0b2789d6a22f76b8f79d6064e9467d441a794eeb Mon Sep 17 00:00:00 2001 From: cam900 Date: Thu, 3 Jan 2019 18:49:51 +0900 Subject: [PATCH] galastrm.cpp : Device'fied TC0110PCR, Reduce duplicate, ACCESSING_BITs, Unnesessary Runtime tag lookups, handlers, pointers --- src/mame/drivers/galastrm.cpp | 40 ++++++++++++----------------------- src/mame/includes/galastrm.h | 18 ++++++++-------- src/mame/video/galastrm.cpp | 14 +++++------- 3 files changed, 27 insertions(+), 45 deletions(-) diff --git a/src/mame/drivers/galastrm.cpp b/src/mame/drivers/galastrm.cpp index f6c6357fae4..2e4e8ce4380 100644 --- a/src/mame/drivers/galastrm.cpp +++ b/src/mame/drivers/galastrm.cpp @@ -38,7 +38,6 @@ $300.b debugmode $305.b invincibility TODO: -- convert to use device implementation of TC0110PCR - device-ify TC0610? (no other known users) */ @@ -61,28 +60,13 @@ INTERRUPT_GEN_MEMBER(galastrm_state::interrupt) device.execute().set_input_line(5, HOLD_LINE); } -WRITE32_MEMBER(galastrm_state::palette_w) +template +WRITE16_MEMBER(galastrm_state::tc0610_w) { - if (ACCESSING_BITS_16_31) - m_tc0110pcr_addr = data >> 16; - if ((ACCESSING_BITS_0_15) && (m_tc0110pcr_addr < 4096)) - m_palette->set_pen_color(m_tc0110pcr_addr, pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0)); -} - -WRITE32_MEMBER(galastrm_state::tc0610_0_w) -{ - if (ACCESSING_BITS_16_31) - m_tc0610_0_addr = data >> 16; - if ((ACCESSING_BITS_0_15) && (m_tc0610_0_addr < 8)) - m_tc0610_ctrl_reg[0][m_tc0610_0_addr] = data; -} - -WRITE32_MEMBER(galastrm_state::tc0610_1_w) -{ - if (ACCESSING_BITS_16_31) - m_tc0610_1_addr = data >> 16; - if ((ACCESSING_BITS_0_15) && (m_tc0610_1_addr < 8)) - m_tc0610_ctrl_reg[1][m_tc0610_1_addr] = data; + if (offset == 0) + m_tc0610_addr[Chip] = data; + else if (m_tc0610_addr[Chip] < 8) + m_tc0610_ctrl_reg[Chip][m_tc0610_addr[Chip]] = data; } @@ -107,7 +91,7 @@ WRITE8_MEMBER(galastrm_state::coin_word_w) void galastrm_state::main_map(address_map &map) { map(0x000000, 0x0fffff).rom(); - map(0x200000, 0x21ffff).ram().share("ram"); /* main CPUA ram */ + map(0x200000, 0x21ffff).ram(); /* main CPU ram */ map(0x300000, 0x303fff).ram().share("spriteram"); map(0x400000, 0x400007).rw("tc0510nio", FUNC(tc0510nio_device::read), FUNC(tc0510nio_device::write)); map(0x40fff0, 0x40fff3).nopw(); @@ -115,9 +99,9 @@ void galastrm_state::main_map(address_map &map) map(0x600000, 0x6007ff).rw("taito_en:dpram", FUNC(mb8421_device::left_r), FUNC(mb8421_device::left_w)); /* Sound shared ram */ map(0x800000, 0x80ffff).rw(m_tc0480scp, FUNC(tc0480scp_device::long_r), FUNC(tc0480scp_device::long_w)); /* tilemaps */ map(0x830000, 0x83002f).rw(m_tc0480scp, FUNC(tc0480scp_device::ctrl_long_r), FUNC(tc0480scp_device::ctrl_long_w)); - map(0x900000, 0x900003).w(FUNC(galastrm_state::palette_w)); /* TC0110PCR */ - map(0xb00000, 0xb00003).w(FUNC(galastrm_state::tc0610_0_w)); /* TC0610 */ - map(0xc00000, 0xc00003).w(FUNC(galastrm_state::tc0610_1_w)); + map(0x900000, 0x900003).rw(m_tc0110pcr, FUNC(tc0110pcr_device::word_r), FUNC(tc0110pcr_device::step1_rbswap_word_w)); /* TC0110PCR */ + map(0xb00000, 0xb00003).w(FUNC(galastrm_state::tc0610_w<0>)); /* TC0610 */ + map(0xc00000, 0xc00003).w(FUNC(galastrm_state::tc0610_w<1>)); map(0xd00000, 0xd0ffff).rw(m_tc0100scn, FUNC(tc0100scn_device::long_r), FUNC(tc0100scn_device::long_w)); /* piv tilemaps */ map(0xd20000, 0xd2000f).rw(m_tc0100scn, FUNC(tc0100scn_device::ctrl_long_r), FUNC(tc0100scn_device::ctrl_long_w)); } @@ -252,6 +236,8 @@ void galastrm_state::galastrm(machine_config &config) m_tc0480scp->set_offsets(-40, -3); m_tc0480scp->set_gfxdecode_tag(m_gfxdecode); + TC0110PCR(config, m_tc0110pcr, 0, m_palette); + /* sound hardware */ TAITO_EN(config, "taito_en", 0); } @@ -279,7 +265,7 @@ ROM_START( galastrm ) ROM_LOAD32_BYTE( "c99-04.ic66", 0x000002, 0x100000, CRC(a681760f) SHA1(23d4fc7eb778c8a25c4bc7cee1d0c8cdd828a996) ) ROM_LOAD32_BYTE( "c99-03.ic67", 0x000003, 0x100000, CRC(a2807a27) SHA1(977e395ea2ab2fb82807d3cf5fe5f1dbbde99da0) ) - ROM_REGION16_LE( 0x80000, "user1", 0 ) + ROM_REGION16_LE( 0x80000, "sprmaprom", 0 ) ROM_LOAD16_WORD( "c99-11.ic90", 0x00000, 0x80000, CRC(26a6926c) SHA1(918860e2829131e9ecfe983b2ae3e49e1c9ecd72) ) /* STY, spritemap */ ROM_REGION16_BE( 0x1000000, "ensoniq.0", ROMREGION_ERASE00 ) diff --git a/src/mame/includes/galastrm.h b/src/mame/includes/galastrm.h index b17966c18b1..024f59c2593 100644 --- a/src/mame/includes/galastrm.h +++ b/src/mame/includes/galastrm.h @@ -9,6 +9,7 @@ #include "video/poly.h" #include "video/tc0100scn.h" +#include "video/tc0110pcr.h" #include "video/tc0480scp.h" #include "emupal.h" @@ -44,11 +45,12 @@ class galastrm_state : public driver_device public: galastrm_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_ram(*this,"ram"), - m_spriteram(*this,"spriteram") , + m_spriteram(*this,"spriteram"), + m_spritemap_rom(*this, "sprmaprom"), m_maincpu(*this, "maincpu"), m_eeprom(*this, "eeprom"), m_tc0100scn(*this, "tc0100scn"), + m_tc0110pcr(*this, "tc0110pcr"), m_tc0480scp(*this, "tc0480scp"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), @@ -62,12 +64,14 @@ protected: virtual void video_start() override; private: - required_shared_ptr m_ram; required_shared_ptr m_spriteram; + required_region_ptr m_spritemap_rom; + required_device m_maincpu; required_device m_eeprom; required_device m_tc0100scn; + required_device m_tc0110pcr; required_device m_tc0480scp; required_device m_gfxdecode; required_device m_screen; @@ -84,9 +88,7 @@ private: }; uint16_t m_frame_counter; - int m_tc0110pcr_addr; - int m_tc0610_0_addr; - int m_tc0610_1_addr; + int m_tc0610_addr[2]; int16_t m_tc0610_ctrl_reg[2][8]; std::unique_ptr m_spritelist; struct gs_tempsprite *m_sprite_ptr_pre; @@ -98,9 +100,7 @@ private: int m_rsxoffs; int m_rsyoffs; - DECLARE_WRITE32_MEMBER(palette_w); - DECLARE_WRITE32_MEMBER(tc0610_0_w); - DECLARE_WRITE32_MEMBER(tc0610_1_w); + template DECLARE_WRITE16_MEMBER(tc0610_w); DECLARE_WRITE8_MEMBER(coin_word_w); uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(interrupt); diff --git a/src/mame/video/galastrm.cpp b/src/mame/video/galastrm.cpp index 49e3efa5bf0..77863568fe9 100644 --- a/src/mame/video/galastrm.cpp +++ b/src/mame/video/galastrm.cpp @@ -31,9 +31,7 @@ void galastrm_state::video_start() save_item(NAME(m_rsxoffs)); save_item(NAME(m_rsyoffs)); save_item(NAME(m_frame_counter)); - save_item(NAME(m_tc0110pcr_addr)); - save_item(NAME(m_tc0610_0_addr)); - save_item(NAME(m_tc0610_1_addr)); + save_item(NAME(m_tc0610_addr)); save_item(NAME(m_tc0610_ctrl_reg)); } @@ -86,8 +84,6 @@ Heavy use is made of sprite zooming. void galastrm_state::draw_sprites_pre(int x_offs, int y_offs) { - uint32_t *spriteram32 = m_spriteram; - uint16_t *spritemap = (uint16_t *)memregion("user1")->base(); int offs, data, tilenum, color, flipx, flipy; int x, y, priority, dblsize, curx, cury; int sprites_flipscreen = 0; @@ -101,19 +97,19 @@ void galastrm_state::draw_sprites_pre(int x_offs, int y_offs) for (offs = (m_spriteram.bytes()/4-4);offs >= 0;offs -= 4) { - data = spriteram32[offs+0]; + data = m_spriteram[offs+0]; flipx = (data & 0x00800000) >> 23; zoomx = (data & 0x007f0000) >> 16; tilenum = (data & 0x00007fff); if (!tilenum) continue; - data = spriteram32[offs+2]; + data = m_spriteram[offs+2]; priority = (data & 0x000c0000) >> 18; color = (data & 0x0003fc00) >> 10; x = (data & 0x000003ff); - data = spriteram32[offs+3]; + data = m_spriteram[offs+3]; dblsize = (data & 0x00040000) >> 18; flipy = (data & 0x00020000) >> 17; zoomy = (data & 0x0001fc00) >> 10; @@ -146,7 +142,7 @@ void galastrm_state::draw_sprites_pre(int x_offs, int y_offs) if (flipx) px = dimension-1-k; if (flipy) py = dimension-1-j; - code = spritemap[map_offset + px + (py<<(dblsize+1))]; + code = m_spritemap_rom[map_offset + px + (py<<(dblsize+1))]; if (code==0xffff) {