dfsound: Fix issues on big-endian systems
[pcsx_rearmed.git] / plugins / dfsound / registers.c
index e75f708..badd0af 100644 (file)
@@ -22,6 +22,7 @@
 #include "externals.h"\r
 #include "registers.h"\r
 #include "spu_config.h"\r
+#include "spu.h"\r
 \r
 static void SoundOn(int start,int end,unsigned short val);\r
 static void SoundOff(int start,int end,unsigned short val);\r
@@ -127,7 +128,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val,
       break;\r
     //-------------------------------------------------//\r
     case H_SPUdata:\r
-      *(unsigned short *)(spu.spuMemC + spu.spuAddr) = val;\r
+      *(unsigned short *)(spu.spuMemC + spu.spuAddr) = HTOLE16(val);\r
       spu.spuAddr += 2;\r
       spu.spuAddr &= 0x7fffe;\r
       break;\r
@@ -334,7 +335,7 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg)
 \r
     case H_SPUdata:\r
      {\r
-      unsigned short s = *(unsigned short *)(spu.spuMemC + spu.spuAddr);\r
+      unsigned short s = LE16TOH(*(unsigned short *)(spu.spuMemC + spu.spuAddr));\r
       spu.spuAddr += 2;\r
       spu.spuAddr &= 0x7fffe;\r
       return s;\r
@@ -505,10 +506,8 @@ static void SetPitch(int ch,unsigned short val)               // SET PITCH
  spu.s_chan[ch].sinc = NP << 4;\r
  spu.s_chan[ch].sinc_inv = 0;\r
  spu.SB[ch * SB_SIZE + 32] = 1; // -> freq change in simple interpolation mode: set flag\r
- if (val)\r
-  spu.dwChannelsAudible |= 1u << ch;\r
- else\r
-  spu.dwChannelsAudible &= ~(1u << ch);\r
+\r
+ // don't mess spu.dwChannelsAudible as adsr runs independently\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////\r