From 5f77979a2c8cd7e215574367cc18b17a521dcdbd Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Tue, 30 Sep 2014 06:05:07 +0000 Subject: [PATCH] (MESS) converted scv and vboy to use slot devices for their carts. nw. --- .gitattributes | 8 + hash/scv.xml | 32 ++++ hash/vboy.xml | 31 ++++ src/emu/bus/bus.mak | 20 +++ src/emu/bus/scv/rom.c | 203 +++++++++++++++++++++++++ src/emu/bus/scv/rom.h | 149 +++++++++++++++++++ src/emu/bus/scv/slot.c | 318 ++++++++++++++++++++++++++++++++++++++++ src/emu/bus/scv/slot.h | 118 +++++++++++++++ src/emu/bus/vboy/rom.c | 59 ++++++++ src/emu/bus/vboy/rom.h | 45 ++++++ src/emu/bus/vboy/slot.c | 267 +++++++++++++++++++++++++++++++++ src/emu/bus/vboy/slot.h | 114 ++++++++++++++ src/mess/drivers/scv.c | 267 +++++++-------------------------- src/mess/drivers/vboy.c | 234 +++++++++-------------------- src/mess/mess.mak | 2 + 15 files changed, 1486 insertions(+), 381 deletions(-) create mode 100644 src/emu/bus/scv/rom.c create mode 100644 src/emu/bus/scv/rom.h create mode 100644 src/emu/bus/scv/slot.c create mode 100644 src/emu/bus/scv/slot.h create mode 100644 src/emu/bus/vboy/rom.c create mode 100644 src/emu/bus/vboy/rom.h create mode 100644 src/emu/bus/vboy/slot.c create mode 100644 src/emu/bus/vboy/slot.h diff --git a/.gitattributes b/.gitattributes index cd2c92be163..175b7d8c17f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1495,6 +1495,10 @@ src/emu/bus/scsi/scsihd.c svneol=native#text/plain src/emu/bus/scsi/scsihd.h svneol=native#text/plain src/emu/bus/scsi/scsihle.c svneol=native#text/plain src/emu/bus/scsi/scsihle.h svneol=native#text/plain +src/emu/bus/scv/rom.c svneol=native#text/plain +src/emu/bus/scv/rom.h svneol=native#text/plain +src/emu/bus/scv/slot.c svneol=native#text/plain +src/emu/bus/scv/slot.h svneol=native#text/plain src/emu/bus/sega8/rom.c svneol=native#text/plain src/emu/bus/sega8/rom.h svneol=native#text/plain src/emu/bus/sega8/sega8_slot.c svneol=native#text/plain @@ -1581,6 +1585,10 @@ src/emu/bus/tvc/hbf.c svneol=native#text/plain src/emu/bus/tvc/hbf.h svneol=native#text/plain src/emu/bus/tvc/tvc.c svneol=native#text/plain src/emu/bus/tvc/tvc.h svneol=native#text/plain +src/emu/bus/vboy/rom.c svneol=native#text/plain +src/emu/bus/vboy/rom.h svneol=native#text/plain +src/emu/bus/vboy/slot.c svneol=native#text/plain +src/emu/bus/vboy/slot.h svneol=native#text/plain src/emu/bus/vcs/compumat.c svneol=native#text/plain src/emu/bus/vcs/compumat.h svneol=native#text/plain src/emu/bus/vcs/dpc.c svneol=native#text/plain diff --git a/hash/scv.xml b/hash/scv.xml index b3c7aac8516..1e3446c32dd 100644 --- a/hash/scv.xml +++ b/hash/scv.xml @@ -63,6 +63,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -74,6 +75,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -85,6 +87,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -97,6 +100,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -108,6 +112,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -119,6 +124,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -130,6 +136,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -142,6 +149,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1986 Epoch + @@ -153,6 +161,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1986 Epoch + @@ -166,6 +175,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -178,6 +188,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -191,6 +202,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -202,6 +214,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1986 Epoch + @@ -213,6 +226,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -224,6 +238,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -236,6 +251,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1986 Epoch + @@ -247,6 +263,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -258,6 +275,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -269,6 +287,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -282,6 +301,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -295,6 +315,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1986 Epoch + @@ -306,6 +327,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -317,6 +339,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -328,6 +351,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1986 Epoch + @@ -339,6 +363,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -354,6 +379,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -367,6 +393,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -379,6 +406,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -391,6 +419,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -403,6 +432,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1984 Epoch + @@ -414,6 +444,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + @@ -425,6 +456,7 @@ Information found at http://www.rhod.fr/yeno_epoch.html 1985 Epoch + diff --git a/hash/vboy.xml b/hash/vboy.xml index 0f3457d990f..215dcf2d50c 100644 --- a/hash/vboy.xml +++ b/hash/vboy.xml @@ -21,6 +21,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -36,6 +37,7 @@ According to Planet Virtual Boy, the following undumped protos exist Nintendo + @@ -50,6 +52,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -65,6 +68,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -81,6 +85,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -96,6 +101,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -111,6 +117,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -126,6 +133,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -141,6 +149,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -158,6 +167,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -170,6 +180,7 @@ According to Planet Virtual Boy, the following undumped protos exist Bullet-Proof Software + @@ -185,6 +196,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -202,6 +214,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -217,6 +230,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -232,6 +246,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -247,6 +262,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -261,6 +277,7 @@ According to Planet Virtual Boy, the following undumped protos exist 1995 Nintendo + @@ -275,6 +292,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -292,6 +310,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -309,6 +328,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -326,6 +346,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -341,6 +362,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -358,6 +380,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -373,6 +396,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -388,6 +412,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -404,6 +429,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -419,6 +445,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -434,6 +461,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -449,6 +477,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -466,6 +495,7 @@ According to Planet Virtual Boy, the following undumped protos exist + @@ -482,6 +512,7 @@ According to Planet Virtual Boy, the following undumped protos exist + diff --git a/src/emu/bus/bus.mak b/src/emu/bus/bus.mak index 009fede5a0b..09986d28ac2 100644 --- a/src/emu/bus/bus.mak +++ b/src/emu/bus/bus.mak @@ -956,6 +956,16 @@ BUSOBJS += $(BUSOBJ)/snes/sufami.o BUSOBJS += $(BUSOBJ)/snes/upd.o endif +#------------------------------------------------- +# +#@src/emu/bus/vboy/slot.h,BUSES += VBOY +#------------------------------------------------- +ifneq ($(filter VBOY,$(BUSES)),) +OBJDIRS += $(BUSOBJ)/vboy +BUSOBJS += $(BUSOBJ)/vboy/slot.o +BUSOBJS += $(BUSOBJ)/vboy/rom.o +endif + #------------------------------------------------- # #@src/emu/bus/megadrive/md_slot.h,BUSES += MEGADRIVE @@ -1173,6 +1183,16 @@ BUSOBJS += $(BUSOBJ)/pce/pce_slot.o BUSOBJS += $(BUSOBJ)/pce/pce_rom.o endif +#------------------------------------------------- +# +#@src/emu/bus/scv/slot.h,BUSES += SCV +#------------------------------------------------- +ifneq ($(filter SCV,$(BUSES)),) +OBJDIRS += $(BUSOBJ)/scv +BUSOBJS += $(BUSOBJ)/scv/slot.o +BUSOBJS += $(BUSOBJ)/scv/rom.o +endif + #------------------------------------------------- # #@src/emu/bus/x68k/x68kexp.h,BUSES += X68K diff --git a/src/emu/bus/scv/rom.c b/src/emu/bus/scv/rom.c new file mode 100644 index 00000000000..39d33a86ee8 --- /dev/null +++ b/src/emu/bus/scv/rom.c @@ -0,0 +1,203 @@ +/*********************************************************************************************************** + + + Epoch Super Cassette Vision cart emulation + + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "rom.h" + + +//------------------------------------------------- +// scv_rom_device - constructor +//------------------------------------------------- + +const device_type SCV_ROM8K = &device_creator; +const device_type SCV_ROM16K = &device_creator; +const device_type SCV_ROM32K = &device_creator; +const device_type SCV_ROM32K_RAM8K = &device_creator; +const device_type SCV_ROM64K = &device_creator; +const device_type SCV_ROM128K = &device_creator; +const device_type SCV_ROM128K_RAM4K = &device_creator; + + +scv_rom8_device::scv_rom8_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_scv_cart_interface( mconfig, *this ) +{ +} + +scv_rom8_device::scv_rom8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, SCV_ROM8K, "SCV 8K Carts", tag, owner, clock, "scv_rom8", __FILE__), + device_scv_cart_interface( mconfig, *this ) +{ +} + +scv_rom16_device::scv_rom16_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : scv_rom8_device(mconfig, SCV_ROM16K, "SCV 16K Carts", tag, owner, clock, "scv_rom16", __FILE__) +{ +} + +scv_rom32_device::scv_rom32_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : scv_rom8_device(mconfig, SCV_ROM32K, "SCV 32K Carts", tag, owner, clock, "scv_rom32", __FILE__) +{ +} + +scv_rom32ram8_device::scv_rom32ram8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : scv_rom8_device(mconfig, SCV_ROM32K_RAM8K, "SCV 32K + RAM 8K Carts", tag, owner, clock, "scv_rom32_ram8", __FILE__) +{ +} + +scv_rom64_device::scv_rom64_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : scv_rom8_device(mconfig, SCV_ROM16K, "SCV 64K Carts", tag, owner, clock, "scv_rom64", __FILE__) +{ +} + +scv_rom128_device::scv_rom128_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : scv_rom8_device(mconfig, SCV_ROM32K, "SCV 128K Carts", tag, owner, clock, "scv_rom128", __FILE__) +{ +} + +scv_rom128ram4_device::scv_rom128ram4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : scv_rom8_device(mconfig, SCV_ROM128K_RAM4K, "SCV 128K + RAM 4K Carts", tag, owner, clock, "scv_rom128_ram4", __FILE__) +{ +} + + +//------------------------------------------------- +// mapper specific start/reset +//------------------------------------------------- + +void scv_rom32ram8_device::device_start() +{ + save_item(NAME(m_ram_enabled)); +} + +void scv_rom32ram8_device::device_reset() +{ + m_ram_enabled = 1; +} + + +void scv_rom64_device::device_start() +{ + save_item(NAME(m_bank_base)); +} + +void scv_rom64_device::device_reset() +{ + m_bank_base = 0; +} + + +void scv_rom128_device::device_start() +{ + save_item(NAME(m_bank_base)); +} + +void scv_rom128_device::device_reset() +{ + m_bank_base = 0; +} + + +void scv_rom128ram4_device::device_start() +{ + save_item(NAME(m_bank_base)); + save_item(NAME(m_ram_enabled)); +} + +void scv_rom128ram4_device::device_reset() +{ + m_bank_base = 0; + m_ram_enabled = 1; +} + + + +/*------------------------------------------------- + mapper specific handlers + -------------------------------------------------*/ + +READ8_MEMBER(scv_rom8_device::read_cart) +{ + return m_rom[offset & 0x1fff]; +} + + +READ8_MEMBER(scv_rom16_device::read_cart) +{ + return m_rom[offset & 0x3fff]; +} + + +READ8_MEMBER(scv_rom32_device::read_cart) +{ + return m_rom[offset]; +} + + +READ8_MEMBER(scv_rom32ram8_device::read_cart) +{ + if (m_ram_enabled && offset >= 0x6000) + return m_ram[offset & 0x1fff]; + + return m_rom[offset]; +} + +WRITE8_MEMBER(scv_rom32ram8_device::write_cart) +{ + if (m_ram_enabled && offset >= 0x6000) + m_ram[offset & 0x1fff] = data; +} + +WRITE8_MEMBER(scv_rom32ram8_device::write_bank) +{ + m_ram_enabled = BIT(data, 5); +} + + +READ8_MEMBER(scv_rom64_device::read_cart) +{ + return m_rom[offset + (m_bank_base * 0x8000)]; +} + +WRITE8_MEMBER(scv_rom64_device::write_bank) +{ + m_bank_base = BIT(data, 5); +} + + +READ8_MEMBER(scv_rom128_device::read_cart) +{ + return m_rom[offset + (m_bank_base * 0x8000)]; +} + +WRITE8_MEMBER(scv_rom128_device::write_bank) +{ + m_bank_base = (data >> 5) & 0x03; +} + + +READ8_MEMBER(scv_rom128ram4_device::read_cart) +{ + if (m_ram_enabled && offset >= 0x7000) + return m_ram[offset & 0xfff]; + + return m_rom[offset + (m_bank_base * 0x8000)]; +} + +WRITE8_MEMBER(scv_rom128ram4_device::write_cart) +{ + if (m_ram_enabled && offset >= 0x7000) + m_ram[offset & 0xfff] = data; +} + +WRITE8_MEMBER(scv_rom128ram4_device::write_bank) +{ + m_bank_base = (data >> 5) & 0x03; + m_ram_enabled = BIT(data, 6); +} diff --git a/src/emu/bus/scv/rom.h b/src/emu/bus/scv/rom.h new file mode 100644 index 00000000000..1ef3c4f8ecc --- /dev/null +++ b/src/emu/bus/scv/rom.h @@ -0,0 +1,149 @@ +#ifndef __SCV_ROM_H +#define __SCV_ROM_H + +#include "slot.h" + + +// ======================> scv_rom8_device + +class scv_rom8_device : public device_t, + public device_scv_cart_interface +{ +public: + // construction/destruction + scv_rom8_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); + scv_rom8_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_cart); +}; + +// ======================> scv_rom16_device + +class scv_rom16_device : public scv_rom8_device +{ +public: + // construction/destruction + scv_rom16_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_cart); +}; + + +// ======================> scv_rom32_device + +class scv_rom32_device : public scv_rom8_device +{ +public: + // construction/destruction + scv_rom32_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_cart); +}; + + +// ======================> scv_rom32ram8_device + +class scv_rom32ram8_device : public scv_rom8_device +{ +public: + // construction/destruction + scv_rom32ram8_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_cart); + virtual DECLARE_WRITE8_MEMBER(write_cart); + virtual DECLARE_WRITE8_MEMBER(write_bank); + +private: + UINT8 m_ram_enabled; +}; + + +// ======================> scv_rom64_device + +class scv_rom64_device : public scv_rom8_device +{ +public: + // construction/destruction + scv_rom64_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_cart); + virtual DECLARE_WRITE8_MEMBER(write_bank); + +private: + UINT8 m_bank_base; +}; + + +// ======================> scv_rom128_device + +class scv_rom128_device : public scv_rom8_device +{ +public: + // construction/destruction + scv_rom128_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_cart); + virtual DECLARE_WRITE8_MEMBER(write_bank); + +private: + UINT8 m_bank_base; +}; + + +// ======================> scv_rom128ram4_device + +class scv_rom128ram4_device : public scv_rom8_device +{ +public: + // construction/destruction + scv_rom128ram4_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_cart); + virtual DECLARE_WRITE8_MEMBER(write_cart); + virtual DECLARE_WRITE8_MEMBER(write_bank); + +private: + UINT8 m_bank_base, m_ram_enabled; +}; + + + +// device type definition +extern const device_type SCV_ROM8K; +extern const device_type SCV_ROM16K; +extern const device_type SCV_ROM32K; +extern const device_type SCV_ROM32K_RAM8K; +extern const device_type SCV_ROM64K; +extern const device_type SCV_ROM128K; +extern const device_type SCV_ROM128K_RAM4K; + + + +#endif diff --git a/src/emu/bus/scv/slot.c b/src/emu/bus/scv/slot.c new file mode 100644 index 00000000000..1696051b013 --- /dev/null +++ b/src/emu/bus/scv/slot.c @@ -0,0 +1,318 @@ +/*********************************************************************************************************** + + Epoch Super Cassette Vision cart emulation + (through slot devices) + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "slot.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type SCV_CART_SLOT = &device_creator; + +//************************************************************************** +// SCV cartridges Interface +//************************************************************************** + +//------------------------------------------------- +// device_scv_cart_interface - constructor +//------------------------------------------------- + +device_scv_cart_interface::device_scv_cart_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device), + m_rom(NULL), + m_rom_size(0) +{ +} + + +//------------------------------------------------- +// ~device_scv_cart_interface - destructor +//------------------------------------------------- + +device_scv_cart_interface::~device_scv_cart_interface() +{ +} + +//------------------------------------------------- +// rom_alloc - alloc the space for the cart +//------------------------------------------------- + +void device_scv_cart_interface::rom_alloc(UINT32 size, const char *tag) +{ + if (m_rom == NULL) + { + astring tempstring(tag); + tempstring.cat(SCVSLOT_ROM_REGION_TAG); + m_rom = device().machine().memory().region_alloc(tempstring, size, 1, ENDIANNESS_LITTLE)->base(); + m_rom_size = size; + } +} + + +//------------------------------------------------- +// ram_alloc - alloc the space for the ram +//------------------------------------------------- + +void device_scv_cart_interface::ram_alloc(UINT32 size) +{ + m_ram.resize(size); +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// scv_cart_slot_device - constructor +//------------------------------------------------- +scv_cart_slot_device::scv_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, SCV_CART_SLOT, "SCV Cartridge Slot", tag, owner, clock, "scv_cart_slot", __FILE__), + device_image_interface(mconfig, *this), + device_slot_interface(mconfig, *this), + m_type(SCV_8K) +{ +} + + +//------------------------------------------------- +// scv_cart_slot_device - destructor +//------------------------------------------------- + +scv_cart_slot_device::~scv_cart_slot_device() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void scv_cart_slot_device::device_start() +{ + m_cart = dynamic_cast(get_card_device()); +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void scv_cart_slot_device::device_config_complete() +{ + // set brief and instance name + update_names(); +} + + +//------------------------------------------------- +// SCV PCB +//------------------------------------------------- + +struct scv_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 scv_slot slot_list[] = +{ + { SCV_8K, "rom8k" }, + { SCV_16K, "rom16k" }, + { SCV_32K, "rom32k" }, + { SCV_32K_RAM, "rom32k_ram" }, + { SCV_64K, "rom64k" }, + { SCV_128K, "rom128k" }, + { SCV_128K_RAM, "rom128k_ram" } +}; + +static int scv_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 *scv_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 "rom8k"; +} + + +/*------------------------------------------------- + call load + -------------------------------------------------*/ + +bool scv_cart_slot_device::call_load() +{ + if (m_cart) + { + UINT8 *ROM; + UINT32 len = (software_entry() == NULL) ? length() : get_software_region_length("rom"); + bool has_ram = (software_entry() != NULL) && get_software_region("ram"); + + if (len > 0x20000) + { + seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); + return IMAGE_INIT_FAIL; + } + + m_cart->rom_alloc(len, tag()); + if (has_ram) + m_cart->ram_alloc(get_software_region_length("ram")); + + ROM = m_cart->get_rom_base(); + + if (software_entry() == NULL) + fread(ROM, len); + else + memcpy(ROM, get_software_region("rom"), len); + + if (software_entry() == NULL) + m_type = get_cart_type(ROM, len); + else + { + const char *pcb_name = get_feature("slot"); + if (pcb_name) + m_type = scv_get_pcb_id(pcb_name); + } + + // for the moment we only support RAM from softlist and in the following configurations + // 1) 32K ROM + 8K RAM; 2) 128K ROM + 4K RAM + if (m_type == SCV_32K && has_ram) + m_type = SCV_32K_RAM; + if (m_type == SCV_128K && has_ram) + m_type = SCV_128K_RAM; + + //printf("Type: %s\n", scv_get_slot(m_type)); + + return IMAGE_INIT_PASS; + } + + return IMAGE_INIT_PASS; +} + + +/*------------------------------------------------- + call softlist load + -------------------------------------------------*/ + +bool scv_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_cart_type - code to detect NVRAM type from + fullpath + -------------------------------------------------*/ + +int scv_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len) +{ + int type = SCV_8K; + + // TO DO: is there any way to identify carts with RAM?!? + switch (len) + { + case 0x2000: + type = SCV_8K; + break; + case 0x4000: + type = SCV_16K; + break; + case 0x8000: + type = SCV_32K; + break; + case 0x10000: + type = SCV_64K; + break; + case 0x20000: + type = SCV_128K; + break; + } + + return type; +} + + +/*------------------------------------------------- + get default card software + -------------------------------------------------*/ + +void scv_cart_slot_device::get_default_card_software(astring &result) +{ + if (open_image_file(mconfig().options())) + { + const char *slot_string = "rom8k"; + UINT32 len = core_fsize(m_file); + dynamic_buffer rom(len); + int type; + + core_fread(m_file, rom, len); + + type = get_cart_type(rom, len); + slot_string = scv_get_slot(type); + + //printf("type: %s\n", slot_string); + clear(); + + result.cpy(slot_string); + return; + } + + software_get_default_slot(result, "rom8k"); +} + +/*------------------------------------------------- + read + -------------------------------------------------*/ + +READ8_MEMBER(scv_cart_slot_device::read_cart) +{ + if (m_cart) + return m_cart->read_cart(space, offset); + else + return 0xff; +} + +/*------------------------------------------------- + write + -------------------------------------------------*/ + +WRITE8_MEMBER(scv_cart_slot_device::write_cart) +{ + if (m_cart) + m_cart->write_cart(space, offset, data); +} + + +/*------------------------------------------------- + write_bank + -------------------------------------------------*/ + +WRITE8_MEMBER(scv_cart_slot_device::write_bank) +{ + if (m_cart) + m_cart->write_bank(space, offset, data); +} + diff --git a/src/emu/bus/scv/slot.h b/src/emu/bus/scv/slot.h new file mode 100644 index 00000000000..61e3fdfd9da --- /dev/null +++ b/src/emu/bus/scv/slot.h @@ -0,0 +1,118 @@ +#ifndef __SCV_SLOT_H +#define __SCV_SLOT_H + +/*************************************************************************** + TYPE DEFINITIONS + ***************************************************************************/ + + +/* PCB */ +enum +{ + SCV_8K = 0, + SCV_16K, + SCV_32K, + SCV_32K_RAM, + SCV_64K, + SCV_128K, + SCV_128K_RAM +}; + + +// ======================> device_scv_cart_interface + +class device_scv_cart_interface : public device_slot_card_interface +{ +public: + // construction/destruction + device_scv_cart_interface(const machine_config &mconfig, device_t &device); + virtual ~device_scv_cart_interface(); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_cart) { return 0xff; } + virtual DECLARE_WRITE8_MEMBER(write_cart) {} + virtual DECLARE_WRITE8_MEMBER(write_bank) {} + + void rom_alloc(UINT32 size, const char *tag); + void ram_alloc(UINT32 size); + UINT8* get_rom_base() { return m_rom; } + UINT8* get_ram_base() { return m_ram; } + UINT32 get_rom_size() { return m_rom_size; } + UINT32 get_ram_size() { return m_ram.count(); } + + void save_ram() { device().save_item(NAME(m_ram)); } + +protected: + // internal state + UINT8 *m_rom; + UINT32 m_rom_size; + dynamic_buffer m_ram; +}; + + +// ======================> scv_cart_slot_device + +class scv_cart_slot_device : public device_t, + public device_image_interface, + public device_slot_interface +{ +public: + // construction/destruction + scv_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual ~scv_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; } + int get_cart_type(UINT8 *ROM, UINT32 len); + + void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } + + 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 "scv_cart"; } + virtual const char *file_extensions() const { return "bin"; } + + // slot interface overrides + virtual void get_default_card_software(astring &result); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read_cart); + virtual DECLARE_WRITE8_MEMBER(write_cart); + virtual DECLARE_WRITE8_MEMBER(write_bank); + +protected: + + int m_type; + device_scv_cart_interface* m_cart; +}; + + + +// device type definition +extern const device_type SCV_CART_SLOT; + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS + ***************************************************************************/ + +#define SCVSLOT_ROM_REGION_TAG ":cart:rom" + +#define MCFG_SCV_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ + MCFG_DEVICE_ADD(_tag, SCV_CART_SLOT, 0) \ + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ + +#endif diff --git a/src/emu/bus/vboy/rom.c b/src/emu/bus/vboy/rom.c new file mode 100644 index 00000000000..a572c08c367 --- /dev/null +++ b/src/emu/bus/vboy/rom.c @@ -0,0 +1,59 @@ +/*********************************************************************************************************** + + + Nintendo Virtual Boy cart emulation + + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "rom.h" + + +//------------------------------------------------- +// vboy_rom_device - constructor +//------------------------------------------------- + +const device_type VBOY_ROM_STD = &device_creator; +const device_type VBOY_ROM_EEPROM = &device_creator; + + +vboy_rom_device::vboy_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_vboy_cart_interface( mconfig, *this ) +{ +} + +vboy_rom_device::vboy_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, VBOY_ROM_STD, "Nintendo Virtual Boy Carts", tag, owner, clock, "vboy_rom", __FILE__), + device_vboy_cart_interface( mconfig, *this ) +{ +} + +vboy_eeprom_device::vboy_eeprom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : vboy_rom_device(mconfig, VBOY_ROM_EEPROM, "Nintendo Virtual Boy Carts + EEPROM", tag, owner, clock, "vboy_eeprom", __FILE__) +{ +} + + +/*------------------------------------------------- + mapper specific handlers + -------------------------------------------------*/ + +READ32_MEMBER(vboy_rom_device::read_cart) +{ + return m_rom[offset & m_rom_mask]; +} + + +READ32_MEMBER(vboy_eeprom_device::read_eeprom) +{ + return m_eeprom[offset]; +} + + +WRITE32_MEMBER(vboy_eeprom_device::write_eeprom) +{ + COMBINE_DATA(&m_eeprom[offset]); +} diff --git a/src/emu/bus/vboy/rom.h b/src/emu/bus/vboy/rom.h new file mode 100644 index 00000000000..cc13aa3ec84 --- /dev/null +++ b/src/emu/bus/vboy/rom.h @@ -0,0 +1,45 @@ +#ifndef __VBOY_ROM_H +#define __VBOY_ROM_H + +#include "slot.h" + + +// ======================> vboy_rom_device + +class vboy_rom_device : public device_t, + public device_vboy_cart_interface +{ +public: + // construction/destruction + vboy_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); + vboy_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start() {} + + // reading and writing + virtual DECLARE_READ32_MEMBER(read_cart); +}; + +// ======================> vboy_eeprom_device + +class vboy_eeprom_device : public vboy_rom_device +{ +public: + // construction/destruction + vboy_eeprom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // reading and writing + virtual DECLARE_READ32_MEMBER(read_eeprom); + virtual DECLARE_WRITE32_MEMBER(write_eeprom); +}; + + + +// device type definition +extern const device_type VBOY_ROM_STD; +extern const device_type VBOY_ROM_EEPROM; + + + +#endif diff --git a/src/emu/bus/vboy/slot.c b/src/emu/bus/vboy/slot.c new file mode 100644 index 00000000000..244f7a80b60 --- /dev/null +++ b/src/emu/bus/vboy/slot.c @@ -0,0 +1,267 @@ +/*********************************************************************************************************** + + Nintendo Virtual Boy cart emulation + (through slot devices) + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "slot.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type VBOY_CART_SLOT = &device_creator; + +//************************************************************************** +// vboy cartridges Interface +//************************************************************************** + +//------------------------------------------------- +// device_vboy_cart_interface - constructor +//------------------------------------------------- + +device_vboy_cart_interface::device_vboy_cart_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device), + m_rom(NULL), + m_rom_size(0), + m_rom_mask(0) +{ +} + + +//------------------------------------------------- +// ~device_vboy_cart_interface - destructor +//------------------------------------------------- + +device_vboy_cart_interface::~device_vboy_cart_interface() +{ +} + +//------------------------------------------------- +// rom_alloc - alloc the space for the cart +//------------------------------------------------- + +void device_vboy_cart_interface::rom_alloc(UINT32 size, const char *tag) +{ + if (m_rom == NULL) + { + astring tempstring(tag); + tempstring.cat(VBOYSLOT_ROM_REGION_TAG); + m_rom = (UINT32 *)device().machine().memory().region_alloc(tempstring, size, 4, ENDIANNESS_LITTLE)->base(); + m_rom_size = size/4; + m_rom_mask = m_rom_size - 1; + } +} + + +//------------------------------------------------- +// ram_alloc - alloc the space for the ram +//------------------------------------------------- + +void device_vboy_cart_interface::eeprom_alloc(UINT32 size) +{ + m_eeprom.resize(size/sizeof(UINT32)); +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// vboy_cart_slot_device - constructor +//------------------------------------------------- +vboy_cart_slot_device::vboy_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, VBOY_CART_SLOT, "Nintendo Virtual Boy Cartridge Slot", tag, owner, clock, "vboy_cart_slot", __FILE__), + device_image_interface(mconfig, *this), + device_slot_interface(mconfig, *this), + m_type(VBOY_STD) +{ +} + + +//------------------------------------------------- +// vboy_cart_slot_device - destructor +//------------------------------------------------- + +vboy_cart_slot_device::~vboy_cart_slot_device() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void vboy_cart_slot_device::device_start() +{ + m_cart = dynamic_cast(get_card_device()); +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void vboy_cart_slot_device::device_config_complete() +{ + // set brief and instance name + update_names(); +} + + +//------------------------------------------------- +// vboy PCB +//------------------------------------------------- + +struct vboy_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 vboy_slot slot_list[] = +{ + { VBOY_STD, "vb_rom" }, + { VBOY_EEPROM, "vb_eeprom" } +}; + +static int vboy_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; +} + +#if 0 +static const char *vboy_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 "vb_rom"; +} +#endif + +/*------------------------------------------------- + call load + -------------------------------------------------*/ + +bool vboy_cart_slot_device::call_load() +{ + if (m_cart) + { + UINT8 *ROM; + UINT32 len = (software_entry() == NULL) ? length() : get_software_region_length("rom"); + bool has_eeprom = (software_entry() != NULL) && get_software_region("eeprom"); + + if (len > 0x200000) + { + seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); + return IMAGE_INIT_FAIL; + } + + m_cart->rom_alloc(len, tag()); + if (has_eeprom) + m_cart->eeprom_alloc(get_software_region_length("eeprom")); + + ROM = (UINT8 *)m_cart->get_rom_base(); + + if (software_entry() == NULL) + fread(ROM, len); + else + memcpy(ROM, get_software_region("rom"), len); + + if (software_entry() == NULL) + m_type = vboy_get_pcb_id("vb_rom"); + else + { + const char *pcb_name = get_feature("slot"); + if (pcb_name) + m_type = vboy_get_pcb_id(pcb_name); + } + + //printf("Type: %s\n", vboy_get_slot(m_type)); + + return IMAGE_INIT_PASS; + } + + return IMAGE_INIT_PASS; +} + + +/*------------------------------------------------- + call_unload + -------------------------------------------------*/ + +void vboy_cart_slot_device::call_unload() +{ + if (m_cart && m_cart->get_eeprom_size()) + battery_save(m_cart->get_eeprom_base(), m_cart->get_eeprom_size() * 4); +} + +/*------------------------------------------------- + call softlist load + -------------------------------------------------*/ + +bool vboy_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 vboy_cart_slot_device::get_default_card_software(astring &result) +{ + software_get_default_slot(result, "vb_rom"); +} + +/*------------------------------------------------- + read + -------------------------------------------------*/ + +READ32_MEMBER(vboy_cart_slot_device::read_cart) +{ + if (m_cart) + return m_cart->read_cart(space, offset, mem_mask); + else + return 0xffffffff; +} + +/*------------------------------------------------- + read + -------------------------------------------------*/ + +READ32_MEMBER(vboy_cart_slot_device::read_eeprom) +{ + if (m_cart) + return m_cart->read_eeprom(space, offset, mem_mask); + else + return 0xffffffff; +} + +/*------------------------------------------------- + write + -------------------------------------------------*/ + +WRITE32_MEMBER(vboy_cart_slot_device::write_eeprom) +{ + if (m_cart) + m_cart->write_eeprom(space, offset, data, mem_mask); +} diff --git a/src/emu/bus/vboy/slot.h b/src/emu/bus/vboy/slot.h new file mode 100644 index 00000000000..0d5c3edb403 --- /dev/null +++ b/src/emu/bus/vboy/slot.h @@ -0,0 +1,114 @@ +#ifndef __VBOY_SLOT_H +#define __VBOY_SLOT_H + +/*************************************************************************** + TYPE DEFINITIONS + ***************************************************************************/ + + +/* PCB */ +enum +{ + VBOY_STD = 0, + VBOY_EEPROM +}; + + +// ======================> device_vboy_cart_interface + +class device_vboy_cart_interface : public device_slot_card_interface +{ +public: + // construction/destruction + device_vboy_cart_interface(const machine_config &mconfig, device_t &device); + virtual ~device_vboy_cart_interface(); + + // reading and writing + virtual DECLARE_READ32_MEMBER(read_cart) { return 0xffffffff; } + virtual DECLARE_READ32_MEMBER(read_eeprom) { return 0xffffffff; } + virtual DECLARE_WRITE32_MEMBER(write_eeprom) {} + + void rom_alloc(UINT32 size, const char *tag); + void eeprom_alloc(UINT32 size); + UINT32* get_rom_base() { return m_rom; } + UINT32* get_eeprom_base() { return m_eeprom; } + UINT32 get_rom_size() { return m_rom_size; } + UINT32 get_eeprom_size() { return m_eeprom.count(); } + + void save_eeprom() { device().save_item(NAME(m_eeprom)); } + +protected: + // internal state + UINT32 *m_rom; + UINT32 m_rom_size; + UINT32 m_rom_mask; + dynamic_array m_eeprom; +}; + + +// ======================> vboy_cart_slot_device + +class vboy_cart_slot_device : public device_t, + public device_image_interface, + public device_slot_interface +{ +public: + // construction/destruction + vboy_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual ~vboy_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; } + int get_cart_type(UINT8 *ROM, UINT32 len); + + void save_eeprom() { if (m_cart && m_cart->get_eeprom_size()) m_cart->save_eeprom(); } + + 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 1; } + 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 "vboy_cart"; } + virtual const char *file_extensions() const { return "vb,bin"; } + + // slot interface overrides + virtual void get_default_card_software(astring &result); + + // reading and writing + virtual DECLARE_READ32_MEMBER(read_cart); + virtual DECLARE_READ32_MEMBER(read_eeprom); + virtual DECLARE_WRITE32_MEMBER(write_eeprom); + +protected: + + int m_type; + device_vboy_cart_interface* m_cart; +}; + + + +// device type definition +extern const device_type VBOY_CART_SLOT; + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS + ***************************************************************************/ + +#define VBOYSLOT_ROM_REGION_TAG ":cart:rom" + +#define MCFG_VBOY_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \ + MCFG_DEVICE_ADD(_tag, VBOY_CART_SLOT, 0) \ + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ + +#endif diff --git a/src/mess/drivers/scv.c b/src/mess/drivers/scv.c index fe642456746..9ee007a2550 100644 --- a/src/mess/drivers/scv.c +++ b/src/mess/drivers/scv.c @@ -2,13 +2,13 @@ Driver for Epoch Super Cassette Vision - ***************************************************************************/ #include "emu.h" #include "cpu/upd7810/upd7810.h" -#include "imagedev/cartslot.h" #include "audio/upd1771.h" +#include "bus/scv/slot.h" +#include "bus/scv/rom.h" class scv_state : public driver_device @@ -17,41 +17,26 @@ public: scv_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_videoram(*this,"videoram"), - m_cart_rom_size(0), - m_cart_ram(NULL), - m_cart_ram_size(0), m_maincpu(*this, "maincpu"), m_upd1771c(*this, "upd1771c"), + m_cart(*this, "cartslot"), + m_pa(*this, "PA"), m_pc0(*this, "PC0"), - m_bank0(*this, "bank0"), - m_bank1(*this, "bank1"), - m_bank2(*this, "bank2"), - m_bank3(*this, "bank3"), - m_bank4(*this, "bank4"), m_charrom(*this, "charrom") { } - DECLARE_WRITE8_MEMBER(scv_porta_w); - DECLARE_READ8_MEMBER(scv_portb_r); - DECLARE_READ8_MEMBER(scv_portc_r); - DECLARE_WRITE8_MEMBER(scv_portc_w); - DECLARE_WRITE8_MEMBER(scv_cart_ram_w); - DECLARE_WRITE8_MEMBER(scv_cart_ram2_w); - DECLARE_WRITE_LINE_MEMBER(scv_upd1771_ack_w); + DECLARE_WRITE8_MEMBER(porta_w); + DECLARE_READ8_MEMBER(portb_r); + DECLARE_READ8_MEMBER(portc_r); + DECLARE_WRITE8_MEMBER(portc_w); + DECLARE_WRITE_LINE_MEMBER(upd1771_ack_w); required_shared_ptr m_videoram; UINT8 m_porta; UINT8 m_portc; emu_timer *m_vb_timer; - UINT8 *m_cart_rom; - UINT32 m_cart_rom_size; - UINT8 *m_cart_ram; - UINT32 m_cart_ram_size; - bool m_cart_ram_enabled; virtual void machine_start(); virtual void machine_reset(); DECLARE_PALETTE_INIT(scv); - void scv_postload(); UINT32 screen_update_scv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - DECLARE_DEVICE_IMAGE_LOAD_MEMBER( scv_cart ); protected: enum @@ -61,12 +46,9 @@ protected: required_device m_maincpu; required_device m_upd1771c; + required_device m_cart; + required_ioport_array<8> m_pa; required_ioport m_pc0; - required_memory_bank m_bank0; - required_memory_bank m_bank1; - required_memory_bank m_bank2; - required_memory_bank m_bank3; - required_memory_bank m_bank4; required_memory_region m_charrom; ioport_port *m_key[8]; @@ -82,30 +64,25 @@ protected: static ADDRESS_MAP_START( scv_mem, AS_PROGRAM, 8, scv_state ) - AM_RANGE( 0x0000, 0x0fff ) AM_ROM /* BIOS */ - - AM_RANGE( 0x2000, 0x3403 ) AM_RAM AM_SHARE("videoram") /* VRAM + 4 registers */ + AM_RANGE( 0x0000, 0x0fff ) AM_ROM // BIOS + AM_RANGE( 0x2000, 0x3403 ) AM_RAM AM_SHARE("videoram") // VRAM + 4 registers AM_RANGE( 0x3600, 0x3600 ) AM_DEVWRITE("upd1771c", upd1771c_device, write) - AM_RANGE( 0x8000, 0x9fff ) AM_ROMBANK("bank0") - AM_RANGE( 0xa000, 0xbfff ) AM_ROMBANK("bank1") - AM_RANGE( 0xc000, 0xdfff ) AM_ROMBANK("bank2") - AM_RANGE( 0xe000, 0xefff ) AM_READ_BANK("bank3") AM_WRITE( scv_cart_ram_w ) - AM_RANGE( 0xf000, 0xff7f ) AM_READ_BANK("bank4") AM_WRITE( scv_cart_ram2_w ) - AM_RANGE( 0xff80, 0xffff ) AM_RAM /* upd7801 internal RAM */ + AM_RANGE( 0x8000, 0xff7f ) AM_DEVREADWRITE("cartslot", scv_cart_slot_device, read_cart, write_cart) // cartridge + AM_RANGE( 0xff80, 0xffff ) AM_RAM // upd7801 internal RAM ADDRESS_MAP_END static ADDRESS_MAP_START( scv_io, AS_IO, 8, scv_state ) - AM_RANGE( 0x00, 0x00 ) AM_WRITE( scv_porta_w ) - AM_RANGE( 0x01, 0x01 ) AM_READ( scv_portb_r ) - AM_RANGE( 0x02, 0x02 ) AM_READWRITE( scv_portc_r, scv_portc_w ) + AM_RANGE( 0x00, 0x00 ) AM_WRITE(porta_w) + AM_RANGE( 0x01, 0x01 ) AM_READ(portb_r) + AM_RANGE( 0x02, 0x02 ) AM_READWRITE(portc_r, portc_w) ADDRESS_MAP_END static INPUT_PORTS_START( scv ) - PORT_START( "PA0" ) + PORT_START( "PA.0" ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_8WAY PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_8WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) @@ -115,7 +92,7 @@ static INPUT_PORTS_START( scv ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START( "PA1" ) + PORT_START( "PA.1" ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_8WAY PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_8WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) @@ -125,7 +102,7 @@ static INPUT_PORTS_START( scv ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START( "PA2" ) + PORT_START( "PA.2" ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -135,7 +112,7 @@ static INPUT_PORTS_START( scv ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("0") PORT_CODE(KEYCODE_0_PAD) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("1") PORT_CODE(KEYCODE_1_PAD) - PORT_START( "PA3" ) + PORT_START( "PA.3" ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -145,7 +122,7 @@ static INPUT_PORTS_START( scv ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("2") PORT_CODE(KEYCODE_2_PAD) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("3") PORT_CODE(KEYCODE_3_PAD) - PORT_START( "PA4" ) + PORT_START( "PA.4" ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -155,7 +132,7 @@ static INPUT_PORTS_START( scv ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("4") PORT_CODE(KEYCODE_4_PAD) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("5") PORT_CODE(KEYCODE_5_PAD) - PORT_START( "PA5" ) + PORT_START( "PA.5" ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -165,7 +142,7 @@ static INPUT_PORTS_START( scv ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("6") PORT_CODE(KEYCODE_6_PAD) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("7") PORT_CODE(KEYCODE_7_PAD) - PORT_START( "PA6" ) + PORT_START( "PA.6" ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -175,7 +152,7 @@ static INPUT_PORTS_START( scv ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("8") PORT_CODE(KEYCODE_8_PAD) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("9") PORT_CODE(KEYCODE_9_PAD) - PORT_START( "PA7" ) + PORT_START( "PA.7" ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -190,52 +167,27 @@ static INPUT_PORTS_START( scv ) INPUT_PORTS_END -WRITE8_MEMBER( scv_state::scv_cart_ram_w ) -{ - /* Check if cartridge ram is enabled */ - if ( m_cart_ram_enabled ) - { - m_cart_ram[offset] = data; - } -} - - -WRITE8_MEMBER( scv_state::scv_cart_ram2_w ) -{ - /* Check if cartridge ram is enabled */ - if ( m_cart_ram_enabled ) - { - if ( m_cart_ram_size > 0x1000 ) - { - offset += 0x1000; - } - - m_cart_ram[offset] = data; - } -} - - -WRITE8_MEMBER( scv_state::scv_porta_w ) +WRITE8_MEMBER( scv_state::porta_w ) { m_porta = data; } -READ8_MEMBER( scv_state::scv_portb_r ) +READ8_MEMBER( scv_state::portb_r ) { UINT8 data = 0xff; for (int i = 0; i < 8; i++) { if (!BIT(m_porta, i)) - data &= m_key[i]->read(); + data &= m_pa[i]->read(); } return data; } -READ8_MEMBER( scv_state::scv_portc_r ) +READ8_MEMBER( scv_state::portc_r ) { UINT8 data = m_portc; @@ -245,123 +197,15 @@ READ8_MEMBER( scv_state::scv_portc_r ) } -void scv_state::scv_set_banks() -{ - m_cart_ram_enabled = false; - - switch( m_cart_rom_size ) - { - case 0: - case 0x2000: - m_bank0->set_base( m_cart_rom ); - m_bank1->set_base( m_cart_rom ); - m_bank2->set_base( m_cart_rom ); - m_bank3->set_base( m_cart_rom ); - m_bank4->set_base( m_cart_rom + 0x1000 ); - break; - case 0x4000: - m_bank0->set_base( m_cart_rom ); - m_bank1->set_base( m_cart_rom + 0x2000 ); - m_bank2->set_base( m_cart_rom ); - m_bank3->set_base( m_cart_rom + 0x2000 ); - m_bank4->set_base( m_cart_rom + 0x3000 ); - break; - case 0x8000: - m_bank0->set_base( m_cart_rom ); - m_bank1->set_base( m_cart_rom + 0x2000 ); - m_bank2->set_base( m_cart_rom + 0x4000 ); - m_bank3->set_base( m_cart_rom + 0x6000 ); - m_bank4->set_base( m_cart_rom + 0x7000 ); - break; - case 0x10000: - m_bank0->set_base( m_cart_rom + ( ( m_portc & 0x20 ) ? 0x8000 : 0 ) ); - m_bank1->set_base( m_cart_rom + ( ( m_portc & 0x20 ) ? 0xa000 : 0x2000 ) ); - m_bank2->set_base( m_cart_rom + ( ( m_portc & 0x20 ) ? 0xc000 : 0x4000 ) ); - m_bank3->set_base( m_cart_rom + ( ( m_portc & 0x20 ) ? 0xe000 : 0x6000 ) ); - m_bank4->set_base( m_cart_rom + ( ( m_portc & 0x20 ) ? 0xf000 : 0x7000 ) ); - break; - case 0x20000: /* Pole Position 2 */ - int base = ( ( m_portc >> 5 ) & 0x03 ) * 0x8000 ; - m_bank0->set_base( m_cart_rom + base + 0 ); - m_bank1->set_base( m_cart_rom + base + 0x2000 ); - m_bank2->set_base( m_cart_rom + base + 0x4000 ); - m_bank3->set_base( m_cart_rom + base + 0x6000 ); - m_bank4->set_base( m_cart_rom + base + 0x7000 ); - /* On-cart RAM is enabled when PC6 is high */ - if ( m_cart_ram && m_portc & 0x40 ) - { - m_cart_ram_enabled = true; - m_bank4->set_base( m_cart_ram ); - } - break; - } - - /* Check if cartridge RAM is available and should be enabled */ - if ( m_cart_rom_size < 0x20000 && m_cart_ram && m_cart_ram_size && ( m_portc & 0x20 ) ) - { - if ( m_cart_ram_size == 0x1000 ) - { - m_bank4->set_base( m_cart_ram ); - } - else - { - m_bank3->set_base( m_cart_ram ); - m_bank4->set_base( m_cart_ram + 0x1000 ); - } - m_cart_ram_enabled = true; - } - -} - - -WRITE8_MEMBER( scv_state::scv_portc_w ) +WRITE8_MEMBER( scv_state::portc_w ) { //logerror("%04x: scv_portc_w: data = 0x%02x\n", m_maincpu->pc(), data ); m_portc = data; - - scv_set_banks(); + m_cart->write_bank(space, 0, m_portc); m_upd1771c->pcm_write(m_portc & 0x08); } -DEVICE_IMAGE_LOAD_MEMBER( scv_state, scv_cart ) -{ - UINT8 *cart = memregion( "cart" )->base(); - - if ( image.software_entry() == NULL ) - { - int size = image.length(); - - if ( size > memregion( "cart" )->bytes() ) - { - 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; - } - - m_cart_rom_size = size; - } - else - { - m_cart_rom_size = image.get_software_region_length( "rom" ); - memcpy( cart, image.get_software_region( "rom" ), m_cart_rom_size ); - m_cart_ram_size = image.get_software_region_length( "ram" ); - if ( m_cart_ram_size > 0 ) - { - m_cart_ram = auto_alloc_array_clear( machine(), UINT8, m_cart_ram_size ); - save_pointer(NAME(m_cart_ram), m_cart_ram_size); - } - } - - return IMAGE_INIT_PASS; -} - - PALETTE_INIT_MEMBER(scv_state, scv) { /* @@ -758,41 +602,26 @@ UINT32 scv_state::screen_update_scv(screen_device &screen, bitmap_ind16 &bitmap, } -WRITE_LINE_MEMBER( scv_state::scv_upd1771_ack_w ) +WRITE_LINE_MEMBER( scv_state::upd1771_ack_w ) { m_maincpu->set_input_line(UPD7810_INTF1, (state) ? ASSERT_LINE : CLEAR_LINE); } -void scv_state::scv_postload() -{ - scv_set_banks(); -} - - void scv_state::machine_start() { - m_cart_rom = memregion( "cart" )->base(); m_vb_timer = timer_alloc(TIMER_VB); - for (int i = 0; i < 8; i++) - { - char str[4]; - sprintf(str, "PA%i", i); - m_key[i] = ioport(str); - } - save_item(NAME(m_porta)); save_item(NAME(m_portc)); - save_item(NAME(m_cart_ram_enabled)); + if (m_cart->exists()) + m_cart->save_ram(); - machine().save().register_postload(save_prepost_delegate(FUNC(scv_state::scv_postload), this)); } void scv_state::machine_reset() { m_vb_timer->adjust(machine().first_screen()->time_until_pos(0, 0)); - scv_set_banks(); } @@ -815,13 +644,22 @@ static GFXDECODE_START( scv ) GFXDECODE_END +static SLOT_INTERFACE_START(scv_cart) + SLOT_INTERFACE_INTERNAL("rom8k", SCV_ROM8K) + SLOT_INTERFACE_INTERNAL("rom16k", SCV_ROM16K) + SLOT_INTERFACE_INTERNAL("rom32k", SCV_ROM32K) + SLOT_INTERFACE_INTERNAL("rom32k_ram", SCV_ROM32K_RAM8K) + SLOT_INTERFACE_INTERNAL("rom64k", SCV_ROM64K) + SLOT_INTERFACE_INTERNAL("rom128k", SCV_ROM128K) + SLOT_INTERFACE_INTERNAL("rom128k_ram", SCV_ROM128K_RAM4K) +SLOT_INTERFACE_END + static MACHINE_CONFIG_START( scv, scv_state ) MCFG_CPU_ADD( "maincpu", UPD7801, XTAL_4MHz ) MCFG_CPU_PROGRAM_MAP( scv_mem ) MCFG_CPU_IO_MAP( scv_io ) - /* Video chip is EPOCH TV-1 */ MCFG_SCREEN_ADD( "screen", RASTER ) MCFG_SCREEN_RAW_PARAMS( XTAL_14_31818MHz/2, 456, 24, 24+192, 262, 23, 23+222 ) /* TODO: Verify */ @@ -835,14 +673,10 @@ static MACHINE_CONFIG_START( scv, scv_state ) /* Sound is generated by UPD1771C clocked at XTAL_6MHz */ MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD( "upd1771c", UPD1771C, XTAL_6MHz ) - MCFG_UPD1771_ACK_HANDLER(WRITELINE(scv_state, scv_upd1771_ack_w)) + MCFG_UPD1771_ACK_HANDLER(WRITELINE(scv_state, upd1771_ack_w)) MCFG_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 ) - MCFG_CARTSLOT_ADD( "cart" ) - MCFG_CARTSLOT_EXTENSION_LIST( "bin" ) - MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_INTERFACE("scv_cart") - MCFG_CARTSLOT_LOAD( scv_state, scv_cart ) + MCFG_SCV_CARTRIDGE_ADD("cartslot", scv_cart, NULL) /* Software lists */ MCFG_SOFTWARE_LIST_ADD("cart_list","scv") @@ -850,7 +684,6 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( scv_pal, scv ) - MCFG_CPU_MODIFY( "maincpu" ) MCFG_CPU_CLOCK( 3780000 ) @@ -864,20 +697,18 @@ MACHINE_CONFIG_END ROM_START( scv ) ROM_REGION( 0x1000, "maincpu", 0 ) ROM_LOAD( "upd7801g.s01", 0, 0x1000, CRC(7ac06182) SHA1(6e89d1227581c76441a53d605f9e324185f1da33) ) + ROM_REGION( 0x400, "charrom", 0 ) ROM_LOAD( "epochtv.chr", 0, 0x400, BAD_DUMP CRC(db521533) SHA1(40b4e44838c35191f115437a14f200f052e71509) ) - - ROM_REGION( 0x20000, "cart", ROMREGION_ERASEFF ) ROM_END ROM_START( scv_pal ) ROM_REGION( 0x1000, "maincpu", 0 ) ROM_LOAD( "upd7801g.s01", 0, 0x1000, CRC(7ac06182) SHA1(6e89d1227581c76441a53d605f9e324185f1da33) ) + ROM_REGION( 0x400, "charrom", 0 ) ROM_LOAD( "epochtv.chr", 0, 0x400, BAD_DUMP CRC(db521533) SHA1(40b4e44838c35191f115437a14f200f052e71509) ) - - ROM_REGION( 0x20000, "cart", ROMREGION_ERASEFF ) ROM_END diff --git a/src/mess/drivers/vboy.c b/src/mess/drivers/vboy.c index 19b236fe3f2..de8c6d11003 100644 --- a/src/mess/drivers/vboy.c +++ b/src/mess/drivers/vboy.c @@ -28,8 +28,9 @@ #include "emu.h" #include "cpu/v810/v810.h" -#include "imagedev/cartslot.h" #include "audio/vboy.h" +#include "bus/vboy/slot.h" +#include "bus/vboy/rom.h" #include "vboy.lh" #define READ_BGMAP(bgoffs) m_bgmap[(bgoffs) & 0xffff] @@ -104,9 +105,10 @@ class vboy_state : public driver_device public: vboy_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_maintimer(*this, "timer_main"), m_maincpu(*this, "maincpu"), - m_palette(*this, "palette") + m_cart(*this, "cartslot"), + m_maintimer(*this, "timer_main"), + m_palette(*this, "palette") { m_vip_regs.INTPND = 0; m_vip_regs.INTENB = 0; @@ -151,32 +153,33 @@ public: m_vboy_timer.latch = 0; } - required_device m_maintimer; required_device m_maincpu; + required_device m_cart; + required_device m_maintimer; required_device m_palette; DECLARE_READ32_MEMBER(io_r); DECLARE_WRITE32_MEMBER(io_w); DECLARE_READ16_MEMBER(vip_r); DECLARE_WRITE16_MEMBER(vip_w); - DECLARE_WRITE16_MEMBER(vboy_font0_w); - DECLARE_WRITE16_MEMBER(vboy_font1_w); - DECLARE_WRITE16_MEMBER(vboy_font2_w); - DECLARE_WRITE16_MEMBER(vboy_font3_w); - DECLARE_READ16_MEMBER(vboy_font0_r); - DECLARE_READ16_MEMBER(vboy_font1_r); - DECLARE_READ16_MEMBER(vboy_font2_r); - DECLARE_READ16_MEMBER(vboy_font3_r); + DECLARE_WRITE16_MEMBER(font0_w); + DECLARE_WRITE16_MEMBER(font1_w); + DECLARE_WRITE16_MEMBER(font2_w); + DECLARE_WRITE16_MEMBER(font3_w); + DECLARE_READ16_MEMBER(font0_r); + DECLARE_READ16_MEMBER(font1_r); + DECLARE_READ16_MEMBER(font2_r); + DECLARE_READ16_MEMBER(font3_r); DECLARE_WRITE16_MEMBER(vboy_bgmap_w); DECLARE_READ16_MEMBER(vboy_bgmap_r); - DECLARE_READ8_MEMBER(vboy_lfb0_r); - DECLARE_READ8_MEMBER(vboy_lfb1_r); - DECLARE_READ8_MEMBER(vboy_rfb0_r); - DECLARE_READ8_MEMBER(vboy_rfb1_r); - DECLARE_WRITE8_MEMBER(vboy_lfb0_w); - DECLARE_WRITE8_MEMBER(vboy_lfb1_w); - DECLARE_WRITE8_MEMBER(vboy_rfb0_w); - DECLARE_WRITE8_MEMBER(vboy_rfb1_w); + DECLARE_READ8_MEMBER(lfb0_r); + DECLARE_READ8_MEMBER(lfb1_r); + DECLARE_READ8_MEMBER(rfb0_r); + DECLARE_READ8_MEMBER(rfb1_r); + DECLARE_WRITE8_MEMBER(lfb0_w); + DECLARE_WRITE8_MEMBER(lfb1_w); + DECLARE_WRITE8_MEMBER(rfb0_w); + DECLARE_WRITE8_MEMBER(rfb1_w); UINT16 *m_font; UINT16 *m_bgmap; UINT8 *m_l_frame_0; @@ -195,11 +198,6 @@ public: void m_timer_tick(void); void m_scanline_tick(int scanline, UINT8 screen_type); void m_set_irq(UINT16 irq_vector); - UINT8 *m_nvptr; - UINT32 m_vboy_sram[0x10000/4]; - device_t *m_nvimage; - DECLARE_READ32_MEMBER(sram_r); - DECLARE_WRITE32_MEMBER(sram_w); void put_obj(bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y, UINT16 code, UINT8 pal); void fill_ovr_char(UINT16 code, UINT8 pal); @@ -220,15 +218,11 @@ public: TIMER_DEVICE_CALLBACK_MEMBER(timer_pad_tick); TIMER_DEVICE_CALLBACK_MEMBER(vboy_scanlineL); TIMER_DEVICE_CALLBACK_MEMBER(vboy_scanlineR); - void vboy_machine_stop(); - DECLARE_DEVICE_IMAGE_LOAD_MEMBER(vboy_cart); }; void vboy_state::video_start() { - //int i; - // Allocate memory for temporary screens m_ovr_tempdraw_map = auto_alloc_array_clear(machine(), INT32, 0x40); @@ -1031,42 +1025,42 @@ WRITE16_MEMBER( vboy_state::vip_w ) -WRITE16_MEMBER( vboy_state::vboy_font0_w ) +WRITE16_MEMBER( vboy_state::font0_w ) { WRITE_FONT(offset); } -WRITE16_MEMBER( vboy_state::vboy_font1_w ) +WRITE16_MEMBER( vboy_state::font1_w ) { WRITE_FONT(offset+0x1000); } -WRITE16_MEMBER( vboy_state::vboy_font2_w ) +WRITE16_MEMBER( vboy_state::font2_w ) { WRITE_FONT(offset+0x2000); } -WRITE16_MEMBER( vboy_state::vboy_font3_w ) +WRITE16_MEMBER( vboy_state::font3_w ) { WRITE_FONT(offset+0x3000); } -READ16_MEMBER( vboy_state::vboy_font0_r ) +READ16_MEMBER( vboy_state::font0_r ) { return READ_FONT(offset); } -READ16_MEMBER( vboy_state::vboy_font1_r ) +READ16_MEMBER( vboy_state::font1_r ) { return READ_FONT(offset + 0x1000); } -READ16_MEMBER( vboy_state::vboy_font2_r ) +READ16_MEMBER( vboy_state::font2_r ) { return READ_FONT(offset + 0x2000); } -READ16_MEMBER( vboy_state::vboy_font3_r ) +READ16_MEMBER( vboy_state::font3_r ) { return READ_FONT(offset + 0x3000); } @@ -1081,72 +1075,72 @@ READ16_MEMBER( vboy_state::vboy_bgmap_r ) return m_bgmap[offset]; } -READ8_MEMBER( vboy_state::vboy_lfb0_r ) { return m_l_frame_0[offset]; } -READ8_MEMBER( vboy_state::vboy_lfb1_r ) { return m_l_frame_1[offset]; } -READ8_MEMBER( vboy_state::vboy_rfb0_r ) { return m_r_frame_0[offset]; } -READ8_MEMBER( vboy_state::vboy_rfb1_r ) { return m_r_frame_1[offset]; } -WRITE8_MEMBER( vboy_state::vboy_lfb0_w ) { m_l_frame_0[offset] = data; } -WRITE8_MEMBER( vboy_state::vboy_lfb1_w ) { m_l_frame_1[offset] = data; } -WRITE8_MEMBER( vboy_state::vboy_rfb0_w ) { m_r_frame_0[offset] = data; } -WRITE8_MEMBER( vboy_state::vboy_rfb1_w ) { m_r_frame_1[offset] = data; } +READ8_MEMBER( vboy_state::lfb0_r ) { return m_l_frame_0[offset]; } +READ8_MEMBER( vboy_state::lfb1_r ) { return m_l_frame_1[offset]; } +READ8_MEMBER( vboy_state::rfb0_r ) { return m_r_frame_0[offset]; } +READ8_MEMBER( vboy_state::rfb1_r ) { return m_r_frame_1[offset]; } +WRITE8_MEMBER( vboy_state::lfb0_w ) { m_l_frame_0[offset] = data; } +WRITE8_MEMBER( vboy_state::lfb1_w ) { m_l_frame_1[offset] = data; } +WRITE8_MEMBER( vboy_state::rfb0_w ) { m_r_frame_0[offset] = data; } +WRITE8_MEMBER( vboy_state::rfb1_w ) { m_r_frame_1[offset] = data; } static ADDRESS_MAP_START( vboy_mem, AS_PROGRAM, 32, vboy_state ) ADDRESS_MAP_GLOBAL_MASK(0x07ffffff) - AM_RANGE( 0x00000000, 0x00005fff ) AM_READWRITE8(vboy_lfb0_r,vboy_lfb0_w,0xffffffff) // L frame buffer 0 - AM_RANGE( 0x00006000, 0x00007fff ) AM_READWRITE16(vboy_font0_r, vboy_font0_w, 0xffffffff) // Font 0-511 - AM_RANGE( 0x00008000, 0x0000dfff ) AM_READWRITE8(vboy_lfb1_r,vboy_lfb1_w,0xffffffff) // L frame buffer 1 - AM_RANGE( 0x0000e000, 0x0000ffff ) AM_READWRITE16(vboy_font1_r, vboy_font1_w, 0xffffffff) // Font 512-1023 - AM_RANGE( 0x00010000, 0x00015fff ) AM_READWRITE8(vboy_rfb0_r,vboy_rfb0_w,0xffffffff) // R frame buffer 0 - AM_RANGE( 0x00016000, 0x00017fff ) AM_READWRITE16(vboy_font2_r, vboy_font2_w, 0xffffffff) // Font 1024-1535 - AM_RANGE( 0x00018000, 0x0001dfff ) AM_READWRITE8(vboy_rfb1_r,vboy_rfb1_w,0xffffffff) // R frame buffer 1 - AM_RANGE( 0x0001e000, 0x0001ffff ) AM_READWRITE16(vboy_font3_r, vboy_font3_w, 0xffffffff) // Font 1536-2047 + AM_RANGE( 0x00000000, 0x00005fff ) AM_READWRITE8(lfb0_r, lfb0_w,0xffffffff) // L frame buffer 0 + AM_RANGE( 0x00006000, 0x00007fff ) AM_READWRITE16(font0_r, font0_w, 0xffffffff) // Font 0-511 + AM_RANGE( 0x00008000, 0x0000dfff ) AM_READWRITE8(lfb1_r, lfb1_w,0xffffffff) // L frame buffer 1 + AM_RANGE( 0x0000e000, 0x0000ffff ) AM_READWRITE16(font1_r, font1_w, 0xffffffff) // Font 512-1023 + AM_RANGE( 0x00010000, 0x00015fff ) AM_READWRITE8(rfb0_r, rfb0_w,0xffffffff) // R frame buffer 0 + AM_RANGE( 0x00016000, 0x00017fff ) AM_READWRITE16(font2_r, font2_w, 0xffffffff) // Font 1024-1535 + AM_RANGE( 0x00018000, 0x0001dfff ) AM_READWRITE8(rfb1_r, rfb1_w,0xffffffff) // R frame buffer 1 + AM_RANGE( 0x0001e000, 0x0001ffff ) AM_READWRITE16(font3_r, font3_w, 0xffffffff) // Font 1536-2047 AM_RANGE( 0x00020000, 0x0003ffff ) AM_READWRITE16(vboy_bgmap_r,vboy_bgmap_w, 0xffffffff) // VIPC memory //AM_RANGE( 0x00040000, 0x0005ffff ) AM_RAM // VIPC AM_RANGE( 0x0005f800, 0x0005f87f ) AM_READWRITE16(vip_r, vip_w, 0xffffffff) - AM_RANGE( 0x00078000, 0x00079fff ) AM_READWRITE16(vboy_font0_r, vboy_font0_w, 0xffffffff) // Font 0-511 mirror - AM_RANGE( 0x0007a000, 0x0007bfff ) AM_READWRITE16(vboy_font1_r, vboy_font1_w, 0xffffffff) // Font 512-1023 mirror - AM_RANGE( 0x0007c000, 0x0007dfff ) AM_READWRITE16(vboy_font2_r, vboy_font2_w, 0xffffffff) // Font 1024-1535 mirror - AM_RANGE( 0x0007e000, 0x0007ffff ) AM_READWRITE16(vboy_font3_r, vboy_font3_w, 0xffffffff) // Font 1536-2047 mirror + AM_RANGE( 0x00078000, 0x00079fff ) AM_READWRITE16(font0_r, font0_w, 0xffffffff) // Font 0-511 mirror + AM_RANGE( 0x0007a000, 0x0007bfff ) AM_READWRITE16(font1_r, font1_w, 0xffffffff) // Font 512-1023 mirror + AM_RANGE( 0x0007c000, 0x0007dfff ) AM_READWRITE16(font2_r, font2_w, 0xffffffff) // Font 1024-1535 mirror + AM_RANGE( 0x0007e000, 0x0007ffff ) AM_READWRITE16(font3_r, font3_w, 0xffffffff) // Font 1536-2047 mirror AM_RANGE( 0x01000000, 0x010005ff ) AM_DEVREADWRITE8("vbsnd", vboysnd_device, read, write, 0xffffffff) AM_RANGE( 0x02000000, 0x0200002b ) AM_MIRROR(0x0ffff00) AM_READWRITE(io_r, io_w) // Hardware control registers mask 0xff //AM_RANGE( 0x04000000, 0x04ffffff ) // Expansion area AM_RANGE( 0x05000000, 0x0500ffff ) AM_MIRROR(0x0ff0000) AM_RAM AM_SHARE("wram")// Main RAM - 64K mask 0xffff -// AM_RANGE( 0x06000000, 0x06003fff ) AM_RAM AM_SHARE("nvram") // Cart RAM - 8K NVRAM - AM_RANGE( 0x07000000, 0x071fffff ) AM_MIRROR(0x0e00000) AM_ROM AM_REGION("cartridge", 0) /* ROM */ + AM_RANGE( 0x06000000, 0x06003fff ) AM_DEVREADWRITE("cartslot", vboy_cart_slot_device, read_eeprom, write_eeprom) // Cart RAM - 8K NVRAM + AM_RANGE( 0x07000000, 0x071fffff ) AM_MIRROR(0x0e00000) AM_DEVREAD("cartslot", vboy_cart_slot_device, read_cart) /* ROM */ ADDRESS_MAP_END static ADDRESS_MAP_START( vboy_io, AS_IO, 32, vboy_state ) ADDRESS_MAP_GLOBAL_MASK(0x07ffffff) AM_RANGE( 0x00000000, 0x00005fff ) AM_RAM AM_SHARE("l_frame_0") // L frame buffer 0 - AM_RANGE( 0x00006000, 0x00007fff ) AM_READWRITE16(vboy_font0_r, vboy_font0_w, 0xffffffff) // Font 0-511 + AM_RANGE( 0x00006000, 0x00007fff ) AM_READWRITE16(font0_r, font0_w, 0xffffffff) // Font 0-511 AM_RANGE( 0x00008000, 0x0000dfff ) AM_RAM AM_SHARE("l_frame_1") // L frame buffer 1 - AM_RANGE( 0x0000e000, 0x0000ffff ) AM_READWRITE16(vboy_font1_r, vboy_font1_w, 0xffffffff) // Font 512-1023 + AM_RANGE( 0x0000e000, 0x0000ffff ) AM_READWRITE16(font1_r, font1_w, 0xffffffff) // Font 512-1023 AM_RANGE( 0x00010000, 0x00015fff ) AM_RAM AM_SHARE("r_frame_0") // R frame buffer 0 - AM_RANGE( 0x00016000, 0x00017fff ) AM_READWRITE16(vboy_font2_r, vboy_font2_w, 0xffffffff) // Font 1024-1535 + AM_RANGE( 0x00016000, 0x00017fff ) AM_READWRITE16(font2_r, font2_w, 0xffffffff) // Font 1024-1535 AM_RANGE( 0x00018000, 0x0001dfff ) AM_RAM AM_SHARE("r_frame_1") // R frame buffer 1 - AM_RANGE( 0x0001e000, 0x0001ffff ) AM_READWRITE16(vboy_font3_r, vboy_font3_w, 0xffffffff) // Font 1536-2047 + AM_RANGE( 0x0001e000, 0x0001ffff ) AM_READWRITE16(font3_r, font3_w, 0xffffffff) // Font 1536-2047 AM_RANGE( 0x00020000, 0x0003ffff ) AM_READWRITE16(vboy_bgmap_r,vboy_bgmap_w, 0xffffffff) // VIPC memory //AM_RANGE( 0x00040000, 0x0005ffff ) AM_RAM // VIPC AM_RANGE( 0x0005f800, 0x0005f87f ) AM_READWRITE16(vip_r, vip_w, 0xffffffff) - AM_RANGE( 0x00078000, 0x00079fff ) AM_READWRITE16(vboy_font0_r, vboy_font0_w, 0xffffffff) // Font 0-511 mirror - AM_RANGE( 0x0007a000, 0x0007bfff ) AM_READWRITE16(vboy_font1_r, vboy_font1_w, 0xffffffff) // Font 512-1023 mirror - AM_RANGE( 0x0007c000, 0x0007dfff ) AM_READWRITE16(vboy_font2_r, vboy_font2_w, 0xffffffff) // Font 1024-1535 mirror - AM_RANGE( 0x0007e000, 0x0007ffff ) AM_READWRITE16(vboy_font3_r, vboy_font3_w, 0xffffffff) // Font 1536-2047 mirror + AM_RANGE( 0x00078000, 0x00079fff ) AM_READWRITE16(font0_r, font0_w, 0xffffffff) // Font 0-511 mirror + AM_RANGE( 0x0007a000, 0x0007bfff ) AM_READWRITE16(font1_r, font1_w, 0xffffffff) // Font 512-1023 mirror + AM_RANGE( 0x0007c000, 0x0007dfff ) AM_READWRITE16(font2_r, font2_w, 0xffffffff) // Font 1024-1535 mirror + AM_RANGE( 0x0007e000, 0x0007ffff ) AM_READWRITE16(font3_r, font3_w, 0xffffffff) // Font 1536-2047 mirror AM_RANGE( 0x01000000, 0x010005ff ) AM_DEVREADWRITE8("vbsnd", vboysnd_device, read, write, 0xffffffff) AM_RANGE( 0x02000000, 0x0200002b ) AM_MIRROR(0x0ffff00) AM_READWRITE(io_r, io_w) // Hardware control registers mask 0xff // AM_RANGE( 0x04000000, 0x04ffffff ) // Expansion area AM_RANGE( 0x05000000, 0x0500ffff ) AM_MIRROR(0x0ff0000) AM_RAM AM_SHARE("wram") // Main RAM - 64K mask 0xffff - AM_RANGE( 0x06000000, 0x06003fff ) AM_RAM AM_SHARE("nvram") // Cart RAM - 8K NVRAM - AM_RANGE( 0x07000000, 0x071fffff ) AM_MIRROR(0x0e00000) AM_ROM AM_REGION("cartridge", 0) /* ROM */ + AM_RANGE( 0x06000000, 0x06003fff ) AM_NOP // Cart RAM - 8K NVRAM ? + AM_RANGE( 0x07000000, 0x071fffff ) AM_MIRROR(0x0e00000) AM_DEVREAD("cartslot", vboy_cart_slot_device, read_cart) /* ROM */ ADDRESS_MAP_END /* Input ports */ @@ -1170,22 +1164,11 @@ static INPUT_PORTS_START( vboy ) PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_UNUSED ) // Battery low INPUT_PORTS_END -void vboy_state::vboy_machine_stop() -{ - // only do this if the cart loader detected some form of backup - if (m_nvptr != NULL) - { - device_image_interface *image = dynamic_cast(m_nvimage); - image->battery_save(m_nvptr, 0x10000); - } -} void vboy_state::machine_start() { - /* add a hook for battery save */ - machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(vboy_state::vboy_machine_stop),this)); - -// m_vboy_sram = auto_alloc_array(machine(), UINT32, 0x10000/4); + if (m_cart->exists()) + m_cart->save_eeprom(); } void vboy_state::machine_reset() @@ -1339,80 +1322,10 @@ TIMER_DEVICE_CALLBACK_MEMBER(vboy_state::vboy_scanlineR) #endif - -READ32_MEMBER(vboy_state::sram_r) -{ - return m_vboy_sram[offset]; -} - -WRITE32_MEMBER(vboy_state::sram_w) -{ - COMBINE_DATA(&m_vboy_sram[offset]); -} - - -DEVICE_IMAGE_LOAD_MEMBER( vboy_state, vboy_cart ) -{ - UINT32 chip = 0; - UINT8 *ROM = memregion("cartridge")->base(); - UINT32 cart_size; - - m_nvptr = (UINT8 *)NULL; - if (image.software_entry() == NULL) - { - cart_size = image.length(); - image.fread(ROM, cart_size); - switch (cart_size) - { - case 0x001000: - memcpy(ROM + 0x001000, ROM, 0x001000); - case 0x002000: - memcpy(ROM + 0x002000, ROM, 0x002000); - case 0x004000: - memcpy(ROM + 0x004000, ROM, 0x004000); - case 0x008000: - memcpy(ROM + 0x008000, ROM, 0x008000); - case 0x010000: - memcpy(ROM + 0x010000, ROM, 0x010000); - case 0x020000: - memcpy(ROM + 0x020000, ROM, 0x020000); - case 0x040000: - memcpy(ROM + 0x040000, ROM, 0x040000); - case 0x080000: - memcpy(ROM + 0x080000, ROM, 0x080000); - case 0x100000: - memcpy(ROM + 0x100000, ROM, 0x100000); - default: - break; - } - } - else - { - cart_size = image.get_software_region_length("rom"); - memcpy(ROM, image.get_software_region("rom"), cart_size); - - UINT8 *tmp_eeprom = image.get_software_region("eeprom"); - if (tmp_eeprom) - chip = 1; - } - - if (chip) - { - m_nvptr = (UINT8 *)&m_vboy_sram; - - m_maincpu->space(AS_PROGRAM).install_read_handler(0x06000000, 0x0600ffff, read32_delegate(FUNC(vboy_state::sram_r),this)); - m_maincpu->space(AS_PROGRAM).install_write_handler(0x06000000, 0x0600ffff, write32_delegate(FUNC(vboy_state::sram_w),this)); - - image.battery_load(m_nvptr, 0x10000, 0x00); - m_nvimage = image; - } - else - { - m_nvimage = NULL; - } - - return IMAGE_INIT_PASS; -} +static SLOT_INTERFACE_START(vboy_cart) + SLOT_INTERFACE_INTERNAL("vb_rom", VBOY_ROM_STD) + SLOT_INTERFACE_INTERNAL("vb_eeprom", VBOY_ROM_EEPROM) +SLOT_INTERFACE_END static MACHINE_CONFIG_START( vboy, vboy_state ) @@ -1423,7 +1336,6 @@ static MACHINE_CONFIG_START( vboy, vboy_state ) MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer_l", vboy_state, vboy_scanlineL, "3dleft", 0, 1) //MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer_r", vboy_state, vboy_scanlineR, "3dright", 0, 1) - // programmable timer MCFG_TIMER_DRIVER_ADD("timer_main", vboy_state, timer_main_tick) @@ -1448,11 +1360,7 @@ static MACHINE_CONFIG_START( vboy, vboy_state ) MCFG_SCREEN_PALETTE("palette") /* cartridge */ - MCFG_CARTSLOT_ADD("cart") - MCFG_CARTSLOT_EXTENSION_LIST("vb,bin") - MCFG_CARTSLOT_MANDATORY - MCFG_CARTSLOT_INTERFACE("vboy_cart") - MCFG_CARTSLOT_LOAD(vboy_state, vboy_cart) + MCFG_VBOY_CARTRIDGE_ADD("cartslot", vboy_cart, NULL) /* software lists */ MCFG_SOFTWARE_LIST_ADD("cart_list","vboy") @@ -1466,7 +1374,7 @@ MACHINE_CONFIG_END /* ROM definition */ ROM_START( vboy ) - ROM_REGION( 0x2000000, "cartridge", ROMREGION_ERASEFF ) + ROM_REGION( 0x2000000, "maincpu", ROMREGION_ERASEFF ) ROM_END /* Driver */ diff --git a/src/mess/mess.mak b/src/mess/mess.mak index 20d9f782168..47b18329e99 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -612,12 +612,14 @@ BUSES += RS232 BUSES += S100 BUSES += SATURN BUSES += SCSI +BUSES += SCV BUSES += SEGA8 BUSES += SMS_CTRL BUSES += SMS_EXP BUSES += SNES BUSES += TI99PEB BUSES += TVC +BUSES += VBOY BUSES += VCS BUSES += VCS_CTRL BUSES += VIC10