CDROM: Fix interrupt enable register having no effect

This commit is contained in:
Connor McLaughlin 2019-11-08 23:48:09 +10:00
parent c3efc5637a
commit 5eea2f9ced
2 changed files with 13 additions and 3 deletions

View File

@ -311,6 +311,7 @@ void CDROM::WriteRegister(u32 offset, u8 value)
{ {
Log_DebugPrintf("Interrupt enable register <- 0x%02X", value); Log_DebugPrintf("Interrupt enable register <- 0x%02X", value);
m_interrupt_enable_register = value & INTERRUPT_REGISTER_MASK; m_interrupt_enable_register = value & INTERRUPT_REGISTER_MASK;
UpdateInterruptRequest();
return; return;
} }
@ -415,8 +416,7 @@ void CDROM::DMARead(u32* words, u32 word_count)
void CDROM::SetInterrupt(Interrupt interrupt) void CDROM::SetInterrupt(Interrupt interrupt)
{ {
m_interrupt_flag_register = static_cast<u8>(interrupt); m_interrupt_flag_register = static_cast<u8>(interrupt);
if (HasPendingInterrupt()) UpdateInterruptRequest();
m_interrupt_controller->InterruptRequest(InterruptController::IRQ::CDROM);
} }
void CDROM::SetAsyncInterrupt(Interrupt interrupt) void CDROM::SetAsyncInterrupt(Interrupt interrupt)
@ -442,7 +442,7 @@ void CDROM::DeliverAsyncInterrupt()
m_response_fifo.PushFromQueue(&m_async_response_fifo); m_response_fifo.PushFromQueue(&m_async_response_fifo);
m_interrupt_flag_register = m_pending_async_interrupt; m_interrupt_flag_register = m_pending_async_interrupt;
m_pending_async_interrupt = 0; m_pending_async_interrupt = 0;
m_interrupt_controller->InterruptRequest(InterruptController::IRQ::CDROM); UpdateInterruptRequest();
} }
void CDROM::SendACKAndStat() void CDROM::SendACKAndStat()
@ -477,6 +477,14 @@ void CDROM::UpdateStatusRegister()
m_dma->SetRequest(DMA::Channel::CDROM, m_status.DRQSTS); 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 TickCount CDROM::GetAckDelayForCommand() const
{ {
const u32 default_ack_delay = 3000; const u32 default_ack_delay = 3000;
@ -937,6 +945,7 @@ void CDROM::ExecuteTestCommand(u8 subcommand)
{ {
Log_DebugPrintf("Get CDROM BIOS Date/Version"); Log_DebugPrintf("Get CDROM BIOS Date/Version");
static constexpr u8 response[] = {0x94, 0x09, 0x19, 0xC0}; static constexpr u8 response[] = {0x94, 0x09, 0x19, 0xC0};
// static constexpr u8 response[] = {0x96, 0x09, 0x12, 0xC2};
m_response_fifo.PushRange(response, countof(response)); m_response_fifo.PushRange(response, countof(response));
SetInterrupt(Interrupt::ACK); SetInterrupt(Interrupt::ACK);
EndCommand(); EndCommand();

View File

@ -186,6 +186,7 @@ private:
void SendErrorResponse(u8 reason = 0x80); void SendErrorResponse(u8 reason = 0x80);
void SendAsyncErrorResponse(u8 reason = 0x80); void SendAsyncErrorResponse(u8 reason = 0x80);
void UpdateStatusRegister(); void UpdateStatusRegister();
void UpdateInterruptRequest();
TickCount GetAckDelayForCommand() const; TickCount GetAckDelayForCommand() const;
TickCount GetTicksForRead() const; TickCount GetTicksForRead() const;