From c92830b103121736ce14eecd916bfbc0eb880983 Mon Sep 17 00:00:00 2001 From: Akash Date: Sat, 24 Dec 2016 11:47:05 +0530 Subject: [PATCH] PCSX2-Counters: Fix RTC counting at certain cases Previously, the seconds variable of the RTC was updated on progressive modes after every 50 Vsyncs, which was obviously wrong. The code has been adjusted to update the RTC with respect to the vertical frequencies of various other video modes. --- pcsx2/CDVD/CDVD.cpp | 2 +- pcsx2/CDVD/CDVD.h | 2 ++ pcsx2/Counters.h | 1 - pcsx2/GS.h | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 73fbe508f8..b5a9975d3f 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -975,7 +975,7 @@ u8 monthmap[13] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; void cdvdVsync() { cdvd.RTCcount++; - if (cdvd.RTCcount < ((gsVideoMode == GS_VideoMode::NTSC) ? 60 : 50)) return; + if (cdvd.RTCcount < (GetVerticalFrequency().ToIntRounded())) return; cdvd.RTCcount = 0; if ( cdvd.Status == CDVD_STATUS_TRAY_OPEN ) diff --git a/pcsx2/CDVD/CDVD.h b/pcsx2/CDVD/CDVD.h index 24a2e12bbf..7714d6fb36 100644 --- a/pcsx2/CDVD/CDVD.h +++ b/pcsx2/CDVD/CDVD.h @@ -100,6 +100,8 @@ struct cdvdStruct { u8 CReadWrite; u8 CNumBlocks; + // Calculates the number of Vsyncs and once it reaches a total number of Vsyncs worth a second with respect to + // the videomode's vertical frequency, it updates the real time clock. int RTCcount; cdvdRTC RTC; diff --git a/pcsx2/Counters.h b/pcsx2/Counters.h index e1ff51af07..bc19e92d4d 100644 --- a/pcsx2/Counters.h +++ b/pcsx2/Counters.h @@ -123,7 +123,6 @@ struct SyncCounter #define MODE_HBLANK 0x1 //Set for the remaining ~1/6 of 1 Scanline -extern Fixed100 GetVerticalFrequency(); extern Counter counters[4]; extern SyncCounter hsyncCounter; extern SyncCounter vsyncCounter; diff --git a/pcsx2/GS.h b/pcsx2/GS.h index ad90b41c31..6ab029b92e 100644 --- a/pcsx2/GS.h +++ b/pcsx2/GS.h @@ -19,6 +19,7 @@ #include "System/SysThreads.h" #include "Gif.h" +extern Fixed100 GetVerticalFrequency(); extern __aligned16 u8 g_RealGSMem[Ps2MemSize::GSregs]; enum CSR_FifoState