spu: add a schedule callback
[pcsx_rearmed.git] / frontend / plugin.c
index bc42f04..1980ef5 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "plugin_lib.h"
 #include "plugin.h"
-#include "../libpcsxcore/psemu_plugin_defs.h"
+#include "psemu_plugin_defs.h"
 #include "../libpcsxcore/system.h"
 #include "../plugins/cdrcimg/cdrcimg.h"
 
@@ -32,20 +32,21 @@ extern unsigned short SPUreadDMA(void);
 extern void SPUwriteDMAMem(unsigned short *, int);
 extern void SPUreadDMAMem(unsigned short *, int);
 extern void SPUplayADPCMchannel(void *);
-extern void SPUregisterCallback(void (*callback)(void));
+extern void SPUregisterCallback(void (*cb)(void));
+extern void SPUregisterScheduleCb(void (*cb)(unsigned int));
 extern long SPUconfigure(void);
 extern long SPUtest(void);
 extern void SPUabout(void);
 extern long SPUfreeze(unsigned int, void *);
 extern void SPUasync(unsigned int);
-extern void SPUplayCDDAchannel(short *, int);
+extern int  SPUplayCDDAchannel(short *, int);
 
 /* PAD */
 static long PADreadPort1(PadDataS *pad)
 {
-       pad->controllerType = in_type;
+       pad->controllerType = in_type1;
        pad->buttonStatus = ~in_keystate;
-       if (in_type == PSE_PAD_TYPE_ANALOGPAD) {
+       if (in_type1 == PSE_PAD_TYPE_ANALOGPAD) {
                pad->leftJoyX = in_a1[0];
                pad->leftJoyY = in_a1[1];
                pad->rightJoyX = in_a2[0];
@@ -56,7 +57,7 @@ static long PADreadPort1(PadDataS *pad)
 
 static long PADreadPort2(PadDataS *pad)
 {
-       pad->controllerType = PSE_PAD_TYPE_STANDARD;
+       pad->controllerType = in_type2;
        pad->buttonStatus = ~in_keystate >> 16;
        return 0;
 }
@@ -75,7 +76,8 @@ extern void GPUreadDataMem(uint32_t *, int);
 extern long GPUdmaChain(uint32_t *,uint32_t);
 extern void GPUupdateLace(void);
 extern long GPUfreeze(uint32_t, void *);
-extern void GPUvBlank(int);
+extern void GPUvBlank(int, int);
+extern void GPUrearmedCallbacks(const struct rearmed_cbs *cbs);
 
 
 #define DUMMY(id, name) \
@@ -134,6 +136,7 @@ static const struct {
        DIRECT_SPU(SPUplayADPCMchannel),
        DIRECT_SPU(SPUfreeze),
        DIRECT_SPU(SPUregisterCallback),
+       DIRECT_SPU(SPUregisterScheduleCb),
        DIRECT_SPU(SPUasync),
        DIRECT_SPU(SPUplayCDDAchannel),
        /* PAD */
@@ -168,6 +171,7 @@ static const struct {
        DIRECT_GPU(GPUdmaChain),
        DIRECT_GPU(GPUfreeze),
        DIRECT_GPU(GPUvBlank),
+       DIRECT_GPU(GPUrearmedCallbacks),
 
        DUMMY_GPU(GPUdisplayText),
 /*
@@ -260,7 +264,7 @@ pc_hook_func              (SPU_writeDMAMem, (unsigned short *a0, int a1), (a0, a
 pc_hook_func              (SPU_readDMAMem, (unsigned short *a0, int a1), (a0, a1), PCNT_SPU)
 pc_hook_func              (SPU_playADPCMchannel, (void *a0), (a0), PCNT_SPU)
 pc_hook_func              (SPU_async, (unsigned int a0), (a0), PCNT_SPU)
-pc_hook_func              (SPU_playCDDAchannel, (short *a0, int a1), (a0, a1), PCNT_SPU)
+pc_hook_func_ret(int,      SPU_playCDDAchannel, (short *a0, int a1), (a0, a1), PCNT_SPU)
 
 #define hook_it(name) { \
        o_##name = name; \
@@ -269,8 +273,7 @@ pc_hook_func              (SPU_playCDDAchannel, (short *a0, int a1), (a0, a1), P
 
 void pcnt_hook_plugins(void)
 {
-       /* test it first */
-       pcnt_get();
+       pcnt_init();
 
        hook_it(GPU_writeStatus);
        hook_it(GPU_writeData);
@@ -291,4 +294,15 @@ void pcnt_hook_plugins(void)
        hook_it(SPU_playCDDAchannel);
 }
 
+// hooked into recompiler
+void pcnt_gte_start(int op)
+{
+       pcnt_start(PCNT_GTE);
+}
+
+void pcnt_gte_end(int op)
+{
+       pcnt_end(PCNT_GTE);
+}
+
 #endif