mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
CDROM: Cancel speed changes if they're not complete
This commit is contained in:
parent
b1776dea61
commit
2c19c7ce57
|
@ -1020,23 +1020,34 @@ void CDROM::ExecuteCommand(TickCount ticks_late)
|
||||||
SendACKAndStat();
|
SendACKAndStat();
|
||||||
EndCommand();
|
EndCommand();
|
||||||
|
|
||||||
if (speed_change && m_drive_state != DriveState::SeekingImplicit &&
|
if (speed_change)
|
||||||
m_drive_state != DriveState::ChangingSpeedOrTOCRead)
|
|
||||||
{
|
{
|
||||||
// if we're seeking or reading, we need to add time to the current seek/read
|
if (m_drive_state == DriveState::ChangingSpeedOrTOCRead)
|
||||||
const TickCount change_ticks = GetTicksForSpeedChange();
|
|
||||||
if (m_drive_state != DriveState::Idle)
|
|
||||||
{
|
{
|
||||||
Log_DevPrintf("Drive is %s, delaying event by %d ticks for speed change to %s-speed",
|
// cancel the speed change if it's less than a quarter complete
|
||||||
s_drive_state_names[static_cast<u8>(m_drive_state)], change_ticks,
|
if (m_drive_event->GetTicksUntilNextExecution() >= (GetTicksForSpeedChange() / 4))
|
||||||
m_mode.double_speed ? "double" : "single");
|
{
|
||||||
m_drive_event->Delay(change_ticks);
|
Log_DevPrintf("Cancelling speed change event");
|
||||||
|
ClearDriveState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (m_drive_state != DriveState::SeekingImplicit)
|
||||||
{
|
{
|
||||||
Log_DevPrintf("Drive is idle, speed change takes %d ticks", change_ticks);
|
// if we're seeking or reading, we need to add time to the current seek/read
|
||||||
m_drive_state = DriveState::ChangingSpeedOrTOCRead;
|
const TickCount change_ticks = GetTicksForSpeedChange();
|
||||||
m_drive_event->Schedule(change_ticks);
|
if (m_drive_state != DriveState::Idle)
|
||||||
|
{
|
||||||
|
Log_DevPrintf("Drive is %s, delaying event by %d ticks for speed change to %s-speed",
|
||||||
|
s_drive_state_names[static_cast<u8>(m_drive_state)], change_ticks,
|
||||||
|
m_mode.double_speed ? "double" : "single");
|
||||||
|
m_drive_event->Delay(change_ticks);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log_DevPrintf("Drive is idle, speed change takes %d ticks", change_ticks);
|
||||||
|
m_drive_state = DriveState::ChangingSpeedOrTOCRead;
|
||||||
|
m_drive_event->Schedule(change_ticks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue