From 200f9a73499cff619677f109c6fd9c19e5d494fc Mon Sep 17 00:00:00 2001 From: EkeEke Date: Wed, 17 Sep 2014 23:37:40 +0200 Subject: [PATCH] [Core/MD] added support for Everdrive extended SSF mapper --- core/cart_hw/md_cart.c | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/core/cart_hw/md_cart.c b/core/cart_hw/md_cart.c index 8ba47f7..c4f34a6 100644 --- a/core/cart_hw/md_cart.c +++ b/core/cart_hw/md_cart.c @@ -60,6 +60,7 @@ typedef struct /* Function prototypes */ static void mapper_sega_w(uint32 data); +static void mapper_512k_w(uint32 address, uint32 data); static void mapper_ssf2_w(uint32 address, uint32 data); static void mapper_sf001_w(uint32 address, uint32 data); static void mapper_sf002_w(uint32 address, uint32 data); @@ -568,7 +569,15 @@ void md_cart_init(void) } /* detect specific mappers */ - if (strstr(rominfo.domestic,"SUPER STREET FIGHTER2")) + if (strstr(rominfo.consoletype,"SEGA SSF")) + { + /* Everdrive extended SSF mapper */ + cart.hw.bankshift = 1; + + /* specific !TIME handler */ + cart.hw.time_w = mapper_512k_w; + } + else if (strstr(rominfo.domestic,"SUPER STREET FIGHTER2")) { /* SSF2 mapper */ cart.hw.bankshift = 1; @@ -912,25 +921,38 @@ static void mapper_sega_w(uint32 data) } } +/* + Everdrive extended SSF ROM bankswitch + documented by Krikzz (http://krikzz.com/pub/support/mega-ed/dev/extended_ssf.txt) +*/ +static void mapper_512k_w(uint32 address, uint32 data) +{ + uint32 i; + + /* 512K ROM paging */ + uint8 *src = cart.rom + (data << 19); + + + /* cartridge area ($000000-$3FFFFF) is divided into 8 x 512K banks */ + address = (address << 2) & 0x38; + + /* remap selected ROM page to selected bank */ + for (i=0; i<8; i++) + { + m68k.memory_map[address++].base = src + (i<<16); + } +} + /* Super Street Fighter 2 ROM bankswitch - documented by Bart Trzynadlowski (http://www.trzy.org/files/ssf2.txt) + documented by Bart Trzynadlowski (http://emu-docs.org/Genesis/ssf2.txt) */ static void mapper_ssf2_w(uint32 address, uint32 data) { - /* 8 x 512k banks */ - address = (address << 2) & 0x38; - - /* bank 0 remains unchanged */ + /* only banks 1-7 are remappable, bank 0 remains unchanged */ if (address) { - uint32 i; - uint8 *src = cart.rom + (data << 19); - - for (i=0; i<8; i++) - { - m68k.memory_map[address++].base = src + (i<<16); - } + mapper_512k_w(address, data); } }