Fix CD Volume issue in Star Wars Dark Forces
authorgameblabla <gameblabla@protonmail.com>
Wed, 13 Oct 2021 20:21:08 +0000 (22:21 +0200)
committergameblabla <gameblabla@protonmail.com>
Wed, 13 Oct 2021 20:21:08 +0000 (22:21 +0200)
CD Volume is 16-bits signed, not unsigned.
Otherwise in Star Wars - Dark Forces :
if you lower the music volume slider all the way down,
the volume will wrap around and instead be set at the highest volume.

plugins/dfsound/externals.h
plugins/dfsound/registers.c
plugins/dfsound/spu.c
plugins/spunull/spunull.c

index c038ea3..19cd9ba 100644 (file)
@@ -204,7 +204,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 e1b8a40..0a18887 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;
 }