Skip to content

Commit

Permalink
CDVD: Fix some read timing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
refractionpcsx2 committed Dec 14, 2021
1 parent 103dd39 commit e4ef41f
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions pcsx2/CDVD/CDVD.cpp
Expand Up @@ -1139,14 +1139,10 @@ __fi void cdvdReadInterrupt()
cdvd.Reading = 1;
cdvd.Readed = 1;
cdvd.Sector = cdvd.SeekToSector;
CDVD_LOG("Cdvd Seek Complete > Scheduling block read interrupt at iopcycle=%8.8x.",
psxRegs.cycle + cdvd.ReadTime);

CDVDREAD_INT(cdvd.ReadTime);
cdvd.Status = CDVD_STATUS_READ;
return;
CDVD_LOG("Cdvd Seek Complete at iopcycle=%8.8x.", psxRegs.cycle);
}
else if (cdvd.Reading)

if (cdvd.Reading)
{
if (cdvd.RErr == 0)
{
Expand Down Expand Up @@ -1300,6 +1296,7 @@ static uint cdvdStartSeek(uint newsector, CDVD_MODE_TYPE mode)

// if delta > 0 it will read a new sector so the readInterrupt will account for this.
seektime = 0;
isSeeking = false;

if (delta == 0)
{
Expand All @@ -1324,24 +1321,16 @@ static uint cdvdStartSeek(uint newsector, CDVD_MODE_TYPE mode)
}
else
{
CDVDSECTORREADY_INT(cdvd.ReadTime);
seektime = cdvd.ReadTime + ((cdvd.BlockSize / 4) * 12);
delta = 1; // Forces it to use the rotational delay since we have no sectors buffered and it isn't buffering any.
}
}
else
seektime = (cdvd.BlockSize / 4) * 12;
return (cdvd.BlockSize / 4) * 12;
}
else
{
if (delta < cdvd.nextSectorsBuffered)
{
isSeeking = false;
}
else
{
psxRegs.interrupt &= ~(1 << IopEvt_CdvdSectorReady);
cdvd.nextSectorsBuffered = 0;
}
psxRegs.interrupt &= ~(1 << IopEvt_CdvdSectorReady);
cdvd.nextSectorsBuffered = 0;
}
}

Expand All @@ -1354,8 +1343,9 @@ static uint cdvdStartSeek(uint newsector, CDVD_MODE_TYPE mode)
CDVDSECTORREADY_INT(seektime);
seektime += (cdvd.BlockSize / 4) * 12;
}
else if(cdvd.nCommand != N_CD_SEEK)
CDVDSECTORREADY_INT(seektime + ((cdvd.BlockSize / 4) * 12));
else
CDVDSECTORREADY_INT(seektime);

return seektime;
}

Expand Down

0 comments on commit e4ef41f

Please sign in to comment.