diff options
author | 2015-09-13 08:41:44 +0200 | |
---|---|---|
committer | 2015-09-13 08:41:44 +0200 | |
commit | f88cefad27a1737c76e09d99c9fb43e173506081 (patch) | |
tree | 2d8167d03579c46e226471747eb4407bd00ed6fa /src/devices/bus/astrocde | |
parent | e92ac9e0fa8e99869894bea00589bbb526be30aa (diff) |
Move all devices into separate part of src tree (nw)
Diffstat (limited to 'src/devices/bus/astrocde')
-rw-r--r-- | src/devices/bus/astrocde/exp.c | 85 | ||||
-rw-r--r-- | src/devices/bus/astrocde/exp.h | 57 | ||||
-rw-r--r-- | src/devices/bus/astrocde/ram.c | 211 | ||||
-rw-r--r-- | src/devices/bus/astrocde/ram.h | 135 | ||||
-rw-r--r-- | src/devices/bus/astrocde/rom.c | 99 | ||||
-rw-r--r-- | src/devices/bus/astrocde/rom.h | 73 | ||||
-rw-r--r-- | src/devices/bus/astrocde/slot.c | 236 | ||||
-rw-r--r-- | src/devices/bus/astrocde/slot.h | 103 |
8 files changed, 999 insertions, 0 deletions
diff --git a/src/devices/bus/astrocde/exp.c b/src/devices/bus/astrocde/exp.c new file mode 100644 index 00000000000..28017230f0d --- /dev/null +++ b/src/devices/bus/astrocde/exp.c @@ -0,0 +1,85 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/*********************************************************************************************************** + + Bally Astrocade Expansion port + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "exp.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type ASTROCADE_EXP_SLOT = &device_creator<astrocade_exp_device>; + + +device_astrocade_card_interface::device_astrocade_card_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device) +{ +} + + +device_astrocade_card_interface::~device_astrocade_card_interface() +{ +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// astrocade_exp_device - constructor +//------------------------------------------------- +astrocade_exp_device::astrocade_exp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, ASTROCADE_EXP_SLOT, "Bally Astrocade expansion", tag, owner, clock, "astrocde_exp", __FILE__), + device_slot_interface(mconfig, *this), + m_card_mounted(false) +{ +} + + +//------------------------------------------------- +// astrocade_exp_device - destructor +//------------------------------------------------- + +astrocade_exp_device::~astrocade_exp_device() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void astrocade_exp_device::device_start() +{ + m_card = dynamic_cast<device_astrocade_card_interface *>(get_card_device()); + if (m_card) + m_card_mounted = true; +} + +/*------------------------------------------------- + read + -------------------------------------------------*/ + +READ8_MEMBER(astrocade_exp_device::read) +{ + if (m_card) + return m_card->read(space, offset); + else + return 0xff; +} + +/*------------------------------------------------- + write + -------------------------------------------------*/ + +WRITE8_MEMBER(astrocade_exp_device::write) +{ + if (m_card) + m_card->write(space, offset, data); +} diff --git a/src/devices/bus/astrocde/exp.h b/src/devices/bus/astrocde/exp.h new file mode 100644 index 00000000000..e691a5b946a --- /dev/null +++ b/src/devices/bus/astrocde/exp.h @@ -0,0 +1,57 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +#ifndef __ASTROCADE_EXP_H +#define __ASTROCADE_EXP_H + +// ======================> device_astrocade_card_interface + +class device_astrocade_card_interface : public device_slot_card_interface +{ +public: + // construction/destruction + device_astrocade_card_interface(const machine_config &mconfig, device_t &device); + virtual ~device_astrocade_card_interface(); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read) { return 0xff; } + virtual DECLARE_WRITE8_MEMBER(write) {} + +protected: +}; + + +// ======================> astrocade_exp_device + +class astrocade_exp_device : public device_t, + public device_slot_interface +{ +public: + // construction/destruction + astrocade_exp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual ~astrocade_exp_device(); + + // device-level overrides + virtual void device_start(); + + bool get_card_mounted() { return m_card_mounted; } + + // reading and writing + virtual DECLARE_READ8_MEMBER(read); + virtual DECLARE_WRITE8_MEMBER(write); + +protected: + bool m_card_mounted; + device_astrocade_card_interface* m_card; +}; + + + +// device type definition +extern const device_type ASTROCADE_EXP_SLOT; + + +#define MCFG_ASTROCADE_EXPANSION_SLOT_ADD(_tag, _slot_intf, _def_slot) \ + MCFG_DEVICE_ADD(_tag, ASTROCADE_EXP_SLOT, 0) \ + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) + +#endif diff --git a/src/devices/bus/astrocde/ram.c b/src/devices/bus/astrocde/ram.c new file mode 100644 index 00000000000..95ebb6816aa --- /dev/null +++ b/src/devices/bus/astrocde/ram.c @@ -0,0 +1,211 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/*********************************************************************************************************** + + + Bally Astrocade RAM expansion emulation + + RAM Expansions (info below courtesy of Paul Thacker) + + Several third party RAM expansions have been made for the Astrocade. These + allow access to various ranges of the expansion memory ($5000 to $FFFF). + A RAM expansion is required to use extended BASIC programs like Blue RAM BASIC + and VIPERSoft BASIC. All of the expansions also have a RAM protect switch, which + can be flipped at any time to make the RAM act like ROM. Extended BASIC + programs need access to the RAM and won't work with RAM protect enabled, but + this can be useful with Bally and Astrocade BASIC. They also have a range switch + (not implemented). The default position is 6K, but it can be switched to + 2K. This means that the expanded memory starting at $6000 will instead be + mapped to the cartridge memory starting at $2000. So it would be possible to + load a cartridge program from tape into the expansion memory, then flip the range + switch and run it as a cartridge. This is useful for cartridge development. + + Blue RAM -- available in 4K, 16K, and 32K. These also use an INS8154 chip, + (not yet implemented) which has an additional $80 bytes of RAM mapped + immediately after the end of the expansion address space. This memory + can't be write protected. The INS8154 has I/O features needed for loading + tape programs into Blue RAM BASIC, as well as running the Blue RAM Utility cart. + 4K: $6000 to $6FFF (can't run VIPERSoft BASIC, because this program needs memory + past this range) + 16K: $6000 to $9FFF + 32K: $6000 to $DFFF + + VIPER System 1 -- This is available in 16K only. It also includes a keyboard (not implemented). + 16K: $6000 to $9FFF + + Lil' WHITE RAM -- This is available in 32K only. Attempts to read and write + to memory outside of its address range ($D000 to $FFFF) are mapped to the expansion + memory $5000 to $7FFF. The current implementation won't allow the shadow RAM area + to be accessed when RAM protect is on, but there is no known software that will + access the upper range of the expansion RAM when RAM protect is enabled. + 32K: $5000 to $CFFF + + R&L 64K RAM Board -- This is a highly configurable kit. RAM can be installed in + 2K increments. So, the entire 44K expansion memory can be filled. It is also + possible to override the rest of the memory map with RAM (not implemented). + There are 32 switches allowing users to activate and deactivate each 2K block (not implemented). + RAM write protection can be implemented in three ranges through jumpers or by + installing switches. The ranges are $0000 to $0FFF (first 4K), $0000 to $3FFF (first 16K), + and $0000 to $FFFF (all 64K). The current implementation is for 44K expansion memory mapped from + $5000 to $FFFF, with only a single write protect covering this entire range. + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "ram.h" + + +//------------------------------------------------- +// astrocade_rom_device - constructor +//------------------------------------------------- + +const device_type ASTROCADE_BLUERAM_4K = &device_creator<astrocade_blueram_4k_device>; +const device_type ASTROCADE_BLUERAM_16K = &device_creator<astrocade_blueram_16k_device>; +const device_type ASTROCADE_BLUERAM_32K = &device_creator<astrocade_blueram_32k_device>; +const device_type ASTROCADE_VIPER_SYS1 = &device_creator<astrocade_viper_sys1_device>; +const device_type ASTROCADE_WHITERAM = &device_creator<astrocade_whiteram_device>; +const device_type ASTROCADE_RL64RAM = &device_creator<astrocade_rl64ram_device>; + + +astrocade_blueram_4k_device::astrocade_blueram_4k_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) + : device_t(mconfig, type, name, tag, owner, clock, shortname, source), + device_astrocade_card_interface(mconfig, *this), + m_write_prot(*this, "RAM_PROTECT") +{ +} + +astrocade_blueram_4k_device::astrocade_blueram_4k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, ASTROCADE_BLUERAM_4K, "Bally Astrocade Blue RAM 4K", tag, owner, clock, "astrocade_br4", __FILE__), + device_astrocade_card_interface(mconfig, *this), + m_write_prot(*this, "RAM_PROTECT") +{ +} + +astrocade_blueram_16k_device::astrocade_blueram_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : astrocade_blueram_4k_device(mconfig, ASTROCADE_BLUERAM_16K, "Bally Astrocade Blue RAM 16K", tag, owner, clock, "astrocade_br16", __FILE__) +{ +} + +astrocade_blueram_32k_device::astrocade_blueram_32k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : astrocade_blueram_4k_device(mconfig, ASTROCADE_BLUERAM_32K, "Bally Astrocade Blue RAM 32K", tag, owner, clock, "astrocade_br32", __FILE__) +{ +} + +astrocade_viper_sys1_device::astrocade_viper_sys1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, ASTROCADE_VIPER_SYS1, "Bally Astrocade Viper System 1", tag, owner, clock, "astrocade_vs1", __FILE__), + device_astrocade_card_interface(mconfig, *this), + m_write_prot(*this, "RAM_PROTECT") +{ +} + +astrocade_whiteram_device::astrocade_whiteram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, ASTROCADE_WHITERAM, "Bally Astrocade Lil' White RAM 32K", tag, owner, clock, "astrocade_lwr", __FILE__), + device_astrocade_card_interface(mconfig, *this), + m_write_prot(*this, "RAM_PROTECT") +{ +} + +astrocade_rl64ram_device::astrocade_rl64ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, ASTROCADE_RL64RAM, "Bally Astrocade R&L RAM 64K", tag, owner, clock, "astrocade_rl64", __FILE__), + device_astrocade_card_interface(mconfig, *this), + m_write_prot(*this, "RAM_PROTECT") +{ +} + + +//------------------------------------------------- +// RAM Write protect switch +//------------------------------------------------- + +static INPUT_PORTS_START( exp_switches ) + PORT_START("RAM_PROTECT") + PORT_CONFNAME( 0x01, 0x00, "Write Protect RAM") + PORT_CONFSETTING( 0x00, DEF_STR(Off)) + PORT_CONFSETTING( 0x01, DEF_STR(On)) +INPUT_PORTS_END + + +ioport_constructor astrocade_blueram_4k_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( exp_switches ); +} + +ioport_constructor astrocade_viper_sys1_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( exp_switches ); +} + +ioport_constructor astrocade_whiteram_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( exp_switches ); +} + +ioport_constructor astrocade_rl64ram_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( exp_switches ); +} + +/*------------------------------------------------- + specific handlers + -------------------------------------------------*/ + +// Blue RAM expansions have RAM starting at 0x6000, up to the RAM size +READ8_MEMBER(astrocade_blueram_4k_device::read) +{ + if (offset >= 0x1000 && offset < 0x1000 + m_ram.size()) + return m_ram[offset - 0x1000]; + else + return 0; +} + +WRITE8_MEMBER(astrocade_blueram_4k_device::write) +{ + if (offset >= 0x1000 && offset < 0x1000 + m_ram.size() && !m_write_prot->read()) + m_ram[offset - 0x1000] = data; +} + + + +// Viper System 1 expansion has RAM in 0x6000-0x9fff +READ8_MEMBER(astrocade_viper_sys1_device::read) +{ + if (offset >= 0x1000 && offset < 0xa000) + return m_ram[offset - 0x1000]; + else + return 0; +} + +WRITE8_MEMBER(astrocade_viper_sys1_device::write) +{ + if (offset >= 0x1000 && offset < 0xa000 && !m_write_prot->read()) + m_ram[offset - 0x1000] = data; +} + + + +// Lil' WHITE RAM expansion has RAM in 0x5000-0xcfff + a mirror of the first 0x3000 bytes up to 0xffff +READ8_MEMBER(astrocade_whiteram_device::read) +{ + return m_ram[offset % 0x8000]; +} + +WRITE8_MEMBER(astrocade_whiteram_device::write) +{ + if (!m_write_prot->read()) + m_ram[offset % 0x8000] = data; +} + + + +// R&L 64K RAM Board (44KB installed) has RAM in 0x5000-0xffff +READ8_MEMBER(astrocade_rl64ram_device::read) +{ + return m_ram[offset]; +} + +WRITE8_MEMBER(astrocade_rl64ram_device::write) +{ + if (!m_write_prot->read()) + m_ram[offset] = data; +} diff --git a/src/devices/bus/astrocde/ram.h b/src/devices/bus/astrocde/ram.h new file mode 100644 index 00000000000..9df04bdad0e --- /dev/null +++ b/src/devices/bus/astrocde/ram.h @@ -0,0 +1,135 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +#ifndef __ASTROCADE_RAM_H +#define __ASTROCADE_RAM_H + +#include "exp.h" + + +// ======================> astrocade_blueram_4k_device + +class astrocade_blueram_4k_device : public device_t, + public device_astrocade_card_interface +{ +public: + // construction/destruction + astrocade_blueram_4k_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); + astrocade_blueram_4k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start() { m_ram.resize(0x1000); save_item(NAME(m_ram)); } + virtual void device_reset() {} + virtual ioport_constructor device_input_ports() const; + + // reading and writing + virtual DECLARE_READ8_MEMBER(read); + virtual DECLARE_WRITE8_MEMBER(write); + +protected: + dynamic_buffer m_ram; + required_ioport m_write_prot; +}; + +// ======================> astrocade_blueram_16k_device + +class astrocade_blueram_16k_device : public astrocade_blueram_4k_device +{ +public: + // construction/destruction + astrocade_blueram_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual void device_start() { m_ram.resize(0x4000); save_item(NAME(m_ram)); } +}; + +// ======================> astrocade_blueram_32k_device + +class astrocade_blueram_32k_device : public astrocade_blueram_4k_device +{ +public: + // construction/destruction + astrocade_blueram_32k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual void device_start() { m_ram.resize(0x8000); save_item(NAME(m_ram)); } +}; + +// ======================> astrocade_viper_sys1_device + +class astrocade_viper_sys1_device : public device_t, + public device_astrocade_card_interface +{ +public: + // construction/destruction + astrocade_viper_sys1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start() { m_ram.resize(0x4000); save_item(NAME(m_ram)); } + virtual void device_reset() {} + virtual ioport_constructor device_input_ports() const; + + // reading and writing + virtual DECLARE_READ8_MEMBER(read); + virtual DECLARE_WRITE8_MEMBER(write); + +private: + dynamic_buffer m_ram; + required_ioport m_write_prot; +}; + +// ======================> astrocade_whiteram_device + +class astrocade_whiteram_device : public device_t, + public device_astrocade_card_interface +{ +public: + // construction/destruction + astrocade_whiteram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start() { m_ram.resize(0x8000); save_item(NAME(m_ram)); } + virtual void device_reset() {} + virtual ioport_constructor device_input_ports() const; + + // reading and writing + virtual DECLARE_READ8_MEMBER(read); + virtual DECLARE_WRITE8_MEMBER(write); + +private: + dynamic_buffer m_ram; + required_ioport m_write_prot; +}; + +// ======================> astrocade_rl64ram_device + +class astrocade_rl64ram_device : public device_t, + public device_astrocade_card_interface +{ +public: + // construction/destruction + astrocade_rl64ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start() { m_ram.resize(0xb000); save_item(NAME(m_ram)); } + virtual void device_reset() {} + virtual ioport_constructor device_input_ports() const; + + // reading and writing + virtual DECLARE_READ8_MEMBER(read); + virtual DECLARE_WRITE8_MEMBER(write); + +private: + dynamic_buffer m_ram; + required_ioport m_write_prot; +}; + + + +// device type definition +extern const device_type ASTROCADE_BLUERAM_4K; +extern const device_type ASTROCADE_BLUERAM_16K; +extern const device_type ASTROCADE_BLUERAM_32K; +extern const device_type ASTROCADE_VIPER_SYS1; +extern const device_type ASTROCADE_WHITERAM; +extern const device_type ASTROCADE_RL64RAM; + + +#endif diff --git a/src/devices/bus/astrocde/rom.c b/src/devices/bus/astrocde/rom.c new file mode 100644 index 00000000000..d8067daa062 --- /dev/null +++ b/src/devices/bus/astrocde/rom.c @@ -0,0 +1,99 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/*********************************************************************************************************** + + + Bally Astrocade cart emulation + + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "rom.h" + + +//------------------------------------------------- +// astrocade_rom_device - constructor +//------------------------------------------------- + +const device_type ASTROCADE_ROM_STD = &device_creator<astrocade_rom_device>; +const device_type ASTROCADE_ROM_256K = &device_creator<astrocade_rom_256k_device>; +const device_type ASTROCADE_ROM_512K = &device_creator<astrocade_rom_512k_device>; + + +astrocade_rom_device::astrocade_rom_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) + : device_t(mconfig, type, name, tag, owner, clock, shortname, source), + device_astrocade_cart_interface(mconfig, *this) +{ +} + +astrocade_rom_device::astrocade_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, ASTROCADE_ROM_STD, "Bally Astrocade Standard Carts", tag, owner, clock, "astrocade_rom", __FILE__), + device_astrocade_cart_interface(mconfig, *this) +{ +} + +astrocade_rom_256k_device::astrocade_rom_256k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : astrocade_rom_device(mconfig, ASTROCADE_ROM_256K, "Bally Astrocade 256K Carts", tag, owner, clock, "astrocade_256k", __FILE__) +{ +} + +astrocade_rom_512k_device::astrocade_rom_512k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : astrocade_rom_device(mconfig, ASTROCADE_ROM_512K, "Bally Astrocade 512K Carts", tag, owner, clock, "astrocade_512k", __FILE__) +{ +} + + +void astrocade_rom_256k_device::device_start() +{ + save_item(NAME(m_base_bank)); +} + +void astrocade_rom_256k_device::device_reset() +{ + m_base_bank = 0; +} + +void astrocade_rom_512k_device::device_start() +{ + save_item(NAME(m_base_bank)); +} + +void astrocade_rom_512k_device::device_reset() +{ + m_base_bank = 0; +} + + +/*------------------------------------------------- + mapper specific handlers + -------------------------------------------------*/ + +READ8_MEMBER(astrocade_rom_device::read_rom) +{ + if (offset < m_rom_size) + return m_rom[offset]; + else + return 0xff; +} + +READ8_MEMBER(astrocade_rom_256k_device::read_rom) +{ + if (offset < 0x1000) // 0x2000-0x2fff + return m_rom[offset + 0x1000 * 0x3f]; + else if (offset < 0x1fc0) // 0x3000-0x3fbf + return m_rom[(offset & 0xfff) + (0x1000 * m_base_bank)]; + else // 0x3fc0-0x3fff + return m_base_bank = offset & 0x3f; +} + +READ8_MEMBER(astrocade_rom_512k_device::read_rom) +{ + if (offset < 0x1000) // 0x2000-0x2fff + return m_rom[offset + 0x1000 * 0x7f]; + else if (offset < 0x1f80) // 0x3000-0x3fbf + return m_rom[(offset & 0xfff) + (0x1000 * m_base_bank)]; + else // 0x3fc0-0x3fff + return m_base_bank = offset & 0x7f; +} diff --git a/src/devices/bus/astrocde/rom.h b/src/devices/bus/astrocde/rom.h new file mode 100644 index 00000000000..e0b5647742a --- /dev/null +++ b/src/devices/bus/astrocde/rom.h @@ -0,0 +1,73 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +#ifndef __ASTROCADE_ROM_H +#define __ASTROCADE_ROM_H + +#include "slot.h" + + +// ======================> astrocade_rom_device + +class astrocade_rom_device : public device_t, + public device_astrocade_cart_interface +{ +public: + // construction/destruction + astrocade_rom_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); + astrocade_rom_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_rom); +}; + +// ======================> astrocade_rom_256k_device + +class astrocade_rom_256k_device : public astrocade_rom_device +{ +public: + // construction/destruction + astrocade_rom_256k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual void device_start(); + virtual void device_reset(); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_rom); + +private: + UINT8 m_base_bank; +}; + +// ======================> astrocade_rom_512k_device + +class astrocade_rom_512k_device : public astrocade_rom_device +{ +public: + // construction/destruction + astrocade_rom_512k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual void device_start(); + virtual void device_reset(); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_rom); + +private: + UINT8 m_base_bank; +}; + + + + + +// device type definition +extern const device_type ASTROCADE_ROM_STD; +extern const device_type ASTROCADE_ROM_256K; +extern const device_type ASTROCADE_ROM_512K; + + +#endif diff --git a/src/devices/bus/astrocde/slot.c b/src/devices/bus/astrocde/slot.c new file mode 100644 index 00000000000..5345d90b7fb --- /dev/null +++ b/src/devices/bus/astrocde/slot.c @@ -0,0 +1,236 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/*********************************************************************************************************** + + Bally Astrocade cart emulation + (through slot devices) + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "slot.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type ASTROCADE_CART_SLOT = &device_creator<astrocade_cart_slot_device>; + +//************************************************************************** +// Astrocade Cartridges Interface +//************************************************************************** + +//------------------------------------------------- +// device_astrocade_cart_interface - constructor +//------------------------------------------------- + +device_astrocade_cart_interface::device_astrocade_cart_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device), + m_rom(NULL), + m_rom_size(0) +{ +} + + +//------------------------------------------------- +// ~device_astrocade_cart_interface - destructor +//------------------------------------------------- + +device_astrocade_cart_interface::~device_astrocade_cart_interface() +{ +} + +//------------------------------------------------- +// rom_alloc - alloc the space for the cart +//------------------------------------------------- + +void device_astrocade_cart_interface::rom_alloc(UINT32 size, const char *tag) +{ + if (m_rom == NULL) + { + m_rom = device().machine().memory().region_alloc(std::string(tag).append(ASTROCADESLOT_ROM_REGION_TAG).c_str(), size, 1, ENDIANNESS_LITTLE)->base(); + m_rom_size = size; + } +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// astrocade_cart_slot_device - constructor +//------------------------------------------------- +astrocade_cart_slot_device::astrocade_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, ASTROCADE_CART_SLOT, "Bally Astrocade Cartridge Slot", tag, owner, clock, "astrocade_cart_slot", __FILE__), + device_image_interface(mconfig, *this), + device_slot_interface(mconfig, *this), + m_type(ASTROCADE_STD) +{ +} + + +//------------------------------------------------- +// astrocade_cart_slot_device - destructor +//------------------------------------------------- + +astrocade_cart_slot_device::~astrocade_cart_slot_device() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void astrocade_cart_slot_device::device_start() +{ + m_cart = dynamic_cast<device_astrocade_cart_interface *>(get_card_device()); +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void astrocade_cart_slot_device::device_config_complete() +{ + // set brief and instance name + update_names(); +} + + +//------------------------------------------------- +// ASTROCADE PCB +//------------------------------------------------- + +struct astrocade_slot +{ + int pcb_id; + const char *slot_option; +}; + +// Here, we take the feature attribute from .xml (i.e. the PCB name) and we assign a unique ID to it +static const astrocade_slot slot_list[] = +{ + { ASTROCADE_STD, "rom" }, + { ASTROCADE_256K, "rom_256k" }, + { ASTROCADE_512K, "rom_512k" } +}; + +static int astrocade_get_pcb_id(const char *slot) +{ + for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + { + if (!core_stricmp(slot_list[i].slot_option, slot)) + return slot_list[i].pcb_id; + } + + return 0; +} + +static const char *astrocade_get_slot(int type) +{ + for (int i = 0; i < ARRAY_LENGTH(slot_list); i++) + { + if (slot_list[i].pcb_id == type) + return slot_list[i].slot_option; + } + + return "std"; +} + + +/*------------------------------------------------- + call load + -------------------------------------------------*/ + +bool astrocade_cart_slot_device::call_load() +{ + if (m_cart) + { + UINT32 size = (software_entry() == NULL) ? length() : get_software_region_length("rom"); + m_cart->rom_alloc(size, tag()); + + if (software_entry() == NULL) + fread(m_cart->get_rom_base(), size); + else + memcpy(m_cart->get_rom_base(), get_software_region("rom"), size); + + if (software_entry() == NULL) + { + m_type = ASTROCADE_STD; + + if (size == 0x40000) + m_type = ASTROCADE_256K; + if (size == 0x80000) + m_type = ASTROCADE_512K; + } + else + { + const char *pcb_name = get_feature("slot"); + if (pcb_name) + m_type = astrocade_get_pcb_id(pcb_name); + } + + //printf("Type: %s\n", astrocade_get_slot(m_type)); + + return IMAGE_INIT_PASS; + } + + return IMAGE_INIT_PASS; +} + + +/*------------------------------------------------- + call softlist load + -------------------------------------------------*/ + +bool astrocade_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) +{ + load_software_part_region(*this, swlist, swname, start_entry); + return TRUE; +} + + +/*------------------------------------------------- + get default card software + -------------------------------------------------*/ + +void astrocade_cart_slot_device::get_default_card_software(std::string &result) +{ + if (open_image_file(mconfig().options())) + { + const char *slot_string = "rom"; + UINT32 size = core_fsize(m_file); + int type = ASTROCADE_STD; + + if (size == 0x40000) + type = ASTROCADE_256K; + if (size == 0x80000) + type = ASTROCADE_512K; + + slot_string = astrocade_get_slot(type); + + //printf("type: %s\n", slot_string); + clear(); + + result.assign(slot_string); + return; + } + + software_get_default_slot(result, "rom"); +} + +/*------------------------------------------------- + read + -------------------------------------------------*/ + +READ8_MEMBER(astrocade_cart_slot_device::read_rom) +{ + if (m_cart) + return m_cart->read_rom(space, offset); + else + return 0xff; +} diff --git a/src/devices/bus/astrocde/slot.h b/src/devices/bus/astrocde/slot.h new file mode 100644 index 00000000000..738c32a6faa --- /dev/null +++ b/src/devices/bus/astrocde/slot.h @@ -0,0 +1,103 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +#ifndef __ASTROCADE_SLOT_H +#define __ASTROCADE_SLOT_H + +/*************************************************************************** + TYPE DEFINITIONS + ***************************************************************************/ + + +/* PCB */ +enum +{ + ASTROCADE_STD = 0, + ASTROCADE_256K, + ASTROCADE_512K +}; + + +// ======================> device_astrocade_cart_interface + +class device_astrocade_cart_interface : public device_slot_card_interface +{ +public: + // construction/destruction + device_astrocade_cart_interface(const machine_config &mconfig, device_t &device); + virtual ~device_astrocade_cart_interface(); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_rom) { return 0xff; } + + void rom_alloc(UINT32 size, const char *tag); + void ram_alloc(UINT32 size); + UINT8* get_rom_base() { return m_rom; } + UINT32 get_rom_size() { return m_rom_size; } + +protected: + // internal state + UINT8 *m_rom; + UINT32 m_rom_size; +}; + + +// ======================> astrocade_cart_slot_device + +class astrocade_cart_slot_device : public device_t, + public device_image_interface, + public device_slot_interface +{ +public: + // construction/destruction + astrocade_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual ~astrocade_cart_slot_device(); + + // device-level overrides + virtual void device_start(); + virtual void device_config_complete(); + + // image-level overrides + virtual bool call_load(); + virtual void call_unload() {} + virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry); + + int get_type() { return m_type; } + + virtual iodevice_t image_type() const { return IO_CARTSLOT; } + virtual bool is_readable() const { return 1; } + virtual bool is_writeable() const { return 0; } + virtual bool is_creatable() const { return 0; } + virtual bool must_be_loaded() const { return 0; } + virtual bool is_reset_on_load() const { return 1; } + virtual const option_guide *create_option_guide() const { return NULL; } + virtual const char *image_interface() const { return "astrocde_cart"; } + virtual const char *file_extensions() const { return "bin"; } + + // slot interface overrides + virtual void get_default_card_software(std::string &result); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_rom); + +protected: + + int m_type; + device_astrocade_cart_interface* m_cart; +}; + + + +// device type definition +extern const device_type ASTROCADE_CART_SLOT; + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS + ***************************************************************************/ + +#define ASTROCADESLOT_ROM_REGION_TAG ":cart:rom" + +#define MCFG_ASTROCADE_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ + MCFG_DEVICE_ADD(_tag, ASTROCADE_CART_SLOT, 0) \ + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) +#endif |