Fixed Wii AX sound, for real this time

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1169 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2008-11-14 11:47:17 +00:00
parent 09e168beac
commit 2976f3f1e3
16 changed files with 111 additions and 74 deletions

View File

@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/
#include "FileUtil.h" // for IsDirectory
#include "StringUtil.h" // for StringFromFormat
#include "../Debugger/Debugger.h"
#include "../Logging/Console.h" // for aprintf
#include <sstream>
@ -119,7 +120,9 @@ if(m_frame->ScanMails)
ci << (saveNext - 1);
TmpMailLog += "\n\n";
TmpMailLog += "-----------------------------------------------------------------------\n";
TmpMailLog += "Current mail: " + gpName + " mail " + ci.str() + "\n\n";
TmpMailLog += "Current mail: " + gpName + " mail " + ci.str() + "\n";
if(Wii)
TmpMailLog += "Current CRC: " + StringFromFormat("0x%08x \n\n", _CRC);
for (int i = 0; i < sMailTime.size(); i++)
{
@ -143,7 +146,7 @@ if(m_frame->ScanMails)
{
TmpMailLog += Msg;
TmpMailLog += "\n";
LOG_(1, Msg);
LOG_(1, Msg); // also write it to the log
}
}
}

View File

@ -48,6 +48,7 @@ public:
// PBs
u32 m_addressPBs;
u32 _CRC;
private:
enum

View File

@ -79,7 +79,7 @@ struct PBDpop
s16 unknown[12];
};
struct PBDpopWii_
struct PBDpopWii_ // new CRC version
{
s16 unknown[7];
};
@ -204,7 +204,7 @@ struct AXParamBlockWii
/* 106 */ u16 pad[22];
};
struct AXParamBlockWii_
struct AXParamBlockWii_ // new CRC version
{
u16 next_pb_hi;
u16 next_pb_lo;

View File

@ -54,6 +54,7 @@ CUCode_AXWii::CUCode_AXWii(CMailHandler& _rMailHandler, u32 _CRC)
temprbuffer = new int[1024 * 1024];
lCUCode_AX = new CUCode_AX(_rMailHandler);
lCUCode_AX->_CRC = _CRC;
_CRC = _CRC;
}
@ -86,6 +87,7 @@ void CUCode_AXWii::MixAdd(short* _pBuffer, int _iSize)
}
else
{
//LOG_(0, "else");
AXParamBlockWii_ PBs[NUMBER_OF_PBS];
MixAdd_(_pBuffer, _iSize, PBs);
}
@ -99,7 +101,7 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
//AXParamBlockWii PBs[NUMBER_OF_PBS];
// read out pbs
int numberOfPBs = ReadOutPBsWii(m_addressPBs, PBs, NUMBER_OF_PBS);
int numberOfPBs = ReadOutPBsWii(m_addressPBs, PBs, NUMBER_OF_PBS, false);
if (_iSize > 1024 * 1024)
_iSize = 1024 * 1024;
@ -194,10 +196,9 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
//MixAddVoice(pb, templbuffer, temprbuffer, _iSize);
MixAddVoice(PBs[i], templbuffer, temprbuffer, _iSize);
}
}
}
WriteBackPBsWii(m_addressPBs, PBs, numberOfPBs);
// We write the sound to _pBuffer
for (int i = 0; i < _iSize; i++)
{
@ -350,7 +351,7 @@ bool CUCode_AXWii::AXTask(u32& _uMail)
Addr__AXOutSBuffer = Memory_Read_U32(uAddress);
uAddress += 10;
// uAddress += 12;
DebugLog("%08x : AXLIST OutSBuffer (0x0007) address: %08x", uAddress, Addr__AXOutSBuffer);
SaveLog("%08x : AXLIST OutSBuffer (0x0007) address: %08x", uAddress, Addr__AXOutSBuffer);
break;
/* case 0x0009:

View File

@ -26,12 +26,11 @@
// -----------
extern bool gSequenced;
extern bool gVolume;
extern float ratioFactor;
template<class ParamBlockType>
inline int ReadOutPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
inline int ReadOutPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num, int _deb)
//int ReadOutPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
{
int count = 0;
@ -50,14 +49,13 @@ inline int ReadOutPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
for (int p = 0; p < sizeof(AXParamBlockWii) / 2; p++)
{
if(p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
//else if(p == 62 || p == 63 || p == 64 || p == 65 || p == 66 || p == 67)
// pDest[p] = Common::swap16(pSrc[p-1]);
else pDest[p] = Common::swap16(pSrc[p]);
#if defined(_DEBUG) || defined(DEBUGFAST)
gLastBlock = blockAddr + p*2 + 2; // save last block location
#endif
}
}
_pPBs[i].mixer_control = Common::swap32(_pPBs[i].mixer_control);
blockAddr = (_pPBs[i].next_pb_hi << 16) | _pPBs[i].next_pb_lo;
count++;
@ -88,10 +86,8 @@ inline void WriteBackPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
_pPBs[i].mixer_control = Common::swap32(_pPBs[i].mixer_control);
for (size_t p = 0; p < sizeof(AXParamBlockWii) / 2; p++)
{
if(p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
//else if(p == 62 || p == 63 || p == 64 || p == 65 || p == 66 || p == 67)
// pDest[p-1] = Common::swap16(pSrc[p]);
else pDest[p] = Common::swap16(pSrc[p]);
if(p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
else pDest[p] = Common::swap16(pSrc[p]);
}
// next block
@ -100,18 +96,13 @@ inline void WriteBackPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
}
template<class ParamBlockType>
inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, int _iSize)
{
#ifdef _WIN32
float ratioFactor = 32000.0f / (float)DSound::DSound_GetSampleRate();
ratioFactor = 32000.0f / (float)DSound::DSound_GetSampleRate();
#else
float ratioFactor = 32000.0f / 44100.0f;
ratioFactor = 32000.0f / 44100.0f;
#endif
// DoVoiceHacks(pb);
@ -123,7 +114,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
// =======================================================================================
// Read initial parameters
// ------------
//constants
//constants
const u32 ratio = (u32)(((pb.src.ratio_hi << 16) + pb.src.ratio_lo) * ratioFactor);
u32 sampleEnd = (pb.audio_addr.end_addr_hi << 16) | pb.audio_addr.end_addr_lo;
u32 loopPos = (pb.audio_addr.loop_addr_hi << 16) | pb.audio_addr.loop_addr_lo;
@ -132,7 +123,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
u32 samplePos = (pb.audio_addr.cur_addr_hi << 16) | pb.audio_addr.cur_addr_lo;
u32 frac = pb.src.cur_addr_frac;
// =============
// =======================================================================================
// Handle no-src streams - No src streams have pb.src_type == 2 and have pb.src.ratio_hi = 0
// and pb.src.ratio_lo = 0. We handle that by setting the sampling ratio integer to 1. This
@ -155,6 +146,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
}
// =============
// =======================================================================================
// Games that use looping to play non-looping music streams - SSBM has info in all
// pb.adpcm_loop_info parameters but has pb.audio_addr.looping = 0. If we treat these streams
@ -278,7 +270,6 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
}
}
// ===============
} // end of the _iSize loop
// Update volume
@ -292,6 +283,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
pb.src.cur_addr_frac = (u16)frac;
pb.audio_addr.cur_addr_hi = samplePos >> 16;
pb.audio_addr.cur_addr_lo = (u16)samplePos;
} // if (pb.running)
}