From c397bad20b39cbd57ff86c316ccd6cfff6572027 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Tue, 26 Aug 2014 05:58:29 +0000 Subject: [PATCH] (MESS) a7800: added Yamaha 2151 emulation to the XM expansion board, thanks to info from tep392. nw. Also removed from the softlist the Donkey Kong XM Enhanced version which had been hacked to work on ProSystem emulator and fails to save hiscores with correct HSC emulation (it remains available the correct version which saves fine both in MESS and in the real hardware). --- hash/a7800.xml | 41 ++++-------------------- src/emu/bus/a7800/xboard.c | 64 ++++++++++++++++++++++++++++++++++++-- src/emu/bus/a7800/xboard.h | 12 +++++++ 3 files changed, 79 insertions(+), 38 deletions(-) diff --git a/hash/a7800.xml b/hash/a7800.xml index 641934c513f..3061a049fcd 100644 --- a/hash/a7800.xml +++ b/hash/a7800.xml @@ -2436,41 +2436,11 @@ almost nothing like the prototype. - - - Donkey Kong (homebrew, XM enhanced, HSC support) (Demo) + Donkey Kong (PAL, Demo, XM enhanced) 2012 - <homebrew> - - - - - - - - - - - - Donkey Kong (homebrew, XM enhanced, HSC support) (Demo) (NTSC) - 2012 - <homebrew> - - - - - - - - - - - - Donkey Kong (homebrew, XM enhanced) (Demo) - 2012 - <homebrew> + <homebrew> + @@ -2482,9 +2452,10 @@ almost nothing like the prototype. - Donkey Kong (homebrew, XM enhanced) (Demo) (NTSC) + Donkey Kong (NTSC, Demo, XM enhanced) 2012 - <homebrew> + <homebrew> + diff --git a/src/emu/bus/a7800/xboard.c b/src/emu/bus/a7800/xboard.c index 5a29d6b2af9..8a6c1ce90e3 100644 --- a/src/emu/bus/a7800/xboard.c +++ b/src/emu/bus/a7800/xboard.c @@ -37,8 +37,6 @@ TODO: - verify what happens when 2 POKEYs are present - - understand why high score in XM is not written to NVRAM - - add Yamaha YM2151 when more clear specs are available ***********************************************************************************************************/ @@ -73,7 +71,8 @@ a78_xboard_device::a78_xboard_device(const machine_config &mconfig, const char * a78_xm_device::a78_xm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : a78_xboard_device(mconfig, A78_XM, "Atari 7800 XM expansion module", tag, owner, clock, "a78_xm", __FILE__) + : a78_xboard_device(mconfig, A78_XM, "Atari 7800 XM expansion module", tag, owner, clock, "a78_xm", __FILE__), + m_ym(*this, "xm_ym2151") { } @@ -90,6 +89,20 @@ void a78_xboard_device::device_reset() m_ram_bank = 0; } +void a78_xm_device::device_start() +{ + save_item(NAME(m_reg)); + save_item(NAME(m_ram_bank)); + save_item(NAME(m_ym_enabled)); +} + +void a78_xm_device::device_reset() +{ + m_reg = 0; + m_ram_bank = 0; + m_ym_enabled = 0; +} + static MACHINE_CONFIG_FRAGMENT( a78_xb ) MCFG_A78_CARTRIDGE_ADD("xb_slot", a7800_cart, NULL) @@ -100,11 +113,27 @@ static MACHINE_CONFIG_FRAGMENT( a78_xb ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "xb_speaker", 1.00) MACHINE_CONFIG_END +static MACHINE_CONFIG_FRAGMENT( a78_xm ) + MCFG_A78_CARTRIDGE_ADD("xb_slot", a7800_cart, NULL) + + MCFG_SPEAKER_STANDARD_MONO("xb_speaker") + + MCFG_SOUND_ADD("xb_pokey", POKEY, XTAL_14_31818MHz/8) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "xb_speaker", 1.00) + + MCFG_SOUND_ADD("xm_ym2151", YM2151, XTAL_14_31818MHz/8) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "xb_speaker", 1.00) +MACHINE_CONFIG_END + machine_config_constructor a78_xboard_device::device_mconfig_additions() const { return MACHINE_CONFIG_NAME( a78_xb ); } +machine_config_constructor a78_xm_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( a78_xm ); +} /*------------------------------------------------- mapper specific handlers @@ -177,3 +206,32 @@ READ8_MEMBER(a78_xm_device::read_30xx) return m_rom[offset]; } +READ8_MEMBER(a78_xm_device::read_04xx) +{ + if (BIT(m_reg, 4) && offset >= 0x50 && offset < 0x60) + return m_pokey->read(space, offset & 0x0f); + else if (m_ym_enabled && offset >= 0x60 && offset <= 0x61) + return m_ym->read(space, offset & 1); + else if (BIT(m_reg, 4) && offset >= 0x60 && offset < 0x70) + return m_xbslot->read_04xx(space, offset - 0x10); // access second POKEY + else + return 0xff; +} + +WRITE8_MEMBER(a78_xm_device::write_04xx) +{ + if (BIT(m_reg, 4) && offset >= 0x50 && offset < 0x60) + m_pokey->write(space, offset & 0x0f, data); + else if (m_ym_enabled && offset >= 0x60 && offset <= 0x61) + m_ym->write(space, offset & 1, data); + else if (BIT(m_reg, 4) && offset >= 0x60 && offset < 0x70) + m_xbslot->write_04xx(space, offset - 0x10, data); // access second POKEY + else if (offset >= 0x70 && offset < 0x80) + { + if (data == 0x84) + m_ym_enabled = 1; + m_reg = data; + m_ram_bank = m_reg & 7; + } +} + diff --git a/src/emu/bus/a7800/xboard.h b/src/emu/bus/a7800/xboard.h index 011894b56ef..f8c843d35c1 100644 --- a/src/emu/bus/a7800/xboard.h +++ b/src/emu/bus/a7800/xboard.h @@ -4,6 +4,7 @@ #include "a78_slot.h" #include "rom.h" #include "sound/pokey.h" +#include "sound/2151intf.h" // ======================> a78_xboard_device @@ -41,10 +42,21 @@ public: // construction/destruction a78_xm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + // device-level overrides + virtual void device_start(); + virtual machine_config_constructor device_mconfig_additions() const; + virtual void device_reset(); + // reading and writing + virtual DECLARE_READ8_MEMBER(read_04xx); + virtual DECLARE_WRITE8_MEMBER(write_04xx); virtual DECLARE_READ8_MEMBER(read_10xx); virtual DECLARE_WRITE8_MEMBER(write_10xx); virtual DECLARE_READ8_MEMBER(read_30xx); + +protected: + required_device m_ym; + int m_ym_enabled; };