From b64fb8912577f6f1e856bf255b6bd96e4e977203 Mon Sep 17 00:00:00 2001 From: gameblabla Date: Mon, 18 Oct 2021 20:20:09 +0000 Subject: [PATCH] Fix CD volume issue in Star Wars - Dark Forces. (#232) CD Volume is 16-bits signed, not unsigned. Otherwise in Star Wars Dark Forces : If you set the volume slider to the minimum value allowed for the CD Volume, it will overflow and wrap around (to the maximum volume). --- plugins/dfsound/externals.h | 2 +- plugins/dfsound/registers.c | 8 ++++---- plugins/dfsound/spu.c | 2 +- plugins/spunull/spunull.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index de4b5dbe..5ec94152 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -201,7 +201,7 @@ typedef struct short * pS; void (CALLBACK *irqCallback)(void); // func of main emu, called on spu irq - void (CALLBACK *cddavCallback)(unsigned short,unsigned short); + void (CALLBACK *cddavCallback)(short, short); void (CALLBACK *scheduleCallback)(unsigned int); xa_decode_t * xapGlobal; diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index cc720207..e0693064 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -204,12 +204,12 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, break; //-------------------------------------------------// case H_CDLeft: - spu.iLeftXAVol=val & 0x7fff; - if(spu.cddavCallback) spu.cddavCallback(0,val); + spu.iLeftXAVol=(int16_t)val; + if(spu.cddavCallback) spu.cddavCallback(0,(int16_t)val); break; case H_CDRight: - spu.iRightXAVol=val & 0x7fff; - if(spu.cddavCallback) spu.cddavCallback(1,val); + spu.iRightXAVol=(int16_t)val; + if(spu.cddavCallback) spu.cddavCallback(1,(int16_t)val); break; //-------------------------------------------------// case H_FMod1: diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 3822e8c4..637e8521 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -1580,7 +1580,7 @@ void CALLBACK SPUregisterCallback(void (CALLBACK *callback)(void)) spu.irqCallback = callback; } -void CALLBACK SPUregisterCDDAVolume(void (CALLBACK *CDDAVcallback)(unsigned short,unsigned short)) +void CALLBACK SPUregisterCDDAVolume(void (CALLBACK *CDDAVcallback)(short, short)) { spu.cddavCallback = CDDAVcallback; } diff --git a/plugins/spunull/spunull.c b/plugins/spunull/spunull.c index 96bd3906..ece5db93 100644 --- a/plugins/spunull/spunull.c +++ b/plugins/spunull/spunull.c @@ -53,7 +53,7 @@ char * pConfigFile=0; //////////////////////////////////////////////////////////////////////// void (CALLBACK *irqCallback)(void)=0; // func of main emu, called on spu irq -void (CALLBACK *cddavCallback)(unsigned short,unsigned short)=0; +void (CALLBACK *cddavCallback)(short, short)=0; //////////////////////////////////////////////////////////////////////// // CODE AREA @@ -361,7 +361,7 @@ void CALLBACK SPUregisterCallback(void (CALLBACK *callback)(void)) irqCallback = callback; } -void CALLBACK SPUregisterCDDAVolume(void (CALLBACK *CDDAVcallback)(unsigned short,unsigned short)) +void CALLBACK SPUregisterCDDAVolume(void (CALLBACK *CDDAVcallback)(short, short)) { cddavCallback = CDDAVcallback; } -- 2.39.5