Skip to content

Commit

Permalink
Core: Refactor a lot of timer work and fix a couple of bugs
Browse files Browse the repository at this point in the history
EE/IOP Timers: improve clock sync, disable v/h sync when SINT enabled.

Some changes based on tests from PS2

[SAVEVERSION+]
  • Loading branch information
refractionpcsx2 committed May 15, 2024
1 parent 67f1d6e commit 566ea8e
Show file tree
Hide file tree
Showing 17 changed files with 514 additions and 579 deletions.
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

0 comments on commit 566ea8e

Please sign in to comment.