cdrom: adjust timing
authornotaz <notasas@gmail.com>
Sat, 14 Oct 2023 21:48:20 +0000 (00:48 +0300)
committernotaz <notasas@gmail.com>
Sat, 14 Oct 2023 22:28:52 +0000 (01:28 +0300)
notaz/pcsx_rearmed#317

libpcsxcore/cdrom.c

index 047172c..2ce7fe9 100644 (file)
@@ -106,7 +106,7 @@ static struct {
        u16 CmdInProgress;
        u8 Irq1Pending;
        u8 unused5;
-       u32 LastReadCycles;
+       u32 LastReadSeekCycles;
 
        u8 unused7;
 
@@ -555,16 +555,15 @@ static void cdrPlayInterrupt_Autopause()
                cdr.ReportDelay--;
 }
 
-// LastReadCycles
 static int cdrSeekTime(unsigned char *target)
 {
        int diff = msf2sec(cdr.SetSectorPlay) - msf2sec(target);
-       int pausePenalty, seekTime = abs(diff) * (cdReadTime / 2000);
+       int seekTime = abs(diff) * (cdReadTime / 2000);
        seekTime = MAX_VALUE(seekTime, 20000);
 
        // need this stupidly long penalty or else Spyro2 intro desyncs
-       pausePenalty = (s32)(psxRegs.cycle - cdr.LastReadCycles) > cdReadTime * 8 ? cdReadTime * 25 : 0;
-       seekTime += pausePenalty;
+       if ((s32)(psxRegs.cycle - cdr.LastReadSeekCycles) > cdReadTime * 8)
+               seekTime += cdReadTime * 25;
 
        seekTime = MIN_VALUE(seekTime, PSXCLK * 2 / 3);
        CDR_LOG("seek: %.2f %.2f\n", (float)seekTime / PSXCLK, (float)seekTime / cdReadTime);
@@ -633,7 +632,7 @@ static void msfiSub(u8 *msfi, u32 count)
 
 void cdrPlayReadInterrupt(void)
 {
-       cdr.LastReadCycles = psxRegs.cycle;
+       cdr.LastReadSeekCycles = psxRegs.cycle;
 
        if (cdr.Reading) {
                cdrReadInterrupt();
@@ -1071,6 +1070,7 @@ void cdrInterrupt(void) {
                                memcpy(cdr.LocL, buf, 8);
                        UpdateSubq(cdr.SetSectorPlay);
                        cdr.TrackChanged = FALSE;
+                       cdr.LastReadSeekCycles = psxRegs.cycle;
                        break;
 
                case CdlTest: