From b8c71acc15487907dd5b06935fe3dcf21b963b8c Mon Sep 17 00:00:00 2001 From: EkeEke Date: Tue, 26 Feb 2013 20:30:52 +0100 Subject: [PATCH] [Core/MD] added support for earlier revision of SF-001 mapper --- source/cart_hw/md_cart.c | 13 +++++++------ source/cart_hw/md_cart.h | 2 +- source/cart_hw/sram.c | 22 ++++++++++++++++------ source/cart_hw/sram.h | 2 +- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/source/cart_hw/md_cart.c b/source/cart_hw/md_cart.c index 5eb3a6f..35a9ec8 100644 --- a/source/cart_hw/md_cart.c +++ b/source/cart_hw/md_cart.c @@ -2,7 +2,7 @@ * Genesis Plus * Mega Drive cartridge hardware support * - * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX) * * Most cartridge protections were initially documented by Haze * (http://haze.mameworld.info/) @@ -904,8 +904,8 @@ static void mapper_sf001_w(uint32 address, uint32 data) zbank_memory_map[i].read = NULL; } - /* 256K ROM banks #2 to #15 mapped to $040000-$3BFFFF */ - for (i=0x04; i<0x3c; i++) + /* 256K ROM banks #2 to #15 mapped to $040000-$3BFFFF (last revision) or $040000-$3FFFFF (older revisions) */ + for (i=0x04; i<(sram.start >> 16); i++) { m68k.memory_map[i].base = cart.rom + (i << 16); m68k.memory_map[i].read8 = NULL; @@ -913,8 +913,8 @@ static void mapper_sf001_w(uint32 address, uint32 data) zbank_memory_map[i].read = NULL; } - /* 32K static RAM mirrored into $3C0000-$3FFFFF (odd bytes only) */ - for (i=0x3c; i<0x40; i++) + /* 32K static RAM mirrored into $3C0000-$3FFFFF (odd bytes only) (last revision only) */ + while (i<0x40) { m68k.memory_map[i].base = sram.sram; m68k.memory_map[i].read8 = NULL; @@ -923,11 +923,12 @@ static void mapper_sf001_w(uint32 address, uint32 data) m68k.memory_map[i].write16 = NULL; zbank_memory_map[i].read = NULL; zbank_memory_map[i].write = NULL; + i++; } } else { - /* 256K ROM banks #1 to #16 mapped to $000000-$3FFFFF */ + /* 256K ROM banks #1 to #16 mapped to $000000-$3FFFFF (default) */ for (i=0x00; i<0x40; i++) { m68k.memory_map[i].base = cart.rom + (i << 16); diff --git a/source/cart_hw/md_cart.h b/source/cart_hw/md_cart.h index 34858aa..24c0bee 100644 --- a/source/cart_hw/md_cart.h +++ b/source/cart_hw/md_cart.h @@ -2,7 +2,7 @@ * Genesis Plus * Mega Drive cartridge hardware support * - * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX) * * Most cartridge protections were initially documented by Haze * (http://haze.mameworld.info/) diff --git a/source/cart_hw/sram.c b/source/cart_hw/sram.c index ae83e01..665a864 100644 --- a/source/cart_hw/sram.c +++ b/source/cart_hw/sram.c @@ -2,7 +2,7 @@ * Genesis Plus * Backup RAM support * - * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -122,15 +122,25 @@ void sram_init() { /* Xin Qigai Wangzi (use uncommon area) */ sram.on = 1; - sram.start = 0x400000; + sram.start = 0x400001; sram.end = 0x40ffff; } else if ((strstr(rominfo.ROMType,"SF") != NULL) && (strstr(rominfo.product,"001") != NULL)) { - /* SF-001 (use bankswitching) */ + /* SF-001 */ sram.on = 1; - sram.start = 0x3c0001; - sram.end = 0x3cffff; + if (rominfo.checksum == 0x3e08) + { + /* last revision (use bankswitching) */ + sram.start = 0x3c0001; + sram.end = 0x3cffff; + } + else + { + /* older revisions (use uncommon area) */ + sram.start = 0x400001; + sram.end = 0x40ffff; + } } else if ((strstr(rominfo.ROMType,"SF") != NULL) && (strstr(rominfo.product,"004") != NULL)) { @@ -147,7 +157,7 @@ void sram_init() /* Sonic 3 & Knuckles combined ROM */ /* it shows S&K header but should obviously use FRAM from Sonic 3 */ sram.on = 1; - sram.start = 0x200000; + sram.start = 0x200001; sram.end = 0x203fff; } } diff --git a/source/cart_hw/sram.h b/source/cart_hw/sram.h index f7fd926..d838e69 100644 --- a/source/cart_hw/sram.h +++ b/source/cart_hw/sram.h @@ -2,7 +2,7 @@ * Genesis Plus * Backup RAM support * - * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: