From 108c36547ccd890828a173752aa4f20bb456208c Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Tue, 12 Jun 2018 07:04:57 +0200 Subject: lviv, gaplus: machine().device cleanup, other cleanup, nw --- src/mame/drivers/gaplus.cpp | 232 ++++++++++++++++++++------------------------ src/mame/drivers/lviv.cpp | 36 +++---- src/mame/includes/gaplus.h | 88 ++++++++++++----- src/mame/includes/lviv.h | 103 +++++++++++--------- src/mame/machine/gaplus.cpp | 4 +- src/mame/machine/lviv.cpp | 60 ++++++------ src/mame/video/gaplus.cpp | 182 ++++++++++++++++------------------ src/mame/video/lviv.cpp | 55 +++++------ 8 files changed, 379 insertions(+), 381 deletions(-) diff --git a/src/mame/drivers/gaplus.cpp b/src/mame/drivers/gaplus.cpp index 1af2b4392a9..998f806706d 100644 --- a/src/mame/drivers/gaplus.cpp +++ b/src/mame/drivers/gaplus.cpp @@ -161,7 +161,7 @@ TODO: #include "speaker.h" -WRITE8_MEMBER(gaplus_state::irq_1_ctrl_w) +WRITE8_MEMBER(gaplus_base_state::irq_1_ctrl_w) { int bit = !BIT(offset, 11); m_main_irq_mask = bit & 1; @@ -169,7 +169,7 @@ WRITE8_MEMBER(gaplus_state::irq_1_ctrl_w) m_maincpu->set_input_line(0, CLEAR_LINE); } -WRITE8_MEMBER(gaplus_state::irq_2_ctrl_w) +WRITE8_MEMBER(gaplus_base_state::irq_2_ctrl_w) { int bit = offset & 1; m_sub_irq_mask = bit & 1; @@ -177,7 +177,7 @@ WRITE8_MEMBER(gaplus_state::irq_2_ctrl_w) m_subcpu->set_input_line(0, CLEAR_LINE); } -WRITE8_MEMBER(gaplus_state::irq_3_ctrl_w) +WRITE8_MEMBER(gaplus_base_state::irq_3_ctrl_w) { int bit = !BIT(offset, 13); m_sub2_irq_mask = bit & 1; @@ -185,7 +185,7 @@ WRITE8_MEMBER(gaplus_state::irq_3_ctrl_w) m_subcpu2->set_input_line(0, CLEAR_LINE); } -WRITE8_MEMBER(gaplus_state::sreset_w) +WRITE8_MEMBER(gaplus_base_state::sreset_w) { int bit = !BIT(offset, 11); m_subcpu->set_input_line(INPUT_LINE_RESET, bit ? CLEAR_LINE : ASSERT_LINE); @@ -193,7 +193,7 @@ WRITE8_MEMBER(gaplus_state::sreset_w) m_namco_15xx->sound_enable_w(bit); } -WRITE8_MEMBER(gaplus_state::freset_w) +WRITE8_MEMBER(gaplus_base_state::freset_w) { int bit = !BIT(offset, 11); @@ -203,14 +203,14 @@ WRITE8_MEMBER(gaplus_state::freset_w) m_namco56xx->set_reset_line(bit ? CLEAR_LINE : ASSERT_LINE); } -void gaplus_state::machine_reset() +void gaplus_base_state::machine_reset() { /* on reset, VINTON is reset, while the other flags don't seem to be affected */ m_sub_irq_mask = 0; m_subcpu->set_input_line(0, CLEAR_LINE); } -void gaplus_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +void gaplus_base_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) { @@ -221,21 +221,21 @@ void gaplus_state::device_timer(emu_timer &timer, device_timer_id id, int param, namcoio1_run(ptr, param); break; default: - assert_always(false, "Unknown id in gaplus_state::device_timer"); + assert_always(false, "Unknown id in gaplus_base_state::device_timer"); } } -TIMER_CALLBACK_MEMBER(gaplus_state::namcoio0_run) +TIMER_CALLBACK_MEMBER(gaplus_base_state::namcoio0_run) { m_namco58xx->customio_run(); } -TIMER_CALLBACK_MEMBER(gaplus_state::namcoio1_run) +TIMER_CALLBACK_MEMBER(gaplus_base_state::namcoio1_run) { m_namco56xx->customio_run(); } -WRITE_LINE_MEMBER(gaplus_state::vblank_irq) +WRITE_LINE_MEMBER(gaplus_base_state::vblank_irq) { if (!state) return; @@ -256,7 +256,7 @@ WRITE_LINE_MEMBER(gaplus_state::vblank_irq) m_subcpu2->set_input_line(0, ASSERT_LINE); } -WRITE_LINE_MEMBER(gaplus_state::gapluso_vblank_irq) +WRITE_LINE_MEMBER(gapluso_state::vblank_irq) { if (!state) return; @@ -278,36 +278,36 @@ WRITE_LINE_MEMBER(gaplus_state::gapluso_vblank_irq) } -void gaplus_state::cpu1_map(address_map &map) +void gaplus_base_state::cpu1_map(address_map &map) { - map(0x0000, 0x07ff).ram().w(FUNC(gaplus_state::videoram_w)).share("videoram"); /* tilemap RAM (shared with CPU #2) */ + map(0x0000, 0x07ff).ram().w(FUNC(gaplus_base_state::videoram_w)).share("videoram"); /* tilemap RAM (shared with CPU #2) */ map(0x0800, 0x1fff).ram().share("spriteram"); /* shared RAM with CPU #2 (includes sprite RAM) */ map(0x6000, 0x63ff).rw(m_namco_15xx, FUNC(namco_15xx_device::sharedram_r), FUNC(namco_15xx_device::sharedram_w)); /* shared RAM with CPU #3 */ map(0x6800, 0x680f).rw("namcoio_1", FUNC(namcoio_device::read), FUNC(namcoio_device::write)); /* custom I/O chips interface */ map(0x6810, 0x681f).rw("namcoio_2", FUNC(namcoio_device::read), FUNC(namcoio_device::write)); /* custom I/O chips interface */ - map(0x6820, 0x682f).rw(FUNC(gaplus_state::customio_3_r), FUNC(gaplus_state::customio_3_w)).share("customio_3"); /* custom I/O chip #3 interface */ - map(0x7000, 0x7fff).w(FUNC(gaplus_state::irq_1_ctrl_w)); /* main CPU irq control */ + map(0x6820, 0x682f).rw(FUNC(gaplus_base_state::customio_3_r), FUNC(gaplus_base_state::customio_3_w)).share("customio_3"); /* custom I/O chip #3 interface */ + map(0x7000, 0x7fff).w(FUNC(gaplus_base_state::irq_1_ctrl_w)); /* main CPU irq control */ map(0x7800, 0x7fff).r("watchdog", FUNC(watchdog_timer_device::reset_r)); - map(0x8000, 0x8fff).w(FUNC(gaplus_state::sreset_w)); /* reset CPU #2 & #3, enable sound */ - map(0x9000, 0x9fff).w(FUNC(gaplus_state::freset_w)); /* reset I/O chips */ - map(0xa000, 0xa7ff).w(FUNC(gaplus_state::starfield_control_w)); /* starfield control */ + map(0x8000, 0x8fff).w(FUNC(gaplus_base_state::sreset_w)); /* reset CPU #2 & #3, enable sound */ + map(0x9000, 0x9fff).w(FUNC(gaplus_base_state::freset_w)); /* reset I/O chips */ + map(0xa000, 0xa7ff).w(FUNC(gaplus_base_state::starfield_control_w)); /* starfield control */ map(0xa000, 0xffff).rom(); /* ROM */ } -void gaplus_state::cpu2_map(address_map &map) +void gaplus_base_state::cpu2_map(address_map &map) { - map(0x0000, 0x07ff).ram().w(FUNC(gaplus_state::videoram_w)).share("videoram"); /* tilemap RAM (shared with CPU #1) */ + map(0x0000, 0x07ff).ram().w(FUNC(gaplus_base_state::videoram_w)).share("videoram"); /* tilemap RAM (shared with CPU #1) */ map(0x0800, 0x1fff).ram().share("spriteram"); /* shared RAM with CPU #1 */ // AM_RANGE(0x500f, 0x500f) AM_WRITENOP /* ??? written 256 times on startup */ - map(0x6000, 0x6fff).w(FUNC(gaplus_state::irq_2_ctrl_w)); /* IRQ 2 control */ + map(0x6000, 0x6fff).w(FUNC(gaplus_base_state::irq_2_ctrl_w)); /* IRQ 2 control */ map(0xa000, 0xffff).rom(); /* ROM */ } -void gaplus_state::cpu3_map(address_map &map) +void gaplus_base_state::cpu3_map(address_map &map) { map(0x0000, 0x03ff).rw(m_namco_15xx, FUNC(namco_15xx_device::sharedram_r), FUNC(namco_15xx_device::sharedram_w)); /* shared RAM with the main CPU + sound registers */ map(0x2000, 0x3fff).rw("watchdog", FUNC(watchdog_timer_device::reset_r), FUNC(watchdog_timer_device::reset_w)); /* watchdog? */ - map(0x4000, 0x7fff).w(FUNC(gaplus_state::irq_3_ctrl_w)); /* interrupt enable/disable */ + map(0x4000, 0x7fff).w(FUNC(gaplus_base_state::irq_3_ctrl_w)); /* interrupt enable/disable */ map(0xe000, 0xffff).rom(); /* ROM */ } @@ -497,46 +497,77 @@ WRITE8_MEMBER(gaplus_state::out_lamps1) machine().bookkeeping().coin_counter_w(1, ~data & 1); } -void gaplus_state::machine_start() +void gaplus_base_state::machine_start() { - m_lamps.resolve(); m_namcoio0_run_timer = timer_alloc(TIMER_NAMCOIO0_RUN); m_namcoio1_run_timer = timer_alloc(TIMER_NAMCOIO1_RUN); - switch (m_type) - { - case GAME_GALAGA3: - case GAME_GAPLUS: - m_namco56xx = machine().device("namcoio_1"); - m_namco58xx = machine().device("namcoio_2"); - break; - case GAME_GAPLUSD: - m_namco58xx = machine().device("namcoio_1"); - m_namco56xx = machine().device("namcoio_2"); - break; - } - save_item(NAME(m_main_irq_mask)); save_item(NAME(m_sub_irq_mask)); save_item(NAME(m_sub2_irq_mask)); } +void gaplus_state::machine_start() +{ + gaplus_base_state::machine_start(); -MACHINE_CONFIG_START(gaplus_state::gaplus) - - /* basic machine hardware */ - MCFG_DEVICE_ADD("maincpu", MC6809E, XTAL(24'576'000)/16) /* 1.536 MHz */ - MCFG_DEVICE_PROGRAM_MAP(cpu1_map) - - MCFG_DEVICE_ADD("sub", MC6809E, XTAL(24'576'000)/16) /* 1.536 MHz */ - MCFG_DEVICE_PROGRAM_MAP(cpu2_map) - - MCFG_DEVICE_ADD("sub2", MC6809E, XTAL(24'576'000)/16) /* 1.536 MHz */ - MCFG_DEVICE_PROGRAM_MAP(cpu3_map) + m_lamps.resolve(); +} - MCFG_QUANTUM_TIME(attotime::from_hz(6000)) /* a high value to ensure proper synchronization of the CPUs */ +MACHINE_CONFIG_START(gaplus_base_state::gaplus_base) + /* basic machine hardware */ + MCFG_DEVICE_ADD(m_maincpu, MC6809E, XTAL(24'576'000) / 16) /* 1.536 MHz */ + MCFG_DEVICE_PROGRAM_MAP(cpu1_map) + + MCFG_DEVICE_ADD("sub", MC6809E, XTAL(24'576'000) / 16) /* 1.536 MHz */ + MCFG_DEVICE_PROGRAM_MAP(cpu2_map) + + MCFG_DEVICE_ADD("sub2", MC6809E, XTAL(24'576'000) / 16) /* 1.536 MHz */ + MCFG_DEVICE_PROGRAM_MAP(cpu3_map) + + MCFG_QUANTUM_TIME(attotime::from_hz(6000)) /* a high value to ensure proper synchronization of the CPUs */ + + MCFG_WATCHDOG_ADD("watchdog") + + MCFG_NAMCO_62XX_ADD("62xx", 24576000 / 6 / 2) /* totally made up - TODO: fix */ + //MCFG_NAMCO_62XX_INPUT_0_CB(IOPORT("IN0L")) + //MCFG_NAMCO_62XX_INPUT_1_CB(IOPORT("IN0H")) + //MCFG_NAMCO_62XX_INPUT_2_CB(IOPORT("IN1L")) + //MCFG_NAMCO_62XX_INPUT_3_CB(IOPORT("IN1H")) + //MCFG_NAMCO_62XX_OUTPUT_0_CB(WRITE8(*this, gaplus_base_state,out_0)) + //MCFG_NAMCO_62XX_OUTPUT_1_CB(WRITE8(*this, gaplus_base_state,out_1)) + + /* video hardware */ + MCFG_SCREEN_ADD("screen", RASTER) + MCFG_SCREEN_REFRESH_RATE(60.606060) + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) + MCFG_SCREEN_SIZE(36 * 8, 28 * 8) + MCFG_SCREEN_VISIBLE_AREA(0 * 8, 36 * 8 - 1, 0 * 8, 28 * 8 - 1) + MCFG_SCREEN_UPDATE_DRIVER(gaplus_base_state, screen_update) + MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, gaplus_base_state, screen_vblank)) + MCFG_DEVCB_CHAIN_OUTPUT(WRITELINE(*this, gaplus_base_state, vblank_irq)) + MCFG_SCREEN_PALETTE("palette") + + MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_gaplus) + MCFG_PALETTE_ADD("palette", 64 * 4 + 64 * 8) + MCFG_PALETTE_INDIRECT_ENTRIES(256) + MCFG_PALETTE_INIT_OWNER(gaplus_base_state, gaplus) + + /* sound hardware */ + SPEAKER(config, "mono").front_center(); + + MCFG_DEVICE_ADD("namco", NAMCO_15XX, XTAL(24'576'000) / 1024) + MCFG_NAMCO_AUDIO_VOICES(8) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) + + MCFG_DEVICE_ADD("samples", SAMPLES) + MCFG_SAMPLES_CHANNELS(1) + MCFG_SAMPLES_NAMES(gaplus_sample_names) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) +MACHINE_CONFIG_END - MCFG_WATCHDOG_ADD("watchdog") +MACHINE_CONFIG_START(gaplus_state::gaplus) + gaplus_base(config); MCFG_DEVICE_ADD("namcoio_1", NAMCO_56XX, 0) MCFG_NAMCO56XX_IN_0_CB(IOPORT("COINS")) @@ -551,75 +582,39 @@ MACHINE_CONFIG_START(gaplus_state::gaplus) MCFG_NAMCO58XX_IN_1_CB(IOPORT("DSWB_LOW")) MCFG_NAMCO58XX_IN_2_CB(IOPORT("DSWB_HIGH")) MCFG_NAMCO58XX_IN_3_CB(IOPORT("DSWA_LOW")) - - MCFG_NAMCO_62XX_ADD("62xx", 24576000/6/2) /* totally made up - TODO: fix */ - //MCFG_NAMCO_62XX_INPUT_0_CB(IOPORT("IN0L")) - //MCFG_NAMCO_62XX_INPUT_1_CB(IOPORT("IN0H")) - //MCFG_NAMCO_62XX_INPUT_2_CB(IOPORT("IN1L")) - //MCFG_NAMCO_62XX_INPUT_3_CB(IOPORT("IN1H")) - //MCFG_NAMCO_62XX_OUTPUT_0_CB(WRITE8(*this, gaplus_state,out_0)) - //MCFG_NAMCO_62XX_OUTPUT_1_CB(WRITE8(*this, gaplus_state,out_1)) - - /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60.606060) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) - MCFG_SCREEN_SIZE(36*8, 28*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 0*8, 28*8-1) - MCFG_SCREEN_UPDATE_DRIVER(gaplus_state, screen_update) - MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, gaplus_state, screen_vblank)) - MCFG_DEVCB_CHAIN_OUTPUT(WRITELINE(*this, gaplus_state, vblank_irq)) - MCFG_SCREEN_PALETTE("palette") - - MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_gaplus) - MCFG_PALETTE_ADD("palette", 64*4+64*8) - MCFG_PALETTE_INDIRECT_ENTRIES(256) - MCFG_PALETTE_INIT_OWNER(gaplus_state, gaplus) - - /* sound hardware */ - SPEAKER(config, "mono").front_center(); - - MCFG_DEVICE_ADD("namco", NAMCO_15XX, XTAL(24'576'000)/1024) - MCFG_NAMCO_AUDIO_VOICES(8) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - - MCFG_DEVICE_ADD("samples", SAMPLES) - MCFG_SAMPLES_CHANNELS(1) - MCFG_SAMPLES_NAMES(gaplus_sample_names) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -MACHINE_CONFIG_START(gaplus_state::gaplusd) - gaplus(config); +MACHINE_CONFIG_START(gaplusd_state::gaplusd) + gaplus_base(config); - MCFG_DEVICE_REPLACE("namcoio_1", NAMCO_58XX, 0) + MCFG_DEVICE_ADD("namcoio_1", NAMCO_58XX, 0) MCFG_NAMCO58XX_IN_0_CB(IOPORT("COINS")) MCFG_NAMCO58XX_IN_1_CB(IOPORT("P1")) MCFG_NAMCO58XX_IN_2_CB(IOPORT("P2")) MCFG_NAMCO58XX_IN_3_CB(IOPORT("BUTTONS")) - MCFG_DEVICE_REPLACE("namcoio_2", NAMCO_56XX, 0) + MCFG_DEVICE_ADD("namcoio_2", NAMCO_56XX, 0) MCFG_NAMCO56XX_IN_0_CB(IOPORT("DSWA_HIGH")) MCFG_NAMCO56XX_IN_1_CB(IOPORT("DSWB_LOW")) MCFG_NAMCO56XX_IN_2_CB(IOPORT("DSWB_HIGH")) MCFG_NAMCO56XX_IN_3_CB(IOPORT("DSWA_LOW")) MACHINE_CONFIG_END -MACHINE_CONFIG_START(gaplus_state::gapluso) - gaplusd(config); +MACHINE_CONFIG_START(gapluso_state::gapluso) + gaplus_base(config); /* basic machine hardware */ MCFG_DEVICE_MODIFY("screen") - MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, gaplus_state, screen_vblank)) - MCFG_DEVCB_CHAIN_OUTPUT(WRITELINE(*this, gaplus_state, gapluso_vblank_irq)) + MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, gaplus_base_state, screen_vblank)) + MCFG_DEVCB_CHAIN_OUTPUT(WRITELINE(*this, gapluso_state, vblank_irq)) - MCFG_DEVICE_REPLACE("namcoio_1", NAMCO_56XX, 0) + MCFG_DEVICE_ADD("namcoio_1", NAMCO_56XX, 0) MCFG_NAMCO56XX_IN_0_CB(IOPORT("COINS")) MCFG_NAMCO56XX_IN_1_CB(IOPORT("P1")) MCFG_NAMCO56XX_IN_2_CB(IOPORT("P2")) MCFG_NAMCO56XX_IN_3_CB(IOPORT("BUTTONS")) - - MCFG_DEVICE_REPLACE("namcoio_2", NAMCO_58XX, 0) + + MCFG_DEVICE_ADD("namcoio_2", NAMCO_58XX, 0) MCFG_NAMCO58XX_IN_0_CB(IOPORT("DSWA_HIGH")) MCFG_NAMCO58XX_IN_1_CB(IOPORT("DSWB_LOW")) MCFG_NAMCO58XX_IN_2_CB(IOPORT("DSWB_HIGH")) @@ -993,44 +988,29 @@ ROM_START( galaga3m ) /* Version (AKA Midway) 1 PCB */ ROM_END -void gaplus_state::init_gaplus() +void gaplus_base_state::driver_init() { - uint8_t *rom = memregion("gfx1")->base(); + uint8_t *rom = m_gfx1_region->base(); for (int i = 0;i < 0x2000;i++) rom[i + 0x2000] = rom[i] >> 4; - rom = memregion("gfx2")->base() + 0x6000; + rom = m_gfx2_region->base() + 0x6000; for (int i = 0;i < 0x2000;i++) rom[i + 0x2000] = rom[i] << 4; - - m_type = GAME_GAPLUS; -} - - -void gaplus_state::init_gaplusd() -{ - init_gaplus(); - m_type = GAME_GAPLUSD; -} - -void gaplus_state::init_galaga3() -{ - init_gaplus(); - m_type = GAME_GALAGA3; } /* These sets are on revision 2 or 3 PCBs AKA "Namco" PCBs */ -GAME( 1984, gaplus, 0, gapluso, gapluso, gaplus_state, init_gaplus, ROT90, "Namco", "Gaplus (GP2 rev. B)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1984, gaplusa, gaplus, gapluso, gapluso, gaplus_state, init_gaplus, ROT90, "Namco", "Gaplus (GP2)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1984, gaplusd, gaplus, gaplusd, gapluso, gaplus_state, init_gaplusd, ROT90, "Namco", "Gaplus (GP2 rev D, alternate hardware)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1984, galaga3, gaplus, gaplus, gaplus, gaplus_state, init_galaga3, ROT90, "Namco", "Galaga 3 (GP3 rev. D)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1984, galaga3a, gaplus, gaplus, gaplus, gaplus_state, init_galaga3, ROT90, "Namco", "Galaga 3 (GP3 rev. C)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1984, galaga3b, gaplus, gaplus, gaplus, gaplus_state, init_galaga3, ROT90, "Namco", "Galaga 3 (GP3)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1984, gaplus, 0, gapluso, gapluso, gapluso_state, driver_init, ROT90, "Namco", "Gaplus (GP2 rev. B)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1984, gaplusa, gaplus, gapluso, gapluso, gapluso_state, driver_init, ROT90, "Namco", "Gaplus (GP2)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1984, gaplusd, gaplus, gaplusd, gapluso, gaplusd_state, driver_init, ROT90, "Namco", "Gaplus (GP2 rev D, alternate hardware)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1984, galaga3, gaplus, gaplus, gaplus, gaplus_state, driver_init, ROT90, "Namco", "Galaga 3 (GP3 rev. D)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1984, galaga3a, gaplus, gaplus, gaplus, gaplus_state, driver_init, ROT90, "Namco", "Galaga 3 (GP3 rev. C)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1984, galaga3b, gaplus, gaplus, gaplus, gaplus_state, driver_init, ROT90, "Namco", "Galaga 3 (GP3)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) /* These sets are on older revision (AKA Midway) 1 PCBs */ -GAME( 1984, galaga3c, gaplus, gaplus, galaga3a, gaplus_state, init_galaga3, ROT90, "Namco", "Galaga 3 (set 4)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1984, galaga3m, gaplus, gaplus, galaga3m, gaplus_state, init_galaga3, ROT90, "Namco", "Galaga 3 (set 5)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1984, galaga3c, gaplus, gaplus, galaga3a, gaplus_state, driver_init, ROT90, "Namco", "Galaga 3 (set 4)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1984, galaga3m, gaplus, gaplus, galaga3m, gaplus_state, driver_init, ROT90, "Namco", "Galaga 3 (set 5)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) /* This is an odd mix of Galaga3 and Gaplus, main code seems closest to galaga3m but still has significant changes, copyright is modified to 1992, has Galaga 3 style high scores, PARSEF spelling error on high score table */ -GAME( 1992, gaplust, gaplus, gaplus, galaga3m, gaplus_state, init_galaga3, ROT90, "bootleg (Tecfri)", "Gaplus (Tecfri PCB)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1992, gaplust, gaplus, gaplus, galaga3m, gaplus_state, driver_init, ROT90, "bootleg (Tecfri)", "Gaplus (Tecfri PCB)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/lviv.cpp b/src/mame/drivers/lviv.cpp index 86c89ce2c0e..7fe75206ebe 100644 --- a/src/mame/drivers/lviv.cpp +++ b/src/mame/drivers/lviv.cpp @@ -298,12 +298,12 @@ Timings: void lviv_state::io_map(address_map &map) { - map(0x00, 0xff).rw(FUNC(lviv_state::lviv_io_r), FUNC(lviv_state::lviv_io_w)); + map(0x00, 0xff).rw(FUNC(lviv_state::io_r), FUNC(lviv_state::io_w)); } /* memory w/r functions */ -void lviv_state::lviv_mem(address_map &map) +void lviv_state::mem_map(address_map &map) { map(0x0000, 0x3fff).bankrw(m_bank[0]); map(0x4000, 0x7fff).bankrw(m_bank[1]); @@ -407,7 +407,7 @@ static INPUT_PORTS_START (lviv) PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_START("RESET") /* CPU */ - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Reset") PORT_CODE(KEYCODE_PGDN) PORT_CHAR(UCHAR_MAMEKEY(PGDN)) PORT_CHANGED_MEMBER(DEVICE_SELF, lviv_state, lviv_reset, 0) + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Reset") PORT_CODE(KEYCODE_PGDN) PORT_CHAR(UCHAR_MAMEKEY(PGDN)) PORT_CHANGED_MEMBER(DEVICE_SELF, lviv_state, reset_button, 0) PORT_START("JOY") /* Joystick */ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP) PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN) @@ -424,25 +424,25 @@ INPUT_PORTS_END MACHINE_CONFIG_START(lviv_state::lviv) /* basic machine hardware */ MCFG_DEVICE_ADD(m_maincpu, I8080, 2500000) - MCFG_DEVICE_PROGRAM_MAP(lviv_mem) + MCFG_DEVICE_PROGRAM_MAP(mem_map) MCFG_DEVICE_IO_MAP(io_map) MCFG_QUANTUM_TIME(attotime::from_hz(60)) MCFG_DEVICE_ADD(m_ppi[0], I8255, 0) - MCFG_I8255_IN_PORTA_CB(READ8(*this, lviv_state, lviv_ppi_0_porta_r)) - MCFG_I8255_OUT_PORTA_CB(WRITE8(*this, lviv_state, lviv_ppi_0_porta_w)) - MCFG_I8255_IN_PORTB_CB(READ8(*this, lviv_state, lviv_ppi_0_portb_r)) - MCFG_I8255_OUT_PORTB_CB(WRITE8(*this, lviv_state, lviv_ppi_0_portb_w)) - MCFG_I8255_IN_PORTC_CB(READ8(*this, lviv_state, lviv_ppi_0_portc_r)) - MCFG_I8255_OUT_PORTC_CB(WRITE8(*this, lviv_state, lviv_ppi_0_portc_w)) + MCFG_I8255_IN_PORTA_CB(READ8(*this, lviv_state, ppi_0_porta_r)) + MCFG_I8255_OUT_PORTA_CB(WRITE8(*this, lviv_state, ppi_0_porta_w)) + MCFG_I8255_IN_PORTB_CB(READ8(*this, lviv_state, ppi_0_portb_r)) + MCFG_I8255_OUT_PORTB_CB(WRITE8(*this, lviv_state, ppi_0_portb_w)) + MCFG_I8255_IN_PORTC_CB(READ8(*this, lviv_state, ppi_0_portc_r)) + MCFG_I8255_OUT_PORTC_CB(WRITE8(*this, lviv_state, ppi_0_portc_w)) MCFG_DEVICE_ADD(m_ppi[1], I8255, 0) - MCFG_I8255_IN_PORTA_CB(READ8(*this, lviv_state, lviv_ppi_1_porta_r)) - MCFG_I8255_OUT_PORTA_CB(WRITE8(*this, lviv_state, lviv_ppi_1_porta_w)) - MCFG_I8255_IN_PORTB_CB(READ8(*this, lviv_state, lviv_ppi_1_portb_r)) - MCFG_I8255_OUT_PORTB_CB(WRITE8(*this, lviv_state, lviv_ppi_1_portb_w)) - MCFG_I8255_IN_PORTC_CB(READ8(*this, lviv_state, lviv_ppi_1_portc_r)) - MCFG_I8255_OUT_PORTC_CB(WRITE8(*this, lviv_state, lviv_ppi_1_portc_w)) + MCFG_I8255_IN_PORTA_CB(READ8(*this, lviv_state, ppi_1_porta_r)) + MCFG_I8255_OUT_PORTA_CB(WRITE8(*this, lviv_state, ppi_1_porta_w)) + MCFG_I8255_IN_PORTB_CB(READ8(*this, lviv_state, ppi_1_portb_r)) + MCFG_I8255_OUT_PORTB_CB(WRITE8(*this, lviv_state, ppi_1_portb_w)) + MCFG_I8255_IN_PORTC_CB(READ8(*this, lviv_state, ppi_1_portc_r)) + MCFG_I8255_OUT_PORTC_CB(WRITE8(*this, lviv_state, ppi_1_portc_w)) MCFG_SCREEN_ADD(m_screen, RASTER) MCFG_SCREEN_REFRESH_RATE(50) @@ -451,10 +451,10 @@ MACHINE_CONFIG_START(lviv_state::lviv) /* video hardware */ MCFG_SCREEN_SIZE(256, 256) MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 0, 256-1) - MCFG_SCREEN_UPDATE_DRIVER(lviv_state, screen_update_lviv) + MCFG_SCREEN_UPDATE_DRIVER(lviv_state, screen_update) MCFG_SCREEN_PALETTE(m_palette) - MCFG_PALETTE_ADD(m_palette, sizeof (lviv_palette) / 3) + MCFG_PALETTE_ADD(m_palette, sizeof (s_palette) / 3) MCFG_PALETTE_INIT_OWNER(lviv_state, lviv) /* sound hardware */ diff --git a/src/mame/includes/gaplus.h b/src/mame/includes/gaplus.h index c1c275a9608..db7e4541f86 100644 --- a/src/mame/includes/gaplus.h +++ b/src/mame/includes/gaplus.h @@ -13,7 +13,7 @@ struct star { }; -class gaplus_state : public driver_device +class gaplus_base_state : public driver_device { public: enum @@ -22,27 +22,24 @@ public: TIMER_NAMCOIO1_RUN }; - enum - { - GAME_GAPLUS = 0, - GAME_GAPLUSD, - GAME_GALAGA3 - }; - - gaplus_state(const machine_config &mconfig, device_type type, const char *tag) + gaplus_base_state(const machine_config &mconfig, device_type type, const char *tag, const char *namco56xx_tag, const char *namco58xx_tag) : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") , m_subcpu(*this, "sub") , m_subcpu2(*this, "sub2") + , m_namco56xx(*this, namco56xx_tag) + , m_namco58xx(*this, namco58xx_tag) , m_namco_15xx(*this, "namco") , m_samples(*this, "samples") , m_gfxdecode(*this, "gfxdecode") , m_screen(*this, "screen") , m_palette(*this, "palette") - , m_customio_3(*this,"customio_3") - , m_videoram(*this,"videoram") - , m_spriteram(*this,"spriteram") - , m_lamps(*this, "lamp%u", 0U) + , m_proms_region(*this, "proms") + , m_customio_3(*this, "customio_3") + , m_videoram(*this, "videoram") + , m_spriteram(*this, "spriteram") + , m_gfx1_region(*this, "gfx1") + , m_gfx2_region(*this, "gfx2") { } DECLARE_WRITE8_MEMBER(irq_1_ctrl_w); @@ -54,19 +51,13 @@ public: DECLARE_READ8_MEMBER(customio_3_r); DECLARE_WRITE8_MEMBER(videoram_w); DECLARE_WRITE8_MEMBER(starfield_control_w); - DECLARE_WRITE8_MEMBER(out_lamps0); - DECLARE_WRITE8_MEMBER(out_lamps1); - void init_gaplus(); - void init_gaplusd(); - void init_galaga3(); DECLARE_PALETTE_INIT(gaplus); TILEMAP_MAPPER_MEMBER(tilemap_scan); TILE_GET_INFO_MEMBER(get_tile_info); DECLARE_WRITE_LINE_MEMBER(vblank_irq); - DECLARE_WRITE_LINE_MEMBER(gapluso_vblank_irq); TIMER_CALLBACK_MEMBER(namcoio0_run); TIMER_CALLBACK_MEMBER(namcoio1_run); @@ -74,14 +65,15 @@ public: DECLARE_WRITE_LINE_MEMBER(screen_vblank); void starfield_init(); void starfield_render(bitmap_ind16 &bitmap); - void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ); + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) const; - void gapluso(machine_config &config); - void gaplusd(machine_config &config); - void gaplus(machine_config &config); + void gaplus_base(machine_config &config); void cpu1_map(address_map &map); void cpu2_map(address_map &map); void cpu3_map(address_map &map); + + virtual void driver_init() override; + protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; virtual void machine_start() override; @@ -91,18 +83,20 @@ protected: required_device m_maincpu; required_device m_subcpu; required_device m_subcpu2; + required_device m_namco56xx; + required_device m_namco58xx; required_device m_namco_15xx; required_device m_samples; required_device m_gfxdecode; required_device m_screen; required_device m_palette; - namco58xx_device *m_namco58xx; - namco56xx_device *m_namco56xx; + required_memory_region m_proms_region; required_shared_ptr m_customio_3; required_shared_ptr m_videoram; required_shared_ptr m_spriteram; - output_finder<2> m_lamps; + required_memory_region m_gfx1_region; + required_memory_region m_gfx2_region; int m_type; @@ -116,3 +110,45 @@ protected: emu_timer *m_namcoio0_run_timer; emu_timer *m_namcoio1_run_timer; }; + +class gaplusd_state : public gaplus_base_state +{ +public: + gaplusd_state(const machine_config &mconfig, device_type type, const char *tag) + : gaplus_base_state(mconfig, type, tag, "namcoio_2", "namcoio_1") + { + } + + void gaplusd(machine_config &config); +}; + +class gapluso_state : public gaplus_base_state { +public: + gapluso_state(const machine_config &mconfig, device_type type, const char *tag) + : gaplus_base_state(mconfig, type, tag, "namcoio_1", "namcoio_2") { + } + + void gapluso(machine_config &config); + +protected: + DECLARE_WRITE_LINE_MEMBER(vblank_irq); +}; + +class gaplus_state : public gaplus_base_state { +public: + gaplus_state(const machine_config &mconfig, device_type type, const char *tag) + : gaplus_base_state(mconfig, type, tag, "namcoio_1", "namcoio_2") + , m_lamps(*this, "lamp%u", 0U) + { + } + + void gaplus(machine_config &config); + +protected: + virtual void machine_start() override; + + DECLARE_WRITE8_MEMBER(out_lamps0); + DECLARE_WRITE8_MEMBER(out_lamps1); + + output_finder<2> m_lamps; +}; diff --git a/src/mame/includes/lviv.h b/src/mame/includes/lviv.h index dc98fb4570b..12df36c4c19 100644 --- a/src/mame/includes/lviv.h +++ b/src/mame/includes/lviv.h @@ -20,42 +20,59 @@ class lviv_state : public driver_device { public: lviv_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_ram(*this, RAM_TAG), - m_ppi(*this, "ppi8255_%u", 0U), - m_speaker(*this, "speaker"), - m_cassette(*this, "cassette"), - m_screen(*this, "screen"), - m_palette(*this, "palette"), - m_maincpu_region(*this, "maincpu"), - m_bank(*this, "bank%u", 1U), - m_key(*this, "KEY%u", 0U), - m_joy_port(*this, "JOY") + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_ram(*this, RAM_TAG) + , m_ppi(*this, "ppi8255_%u", 0U) + , m_speaker(*this, "speaker") + , m_cassette(*this, "cassette") + , m_screen(*this, "screen") + , m_palette(*this, "palette") + , m_maincpu_region(*this, "maincpu") + , m_bank(*this, "bank%u", 1U) + , m_key(*this, "KEY%u", 0U) + , m_joy_port(*this, "JOY") { } - unsigned char * m_video_ram; - unsigned short m_colortable[1][4]; - uint8_t m_ppi_port_outputs[2][3]; - uint8_t m_startup_mem_map; - DECLARE_READ8_MEMBER(lviv_io_r); - DECLARE_WRITE8_MEMBER(lviv_io_w); + void lviv(machine_config &config); + + DECLARE_INPUT_CHANGED_MEMBER(reset_button); + +protected: virtual void machine_reset() override; - virtual void video_start() override; + DECLARE_PALETTE_INIT(lviv); - uint32_t screen_update_lviv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - DECLARE_READ8_MEMBER(lviv_ppi_0_porta_r); - DECLARE_READ8_MEMBER(lviv_ppi_0_portb_r); - DECLARE_READ8_MEMBER(lviv_ppi_0_portc_r); - DECLARE_WRITE8_MEMBER(lviv_ppi_0_porta_w); - DECLARE_WRITE8_MEMBER(lviv_ppi_0_portb_w); - DECLARE_WRITE8_MEMBER(lviv_ppi_0_portc_w); - DECLARE_READ8_MEMBER(lviv_ppi_1_porta_r); - DECLARE_READ8_MEMBER(lviv_ppi_1_portb_r); - DECLARE_READ8_MEMBER(lviv_ppi_1_portc_r); - DECLARE_WRITE8_MEMBER(lviv_ppi_1_porta_w); - DECLARE_WRITE8_MEMBER(lviv_ppi_1_portb_w); - DECLARE_WRITE8_MEMBER(lviv_ppi_1_portc_w); + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + + DECLARE_READ8_MEMBER(io_r); + DECLARE_WRITE8_MEMBER(io_w); + + DECLARE_READ8_MEMBER(ppi_0_porta_r); + DECLARE_READ8_MEMBER(ppi_0_portb_r); + DECLARE_READ8_MEMBER(ppi_0_portc_r); + DECLARE_READ8_MEMBER(ppi_1_porta_r); + DECLARE_READ8_MEMBER(ppi_1_portb_r); + DECLARE_READ8_MEMBER(ppi_1_portc_r); + + DECLARE_WRITE8_MEMBER(ppi_0_porta_w); + DECLARE_WRITE8_MEMBER(ppi_0_portb_w); + DECLARE_WRITE8_MEMBER(ppi_0_portc_w); + DECLARE_WRITE8_MEMBER(ppi_1_porta_w); + DECLARE_WRITE8_MEMBER(ppi_1_portb_w); + DECLARE_WRITE8_MEMBER(ppi_1_portc_w); + + DECLARE_SNAPSHOT_LOAD_MEMBER(lviv); + + void update_palette(uint8_t pal); + + void update_memory(); + void setup_snapshot(uint8_t * data); + void dump_registers(); + image_verify_result verify_snapshot(uint8_t * data, uint32_t size); + + void io_map(address_map &map); + void mem_map(address_map &map); + required_device m_maincpu; required_device m_ram; required_device_array m_ppi; @@ -68,21 +85,13 @@ public: required_ioport_array<12> m_key; required_ioport m_joy_port; - void lviv_update_palette(uint8_t pal); - void lviv_update_memory (); - void lviv_setup_snapshot (uint8_t * data); - void dump_registers(); - image_verify_result lviv_verify_snapshot(uint8_t * data, uint32_t size); - DECLARE_SNAPSHOT_LOAD_MEMBER( lviv ); - DECLARE_INPUT_CHANGED_MEMBER(lviv_reset); - void lviv(machine_config &config); - void io_map(address_map &map); - void lviv_mem(address_map &map); -}; - -/*----------- defined in video/lviv.c -----------*/ - -extern const unsigned char lviv_palette[8*3]; + uint8_t* m_video_ram; + uint16_t m_colortable[1][4]; + uint8_t m_ppi_port_outputs[2][3]; + uint8_t m_startup_mem_map; + /*----------- defined in video/lviv.c -----------*/ + static const uint8_t s_palette[8*3]; +}; #endif // MAME_INCLUDES_LVIV_H diff --git a/src/mame/machine/gaplus.cpp b/src/mame/machine/gaplus.cpp index 377ea6f6233..c496e69fabd 100644 --- a/src/mame/machine/gaplus.cpp +++ b/src/mame/machine/gaplus.cpp @@ -20,7 +20,7 @@ * * ************************************************************************************/ -WRITE8_MEMBER(gaplus_state::customio_3_w) +WRITE8_MEMBER(gaplus_base_state::customio_3_w) { if ((offset == 0x09) && (data >= 0x0f)) m_samples->start(0,0); @@ -29,7 +29,7 @@ WRITE8_MEMBER(gaplus_state::customio_3_w) } -READ8_MEMBER(gaplus_state::customio_3_r) +READ8_MEMBER(gaplus_base_state::customio_3_r) { int mode = m_customio_3[8]; diff --git a/src/mame/machine/lviv.cpp b/src/mame/machine/lviv.cpp index 4c6fc34332d..afc15380bf2 100644 --- a/src/mame/machine/lviv.cpp +++ b/src/mame/machine/lviv.cpp @@ -20,7 +20,7 @@ #define LVIV_SNAPSHOT_SIZE 82219 -void lviv_state::lviv_update_memory() +void lviv_state::update_memory() { uint8_t *ram = m_ram->pointer(); @@ -36,22 +36,22 @@ void lviv_state::lviv_update_memory() } } -INPUT_CHANGED_MEMBER(lviv_state::lviv_reset) +INPUT_CHANGED_MEMBER(lviv_state::reset_button) { machine().schedule_soft_reset(); } -READ8_MEMBER(lviv_state::lviv_ppi_0_porta_r) +READ8_MEMBER(lviv_state::ppi_0_porta_r) { return 0xff; } -READ8_MEMBER(lviv_state::lviv_ppi_0_portb_r) +READ8_MEMBER(lviv_state::ppi_0_portb_r) { return 0xff; } -READ8_MEMBER(lviv_state::lviv_ppi_0_portc_r) +READ8_MEMBER(lviv_state::ppi_0_portc_r) { uint8_t data = m_ppi_port_outputs[0][2] & 0x0f; if (m_cassette->input() > 0.038) @@ -61,32 +61,32 @@ READ8_MEMBER(lviv_state::lviv_ppi_0_portc_r) return data; } -WRITE8_MEMBER(lviv_state::lviv_ppi_0_porta_w) +WRITE8_MEMBER(lviv_state::ppi_0_porta_w) { m_ppi_port_outputs[0][0] = data; } -WRITE8_MEMBER(lviv_state::lviv_ppi_0_portb_w) +WRITE8_MEMBER(lviv_state::ppi_0_portb_w) { m_ppi_port_outputs[0][1] = data; - lviv_update_palette(data&0x7f); + update_palette(data&0x7f); } -WRITE8_MEMBER(lviv_state::lviv_ppi_0_portc_w)/* tape in/out, video memory on/off */ +WRITE8_MEMBER(lviv_state::ppi_0_portc_w)/* tape in/out, video memory on/off */ { m_ppi_port_outputs[0][2] = data; if (m_ppi_port_outputs[0][1]&0x80) m_speaker->level_w(data & 0x01); m_cassette->output((data & 0x01) ? -1.0 : 1.0); - lviv_update_memory(); + update_memory(); } -READ8_MEMBER(lviv_state::lviv_ppi_1_porta_r) +READ8_MEMBER(lviv_state::ppi_1_porta_r) { return 0xff; } -READ8_MEMBER(lviv_state::lviv_ppi_1_portb_r)/* keyboard reading */ +READ8_MEMBER(lviv_state::ppi_1_portb_r)/* keyboard reading */ { return ((m_ppi_port_outputs[1][0] & 0x01) ? 0xff : m_key[0]->read()) & ((m_ppi_port_outputs[1][0] & 0x02) ? 0xff : m_key[1]->read()) & @@ -98,7 +98,7 @@ READ8_MEMBER(lviv_state::lviv_ppi_1_portb_r)/* keyboard reading */ ((m_ppi_port_outputs[1][0] & 0x80) ? 0xff : m_key[7]->read()); } -READ8_MEMBER(lviv_state::lviv_ppi_1_portc_r)/* keyboard reading */ +READ8_MEMBER(lviv_state::ppi_1_portc_r)/* keyboard reading */ { return ((m_ppi_port_outputs[1][2] & 0x01) ? 0xff : m_key[ 8]->read()) & ((m_ppi_port_outputs[1][2] & 0x02) ? 0xff : m_key[ 9]->read()) & @@ -106,24 +106,24 @@ READ8_MEMBER(lviv_state::lviv_ppi_1_portc_r)/* keyboard reading */ ((m_ppi_port_outputs[1][2] & 0x08) ? 0xff : m_key[11]->read()); } -WRITE8_MEMBER(lviv_state::lviv_ppi_1_porta_w)/* kayboard scaning */ +WRITE8_MEMBER(lviv_state::ppi_1_porta_w)/* kayboard scaning */ { m_ppi_port_outputs[1][0] = data; } -WRITE8_MEMBER(lviv_state::lviv_ppi_1_portb_w) +WRITE8_MEMBER(lviv_state::ppi_1_portb_w) { m_ppi_port_outputs[1][1] = data; } -WRITE8_MEMBER(lviv_state::lviv_ppi_1_portc_w)/* kayboard scaning */ +WRITE8_MEMBER(lviv_state::ppi_1_portc_w)/* kayboard scaning */ { m_ppi_port_outputs[1][2] = data; } /* I/O */ -READ8_MEMBER(lviv_state::lviv_io_r) +READ8_MEMBER(lviv_state::io_r) { if (m_startup_mem_map) { @@ -147,7 +147,7 @@ READ8_MEMBER(lviv_state::lviv_io_r) } } -WRITE8_MEMBER(lviv_state::lviv_io_w) +WRITE8_MEMBER(lviv_state::io_w) { address_space &cpuspace = m_maincpu->space(AS_PROGRAM); if (m_startup_mem_map) @@ -223,13 +223,11 @@ Lviv snapshot files (SAV) 1411D - 1412A: ??? (something additional) *******************************************************************************/ -void lviv_state::lviv_setup_snapshot(uint8_t * data) +void lviv_state::setup_snapshot(uint8_t * data) { - unsigned char lo,hi; - /* Set registers */ - lo = data[0x14112] & 0x0ff; - hi = data[0x14111] & 0x0ff; + uint8_t lo = data[0x14112] & 0x0ff; + uint8_t hi = data[0x14111] & 0x0ff; m_maincpu->set_state_int(i8080_cpu_device::I8085_BC, (hi << 8) | lo); lo = data[0x14114] & 0x0ff; hi = data[0x14113] & 0x0ff; @@ -254,9 +252,9 @@ void lviv_state::lviv_setup_snapshot(uint8_t * data) /* Ports */ m_ppi_port_outputs[0][0] = data[0x14011+0xc0]; m_ppi_port_outputs[0][1] = data[0x14011+0xc1]; - lviv_update_palette(m_ppi_port_outputs[0][1]&0x7f); + update_palette(m_ppi_port_outputs[0][1]&0x7f); m_ppi_port_outputs[0][2] = data[0x14011+0xc2]; - lviv_update_memory(); + update_memory(); } void lviv_state::dump_registers() @@ -269,7 +267,7 @@ void lviv_state::dump_registers() logerror("HL = %04x\n", (unsigned) m_maincpu->state_int(i8080_cpu_device::I8085_HL)); } -image_verify_result lviv_state::lviv_verify_snapshot(uint8_t * data, uint32_t size) +image_verify_result lviv_state::verify_snapshot(uint8_t * data, uint32_t size) { const char* tag = "LVOV/DUMP/2.0/"; @@ -289,18 +287,18 @@ image_verify_result lviv_state::lviv_verify_snapshot(uint8_t * data, uint32_t si return image_verify_result::PASS; } -SNAPSHOT_LOAD_MEMBER( lviv_state, lviv ) +SNAPSHOT_LOAD_MEMBER(lviv_state, lviv) { - std::vector lviv_snapshot_data(LVIV_SNAPSHOT_SIZE); + std::vector snapshot_data(LVIV_SNAPSHOT_SIZE); - image.fread( &lviv_snapshot_data[0], LVIV_SNAPSHOT_SIZE); + image.fread(&snapshot_data[0], LVIV_SNAPSHOT_SIZE); - if (lviv_verify_snapshot(&lviv_snapshot_data[0], snapshot_size) != image_verify_result::PASS) + if (verify_snapshot(&snapshot_data[0], snapshot_size) != image_verify_result::PASS) { return image_init_result::FAIL; } - lviv_setup_snapshot (&lviv_snapshot_data[0]); + setup_snapshot(&snapshot_data[0]); dump_registers(); diff --git a/src/mame/video/gaplus.cpp b/src/mame/video/gaplus.cpp index a7a492bc588..3ef083b6f79 100644 --- a/src/mame/video/gaplus.cpp +++ b/src/mame/video/gaplus.cpp @@ -25,46 +25,43 @@ ***************************************************************************/ -PALETTE_INIT_MEMBER(gaplus_state, gaplus) +PALETTE_INIT_MEMBER(gaplus_base_state, gaplus) { - const uint8_t *color_prom = memregion("proms")->base(); - int i; - - for (i = 0;i < 256;i++) + const uint8_t *color_prom = m_proms_region->base(); + for (int i = 0; i < 256; i++) { - int bit0,bit1,bit2,bit3,r,g,b; - /* red component */ - bit0 = (color_prom[i] >> 0) & 0x01; - bit1 = (color_prom[i] >> 1) & 0x01; - bit2 = (color_prom[i] >> 2) & 0x01; - bit3 = (color_prom[i] >> 3) & 0x01; - r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; - /* green component */ - bit0 = (color_prom[i + 0x100] >> 0) & 0x01; - bit1 = (color_prom[i + 0x100] >> 1) & 0x01; - bit2 = (color_prom[i + 0x100] >> 2) & 0x01; - bit3 = (color_prom[i + 0x100] >> 3) & 0x01; - g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; + int bit0 = BIT(color_prom[i], 0); + int bit1 = BIT(color_prom[i], 1); + int bit2 = BIT(color_prom[i], 2); + int bit3 = BIT(color_prom[i], 3); + int r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; + + /* green component */ + bit0 = BIT(color_prom[i + 0x100], 0); + bit1 = BIT(color_prom[i + 0x100], 1); + bit2 = BIT(color_prom[i + 0x100], 2); + bit3 = BIT(color_prom[i + 0x100], 3); + int g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; /* blue component */ - bit0 = (color_prom[i + 0x200] >> 0) & 0x01; - bit1 = (color_prom[i + 0x200] >> 1) & 0x01; - bit2 = (color_prom[i + 0x200] >> 2) & 0x01; - bit3 = (color_prom[i + 0x200] >> 3) & 0x01; - b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; + bit0 = BIT(color_prom[i + 0x200], 0); + bit1 = BIT(color_prom[i + 0x200], 1); + bit2 = BIT(color_prom[i + 0x200], 2); + bit3 = BIT(color_prom[i + 0x200], 3); + int b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; - palette.set_indirect_color(i,rgb_t(r,g,b)); + palette.set_indirect_color(i, rgb_t(r, g, b)); } color_prom += 0x300; /* color_prom now points to the beginning of the lookup table */ /* characters use colors 0xf0-0xff */ - for (i = 0;i < m_gfxdecode->gfx(0)->colors() * m_gfxdecode->gfx(0)->granularity();i++) + for (int i = 0; i < m_gfxdecode->gfx(0)->colors() * m_gfxdecode->gfx(0)->granularity(); i++) palette.set_pen_indirect(m_gfxdecode->gfx(0)->colorbase() + i, 0xf0 + (*color_prom++ & 0x0f)); /* sprites */ - for (i = 0;i < m_gfxdecode->gfx(1)->colors() * m_gfxdecode->gfx(1)->granularity();i++) + for (int i = 0; i < m_gfxdecode->gfx(1)->colors() * m_gfxdecode->gfx(1)->granularity(); i++) { palette.set_pen_indirect(m_gfxdecode->gfx(1)->colorbase() + i, (color_prom[0] & 0x0f) + ((color_prom[0x200] & 0x0f) << 4)); color_prom++; @@ -80,23 +77,18 @@ PALETTE_INIT_MEMBER(gaplus_state, gaplus) ***************************************************************************/ /* convert from 32x32 to 36x28 */ -TILEMAP_MAPPER_MEMBER(gaplus_state::tilemap_scan) +TILEMAP_MAPPER_MEMBER(gaplus_base_state::tilemap_scan) { - int offs; - row += 2; col -= 2; if (col & 0x20) - offs = row + ((col & 0x1f) << 5); - else - offs = col + (row << 5); - - return offs; + return row + ((col & 0x1f) << 5); + return col + (row << 5); } -TILE_GET_INFO_MEMBER(gaplus_state::get_tile_info) +TILE_GET_INFO_MEMBER(gaplus_base_state::get_tile_info) { - uint8_t attr = m_videoram[tile_index + 0x400]; + const uint8_t attr = m_videoram[tile_index + 0x400]; tileinfo.category = (attr & 0x40) >> 6; tileinfo.group = attr & 0x3f; SET_TILE_INFO_MEMBER(0, @@ -123,42 +115,40 @@ TILE_GET_INFO_MEMBER(gaplus_state::get_tile_info) #define SPEED_2 1.0f #define SPEED_3 2.0f -void gaplus_state::starfield_init() +void gaplus_base_state::starfield_init() { - struct star *stars = m_stars; int generator = 0; - int x,y; int set = 0; - int width = m_screen->width(); - int height = m_screen->height(); + const int width = m_screen->width(); + const int height = m_screen->height(); m_total_stars = 0; /* precalculate the star background */ /* this comes from the Galaxian hardware, Gaplus is probably different */ - for ( y = 0;y < height; y++ ) { - for ( x = width*2 - 1; x >= 0; x--) { - int bit1,bit2; - + for (int y = 0; y < height; y++) + { + for (int x = width * 2 - 1; x >= 0; x--) + { generator <<= 1; - bit1 = (~generator >> 17) & 1; - bit2 = (generator >> 5) & 1; + const int bit1 = (~generator >> 17) & 1; + const int bit2 = (generator >> 5) & 1; if (bit1 ^ bit2) generator |= 1; - if ( ((~generator >> 16) & 1) && (generator & 0xff) == 0xff) { - int color; - - color = (~(generator >> 8)) & 0x3f; - if ( color && m_total_stars < MAX_STARS ) { - stars[m_total_stars].x = x; - stars[m_total_stars].y = y; - stars[m_total_stars].col = color; - stars[m_total_stars].set = set++; - - if ( set == 3 ) + if (BIT(~generator, 16) && (generator & 0xff) == 0xff) + { + const int color = ~(generator >> 8) & 0x3f; + if (color && m_total_stars < MAX_STARS) + { + m_stars[m_total_stars].x = x; + m_stars[m_total_stars].y = y; + m_stars[m_total_stars].col = color; + m_stars[m_total_stars].set = set++; + + if (set == 3) set = 0; m_total_stars++; @@ -176,7 +166,7 @@ void gaplus_state::starfield_init() ***************************************************************************/ -void gaplus_state::video_start() +void gaplus_base_state::video_start() { m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(gaplus_state::get_tile_info),this),tilemap_mapper_delegate(FUNC(gaplus_state::tilemap_scan),this),8,8,36,28); @@ -202,16 +192,15 @@ void gaplus_state::video_start() ***************************************************************************/ -WRITE8_MEMBER(gaplus_state::videoram_w) +WRITE8_MEMBER(gaplus_base_state::videoram_w) { m_videoram[offset] = data; m_bg_tilemap->mark_tile_dirty(offset & 0x3ff); } -WRITE8_MEMBER(gaplus_state::starfield_control_w) +WRITE8_MEMBER(gaplus_base_state::starfield_control_w) { - offset &= 3; - m_starfield_control[offset] = data; + m_starfield_control[offset & 3] = data; } @@ -222,41 +211,35 @@ WRITE8_MEMBER(gaplus_state::starfield_control_w) ***************************************************************************/ -void gaplus_state::starfield_render(bitmap_ind16 &bitmap) +void gaplus_base_state::starfield_render(bitmap_ind16 &bitmap) { - struct star *stars = m_stars; - int i; - - int width = m_screen->width(); - int height = m_screen->height(); - /* check if we're running */ - if ( ( m_starfield_control[0] & 1 ) == 0 ) + if ((m_starfield_control[0] & 1) == 0) return; - /* draw the starfields */ - for ( i = 0; i < m_total_stars; i++ ) - { - int x, y; + const int width = m_screen->width(); + const int height = m_screen->height(); - x = stars[i].x; - y = stars[i].y; + /* draw the starfields */ + for (int i = 0; i < m_total_stars; i++) + { + int x = m_stars[i].x; + int y = m_stars[i].y; - if ( x >=0 && x < width && y >= 0 && y < height ) + if (x >= 0 && x < width && y >= 0 && y < height) { - bitmap.pix16(y, x) = stars[i].col; + bitmap.pix16(y, x) = m_stars[i].col; } } } -void gaplus_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) +void gaplus_base_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) const { uint8_t *spriteram = m_spriteram + 0x780; uint8_t *spriteram_2 = spriteram + 0x800; uint8_t *spriteram_3 = spriteram_2 + 0x800; - int offs; - for (offs = 0;offs < 0x80;offs += 2) + for (int offs = 0;offs < 0x80;offs += 2) { /* is it on? */ if ((spriteram_3[offs+1] & 2) == 0) @@ -266,16 +249,15 @@ void gaplus_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect { 0, 1 }, { 2, 3 } }; - int sprite = spriteram[offs] | ((spriteram_3[offs] & 0x40) << 2); - int color = spriteram[offs+1] & 0x3f; - int sx = spriteram_2[offs+1] + 0x100 * (spriteram_3[offs+1] & 1) - 71; + const int sprite = spriteram[offs] | ((spriteram_3[offs] & 0x40) << 2); + const int color = spriteram[offs+1] & 0x3f; + const int sx = spriteram_2[offs+1] + 0x100 * (spriteram_3[offs+1] & 1) - 71; int sy = 256 - spriteram_2[offs] - 8; - int flipx = (spriteram_3[offs] & 0x01); - int flipy = (spriteram_3[offs] & 0x02) >> 1; - int sizex = (spriteram_3[offs] & 0x08) >> 3; - int sizey = (spriteram_3[offs] & 0x20) >> 5; - int duplicate = spriteram_3[offs] & 0x80; - int x,y; + int flipx = BIT(spriteram_3[offs], 0); + int flipy = BIT(spriteram_3[offs], 1); + const int sizex = BIT(spriteram_3[offs], 3); + const int sizey = BIT(spriteram_3[offs], 5); + const int duplicate = spriteram_3[offs] & 0x80; if (flip_screen()) { @@ -286,15 +268,15 @@ void gaplus_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect sy -= 16 * sizey; sy = (sy & 0xff) - 32; // fix wraparound - for (y = 0;y <= sizey;y++) + for (int y = 0;y <= sizey; y++) { - for (x = 0;x <= sizex;x++) + for (int x = 0; x <= sizex; x++) { - m_gfxdecode->gfx(1)->transmask(bitmap,cliprect, + m_gfxdecode->gfx(1)->transmask(bitmap, cliprect, sprite + (duplicate ? 0 : (gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)])), color, flipx,flipy, - sx + 16*x,sy + 16*y, + sx + 16 * x, sy + 16 * y, m_palette->transpen_mask(*m_gfxdecode->gfx(1), color, 0xff)); } } @@ -302,28 +284,28 @@ void gaplus_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect } } -uint32_t gaplus_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +uint32_t gaplus_base_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { /* flip screen control is embedded in RAM */ - flip_screen_set(m_spriteram[0x1f7f-0x800] & 1); + flip_screen_set(m_spriteram[0x1f7f - 0x800] & 1); bitmap.fill(0, cliprect); starfield_render(bitmap); /* draw the low priority characters */ - m_bg_tilemap->draw(screen, bitmap, cliprect, 0,0); + m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); draw_sprites(bitmap, cliprect); /* draw the high priority characters */ /* (I don't know if this feature is used by Gaplus, but it's shown in the schematics) */ - m_bg_tilemap->draw(screen, bitmap, cliprect, 1,0); + m_bg_tilemap->draw(screen, bitmap, cliprect, 1, 0); return 0; } -WRITE_LINE_MEMBER(gaplus_state::screen_vblank)/* update starfields */ +WRITE_LINE_MEMBER(gaplus_base_state::screen_vblank)/* update starfields */ { // falling edge if (!state) diff --git a/src/mame/video/lviv.cpp b/src/mame/video/lviv.cpp index db8577c316d..4fa8e63bf05 100644 --- a/src/mame/video/lviv.cpp +++ b/src/mame/video/lviv.cpp @@ -13,7 +13,7 @@ #include "emu.h" #include "includes/lviv.h" -const unsigned char lviv_palette[8*3] = +const uint8_t lviv_state::s_palette[8*3] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, @@ -28,54 +28,46 @@ const unsigned char lviv_palette[8*3] = PALETTE_INIT_MEMBER(lviv_state, lviv) { - int i; - - for ( i = 0; i < sizeof(lviv_palette) / 3; i++ ) { - m_palette->set_pen_color(i, lviv_palette[i*3], lviv_palette[i*3+1], lviv_palette[i*3+2]); + for (int i = 0; i < sizeof(s_palette) / 3; i++) + { + m_palette->set_pen_color(i, s_palette[i*3], s_palette[i*3+1], s_palette[i*3+2]); } } -void lviv_state::lviv_update_palette(uint8_t pal) +void lviv_state::update_palette(uint8_t pal) { m_colortable[0][0] = 0; m_colortable[0][1] = 0; m_colortable[0][2] = 0; m_colortable[0][3] = 0; - m_colortable[0][0] |= (((pal>>3)&0x01) == ((pal>>4)&0x01)) ? 0x04 : 0x00; - m_colortable[0][0] |= ((pal>>5)&0x01) ? 0x02 : 0x00; - m_colortable[0][0] |= (((pal>>2)&0x01) == ((pal>>6)&0x01)) ? 0x01 : 0x00; - - m_colortable[0][1] |= ((pal&0x01) == ((pal>>4)&0x01)) ? 0x04 : 0x00; - m_colortable[0][1] |= ((pal>>5)&0x01) ? 0x02 : 0x00; - m_colortable[0][1] |= ((pal>>6)&0x01) ? 0x00 : 0x01; + m_colortable[0][0] |= (BIT(pal, 3) == BIT(pal, 4)) ? 0x04 : 0x00; + m_colortable[0][0] |= BIT(pal, 5) ? 0x02 : 0x00; + m_colortable[0][0] |= (BIT(pal, 2) == BIT(pal, 6)) ? 0x01 : 0x00; - m_colortable[0][2] |= ((pal>>4)&0x01) ? 0x04 : 0x00; - m_colortable[0][2] |= ((pal>>5)&0x01) ? 0x00 : 0x02; - m_colortable[0][2] |= ((pal>>6)&0x01) ? 0x01 : 0x00; + m_colortable[0][1] |= (BIT(pal, 0) == BIT(pal, 4)) ? 0x04 : 0x00; + m_colortable[0][1] |= BIT(pal, 5) ? 0x02 : 0x00; + m_colortable[0][1] |= BIT(pal, 6) ? 0x00 : 0x01; - m_colortable[0][3] |= ((pal>>4)&0x01) ? 0x00 : 0x04; - m_colortable[0][3] |= (((pal>>1)&0x01) == ((pal>>5)&0x01)) ? 0x02 : 0x00; - m_colortable[0][3] |= ((pal>>6)&0x01) ? 0x01 : 0x00; -} + m_colortable[0][2] |= BIT(pal, 4) ? 0x04 : 0x00; + m_colortable[0][2] |= BIT(pal, 5) ? 0x00 : 0x02; + m_colortable[0][2] |= BIT(pal, 6) ? 0x01 : 0x00; -void lviv_state::video_start() -{ + m_colortable[0][3] |= BIT(pal, 4) ? 0x00 : 0x04; + m_colortable[0][3] |= (BIT(pal, 1) == BIT(pal, 5)) ? 0x02 : 0x00; + m_colortable[0][3] |= BIT(pal, 6) ? 0x01 : 0x00; } -uint32_t lviv_state::screen_update_lviv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +uint32_t lviv_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - int x,y; - int pen; - uint8_t data; - - for (y=0; y<256; y++) - for (x=0; x<256; x+=4) + for (int y = 0; y < 256; y++) + { + for (int x = 0; x < 256; x += 4) { - data = m_video_ram[y*64+x/4]; + const uint8_t data = m_video_ram[(y << 6) | (x >> 2)]; - pen = m_colortable[0][((data & 0x08) >> 3) | ((data & 0x80) >> (3+3))]; + int pen = m_colortable[0][((data & 0x08) >> 3) | ((data & 0x80) >> (3+3))]; bitmap.pix16(y, x + 0) = pen; pen = m_colortable[0][((data & 0x04) >> 2) | ((data & 0x40) >> (2+3))]; @@ -87,5 +79,6 @@ uint32_t lviv_state::screen_update_lviv(screen_device &screen, bitmap_ind16 &bit pen = m_colortable[0][((data & 0x01) >> 0) | ((data & 0x10) >> (0+3))]; bitmap.pix16(y, x + 3) = pen; } + } return 0; } -- cgit v1.2.3