Skip to content

Commit f7e41cf

Browse files
committed
spu: Emulate capture IRQ
1 parent dee7345 commit f7e41cf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

psx/dev/spu.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void psx_spu_init(psx_spu_t* spu, psx_ic_t* ic) {
111111

112112
// Mute all voices
113113
spu->endx = 0x00ffffff;
114+
spu->irq9addr = 0xffff;
114115
}
115116

116117
uint32_t psx_spu_read32(psx_spu_t* spu, uint32_t offset) {
@@ -703,6 +704,8 @@ uint32_t psx_spu_get_sample(psx_spu_t* spu) {
703704
return clampl | (((uint32_t)clampr) << 16);
704705
}
705706

707+
int counter = 0;
708+
706709
void psx_spu_update_cdda_buffer(psx_spu_t* spu, void* buf) {
707710
int16_t* ptr = buf;
708711
int16_t* ram = (int16_t*)spu->ram;
@@ -724,6 +727,18 @@ void psx_spu_update_cdda_buffer(psx_spu_t* spu, void* buf) {
724727
ram[i + 0x000] = l / 8;
725728
ram[i + 0x400] = r / 8;
726729
}
730+
731+
// Simulate capture IRQ
732+
if (spu->ramdtc & 0xc) {
733+
if (spu->irq9addr <= 0x1ff) {
734+
if (!counter) {
735+
psx_ic_irq(spu->ic, IC_SPU);
736+
}
737+
738+
counter++;
739+
counter &= 0x1;
740+
}
741+
}
727742
}
728743

729744
#undef CLAMP

0 commit comments

Comments
 (0)