diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2018-06-06 13:19:53 -0400 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2018-06-06 13:21:14 -0400 |
commit | 3c02d6cd45f4b6091b1a1f5b591aa34ccbacddee (patch) | |
tree | c574ef4c49197dfd2963208894ca999a508a667d | |
parent | b00b31b2d003da6cfd53060cfea278b731132ef8 (diff) |
atetrisb3: Hook up MCU to get working sound
atetris.cpp: Replace NVRAM with parallel EEPROM (nw)
-rw-r--r-- | src/mame/drivers/atetris.cpp | 180 | ||||
-rw-r--r-- | src/mame/includes/atetris.h | 36 |
2 files changed, 125 insertions, 91 deletions
diff --git a/src/mame/drivers/atetris.cpp b/src/mame/drivers/atetris.cpp index a9de1971421..1c048dcd6e3 100644 --- a/src/mame/drivers/atetris.cpp +++ b/src/mame/drivers/atetris.cpp @@ -53,9 +53,8 @@ #include "emu.h" #include "cpu/m6502/m6502.h" #include "includes/atetris.h" -#include "sound/sn76496.h" #include "sound/pokey.h" -#include "machine/nvram.h" +#include "machine/eeprompar.h" #include "machine/watchdog.h" #include "speaker.h" @@ -111,7 +110,6 @@ void atetris_state::machine_start() /* Set up save state */ save_item(NAME(m_current_bank)); - save_item(NAME(m_nvram_write_enable)); machine().save().register_postload(save_prepost_delegate(FUNC(atetris_state::reset_bank), this)); } @@ -167,27 +165,6 @@ WRITE8_MEMBER(atetris_state::coincount_w) /************************************* * - * NVRAM handlers - * - *************************************/ - -WRITE8_MEMBER(atetris_state::nvram_w) -{ - if (m_nvram_write_enable) - m_nvram[offset] = data; - m_nvram_write_enable = 0; -} - - -WRITE8_MEMBER(atetris_state::nvram_enable_w) -{ - m_nvram_write_enable = 1; -} - - - -/************************************* - * * Main CPU memory handlers * *************************************/ @@ -198,11 +175,11 @@ void atetris_state::main_map(address_map &map) map(0x0000, 0x0fff).ram(); map(0x1000, 0x1fff).ram().w(this, FUNC(atetris_state::videoram_w)).share("videoram"); map(0x2000, 0x20ff).mirror(0x0300).ram().w("palette", FUNC(palette_device::write8)).share("palette"); - map(0x2400, 0x25ff).mirror(0x0200).ram().w(this, FUNC(atetris_state::nvram_w)).share("nvram"); + map(0x2400, 0x25ff).rw("eeprom", FUNC(eeprom_parallel_28xx_device::read), FUNC(eeprom_parallel_28xx_device::write)); map(0x2800, 0x280f).mirror(0x03e0).rw("pokey1", FUNC(pokey_device::read), FUNC(pokey_device::write)); map(0x2810, 0x281f).mirror(0x03e0).rw("pokey2", FUNC(pokey_device::read), FUNC(pokey_device::write)); map(0x3000, 0x3000).mirror(0x03ff).w("watchdog", FUNC(watchdog_timer_device::reset_w)); - map(0x3400, 0x3400).mirror(0x03ff).w(this, FUNC(atetris_state::nvram_enable_w)); + map(0x3400, 0x3400).mirror(0x03ff).w("eeprom", FUNC(eeprom_parallel_28xx_device::unlock_write8)); map(0x3800, 0x3800).mirror(0x03ff).w(this, FUNC(atetris_state::irq_ack_w)); map(0x3c00, 0x3c00).mirror(0x03ff).w(this, FUNC(atetris_state::coincount_w)); map(0x4000, 0x5fff).rom(); @@ -216,14 +193,16 @@ void atetris_state::atetrisb2_map(address_map &map) map(0x0000, 0x0fff).ram(); map(0x1000, 0x1fff).ram().w(this, FUNC(atetris_state::videoram_w)).share("videoram"); map(0x2000, 0x20ff).ram().w("palette", FUNC(palette_device::write8)).share("palette"); - map(0x2400, 0x25ff).ram().w(this, FUNC(atetris_state::nvram_w)).share("nvram"); + map(0x2400, 0x25ff).rw("eeprom", FUNC(eeprom_parallel_28xx_device::read), FUNC(eeprom_parallel_28xx_device::write)); map(0x2802, 0x2802).w("sn1", FUNC(sn76496_device::write)); map(0x2804, 0x2804).w("sn2", FUNC(sn76496_device::write)); map(0x2806, 0x2806).w("sn3", FUNC(sn76496_device::write)); map(0x2808, 0x2808).portr("IN0"); + map(0x2808, 0x280f).nopw(); map(0x2818, 0x2818).portr("IN1"); + map(0x2818, 0x281f).nopw(); map(0x3000, 0x3000).w("watchdog", FUNC(watchdog_timer_device::reset_w)); - map(0x3400, 0x3400).w(this, FUNC(atetris_state::nvram_enable_w)); + map(0x3400, 0x3400).w("eeprom", FUNC(eeprom_parallel_28xx_device::unlock_write8)); map(0x3800, 0x3800).w(this, FUNC(atetris_state::irq_ack_w)); map(0x3c00, 0x3c00).w(this, FUNC(atetris_state::coincount_w)); map(0x4000, 0x5fff).rom(); @@ -232,27 +211,59 @@ void atetris_state::atetrisb2_map(address_map &map) } -void atetris_state::atetrisb3_map(address_map &map) +void atetris_mcu_state::atetrisb3_map(address_map &map) { map(0x0000, 0x0fff).ram(); - map(0x1000, 0x1fff).ram().w(this, FUNC(atetris_state::videoram_w)).share("videoram"); + map(0x1000, 0x1fff).ram().w(this, FUNC(atetris_mcu_state::videoram_w)).share("videoram"); map(0x2000, 0x20ff).ram().w("palette", FUNC(palette_device::write8)).share("palette"); - map(0x2400, 0x25ff).ram().w(this, FUNC(atetris_state::nvram_w)).share("nvram"); - //AM_RANGE(0x2802, 0x2802) AM_DEVWRITE("sn1", sn76489_device, write) - //AM_RANGE(0x2804, 0x2804) AM_DEVWRITE("sn2", sn76489_device, write) - //AM_RANGE(0x2806, 0x2806) AM_DEVWRITE("sn3", sn76489_device, write) + map(0x2400, 0x27ff).rw("eeprom", FUNC(eeprom_parallel_28xx_device::read), FUNC(eeprom_parallel_28xx_device::write)); + map(0x2800, 0x281f).nopr().w(this, FUNC(atetris_mcu_state::mcu_reg_w)); map(0x2808, 0x2808).portr("IN0"); map(0x2818, 0x2818).portr("IN1"); map(0x3000, 0x3000).w("watchdog", FUNC(watchdog_timer_device::reset_w)); - map(0x3400, 0x3400).w(this, FUNC(atetris_state::nvram_enable_w)); - map(0x3800, 0x3800).w(this, FUNC(atetris_state::irq_ack_w)); - map(0x3c00, 0x3c00).w(this, FUNC(atetris_state::coincount_w)); + map(0x3400, 0x3400).w("eeprom", FUNC(eeprom_parallel_28xx_device::unlock_write8)); + map(0x3800, 0x3800).w(this, FUNC(atetris_mcu_state::irq_ack_w)); + map(0x3c00, 0x3c00).w(this, FUNC(atetris_mcu_state::coincount_w)); map(0x4000, 0x5fff).rom(); - map(0x6000, 0x7fff).r(this, FUNC(atetris_state::slapstic_r)); + map(0x6000, 0x7fff).r(this, FUNC(atetris_mcu_state::slapstic_r)); map(0x8000, 0xffff).rom(); } +/************************************* + * + * Bootleg MCU handlers + * + *************************************/ + +READ8_MEMBER(atetris_mcu_state::mcu_bus_r) +{ + switch (m_mcu->p2_r(space, 0) & 0xf0) + { + case 0x40: + return m_soundlatch[1]->read(space, 0); + + case 0xf0: + return m_soundlatch[0]->read(space, 0); + + default: + return 0xff; + } +} + +WRITE8_MEMBER(atetris_mcu_state::mcu_p2_w) +{ + if ((data & 0xc0) == 0x80) + m_sn[(data >> 4) & 3]->write(space, 0, m_mcu->p1_r(space, 0)); +} + +WRITE8_MEMBER(atetris_mcu_state::mcu_reg_w) +{ + // FIXME: a lot of sound writes seem to get lost this way; why doesn't that hurt? + m_soundlatch[0]->write(space, 0, offset | 0x20); + m_soundlatch[1]->write(space, 0, data); +} + /************************************* * @@ -337,7 +348,8 @@ MACHINE_CONFIG_START(atetris_state::atetris) MCFG_SLAPSTIC_ADD("slapstic", 101) - MCFG_NVRAM_ADD_1FILL("nvram") + MCFG_DEVICE_ADD("eeprom", EEPROM_PARALLEL_2804, 0) + MCFG_EEPROM_28XX_LOCK_AFTER_WRITE(true) MCFG_WATCHDOG_ADD("watchdog") @@ -369,60 +381,60 @@ MACHINE_CONFIG_END MACHINE_CONFIG_START(atetris_state::atetrisb2) + atetris(config); /* basic machine hardware */ - MCFG_DEVICE_ADD("maincpu", M6502,BOOTLEG_CLOCK/8) + MCFG_DEVICE_MODIFY("maincpu") + MCFG_DEVICE_CLOCK(BOOTLEG_CLOCK/8) MCFG_DEVICE_PROGRAM_MAP(atetrisb2_map) - MCFG_SLAPSTIC_ADD("slapstic", 101) - - MCFG_NVRAM_ADD_1FILL("nvram") - - MCFG_WATCHDOG_ADD("watchdog") - - /* video hardware */ - MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_atetris) - - MCFG_PALETTE_ADD("palette", 256) - MCFG_PALETTE_FORMAT(RRRGGGBB) - - MCFG_SCREEN_ADD("screen", RASTER) - /* note: these parameters are from published specs, not derived */ - /* the board uses an SOS-2 chip to generate video signals */ - MCFG_SCREEN_RAW_PARAMS(MASTER_CLOCK/2, 456, 0, 336, 262, 0, 240) - MCFG_SCREEN_UPDATE_DRIVER(atetris_state, screen_update) - MCFG_SCREEN_PALETTE("palette") - - - /* sound hardware */ - SPEAKER(config, "mono").front_center(); + MCFG_DEVICE_REMOVE("pokey1") + MCFG_DEVICE_REMOVE("pokey2") - MCFG_DEVICE_ADD("sn1", SN76496, BOOTLEG_CLOCK/8) + MCFG_DEVICE_ADD("sn1", SN76489A, BOOTLEG_CLOCK/8) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_DEVICE_ADD("sn2", SN76496, BOOTLEG_CLOCK/8) + MCFG_DEVICE_ADD("sn2", SN76489A, BOOTLEG_CLOCK/8) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_DEVICE_ADD("sn3", SN76496, BOOTLEG_CLOCK/8) + MCFG_DEVICE_ADD("sn3", SN76489, BOOTLEG_CLOCK/8) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END -MACHINE_CONFIG_START(atetris_state::atetrisb3) - atetrisb2(config); +MACHINE_CONFIG_START(atetris_mcu_state::atetrisb3) + atetris(config); - MCFG_DEVICE_REPLACE("maincpu", M6502, MASTER_CLOCK/8) + MCFG_DEVICE_MODIFY("maincpu") MCFG_DEVICE_PROGRAM_MAP(atetrisb3_map) - //8749 at 10 MHz instead of slapstic + MCFG_DEVICE_REPLACE("eeprom", EEPROM_PARALLEL_2816, 0) + MCFG_EEPROM_28XX_LOCK_AFTER_WRITE(true) + + MCFG_DEVICE_REMOVE("pokey1") + MCFG_DEVICE_REMOVE("pokey2") + + MCFG_DEVICE_ADD("mcu", I8749, 10_MHz_XTAL) + MCFG_MCS48_PORT_BUS_IN_CB(READ8(*this, atetris_mcu_state, mcu_bus_r)) + MCFG_MCS48_PORT_BUS_OUT_CB(WRITE8("soundlatch1", generic_latch_8_device, acknowledge_w)) + MCFG_MCS48_PORT_P2_OUT_CB(WRITE8(*this, atetris_mcu_state, mcu_p2_w)) + + MCFG_GENERIC_LATCH_8_ADD("soundlatch1") + MCFG_GENERIC_LATCH_DATA_PENDING_CB(INPUTLINE("mcu", MCS48_INPUT_IRQ)) + MCFG_GENERIC_LATCH_SEPARATE_ACKNOWLEDGE(true) - MCFG_DEVICE_REPLACE("sn1", SN76489, 4000000) + MCFG_GENERIC_LATCH_8_ADD("soundlatch2") + + MCFG_DEVICE_ADD("sn1", SN76489A, 4000000) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) + + MCFG_DEVICE_ADD("sn2", SN76489A, 4000000) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_DEVICE_REPLACE("sn2", SN76489, 4000000) + MCFG_DEVICE_ADD("sn3", SN76489A, 4000000) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_DEVICE_REPLACE("sn3", SN76489, 4000000) + MCFG_DEVICE_ADD("sn4", SN76489A, 4000000) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -507,7 +519,7 @@ RC-1108 |M 62256 | |A | | 27512 | -| PAL | +| 28C16 PAL | | PAL PAL | |76489 76489 4MHz 82S123 | |76489 6502 | @@ -515,6 +527,7 @@ RC-1108 |---------------------------------------------------| A second PCB has been found with identical code, but with 1x additional SN76489AN, 1x additional DIP switch, a few more TTLs, and 6 PAL18l8ACN. +The MCU XTAL is 10.73835 MHz rather than 10 MHz on this PCB. */ ROM_START( atetrisb3 ) @@ -525,9 +538,10 @@ ROM_START( atetrisb3 ) ROM_REGION( 0x10000, "gfx1", 0 ) ROM_LOAD( "gfx.bin", 0x0000, 0x10000, CRC(84a1939f) SHA1(d8577985fc8ed4e74f74c68b7c00c4855b7c3270) ) - // 8749 (10 MHz OSC) instead of the slapstic, needs to be hooked up. - ROM_REGION( 0x0800, "user1", 0 ) - ROM_LOAD( "8749h.bin", 0x0000, 0x0800, CRC(a66a9c47) SHA1(fbebd755a5e826c7d94ebcafdff2f9a01c9fd1a5) ) + // 8749 (10 MHz OSC) emulates POKEYs + ROM_REGION( 0x0800, "mcu", 0 ) + ROM_LOAD( "8749h.bin", 0x0000, 0x0800, CRC(a66a9c47) SHA1(fbebd755a5e826c7d94ebcafdff2f9a01c9fd1a5) BAD_DUMP ) + ROM_FILL( 0x06e2, 1, 0x96 ) // patch illegal opcode // currently unused ROM_REGION( 0x0020, "proms", 0 ) @@ -587,10 +601,10 @@ void atetris_state::init_atetris() * *************************************/ -GAME( 1988, atetris, 0, atetris, atetris, atetris_state, init_atetris, ROT0, "Atari Games", "Tetris (set 1)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, atetrisa, atetris, atetris, atetris, atetris_state, init_atetris, ROT0, "Atari Games", "Tetris (set 2)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, atetrisb, atetris, atetris, atetris, atetris_state, init_atetris, ROT0, "bootleg", "Tetris (bootleg set 1)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, atetrisb2, atetris, atetrisb2, atetris, atetris_state, init_atetris, ROT0, "bootleg", "Tetris (bootleg set 2)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, atetrisb3, atetris, atetrisb3, atetris, atetris_state, init_atetris, ROT0, "bootleg", "Tetris (bootleg set 3)", MACHINE_NO_SOUND | MACHINE_SUPPORTS_SAVE ) -GAME( 1989, atetrisc, atetris, atetris, atetrisc, atetris_state, init_atetris, ROT270, "Atari Games", "Tetris (cocktail set 1)", MACHINE_SUPPORTS_SAVE ) -GAME( 1989, atetrisc2, atetris, atetris, atetrisc, atetris_state, init_atetris, ROT270, "Atari Games", "Tetris (cocktail set 2)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, atetris, 0, atetris, atetris, atetris_state, init_atetris, ROT0, "Atari Games", "Tetris (set 1)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, atetrisa, atetris, atetris, atetris, atetris_state, init_atetris, ROT0, "Atari Games", "Tetris (set 2)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, atetrisb, atetris, atetris, atetris, atetris_state, init_atetris, ROT0, "bootleg", "Tetris (bootleg set 1)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, atetrisb2, atetris, atetrisb2, atetris, atetris_state, init_atetris, ROT0, "bootleg", "Tetris (bootleg set 2)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, atetrisb3, atetris, atetrisb3, atetris, atetris_mcu_state, init_atetris, ROT0, "bootleg", "Tetris (bootleg set 3)", MACHINE_SUPPORTS_SAVE ) +GAME( 1989, atetrisc, atetris, atetris, atetrisc, atetris_state, init_atetris, ROT270, "Atari Games", "Tetris (cocktail set 1)", MACHINE_SUPPORTS_SAVE ) +GAME( 1989, atetrisc2, atetris, atetris, atetrisc, atetris_state, init_atetris, ROT270, "Atari Games", "Tetris (cocktail set 2)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/atetris.h b/src/mame/includes/atetris.h index 9cd3e9ea3c7..7fdd8fd4bd7 100644 --- a/src/mame/includes/atetris.h +++ b/src/mame/includes/atetris.h @@ -7,6 +7,9 @@ *************************************************************************/ #include "includes/slapstic.h" +#include "cpu/mcs48/mcs48.h" +#include "machine/gen_latch.h" +#include "sound/sn76496.h" #include "screen.h" class atetris_state : public driver_device @@ -18,13 +21,11 @@ public: m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), m_slapstic_device(*this, "slapstic"), - m_nvram(*this, "nvram") , m_videoram(*this, "videoram") { } void atetris(machine_config &config); void atetrisb2(machine_config &config); - void atetrisb3(machine_config &config); void init_atetris(); @@ -33,27 +34,22 @@ protected: virtual void machine_reset() override; virtual void video_start() override; -private: required_device<cpu_device> m_maincpu; required_device<gfxdecode_device> m_gfxdecode; required_device<screen_device> m_screen; optional_device<atari_slapstic_device> m_slapstic_device; - required_shared_ptr<uint8_t> m_nvram; required_shared_ptr<uint8_t> m_videoram; uint8_t *m_slapstic_source; uint8_t *m_slapstic_base; uint8_t m_current_bank; - uint8_t m_nvram_write_enable; emu_timer *m_interrupt_timer; tilemap_t *m_bg_tilemap; DECLARE_WRITE8_MEMBER(irq_ack_w); DECLARE_READ8_MEMBER(slapstic_r); DECLARE_WRITE8_MEMBER(coincount_w); - DECLARE_WRITE8_MEMBER(nvram_w); - DECLARE_WRITE8_MEMBER(nvram_enable_w); DECLARE_WRITE8_MEMBER(videoram_w); TILE_GET_INFO_MEMBER(get_tile_info); uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); @@ -61,6 +57,30 @@ private: void reset_bank(); void atetrisb2_map(address_map &map); - void atetrisb3_map(address_map &map); void main_map(address_map &map); }; + +class atetris_mcu_state : public atetris_state +{ +public: + atetris_mcu_state(const machine_config &mconfig, device_type type, const char *tag) + : atetris_state(mconfig, type, tag), + m_mcu(*this, "mcu"), + m_soundlatch(*this, "soundlatch%u", 1U), + m_sn(*this, "sn%u", 1U) + { + } + + void atetrisb3(machine_config &config); + +private: + DECLARE_READ8_MEMBER(mcu_bus_r); + DECLARE_WRITE8_MEMBER(mcu_p2_w); + DECLARE_WRITE8_MEMBER(mcu_reg_w); + + void atetrisb3_map(address_map &map); + + required_device<i8749_device> m_mcu; + required_device_array<generic_latch_8_device, 2> m_soundlatch; + required_device_array<sn76496_base_device, 4> m_sn; +}; |