cdrom: add a hack for bad rips
authornotaz <notasas@gmail.com>
Sun, 10 Sep 2023 15:18:26 +0000 (18:18 +0300)
committernotaz <notasas@gmail.com>
Sun, 10 Sep 2023 22:31:32 +0000 (01:31 +0300)
The game gets track times using CdlGetTN/CdlGetTD, but the rip only
keeps the data track. The game then wants to play a track using a
hardcoded track number, reading out of range of the list it got before,
sending garbage to CDC with infinite retries.

notaz/pcsx_rearmed#302

libpcsxcore/cdrom.c

index 28358bf..6f48df0 100644 (file)
@@ -109,7 +109,7 @@ static struct {
        u8 DriveState;
        u8 FastForward;
        u8 FastBackward;
-       u8 unused8;
+       u8 errorRetryhack;
 
        u8 AttenuatorLeftToLeft, AttenuatorLeftToRight;
        u8 AttenuatorRightToRight, AttenuatorRightToLeft;
@@ -749,6 +749,8 @@ void cdrInterrupt(void) {
                        if (((cdr.Param[0] & 0x0F) > 0x09) || (cdr.Param[0] > 0x99) || ((cdr.Param[1] & 0x0F) > 0x09) || (cdr.Param[1] >= 0x60) || ((cdr.Param[2] & 0x0F) > 0x09) || (cdr.Param[2] >= 0x75))
                        {
                                CDR_LOG_I("Invalid/out of range seek to %02X:%02X:%02X\n", cdr.Param[0], cdr.Param[1], cdr.Param[2]);
+                               if (++cdr.errorRetryhack > 100)
+                                       break;
                                error = ERROR_INVALIDARG;
                                goto set_error;
                        }
@@ -759,6 +761,7 @@ void cdrInterrupt(void) {
                                memcpy(cdr.SetSector, set_loc, 3);
                                cdr.SetSector[3] = 0;
                                cdr.SetlocPending = 1;
+                               cdr.errorRetryhack = 0;
                        }
                        break;