SGB: Prevent freeze/lock up when resetting a MBC3 game that has a RTC clock

This commit is contained in:
Sour 2025-03-02 11:25:21 +09:00
parent 8d190963da
commit 53f17745d7
3 changed files with 12 additions and 3 deletions

View file

@ -26,6 +26,7 @@ public:
void InitCart() override
{
_memoryManager->MapRegisters(0x0000, 0x7FFF, RegisterAccess::Write);
_rtc.Init();
}
void RefreshMappings() override

View file

@ -26,8 +26,7 @@ public:
GbMbc3Rtc(Emulator* emu)
{
_emu = emu;
_lastMasterClock = 0;
LoadBattery();
Init();
}
~GbMbc3Rtc()
@ -35,6 +34,12 @@ public:
SaveBattery();
}
void Init()
{
_lastMasterClock = 0;
LoadBattery();
}
void LoadBattery()
{
vector<uint8_t> rtcData = _emu->GetBatteryManager()->LoadBattery(".rtc");

View file

@ -46,8 +46,11 @@ SuperGameboy::~SuperGameboy()
void SuperGameboy::Reset()
{
_control = 0;
_control = 0x01;
_effectiveClockRate = 0;
_clockOffset = 0;
_resetClock = 0;
UpdateClockRatio();
memset(_input, 0, sizeof(_input));
_inputIndex = 0;