GB Memory: Fix RTC latching

This commit is contained in:
Jeffrey Pfau 2016-05-28 12:27:30 -07:00
parent 2ee192d868
commit b14aafe9cb
2 changed files with 4 additions and 3 deletions

View File

@ -132,7 +132,7 @@ void GBMemoryReset(struct GB* gb) {
gb->memory.sramAccess = false;
gb->memory.rtcAccess = false;
gb->memory.activeRtcReg = 0;
gb->memory.rtcLatched = 0;
gb->memory.rtcLatched = false;
memset(&gb->memory.rtcRegs, 0, sizeof(gb->memory.rtcRegs));
memset(&gb->memory.hram, 0, sizeof(gb->memory.hram));
@ -682,9 +682,10 @@ void _GBMBC3(struct GBMemory* memory, uint16_t address, uint8_t value) {
break;
case 0x3:
if (memory->rtcLatched && value == 0) {
memory->rtcLatched = value;
memory->rtcLatched = false;
} else if (!memory->rtcLatched && value == 1) {
_latchRtc(memory);
memory->rtcLatched = true;
}
break;
}

View File

@ -149,7 +149,7 @@ struct GBMemory {
bool rtcAccess;
int activeRtcReg;
int rtcLatched;
bool rtcLatched;
uint8_t rtcRegs[5];
struct mRTCSource* rtc;
struct mRotationSource* rotation;