From 86fcffefd05ba7cc9872dc67c47a9fab3a89a9e9 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 14 Aug 2020 18:55:03 +0800 Subject: [PATCH 1/2] GB: Add support for 4MB MBC30 --- src/gb/gbMemory.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gb/gbMemory.cpp b/src/gb/gbMemory.cpp index b2ac740c..d1a6e61e 100644 --- a/src/gb/gbMemory.cpp +++ b/src/gb/gbMemory.cpp @@ -362,7 +362,9 @@ void mapperMBC3ROM(uint16_t address, uint8_t value) gbDataMBC3.mapperRAMEnable = ((value & 0x0a) == 0x0a ? 1 : 0); break; case 0x2000: // ROM bank select - value = value & 0x7f; + // MBC3 has 2MB rom size, anything above that is a 4MB MBC30 + if (gbRomSize < 0x200000) + value &= 0x7f; if (value == 0) value = 1; if (value == gbDataMBC3.mapperROMBank) From 95213a6d551c9fd81d22ea51b78143f2573d923b Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 14 Aug 2020 21:20:54 +0800 Subject: [PATCH 2/2] GB: Only use mapperLastTime to see if RTC data was loaded - Removing mapperSeconds and mapperLSeconds since both of these can be zero at any time since they are seconds timer, not seconds since epoch. - This leaves only mapperLastTime as this is the number of seconds since last epoch. If this value is zero, then initialize rtc. --- src/libretro/libretro.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 2d0f1f22..93153164 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -1462,11 +1462,11 @@ void retro_run(void) case 0x0f: case 0x10: /* Check if any RTC has been loaded, zero value means nothing has been loaded. */ - if (!gbDataMBC3.mapperSeconds && !gbDataMBC3.mapperLSeconds && !gbDataMBC3.mapperLastTime) + if (!gbDataMBC3.mapperLastTime) initRTC = true; break; case 0xfd: - if (!gbDataTAMA5.mapperSeconds && !gbDataTAMA5.mapperLSeconds && !gbDataTAMA5.mapperLastTime) + if (!gbDataTAMA5.mapperLastTime) initRTC = true; break; }