Same as last change but for Wii AX

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3832 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-07-18 09:51:47 +00:00
parent a8731c635b
commit 3a14b31b81
5 changed files with 95 additions and 123 deletions

View File

@ -914,6 +914,10 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii)
{ {
/* Doing all this may have a noticable CPU effect, so we can disable it completely /* Doing all this may have a noticable CPU effect, so we can disable it completely
this way. But remember that "Save to file" will not write anything then either. */ this way. But remember that "Save to file" will not write anything then either. */
/*
This is all broken right now since ReadOutPBs is gone.
*/
/*
if (m_DebuggerFrame->gUpdFreq > 0) if (m_DebuggerFrame->gUpdFreq > 0)
{ {
int version; // AX version int version; // AX version
@ -930,13 +934,13 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii)
{ {
if(version == 0) if(version == 0)
{ {
numberOfPBs = ReadOutPBsWii(m_addressPBs, PBw, NUMBER_OF_PBS); // numberOfPBs = ReadOutPBsWii(m_addressPBs, PBw, NUMBER_OF_PBS);
Logging_(_pBuffer, _iSize, a, Wii, PBw, numberOfPBs, m_addressPBs); // Logging_(_pBuffer, _iSize, a, Wii, PBw, numberOfPBs, m_addressPBs);
} }
else else
{ {
numberOfPBs = ReadOutPBsWii(m_addressPBs, PBw_, NUMBER_OF_PBS); // numberOfPBs = ReadOutPBsWii(m_addressPBs, PBw_, NUMBER_OF_PBS);
Logging_(_pBuffer, _iSize, a, Wii, PBw_, numberOfPBs, m_addressPBs); // Logging_(_pBuffer, _iSize, a, Wii, PBw_, numberOfPBs, m_addressPBs);
} }
} }
else else
@ -944,5 +948,5 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii)
// numberOfPBs = ReadOutPBs(m_addressPBs, PBs, NUMBER_OF_PBS); // numberOfPBs = ReadOutPBs(m_addressPBs, PBs, NUMBER_OF_PBS);
// Logging_(_pBuffer, _iSize, a, Wii, PBs, numberOfPBs, m_addressPBs); // Logging_(_pBuffer, _iSize, a, Wii, PBs, numberOfPBs, m_addressPBs);
} }
} } */
} }

View File

