From 23e06597d4776f02e09bcecbcd91b007a7ad6037 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Sat, 6 Sep 2014 10:59:23 +0000 Subject: [PATCH] d'oh. sorry. --- .gitattributes | 2 + src/emu/bus/a7800/cpuwiz.c | 158 +++++++++++++++++++++++++++++++++++++ src/emu/bus/a7800/cpuwiz.h | 72 +++++++++++++++++ 3 files changed, 232 insertions(+) create mode 100644 src/emu/bus/a7800/cpuwiz.c create mode 100644 src/emu/bus/a7800/cpuwiz.h diff --git a/.gitattributes b/.gitattributes index bb8f09f231a..d7f0ed52f3b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -479,6 +479,8 @@ src/emu/bus/a2bus/timemasterho.h svneol=native#text/plain src/emu/bus/a7800/a78_carts.h svneol=native#text/plain src/emu/bus/a7800/a78_slot.c svneol=native#text/plain src/emu/bus/a7800/a78_slot.h svneol=native#text/plain +src/emu/bus/a7800/cpuwiz.c svneol=native#text/plain +src/emu/bus/a7800/cpuwiz.h svneol=native#text/plain src/emu/bus/a7800/hiscore.c svneol=native#text/plain src/emu/bus/a7800/hiscore.h svneol=native#text/plain src/emu/bus/a7800/rom.c svneol=native#text/plain diff --git a/src/emu/bus/a7800/cpuwiz.c b/src/emu/bus/a7800/cpuwiz.c new file mode 100644 index 00000000000..c9d55f080c7 --- /dev/null +++ b/src/emu/bus/a7800/cpuwiz.c @@ -0,0 +1,158 @@ +/*********************************************************************************************************** + + A7800 CPUWIZ's homebrew boards (MegaCart+ and VersaBoard) + + Here we emulate the base configurations of these two boards: + + MegaCart+ = up to 512K (31 banks at $8000, 1 at $C000) of ROM and 2 x 16K RAM @ $4000 + VersaBoard = up to 256K of ROM and 2 x 16K RAM + + Plus, for the moment, a VersaBoard with POKEY mapped at 0x0450 and support for 144K ROM, + since a few demo homebrew programs seems to use this to combine compatibility with + XBoarD & XM expansions + + Note that the VersaBoard can be configured to work with different banking hardware + e.g. with SG 9bank games or with SG + RAM (so to allow reproduction of games which + could have worked on old carts without sacrifying original carts), but games running + on those "standard" variants can be emulated with the standard code from rom.c ;-) + + + TO DO: + - investigate whether the POKEY detection routines in homebrew do fail due to emulation + issues or not + +***********************************************************************************************************/ + + +#include "emu.h" +#include "cpuwiz.h" + + +//------------------------------------------------- +// constructor +//------------------------------------------------- + +const device_type A78_ROM_VERSABOARD = &device_creator; +const device_type A78_ROM_VERSAPOKEY = &device_creator; +const device_type A78_ROM_MEGACART = &device_creator; + + +a78_versaboard_device::a78_versaboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) + : a78_rom_sg_device(mconfig, type, name, tag, owner, clock, shortname, source) +{ +} + +a78_versaboard_device::a78_versaboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : a78_rom_sg_device(mconfig, A78_ROM_VERSABOARD, "Atari 7800 VersaBoard Cart", tag, owner, clock, "a78_versaboard", __FILE__) +{ +} + +a78_versapokey_device::a78_versapokey_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : a78_versaboard_device(mconfig, A78_ROM_VERSAPOKEY, "Atari 7800 VersaBoard + POKEY @ 0x0450 Cart", tag, owner, clock, "a78_versapokey", __FILE__), + m_pokey(*this, "pokey") +{ +} + +a78_megacart_device::a78_megacart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : a78_versaboard_device(mconfig, A78_ROM_MEGACART, "Atari 7800 MegaCart+", tag, owner, clock, "a78_megacart", __FILE__) +{ +} + + +void a78_versaboard_device::device_start() +{ + save_item(NAME(m_bank)); + save_item(NAME(m_ram_bank)); +} + +void a78_versaboard_device::device_reset() +{ + m_bank = 0; + m_ram_bank = 0; +} + + +// VersaBoard + +READ8_MEMBER(a78_versaboard_device::read_40xx) +{ + if (offset < 0x4000) + return m_ram[offset + (m_ram_bank * 0x4000)]; + else if (offset < 0x8000) + return m_rom[(offset & 0x3fff) + (m_bank * 0x4000)]; + else + return m_rom[(offset & 0x3fff) + (m_bank_mask * 0x4000)]; // last bank +} + +WRITE8_MEMBER(a78_versaboard_device::write_40xx) +{ + if (offset < 0x4000) + m_ram[offset + (m_ram_bank * 0x4000)] = data; + else if (offset < 0x8000) + { + // hardware allows up to 256K ROM + m_bank = (data & 0x0f) & m_bank_mask; + m_ram_bank = BIT(data, 5); + } +} + + +// VersaBoard + POKEY @ 0x0450 + +static MACHINE_CONFIG_FRAGMENT( a78_pokey ) + MCFG_SPEAKER_STANDARD_MONO("addon") + + MCFG_SOUND_ADD("pokey", POKEY, XTAL_14_31818MHz/8) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "addon", 1.00) +MACHINE_CONFIG_END + +machine_config_constructor a78_versapokey_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( a78_pokey ); +} + +READ8_MEMBER(a78_versapokey_device::read_04xx) +{ + if (offset >= 0x50 && offset < 0x60) + return m_pokey->read(space, offset & 0x0f); + else + return 0xff; +} + +WRITE8_MEMBER(a78_versapokey_device::write_04xx) +{ + if (offset >= 0x50 && offset < 0x60) + m_pokey->write(space, offset & 0x0f, data); +} + +READ8_MEMBER(a78_versapokey_device::read_40xx) +{ + if (offset < 0x4000) + return m_rom[(offset & 0x3fff)]; + else if (offset < 0x8000) + return m_rom[(offset & 0x3fff) + (m_bank * 0x4000)]; + else + return m_rom[(offset & 0x3fff) + ((m_bank_mask + 1) * 0x4000)]; // last bank +} + +WRITE8_MEMBER(a78_versapokey_device::write_40xx) +{ + if (offset >= 0x4000 && offset < 0x8000) + m_bank = (data & m_bank_mask) + 1; +} + + +// MegaCart+ + +WRITE8_MEMBER(a78_megacart_device::write_40xx) +{ + if (offset < 0x4000) + m_ram[offset + (m_ram_bank * 0x4000)] = data; + else if (offset < 0x8000) + { + // hardware allows up to 512K ROM + m_bank = (data & 0x1f) & m_bank_mask; + m_ram_bank = BIT(data, 5); + } +} + diff --git a/src/emu/bus/a7800/cpuwiz.h b/src/emu/bus/a7800/cpuwiz.h new file mode 100644 index 00000000000..f9fb590bbca --- /dev/null +++ b/src/emu/bus/a7800/cpuwiz.h @@ -0,0 +1,72 @@ +#ifndef __A78_CPUWIZ_H +#define __A78_CPUWIZ_H + +#include "a78_slot.h" +#include "rom.h" + + +// ======================> a78_versaboard_device + +class a78_versaboard_device : public a78_rom_sg_device +{ +public: + // construction/destruction + a78_versaboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); + a78_versaboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_40xx); + virtual DECLARE_WRITE8_MEMBER(write_40xx); + +protected: + int m_ram_bank; +}; + + +// ======================> a78_versapokey_device + +class a78_versapokey_device : public a78_versaboard_device +{ +public: + // construction/destruction + a78_versapokey_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual machine_config_constructor device_mconfig_additions() const; + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_04xx); + virtual DECLARE_WRITE8_MEMBER(write_04xx); + virtual DECLARE_READ8_MEMBER(read_40xx); + virtual DECLARE_WRITE8_MEMBER(write_40xx); + +protected: + required_device m_pokey; +}; + + +// ======================> a78_megacart_device + +class a78_megacart_device : public a78_versaboard_device +{ +public: + // construction/destruction + a78_megacart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // reading and writing + virtual DECLARE_WRITE8_MEMBER(write_40xx); +}; + + + +// device type definition +extern const device_type A78_ROM_VERSABOARD; +extern const device_type A78_ROM_VERSAPOKEY; +extern const device_type A78_ROM_MEGACART; + + +#endif