#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
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
\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
***************************************************************************/\r
\r
#include "stdafx.h"\r
+#include "spu.h"\r
\r
#define _IN_REVERB\r
\r
\r
// get_buffer content helper: takes care about wraps\r
#define g_buffer(var) \\r
- ((int)(signed short)spu.spuMem[rvb2ram_offs(curr_addr, space, rvb->var)])\r
+ ((int)(signed short)LE16TOH(spu.spuMem[rvb2ram_offs(curr_addr, space, rvb->var)]))\r
\r
// saturate iVal and store it as var\r
#define s_buffer(var, iVal) \\r
ssat32_to_16(iVal); \\r
- spu.spuMem[rvb2ram_offs(curr_addr, space, rvb->var)] = iVal\r
+ spu.spuMem[rvb2ram_offs(curr_addr, space, rvb->var)] = HTOLE16(iVal)\r
\r
#define s_buffer1(var, iVal) \\r
ssat32_to_16(iVal); \\r
- spu.spuMem[rvb2ram_offs(curr_addr, space, rvb->var + 1)] = iVal\r
+ spu.spuMem[rvb2ram_offs(curr_addr, space, rvb->var + 1)] = HTOLE16(iVal)\r
\r
////////////////////////////////////////////////////////////////////////\r
\r
#ifndef __P_SPU_H__\r
#define __P_SPU_H__\r
\r
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\r
+#define HTOLE16(x) __builtin_bswap16(x)\r
+#define LE16TOH(x) __builtin_bswap16(x)\r
+#else\r
+#define HTOLE16(x) (x)\r
+#define LE16TOH(x) (x)\r
+#endif\r
+\r
void ClearWorkingState(void);\r
void CALLBACK SPUplayADPCMchannel(xa_decode_t *xap, unsigned int cycle, int is_start);\r
int CALLBACK SPUplayCDDAchannel(short *pcm, int bytes, unsigned int cycle, int is_start);\r
***************************************************************************/
#include "stdafx.h"
+#include "spu.h"
#define _IN_XA
#include <stdint.h>
SSumLR[ns++] += l;
SSumLR[ns++] += r;
- spu.spuMem[cursor] = v;
- spu.spuMem[cursor + 0x400/2] = v >> 16;
+ spu.spuMem[cursor] = HTOLE16(v);
+ spu.spuMem[cursor + 0x400/2] = HTOLE16(v >> 16);
cursor = (cursor + 1) & 0x1ff;
}
spu.XALastVal = v;
SSumLR[ns++] += l;
SSumLR[ns++] += r;
- spu.spuMem[cursor] = v;
- spu.spuMem[cursor + 0x400/2] = v >> 16;
+ spu.spuMem[cursor] = HTOLE16(v);
+ spu.spuMem[cursor + 0x400/2] = HTOLE16(v >> 16);
cursor = (cursor + 1) & 0x1ff;
}
spu.XALastVal = v;