CDVD: Increase cycle accuracy + simulate speedup for CLV/CAS swap

This commit is contained in:
refractionpcsx2 2022-08-25 21:15:22 +01:00
parent 256a5b94c5
commit 86685a9db4
1 changed files with 27 additions and 4 deletions

View File

@ -811,15 +811,17 @@ static uint cdvdBlockReadTime(CDVD_MODE_TYPE mode)
break;
}
// 0.40f is the "base" inner track speed.
const float sectorSpeed = ((static_cast<float>(cdvd.SeekToSector - offset) / static_cast<float>(numSectors)) * 0.60f) + 0.40f;
float cycles = static_cast<float>(PSXCLK) / (static_cast<float>(((mode == MODE_CDROM) ? CD_SECTORS_PERSECOND : DVD_SECTORS_PERSECOND) * cdvd.Speed) * sectorSpeed);
return (PSXCLK / (static_cast<float>(((mode == MODE_CDROM) ? CD_SECTORS_PERSECOND : DVD_SECTORS_PERSECOND) * cdvd.Speed) * sectorSpeed));
//return ((PSXCLK * cdvd.BlockSize) / ((float)(((mode == MODE_CDROM) ? PSX_CD_READSPEED : PSX_DVD_READSPEED) * cdvd.Speed) * sectorSpeed));
return static_cast<int>(cycles);
}
// CLV Read Speed is constant
//return ((PSXCLK * cdvd.BlockSize) / (float)(((mode == MODE_CDROM) ? PSX_CD_READSPEED : PSX_DVD_READSPEED) * cdvd.Speed));
return (PSXCLK / (((mode == MODE_CDROM) ? CD_SECTORS_PERSECOND : DVD_SECTORS_PERSECOND) * cdvd.Speed));
float cycles = static_cast<float>(PSXCLK) / static_cast<float>(((mode == MODE_CDROM) ? CD_SECTORS_PERSECOND : DVD_SECTORS_PERSECOND) * cdvd.Speed);
return static_cast<int>(cycles);
}
void cdvdReset()
@ -1782,6 +1784,7 @@ static void cdvdWrite04(u8 rt)
DevCon.Warning("CDVD: CD Read using Nominal switch from CAV to CLV, unhandled");
bool ParamError = false;
const int oldSpeed = cdvd.Speed;
switch (cdvd.SpindlCtrl & CDVD_SPINDLE_SPEED)
{
@ -1818,6 +1821,12 @@ static void cdvdWrite04(u8 rt)
break;
}
if ((cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) != (oldSpindleCtrl & CDVD_SPINDLE_CAV) || oldSpeed != cdvd.Speed)
{
CDVD_LOG("CdRead > Speed change, adding delay");
cdvd.Spinning = false;
}
if (cdvdIsDVD() && cdvd.NCMDParam[10] != 0)
{
ParamError = true;
@ -1913,6 +1922,7 @@ static void cdvdWrite04(u8 rt)
DevCon.Warning("CDVD: CDDA Read using Nominal switch from CAV to CLV, unhandled");
bool ParamError = false;
const int oldSpeed = cdvd.Speed;
switch (cdvd.SpindlCtrl & CDVD_SPINDLE_SPEED)
{
@ -1937,6 +1947,12 @@ static void cdvdWrite04(u8 rt)
break;
}
if ((cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) != (oldSpindleCtrl & CDVD_SPINDLE_CAV) || oldSpeed != cdvd.Speed)
{
CDVD_LOG("CdRead > Speed change, adding delay");
cdvd.Spinning = false;
}
switch (cdvd.NCMDParam[10])
{
case 1:
@ -2015,6 +2031,7 @@ static void cdvdWrite04(u8 rt)
DevCon.Warning("CDVD: DVD Read using Nominal switch from CAV to CLV, unhandled");
bool ParamError = false;
const int oldSpeed = cdvd.Speed;
switch (cdvd.SpindlCtrl & CDVD_SPINDLE_SPEED)
{
@ -2033,6 +2050,12 @@ static void cdvdWrite04(u8 rt)
break;
}
if ((cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) != (oldSpindleCtrl & CDVD_SPINDLE_CAV) || oldSpeed != cdvd.Speed)
{
CDVD_LOG("DvdRead > Speed change, adding delay");
cdvd.Spinning = false;
}
if (cdvd.NCMDParam[10] != 0)
ParamError = true;