Skip to content

Commit

Permalink
CDROM: Fix rare interrupt race when cancelling commands
Browse files Browse the repository at this point in the history
Fixes hang during loading in Street Fighter Alpha 3.
  • Loading branch information
stenzek committed Aug 19, 2024
1 parent ee98912 commit 304f69e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/cdrom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,17 @@ void CDROM::BeginCommand(Command command)
const TickCount elapsed_ticks = s_command_event.GetInterval() - s_command_event.GetTicksUntilNextExecution();
ack_delay = std::max(ack_delay - elapsed_ticks, 1);
s_command_event.Deactivate();

// If there's a pending async interrupt, we need to deliver it now, since we've deactivated the command that was
// blocking it from being delivered. Not doing so will cause lockups in Street Fighter Alpha 3, where it spams
// multiple pause commands while an INT1 is scheduled, and there isn't much that can stop an INT1 once it's been
// queued on real hardware.
if (HasPendingAsyncInterrupt())
{
WARNING_LOG("Delivering pending interrupt after command {} cancellation for {}.",
s_command_info[static_cast<u8>(s_command)].name, s_command_info[static_cast<u8>(command)].name);
QueueDeliverAsyncInterrupt();
}
}
}

Expand Down

0 comments on commit 304f69e

Please sign in to comment.