SPU: Fire interrupt on DMA reads/writes too

This commit is contained in:
Connor McLaughlin 2019-11-11 14:05:58 +10:00
parent 8722757412
commit 26437e31dd
2 changed files with 21 additions and 12 deletions

View File

@ -544,6 +544,8 @@ void SPU::UpdateDMARequest()
u16 SPU::RAMTransferRead()
{
CheckRAMIRQ(m_transfer_address);
u16 value;
std::memcpy(&value, &m_ram[m_transfer_address], sizeof(value));
m_transfer_address = (m_transfer_address + sizeof(value)) & RAM_MASK;
@ -554,8 +556,23 @@ void SPU::RAMTransferWrite(u16 value)
{
Log_TracePrintf("SPU RAM @ 0x%08X (voice 0x%04X) <- 0x%04X", m_transfer_address,
m_transfer_address >> VOICE_ADDRESS_SHIFT, ZeroExtend32(value));
std::memcpy(&m_ram[m_transfer_address], &value, sizeof(value));
m_transfer_address = (m_transfer_address + sizeof(value)) & RAM_MASK;
CheckRAMIRQ(m_transfer_address);
}
void SPU::CheckRAMIRQ(u32 address)
{
if (!m_SPUCNT.irq9_enable)
return;
if (ZeroExtend32(m_irq_address) * 8 == address)
{
Log_DebugPrintf("SPU IRQ at address 0x%08X", address);
m_SPUSTAT.irq9_flag = true;
m_interrupt_controller->InterruptRequest(InterruptController::IRQ::SPU);
}
}
void SPU::Execute(TickCount ticks)
@ -808,17 +825,7 @@ s16 SPU::Voice::Interpolate() const
void SPU::ReadADPCMBlock(u16 address, ADPCMBlock* block)
{
u32 ram_address = (ZeroExtend32(address) * 8) & RAM_MASK;
// 16 bytes, so 2 8-byte blocks for the interrupt check
if (m_SPUCNT.irq9_enable)
{
if (m_irq_address == address || m_irq_address == (address + 1))
{
Log_DebugPrintf("SPU IRQ at address 0x%08X", ram_address);
m_SPUSTAT.irq9_flag = true;
m_interrupt_controller->InterruptRequest(InterruptController::IRQ::SPU);
}
}
CheckRAMIRQ(ram_address);
// fast path - no wrap-around
if ((ram_address + sizeof(ADPCMBlock)) <= RAM_SIZE)
@ -1014,7 +1021,7 @@ void SPU::DrawDebugStateWindow()
ImGui::SameLine(offsets[0]);
ImGui::TextColored(m_SPUCNT.irq9_enable ? active_color : inactive_color,
m_SPUCNT.irq9_enable ? "Enabled @ 0x%04X (actual 0x%08X)" : "Disabled @ 0x%04X (actual 0x%08X)",
m_irq_address, ZeroExtend32(m_irq_address * 8) & RAM_MASK);
m_irq_address, (ZeroExtend32(m_irq_address) * 8) & RAM_MASK);
ImGui::Text("Volume: ");
ImGui::SameLine(offsets[0]);

View File

@ -268,6 +268,7 @@ private:
void UpdateDMARequest();
u16 RAMTransferRead();
void RAMTransferWrite(u16 value);
void CheckRAMIRQ(u32 address);
void ReadADPCMBlock(u16 address, ADPCMBlock* block);
std::tuple<s32, s32> SampleVoice(u32 voice_index);
@ -285,6 +286,7 @@ private:
u32 m_transfer_address = 0;
u16 m_irq_address = 0;
u16 m_capture_buffer_position = 0;
VolumeRegister m_main_volume_left = {};
VolumeRegister m_main_volume_right = {};