msu1: endianess fix.

This commit is contained in:
qwertymodo 2016-11-15 16:07:36 -08:00
parent 8dba3d447e
commit 2db1653836
1 changed files with 17 additions and 8 deletions

View File

@ -193,6 +193,7 @@
#include "snes9x.h" #include "snes9x.h"
#include "display.h" #include "display.h"
#include "msu1.h" #include "msu1.h"
#include "apu/bapu/dsp/blargg_endian.h"
#include <fstream> #include <fstream>
#include <cerrno> #include <cerrno>
@ -229,6 +230,7 @@ bool AudioOpen()
return false; return false;
audioFile.read((char *)&audioLoopPos, 4); audioFile.read((char *)&audioLoopPos, 4);
audioLoopPos = GET_LE32(&audioLoopPos);
audioLoopPos <<= 2; audioLoopPos <<= 2;
audioLoopPos += 8; audioLoopPos += 8;
@ -289,7 +291,7 @@ void S9xMSU1Generate(int sample_count)
int16 sample; int16 sample;
if (audioFile.read((char *)&sample, 2).good()) if (audioFile.read((char *)&sample, 2).good())
{ {
sample = (int16)((double)sample * (double)MSU1.MSU1_VOLUME / 255.0); sample = (int16)((double)(int16)GET_LE16(&sample) * (double)MSU1.MSU1_VOLUME / 255.0);
*(bufPos++) = sample; *(bufPos++) = sample;
MSU1.MSU1_AUDIO_POS += 2; MSU1.MSU1_AUDIO_POS += 2;
@ -298,7 +300,7 @@ void S9xMSU1Generate(int sample_count)
else else
if (audioFile.eof()) if (audioFile.eof())
{ {
sample = (int16)((double)sample * (double)MSU1.MSU1_VOLUME / 255.0); sample = (int16)((double)(int16)GET_LE16(&sample) * (double)MSU1.MSU1_VOLUME / 255.0);
*(bufPos++) = sample; *(bufPos++) = sample;
MSU1.MSU1_AUDIO_POS += 2; MSU1.MSU1_AUDIO_POS += 2;
@ -369,25 +371,31 @@ void S9xMSU1WritePort(int port, uint8 byte)
switch (port) switch (port)
{ {
case 0: case 0:
((uint8 *)(&MSU1.MSU1_DATA_SEEK))[0] = byte; MSU1.MSU1_DATA_SEEK &= 0xFFFFFF00;
MSU1.MSU1_DATA_SEEK |= byte << 0;
break; break;
case 1: case 1:
((uint8 *)(&MSU1.MSU1_DATA_SEEK))[1] = byte; MSU1.MSU1_DATA_SEEK &= 0xFFFF00FF;
MSU1.MSU1_DATA_SEEK |= byte << 8;
break; break;
case 2: case 2:
((uint8 *)(&MSU1.MSU1_DATA_SEEK))[2] = byte; MSU1.MSU1_DATA_SEEK &= 0xFF00FFFF;
MSU1.MSU1_DATA_SEEK |= byte << 16;
break; break;
case 3: case 3:
((uint8 *)(&MSU1.MSU1_DATA_SEEK))[3] = byte; MSU1.MSU1_DATA_SEEK &= 0x00FFFFFF;
MSU1.MSU1_DATA_SEEK |= byte << 24;
MSU1.MSU1_DATA_POS = MSU1.MSU1_DATA_SEEK; MSU1.MSU1_DATA_POS = MSU1.MSU1_DATA_SEEK;
if(dataFile.good()) if(dataFile.good())
dataFile.seekg(MSU1.MSU1_DATA_POS); dataFile.seekg(MSU1.MSU1_DATA_POS);
break; break;
case 4: case 4:
((uint8 *)(&MSU1.MSU1_TRACK_SEEK))[0] = byte; MSU1.MSU1_TRACK_SEEK &= 0xFF00;
MSU1.MSU1_TRACK_SEEK |= byte;
break; break;
case 5: case 5:
((uint8 *)(&MSU1.MSU1_TRACK_SEEK))[1] = byte; MSU1.MSU1_TRACK_SEEK &= 0x00FF;
MSU1.MSU1_TRACK_SEEK |= (byte << 8);
MSU1.MSU1_CURRENT_TRACK = MSU1.MSU1_TRACK_SEEK; MSU1.MSU1_CURRENT_TRACK = MSU1.MSU1_TRACK_SEEK;
MSU1.MSU1_STATUS &= ~AudioPlaying; MSU1.MSU1_STATUS &= ~AudioPlaying;
@ -451,6 +459,7 @@ void S9xMSU1PostLoadState(void)
{ {
audioFile.seekg(4); audioFile.seekg(4);
audioFile.read((char *)&audioLoopPos, 4); audioFile.read((char *)&audioLoopPos, 4);
audioLoopPos = GET_LE32(&audioLoopPos);
audioLoopPos <<= 2; audioLoopPos <<= 2;
audioLoopPos += 8; audioLoopPos += 8;