Fix CD volume issue in Star Wars - Dark Forces. (#232)
authorgameblabla <gameblabla@users.noreply.github.com>
Mon, 18 Oct 2021 20:20:09 +0000 (20:20 +0000)
committerGitHub <noreply@github.com>
Mon, 18 Oct 2021 20:20:09 +0000 (23:20 +0300)
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
plugins/dfsound/registers.c
plugins/dfsound/spu.c
plugins/spunull/spunull.c

index de4b5db..5ec9415 100644 (file)
@@ -201,7 +201,7 @@ typedef struct
  short         * pS;\r
 \r
  void (CALLBACK *irqCallback)(void);   // func of main emu, called on spu irq\r
- void (CALLBACK *cddavCallback)(unsigned short,unsigned short);\r
+ void (CALLBACK *cddavCallback)(short, short);\r
  void (CALLBACK *scheduleCallback)(unsigned int);\r
 \r
  xa_decode_t   * xapGlobal;\r
index cc72020..e069306 100644 (file)
@@ -204,12 +204,12 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val,
       break;\r
     //-------------------------------------------------//\r
     case H_CDLeft:\r
-      spu.iLeftXAVol=val  & 0x7fff;\r
-      if(spu.cddavCallback) spu.cddavCallback(0,val);\r
+      spu.iLeftXAVol=(int16_t)val;\r
+      if(spu.cddavCallback) spu.cddavCallback(0,(int16_t)val);\r
       break;\r
     case H_CDRight:\r
-      spu.iRightXAVol=val & 0x7fff;\r
-      if(spu.cddavCallback) spu.cddavCallback(1,val);\r
+      spu.iRightXAVol=(int16_t)val;\r
+      if(spu.cddavCallback) spu.cddavCallback(1,(int16_t)val);\r
       break;\r
     //-------------------------------------------------//\r
     case H_FMod1:\r
index 3822e8c..637e852 100644 (file)
@@ -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;
 }
index 96bd390..ece5db9 100644 (file)
@@ -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;
 }