CDROM: Don't crash emulator when interrupts are missed

This commit is contained in:
Connor McLaughlin 2019-10-26 22:34:05 +10:00
parent b0c492fd43
commit 62f6a5597e
2 changed files with 8 additions and 0 deletions

View file

@ -424,6 +424,12 @@ void CDROM::SetAsyncInterrupt(Interrupt interrupt)
DeliverAsyncInterrupt(); DeliverAsyncInterrupt();
} }
void CDROM::CancelAsyncInterrupt()
{
m_pending_async_interrupt = 0;
m_async_response_fifo.Clear();
}
void CDROM::DeliverAsyncInterrupt() void CDROM::DeliverAsyncInterrupt()
{ {
Assert(m_pending_async_interrupt != 0 && !HasPendingInterrupt()); Assert(m_pending_async_interrupt != 0 && !HasPendingInterrupt());
@ -992,6 +998,7 @@ void CDROM::DoSectorRead()
if (HasPendingAsyncInterrupt()) if (HasPendingAsyncInterrupt())
{ {
Log_WarningPrintf("Data interrupt was not delivered"); Log_WarningPrintf("Data interrupt was not delivered");
CancelAsyncInterrupt();
} }
if (!m_sector_buffer.empty()) if (!m_sector_buffer.empty())
{ {

View file

@ -171,6 +171,7 @@ private:
bool HasPendingAsyncInterrupt() const { return m_pending_async_interrupt != 0; } bool HasPendingAsyncInterrupt() const { return m_pending_async_interrupt != 0; }
void SetInterrupt(Interrupt interrupt); void SetInterrupt(Interrupt interrupt);
void SetAsyncInterrupt(Interrupt interrupt); void SetAsyncInterrupt(Interrupt interrupt);
void CancelAsyncInterrupt();
void DeliverAsyncInterrupt(); void DeliverAsyncInterrupt();
void SendACKAndStat(); void SendACKAndStat();
void SendErrorResponse(u8 reason = 0x80); void SendErrorResponse(u8 reason = 0x80);