[Core/MD] added SRAM support for games larger than 8MB

This commit is contained in:
ekeeke 2021-08-08 16:48:49 +02:00
parent cc8a6725a7
commit e6ab7563e7
10 changed files with 41 additions and 44 deletions

View File

@ -56,6 +56,7 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke)
* added support for Everdrive extended SSF mapper * added support for Everdrive extended SSF mapper
* added (very basic) emulation of Flashkit MD hardware * added (very basic) emulation of Flashkit MD hardware
* added emulation of Micro Machines USA on-board TMSS bypass logic 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 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 I2C EEPROM boards emulation accuracy
* improved SVP memory handlers accuracy (fixes Virtua Racing debug mode) * improved SVP memory handlers accuracy (fixes Virtua Racing debug mode)

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Action Replay / Pro Action Replay emulation * 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 * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -63,10 +63,10 @@ void areplay_init(void)
memset(&action_replay,0,sizeof(action_replay)); memset(&action_replay,0,sizeof(action_replay));
/* store Action replay ROM (max. 128k) & RAM (64k) above cartridge ROM + SRAM area */ /* store Action replay ROM (max. 128KB) & RAM (64KB) above cartridge ROM (max. 8MB) */
if (cart.romsize > 0x810000) return; if (cart.romsize > 0x800000) return;
action_replay.rom = cart.rom + 0x810000; action_replay.rom = cart.rom + 0x800000;
action_replay.ram = cart.rom + 0x830000; action_replay.ram = cart.rom + 0x820000;
/* try to load Action Replay ROM file */ /* try to load Action Replay ROM file */
size = load_archive(AR_ROM, action_replay.rom, 0x20000, NULL); size = load_archive(AR_ROM, action_replay.rom, 0x20000, NULL);

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* DATEL Action Replay / Pro Action Replay emulation * 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 * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Game Genie Hardware emulation * 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 * Based on documentation from Charles McDonald
* (http://cgfm2.emuviews.com/txt/genie.txt) * (http://cgfm2.emuviews.com/txt/genie.txt)
@ -61,9 +61,9 @@ void ggenie_init(void)
{ {
memset(&ggenie,0,sizeof(ggenie)); memset(&ggenie,0,sizeof(ggenie));
/* Store Game Genie ROM (32k) above cartridge ROM + SRAM area */ /* Store Game Genie ROM (32KB) above cartridge ROM (max. 8MB) */
if (cart.romsize > 0x810000) return; if (cart.romsize > 0x800000) return;
ggenie.rom = cart.rom + 0x810000; ggenie.rom = cart.rom + 0x800000;
/* Try to load Game Genie ROM file */ /* Try to load Game Genie ROM file */
if (load_archive(GG_ROM, ggenie.rom, 0x8000, NULL) > 0) if (load_archive(GG_ROM, ggenie.rom, 0x8000, NULL) > 0)

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Game Genie Hardware emulation * 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 * Based on documentation from Charles McDonald
* (http://cgfm2.emuviews.com/txt/genie.txt) * (http://cgfm2.emuviews.com/txt/genie.txt)

View File

@ -478,39 +478,39 @@ void md_cart_init(void)
case TYPE_SK: case TYPE_SK:
{ {
/* store S&K ROM above cartridge ROM (and before backup memory) */ /* store Sonic & Knuckles ROM files after cartridge ROM area */
if (cart.romsize > 0x600000) break; if (cart.romsize > 0x400000) break;
/* try to load Sonic & Knuckles ROM file (2 MB) */ /* try to load Sonic & Knuckles ROM file (2MB) */
if (load_archive(SK_ROM, cart.rom + 0x600000, 0x200000, NULL) == 0x200000) if (load_archive(SK_ROM, cart.rom + 0x400000, 0x200000, NULL) == 0x200000)
{ {
/* check ROM header */ /* 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) */ /* try to load Sonic 2 & Knuckles upmem ROM file (256KB) */
if (load_archive(SK_UPMEM, cart.rom + 0x900000, 0x40000, NULL) == 0x40000) if (load_archive(SK_UPMEM, cart.rom + 0x600000, 0x40000, NULL) == 0x40000)
{ {
/* $000000-$1FFFFF is mapped to S&K ROM */ /* $000000-$1FFFFF is mapped to S&K ROM */
for (i=0x00; i<0x20; i++) 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 #ifdef LSB_FIRST
for (i=0; i<0x200000; i+=2) for (i=0; i<0x200000; i+=2)
{ {
/* Byteswap ROM */ /* Byteswap ROM */
uint8 temp = cart.rom[i + 0x600000]; uint8 temp = cart.rom[i + 0x400000];
cart.rom[i + 0x600000] = cart.rom[i + 0x600000 + 1]; cart.rom[i + 0x400000] = cart.rom[i + 0x400000 + 1];
cart.rom[i + 0x600000 + 1] = temp; cart.rom[i + 0x400000 + 1] = temp;
} }
for (i=0; i<0x40000; i+=2) for (i=0; i<0x40000; i+=2)
{ {
/* Byteswap ROM */ /* Byteswap ROM */
uint8 temp = cart.rom[i + 0x900000]; uint8 temp = cart.rom[i + 0x600000];
cart.rom[i + 0x900000] = cart.rom[i + 0x900000 + 1]; cart.rom[i + 0x600000] = cart.rom[i + 0x600000 + 1];
cart.rom[i + 0x900000 + 1] = temp; cart.rom[i + 0x600000 + 1] = temp;
} }
#endif #endif
cart.special |= HW_LOCK_ON; cart.special |= HW_LOCK_ON;
@ -569,16 +569,16 @@ void md_cart_init(void)
/* Realtec mapper */ /* Realtec mapper */
if (cart.hw.realtec) if (cart.hw.realtec)
{ {
/* 8k BOOT ROM */ /* copy 8KB Boot ROM after cartridge ROM area */
for (i=0; i<8; i++) 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++) 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 */ /* 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++) 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);
} }
} }
} }

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Backup RAM support * 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 * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -61,11 +61,8 @@ T_SRAM sram;
****************************************************************************/ ****************************************************************************/
void sram_init() void sram_init()
{ {
memset(&sram, 0, sizeof (T_SRAM)); /* disable Backup RAM by default */
sram.detected = sram.on = sram.custom = sram.start = sram.end = 0;
/* backup RAM data is stored above cartridge ROM area, at $800000-$80FFFF (max. 64K) */
if (cart.romsize > 0x800000) return;
sram.sram = cart.rom + 0x800000;
/* initialize Backup RAM */ /* initialize Backup RAM */
if (strstr(rominfo.international,"Sonic 1 Remastered")) if (strstr(rominfo.international,"Sonic 1 Remastered"))

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* Backup RAM support * 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 * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -47,7 +47,7 @@ typedef struct
uint32 start; uint32 start;
uint32 end; uint32 end;
uint32 crc; uint32 crc;
uint8 *sram; uint8 sram[0x10000];
} T_SRAM; } T_SRAM;
/* Function prototypes */ /* Function prototypes */

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* CD compatible ROM/RAM cartridge support * 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 * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -38,7 +38,6 @@
#include "shared.h" #include "shared.h"
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* backup RAM cartridge (max. 512KB) */ /* backup RAM cartridge (max. 512KB) */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* CD compatible ROM/RAM cartridge support * 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 * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -41,7 +41,7 @@
typedef struct typedef struct
{ {
uint8 reserved[0x80]; /* reserved for ROM cartridge infos (see md_cart.h) */ 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 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 id; /* RAM cartridge ID (related to RAM size, 0 if disabled) */
uint8 prot; /* RAM cartridge write protection */ uint8 prot; /* RAM cartridge write protection */