shithub: psxe

Download patch

ref: f7e41cfdf04b28e57c04a2e4c9ff0cc5a4b84ed3
parent: dee7345385538ec26d6c55ab29e3e0b0a0ce3e9e
author: allkern <lisandroaalarcon@gmail.com>
date: Sat Nov 16 07:49:06 EST 2024

spu: Emulate capture IRQ

--- a/psx/dev/spu.c
+++ b/psx/dev/spu.c
@@ -111,6 +111,7 @@
 
     // Mute all voices
     spu->endx = 0x00ffffff;
+    spu->irq9addr = 0xffff;
 }
 
 uint32_t psx_spu_read32(psx_spu_t* spu, uint32_t offset) {
@@ -703,6 +704,8 @@
     return clampl | (((uint32_t)clampr) << 16);
 }
 
+int counter = 0;
+
 void psx_spu_update_cdda_buffer(psx_spu_t* spu, void* buf) {
     int16_t* ptr = buf;
     int16_t* ram = (int16_t*)spu->ram;
@@ -723,6 +726,18 @@
 
         ram[i + 0x000] = l / 8;
         ram[i + 0x400] = r / 8;
+    }
+
+    // Simulate capture IRQ
+    if (spu->ramdtc & 0xc) {
+        if (spu->irq9addr <= 0x1ff) {
+            if (!counter) {
+                psx_ic_irq(spu->ic, IC_SPU);
+            }
+
+            counter++;
+            counter &= 0x1;
+        }
     }
 }
 
--