diff --git a/HISTORY.txt b/HISTORY.txt index 9cea7fb..f30a2cf 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -56,6 +56,7 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke) * added support for Everdrive extended SSF mapper * added (very basic) emulation of Flashkit MD hardware * added emulation of Micro Machines USA on-board TMSS bypass logic hardware +* added SRAM support for games larger than 8MB * improved console region auto-detection for a few PAL-only games (The Smurfs Travel the World & Williams Arcade's Greatest Hits) * improved I2C EEPROM boards emulation accuracy * improved SVP memory handlers accuracy (fixes Virtua Racing debug mode) diff --git a/core/cart_hw/areplay.c b/core/cart_hw/areplay.c index 73b16a4..b066716 100644 --- a/core/cart_hw/areplay.c +++ b/core/cart_hw/areplay.c @@ -2,7 +2,7 @@ * Genesis Plus * Action Replay / Pro Action Replay emulation * - * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2009-2021 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -63,10 +63,10 @@ void areplay_init(void) memset(&action_replay,0,sizeof(action_replay)); - /* store Action replay ROM (max. 128k) & RAM (64k) above cartridge ROM + SRAM area */ - if (cart.romsize > 0x810000) return; - action_replay.rom = cart.rom + 0x810000; - action_replay.ram = cart.rom + 0x830000; + /* store Action replay ROM (max. 128KB) & RAM (64KB) above cartridge ROM (max. 8MB) */ + if (cart.romsize > 0x800000) return; + action_replay.rom = cart.rom + 0x800000; + action_replay.ram = cart.rom + 0x820000; /* try to load Action Replay ROM file */ size = load_archive(AR_ROM, action_replay.rom, 0x20000, NULL); diff --git a/core/cart_hw/areplay.h b/core/cart_hw/areplay.h index d4e8f26..3b4f2a9 100644 --- a/core/cart_hw/areplay.h +++ b/core/cart_hw/areplay.h @@ -2,7 +2,7 @@ * Genesis Plus * DATEL Action Replay / Pro Action Replay emulation * - * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2009-2021 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: diff --git a/core/cart_hw/ggenie.c b/core/cart_hw/ggenie.c index 8fc3b23..f9fdbf7 100644 --- a/core/cart_hw/ggenie.c +++ b/core/cart_hw/ggenie.c @@ -2,7 +2,7 @@ * Genesis Plus * Game Genie Hardware emulation * - * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2009-2021 Eke-Eke (Genesis Plus GX) * * Based on documentation from Charles McDonald * (http://cgfm2.emuviews.com/txt/genie.txt) @@ -61,9 +61,9 @@ void ggenie_init(void) { memset(&ggenie,0,sizeof(ggenie)); - /* Store Game Genie ROM (32k) above cartridge ROM + SRAM area */ - if (cart.romsize > 0x810000) return; - ggenie.rom = cart.rom + 0x810000; + /* Store Game Genie ROM (32KB) above cartridge ROM (max. 8MB) */ + if (cart.romsize > 0x800000) return; + ggenie.rom = cart.rom + 0x800000; /* Try to load Game Genie ROM file */ if (load_archive(GG_ROM, ggenie.rom, 0x8000, NULL) > 0) diff --git a/core/cart_hw/ggenie.h b/core/cart_hw/ggenie.h index a67f007..b61f611 100644 --- a/core/cart_hw/ggenie.h +++ b/core/cart_hw/ggenie.h @@ -2,7 +2,7 @@ * Genesis Plus * Game Genie Hardware emulation * - * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2009-2021 Eke-Eke (Genesis Plus GX) * * Based on documentation from Charles McDonald * (http://cgfm2.emuviews.com/txt/genie.txt) diff --git a/core/cart_hw/md_cart.c b/core/cart_hw/md_cart.c index cc5a445..5c7602b 100644 --- a/core/cart_hw/md_cart.c +++ b/core/cart_hw/md_cart.c @@ -478,39 +478,39 @@ void md_cart_init(void) case TYPE_SK: { - /* store S&K ROM above cartridge ROM (and before backup memory) */ - if (cart.romsize > 0x600000) break; + /* store Sonic & Knuckles ROM files after cartridge ROM area */ + if (cart.romsize > 0x400000) break; - /* try to load Sonic & Knuckles ROM file (2 MB) */ - if (load_archive(SK_ROM, cart.rom + 0x600000, 0x200000, NULL) == 0x200000) + /* try to load Sonic & Knuckles ROM file (2MB) */ + if (load_archive(SK_ROM, cart.rom + 0x400000, 0x200000, NULL) == 0x200000) { /* check ROM header */ - if (!memcmp(cart.rom + 0x600000 + 0x120, "SONIC & KNUCKLES",16)) + if (!memcmp(cart.rom + 0x400000 + 0x120, "SONIC & KNUCKLES",16)) { - /* try to load Sonic 2 & Knuckles UPMEM ROM (256 KB) */ - if (load_archive(SK_UPMEM, cart.rom + 0x900000, 0x40000, NULL) == 0x40000) + /* try to load Sonic 2 & Knuckles upmem ROM file (256KB) */ + if (load_archive(SK_UPMEM, cart.rom + 0x600000, 0x40000, NULL) == 0x40000) { /* $000000-$1FFFFF is mapped to S&K ROM */ for (i=0x00; i<0x20; i++) { - m68k.memory_map[i].base = cart.rom + 0x600000 + (i << 16); + m68k.memory_map[i].base = cart.rom + 0x400000 + (i << 16); } #ifdef LSB_FIRST for (i=0; i<0x200000; i+=2) { /* Byteswap ROM */ - uint8 temp = cart.rom[i + 0x600000]; - cart.rom[i + 0x600000] = cart.rom[i + 0x600000 + 1]; - cart.rom[i + 0x600000 + 1] = temp; + uint8 temp = cart.rom[i + 0x400000]; + cart.rom[i + 0x400000] = cart.rom[i + 0x400000 + 1]; + cart.rom[i + 0x400000 + 1] = temp; } for (i=0; i<0x40000; i+=2) { /* Byteswap ROM */ - uint8 temp = cart.rom[i + 0x900000]; - cart.rom[i + 0x900000] = cart.rom[i + 0x900000 + 1]; - cart.rom[i + 0x900000 + 1] = temp; + uint8 temp = cart.rom[i + 0x600000]; + cart.rom[i + 0x600000] = cart.rom[i + 0x600000 + 1]; + cart.rom[i + 0x600000 + 1] = temp; } #endif cart.special |= HW_LOCK_ON; @@ -569,16 +569,16 @@ void md_cart_init(void) /* Realtec mapper */ if (cart.hw.realtec) { - /* 8k BOOT ROM */ + /* copy 8KB Boot ROM after cartridge ROM area */ for (i=0; i<8; i++) { - memcpy(cart.rom + 0x900000 + i*0x2000, cart.rom + 0x7e000, 0x2000); + memcpy(cart.rom + 0x400000 + i*0x2000, cart.rom + 0x7e000, 0x2000); } - /* BOOT ROM is mapped to $000000-$3FFFFF */ + /* Boot ROM (8KB mirrored) is mapped to $000000-$3FFFFF */ for (i=0x00; i<0x40; i++) { - m68k.memory_map[i].base = cart.rom + 0x900000; + m68k.memory_map[i].base = cart.rom + 0x400000; } } @@ -953,12 +953,12 @@ static void mapper_sega_w(uint32 data) } /* S&K lock-on chip */ - if ((cart.special & HW_LOCK_ON) && (config.lock_on == TYPE_SK)) + if (cart.special & HW_LOCK_ON) { - /* S2K upmem chip mapped to $300000-$3fffff (256K mirrored) */ + /* S2K upmem chip mapped to $300000-$3fffff (256KB mirrored) */ for (i=0x30; i<0x40; i++) { - m68k.memory_map[i].base = (cart.rom + 0x900000) + ((i & 3) << 16); + m68k.memory_map[i].base = (cart.rom + 0x600000) + ((i & 3) << 16); } } } diff --git a/core/cart_hw/sram.c b/core/cart_hw/sram.c index 58ef404..4abc91e 100644 --- a/core/cart_hw/sram.c +++ b/core/cart_hw/sram.c @@ -2,7 +2,7 @@ * Genesis Plus * Backup RAM support * - * Copyright (C) 2007-2020 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2021 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -61,11 +61,8 @@ T_SRAM sram; ****************************************************************************/ void sram_init() { - memset(&sram, 0, sizeof (T_SRAM)); - - /* backup RAM data is stored above cartridge ROM area, at $800000-$80FFFF (max. 64K) */ - if (cart.romsize > 0x800000) return; - sram.sram = cart.rom + 0x800000; + /* disable Backup RAM by default */ + sram.detected = sram.on = sram.custom = sram.start = sram.end = 0; /* initialize Backup RAM */ if (strstr(rominfo.international,"Sonic 1 Remastered")) diff --git a/core/cart_hw/sram.h b/core/cart_hw/sram.h index 3b505c5..e33f6e4 100644 --- a/core/cart_hw/sram.h +++ b/core/cart_hw/sram.h @@ -2,7 +2,7 @@ * Genesis Plus * Backup RAM support * - * Copyright (C) 2007-2020 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2021 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -47,7 +47,7 @@ typedef struct uint32 start; uint32 end; uint32 crc; - uint8 *sram; + uint8 sram[0x10000]; } T_SRAM; /* Function prototypes */ diff --git a/core/cd_hw/cd_cart.c b/core/cd_hw/cd_cart.c index 09e84df..a380bd2 100644 --- a/core/cd_hw/cd_cart.c +++ b/core/cd_hw/cd_cart.c @@ -2,7 +2,7 @@ * Genesis Plus * CD compatible ROM/RAM cartridge support * - * Copyright (C) 2012-2016 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2012-2021 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -38,7 +38,6 @@ #include "shared.h" - /*--------------------------------------------------------------------------*/ /* backup RAM cartridge (max. 512KB) */ /*--------------------------------------------------------------------------*/ diff --git a/core/cd_hw/cd_cart.h b/core/cd_hw/cd_cart.h index 6ee7cad..a0e7482 100644 --- a/core/cd_hw/cd_cart.h +++ b/core/cd_hw/cd_cart.h @@ -2,7 +2,7 @@ * Genesis Plus * CD compatible ROM/RAM cartridge support * - * Copyright (C) 2012-2016 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2012-2021 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -41,7 +41,7 @@ typedef struct { uint8 reserved[0x80]; /* reserved for ROM cartridge infos (see md_cart.h) */ - uint8 area[0x840000]; /* cartridge ROM/RAM area (max. 8MB ROM + 64KB backup memory + Pro Action Replay 128KB ROM / 64KB RAM) */ + uint8 area[0x830000]; /* cartridge ROM/RAM area (max. 8MB ROM + Pro Action Replay 128KB ROM / 64KB RAM) */ uint8 boot; /* cartridge boot mode (0x00: boot from CD with ROM/RAM cartridge enabled, 0x40: boot from ROM cartridge with CD enabled) */ uint8 id; /* RAM cartridge ID (related to RAM size, 0 if disabled) */ uint8 prot; /* RAM cartridge write protection */