From 519dfaece717102336f8f3bffc8b52e2a681a04f Mon Sep 17 00:00:00 2001 From: Wilbert Pol Date: Mon, 2 Jun 2014 19:22:54 +0000 Subject: [PATCH] (MESS) msx.c: Added harry fox mapper (nw) --- .gitattributes | 2 + hash/msx1_cart.xml | 4 +- src/emu/bus/bus.mak | 1 + src/emu/bus/msx_cart/cartridge.c | 2 + src/emu/bus/msx_cart/hfox.c | 78 ++++++++++++++++++++++++++++++++ src/emu/bus/msx_cart/hfox.h | 33 ++++++++++++++ 6 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 src/emu/bus/msx_cart/hfox.c create mode 100644 src/emu/bus/msx_cart/hfox.h diff --git a/.gitattributes b/.gitattributes index e9f06af3db8..d093866bde7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -999,6 +999,8 @@ src/emu/bus/msx_cart/crossblaim.c svneol=native#text/plain src/emu/bus/msx_cart/crossblaim.h svneol=native#text/plain src/emu/bus/msx_cart/fmpac.c svneol=native#text/plain src/emu/bus/msx_cart/fmpac.h svneol=native#text/plain +src/emu/bus/msx_cart/hfox.c svneol=native#text/plain +src/emu/bus/msx_cart/hfox.h svneol=native#text/plain src/emu/bus/msx_cart/konami.c svneol=native#text/plain src/emu/bus/msx_cart/konami.h svneol=native#text/plain src/emu/bus/msx_cart/korean.c svneol=native#text/plain diff --git a/hash/msx1_cart.xml b/hash/msx1_cart.xml index af69bb947ca..e4856384147 100644 --- a/hash/msx1_cart.xml +++ b/hash/msx1_cart.xml @@ -6535,13 +6535,13 @@ kept for now until finding out what those bytes affect... - + Hurry Fox - Yuki no Maou hen (Jpn) 1985 MicroCabin - + diff --git a/src/emu/bus/bus.mak b/src/emu/bus/bus.mak index 9aba456baba..3f07cf6c09b 100644 --- a/src/emu/bus/bus.mak +++ b/src/emu/bus/bus.mak @@ -411,6 +411,7 @@ BUSOBJS += $(BUSOBJ)/msx_cart/ascii.o BUSOBJS += $(BUSOBJ)/msx_cart/cartridge.o BUSOBJS += $(BUSOBJ)/msx_cart/crossblaim.o BUSOBJS += $(BUSOBJ)/msx_cart/fmpac.o +BUSOBJS += $(BUSOBJ)/msx_cart/hfox.o BUSOBJS += $(BUSOBJ)/msx_cart/konami.o BUSOBJS += $(BUSOBJ)/msx_cart/korean.o BUSOBJS += $(BUSOBJ)/msx_cart/majutsushi.o diff --git a/src/emu/bus/msx_cart/cartridge.c b/src/emu/bus/msx_cart/cartridge.c index fc686b79443..20dc60f739e 100644 --- a/src/emu/bus/msx_cart/cartridge.c +++ b/src/emu/bus/msx_cart/cartridge.c @@ -4,6 +4,7 @@ #include "ascii.h" #include "crossblaim.h" #include "fmpac.h" +#include "hfox.h" #include "konami.h" #include "korean.h" #include "majutsushi.h" @@ -42,6 +43,7 @@ SLOT_INTERFACE_START(msx_cart) SLOT_INTERFACE_INTERNAL("msxaud_fsca1", MSX_CART_MSX_AUDIO_FSCA1) SLOT_INTERFACE_INTERNAL("msxaud_nms1205", MSX_CART_MSX_AUDIO_NMS1205) SLOT_INTERFACE_INTERNAL("super_swangi", MSX_CART_SUPER_SWANGI) + SLOT_INTERFACE_INTERNAL("hfox", MSX_CART_HFOX) SLOT_INTERFACE_END diff --git a/src/emu/bus/msx_cart/hfox.c b/src/emu/bus/msx_cart/hfox.c new file mode 100644 index 00000000000..695845a54e2 --- /dev/null +++ b/src/emu/bus/msx_cart/hfox.c @@ -0,0 +1,78 @@ +#include "emu.h" +#include "hfox.h" + + +const device_type MSX_CART_HFOX = &device_creator; + + +msx_cart_hfox::msx_cart_hfox(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, MSX_CART_HFOX, "MSX Cartridge - Harry Fox", tag, owner, clock, "msx_cart_hfox", __FILE__) + , msx_cart_interface(mconfig, *this) +{ + m_selected_bank[0] = m_selected_bank[1] = 0; + m_bank_base[0] = m_bank_base[1] = NULL; +} + + +void msx_cart_hfox::device_start() +{ + save_item(NAME(m_selected_bank)); + + machine().save().register_postload(save_prepost_delegate(FUNC(msx_cart_hfox::restore_banks), this)); +} + + +void msx_cart_hfox::restore_banks() +{ + m_bank_base[0] = get_rom_base() + ((m_selected_bank[0] & 0x01) * 0x8000); + m_bank_base[1] = get_rom_base() + ((m_selected_bank[1] & 0x01) * 0x8000) + 0x4000; +} + + +void msx_cart_hfox::device_reset() +{ + m_selected_bank[0] = m_selected_bank[1] = 0; +} + + +void msx_cart_hfox::initialize_cartridge() +{ + if (get_rom_size() < 0x10000) + { + fatalerror("rtype: Invalid ROM size\n"); + } + + restore_banks(); +} + + +READ8_MEMBER(msx_cart_hfox::read_cart) +{ + if (offset >= 0x4000 && offset < 0xc000) + { + return m_bank_base[offset >> 15][offset & 0x3fff]; + } + return 0xff; +} + + +WRITE8_MEMBER(msx_cart_hfox::write_cart) +{ + switch (offset) + { + case 0x6000: + m_selected_bank[0] = data; + restore_banks(); + break; + + case 0x7000: + m_selected_bank[1] = data; + restore_banks(); + break; + + default: + printf("msx_cart_hfox: unhandled write %02x to %04x\n", data, offset); + break; + } +} + diff --git a/src/emu/bus/msx_cart/hfox.h b/src/emu/bus/msx_cart/hfox.h new file mode 100644 index 00000000000..ce36492be36 --- /dev/null +++ b/src/emu/bus/msx_cart/hfox.h @@ -0,0 +1,33 @@ +#ifndef __MSX_CART_HFOX_H +#define __MSX_CART_HFOX_H + +#include "bus/msx_cart/cartridge.h" + + +extern const device_type MSX_CART_HFOX; + + +class msx_cart_hfox : public device_t + , public msx_cart_interface +{ +public: + msx_cart_hfox(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + virtual void initialize_cartridge(); + + virtual DECLARE_READ8_MEMBER(read_cart); + virtual DECLARE_WRITE8_MEMBER(write_cart); + + void restore_banks(); + +private: + UINT8 m_selected_bank[2]; + UINT8 *m_bank_base[2]; +}; + + +#endif