setup spu r8 handlers
[pcsx_rearmed.git] / libpcsxcore / psxhw.c
index 8397f39..60ff6c4 100644 (file)
@@ -120,8 +120,11 @@ u8 psxHwRead8(u32 add) {
                        log_unhandled("unhandled r8  %08x @%08x\n", add, psxRegs.pc);
                        // falthrough
                default:
-                       if (0x1f801c00 <= add && add < 0x1f802000)
-                               log_unhandled("spu r8 %02x @%08x\n", add, psxRegs.pc);
+                       if (0x1f801c00 <= add && add < 0x1f802000) {
+                               u16 val = SPU_readRegister(add & ~1, psxRegs.cycle);
+                               hard = (add & 1) ? val >> 8 : val;
+                               break;
+                       }
                        hard = psxHu8(add); 
 #ifdef PSXHW_LOG
                        PSXHW_LOG("*Unkwnown 8bit read at address %x\n", add);
@@ -175,7 +178,7 @@ u16 psxHwRead16(u32 add) {
                        return 0x80;\r
 
                case 0x1f801100:
-                       hard = psxRcntRcount(0);
+                       hard = psxRcntRcount0();
 #ifdef PSXHW_LOG
                        PSXHW_LOG("T0 count read16: %x\n", hard);
 #endif
@@ -193,7 +196,7 @@ u16 psxHwRead16(u32 add) {
 #endif
                        return hard;
                case 0x1f801110:
-                       hard = psxRcntRcount(1);
+                       hard = psxRcntRcount1();
 #ifdef PSXHW_LOG
                        PSXHW_LOG("T1 count read16: %x\n", hard);
 #endif
@@ -211,7 +214,7 @@ u16 psxHwRead16(u32 add) {
 #endif
                        return hard;
                case 0x1f801120:
-                       hard = psxRcntRcount(2);
+                       hard = psxRcntRcount2();
 #ifdef PSXHW_LOG
                        PSXHW_LOG("T2 count read16: %x\n", hard);
 #endif
@@ -253,7 +256,7 @@ u16 psxHwRead16(u32 add) {
                        // falthrough
                default:
                        if (0x1f801c00 <= add && add < 0x1f802000)
-                               return SPU_readRegister(add);
+                               return SPU_readRegister(add, psxRegs.cycle);
                        hard = psxHu16(add);
 #ifdef PSXHW_LOG
                        PSXHW_LOG("*Unkwnown 16bit read at address %x\n", add);
@@ -346,7 +349,7 @@ u32 psxHwRead32(u32 add) {
 
                // time for rootcounters :)
                case 0x1f801100:
-                       hard = psxRcntRcount(0);
+                       hard = psxRcntRcount0();
 #ifdef PSXHW_LOG
                        PSXHW_LOG("T0 count read32: %x\n", hard);
 #endif
@@ -364,7 +367,7 @@ u32 psxHwRead32(u32 add) {
 #endif
                        return hard;
                case 0x1f801110:
-                       hard = psxRcntRcount(1);
+                       hard = psxRcntRcount1();
 #ifdef PSXHW_LOG
                        PSXHW_LOG("T1 count read32: %x\n", hard);
 #endif
@@ -382,7 +385,7 @@ u32 psxHwRead32(u32 add) {
 #endif
                        return hard;
                case 0x1f801120:
-                       hard = psxRcntRcount(2);
+                       hard = psxRcntRcount2();
 #ifdef PSXHW_LOG
                        PSXHW_LOG("T2 count read32: %x\n", hard);
 #endif
@@ -411,8 +414,8 @@ u32 psxHwRead32(u32 add) {
                        // falthrough
                default:
                        if (0x1f801c00 <= add && add < 0x1f802000) {
-                               hard = SPU_readRegister(add);
-                               hard |= SPU_readRegister(add + 2) << 16;
+                               hard = SPU_readRegister(add, psxRegs.cycle);
+                               hard |= SPU_readRegister(add + 2, psxRegs.cycle) << 16;
                                return hard;
                        }
                        hard = psxHu32(add);