Play-/tools/SpuTest/SimpleIrqTest.cpp

50 lines
1.3 KiB
C++
Raw Permalink Normal View History

2020-12-28 20:54:11 -05:00
#include "SimpleIrqTest.h"
void CSimpleIrqTest::Execute()
{
static uint32 nullSampleAddress = 0x5000;
static uint32 irqSampleAddress = 0x6000;
2020-12-31 09:07:13 -05:00
2020-12-28 20:54:11 -05:00
//Set some samples
m_ram[nullSampleAddress + 0] = 0;
m_ram[nullSampleAddress + 1] = 0x07;
2020-12-31 09:07:13 -05:00
2020-12-28 20:54:11 -05:00
m_ram[irqSampleAddress + 0] = 0;
m_ram[irqSampleAddress + 1] = 0x07;
2020-12-31 09:07:13 -05:00
2020-12-28 20:54:11 -05:00
//Setup voices
2020-12-30 16:31:00 -05:00
for(unsigned int i = 0; i < VOICE_COUNT; i++)
2020-12-28 20:54:11 -05:00
{
SetVoiceRegister(0, i, Iop::Spu2::CCore::VP_PITCH, 0x1000);
SetVoiceAddress(0, i, Iop::Spu2::CCore::VA_SSA_HI, nullSampleAddress);
}
2020-12-31 09:07:13 -05:00
2020-12-28 20:54:11 -05:00
//Send KEY-ON
SetCoreRegister(0, Iop::Spu2::CCore::A_KON_HI, 0xFFFF);
SetCoreRegister(0, Iop::Spu2::CCore::A_KON_LO, 0xFF);
2020-12-31 09:07:13 -05:00
2023-08-29 12:00:38 -04:00
//Set IRQ parameters (set IRQA to end of RAM to avoid triggering from CORE0_SIN region)
2020-12-28 20:54:11 -05:00
SetCoreRegister(0, Iop::Spu2::CCore::CORE_ATTR, Iop::CSpuBase::CONTROL_IRQ);
2023-08-29 12:00:38 -04:00
SetCoreAddress(0, Iop::Spu2::CCore::A_IRQA_HI, ~0);
2020-12-28 20:54:11 -05:00
2023-08-29 12:00:38 -04:00
RunSpu(1024);
2020-12-31 09:07:13 -05:00
2020-12-28 20:54:11 -05:00
//No IRQ
{
uint32 irqInfo = m_spu.ReadRegister(Iop::CSpu2::C_IRQINFO);
TEST_VERIFY(irqInfo == 0);
}
2020-12-31 09:07:13 -05:00
2020-12-28 20:54:11 -05:00
//Set voice 0 address to IRQ address
SetCoreAddress(0, Iop::Spu2::CCore::A_IRQA_HI, irqSampleAddress);
SetVoiceAddress(0, 0, Iop::Spu2::CCore::VA_SSA_HI, irqSampleAddress);
SetCoreRegister(0, Iop::Spu2::CCore::A_KON_HI, 0x1);
2023-08-29 12:00:38 -04:00
RunSpu(1024);
2020-12-31 09:07:13 -05:00
2020-12-28 20:54:11 -05:00
{
uint32 irqInfo = m_spu.ReadRegister(Iop::CSpu2::C_IRQINFO);
TEST_VERIFY(irqInfo == 0x04);
}
}