CDVD: No rotational delay for seeks less than buffered sectors

Fixes Shadow Hearts Covenant hangs
This commit is contained in:
refractionpcsx2 2021-12-12 06:33:01 +00:00
parent 6beac26727
commit 122968e63a
1 changed files with 15 additions and 4 deletions

View File

@ -1244,7 +1244,7 @@ __fi void cdvdReadInterrupt()
if (cdvd.nextSectorsBuffered) if (cdvd.nextSectorsBuffered)
CDVDREAD_INT((cdvd.BlockSize / 4) * 12); CDVDREAD_INT((cdvd.BlockSize / 4) * 12);
else else
CDVDREAD_INT(cdvd.ReadTime + ((cdvd.BlockSize / 4) * 12)); CDVDREAD_INT((psxRegs.cycle - psxRegs.sCycle[IopEvt_CdvdSectorReady]) + ((cdvd.BlockSize / 4) * 12));
} }
// Returns the number of IOP cycles until the event completes. // Returns the number of IOP cycles until the event completes.
@ -1254,6 +1254,7 @@ static uint cdvdStartSeek(uint newsector, CDVD_MODE_TYPE mode)
uint delta = abs((s32)(cdvd.SeekToSector - cdvd.Sector)); uint delta = abs((s32)(cdvd.SeekToSector - cdvd.Sector));
uint seektime; uint seektime;
bool isSeeking = cdvd.nCommand == N_CD_SEEK;
cdvd.Ready &= ~(CDVD_DRIVE_READY | CDVD_DRIVE_DATARDY); cdvd.Ready &= ~(CDVD_DRIVE_READY | CDVD_DRIVE_DATARDY);
cdvd.Reading = 1; cdvd.Reading = 1;
@ -1291,6 +1292,7 @@ static uint cdvdStartSeek(uint newsector, CDVD_MODE_TYPE mode)
CDVD_LOG("CdSeek Begin > to sector %d, from %d - delta=%d [FAST]", cdvd.SeekToSector, cdvd.Sector, delta); CDVD_LOG("CdSeek Begin > to sector %d, from %d - delta=%d [FAST]", cdvd.SeekToSector, cdvd.Sector, delta);
seektime = Cdvd_FastSeek_Cycles; seektime = Cdvd_FastSeek_Cycles;
} }
isSeeking = true;
} }
else else
{ {
@ -1331,13 +1333,20 @@ static uint cdvdStartSeek(uint newsector, CDVD_MODE_TYPE mode)
} }
else else
{ {
psxRegs.interrupt &= ~(1 << IopEvt_CdvdSectorReady); if (delta < cdvd.nextSectorsBuffered)
cdvd.nextSectorsBuffered = 0; {
isSeeking = false;
}
else
{
psxRegs.interrupt &= ~(1 << IopEvt_CdvdSectorReady);
cdvd.nextSectorsBuffered = 0;
}
} }
} }
// Only do this on reads, the seek kind of accounts for this and then it reads the sectors after // Only do this on reads, the seek kind of accounts for this and then it reads the sectors after
if (delta && cdvd.nCommand != N_CD_SEEK) if (delta && !isSeeking)
{ {
int rotationalLatency = cdvdRotationalLatency((CDVD_MODE_TYPE)cdvdIsDVD()); int rotationalLatency = cdvdRotationalLatency((CDVD_MODE_TYPE)cdvdIsDVD());
//DevCon.Warning("%s rotational latency at sector %d is %d cycles", (cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) ? "CAV" : "CLV", cdvd.SeekToSector, rotationalLatency); //DevCon.Warning("%s rotational latency at sector %d is %d cycles", (cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) ? "CAV" : "CLV", cdvd.SeekToSector, rotationalLatency);
@ -1345,6 +1354,8 @@ static uint cdvdStartSeek(uint newsector, CDVD_MODE_TYPE mode)
CDVDSECTORREADY_INT(seektime); CDVDSECTORREADY_INT(seektime);
seektime += (cdvd.BlockSize / 4) * 12; seektime += (cdvd.BlockSize / 4) * 12;
} }
else if(cdvd.nCommand != N_CD_SEEK)
CDVDSECTORREADY_INT(seektime + ((cdvd.BlockSize / 4) * 12));
return seektime; return seektime;
} }