summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Fabio Priuli <etabeta78@users.noreply.github.com>2014-09-17 05:38:53 +0000
committer Fabio Priuli <etabeta78@users.noreply.github.com>2014-09-17 05:38:53 +0000
commite734a2efc9fa0e58febb6415bdac762dd8c16ef9 (patch)
treeea88ba5392d4418bd36fd1a9006a32a07da28361 /src
parentcd2ef4ee205b55d602d55d740662eff857ca8aca (diff)
added generic cartslot / ROM socket slot device, which offers
basic allocation and access handlers, and converted a few drivers to use this instead of code from cartslot.c [Fabio Priuli] out of whatsnew: the RAM socket part is just a proof of concept, and the natural extension of the line of thought which lead me to this generic socket/cartslot. it might allow to convert current RAM device to be a slot device as well (after some refactorization, of course, since current code lacks many of the necessary features), or be removed soonish, depending on consensus.
Diffstat (limited to 'src')
-rw-r--r--src/emu/bus/bus.mak14
-rw-r--r--src/emu/bus/generic/carts.c16
-rw-r--r--src/emu/bus/generic/carts.h21
-rw-r--r--src/emu/bus/generic/ram.c122
-rw-r--r--src/emu/bus/generic/ram.h107
-rw-r--r--src/emu/bus/generic/rom.c78
-rw-r--r--src/emu/bus/generic/rom.h56
-rw-r--r--src/emu/bus/generic/slot.c236
-rw-r--r--src/emu/bus/generic/slot.h165
-rw-r--r--src/mess/drivers/aim65.c103
-rw-r--r--src/mess/drivers/gamepock.c33
-rw-r--r--src/mess/drivers/pv2000.c94
-rw-r--r--src/mess/drivers/rx78.c40
-rw-r--r--src/mess/drivers/supracan.c171
-rw-r--r--src/mess/includes/aim65.h14
-rw-r--r--src/mess/includes/gamepock.h8
-rw-r--r--src/mess/machine/aim65.c10
-rw-r--r--src/mess/machine/gamepock.c4
-rw-r--r--src/mess/mess.mak1
19 files changed, 1028 insertions, 265 deletions
diff --git a/src/emu/bus/bus.mak b/src/emu/bus/bus.mak
index 62debaa6fd4..b14ac302350 100644
--- a/src/emu/bus/bus.mak
+++ b/src/emu/bus/bus.mak
@@ -313,6 +313,20 @@ endif
#-------------------------------------------------
#
+#@src/emu/bus/generic/slot.h,BUSES += GENERIC
+#-------------------------------------------------
+
+ifneq ($(filter GENERIC,$(BUSES)),)
+OBJDIRS += $(BUSOBJ)/generic
+BUSOBJS += $(BUSOBJ)/generic/slot.o
+BUSOBJS += $(BUSOBJ)/generic/carts.o
+BUSOBJS += $(BUSOBJ)/generic/ram.o
+BUSOBJS += $(BUSOBJ)/generic/rom.o
+endif
+
+
+#-------------------------------------------------
+#
#@src/emu/bus/ieee488/ieee488.h,BUSES += IEEE488
#-------------------------------------------------
diff --git a/src/emu/bus/generic/carts.c b/src/emu/bus/generic/carts.c
new file mode 100644
index 00000000000..04257f60a38
--- /dev/null
+++ b/src/emu/bus/generic/carts.c
@@ -0,0 +1,16 @@
+/**********************************************************************
+
+ Generic ROM / RAM socket slots
+
+ **********************************************************************/
+
+
+#include "carts.h"
+
+SLOT_INTERFACE_START(generic_plain_slot)
+ SLOT_INTERFACE_INTERNAL("rom", GENERIC_ROM_PLAIN)
+SLOT_INTERFACE_END
+
+SLOT_INTERFACE_START(generic_linear_slot)
+ SLOT_INTERFACE_INTERNAL("rom", GENERIC_ROM_LINEAR)
+SLOT_INTERFACE_END
diff --git a/src/emu/bus/generic/carts.h b/src/emu/bus/generic/carts.h
new file mode 100644
index 00000000000..efef8a5dfe0
--- /dev/null
+++ b/src/emu/bus/generic/carts.h
@@ -0,0 +1,21 @@
+/**********************************************************************
+
+ Generic ROM/RAM socket slots
+
+**********************************************************************/
+
+#pragma once
+
+#ifndef __GENERIC_CARTS_H__
+#define __GENERIC_CARTS_H__
+
+#include "emu.h"
+
+#include "rom.h"
+#include "ram.h"
+
+
+SLOT_INTERFACE_EXTERN( generic_plain_slot );
+SLOT_INTERFACE_EXTERN( generic_linear_slot );
+
+#endif
diff --git a/src/emu/bus/generic/ram.c b/src/emu/bus/generic/ram.c
new file mode 100644
index 00000000000..4ddfcb119d3
--- /dev/null
+++ b/src/emu/bus/generic/ram.c
@@ -0,0 +1,122 @@
+/***********************************************************************************************************
+
+
+ Generic RAM socket emulation
+
+ This offers generic access to RAM
+
+ generic_ram_plain : returns 0xff when the system reads beyond the end of the RAM
+ generic_ram_linear : maps linearly the RAM in the accessed area (i.e., read/write offset is masked with
+ (RAM size - 1) )
+
+ TODO:
+ - support variable RAM size
+ - possibly support linear mapping when non-power of 2 RAMs are mapped
+ - add support for 16bit & 32bit RAM access
+
+ ***********************************************************************************************************/
+
+
+#include "emu.h"
+#include "ram.h"
+
+//-------------------------------------------------
+// constructor
+//-------------------------------------------------
+
+const device_type GENERIC_RAM_32K_PLAIN = &device_creator<generic_ram_32k_plain_device>;
+const device_type GENERIC_RAM_64K_PLAIN = &device_creator<generic_ram_64k_plain_device>;
+const device_type GENERIC_RAM_128K_PLAIN = &device_creator<generic_ram_128k_plain_device>;
+const device_type GENERIC_RAM_32K_LINEAR = &device_creator<generic_ram_32k_linear_device>;
+const device_type GENERIC_RAM_64K_LINEAR = &device_creator<generic_ram_64k_linear_device>;
+const device_type GENERIC_RAM_128K_LINEAR = &device_creator<generic_ram_128k_linear_device>;
+
+
+generic_ram_plain_device::generic_ram_plain_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
+ device_generic_cart_interface(mconfig, *this),
+ m_size(size)
+{
+}
+
+generic_ram_linear_device::generic_ram_linear_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
+ device_generic_cart_interface(mconfig, *this),
+ m_size(size)
+{
+}
+
+
+generic_ram_32k_plain_device::generic_ram_32k_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_ram_plain_device(mconfig, GENERIC_RAM_32K_PLAIN, "Generic RAM 32K (plain mapping)", tag, owner, clock, 0x8000, "generic_ram32p", __FILE__)
+{
+}
+
+generic_ram_64k_plain_device::generic_ram_64k_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_ram_plain_device(mconfig, GENERIC_RAM_64K_PLAIN, "Generic RAM 64K (plain mapping)", tag, owner, clock, 0x10000, "generic_ram64p", __FILE__)
+{
+}
+
+generic_ram_128k_plain_device::generic_ram_128k_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_ram_plain_device(mconfig, GENERIC_RAM_128K_PLAIN, "Generic RAM 128K (plain mapping)", tag, owner, clock, 0x20000, "generic_ram128p", __FILE__)
+{
+}
+
+generic_ram_32k_linear_device::generic_ram_32k_linear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_ram_linear_device(mconfig, GENERIC_RAM_32K_LINEAR, "Generic RAM 32K (linear mapping)", tag, owner, clock, 0x8000, "generic_ram32l", __FILE__)
+{
+}
+
+generic_ram_64k_linear_device::generic_ram_64k_linear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_ram_linear_device(mconfig, GENERIC_RAM_64K_LINEAR, "Generic RAM 64K (linear mapping)", tag, owner, clock, 0x10000, "generic_ram64l", __FILE__)
+{
+}
+
+generic_ram_128k_linear_device::generic_ram_128k_linear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_ram_linear_device(mconfig, GENERIC_RAM_128K_LINEAR, "Generic RAM 128K (linear mapping)", tag, owner, clock, 0x20000, "generic_ram128l", __FILE__)
+{
+}
+
+
+void generic_ram_plain_device::device_start()
+{
+ m_ram.resize(m_size);
+ save_item(NAME(m_ram));
+}
+
+void generic_ram_linear_device::device_start()
+{
+ m_ram.resize(m_size);
+ save_item(NAME(m_ram));
+}
+
+
+/*-------------------------------------------------
+ mapper specific handlers
+ -------------------------------------------------*/
+
+READ8_MEMBER(generic_ram_plain_device::read_ram)
+{
+ if (offset < m_ram.bytes())
+ return m_ram[offset];
+ else
+ return 0xff;
+}
+
+WRITE8_MEMBER(generic_ram_plain_device::write_ram)
+{
+ if (offset < m_ram.bytes())
+ m_ram[offset] = data;
+}
+
+
+READ8_MEMBER(generic_ram_linear_device::read_ram)
+{
+ return m_ram[offset % m_ram.bytes()];
+}
+
+WRITE8_MEMBER(generic_ram_linear_device::write_ram)
+{
+ m_ram[offset % m_ram.bytes()] = data;
+}
+
diff --git a/src/emu/bus/generic/ram.h b/src/emu/bus/generic/ram.h
new file mode 100644
index 00000000000..f54120694f1
--- /dev/null
+++ b/src/emu/bus/generic/ram.h
@@ -0,0 +1,107 @@
+#ifndef __GENERIC_RAM_H
+#define __GENERIC_RAM_H
+
+#include "slot.h"
+
+
+// ======================> generic_ram_plain_device
+
+class generic_ram_plain_device : public device_t,
+ public device_generic_cart_interface
+{
+public:
+ // construction/destruction
+ generic_ram_plain_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source);
+
+ // device-level overrides
+ virtual void device_start();
+
+ // reading and writing
+ virtual DECLARE_READ8_MEMBER(read_ram);
+ virtual DECLARE_WRITE8_MEMBER(write_ram);
+
+private:
+ UINT32 m_size;
+};
+
+
+// ======================> generic_ram_linear_device
+
+class generic_ram_linear_device : public device_t,
+ public device_generic_cart_interface
+{
+public:
+ // construction/destruction
+ generic_ram_linear_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 size, const char *shortname, const char *source);
+
+ // device-level overrides
+ virtual void device_start();
+
+ // reading and writing
+ virtual DECLARE_READ8_MEMBER(read_ram);
+ virtual DECLARE_WRITE8_MEMBER(write_ram);
+
+private:
+ UINT32 m_size;
+};
+
+
+// ======================> generic_ram_*k_plain_device
+
+class generic_ram_32k_plain_device : public generic_ram_plain_device
+{
+public:
+ // construction/destruction
+ generic_ram_32k_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+};
+
+class generic_ram_64k_plain_device : public generic_ram_plain_device
+{
+public:
+ // construction/destruction
+ generic_ram_64k_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+};
+
+class generic_ram_128k_plain_device : public generic_ram_plain_device
+{
+public:
+ // construction/destruction
+ generic_ram_128k_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+};
+
+
+// ======================> generic_ram_*k_linear_device
+
+class generic_ram_32k_linear_device : public generic_ram_linear_device
+{
+public:
+ // construction/destruction
+ generic_ram_32k_linear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+};
+
+class generic_ram_64k_linear_device : public generic_ram_linear_device
+{
+public:
+ // construction/destruction
+ generic_ram_64k_linear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+};
+
+class generic_ram_128k_linear_device : public generic_ram_linear_device
+{
+public:
+ // construction/destruction
+ generic_ram_128k_linear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+};
+
+
+
+// device type definition
+extern const device_type GENERIC_RAM_32K_PLAIN;
+extern const device_type GENERIC_RAM_64K_PLAIN;
+extern const device_type GENERIC_RAM_128K_PLAIN;
+extern const device_type GENERIC_RAM_32K_LINEAR;
+extern const device_type GENERIC_RAM_64K_LINEAR;
+extern const device_type GENERIC_RAM_128K_LINEAR;
+
+
+#endif
diff --git a/src/emu/bus/generic/rom.c b/src/emu/bus/generic/rom.c
new file mode 100644
index 00000000000..632b6398d5c
--- /dev/null
+++ b/src/emu/bus/generic/rom.c
@@ -0,0 +1,78 @@
+/***********************************************************************************************************
+
+
+ Generic ROM emulation (for carts and ROM sockets)
+
+ This offers generic access to a ROM
+
+ generic_rom_plain : returns 0xff when the system reads beyond the end of the ROM
+ generic_rom_linear : maps linearly the ROM in the accessed area (i.e., read offset is masked with (ROM size - 1) )
+
+ TODO:
+ - possibly support linear mapping when non-power of 2 ROMs are mapped
+ - add support for 32bit ROM access
+
+ ***********************************************************************************************************/
+
+
+#include "emu.h"
+#include "rom.h"
+
+//-------------------------------------------------
+// constructor
+//-------------------------------------------------
+
+const device_type GENERIC_ROM_PLAIN = &device_creator<generic_rom_plain_device>;
+const device_type GENERIC_ROM_LINEAR = &device_creator<generic_rom_linear_device>;
+
+
+generic_rom_device::generic_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_generic_cart_interface(mconfig, *this)
+{
+}
+
+generic_rom_plain_device::generic_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_rom_device(mconfig, GENERIC_ROM_PLAIN, "Generic ROM (plain mapping)", tag, owner, clock, "generic_rom_plain", __FILE__)
+{
+}
+
+generic_rom_linear_device::generic_rom_linear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_rom_device(mconfig, GENERIC_ROM_LINEAR, "Generic ROM (linear mapping)", tag, owner, clock, "generic_rom_linear", __FILE__)
+{
+}
+
+
+/*-------------------------------------------------
+ mapper specific handlers
+ -------------------------------------------------*/
+
+READ8_MEMBER(generic_rom_plain_device::read_rom)
+{
+ if (offset < m_rom_size)
+ return m_rom[offset];
+ else
+ return 0xff;
+}
+
+READ16_MEMBER(generic_rom_plain_device::read16_rom)
+{
+ UINT16 *ROM = (UINT16 *)m_rom;
+ if (offset < m_rom_size/2)
+ return ROM[offset];
+ else
+ return 0xffff;
+}
+
+
+READ8_MEMBER(generic_rom_linear_device::read_rom)
+{
+ return m_rom[offset % m_rom_size];
+}
+
+READ16_MEMBER(generic_rom_linear_device::read16_rom)
+{
+ UINT16 *ROM = (UINT16 *)m_rom;
+ return ROM[offset % (m_rom_size/2)];
+}
+
diff --git a/src/emu/bus/generic/rom.h b/src/emu/bus/generic/rom.h
new file mode 100644
index 00000000000..24f9962d07a
--- /dev/null
+++ b/src/emu/bus/generic/rom.h
@@ -0,0 +1,56 @@
+#ifndef __GENERIC_ROM_H
+#define __GENERIC_ROM_H
+
+#include "slot.h"
+
+
+// ======================> generic_rom_device
+
+class generic_rom_device : public device_t,
+ public device_generic_cart_interface
+{
+public:
+ // construction/destruction
+ generic_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-level overrides
+ virtual void device_start() {}
+};
+
+
+// ======================> generic_rom_plain_device
+
+class generic_rom_plain_device : public generic_rom_device
+{
+public:
+ // construction/destruction
+ generic_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ // reading and writing
+ virtual DECLARE_READ8_MEMBER(read_rom);
+ virtual DECLARE_READ16_MEMBER(read16_rom);
+};
+
+
+// ======================> generic_rom_linear_device
+
+class generic_rom_linear_device : public generic_rom_device
+{
+public:
+ // construction/destruction
+ generic_rom_linear_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ // reading and writing
+ virtual DECLARE_READ8_MEMBER(read_rom);
+ virtual DECLARE_READ16_MEMBER(read16_rom);
+};
+
+
+
+// device type definition
+extern const device_type GENERIC_ROM_PLAIN;
+extern const device_type GENERIC_ROM_LINEAR;
+
+
+
+#endif
diff --git a/src/emu/bus/generic/slot.c b/src/emu/bus/generic/slot.c
new file mode 100644
index 00000000000..f87590d12e6
--- /dev/null
+++ b/src/emu/bus/generic/slot.c
@@ -0,0 +1,236 @@
+/***********************************************************************************************************
+
+ Generic ROM / RAM Socket and Cartslot device
+
+ This device offers basic RAM / ROM allocation and access
+
+ ***********************************************************************************************************/
+
+
+#include "emu.h"
+#include "slot.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+const device_type GENERIC_SOCKET = &device_creator<generic_slot_device>;
+
+
+//-------------------------------------------------
+// device_generic_cart_interface - constructor
+//-------------------------------------------------
+
+device_generic_cart_interface::device_generic_cart_interface(const machine_config &mconfig, device_t &device)
+ : device_slot_card_interface(mconfig, device),
+ m_rom(NULL),
+ m_rom_size(0)
+{
+}
+
+
+//-------------------------------------------------
+// ~device_generic_cart_interface - destructor
+//-------------------------------------------------
+
+device_generic_cart_interface::~device_generic_cart_interface()
+{
+}
+
+//-------------------------------------------------
+// rom_alloc - alloc the space for the cart
+//-------------------------------------------------
+
+void device_generic_cart_interface::rom_alloc(size_t size, int width, const char *tag)
+{
+ if (m_rom == NULL)
+ {
+ astring tempstring(tag);
+ tempstring.cat(":cart:rom");
+ m_rom = device().machine().memory().region_alloc(tempstring, size, width, ENDIANNESS_LITTLE)->base();
+ m_rom_size = size;
+ }
+}
+
+
+//-------------------------------------------------
+// ram_alloc - alloc the space for the ram
+//-------------------------------------------------
+
+void device_generic_cart_interface::ram_alloc(UINT32 size)
+{
+ if (m_ram == NULL)
+ {
+ m_ram.resize(size);
+ device().save_item(NAME(m_ram));
+ }
+}
+
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// generic_slot_device - constructor
+//-------------------------------------------------
+generic_slot_device::generic_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
+ device_t(mconfig, GENERIC_SOCKET, "Generic ROM Socket / RAM Socket / Cartridge Slot", tag, owner, clock, "generic_socket", __FILE__),
+ device_image_interface(mconfig, *this),
+ device_slot_interface(mconfig, *this),
+ m_interface(NULL),
+ m_default_card("rom"),
+ m_extensions("bin"),
+ m_must_be_loaded(FALSE),
+ m_width(GENERIC_ROM8_WIDTH),
+ m_empty(TRUE)
+{
+}
+
+
+//-------------------------------------------------
+// generic_slot_device - destructor
+//-------------------------------------------------
+
+generic_slot_device::~generic_slot_device()
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void generic_slot_device::device_start()
+{
+ m_cart = dynamic_cast<device_generic_cart_interface *>(get_card_device());
+}
+
+//-------------------------------------------------
+// device_config_complete - perform any
+// operations now that the configuration is
+// complete
+//-------------------------------------------------
+
+void generic_slot_device::device_config_complete()
+{
+ // set brief and instance name
+ update_names();
+}
+
+
+/*-------------------------------------------------
+ call load
+ -------------------------------------------------*/
+
+bool generic_slot_device::call_load()
+{
+ if (m_cart)
+ {
+ if (!m_device_image_load.isnull())
+ {
+ int result = m_device_image_load(*this);
+ m_empty = (result == IMAGE_INIT_PASS) ? FALSE : TRUE;
+ return result;
+ }
+ else
+ {
+ UINT32 len = (software_entry() == NULL) ? length() : get_software_region_length("rom");
+ UINT8 *ROM;
+
+ rom_alloc(len, m_width);
+ ROM = get_rom_base();
+
+ if (software_entry() == NULL)
+ fread(ROM, len);
+ else
+ memcpy(ROM, get_software_region("rom"), len);
+
+ m_empty = FALSE;
+
+ return IMAGE_INIT_PASS;
+ }
+ }
+
+ return IMAGE_INIT_PASS;
+}
+
+
+/*-------------------------------------------------
+ call_unload
+ -------------------------------------------------*/
+
+void generic_slot_device::call_unload()
+{
+ if (!m_device_image_unload.isnull())
+ return m_device_image_unload(*this);
+}
+
+
+/*-------------------------------------------------
+ call softlist load
+ -------------------------------------------------*/
+
+bool generic_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 generic_slot_device::get_default_card_software(astring &result)
+{
+ software_get_default_slot(result, m_default_card);
+}
+
+/*-------------------------------------------------
+ read_rom
+ -------------------------------------------------*/
+
+READ8_MEMBER(generic_slot_device::read_rom)
+{
+ if (m_cart)
+ return m_cart->read_rom(space, offset);
+ else
+ return 0xff;
+}
+
+/*-------------------------------------------------
+ read16_rom
+ -------------------------------------------------*/
+
+READ16_MEMBER(generic_slot_device::read16_rom)
+{
+ if (m_cart)
+ return m_cart->read16_rom(space, offset, mem_mask);
+ else
+ return 0xffff;
+}
+
+/*-------------------------------------------------
+ read_ram
+ -------------------------------------------------*/
+
+READ8_MEMBER(generic_slot_device::read_ram)
+{
+ if (m_cart)
+ return m_cart->read_ram(space, offset);
+ else
+ return 0xff;
+}
+
+/*-------------------------------------------------
+ write
+ -------------------------------------------------*/
+
+WRITE8_MEMBER(generic_slot_device::write_ram)
+{
+ if (m_cart)
+ m_cart->write_ram(space, offset, data);
+}
+
diff --git a/src/emu/bus/generic/slot.h b/src/emu/bus/generic/slot.h
new file mode 100644
index 00000000000..73830950944
--- /dev/null
+++ b/src/emu/bus/generic/slot.h
@@ -0,0 +1,165 @@
+#ifndef __GENERIC_SLOT_H
+#define __GENERIC_SLOT_H
+
+/***************************************************************************
+ TYPE DEFINITIONS
+ ***************************************************************************/
+
+
+// ======================> device_generic_cart_interface
+
+class device_generic_cart_interface : public device_slot_card_interface
+{
+public:
+ // construction/destruction
+ device_generic_cart_interface(const machine_config &mconfig, device_t &device);
+ virtual ~device_generic_cart_interface();
+
+ // reading and writing
+ virtual DECLARE_READ8_MEMBER(read_rom) { return 0xff; }
+ virtual DECLARE_READ16_MEMBER(read16_rom) { return 0xffff; }
+
+ virtual DECLARE_READ8_MEMBER(read_ram) { return 0xff; }
+ virtual DECLARE_WRITE8_MEMBER(write_ram) {};
+
+ virtual void rom_alloc(size_t size, int width, const char *tag);
+ virtual void ram_alloc(UINT32 size);
+
+ UINT8* get_rom_base() { return m_rom; }
+ UINT32 get_rom_size() { return m_rom_size; }
+
+ UINT8* get_ram_base() { return m_ram; }
+ UINT32 get_ram_size() { return m_ram.count(); }
+
+ // internal state
+ UINT8 *m_rom;
+ UINT32 m_rom_size;
+ dynamic_buffer m_ram;
+};
+
+
+enum
+{
+ GENERIC_ROM8_WIDTH = 1,
+ GENERIC_ROM16_WIDTH
+};
+
+
+#define MCFG_GENERIC_MANDATORY \
+ static_cast<generic_slot_device *>(device)->set_must_be_loaded(TRUE);
+
+#define MCFG_GENERIC_WIDTH(_width) \
+ static_cast<generic_slot_device *>(device)->set_width(_width);
+
+#define MCFG_GENERIC_DEFAULT_CARD(_def_card) \
+ static_cast<generic_slot_device *>(device)->set_default_card(_def_card);
+
+#define MCFG_GENERIC_INTERFACE(_intf) \
+ static_cast<generic_slot_device *>(device)->set_interface(_intf);
+
+#define MCFG_GENERIC_EXTENSIONS(_ext) \
+ static_cast<generic_slot_device *>(device)->set_extensions(_ext);
+
+#define MCFG_GENERIC_LOAD(_class, _method) \
+ generic_slot_device::static_set_device_load(*device, device_image_load_delegate(&DEVICE_IMAGE_LOAD_NAME(_class,_method), #_class "::device_image_load_" #_method, downcast<_class *>(owner)));
+
+#define MCFG_GENERIC_UNLOAD(_class, _method) \
+ generic_slot_device::static_set_device_unload(*device, device_image_func_delegate(&DEVICE_IMAGE_UNLOAD_NAME(_class,_method), #_class "::device_image_unload_" #_method, downcast<_class *>(owner)));
+
+
+
+typedef device_delegate<void (int layer, int bank, int *code, int *color, int *flags)> generic_load_delegate;
+
+
+// ======================> generic_slot_device
+
+class generic_slot_device : public device_t,
+ public device_image_interface,
+ public device_slot_interface
+{
+public:
+ // construction/destruction
+ generic_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ virtual ~generic_slot_device();
+
+ static void static_set_device_load(device_t &device, device_image_load_delegate callback) { downcast<generic_slot_device &>(device).m_device_image_load = callback; }
+ static void static_set_device_unload(device_t &device, device_image_func_delegate callback) { downcast<generic_slot_device &>(device).m_device_image_unload = callback; }
+
+ void set_interface(const char * interface) { m_interface = interface; }
+ void set_default_card(const char * def) { m_default_card = def; }
+ void set_extensions(const char * exts) { m_extensions = exts; }
+ void set_must_be_loaded(bool mandatory) { m_must_be_loaded = mandatory; }
+ void set_width(int width) { m_width = width; }
+
+ // 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);
+
+ bool cart_mounted() { return !m_empty; }
+
+ 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 m_must_be_loaded; }
+ 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 m_interface; }
+ virtual const char *file_extensions() const { return m_extensions; }
+
+ // slot interface overrides
+ virtual void get_default_card_software(astring &result);
+
+ // reading and writing
+ virtual DECLARE_READ8_MEMBER(read_rom);
+ virtual DECLARE_READ16_MEMBER(read16_rom);
+
+ virtual DECLARE_READ8_MEMBER(read_ram);
+ virtual DECLARE_WRITE8_MEMBER(write_ram);
+
+ virtual void rom_alloc(size_t size, int width) { if (m_cart) m_cart->rom_alloc(size, width, tag()); }
+ virtual void ram_alloc(UINT32 size) { if (m_cart) m_cart->ram_alloc(size); }
+
+ UINT8* get_rom_base() { if (m_cart) return m_cart->get_rom_base(); return NULL; }
+ UINT8* get_ram_base() { if (m_cart) return m_cart->get_ram_base(); return NULL; }
+
+protected:
+
+ const char *m_interface;
+ const char *m_default_card;
+ const char *m_extensions;
+ bool m_must_be_loaded;
+ int m_width;
+ bool m_empty;
+ device_generic_cart_interface *m_cart;
+ device_image_load_delegate m_device_image_load;
+ device_image_func_delegate m_device_image_unload;
+};
+
+
+// device type definition
+extern const device_type GENERIC_SOCKET;
+
+
+/***************************************************************************
+ DEVICE CONFIGURATION MACROS
+ ***************************************************************************/
+
+#define MCFG_GENERIC_CARTSLOT_ADD(_tag, _width, _slot_intf, _dev_intf) \
+ MCFG_DEVICE_ADD(_tag, GENERIC_SOCKET, 0) \
+ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, NULL, false) \
+ MCFG_GENERIC_INTERFACE(_dev_intf) \
+ MCFG_GENERIC_WIDTH(_width)
+
+#define MCFG_GENERIC_SOCKET_ADD(_tag, _width, _slot_intf, _dev_intf) \
+ MCFG_DEVICE_ADD(_tag, GENERIC_SOCKET, 0) \
+ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, NULL, false) \
+ MCFG_GENERIC_INTERFACE(_dev_intf) \
+ MCFG_GENERIC_WIDTH(_width)
+
+#endif
diff --git a/src/mess/drivers/aim65.c b/src/mess/drivers/aim65.c
index ab738bc8bd7..35fc6675685 100644
--- a/src/mess/drivers/aim65.c
+++ b/src/mess/drivers/aim65.c
@@ -144,83 +144,44 @@ INPUT_PORTS_END
MACHINE DRIVERS
***************************************************************************/
-struct aim_cart_range
-{
- const char *tag;
- int offset;
-};
-
-static const struct aim_cart_range aim_cart_table[] =
-{
- { ":z24", 0xd000 },
- { ":z25", 0xc000 },
- { ":z26", 0xb000 },
- { 0 }
-};
-
-DEVICE_IMAGE_LOAD_MEMBER( aim65_state, aim65_cart )
+int aim65_state::load_cart(device_image_interface &image, generic_slot_device *slot, const char *slot_tag)
{
+ UINT8 *cart;
UINT32 size;
- const struct aim_cart_range *aim_cart = &aim_cart_table[0], *this_cart;
-
- /* First, determine where this cart has to be loaded */
- while (aim_cart->tag)
- {
- if (strcmp(aim_cart->tag, image.device().tag()) == 0)
- break;
-
- aim_cart++;
- }
- this_cart = aim_cart;
-
- if (!this_cart->tag)
+ if (image.software_entry() == NULL)
+ size = image.length();
+ else
+ size = image.get_software_region_length("rom");
+
+ if (size > 0x1000)
{
- astring errmsg;
- errmsg.printf("Tag '%s' could not be found", image.device().tag());
- image.seterror(IMAGE_ERROR_UNSPECIFIED, errmsg.cstr());
+ image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
return IMAGE_INIT_FAIL;
}
- dynamic_buffer temp_copy;
- if (image.software_entry() == NULL)
- {
- size = image.length();
+ slot->rom_alloc(size, 1);
+ cart = slot->get_rom_base();
- if (size > 0x1000)
- {
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
- return IMAGE_INIT_FAIL;
- }
-
- temp_copy.resize(size);
- if (image.fread(temp_copy, size) != size)
- {
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file");
- return IMAGE_INIT_FAIL;
- }
- }
+ if (image.software_entry() == NULL)
+ image.fread(cart, size);
else
{
- if (image.get_software_region(this_cart->tag + 1) == NULL)
+ if (image.get_software_region(slot_tag) == NULL)
{
astring errmsg;
- errmsg.printf("Attempted to load file with wrong extension\nCartslot '%s' only accepts files with '.%s' extension",
- this_cart->tag, this_cart->tag + 1);
+ errmsg.printf("Attempted to load file with wrong extension\nSocket '%s' only accepts files with '.%s' extension",
+ slot_tag, slot_tag);
image.seterror(IMAGE_ERROR_UNSPECIFIED, errmsg.cstr());
return IMAGE_INIT_FAIL;
}
-
- size = image.get_software_region_length(this_cart->tag + 1);
- temp_copy.resize(size);
- memcpy(temp_copy, image.get_software_region(this_cart->tag + 1), size);
+ memcpy(cart, image.get_software_region(slot_tag), size);
}
- memcpy(memregion("maincpu")->base() + this_cart->offset, temp_copy, size);
-
return IMAGE_INIT_PASS;
}
+
static MACHINE_CONFIG_START( aim65, aim65_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, AIM65_CLOCK) /* 1 MHz */
@@ -276,23 +237,17 @@ static MACHINE_CONFIG_START( aim65, aim65_state )
MCFG_CASSETTE_ADD( "cassette2" )
MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_RECORD | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_MUTED)
- MCFG_CARTSLOT_ADD("z26")
- MCFG_CARTSLOT_EXTENSION_LIST("z26")
- MCFG_CARTSLOT_INTERFACE("aim65_cart")
- MCFG_CARTSLOT_LOAD(aim65_state, aim65_cart)
- MCFG_CARTSLOT_NOT_MANDATORY
-
- MCFG_CARTSLOT_ADD("z25")
- MCFG_CARTSLOT_EXTENSION_LIST("z25")
- MCFG_CARTSLOT_INTERFACE("aim65_cart")
- MCFG_CARTSLOT_LOAD(aim65_state, aim65_cart)
- MCFG_CARTSLOT_NOT_MANDATORY
-
- MCFG_CARTSLOT_ADD("z24")
- MCFG_CARTSLOT_EXTENSION_LIST("z24")
- MCFG_CARTSLOT_INTERFACE("aim65_cart")
- MCFG_CARTSLOT_NOT_MANDATORY
- MCFG_CARTSLOT_LOAD(aim65_state, aim65_cart)
+ MCFG_GENERIC_SOCKET_ADD("z26", GENERIC_ROM8_WIDTH, generic_plain_slot, "aim65_cart")
+ MCFG_GENERIC_EXTENSIONS("z26")
+ MCFG_GENERIC_LOAD(aim65_state, z26_load)
+
+ MCFG_GENERIC_SOCKET_ADD("z25", GENERIC_ROM8_WIDTH, generic_plain_slot, "aim65_cart")
+ MCFG_GENERIC_EXTENSIONS("z25")
+ MCFG_GENERIC_LOAD(aim65_state, z25_load)
+
+ MCFG_GENERIC_SOCKET_ADD("z24", GENERIC_ROM8_WIDTH, generic_plain_slot, "aim65_cart")
+ MCFG_GENERIC_EXTENSIONS("z24")
+ MCFG_GENERIC_LOAD(aim65_state, z24_load)
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)
diff --git a/src/mess/drivers/gamepock.c b/src/mess/drivers/gamepock.c
index ef2358b5add..71c56092420 100644
--- a/src/mess/drivers/gamepock.c
+++ b/src/mess/drivers/gamepock.c
@@ -3,7 +3,7 @@
#include "emu.h"
#include "cpu/upd7810/upd7810.h"
#include "sound/speaker.h"
-#include "imagedev/cartslot.h"
+#include "bus/generic/carts.h"
#include "includes/gamepock.h"
#include "rendlay.h"
@@ -12,8 +12,8 @@ static ADDRESS_MAP_START(gamepock_mem, AS_PROGRAM, 8, gamepock_state)
ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x0000,0x0fff) AM_ROM
AM_RANGE(0x1000,0x3fff) AM_NOP
- AM_RANGE(0x4000,0xBfff) AM_ROM AM_REGION("user1", 0)
- AM_RANGE(0xC000,0xC7ff) AM_MIRROR(0x0800) AM_RAM
+ //AM_RANGE(0x4000,0xbfff) AM_ROM // mapped by the cartslot
+ AM_RANGE(0xc000,0xc7ff) AM_MIRROR(0x0800) AM_RAM
AM_RANGE(0xff80,0xffff) AM_RAM /* 128 bytes microcontroller RAM */
ADDRESS_MAP_END
@@ -42,26 +42,6 @@ static INPUT_PORTS_START( gamepock )
INPUT_PORTS_END
-DEVICE_IMAGE_LOAD_MEMBER(gamepock_state,gamepock_cart) {
- UINT8 *cart = memregion("user1" )->base();
-
- if ( image.software_entry() == NULL )
- {
- int size = image.length();
- if ( image.fread( cart, size ) != size ) {
- image.seterror( IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file" );
- return IMAGE_INIT_FAIL;
- }
- }
- else
- {
- memcpy( cart, image.get_software_region( "rom" ), image.get_software_region_length("rom") );
- }
-
- return IMAGE_INIT_PASS;
-}
-
-
static MACHINE_CONFIG_START( gamepock, gamepock_state )
MCFG_CPU_ADD("maincpu", UPD78C06, XTAL_6MHz) /* uPD78C06AG */
MCFG_CPU_PROGRAM_MAP( gamepock_mem)
@@ -85,11 +65,7 @@ static MACHINE_CONFIG_START( gamepock, gamepock_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
/* cartridge */
- MCFG_CARTSLOT_ADD("cart")
- MCFG_CARTSLOT_INTERFACE("gamepock_cart")
- MCFG_CARTSLOT_EXTENSION_LIST("bin")
- MCFG_CARTSLOT_NOT_MANDATORY
- MCFG_CARTSLOT_LOAD(gamepock_state,gamepock_cart)
+ MCFG_GENERIC_CARTSLOT_ADD("cartslot", GENERIC_ROM8_WIDTH, generic_plain_slot, "gamepock_cart")
/* Software lists */
MCFG_SOFTWARE_LIST_ADD("cart_list","gamepock")
@@ -99,7 +75,6 @@ MACHINE_CONFIG_END
ROM_START( gamepock )
ROM_REGION( 0x1000, "maincpu", ROMREGION_ERASEFF )
ROM_LOAD( "egpcboot.bin", 0x0000, 0x1000, CRC(ee1ea65d) SHA1(9c7731b5ead721d2cc7f7e2655c5fed9e56db8b0) )
- ROM_REGION( 0x8000, "user1", ROMREGION_ERASEFF )
ROM_END
diff --git a/src/mess/drivers/pv2000.c b/src/mess/drivers/pv2000.c
index 628a7cd9ecc..89638b040f1 100644
--- a/src/mess/drivers/pv2000.c
+++ b/src/mess/drivers/pv2000.c
@@ -30,10 +30,11 @@ For BIOS CRC confirmation
#include "emu.h"
#include "cpu/z80/z80.h"
#include "sound/sn76496.h"
+#include "sound/wave.h"
#include "video/tms9928a.h"
-#include "imagedev/cartslot.h"
#include "imagedev/cassette.h"
-#include "sound/wave.h"
+#include "bus/generic/slot.h"
+#include "bus/generic/carts.h"
class pv2000_state : public driver_device
@@ -41,18 +42,20 @@ class pv2000_state : public driver_device
public:
pv2000_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
- m_maincpu(*this, "maincpu"),
- m_cass(*this, "cassette"),
- m_last_state(0)
- { }
+ m_maincpu(*this, "maincpu"),
+ m_cass(*this, "cassette"),
+ m_cart(*this, "cartslot"),
+ m_last_state(0)
+ { }
required_device<cpu_device> m_maincpu;
required_device<cassette_image_device> m_cass;
- DECLARE_WRITE8_MEMBER(pv2000_cass_conf_w);
- DECLARE_WRITE8_MEMBER(pv2000_keys_w);
- DECLARE_READ8_MEMBER(pv2000_keys_hi_r);
- DECLARE_READ8_MEMBER(pv2000_keys_lo_r);
- DECLARE_READ8_MEMBER(pv2000_keys_mod_r);
+ required_device<generic_slot_device> m_cart;
+ DECLARE_WRITE8_MEMBER(cass_conf_w);
+ DECLARE_WRITE8_MEMBER(keys_w);
+ DECLARE_READ8_MEMBER(keys_hi_r);
+ DECLARE_READ8_MEMBER(keys_lo_r);
+ DECLARE_READ8_MEMBER(keys_mod_r);
DECLARE_WRITE_LINE_MEMBER(pv2000_vdp_interrupt);
DECLARE_READ8_MEMBER(cass_in);
DECLARE_WRITE8_MEMBER(cass_out);
@@ -62,26 +65,26 @@ public:
UINT8 m_cass_conf;
virtual void machine_start();
virtual void machine_reset();
- DECLARE_DEVICE_IMAGE_LOAD_MEMBER( pv2000_cart );
+ DECLARE_DEVICE_IMAGE_LOAD_MEMBER(pv2000_cart);
};
-WRITE8_MEMBER( pv2000_state::pv2000_cass_conf_w )
+WRITE8_MEMBER( pv2000_state::cass_conf_w )
{
- logerror( "%s: pv2000_cass_conf_w %02x\n", machine().describe_context(), data );
+ logerror( "%s: cass_conf_w %02x\n", machine().describe_context(), data );
m_cass_conf = data & 0x0f;
if ( m_cass_conf & 0x01 )
- m_cass->change_state(CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR );
+ m_cass->change_state(CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR);
else
- m_cass->change_state(CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR );
+ m_cass->change_state(CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
}
-WRITE8_MEMBER( pv2000_state::pv2000_keys_w )
+WRITE8_MEMBER( pv2000_state::keys_w )
{
- logerror( "%s: pv2000_keys_w %02x\n", machine().describe_context(), data );
+ logerror( "%s: keys_w %02x\n", machine().describe_context(), data );
m_keyb_column = data & 0x0f;
@@ -89,7 +92,7 @@ WRITE8_MEMBER( pv2000_state::pv2000_keys_w )
}
-READ8_MEMBER( pv2000_state::pv2000_keys_hi_r )
+READ8_MEMBER( pv2000_state::keys_hi_r )
{
UINT8 data = 0;
char kbdrow[6];
@@ -113,7 +116,7 @@ READ8_MEMBER( pv2000_state::pv2000_keys_hi_r )
}
-READ8_MEMBER( pv2000_state::pv2000_keys_lo_r )
+READ8_MEMBER( pv2000_state::keys_lo_r )
{
UINT8 data = 0;
char kbdrow[6];
@@ -140,7 +143,7 @@ READ8_MEMBER( pv2000_state::pv2000_keys_lo_r )
}
-READ8_MEMBER( pv2000_state::pv2000_keys_mod_r )
+READ8_MEMBER( pv2000_state::keys_mod_r )
{
return 0xf0 | ioport( "MOD" )->read();
}
@@ -169,14 +172,14 @@ WRITE8_MEMBER( pv2000_state::cass_out )
/* Memory Maps */
static ADDRESS_MAP_START( pv2000_map, AS_PROGRAM, 8, pv2000_state )
- AM_RANGE(0x0000, 0x3FFF) AM_ROM
+ AM_RANGE(0x0000, 0x3fff) AM_ROM
AM_RANGE(0x4000, 0x4000) AM_DEVREADWRITE("tms9928a", tms9928a_device, vram_read, vram_write)
AM_RANGE(0x4001, 0x4001) AM_DEVREADWRITE("tms9928a", tms9928a_device, register_read, register_write)
- AM_RANGE(0x7000, 0x7FFF) AM_RAM
- //AM_RANGE(0x8000, 0xBFFF) ext ram?
- AM_RANGE(0xC000, 0xFFFF) AM_ROM //cart
+ AM_RANGE(0x7000, 0x7fff) AM_RAM
+ //AM_RANGE(0x8000, 0xbfff) ext ram?
+ //AM_RANGE(0xc000, 0xffff) // mapped by the cartslot
ADDRESS_MAP_END
@@ -184,14 +187,14 @@ static ADDRESS_MAP_START( pv2000_io_map, AS_IO, 8, pv2000_state )
ADDRESS_MAP_GLOBAL_MASK(0xff)
//theres also printer and tape I/O (TODO)
- AM_RANGE(0x00, 0x00) AM_WRITE(pv2000_cass_conf_w)
+ AM_RANGE(0x00, 0x00) AM_WRITE(cass_conf_w)
//keyboard/joystick
- AM_RANGE(0x10, 0x10) AM_READ(pv2000_keys_hi_r)
- AM_RANGE(0x20, 0x20) AM_READWRITE(pv2000_keys_lo_r, pv2000_keys_w)
+ AM_RANGE(0x10, 0x10) AM_READ(keys_hi_r)
+ AM_RANGE(0x20, 0x20) AM_READWRITE(keys_lo_r, keys_w)
//sn76489a
- AM_RANGE(0x40, 0x40) AM_READ(pv2000_keys_mod_r) AM_DEVWRITE("sn76489a", sn76489a_device, write)
+ AM_RANGE(0x40, 0x40) AM_READ(keys_mod_r) AM_DEVWRITE("sn76489a", sn76489a_device, write)
/* Cassette input. Gets hit a lot after a GLOAD command */
AM_RANGE(0x60, 0x60) AM_READWRITE(cass_in,cass_out)
@@ -341,6 +344,8 @@ WRITE_LINE_MEMBER( pv2000_state::pv2000_vdp_interrupt )
void pv2000_state::machine_start()
{
+ if (m_cart->cart_mounted())
+ m_maincpu->space(AS_PROGRAM).install_read_handler(0xc000, 0xffff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_cart));
}
void pv2000_state::machine_reset()
@@ -355,31 +360,28 @@ void pv2000_state::machine_reset()
DEVICE_IMAGE_LOAD_MEMBER( pv2000_state, pv2000_cart )
{
- UINT8 *cart = memregion("maincpu")->base() + 0xC000;
+ UINT8 *cart;
UINT32 size;
-
+
if (image.software_entry() == NULL)
size = image.length();
else
size = image.get_software_region_length("rom");
-
+
if (size != 0x2000 && size != 0x4000)
{
image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
return IMAGE_INIT_FAIL;
}
-
+
+ m_cart->rom_alloc(size, 1);
+ cart = m_cart->get_rom_base();
+
if (image.software_entry() == NULL)
- {
- if (image.fread( cart, size) != size)
- {
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file");
- return IMAGE_INIT_FAIL;
- }
- }
+ image.fread(cart, size);
else
memcpy(cart, image.get_software_region("rom"), size);
-
+
return IMAGE_INIT_PASS;
}
@@ -391,7 +393,6 @@ static MACHINE_CONFIG_START( pv2000, pv2000_state )
MCFG_CPU_PROGRAM_MAP(pv2000_map)
MCFG_CPU_IO_MAP(pv2000_io_map)
-
// video hardware
MCFG_DEVICE_ADD( "tms9928a", TMS9928A, XTAL_10_738635MHz / 2 )
MCFG_TMS9928A_VRAM_SIZE(0x4000)
@@ -413,11 +414,9 @@ static MACHINE_CONFIG_START( pv2000, pv2000_state )
MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED)
/* cartridge */
- MCFG_CARTSLOT_ADD("cart")
- MCFG_CARTSLOT_EXTENSION_LIST("rom,col,bin")
- MCFG_CARTSLOT_NOT_MANDATORY
- MCFG_CARTSLOT_LOAD(pv2000_state,pv2000_cart)
- MCFG_CARTSLOT_INTERFACE("pv2000_cart")
+ MCFG_GENERIC_CARTSLOT_ADD("cartslot", GENERIC_ROM8_WIDTH, generic_plain_slot, "pv2000_cart")
+ MCFG_GENERIC_EXTENSIONS("bin,rom,col")
+ MCFG_GENERIC_LOAD(pv2000_state, pv2000_cart)
/* Software lists */
MCFG_SOFTWARE_LIST_ADD("cart_list","pv2000")
@@ -429,7 +428,6 @@ MACHINE_CONFIG_END
ROM_START (pv2000)
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "hn613128pc64.bin", 0x0000, 0x4000, CRC(8f31f297) SHA1(94b5f54dd7bce321e377fdaaf592acd3870cf621) )
- ROM_CART_LOAD("cart", 0xC000, 0x4000, ROM_OPTIONAL)
ROM_END
diff --git a/src/mess/drivers/rx78.c b/src/mess/drivers/rx78.c
index b2b02ea0ff5..f5089ef4091 100644
--- a/src/mess/drivers/rx78.c
+++ b/src/mess/drivers/rx78.c
@@ -43,10 +43,11 @@
#include "emu.h"
#include "cpu/z80/z80.h"
#include "sound/sn76496.h"
-#include "imagedev/cartslot.h"
#include "imagedev/cassette.h"
#include "sound/wave.h"
#include "machine/ram.h"
+#include "bus/generic/slot.h"
+#include "bus/generic/carts.h"
class rx78_state : public driver_device
@@ -56,6 +57,7 @@ public:
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_cass(*this, "cassette"),
+ m_cart(*this, "cartslot"),
m_ram(*this, RAM_TAG),
m_palette(*this, "palette")
{ }
@@ -82,6 +84,7 @@ public:
DECLARE_DRIVER_INIT(rx78);
required_device<cpu_device> m_maincpu;
required_device<cassette_image_device> m_cass;
+ required_device<generic_slot_device> m_cart;
required_device<ram_device> m_ram;
required_device<palette_device> m_palette;
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( rx78_cart );
@@ -256,7 +259,7 @@ WRITE8_MEMBER( rx78_state::vdp_pri_mask_w )
static ADDRESS_MAP_START(rx78_mem, AS_PROGRAM, 8, rx78_state)
ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x0000, 0x1fff) AM_ROM
- AM_RANGE(0x2000, 0x5fff) AM_ROM AM_REGION("cart_img", 0x0000)
+ //AM_RANGE(0x2000, 0x5fff) // mapped by the cartslot
AM_RANGE(0x6000, 0xafff) AM_RAM //ext RAM
AM_RANGE(0xb000, 0xebff) AM_RAM
AM_RANGE(0xec00, 0xffff) AM_READWRITE(rx78_vram_r, rx78_vram_w)
@@ -406,11 +409,14 @@ INPUT_PORTS_END
void rx78_state::machine_reset()
{
+ address_space &prg = m_maincpu->space(AS_PROGRAM);
+ if (m_cart->cart_mounted())
+ prg.install_read_handler(0x2000, 0x5fff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_cart));
}
DEVICE_IMAGE_LOAD_MEMBER( rx78_state, rx78_cart )
{
- UINT8 *cart = memregion("cart_img")->base();
+ UINT8 *cart;
UINT32 size;
if (image.software_entry() == NULL)
@@ -423,18 +429,15 @@ DEVICE_IMAGE_LOAD_MEMBER( rx78_state, rx78_cart )
image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
return IMAGE_INIT_FAIL;
}
-
+
+ m_cart->rom_alloc(size, 1);
+ cart = m_cart->get_rom_base();
+
if (image.software_entry() == NULL)
- {
- if (image.fread( cart, size) != size)
- {
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file");
- return IMAGE_INIT_FAIL;
- }
- }
+ image.fread(cart, size);
else
memcpy(cart, image.get_software_region("rom"), size);
-
+
return IMAGE_INIT_PASS;
}
@@ -476,11 +479,9 @@ static MACHINE_CONFIG_START( rx78, rx78_state )
MCFG_PALETTE_ADD("palette", 16+1) //+1 for the background color
MCFG_GFXDECODE_ADD("gfxdecode", "palette", rx78)
- MCFG_CARTSLOT_ADD("cart")
- MCFG_CARTSLOT_EXTENSION_LIST("rom")
- MCFG_CARTSLOT_NOT_MANDATORY
- MCFG_CARTSLOT_LOAD(rx78_state,rx78_cart)
- MCFG_CARTSLOT_INTERFACE("rx78_cart")
+ MCFG_GENERIC_CARTSLOT_ADD("cartslot", GENERIC_ROM8_WIDTH, generic_plain_slot, "rx78_cart")
+ MCFG_GENERIC_EXTENSIONS("bin,rom")
+ MCFG_GENERIC_LOAD(rx78_state, rx78_cart)
MCFG_RAM_ADD(RAM_TAG)
MCFG_RAM_DEFAULT_SIZE("32k")
@@ -505,9 +506,6 @@ ROM_START( rx78 )
ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
ROM_LOAD( "ipl.rom", 0x0000, 0x2000, CRC(a194ea53) SHA1(ba39e73e6eb7cbb8906fff1f81a98964cd62af0d))
- ROM_REGION( 0x4000, "cart_img", ROMREGION_ERASEFF )
- ROM_CART_LOAD("cart", 0x0000, 0x4000, ROM_OPTIONAL | ROM_NOMIRROR)
-
ROM_REGION( 6 * 0x2000, "vram", ROMREGION_ERASE00 )
ROM_END
@@ -516,7 +514,7 @@ DRIVER_INIT_MEMBER(rx78_state,rx78)
UINT32 ram_size = m_ram->size();
address_space &prg = m_maincpu->space(AS_PROGRAM);
- if(ram_size == 0x4000)
+ if (ram_size == 0x4000)
prg.unmap_readwrite(0x6000, 0xafff);
}
diff --git a/src/mess/drivers/supracan.c b/src/mess/drivers/supracan.c
index 4aeef158d22..3b64547d14f 100644
--- a/src/mess/drivers/supracan.c
+++ b/src/mess/drivers/supracan.c
@@ -78,8 +78,8 @@ DEBUG TRICKS:
#include "emu.h"
#include "cpu/m68000/m68000.h"
#include "cpu/m6502/m6502.h"
-#include "imagedev/cartslot.h"
-//#include "debugger.h"
+#include "bus/generic/slot.h"
+#include "bus/generic/carts.h"
#define SOUNDCPU_BOOT_HACK (1)
@@ -119,6 +119,7 @@ public:
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_soundcpu(*this, "soundcpu"),
+ m_cart(*this, "cartslot"),
m_soundram(*this, "soundram"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette")
@@ -128,22 +129,22 @@ public:
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_soundcpu;
- DECLARE_READ16_MEMBER(supracan_68k_soundram_r);
- DECLARE_WRITE16_MEMBER(supracan_68k_soundram_w);
- DECLARE_READ8_MEMBER(supracan_6502_soundmem_r);
- DECLARE_WRITE8_MEMBER(supracan_6502_soundmem_w);
-
- void supracan_dma_w(address_space &space, int offset, UINT16 data, UINT16 mem_mask, int ch);
- WRITE16_MEMBER( supracan_dma_channel0_w );
- WRITE16_MEMBER( supracan_dma_channel1_w );
-
- DECLARE_WRITE16_MEMBER(supracan_dma_w);
- DECLARE_READ16_MEMBER(supracan_sound_r);
- DECLARE_WRITE16_MEMBER(supracan_sound_w);
- DECLARE_READ16_MEMBER(supracan_video_r);
- DECLARE_WRITE16_MEMBER(supracan_video_w);
- DECLARE_READ16_MEMBER(supracan_vram_r);
- DECLARE_WRITE16_MEMBER(supracan_vram_w);
+ required_device<generic_slot_device> m_cart;
+ DECLARE_READ16_MEMBER(_68k_soundram_r);
+ DECLARE_WRITE16_MEMBER(_68k_soundram_w);
+ DECLARE_READ8_MEMBER(_6502_soundmem_r);
+ DECLARE_WRITE8_MEMBER(_6502_soundmem_w);
+
+ void dma_w(address_space &space, int offset, UINT16 data, UINT16 mem_mask, int ch);
+ DECLARE_WRITE16_MEMBER(dma_channel0_w);
+ DECLARE_WRITE16_MEMBER(dma_channel1_w);
+
+ DECLARE_READ16_MEMBER(sound_r);
+ DECLARE_WRITE16_MEMBER(sound_w);
+ DECLARE_READ16_MEMBER(video_r);
+ DECLARE_WRITE16_MEMBER(video_w);
+ DECLARE_READ16_MEMBER(vram_r);
+ DECLARE_WRITE16_MEMBER(vram_w);
DECLARE_WRITE16_MEMBER(paletteram_w);
acan_dma_regs_t m_acan_dma_regs;
acan_sprdma_regs_t m_acan_sprdma_regs;
@@ -997,7 +998,7 @@ UINT32 supracan_state::screen_update_supracan(screen_device &screen, bitmap_ind1
}
-void supracan_state::supracan_dma_w(address_space &space, int offset, UINT16 data, UINT16 mem_mask, int ch)
+void supracan_state::dma_w(address_space &space, int offset, UINT16 data, UINT16 mem_mask, int ch)
{
acan_dma_regs_t *acan_dma_regs = &m_acan_dma_regs;
address_space &mem = m_maincpu->space(AS_PROGRAM);
@@ -1005,36 +1006,36 @@ void supracan_state::supracan_dma_w(address_space &space, int offset, UINT16 dat
switch(offset)
{
case 0x00/2: // Source address MSW
- verboselog("maincpu", 0, "supracan_dma_w: source msw %d: %04x\n", ch, data);
+ verboselog("maincpu", 0, "dma_w: source msw %d: %04x\n", ch, data);
acan_dma_regs->source[ch] &= 0x0000ffff;
acan_dma_regs->source[ch] |= data << 16;
break;
case 0x02/2: // Source address LSW
- verboselog("maincpu", 0, "supracan_dma_w: source lsw %d: %04x\n", ch, data);
+ verboselog("maincpu", 0, "dma_w: source lsw %d: %04x\n", ch, data);
acan_dma_regs->source[ch] &= 0xffff0000;
acan_dma_regs->source[ch] |= data;
break;
case 0x04/2: // Destination address MSW
- verboselog("maincpu", 0, "supracan_dma_w: dest msw %d: %04x\n", ch, data);
+ verboselog("maincpu", 0, "dma_w: dest msw %d: %04x\n", ch, data);
acan_dma_regs->dest[ch] &= 0x0000ffff;
acan_dma_regs->dest[ch] |= data << 16;
break;
case 0x06/2: // Destination address LSW
- verboselog("maincpu", 0, "supracan_dma_w: dest lsw %d: %04x\n", ch, data);
+ verboselog("maincpu", 0, "dma_w: dest lsw %d: %04x\n", ch, data);
acan_dma_regs->dest[ch] &= 0xffff0000;
acan_dma_regs->dest[ch] |= data;
break;
case 0x08/2: // Byte count
- verboselog("maincpu", 0, "supracan_dma_w: count %d: %04x\n", ch, data);
+ verboselog("maincpu", 0, "dma_w: count %d: %04x\n", ch, data);
acan_dma_regs->count[ch] = data;
break;
case 0x0a/2: // Control
- verboselog("maincpu", 0, "supracan_dma_w: control %d: %04x\n", ch, data);
+ verboselog("maincpu", 0, "dma_w: control %d: %04x\n", ch, data);
if(data & 0x8800)
{
// if(data & 0x2000)
// acan_dma_regs->source-=2;
- logerror("supracan_dma_w: Kicking off a DMA from %08x to %08x, %d bytes (%04x)\n", acan_dma_regs->source[ch], acan_dma_regs->dest[ch], acan_dma_regs->count[ch] + 1, data);
+ logerror("dma_w: Kicking off a DMA from %08x to %08x, %d bytes (%04x)\n", acan_dma_regs->source[ch], acan_dma_regs->dest[ch], acan_dma_regs->count[ch] + 1, data);
for(int i = 0; i <= acan_dma_regs->count[ch]; i++)
{
@@ -1057,24 +1058,24 @@ void supracan_state::supracan_dma_w(address_space &space, int offset, UINT16 dat
}
else if(data != 0x0000) // fake DMA, used by C.U.G.
{
- verboselog("maincpu", 0, "supracan_dma_w: Unknown DMA kickoff value of %04x (other regs %08x, %08x, %d)\n", data, acan_dma_regs->source[ch], acan_dma_regs->dest[ch], acan_dma_regs->count[ch] + 1);
- fatalerror("supracan_dma_w: Unknown DMA kickoff value of %04x (other regs %08x, %08x, %d)\n",data, acan_dma_regs->source[ch], acan_dma_regs->dest[ch], acan_dma_regs->count[ch] + 1);
+ verboselog("maincpu", 0, "dma_w: Unknown DMA kickoff value of %04x (other regs %08x, %08x, %d)\n", data, acan_dma_regs->source[ch], acan_dma_regs->dest[ch], acan_dma_regs->count[ch] + 1);
+ fatalerror("dma_w: Unknown DMA kickoff value of %04x (other regs %08x, %08x, %d)\n",data, acan_dma_regs->source[ch], acan_dma_regs->dest[ch], acan_dma_regs->count[ch] + 1);
}
break;
default:
- verboselog("maincpu", 0, "supracan_dma_w: Unknown register: %08x = %04x & %04x\n", 0xe90020 + (offset << 1), data, mem_mask);
+ verboselog("maincpu", 0, "dma_w: Unknown register: %08x = %04x & %04x\n", 0xe90020 + (offset << 1), data, mem_mask);
break;
}
}
-WRITE16_MEMBER( supracan_state::supracan_dma_channel0_w )
+WRITE16_MEMBER( supracan_state::dma_channel0_w )
{
- supracan_dma_w(space,offset,data,mem_mask,0);
+ dma_w(space, offset, data, mem_mask, 0);
}
-WRITE16_MEMBER( supracan_state::supracan_dma_channel1_w )
+WRITE16_MEMBER( supracan_state::dma_channel1_w )
{
- supracan_dma_w(space,offset,data,mem_mask,1);
+ dma_w(space, offset, data, mem_mask, 1);
}
@@ -1095,13 +1096,13 @@ void supracan_state::write_swapped_byte( int offset, UINT8 byte )
}
-READ16_MEMBER( supracan_state::supracan_vram_r )
+READ16_MEMBER( supracan_state::vram_r )
{
return m_vram[offset];
}
-WRITE16_MEMBER( supracan_state::supracan_vram_w )
+WRITE16_MEMBER( supracan_state::vram_w )
{
COMBINE_DATA(&m_vram[offset]);
@@ -1124,23 +1125,23 @@ WRITE16_MEMBER( supracan_state::supracan_vram_w )
}
static ADDRESS_MAP_START( supracan_mem, AS_PROGRAM, 16, supracan_state )
- AM_RANGE( 0x000000, 0x3fffff ) AM_ROM AM_REGION( "cart", 0 )
+ //AM_RANGE( 0x000000, 0x3fffff ) // mapped by the cartslot
AM_RANGE( 0xe80200, 0xe80201 ) AM_READ_PORT("P1")
AM_RANGE( 0xe80202, 0xe80203 ) AM_READ_PORT("P2")
AM_RANGE( 0xe80208, 0xe80209 ) AM_READ_PORT("P3")
AM_RANGE( 0xe8020c, 0xe8020d ) AM_READ_PORT("P4")
- AM_RANGE( 0xe80000, 0xe8ffff ) AM_READWRITE( supracan_68k_soundram_r, supracan_68k_soundram_w )
- AM_RANGE( 0xe90000, 0xe9001f ) AM_READWRITE( supracan_sound_r, supracan_sound_w )
- AM_RANGE( 0xe90020, 0xe9002f ) AM_WRITE( supracan_dma_channel0_w )
- AM_RANGE( 0xe90030, 0xe9003f ) AM_WRITE( supracan_dma_channel1_w )
+ AM_RANGE( 0xe80000, 0xe8ffff ) AM_READWRITE(_68k_soundram_r, _68k_soundram_w)
+ AM_RANGE( 0xe90000, 0xe9001f ) AM_READWRITE(sound_r, sound_w)
+ AM_RANGE( 0xe90020, 0xe9002f ) AM_WRITE(dma_channel0_w)
+ AM_RANGE( 0xe90030, 0xe9003f ) AM_WRITE(dma_channel1_w)
- AM_RANGE( 0xf00000, 0xf001ff ) AM_READWRITE( supracan_video_r, supracan_video_w )
+ AM_RANGE( 0xf00000, 0xf001ff ) AM_READWRITE(video_r, video_w)
AM_RANGE( 0xf00200, 0xf003ff ) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
- AM_RANGE( 0xf40000, 0xf5ffff ) AM_READWRITE(supracan_vram_r, supracan_vram_w)
+ AM_RANGE( 0xf40000, 0xf5ffff ) AM_READWRITE(vram_r, vram_w)
AM_RANGE( 0xfc0000, 0xfdffff ) AM_MIRROR(0x30000) AM_RAM /* System work ram */
ADDRESS_MAP_END
-READ8_MEMBER( supracan_state::supracan_6502_soundmem_r )
+READ8_MEMBER( supracan_state::_6502_soundmem_r )
{
address_space &mem = m_maincpu->space(AS_PROGRAM);
UINT8 data = m_soundram[offset];
@@ -1199,7 +1200,7 @@ READ8_MEMBER( supracan_state::supracan_6502_soundmem_r )
return data;
}
-WRITE8_MEMBER( supracan_state::supracan_6502_soundmem_w )
+WRITE8_MEMBER( supracan_state::_6502_soundmem_w )
{
switch(offset)
{
@@ -1236,7 +1237,7 @@ WRITE8_MEMBER( supracan_state::supracan_6502_soundmem_w )
}
static ADDRESS_MAP_START( supracan_sound_mem, AS_PROGRAM, 8, supracan_state )
- AM_RANGE( 0x0000, 0xffff ) AM_READWRITE(supracan_6502_soundmem_r, supracan_6502_soundmem_w) AM_SHARE("soundram")
+ AM_RANGE(0x0000, 0xffff) AM_READWRITE(_6502_soundmem_r, _6502_soundmem_w) AM_SHARE("soundram")
ADDRESS_MAP_END
static INPUT_PORTS_START( supracan )
@@ -1369,7 +1370,7 @@ PALETTE_INIT_MEMBER(supracan_state, supracan)
//#endif
}
-WRITE16_MEMBER( supracan_state::supracan_68k_soundram_w )
+WRITE16_MEMBER( supracan_state::_68k_soundram_w )
{
address_space &mem = m_maincpu->space(AS_PROGRAM);
m_soundram[offset*2 + 1] = data & 0xff;
@@ -1380,19 +1381,19 @@ WRITE16_MEMBER( supracan_state::supracan_68k_soundram_w )
if(mem_mask & 0xff00)
{
m_hack_68k_to_6502_access = true;
- supracan_6502_soundmem_w(mem, offset*2, data >> 8);
+ _6502_soundmem_w(mem, offset*2, data >> 8);
m_hack_68k_to_6502_access = false;
}
if(mem_mask & 0x00ff)
{
m_hack_68k_to_6502_access = true;
- supracan_6502_soundmem_w(mem, offset*2 + 1, data & 0xff);
+ _6502_soundmem_w(mem, offset*2 + 1, data & 0xff);
m_hack_68k_to_6502_access = false;
}
}
}
-READ16_MEMBER( supracan_state::supracan_68k_soundram_r )
+READ16_MEMBER( supracan_state::_68k_soundram_r )
{
address_space &mem = m_maincpu->space(AS_PROGRAM);
UINT16 val = m_soundram[offset*2 + 0] << 8;
@@ -1404,13 +1405,13 @@ READ16_MEMBER( supracan_state::supracan_68k_soundram_r )
if(mem_mask & 0xff00)
{
m_hack_68k_to_6502_access = true;
- val |= supracan_6502_soundmem_r(mem, offset*2) << 8;
+ val |= _6502_soundmem_r(mem, offset*2) << 8;
m_hack_68k_to_6502_access = false;
}
if(mem_mask & 0x00ff)
{
m_hack_68k_to_6502_access = true;
- val |= supracan_6502_soundmem_r(mem, offset*2 + 1);
+ val |= _6502_soundmem_r(mem, offset*2 + 1);
m_hack_68k_to_6502_access = false;
}
}
@@ -1418,21 +1419,21 @@ READ16_MEMBER( supracan_state::supracan_68k_soundram_r )
return val;
}
-READ16_MEMBER( supracan_state::supracan_sound_r )
+READ16_MEMBER( supracan_state::sound_r )
{
UINT16 data = 0;
switch( offset )
{
default:
- verboselog("maincpu", 0, "supracan_sound_r: Unknown register: (%08x) & %04x\n", 0xe90000 + (offset << 1), mem_mask);
+ verboselog("maincpu", 0, "sound_r: Unknown register: (%08x) & %04x\n", 0xe90000 + (offset << 1), mem_mask);
break;
}
return data;
}
-WRITE16_MEMBER( supracan_state::supracan_sound_w )
+WRITE16_MEMBER( supracan_state::sound_w )
{
switch ( offset )
{
@@ -1460,13 +1461,13 @@ WRITE16_MEMBER( supracan_state::supracan_sound_w )
verboselog("maincpu", 0, "sound cpu ctrl: %04x\n", data);
break;
default:
- verboselog("maincpu", 0, "supracan_sound_w: Unknown register: %08x = %04x & %04x\n", 0xe90000 + (offset << 1), data, mem_mask);
+ verboselog("maincpu", 0, "sound_w: Unknown register: %08x = %04x & %04x\n", 0xe90000 + (offset << 1), data, mem_mask);
break;
}
}
-READ16_MEMBER( supracan_state::supracan_video_r )
+READ16_MEMBER( supracan_state::video_r )
{
address_space &mem = m_maincpu->space(AS_PROGRAM);
UINT16 data = m_video_regs[offset];
@@ -1495,7 +1496,7 @@ READ16_MEMBER( supracan_state::supracan_video_r )
if(!mem.debugger_access()) verboselog("maincpu", 0, "read tilemap_flags[1] (%04x)\n", data);
break;
default:
- if(!mem.debugger_access()) verboselog("maincpu", 0, "supracan_video_r: Unknown register: %08x (%04x & %04x)\n", 0xf00000 + (offset << 1), data, mem_mask);
+ if(!mem.debugger_access()) verboselog("maincpu", 0, "video_r: Unknown register: %08x (%04x & %04x)\n", 0xf00000 + (offset << 1), data, mem_mask);
break;
}
@@ -1562,7 +1563,7 @@ TIMER_CALLBACK_MEMBER(supracan_state::supracan_video_callback)
m_video_timer->adjust( machine().first_screen()->time_until_pos( ( vpos + 1 ) % 256, 0 ) );
}
-WRITE16_MEMBER( supracan_state::supracan_video_w )
+WRITE16_MEMBER( supracan_state::video_w )
{
address_space &mem = m_maincpu->space(AS_PROGRAM);
acan_sprdma_regs_t *acan_sprdma_regs = &m_acan_sprdma_regs;
@@ -1609,7 +1610,7 @@ WRITE16_MEMBER( supracan_state::supracan_video_w )
acan_sprdma_regs->src_inc = data;
break;
case 0x1e/2:
- logerror( "supracan_video_w: Kicking off a DMA from %08x to %08x, %d bytes (%04x)\n", acan_sprdma_regs->src, acan_sprdma_regs->dst, acan_sprdma_regs->count, data);
+ logerror( "video_w: Kicking off a DMA from %08x to %08x, %d bytes (%04x)\n", acan_sprdma_regs->src, acan_sprdma_regs->dst, acan_sprdma_regs->count, data);
/* TODO: what's 0x2000 and 0x4000 for? */
if(data & 0x8000)
@@ -1642,7 +1643,7 @@ WRITE16_MEMBER( supracan_state::supracan_video_w )
}
else
{
- verboselog("maincpu", 0, "supracan_dma_w: Attempting to kick off a DMA without bit 15 set! (%04x)\n", data);
+ verboselog("maincpu", 0, "dma_w: Attempting to kick off a DMA without bit 15 set! (%04x)\n", data);
}
break;
case 0x08/2:
@@ -1743,7 +1744,7 @@ WRITE16_MEMBER( supracan_state::supracan_video_w )
verboselog("maincpu", 3, "irq_mask = %04x\n", data);
break;
default:
- verboselog("maincpu", 0, "supracan_video_w: Unknown register: %08x = %04x & %04x\n", 0xf00000 + (offset << 1), data, mem_mask);
+ verboselog("maincpu", 0, "video_w: Unknown register: %08x = %04x & %04x\n", 0xf00000 + (offset << 1), data, mem_mask);
break;
}
// m_video_regs[offset] = data;
@@ -1752,31 +1753,28 @@ WRITE16_MEMBER( supracan_state::supracan_video_w )
DEVICE_IMAGE_LOAD_MEMBER( supracan_state, supracan_cart )
{
- UINT8 *cart = memregion("cart")->base();
- UINT32 size = 0;
-
+ UINT8 *cart;
+ UINT32 size;
+
if (image.software_entry() == NULL)
- {
size = image.length();
-
- if (size > 0x400000)
- {
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
- return IMAGE_INIT_FAIL;
- }
-
- if (image.fread(cart, size) != size)
- {
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file");
- return IMAGE_INIT_FAIL;
- }
- }
else
- {
size = image.get_software_region_length("rom");
- memcpy(cart, image.get_software_region("rom"), size);
+
+ if (size > 0x400000)
+ {
+ image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
+ return IMAGE_INIT_FAIL;
}
-
+
+ m_cart->rom_alloc(size, 1);
+ cart = m_cart->get_rom_base();
+
+ if (image.software_entry() == NULL)
+ image.fread(cart, size);
+ else
+ memcpy(cart, image.get_software_region("rom"), size);
+
return IMAGE_INIT_PASS;
}
@@ -1787,6 +1785,9 @@ void supracan_state::machine_start()
m_hbl_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supracan_state::supracan_hbl_callback),this));
m_line_on_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supracan_state::supracan_line_on_callback),this));
m_line_off_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supracan_state::supracan_line_off_callback),this));
+
+ if (m_cart->cart_mounted())
+ m_maincpu->space(AS_PROGRAM).install_read_handler(0x000000, 0x3fffff, read16_delegate(FUNC(generic_slot_device::read16_rom),(generic_slot_device*)m_cart));
}
@@ -1920,7 +1921,6 @@ static MACHINE_CONFIG_START( supracan, supracan_state )
MCFG_QUANTUM_PERFECT_CPU("soundcpu")
#endif
-
MCFG_SCREEN_ADD( "screen", RASTER )
MCFG_SCREEN_RAW_PARAMS(XTAL_10_738635MHz/2, 348, 0, 256, 256, 0, 240 ) /* No idea if this is correct */
MCFG_SCREEN_UPDATE_DRIVER(supracan_state, screen_update_supracan)
@@ -1932,17 +1932,14 @@ static MACHINE_CONFIG_START( supracan, supracan_state )
MCFG_GFXDECODE_ADD("gfxdecode", "palette", supracan)
- MCFG_CARTSLOT_ADD("cart")
- MCFG_CARTSLOT_EXTENSION_LIST("bin")
- MCFG_CARTSLOT_INTERFACE("supracan_cart")
- MCFG_CARTSLOT_LOAD(supracan_state,supracan_cart)
+ MCFG_GENERIC_CARTSLOT_ADD("cartslot", GENERIC_ROM16_WIDTH, generic_plain_slot, "supracan_cart")
+ MCFG_GENERIC_LOAD(supracan_state, supracan_cart)
MCFG_SOFTWARE_LIST_ADD("cart_list","supracan")
MACHINE_CONFIG_END
ROM_START( supracan )
- ROM_REGION( 0x400000, "cart", ROMREGION_ERASEFF )
ROM_REGION( 0x20000, "ram_gfx", ROMREGION_ERASEFF )
ROM_REGION( 0x20000, "ram_gfx2", ROMREGION_ERASEFF )
ROM_REGION( 0x20000, "ram_gfx3", ROMREGION_ERASEFF )
diff --git a/src/mess/includes/aim65.h b/src/mess/includes/aim65.h
index fec6d81df8c..5a33c3cc488 100644
--- a/src/mess/includes/aim65.h
+++ b/src/mess/includes/aim65.h
@@ -16,9 +16,10 @@
#include "machine/6532riot.h"
#include "machine/6821pia.h"
#include "machine/ram.h"
-#include "imagedev/cartslot.h"
#include "imagedev/cassette.h"
#include "sound/wave.h"
+#include "bus/generic/slot.h"
+#include "bus/generic/carts.h"
/** R6502 Clock.
@@ -38,6 +39,9 @@ public:
m_maincpu(*this, "maincpu"),
m_cassette1(*this, "cassette"),
m_cassette2(*this, "cassette2"),
+ m_z24(*this, "z24"),
+ m_z25(*this, "z25"),
+ m_z26(*this, "z26"),
m_ram(*this, RAM_TAG),
m_ds1(*this, "ds1"),
m_ds2(*this, "ds2"),
@@ -62,6 +66,9 @@ public:
required_device<cpu_device> m_maincpu;
required_device<cassette_image_device> m_cassette1;
required_device<cassette_image_device> m_cassette2;
+ required_device<generic_slot_device> m_z24;
+ required_device<generic_slot_device> m_z25;
+ required_device<generic_slot_device> m_z26;
required_device<ram_device> m_ram;
required_device<dl1416_device> m_ds1;
required_device<dl1416_device> m_ds2;
@@ -80,7 +87,10 @@ public:
void dl1416_update(dl1416_device *device, int index);
- DECLARE_DEVICE_IMAGE_LOAD_MEMBER(aim65_cart);
+ int load_cart(device_image_interface &image, generic_slot_device *slot, const char *slot_tag);
+ DECLARE_DEVICE_IMAGE_LOAD_MEMBER(z24_load) { return load_cart(image, m_z24, "z24"); }
+ DECLARE_DEVICE_IMAGE_LOAD_MEMBER(z25_load) { return load_cart(image, m_z25, "z25"); }
+ DECLARE_DEVICE_IMAGE_LOAD_MEMBER(z26_load) { return load_cart(image, m_z26, "z26"); }
};
diff --git a/src/mess/includes/gamepock.h b/src/mess/includes/gamepock.h
index 01abd3c7754..4fb420fb4dc 100644
--- a/src/mess/includes/gamepock.h
+++ b/src/mess/includes/gamepock.h
@@ -1,6 +1,7 @@
#ifndef _GAMEPOCK_H_
#define _GAMEPOCK_H_
#include "sound/speaker.h"
+#include "bus/generic/slot.h"
struct HD44102CH {
UINT8 enabled;
@@ -16,7 +17,9 @@ public:
gamepock_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
- m_speaker(*this, "speaker") { }
+ m_speaker(*this, "speaker"),
+ m_cart(*this, "cartslot")
+ { }
virtual void machine_reset();
@@ -33,11 +36,10 @@ public:
DECLARE_WRITE8_MEMBER( port_b_w );
DECLARE_READ8_MEMBER( port_c_r );
UINT32 screen_update_gamepock(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- DECLARE_DEVICE_IMAGE_LOAD_MEMBER(gamepock_cart);
required_device<cpu_device> m_maincpu;
required_device<speaker_sound_device> m_speaker;
+ required_device<generic_slot_device> m_cart;
DECLARE_WRITE_LINE_MEMBER(gamepock_to_w);
-
};
#endif
diff --git a/src/mess/machine/aim65.c b/src/mess/machine/aim65.c
index c10680093c0..68d3eec478f 100644
--- a/src/mess/machine/aim65.c
+++ b/src/mess/machine/aim65.c
@@ -142,7 +142,15 @@ void aim65_state::machine_start()
ram_device *ram = m_ram;
address_space &space = m_maincpu->space(AS_PROGRAM);
- /* Init RAM */
+ // Init ROM sockets
+ if (m_z24->cart_mounted())
+ space.install_read_handler(0xd000, 0xdfff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_z24));
+ if (m_z25->cart_mounted())
+ space.install_read_handler(0xc000, 0xcfff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_z25));
+ if (m_z26->cart_mounted())
+ space.install_read_handler(0xb000, 0xbfff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_z26));
+
+ // Init RAM
space.install_ram(0x0000, ram->size() - 1, ram->pointer());
m_pb_save = 0;
diff --git a/src/mess/machine/gamepock.c b/src/mess/machine/gamepock.c
index b56a88fe963..dc1acc91387 100644
--- a/src/mess/machine/gamepock.c
+++ b/src/mess/machine/gamepock.c
@@ -136,6 +136,10 @@ void gamepock_state::machine_reset()
hd44102ch_init( 0 );
hd44102ch_init( 1 );
hd44102ch_init( 2 );
+
+ if (m_cart->cart_mounted())
+ m_maincpu->space(AS_PROGRAM).install_read_handler(0x4000,0xbfff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_cart));
+
}
UINT32 gamepock_state::screen_update_gamepock(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
diff --git a/src/mess/mess.mak b/src/mess/mess.mak
index 12167a45ee2..d65af8aa627 100644
--- a/src/mess/mess.mak
+++ b/src/mess/mess.mak
@@ -586,6 +586,7 @@ BUSES += EP64
BUSES += EPSON_SIO
BUSES += GAMEBOY
BUSES += GBA
+BUSES += GENERIC
BUSES += IEEE488
BUSES += IMI7000
BUSES += IQ151