From dd53b01f761a6801e7922c993e81048f2c6d7c0a Mon Sep 17 00:00:00 2001 From: RSDuck Date: Sun, 27 Jun 2021 00:45:12 +0200 Subject: [PATCH] only recalculate GBA slot timing if necessary --- src/NDS.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/NDS.cpp b/src/NDS.cpp index 53f57ca2..16547efb 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -3329,10 +3329,14 @@ void ARM9IOWrite16(u32 addr, u16 val) case 0x040001BA: ROMSeed1[4] = val & 0x7F; return; case 0x04000204: - ExMemCnt[0] = val; - ExMemCnt[1] = (ExMemCnt[1] & 0x007F) | (val & 0xFF80); - SetGBASlotTimings(); - return; + { + u16 oldVal = ExMemCnt[0]; + ExMemCnt[0] = val; + ExMemCnt[1] = (ExMemCnt[1] & 0x007F) | (val & 0xFF80); + if ((oldVal ^ ExMemCnt[0]) & 0xFF) + SetGBASlotTimings(); + return; + } case 0x04000208: IME[0] = val & 0x1; UpdateIRQ(0); return; case 0x04000210: IE[0] = (IE[0] & 0xFFFF0000) | val; UpdateIRQ(0); return; @@ -4038,9 +4042,13 @@ void ARM7IOWrite16(u32 addr, u16 val) return; case 0x04000204: - ExMemCnt[1] = (ExMemCnt[1] & 0xFF80) | (val & 0x007F); - SetGBASlotTimings(); - return; + { + u16 oldVal = ExMemCnt[1]; + ExMemCnt[1] = (ExMemCnt[1] & 0xFF80) | (val & 0x007F); + if ((ExMemCnt[1] ^ oldVal) & 0xFF) + SetGBASlotTimings(); + return; + } case 0x04000206: SetWifiWaitCnt(val); return;