Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Refactor a lot of timer work and fix a couple of bugs #11220

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pcsx2/CDVD/CDVD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "CDVD/IsoReader.h"
#include "CDVD/IsoFileFormats.h"
#include "GS.h"
#include "SIO/Sio.h"
#include "Elfheader.h"
#include "ps2/BiosTools.h"
#include "Recording/InputRecording.h"
Expand Down Expand Up @@ -1553,13 +1554,20 @@ void cdvdUpdateTrayState()

void cdvdVsync()
{
// We're counting in frames, but one second isn't exactly 50 or 60 frames in most cases, so we'll keep the fractions.
cdvd.RTCcount++;
if (cdvd.RTCcount < GetVerticalFrequency())
const double verticalFrequency = GetVerticalFrequency();
if (cdvd.RTCcount < verticalFrequency)
return;
cdvd.RTCcount = 0;

cdvd.RTCcount -= verticalFrequency;

cdvdUpdateTrayState();

// FolderMemoryCard needs information on how much time has passed since the last write
// Call it every second.
sioNextFrame();

cdvd.RTC.second++;
if (cdvd.RTC.second < 60)
return;
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/CDVD/CDVD.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct cdvdStruct

// 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;
double RTCcount;
cdvdRTC RTC;

u32 CurrentSector;
Expand Down
Loading