From 18241978ea056a81ff9847f0ad89658f886153ea Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 18 Aug 2021 00:25:15 +1000 Subject: [PATCH] CDROM: Cancel command second response when queuing new command Fixes Wipeout corrupting parts of the TOC. --- src/core/cdrom.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index bfa666fdc..3cdfb3d63 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -908,9 +908,21 @@ void CDROM::BeginCommand(Command command) s_command_info[static_cast(command)].name); // subtract the currently-elapsed ack ticks from the new command - const TickCount elapsed_ticks = m_command_event->GetInterval() - m_command_event->GetTicksUntilNextExecution(); - ack_delay = std::max(ack_delay - elapsed_ticks, 1); - m_command_event->Deactivate(); + if (m_command_event->IsActive()) + { + const TickCount elapsed_ticks = m_command_event->GetInterval() - m_command_event->GetTicksUntilNextExecution(); + ack_delay = std::max(ack_delay - elapsed_ticks, 1); + m_command_event->Deactivate(); + } + } + + if (m_command_second_response != Command::None) + { + Log_WarningPrintf("Cancelling pending command 0x%02X (%s) second response", + static_cast(m_command_second_response), + s_command_info[static_cast(m_command_second_response)].name); + + ClearCommandSecondResponse(); } m_command = command;