CDRom timings changes (#184)
authorgameblabla <gameblabla@users.noreply.github.com>
Wed, 18 Aug 2021 20:24:33 +0000 (20:24 +0000)
committerGitHub <noreply@github.com>
Wed, 18 Aug 2021 20:24:33 +0000 (23:24 +0300)
Upstreamed changes from PCSX Redux as seen here :
https://github.com/grumpycoders/pcsx-redux/commit/5730e04f0183f37038bc1d133cf9f9092425b90a

This apparently fixes Deus Fight in Xenogears.

Co-authored-by: Nicolas Noble <nicolasnoble@users.noreply.github.com>
libpcsxcore/cdrom.c
libpcsxcore/cdrom.h

index a725efa..16b7ca1 100644 (file)
@@ -496,6 +496,7 @@ void cdrPlayInterrupt()
                if (cdr.SetlocPending) {
                        memcpy(cdr.SetSectorPlay, cdr.SetSector, 4);
                        cdr.SetlocPending = 0;
+                       cdr.m_locationChanged = TRUE;
                }
                Find_CurTrack(cdr.SetSectorPlay);
                ReadTrack(cdr.SetSectorPlay);
@@ -527,7 +528,15 @@ void cdrPlayInterrupt()
                }
        }
 
-       CDRMISC_INT(cdReadTime);
+       if (cdr.m_locationChanged)
+       {
+               CDRMISC_INT(cdReadTime * 30);
+               cdr.m_locationChanged = FALSE;
+       }
+       else
+       {
+               CDRMISC_INT(cdReadTime);
+       }
 
        // update for CdlGetlocP/autopause
        generate_subq(cdr.SetSectorPlay);
@@ -589,6 +598,7 @@ void cdrInterrupt() {
                        if (cdr.SetlocPending) {
                                memcpy(cdr.SetSectorPlay, cdr.SetSector, 4);
                                cdr.SetlocPending = 0;
+                               cdr.m_locationChanged = TRUE;
                        }
 
                        // BIOS CD Player
@@ -914,6 +924,7 @@ void cdrInterrupt() {
                                if(seekTime > 1000000) seekTime = 1000000;
                                memcpy(cdr.SetSectorPlay, cdr.SetSector, 4);
                                cdr.SetlocPending = 0;
+                               cdr.m_locationChanged = TRUE;
                        }
                        Find_CurTrack(cdr.SetSectorPlay);
 
@@ -1130,7 +1141,13 @@ void cdrReadInterrupt() {
 
        cdr.Readed = 0;
 
-       CDREAD_INT((cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime);
+       uint32_t delay = (cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime;
+       if (cdr.m_locationChanged) {
+               CDREAD_INT(delay * 30);
+               cdr.m_locationChanged = FALSE;
+       } else {
+               CDREAD_INT(delay);
+       }
 
        /*
        Croc 2: $40 - only FORM1 (*)
@@ -1468,6 +1485,8 @@ void cdrReset() {
        cdr.DriveState = DRIVESTATE_STANDBY;
        cdr.StatP = STATUS_ROTATING;
        pTransfer = cdr.Transfer;
+       cdr.SetlocPending = 0;
+       cdr.m_locationChanged = FALSE;
 
        // BIOS player - default values
        cdr.AttenuatorLeftToLeft = 0x80;
index 543c619..a37f6ba 100644 (file)
@@ -59,7 +59,8 @@ typedef struct {
                unsigned char Absolute[3];
        } subq;
        unsigned char TrackChanged;
-       unsigned char pad1[3];
+       boolean m_locationChanged;
+       unsigned char pad1[2];
        unsigned int  freeze_ver;
 
        unsigned char Prev[4];