Skip to content

Commit

Permalink
GB: Add missing battery save for MMM01 cart
Browse files Browse the repository at this point in the history
  • Loading branch information
retro-wertz authored and rkitover committed Jan 29, 2019
1 parent a0cec10 commit f2b3496
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/gb/GB.cpp
Expand Up @@ -4342,6 +4342,7 @@ bool gbUpdateSizes()
switch (gbRomType) {
case 0x03:
case 0x06:
case 0x0d:
case 0x0f:
case 0x10:
case 0x13:
Expand Down
27 changes: 3 additions & 24 deletions src/libretro/libretro.cpp
Expand Up @@ -187,27 +187,6 @@ static void set_gbPalette(void)
extern int gbRomType; // gets type from header 0x147
extern int gbBattery; // enabled when gbRamSize != 0

static bool gb_hasbattery(void)
{
switch (gbRomType) {
case 0x03: // MBC1
case 0xff: // MBC1
case 0x0d: // MM01
case 0x0f:
case 0x10: // MBC3 + extended
case 0x13:
case 0xfc: // MBC3
case 0x1b:
case 0x1e: // MBC5
//incomplete, does not save gbTAMA5ram
case 0xfd: // TAMA5 + extended
case 0x06: // MBC2
case 0x22: // MBC7
return true;
}
return false;
}

static bool gb_hasrtc(void)
{
switch (gbRomType) {
Expand Down Expand Up @@ -323,7 +302,7 @@ void* retro_get_memory_data(unsigned id)
else if (type == IMAGE_GB) {
switch (id) {
case RETRO_MEMORY_SAVE_RAM:
if (gb_hasbattery())
if (gbBattery)
return gbRam;
return NULL;
case RETRO_MEMORY_SYSTEM_RAM:
Expand Down Expand Up @@ -355,7 +334,7 @@ size_t retro_get_memory_size(unsigned id)
else if (type == IMAGE_GB) {
switch (id) {
case RETRO_MEMORY_SAVE_RAM:
if (gb_hasbattery())
if (gbBattery)
return gbRamSize;
return 0;
case RETRO_MEMORY_SYSTEM_RAM:
Expand Down Expand Up @@ -928,7 +907,7 @@ static void gb_init(void)
crc16 -= gbRom[0x14e] + gbRom[0x14f];
log("Checksum : %04x (%04x)\n", crc16, gbRom[0x14e] * 256 + gbRom[0x14f]);

if (gb_hasbattery())
if (gbBattery)
log("Game supports battery save ram.\n");
if (gbRom[0x143] == 0xc0)
log("Game works on CGB only\n");
Expand Down

0 comments on commit f2b3496

Please sign in to comment.