@ -249,7 +249,7 @@ if(m_DebuggerFrame->ScanMails)
} }
// ---------------- // ----------------
void ReadOutPB(u32 pb_address, AXParamBlock &PB) static void ReadOutPB(u32 pb_address, AXParamBlock &PB)
{ {
const u16 *pSrc = (const u16 *)g_dspInitialize.pGetMemoryPointer(pb_address); const u16 *pSrc = (const u16 *)g_dspInitialize.pGetMemoryPointer(pb_address);
u16 *pDest = (u16 *)&PB; u16 *pDest = (u16 *)&PB;
@ -259,7 +259,7 @@ void ReadOutPB(u32 pb_address, AXParamBlock &PB)
} }
} }
void WriteBackPB(u32 pb_address, AXParamBlock &PB) static void WriteBackPB(u32 pb_address, AXParamBlock &PB)
{ {
const u16 *pSrc = (const u16*)&PB; const u16 *pSrc = (const u16*)&PB;
u16 *pDest = (u16 *)g_dspInitialize.pGetMemoryPointer(pb_address); u16 *pDest = (u16 *)g_dspInitialize.pGetMemoryPointer(pb_address);
@ -269,7 +269,7 @@ void WriteBackPB(u32 pb_address, AXParamBlock &PB)
} }
} }
void ProcessUpdates(AXParamBlock &PB) static void ProcessUpdates(AXParamBlock &PB)
{ {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
/* Make the updates we are told to do. When there are multiple updates for a block they /* Make the updates we are told to do. When there are multiple updates for a block they
@ -330,7 +330,6 @@ void CUCode_AX::MixAdd(short* _pBuffer, int _iSize)
AXParamBlock PB; AXParamBlock PB;
u32 blockAddr = m_addressPBs; u32 blockAddr = m_addressPBs;
// ------------ // ------------
for (int i = 0; i < NUMBER_OF_PBS; i++) for (int i = 0; i < NUMBER_OF_PBS; i++)
{ {

View File

@ -76,30 +76,46 @@ void CUCode_AXWii::HandleMail(u32 _uMail)
} }
} }
template<class ParamBlockType> void ProcessUpdates(ParamBlockType &PB)
void CUCode_AXWii::MixAdd(short* _pBuffer, int _iSize)
{ {
if(_CRC == 0xfa450138) // ---------------------------------------------------------------------------------------
{ /* Make the updates we are told to do. See comments to the GC version in UCode_AX.cpp */
AXParamBlockWii PBs[NUMBER_OF_PBS]; // ------------
MixAdd_( _pBuffer, _iSize, PBs); u16 *pDest = (u16 *)&PB;
} u16 upd0 = pDest[41]; u16 upd1 = pDest[42]; u16 upd2 = pDest[43]; // num_updates
else u16 upd_hi = pDest[44]; // update addr
{ u16 upd_lo = pDest[45];
AXParamBlockWii_ PBs[NUMBER_OF_PBS]; int numupd = upd0 + upd1 + upd2;
MixAdd_(_pBuffer, _iSize, PBs); if(numupd > 64) numupd = 64; // prevent to high values
const u32 updaddr = (u32)(upd_hi << 16) | upd_lo;
int on = false, off = false;
for (int j = 0; j < numupd; j++) // make alll updates
{
const u16 updpar = Memory_Read_U16(updaddr);
const u16 upddata = Memory_Read_U16(updaddr + 2);
// some safety checks, I hope it's enough
if( ( (updaddr > 0x80000000 && updaddr < 0x817fffff)
|| (updaddr > 0x90000000 && updaddr < 0x93ffffff) )
&& updpar < 127 && updpar > 3 && upddata >= 0 // updpar > 3 because we don't want to change
// 0-3, those are important
//&& (upd0 || upd1 || upd2) // We should use these in some way to I think
// but I don't know how or when
&& gSequenced) // on and off option
{
//PanicAlert("Update %i: %i = %04x", i, updpar, upddata);
//DEBUG_LOG(DSPHLE, "Update: %i = %04x", updpar, upddata);
pDest[updpar] = upddata;
}
if (updpar == 7 && upddata == 1) on++;
if (updpar == 7 && upddata == 1) off++;
} }
// hack: if we get both an on and an off select on rather than off
if (on > 0 && off > 0) pDest[7] = 1;
} }
template<class ParamBlockType> template<class ParamBlockType>
void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs) void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PB)
{ {
//AXParamBlockWii PBs[NUMBER_OF_PBS];
// read out pbs
int numberOfPBs = ReadOutPBsWii(m_addressPBs, PBs, NUMBER_OF_PBS);
if (_iSize > 1024 * 1024) if (_iSize > 1024 * 1024)
_iSize = 1024 * 1024; _iSize = 1024 * 1024;
@ -110,6 +126,8 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
// ------------------------------------------- // -------------------------------------------
// write logging data to debugger // write logging data to debugger
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
/*
If this is to be resurrected, it has to be moved into the main PB loop below.
if (m_DebuggerFrame && _pBuffer) if (m_DebuggerFrame && _pBuffer)
{ {
lCUCode_AX->Logging(_pBuffer, _iSize, 0, true); lCUCode_AX->Logging(_pBuffer, _iSize, 0, true);
@ -147,59 +165,27 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
m_DebuggerFrame->upd95 = true; m_DebuggerFrame->upd95 = true;
} }
} }
} }*/
// ----------------- // -----------------
#endif #endif
// --------------------------------------------------------------------------------------- u32 blockAddr = m_addressPBs;
/* Make the updates we are told to do. See comments to the GC version in UCode_AX.cpp */
// ------------ for (int i = 0; i < NUMBER_OF_PBS; i++)
for (int i = 0; i < numberOfPBs; i++)
{ {
u16 *pDest = (u16 *)&PBs[i]; // read out pbs
u16 upd0 = pDest[41]; u16 upd1 = pDest[42]; u16 upd2 = pDest[43]; // num_updates ReadOutPBWii(blockAddr, PB);
u16 upd_hi = pDest[44]; // update addr ProcessUpdates(PB);
u16 upd_lo = pDest[45]; MixAddVoice(PB, templbuffer, temprbuffer, _iSize, true);
int numupd = upd0 + upd1 + upd2; WriteBackPBWii(blockAddr, PB);
if(numupd > 64) numupd = 64; // prevent to high values
const u32 updaddr = (u32)(upd_hi << 16) | upd_lo; // next block
int on = false, off = false; blockAddr = (PB.next_pb_hi << 16) | PB.next_pb_lo;
for (int j = 0; j < numupd; j++) // make alll updates if (blockAddr == 0) break;
{
const u16 updpar = Memory_Read_U16(updaddr);
const u16 upddata = Memory_Read_U16(updaddr + 2);
// some safety checks, I hope it's enough
if( ( (updaddr > 0x80000000 && updaddr < 0x817fffff)
|| (updaddr > 0x90000000 && updaddr < 0x93ffffff) )
&& updpar < 127 && updpar > 3 && upddata >= 0 // updpar > 3 because we don't want to change
// 0-3, those are important
//&& (upd0 || upd1 || upd2) // We should use these in some way to I think
// but I don't know how or when
&& gSequenced) // on and off option
{
//PanicAlert("Update %i: %i = %04x", i, updpar, upddata);
//DEBUG_LOG(DSPHLE, "Update: %i = %04x", updpar, upddata);
pDest[updpar] = upddata;
}
if (updpar == 7 && upddata == 1) on++;
if (updpar == 7 && upddata == 1) off++;
}
// hack: if we get both an on and an off select on rather than off
if (on > 0 && off > 0) pDest[7] = 1;
}
//PrintFile(1, "%08x %04x %04x\n", updaddr, updpar, upddata);
// ------------
for (int i = 0; i < numberOfPBs; i++)
{
MixAddVoice(PBs[i], templbuffer, temprbuffer, _iSize, true);
} }
WriteBackPBsWii(m_addressPBs, PBs, numberOfPBs);
// We write the sound to _pBuffer // We write the sound to _pBuffer
if(_pBuffer) if (_pBuffer)
{ {
for (int i = 0; i < _iSize; i++) for (int i = 0; i < _iSize; i++)
{ {
@ -439,3 +425,18 @@ bool CUCode_AXWii::AXTask(u32& _uMail)
m_rMailHandler.PushMail(0xDCD10001); m_rMailHandler.PushMail(0xDCD10001);
return true; return true;
} }
void CUCode_AXWii::MixAdd(short* _pBuffer, int _iSize)
{
if(_CRC == 0xfa450138)
{
AXParamBlockWii PB;
MixAdd_( _pBuffer, _iSize, PB);
}
else
{
AXParamBlockWii_ PB;
MixAdd_(_pBuffer, _iSize, PB);
}
}

View File

@ -58,7 +58,4 @@ private:
void SendMail(u32 _uMail); void SendMail(u32 _uMail);
}; };
//int ReadOutPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num);
//void WriteBackPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num);
#endif // _UCODE_AXWII #endif // _UCODE_AXWII

View File

@ -37,73 +37,44 @@ extern float ratioFactor;
template<class ParamBlockType> template<class ParamBlockType>
inline int ReadOutPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num) inline void ReadOutPBWii(u32 pbs_address, ParamBlockType& PB)
{ {
int count = 0;
u32 blockAddr = pbs_address; u32 blockAddr = pbs_address;
u32 pAddr = 0; u32 pAddr = 0;
// reading and 'halfword' swap const short *pSrc = (const short *)g_dspInitialize.pGetMemoryPointer(blockAddr);
for (int i = 0; i < _num; i++) pAddr = blockAddr;
short *pDest = (short *)&PB;
for (u32 p = 0; p < sizeof(ParamBlockType) / 2; p++)
{ {
const short *pSrc = (const short *)g_dspInitialize.pGetMemoryPointer(blockAddr); if (p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
pAddr = blockAddr; else pDest[p] = Common::swap16(pSrc[p]);
if (pSrc != NULL)
{
short *pDest = (short *)&_pPBs[i];
for (u32 p = 0; p < sizeof(AXParamBlockWii) / 2; p++)
{
if(p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
else pDest[p] = Common::swap16(pSrc[p]);
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
#if defined(_DEBUG) || defined(DEBUGFAST) #if defined(_DEBUG) || defined(DEBUGFAST)
if(m_DebuggerFrame) m_DebuggerFrame->gLastBlock = blockAddr + p*2 + 2; // save last block location if(m_DebuggerFrame) m_DebuggerFrame->gLastBlock = blockAddr + p*2 + 2; // save last block location
#endif #endif
#endif #endif
}
_pPBs[i].mixer_control = Common::swap32(_pPBs[i].mixer_control);
blockAddr = (_pPBs[i].next_pb_hi << 16) | _pPBs[i].next_pb_lo;
count++;
// Detect the last mail by checking when next_pb = 0
u32 next_pb = (Common::swap16(pSrc[0]) << 16) | Common::swap16(pSrc[1]);
if(next_pb == 0) break;
}
else
break;
} }
// return the number of read PBs PB.mixer_control = Common::swap32(PB.mixer_control);
return count;
} }
template<class ParamBlockType> template<class ParamBlockType>
inline void WriteBackPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num) inline void WriteBackPBWii(u32 pb_address, ParamBlockType& PB)
//void WriteBackPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num) //void WriteBackPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
{ {
u32 blockAddr = pbs_address;
// write back and 'halfword'swap // write back and 'halfword'swap
for (int i = 0; i < _num; i++) short* pSrc = (short*)&PB;
short* pDest = (short*)g_dspInitialize.pGetMemoryPointer(pb_address);
PB.mixer_control = Common::swap32(PB.mixer_control);
for (size_t p = 0; p < sizeof(ParamBlockType) / 2; p++)
{ {
short* pSrc = (short*)&_pPBs[i]; if (p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
short* pDest = (short*)g_dspInitialize.pGetMemoryPointer(blockAddr); else pDest[p] = Common::swap16(pSrc[p]);
_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 pDest[p] = Common::swap16(pSrc[p]);
}
// next block
blockAddr = (_pPBs[i].next_pb_hi << 16) | _pPBs[i].next_pb_lo;
} }
} }
template<class ParamBlockType> template<class ParamBlockType>
inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, int _iSize, bool Wii) inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, int _iSize, bool Wii)
{ {