From d8c238c9fb5030f4bd3a2fa8f0837c9f9178457d Mon Sep 17 00:00:00 2001 From: MrWint Date: Sun, 26 May 2019 19:40:19 +0200 Subject: [PATCH] libgambatte: timar quirk accuracy --- libgambatte/src/memory.cpp | 6 +++--- libgambatte/src/tima.cpp | 4 ++-- libgambatte/src/tima.h | 2 +- output/dll/libgambatte.dll | Bin 168448 -> 168448 bytes 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libgambatte/src/memory.cpp b/libgambatte/src/memory.cpp index 5c85ccebeb..7c20121b71 100644 --- a/libgambatte/src/memory.cpp +++ b/libgambatte/src/memory.cpp @@ -337,8 +337,8 @@ unsigned long Memory::stop(unsigned long cc) { cc += 4; if (ioamhram_[0x14D] & isCgb()) { - psg_.generateSamples(cc, isDoubleSpeed()); - lcd_.speedChange(cc); + psg_.generateSamples(cc + 4, isDoubleSpeed()); + lcd_.speedChange((cc + 7) & ~7); ioamhram_[0x14D] ^= 0x81; intreq_.setEventTime(ioamhram_[0x140] & lcdc_en ? lcd_.nextMode1IrqTime() @@ -686,7 +686,7 @@ void Memory::nontrivial_ff_write(unsigned const p, unsigned data, unsigned long break; case 0x07: data |= 0xF8; - tima_.setTac(data, cc, TimaInterruptRequester(intreq_), gbIsCgb_); + tima_.setTac(data, cc, TimaInterruptRequester(intreq_), agbMode_); break; case 0x0F: updateIrqs(cc); diff --git a/libgambatte/src/tima.cpp b/libgambatte/src/tima.cpp index aa4038821b..5b935c8a9c 100644 --- a/libgambatte/src/tima.cpp +++ b/libgambatte/src/tima.cpp @@ -117,7 +117,7 @@ void Tima::setTma(unsigned const data, unsigned long const cc, TimaInterruptRequ tma_ = data; } -void Tima::setTac(unsigned const data, unsigned long const cc, TimaInterruptRequester timaIrq, bool gbIsCgb) { +void Tima::setTac(unsigned const data, unsigned long const cc, TimaInterruptRequester timaIrq, bool agbFlag) { if (tac_ ^ data) { unsigned long nextIrqEventTime = timaIrq.nextIrqEventTime(); @@ -141,7 +141,7 @@ void Tima::setTac(unsigned const data, unsigned long const cc, TimaInterruptRequ if (data & 4) { unsigned long diff = cc - basetime_; - if (gbIsCgb) { + if (agbFlag) { if (((diff >> (timaClock[tac_ & 3] - 1)) & 1) == 1 && ((diff >> (timaClock[data & 3] - 1)) & 1) == 0) tima_++; } diff --git a/libgambatte/src/tima.h b/libgambatte/src/tima.h index 55bfe849ad..d1db0854b9 100644 --- a/libgambatte/src/tima.h +++ b/libgambatte/src/tima.h @@ -41,7 +41,7 @@ public: void resetCc(unsigned long oldCc, unsigned long newCc, TimaInterruptRequester timaIrq); void setTima(unsigned tima, unsigned long cc, TimaInterruptRequester timaIrq); void setTma(unsigned tma, unsigned long cc, TimaInterruptRequester timaIrq); - void setTac(unsigned tac, unsigned long cc, TimaInterruptRequester timaIrq, bool gbIsCgb); + void setTac(unsigned tac, unsigned long cc, TimaInterruptRequester timaIrq, bool agbFlag); void resTac(unsigned long cc, TimaInterruptRequester timaIrq); unsigned tima(unsigned long cc); void doIrqEvent(TimaInterruptRequester timaIrq); diff --git a/output/dll/libgambatte.dll b/output/dll/libgambatte.dll index 1fb295ab0589a7be30a5dc37673499be7167f9e4..386ccdb45ad7526c2209a24dfee904bf9bb69626 100644 GIT binary patch delta 174 zcmZoz!qu>ZYXKvZ-TBQ-jJ%7q8kravT==&&$BQvA^oFx|G#)%4&cyKIT0Mx%-u&o? zM{l0*sl>6Si%iu#J&rf|cF*S1}Ag05pri8;I8= zGcl|Q1@RadU~)V_wg?da0LuM<%S}J$#v}!F%=TAqOxO4rwYMJ(Wh&NWZYXKwE!84ng7Kp1OlQtaKlp@Ec(cN?d;!L+<_X)jPuRxDGQsNLnO89kKmas}!5fIzBr`Fr z2?g;O7+`WdK(+`F{{YJUfXhuk=f)%jbjtQuZcNws7`3(^3}q_TWaQXxTF-P^2mtnW BI3NH3