mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2025-03-04 10:45:32 +01:00
[Gamecube/Wii][libretro] added Mega-CD PRG-RAM & Word-RAM cheat codes support
This commit is contained in:
parent
0f9d57d6b8
commit
98b5c60355
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 3.8 MiB After Width: | Height: | Size: 3.8 MiB |
Binary file not shown.
Before Width: | Height: | Size: 4.0 MiB After Width: | Height: | Size: 4.0 MiB |
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Genesis Plus GX Cheats menu
|
||||
*
|
||||
* Copyright Eke-Eke (2010-2019)
|
||||
* Copyright Eke-Eke (2010-2022)
|
||||
*
|
||||
* Redistribution and use of this code or any derivative works are permitted
|
||||
* provided that the following conditions are met:
|
||||
@ -456,7 +456,33 @@ static void apply_cheats(void)
|
||||
{
|
||||
if (cheatlist[i].enable)
|
||||
{
|
||||
if (cheatlist[i].address < cart.romsize)
|
||||
/* detect Work RAM patch */
|
||||
if (cheatlist[i].address >= 0xFF0000)
|
||||
{
|
||||
/* add RAM patch */
|
||||
cheatIndexes[maxRAMcheats++] = i;
|
||||
}
|
||||
|
||||
/* check if Mega-CD game is running */
|
||||
else if ((system_hw == SYSTEM_MCD) && !scd.cartridge.boot)
|
||||
{
|
||||
/* detect PRG-RAM patch (Sub-CPU side) */
|
||||
if (cheatlist[i].address < 0x80000)
|
||||
{
|
||||
/* add RAM patch */
|
||||
cheatIndexes[maxRAMcheats++] = i;
|
||||
}
|
||||
|
||||
/* detect Word-RAM patch (Main-CPU side)*/
|
||||
else if ((cheatlist[i].address >= 0x200000) && (cheatlist[i].address < 0x240000))
|
||||
{
|
||||
/* add RAM patch */
|
||||
cheatIndexes[maxRAMcheats++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
/* detect cartridge ROM patch */
|
||||
else if (cheatlist[i].address < cart.romsize)
|
||||
{
|
||||
if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
||||
{
|
||||
@ -489,20 +515,20 @@ static void apply_cheats(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cheatlist[i].address >= 0xFF0000)
|
||||
{
|
||||
/* add RAM patch */
|
||||
cheatIndexes[maxRAMcheats++] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_cheats(void)
|
||||
{
|
||||
int i = maxcheats;
|
||||
int i;
|
||||
|
||||
/* disable cheats in reversed order in case the same address is used by multiple patches */
|
||||
/* no ROM patches with Mega-CD games */
|
||||
if ((system_hw == SYSTEM_MCD) && !scd.cartridge.boot)
|
||||
return;
|
||||
|
||||
/* disable cheats in reversed order in case the same address is used by multiple ROM patches */
|
||||
i = maxcheats;
|
||||
while (i > 0)
|
||||
{
|
||||
if (cheatlist[i-1].enable)
|
||||
@ -1501,6 +1527,8 @@ void CheatLoad(void)
|
||||
****************************************************************************/
|
||||
void RAMCheatUpdate(void)
|
||||
{
|
||||
uint8 *base;
|
||||
uint32 mask;
|
||||
int index, cnt = maxRAMcheats;
|
||||
|
||||
while (cnt)
|
||||
@ -1508,16 +1536,36 @@ void RAMCheatUpdate(void)
|
||||
/* get cheat index */
|
||||
index = cheatIndexes[--cnt];
|
||||
|
||||
/* detect destination RAM */
|
||||
switch ((cheatlist[index].address >> 20) & 0xf)
|
||||
{
|
||||
case 0x0: /* Mega-CD PRG-RAM (512 KB) */
|
||||
base = scd.prg_ram;
|
||||
mask = 0x7fffe;
|
||||
break;
|
||||
|
||||
case 0x2: /* Mega-CD 2M Word-RAM (256 KB) */
|
||||
base = scd.word_ram_2M;
|
||||
mask = 0x3fffe;
|
||||
break;
|
||||
|
||||
default: /* Work-RAM (64 KB) */
|
||||
base = work_ram;
|
||||
mask = 0xfffe;
|
||||
break;
|
||||
}
|
||||
|
||||
/* apply RAM patch */
|
||||
if (cheatlist[index].data & 0xFF00)
|
||||
{
|
||||
/* word patch */
|
||||
*(u16 *)(work_ram + (cheatlist[index].address & 0xFFFE)) = cheatlist[index].data;
|
||||
*(u16 *)(base + (cheatlist[index].address & mask)) = cheatlist[index].data;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* byte patch */
|
||||
work_ram[cheatlist[index].address & 0xFFFF] = cheatlist[index].data;
|
||||
mask |= 1;
|
||||
base[cheatlist[index].address & mask] = cheatlist[index].data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Genesis Plus GX Cheats menu
|
||||
*
|
||||
* Copyright Eke-Eke (2010-2019)
|
||||
* Copyright Eke-Eke (2010-2022)
|
||||
*
|
||||
* Redistribution and use of this code or any derivative works are permitted
|
||||
* provided that the following conditions are met:
|
||||
|
@ -2245,12 +2245,32 @@ static void apply_cheats(void)
|
||||
{
|
||||
if (cheatlist[i].address < cart.romsize)
|
||||
{
|
||||
if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
||||
/* detect Work RAM patch */
|
||||
if (cheatlist[i].address >= 0xFF0000)
|
||||
{
|
||||
/* patch ROM data */
|
||||
cheatlist[i].old = *(uint16_t *)(cart.rom + (cheatlist[i].address & 0xFFFFFE));
|
||||
*(uint16_t *)(cart.rom + (cheatlist[i].address & 0xFFFFFE)) = cheatlist[i].data;
|
||||
/* add RAM patch */
|
||||
cheatIndexes[maxRAMcheats++] = i;
|
||||
}
|
||||
|
||||
/* check if Mega-CD game is running */
|
||||
else if ((system_hw == SYSTEM_MCD) && !scd.cartridge.boot)
|
||||
{
|
||||
/* detect PRG-RAM patch (Sub-CPU side) */
|
||||
if (cheatlist[i].address < 0x80000)
|
||||
{
|
||||
/* add RAM patch */
|
||||
cheatIndexes[maxRAMcheats++] = i;
|
||||
}
|
||||
|
||||
/* detect Word-RAM patch (Main-CPU side)*/
|
||||
else if ((cheatlist[i].address >= 0x200000) && (cheatlist[i].address < 0x240000))
|
||||
{
|
||||
/* add RAM patch */
|
||||
cheatIndexes[maxRAMcheats++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
/* detect cartridge ROM patch */
|
||||
else
|
||||
{
|
||||
/* add ROM patch */
|
||||
@ -2273,19 +2293,20 @@ static void apply_cheats(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cheatlist[i].address >= 0xFF0000)
|
||||
{
|
||||
/* add RAM patch */
|
||||
cheatIndexes[maxRAMcheats++] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_cheats(void)
|
||||
{
|
||||
int i = maxcheats;
|
||||
/* disable cheats in reversed order in case the same address is used by multiple patches */
|
||||
int i;
|
||||
|
||||
/* no ROM patches with Mega-CD games */
|
||||
if ((system_hw == SYSTEM_MCD) && !scd.cartridge.boot)
|
||||
return;
|
||||
|
||||
/* disable cheats in reversed order in case the same address is used by multiple ROM patches */
|
||||
i = maxcheats;
|
||||
while (i > 0)
|
||||
{
|
||||
if (cheatlist[i-1].enable)
|
||||
@ -2322,21 +2343,45 @@ static void clear_cheats(void)
|
||||
****************************************************************************/
|
||||
static void RAMCheatUpdate(void)
|
||||
{
|
||||
uint8_t *base;
|
||||
uint32_t mask;
|
||||
int index, cnt = maxRAMcheats;
|
||||
|
||||
while (cnt)
|
||||
{
|
||||
/* get cheat index */
|
||||
index = cheatIndexes[--cnt];
|
||||
|
||||
/* detect destination RAM */
|
||||
switch ((cheatlist[index].address >> 20) & 0xf)
|
||||
{
|
||||
case 0x0: /* Mega-CD PRG-RAM (512 KB) */
|
||||
base = scd.prg_ram;
|
||||
mask = 0x7fffe;
|
||||
break;
|
||||
|
||||
case 0x2: /* Mega-CD 2M Word-RAM (256 KB) */
|
||||
base = scd.word_ram_2M;
|
||||
mask = 0x3fffe;
|
||||
break;
|
||||
|
||||
default: /* Work-RAM (64 KB) */
|
||||
base = work_ram;
|
||||
mask = 0xfffe;
|
||||
break;
|
||||
}
|
||||
|
||||
/* apply RAM patch */
|
||||
if (cheatlist[index].data & 0xFF00)
|
||||
{
|
||||
/* 16-bit patch */
|
||||
*(uint16_t *)(work_ram + (cheatlist[index].address & 0xFFFE)) = cheatlist[index].data;
|
||||
/* word patch */
|
||||
*(uint16_t *)(base + (cheatlist[index].address & mask)) = cheatlist[index].data;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 8-bit patch */
|
||||
work_ram[cheatlist[index].address & 0xFFFF] = cheatlist[index].data;
|
||||
/* byte patch */
|
||||
mask |= 1;
|
||||
base[cheatlist[index].address & mask] = cheatlist[index].data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user