X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fplugins.c;h=d7c2acb6e9eab64b271b47df77f488041ca5f18d;hb=38b8a211aad8d2c485ccf0c0cbb58d965aac3483;hp=868493bb6c63a2a45536a304ef07227ca5b77b06;hpb=86459dfc29c5c5f78c79d649d297a98d7212cc7f;p=pcsx_rearmed.git diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 868493bb..d7c2acb6 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -86,6 +86,7 @@ SPUregisterCallback SPU_registerCallback; SPUregisterScheduleCb SPU_registerScheduleCb; SPUasync SPU_async; SPUplayCDDAchannel SPU_playCDDAchannel; +SPUsetCDvol SPU_setCDvol; PADconfigure PAD1_configure; PADabout PAD1_about; @@ -179,7 +180,7 @@ static const char *err; #define LoadSym(dest, src, name, checkerr) { \ dest = (src)SysLoadSym(drv, name); \ - if (checkerr) { CheckErr(name); } else SysLibError(); \ + if (checkerr) { CheckErr(name); } \ } void *hGPUDriver = NULL; @@ -313,13 +314,15 @@ static int LoadCDRplugin(const char *CDRdll) { static void *hSPUDriver = NULL; static void CALLBACK SPU__registerScheduleCb(void (CALLBACK *cb)(unsigned int)) {} +static void CALLBACK SPU__setCDvol(unsigned char ll, unsigned char lr, + unsigned char rl, unsigned char rr, unsigned int cycle) {} #define LoadSpuSym1(dest, name) \ LoadSym(SPU_##dest, SPU##dest, name, TRUE); #define LoadSpuSym0(dest, name) \ LoadSym(SPU_##dest, SPU##dest, name, FALSE); \ - if (SPU_##dest == NULL) SPU_##dest = (SPU##dest) SPU__##dest; + if (SPU_##dest == NULL) SPU_##dest = SPU__##dest; #define LoadSpuSymN(dest, name) \ LoadSym(SPU_##dest, SPU##dest, name, FALSE); @@ -346,6 +349,7 @@ static int LoadSPUplugin(const char *SPUdll) { LoadSpuSym0(registerScheduleCb, "SPUregisterScheduleCb"); LoadSpuSymN(async, "SPUasync"); LoadSpuSymN(playCDDAchannel, "SPUplayCDDAchannel"); + LoadSpuSym0(setCDvol, "SPUsetCDvol"); return 0; } @@ -490,15 +494,8 @@ static void initBufForRequest(int padIndex, char value) { return; } - // switch to analog mode automatically after the game finishes init - if (value == 0x42 && pads[padIndex].ds.padMode == 0) - pads[padIndex].ds.digitalModeFrames++; - if (pads[padIndex].ds.digitalModeFrames == 60*4) { - pads[padIndex].ds.padMode = 1; - pads[padIndex].ds.digitalModeFrames = 0; - } - - if ((u32)(frame_counter - pads[padIndex].ds.lastUseFrame) > 60u) + if ((u32)(frame_counter - pads[padIndex].ds.lastUseFrame) > 60u + && !Config.hacks.dualshock_init_analog) pads[padIndex].ds.padMode = 0; // according to nocash pads[padIndex].ds.lastUseFrame = frame_counter; @@ -622,6 +619,15 @@ static void log_pad(int port, int pos) #endif } +static void adjust_analog(unsigned char *b) +{ + // ff8 hates 0x80 for whatever reason (broken in 2d area menus), + // or is this caused by something else we do wrong?? + // Also S.C.A.R.S. treats 0x7f as turning left. + if (b[6] == 0x7f || b[6] == 0x80) + b[6] = 0x81; +} + // Build response for 0x42 request Pad in port static void PADstartPoll_(PadDataS *pad) { switch (pad->controllerType) { @@ -699,6 +705,7 @@ static void PADstartPoll_(PadDataS *pad) { stdpar[5] = pad->rightJoyY; stdpar[6] = pad->leftJoyX; stdpar[7] = pad->leftJoyY; + adjust_analog(stdpar); memcpy(buf, stdpar, 8); respSize = 8; break; @@ -711,6 +718,7 @@ static void PADstartPoll_(PadDataS *pad) { stdpar[5] = pad->rightJoyY; stdpar[6] = pad->leftJoyX; stdpar[7] = pad->leftJoyY; + adjust_analog(stdpar); memcpy(buf, stdpar, 8); respSize = 8; break; @@ -980,6 +988,15 @@ int padFreeze(void *f, int Mode) { return 0; } +int padToggleAnalog(unsigned int index) +{ + int r = -1; + + if (index < sizeof(pads) / sizeof(pads[0])) + r = (pads[index].ds.padMode ^= 1); + return r; +} + void *hNETDriver = NULL;