From 5eea2f9cedf4245a5ddeaab0ffd7166a375cd945 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 8 Nov 2019 23:48:09 +1000 Subject: [PATCH] CDROM: Fix interrupt enable register having no effect --- src/core/cdrom.cpp | 15 ++++++++++++--- src/core/cdrom.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index 9c6073719..7739de756 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -311,6 +311,7 @@ void CDROM::WriteRegister(u32 offset, u8 value) { Log_DebugPrintf("Interrupt enable register <- 0x%02X", value); m_interrupt_enable_register = value & INTERRUPT_REGISTER_MASK; + UpdateInterruptRequest(); return; } @@ -415,8 +416,7 @@ void CDROM::DMARead(u32* words, u32 word_count) void CDROM::SetInterrupt(Interrupt interrupt) { m_interrupt_flag_register = static_cast(interrupt); - if (HasPendingInterrupt()) - m_interrupt_controller->InterruptRequest(InterruptController::IRQ::CDROM); + UpdateInterruptRequest(); } void CDROM::SetAsyncInterrupt(Interrupt interrupt) @@ -442,7 +442,7 @@ void CDROM::DeliverAsyncInterrupt() m_response_fifo.PushFromQueue(&m_async_response_fifo); m_interrupt_flag_register = m_pending_async_interrupt; m_pending_async_interrupt = 0; - m_interrupt_controller->InterruptRequest(InterruptController::IRQ::CDROM); + UpdateInterruptRequest(); } void CDROM::SendACKAndStat() @@ -477,6 +477,14 @@ void CDROM::UpdateStatusRegister() m_dma->SetRequest(DMA::Channel::CDROM, m_status.DRQSTS); } +void CDROM::UpdateInterruptRequest() +{ + if ((m_interrupt_flag_register & m_interrupt_enable_register) == 0) + return; + + m_interrupt_controller->InterruptRequest(InterruptController::IRQ::CDROM); +} + TickCount CDROM::GetAckDelayForCommand() const { const u32 default_ack_delay = 3000; @@ -937,6 +945,7 @@ void CDROM::ExecuteTestCommand(u8 subcommand) { Log_DebugPrintf("Get CDROM BIOS Date/Version"); static constexpr u8 response[] = {0x94, 0x09, 0x19, 0xC0}; + // static constexpr u8 response[] = {0x96, 0x09, 0x12, 0xC2}; m_response_fifo.PushRange(response, countof(response)); SetInterrupt(Interrupt::ACK); EndCommand(); diff --git a/src/core/cdrom.h b/src/core/cdrom.h index c3bc1b906..6c2811294 100644 --- a/src/core/cdrom.h +++ b/src/core/cdrom.h @@ -186,6 +186,7 @@ private: void SendErrorResponse(u8 reason = 0x80); void SendAsyncErrorResponse(u8 reason = 0x80); void UpdateStatusRegister(); + void UpdateInterruptRequest(); TickCount GetAckDelayForCommand() const; TickCount GetTicksForRead() const;