psxinterpreter: log reserved insn once
[pcsx_rearmed.git] / libpcsxcore / plugins.c
index b143923..4516b5c 100644 (file)
@@ -49,7 +49,6 @@ GPUmakeSnapshot       GPU_makeSnapshot;
 GPUfreeze             GPU_freeze;
 GPUgetScreenPic       GPU_getScreenPic;
 GPUshowScreenPic      GPU_showScreenPic;
-GPUclearDynarec       GPU_clearDynarec;
 GPUvBlank             GPU_vBlank;
 
 CDRinit               CDR_init;
@@ -72,18 +71,12 @@ CDRsetfilename        CDR_setfilename;
 CDRreadCDDA           CDR_readCDDA;
 CDRgetTE              CDR_getTE;
 
-SPUconfigure          SPU_configure;
-SPUabout              SPU_about;
 SPUinit               SPU_init;
 SPUshutdown           SPU_shutdown;
-SPUtest               SPU_test;
 SPUopen               SPU_open;
 SPUclose              SPU_close;
-SPUplaySample         SPU_playSample;
 SPUwriteRegister      SPU_writeRegister;
 SPUreadRegister       SPU_readRegister;
-SPUwriteDMA           SPU_writeDMA;
-SPUreadDMA            SPU_readDMA;
 SPUwriteDMAMem        SPU_writeDMAMem;
 SPUreadDMAMem         SPU_readDMAMem;
 SPUplayADPCMchannel   SPU_playADPCMchannel;
@@ -201,7 +194,6 @@ void CALLBACK GPU__makeSnapshot(void) {}
 void CALLBACK GPU__keypressed(int key) {}
 long CALLBACK GPU__getScreenPic(unsigned char *pMem) { return -1; }
 long CALLBACK GPU__showScreenPic(unsigned char *pMem) { return -1; }
-void CALLBACK GPU__clearDynarec(void (CALLBACK *callback)(void)) {}
 void CALLBACK GPU__vBlank(int val) {}
 
 #define LoadGpuSym1(dest, name) \
@@ -241,7 +233,6 @@ static int LoadGPUplugin(const char *GPUdll) {
        LoadGpuSym1(freeze, "GPUfreeze");
        LoadGpuSym0(getScreenPic, "GPUgetScreenPic");
        LoadGpuSym0(showScreenPic, "GPUshowScreenPic");
-       LoadGpuSym0(clearDynarec, "GPUclearDynarec");
        LoadGpuSym0(vBlank, "GPUvBlank");
        LoadGpuSym0(configure, "GPUconfigure");
        LoadGpuSym0(test, "GPUtest");
@@ -317,12 +308,8 @@ static int LoadCDRplugin(const char *CDRdll) {
        return 0;
 }
 
-void *hSPUDriver = NULL;
-
-long CALLBACK SPU__configure(void) { return 0; }
-void CALLBACK SPU__about(void) {}
-long CALLBACK SPU__test(void) { return 0; }
-void CALLBACK SPU__registerScheduleCb(void (CALLBACK *cb)(unsigned int)) {}
+static void *hSPUDriver = NULL;\r
+static void CALLBACK SPU__registerScheduleCb(void (CALLBACK *cb)(unsigned int)) {}\r
 
 #define LoadSpuSym1(dest, name) \
        LoadSym(SPU_##dest, SPU##dest, name, TRUE);
@@ -339,7 +326,6 @@ static int LoadSPUplugin(const char *SPUdll) {
 
        hSPUDriver = SysLoadLibrary(SPUdll);
        if (hSPUDriver == NULL) {
-               SPU_configure = NULL;
                SysMessage (_("Could not load SPU plugin %s!"), SPUdll); return -1;
        }
        drv = hSPUDriver;
@@ -347,13 +333,8 @@ static int LoadSPUplugin(const char *SPUdll) {
        LoadSpuSym1(shutdown, "SPUshutdown");
        LoadSpuSym1(open, "SPUopen");
        LoadSpuSym1(close, "SPUclose");
-       LoadSpuSym0(configure, "SPUconfigure");
-       LoadSpuSym0(about, "SPUabout");
-       LoadSpuSym0(test, "SPUtest");
        LoadSpuSym1(writeRegister, "SPUwriteRegister");
        LoadSpuSym1(readRegister, "SPUreadRegister");
-       LoadSpuSym1(writeDMA, "SPUwriteDMA");
-       LoadSpuSym1(readDMA, "SPUreadDMA");
        LoadSpuSym1(writeDMAMem, "SPUwriteDMAMem");
        LoadSpuSym1(readDMAMem, "SPUreadDMAMem");
        LoadSpuSym1(playADPCMchannel, "SPUplayADPCMchannel");
@@ -664,28 +645,17 @@ void _PADstartPoll(PadDataS *pad) {
                        int absX = (pad->absoluteX / 64) + 512;
                        int absY = (pad->absoluteY / 64) + 512;
 
-                       //Keep within limits
-                       if (absX > 1023) absX = 1023;
-                       if (absX < 0) absX = 0;
-                       if (absY > 1023) absY = 1023;
-                       if (absY < 0) absY = 0;
-
-                       stdpar[4] = 0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * absX >> 10);
-                       stdpar[5] = (0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * absX >> 10)) >> 8;
-                       stdpar[6] = 0x20 + (yres * absY >> 10);
-                       stdpar[7] = (0x20 + (yres * absY >> 10)) >> 8;
-
-                       //Offscreen - Point at the side of the screen so PSX thinks you are pointing offscreen
-                       //Required as a mouse can't be offscreen
-                       //Coordinates X=0001h, Y=000Ah indicates "no light"
-                       //This will mean you cannot shoot the very each of the screen
-                       //ToDo read offscreen range from settings if useful to change
-                       int OffscreenRange = 2;
-                       if (absX < (OffscreenRange) || absX > (1023 - OffscreenRange) || absY < (OffscreenRange) || absY > (1023 - OffscreenRange)) {
-                               stdpar[4] = 0x01;
-                               stdpar[5] = 0x00;
-                               stdpar[6] = 0x0A;
-                               stdpar[7] = 0x00;
+                       if (absX == 65536 || absY == 65536) {
+                          stdpar[4] = 0x01;
+                          stdpar[5] = 0x00;
+                          stdpar[6] = 0x0A;
+                          stdpar[7] = 0x00;
+                       }
+                       else {
+                          stdpar[4] = 0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * absX >> 10);
+                          stdpar[5] = (0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * absX >> 10)) >> 8;
+                          stdpar[6] = 0x20 + (yres * absY >> 10);
+                          stdpar[7] = (0x20 + (yres * absY >> 10)) >> 8;
                        }
 
                        memcpy(buf, stdpar, 8);
@@ -775,10 +745,18 @@ unsigned char _PADpoll(int port, unsigned char value) {
                }
        }
 
+       if (reqPos < sizeof(pad[port].txData))
+               pad[port].txData[reqPos] = value;
+
        //if no new request the pad return 0xff, for signaling connected
        if (reqPos >= respSize)
                return 0xff;
 
+       if (in_type[port] == PSE_PAD_TYPE_GUN) {
+               if (reqPos == 2)
+                       pl_gun_byte2(port, value);
+       }
+       else
        switch(reqPos){
                case 2:
                        reqIndex2Treatment(port, value);
@@ -1131,10 +1109,6 @@ static int LoadSIO1plugin(const char *SIO1dll) {
 
 #endif
 
-void CALLBACK clearDynarec(void) {
-       psxCpu->Reset();
-}
-
 int LoadPlugins() {
        int ret;
        char Plugin[MAXPATHLEN * 2];