diff options
author | cam900 <dbtlrchl@naver.com> | 2019-01-27 14:00:07 +0900 |
---|---|---|
committer | Vas Crabb <cuavas@users.noreply.github.com> | 2019-01-27 16:00:07 +1100 |
commit | 5fec2abe9b266610c05be0f344b2a660ee803931 (patch) | |
tree | f981ee8c9944b2398816ac39d631df32e637db72 | |
parent | 65ea7d3f23630f43054b52d7338ffdda1499b9ba (diff) |
dcheese.cpp : Cleanups (#4561)
* dcheese.cpp : Cleanups
Remove MCFGs, Runtime tag lookups, Use shorter/correct type values, Fix some namings, Spacings, Reduce unnecessary lines, Defines
* dcheese.cpp : Minor revert (nw)
-rw-r--r-- | src/mame/drivers/dcheese.cpp | 63 | ||||
-rw-r--r-- | src/mame/includes/dcheese.h | 30 | ||||
-rw-r--r-- | src/mame/video/dcheese.cpp | 75 |
3 files changed, 84 insertions, 84 deletions
diff --git a/src/mame/drivers/dcheese.cpp b/src/mame/drivers/dcheese.cpp index 8993ba7b2ca..ae549e95787 100644 --- a/src/mame/drivers/dcheese.cpp +++ b/src/mame/drivers/dcheese.cpp @@ -69,17 +69,17 @@ IRQ_CALLBACK_MEMBER(dcheese_state::irq_callback) } -void dcheese_state::dcheese_signal_irq(int which ) +void dcheese_state::signal_irq(u8 which) { m_irq_state[which] = 1; update_irq_state(); } -INTERRUPT_GEN_MEMBER(dcheese_state::dcheese_vblank) +INTERRUPT_GEN_MEMBER(dcheese_state::vblank) { logerror("---- VBLANK ----\n"); - dcheese_signal_irq(4); + signal_irq(4); } @@ -117,7 +117,7 @@ WRITE16_MEMBER(dcheese_state::eeprom_control_w) /* bits $0080-$0010 are probably lamps */ if (ACCESSING_BITS_0_7) { - ioport("EEPROMOUT")->write(data, 0xff); + m_eepromout_io->write(data, 0xff); } } @@ -138,7 +138,7 @@ READ8_MEMBER(dcheese_state::sound_status_r) WRITE8_MEMBER(dcheese_state::sound_control_w) { - uint8_t diff = data ^ m_sound_control; + u8 const diff = data ^ m_sound_control; m_sound_control = data; /* bit 0x20 = LED */ @@ -173,7 +173,7 @@ WRITE8_MEMBER(dcheese_state::bsmt_data_w) void dcheese_state::main_cpu_map(address_map &map) { map.unmap_value_high(); - map(0x000000, 0x03ffff).rom(); + map(0x000000, 0x03ffff).rom().region("maincpu", 0); map(0x100000, 0x10ffff).ram(); map(0x200000, 0x200001).portr("200000").w("watchdog", FUNC(watchdog_timer_device::reset16_w)); map(0x220000, 0x220001).portr("220000").w(FUNC(dcheese_state::blitter_color_w)); @@ -200,7 +200,7 @@ void dcheese_state::sound_cpu_map(address_map &map) map(0x0800, 0x0800).mirror(0x07ff).r(m_soundlatch, FUNC(generic_latch_8_device::read)); map(0x1000, 0x10ff).mirror(0x0700).w(FUNC(dcheese_state::bsmt_data_w)); map(0x1800, 0x1fff).ram(); - map(0x2000, 0xffff).rom(); + map(0x2000, 0xffff).rom().region("audiocpu", 0x2000); } @@ -371,17 +371,17 @@ INPUT_PORTS_END * *************************************/ -MACHINE_CONFIG_START(dcheese_state::dcheese) - +void dcheese_state::dcheese(machine_config &config) +{ /* basic machine hardware */ - MCFG_DEVICE_ADD("maincpu", M68000, MAIN_OSC) - MCFG_DEVICE_PROGRAM_MAP(main_cpu_map) - MCFG_DEVICE_VBLANK_INT_DRIVER("screen", dcheese_state, dcheese_vblank) - MCFG_DEVICE_IRQ_ACKNOWLEDGE_DRIVER(dcheese_state,irq_callback) + M68000(config, m_maincpu, MAIN_OSC); + m_maincpu->set_addrmap(AS_PROGRAM, &dcheese_state::main_cpu_map); + m_maincpu->set_vblank_int("screen", FUNC(dcheese_state::vblank)); + m_maincpu->set_irq_acknowledge_callback(FUNC(dcheese_state::irq_callback)); - MCFG_DEVICE_ADD("audiocpu", M6809, SOUND_OSC/16) - MCFG_DEVICE_PROGRAM_MAP(sound_cpu_map) - MCFG_DEVICE_PERIODIC_INT_DRIVER(dcheese_state, irq1_line_hold, 480) /* accurate for fredmem */ + M6809(config, m_audiocpu, SOUND_OSC/16); // TODO : Unknown CPU type + m_audiocpu->set_addrmap(AS_PROGRAM, &dcheese_state::sound_cpu_map); + m_audiocpu->set_periodic_int(FUNC(dcheese_state::irq1_line_hold), attotime::from_hz(480)); /* accurate for fredmem */ EEPROM_93C46_16BIT(config, "eeprom"); @@ -390,12 +390,12 @@ MACHINE_CONFIG_START(dcheese_state::dcheese) WATCHDOG_TIMER(config, "watchdog"); /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_SIZE(360, 262) /* guess, need to see what the games write to the vid registers */ - MCFG_SCREEN_VISIBLE_AREA(0, 319, 0, 239) - MCFG_SCREEN_UPDATE_DRIVER(dcheese_state, screen_update_dcheese) - MCFG_SCREEN_PALETTE("palette") + SCREEN(config, m_screen, SCREEN_TYPE_RASTER); + m_screen->set_refresh_hz(60); + m_screen->set_size(360, 262); /* guess, need to see what the games write to the vid registers */ + m_screen->set_visarea(0, 319, 0, 239); + m_screen->set_screen_update(FUNC(dcheese_state::screen_update)); + m_screen->set_palette("palette"); PALETTE(config, "palette", FUNC(dcheese_state::dcheese_palette), 65536); @@ -406,17 +406,18 @@ MACHINE_CONFIG_START(dcheese_state::dcheese) GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0); - MCFG_DEVICE_ADD("bsmt", BSMT2000, SOUND_OSC) - MCFG_SOUND_ROUTE(0, "lspeaker", 1.2) - MCFG_SOUND_ROUTE(1, "rspeaker", 1.2) -MACHINE_CONFIG_END + BSMT2000(config, m_bsmt, SOUND_OSC); + m_bsmt->add_route(0, "lspeaker", 1.2); + m_bsmt->add_route(1, "rspeaker", 1.2); +} -MACHINE_CONFIG_START(dcheese_state::fredmem) +void dcheese_state::fredmem(machine_config &config) +{ dcheese(config); - MCFG_SCREEN_MODIFY("screen") - MCFG_SCREEN_VISIBLE_AREA(0, 359, 0, 239) -MACHINE_CONFIG_END + + m_screen->set_visarea(0, 359, 0, 239); +} @@ -760,7 +761,7 @@ ROM_START( cecmatch ) ROM_RELOAD( 0x3c0000, 0x40000 ) ROM_REGION16_LE( 0x20000, "palrom", 0 ) - ROM_LOAD16_BYTE( "0.144", 0x00000, 0x10000, CRC(69b3cc85) SHA1(05f7204ac961274b5d2f42cc6c0d06e5fa146aef)) /* Palette - 0 at U144 */ + ROM_LOAD16_BYTE( "0.144", 0x00000, 0x10000, CRC(69b3cc85) SHA1(05f7204ac961274b5d2f42cc6c0d06e5fa146aef) ) /* Palette - 0 at U144 */ ROM_LOAD16_BYTE( "1.145", 0x00001, 0x10000, CRC(e64a8511) SHA1(0e3a1fe936c841b8acfb150bf63e564b1dec2363) ) /* Palette - 1 at U145 */ ROM_END diff --git a/src/mame/includes/dcheese.h b/src/mame/includes/dcheese.h index 14db4da22a0..be29fe707ac 100644 --- a/src/mame/includes/dcheese.h +++ b/src/mame/includes/dcheese.h @@ -23,6 +23,9 @@ public: driver_device(mconfig, type, tag), m_palrom(*this, "palrom"), m_gfxrom(*this, "gfx"), + m_eepromout_io(*this, "EEPROMOUT"), + m_2a0002_io(*this, "2a0002"), + m_2a000e_io(*this, "2a000e"), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), m_screen(*this, "screen"), @@ -48,23 +51,26 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; private: - required_region_ptr<uint16_t> m_palrom; - required_region_ptr<uint8_t> m_gfxrom; + required_region_ptr<u16> m_palrom; + required_region_ptr<u8> m_gfxrom; + required_ioport m_eepromout_io; + required_ioport m_2a0002_io; + required_ioport m_2a000e_io; /* video-related */ - uint16_t m_blitter_color[2]; - uint16_t m_blitter_xparam[16]; - uint16_t m_blitter_yparam[16]; - uint16_t m_blitter_vidparam[32]; + u16 m_blitter_color[2]; + u16 m_blitter_xparam[16]; + u16 m_blitter_yparam[16]; + u16 m_blitter_vidparam[32]; std::unique_ptr<bitmap_ind16> m_dstbitmap; emu_timer *m_blitter_timer; emu_timer *m_signal_irq_timer; /* misc */ - uint8_t m_irq_state[5]; - uint8_t m_sound_control; - uint8_t m_sound_msb_latch; + u8 m_irq_state[5]; + u8 m_sound_control; + u8 m_sound_msb_latch; /* devices */ required_device<cpu_device> m_maincpu; @@ -84,9 +90,9 @@ private: DECLARE_WRITE16_MEMBER(blitter_unknown_w); DECLARE_READ16_MEMBER(blitter_vidparam_r); void dcheese_palette(palette_device &palette) const; - uint32_t screen_update_dcheese(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(dcheese_vblank); - void dcheese_signal_irq(int which); + u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(vblank); + void signal_irq(u8 which); void update_irq_state(); IRQ_CALLBACK_MEMBER(irq_callback); void update_scanline_irq(); diff --git a/src/mame/video/dcheese.cpp b/src/mame/video/dcheese.cpp index 8e4e1d5b1ff..f7a82d589aa 100644 --- a/src/mame/video/dcheese.cpp +++ b/src/mame/video/dcheese.cpp @@ -17,8 +17,8 @@ * *************************************/ -#define DSTBITMAP_WIDTH 512 -#define DSTBITMAP_HEIGHT 512 +static constexpr u32 DSTBITMAP_WIDTH = 512; +static constexpr u32 DSTBITMAP_HEIGHT = 512; /************************************* @@ -31,7 +31,7 @@ void dcheese_state::dcheese_palette(palette_device &palette) const { for (int i = 0; i < 65536; i++) { - int const data = m_palrom[i]; + u16 const data = m_palrom[i]; palette.set_pen_color(i, pal6bit(data >> 0), pal5bit(data >> 6), pal5bit(data >> 11)); } } @@ -49,16 +49,13 @@ void dcheese_state::update_scanline_irq() /* if not in range, don't bother */ if (m_blitter_vidparam[0x22/2] <= m_blitter_vidparam[0x1e/2]) { - int effscan; - attotime time; - /* compute the effective scanline of the interrupt */ - effscan = m_blitter_vidparam[0x22/2] - m_blitter_vidparam[0x1a/2]; + int effscan = m_blitter_vidparam[0x22/2] - m_blitter_vidparam[0x1a/2]; if (effscan < 0) effscan += m_blitter_vidparam[0x1e/2]; /* determine the time; if it's in this scanline, bump to the next frame */ - time = m_screen->time_until_pos(effscan); + attotime time = m_screen->time_until_pos(effscan); if (time < m_screen->scan_period()) time += m_screen->frame_period(); m_blitter_timer->adjust(time); @@ -71,11 +68,11 @@ void dcheese_state::device_timer(emu_timer &timer, device_timer_id id, int param switch (id) { case TIMER_BLITTER_SCANLINE: - dcheese_signal_irq(3); + signal_irq(3); update_scanline_irq(); break; case TIMER_SIGNAL_IRQ: - dcheese_signal_irq(param); + signal_irq(param); break; default: assert_always(false, "Unknown id in dcheese_state::device_timer"); @@ -114,17 +111,15 @@ void dcheese_state::video_start() * *************************************/ -uint32_t dcheese_state::screen_update_dcheese(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +u32 dcheese_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - int x, y; - /* update the pixels */ - for (y = cliprect.min_y; y <= cliprect.max_y; y++) + for (int y = cliprect.min_y; y <= cliprect.max_y; y++) { - uint16_t *dest = &bitmap.pix16(y); - uint16_t *src = &m_dstbitmap->pix16((y + m_blitter_vidparam[0x28/2]) & 0x1ff); + u16 *dest = &bitmap.pix16(y); + u16 *src = &m_dstbitmap->pix16((y + m_blitter_vidparam[0x28/2]) & 0x1ff); - for (x = cliprect.min_x; x <= cliprect.max_x; x++) + for (int x = cliprect.min_x; x <= cliprect.max_x; x++) dest[x] = src[x]; } return 0; @@ -138,12 +133,10 @@ uint32_t dcheese_state::screen_update_dcheese(screen_device &screen, bitmap_ind1 * *************************************/ -void dcheese_state::do_clear( ) +void dcheese_state::do_clear() { - int y; - /* clear the requested scanlines */ - for (y = m_blitter_vidparam[0x2c/2]; y < m_blitter_vidparam[0x2a/2]; y++) + for (int y = m_blitter_vidparam[0x2c/2]; y < m_blitter_vidparam[0x2a/2]; y++) memset(&m_dstbitmap->pix16(y & 0x1ff), 0, DSTBITMAP_WIDTH * 2); /* signal an IRQ when done (timing is just a guess) */ @@ -151,31 +144,31 @@ void dcheese_state::do_clear( ) } -void dcheese_state::do_blit( ) +void dcheese_state::do_blit() { - int32_t const srcminx = m_blitter_xparam[0] << 12; - int32_t const srcmaxx = m_blitter_xparam[1] << 12; - int32_t const srcminy = m_blitter_yparam[0] << 12; - int32_t const srcmaxy = m_blitter_yparam[1] << 12; - int32_t const srcx = ((m_blitter_xparam[2] & 0x0fff) | ((m_blitter_xparam[3] & 0x0fff) << 12)) << 7; - int32_t const srcy = ((m_blitter_yparam[2] & 0x0fff) | ((m_blitter_yparam[3] & 0x0fff) << 12)) << 7; - int32_t const dxdx = (int32_t)(((m_blitter_xparam[4] & 0x0fff) | ((m_blitter_xparam[5] & 0x0fff) << 12)) << 12) >> 12; - int32_t const dxdy = (int32_t)(((m_blitter_xparam[6] & 0x0fff) | ((m_blitter_xparam[7] & 0x0fff) << 12)) << 12) >> 12; - int32_t const dydx = (int32_t)(((m_blitter_yparam[4] & 0x0fff) | ((m_blitter_yparam[5] & 0x0fff) << 12)) << 12) >> 12; - int32_t const dydy = (int32_t)(((m_blitter_yparam[6] & 0x0fff) | ((m_blitter_yparam[7] & 0x0fff) << 12)) << 12) >> 12; - uint32_t const pagemask = m_gfxrom.mask() >> 18; + s32 const srcminx = m_blitter_xparam[0] << 12; + s32 const srcmaxx = m_blitter_xparam[1] << 12; + s32 const srcminy = m_blitter_yparam[0] << 12; + s32 const srcmaxy = m_blitter_yparam[1] << 12; + s32 const srcx = ((m_blitter_xparam[2] & 0x0fff) | ((m_blitter_xparam[3] & 0x0fff) << 12)) << 7; + s32 const srcy = ((m_blitter_yparam[2] & 0x0fff) | ((m_blitter_yparam[3] & 0x0fff) << 12)) << 7; + s32 const dxdx = (s32)(((m_blitter_xparam[4] & 0x0fff) | ((m_blitter_xparam[5] & 0x0fff) << 12)) << 12) >> 12; + s32 const dxdy = (s32)(((m_blitter_xparam[6] & 0x0fff) | ((m_blitter_xparam[7] & 0x0fff) << 12)) << 12) >> 12; + s32 const dydx = (s32)(((m_blitter_yparam[4] & 0x0fff) | ((m_blitter_yparam[5] & 0x0fff) << 12)) << 12) >> 12; + s32 const dydy = (s32)(((m_blitter_yparam[6] & 0x0fff) | ((m_blitter_yparam[7] & 0x0fff) << 12)) << 12) >> 12; + u32 const pagemask = m_gfxrom.mask() >> 18; int const xstart = m_blitter_xparam[14]; int const xend = m_blitter_xparam[15] + 1; int const ystart = m_blitter_yparam[14]; int const yend = m_blitter_yparam[15]; - int const color = (m_blitter_color[0] << 8) & 0xff00; - int const mask = (m_blitter_color[0] >> 8) & 0x00ff; - int const opaque = (dxdx | dxdy | dydx | dydy) == 0; /* bit of a hack for fredmem */ + u32 const color = (m_blitter_color[0] << 8) & 0xff00; + u8 const mask = (m_blitter_color[0] >> 8) & 0x00ff; + bool const opaque = (dxdx | dxdy | dydx | dydy) == 0; /* bit of a hack for fredmem */ /* loop over target rows */ for (int y = ystart; y <= yend; y++) { - uint16_t *dst = &m_dstbitmap->pix16(y & 0x1ff); + u16 *dst = &m_dstbitmap->pix16(y & 0x1ff); /* loop over target columns */ for (int x = xstart; x <= xend; x++) @@ -188,8 +181,8 @@ void dcheese_state::do_blit( ) if (sx >= srcminx && sx <= srcmaxx && sy >= srcminy && sy <= srcmaxy) { /* page comes from bit 22 of Y and bit 21 of X */ - int const page = (((sy >> 21) & 2) | ((sx >> 21) & 1) | ((sx >> 20) & 4)) & pagemask; - int const pix = m_gfxrom[(page << 18) | (((sy >> 12) & 0x1ff) << 9) | ((sx >> 12) & 0x1ff)]; + u32 const page = (((sy >> 21) & 2) | ((sx >> 21) & 1) | ((sx >> 20) & 4)) & pagemask; + u8 const pix = m_gfxrom[(page << 18) | (((sy >> 12) & 0x1ff) << 9) | ((sx >> 12) & 0x1ff)]; /* only non-zero pixels get written */ if (pix | opaque) @@ -300,9 +293,9 @@ READ16_MEMBER(dcheese_state::blitter_vidparam_r) { /* analog inputs seem to be hooked up here -- might not actually map to blitter */ if (offset == 0x02/2) - return ioport("2a0002")->read(); + return m_2a0002_io->read(); if (offset == 0x0e/2) - return ioport("2a000e")->read(); + return m_2a000e_io->read(); /* early code polls on this bit, wants it to be 0 */ if (offset == 0x36/2) |