Small DSP HLE update. Some AX Wii games now play noise (Top Spin 3, Wario Land).

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1122 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2008-11-11 08:10:09 +00:00
parent 2a4e584e02
commit f38b1688cc
7 changed files with 111 additions and 76 deletions

View File

@ -35,6 +35,12 @@
// ------------------------------------------------------------------
// Externals
// -----------
extern bool gSSBM;
extern bool gSSBMremedy1;
extern bool gSSBMremedy2;
extern bool gSequenced;
extern bool gVolume;
extern bool gReset;
extern u32 gLastBlock;
extern std::string gpName;
extern CDebugger* m_frame;
@ -262,7 +268,7 @@ void DoVoiceHacks(AXParamBlock &pb)
// ------------
if (
(sampleEnd > 0x10000000 || loopPos > 0x10000000)
&& m_frame->gSSBMremedy1
&& gSSBMremedy1
)
{
pb.running = 0;
@ -301,7 +307,7 @@ void DoVoiceHacks(AXParamBlock &pb)
&& pb.mixer_control == 0 // only use this in SSBM
&& m_frame->gSSBMremedy2 // let us turn this fix on and off
&& gSSBMremedy2 // let us turn this fix on and off
)
{
// reset the detection values
@ -323,7 +329,7 @@ void DoVoiceHacks(AXParamBlock &pb)
// =======================================================================================
// Reset all values
// ------------
if (m_frame->gReset
if (gReset
&& (pb.running || pb.audio_addr.looping || pb.adpcm_loop_info.pred_scale)
)
{
@ -430,7 +436,7 @@ void CUCode_AX::MixAdd(short* _pBuffer, int _iSize)
// 0-3, those are important
&& (upd0 || upd1 || upd2 || upd3 || upd4) // We should use these in some way to I think
// but I don't know how or when
&& m_frame->gSequenced) // on and off option
&& gSequenced) // on and off option
{
pDest[updpar] = upddata;
}

View File

@ -34,6 +34,7 @@
// ------------------------------------------------------------------
// Declarations
// -----------
extern bool gSequenced;
extern u32 gLastBlock;
extern CDebugger * m_frame;
// -----------
@ -84,13 +85,11 @@ int ReadOutPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
const short *pSrc = (const short *)g_dspInitialize.pGetMemoryPointer(blockAddr);
pAddr = blockAddr;
// Detect the last mail by checking when next_pb = 0
u32 next_pb = (Common::swap16(pSrc[0]) << 16) | Common::swap16(pSrc[1]);
if (pSrc != NULL && next_pb > 0)
if (pSrc != NULL)
{
short *pDest = (short *)&_pPBs[i];
for (int p = 0; p < sizeof(AXParamBlockWii) / 2; p++)
{
{
pDest[p] = Common::swap16(pSrc[p]);
#if defined(_DEBUG) || defined(DEBUGFAST)
@ -99,6 +98,10 @@ int ReadOutPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
}
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;
@ -118,11 +121,11 @@ void WriteBackPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
short* pSrc = (short*)&_pPBs[i];
short* pDest = (short*)g_dspInitialize.pGetMemoryPointer(blockAddr);
for (size_t p = 0; p < sizeof(AXParamBlockWii) / 2; p++)
{
pDest[p] = Common::swap16(pSrc[p]);
{
pDest[p] = Common::swap16(pSrc[p]);
}
// next block
// next block
blockAddr = (_pPBs[i].next_pb_hi << 16) | _pPBs[i].next_pb_lo;
}
}
@ -146,34 +149,38 @@ void CUCode_AXWii::MixAdd(short* _pBuffer, int _iSize)
lCUCode_AX->Logging(_pBuffer, _iSize, 0, true);
}
// ---------------------------------------------------------------------------------------
// Make the updates we are told to do
// This code is buggy, TODO - fix. If multiple updates in a ms, only does first.
// Make the updates we are told to do. This code may be buggy, TODO - fix. If multiple
// updates in a ms, only does first.
// ------------
/*
for (int i = 0; i < numberOfPBs; i++) {
for (int i = 0; i < numberOfPBs; i++)
{
u16 *pDest = (u16 *)&PBs[i];
u16 upd0 = pDest[34]; u16 upd1 = pDest[35]; u16 upd2 = pDest[36]; // num_updates
u16 upd_hi = pDest[39]; // update addr
u16 upd_lo = pDest[40];
u16 upd0 = pDest[41]; u16 upd1 = pDest[42]; u16 upd2 = pDest[43]; // num_updates
u16 upd_hi = pDest[44]; // update addr
u16 upd_lo = pDest[45];
const u32 updaddr = (u32)(upd_hi << 16) | upd_lo;
const u16 updpar = Memory_Read_U16(updaddr);
const u16 upddata = Memory_Read_U16(updaddr + 2);
// some safety checks, I hope it's enough, how long does the memory go?
if(updaddr > 0x80000000 && updaddr < 0x82000000
&& updpar < 63 && updpar > 3 && upddata >= 0 // updpar > 3 because we don't want to change
&& updpar < 127 && updpar > 3 && upddata >= 0 // updpar > 3 because we don't want to change
// 0-3, those are important
&& (upd0 || upd1 || upd2 || upd3 || upd4) // We should use these in some way to I think
&& (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);
//DebugLog("Update: %i = %04x", updpar, upddata);
pDest[updpar] = upddata;
}
}*/
}
//aprintf(1, "%08x %04x %04x\n", updaddr, updpar, upddata);
// ------------
for (int i = 0; i < numberOfPBs; i++)
{
AXParamBlockWii& pb = PBs[i];

View File

@ -62,7 +62,7 @@ inline s16 ADPCM_Step(PBADPCMInfo &adpcm, u32& samplePos, u32 newSamplePos, u16
// =======================================================================================
// Volume control (ramping)
// --------------
inline u16 ADPCM_Vol(u16 vol, u16 delta, u16 mixer_control)
inline u16 ADPCM_Vol(u16 vol, u16 delta)
{
int x = vol;
if (delta && delta < 0x5000)

View File

@ -21,6 +21,12 @@
#include "UCode_AX_ADPCM.h"
#include "../main.h"
// ----------------------------------------------------
// Externals
// -----------
extern bool gSequenced;
extern bool gVolume;
template<class ParamBlockType>
inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, int _iSize)
{
@ -35,13 +41,14 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
// =============
if (pb.running)
{
// =======================================================================================
// Read initial parameters
// ------------
//constants
const u32 ratio = (u32)(((pb.src.ratio_hi << 16) + pb.src.ratio_lo) * ratioFactor);
const u32 sampleEnd = (pb.audio_addr.end_addr_hi << 16) | pb.audio_addr.end_addr_lo;
const u32 loopPos = (pb.audio_addr.loop_addr_hi << 16) | pb.audio_addr.loop_addr_lo;
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;
//variables
u32 samplePos = (pb.audio_addr.cur_addr_hi << 16) | pb.audio_addr.cur_addr_lo;
@ -63,7 +70,8 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
// Soul Calibur 2: The movie music use src_type 2 but it needs no adjustment, perhaps
// the sound format plays in to, Baten use ADPCM SC2 use PCM16
// ------------
if (pb.src_type == 2 && (pb.src.ratio_hi == 0 && pb.src.ratio_lo == 0))
//if (pb.src_type == 2 && (pb.src.ratio_hi == 0 && pb.src.ratio_lo == 0))
if (pb.running && (pb.src.ratio_hi == 0 && pb.src.ratio_lo == 0))
{
pb.src.ratio_hi = 1;
}
@ -78,14 +86,22 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
// --------------
if (
(pb.adpcm_loop_info.pred_scale || pb.adpcm_loop_info.yn1 || pb.adpcm_loop_info.yn2)
&& pb.mixer_control == 0
&& pb.mixer_control == 0
)
{
pb.audio_addr.looping = 1;
}
// ==============
// Top Spin 3 Wii
if(pb.audio_addr.sample_format > 25) pb.audio_addr.sample_format = 0;
/* What's with the high samplePos values in Wii? Should we adjust them somehow?
samplePos = ((samplePos/14)*16) + (samplePos % 14) + 2;
sampleEnd = ((sampleEnd/14)*16) + (sampleEnd % 14) + 2;
loopPos = ((loopPos/14)*16) + (loopPos % 14) + 2;
*/
// =======================================================================================
// Walk through _iSize. _iSize = numSamples. If the game goes slow _iSize will be higher to
// compensate for that. _iSize can be as low as 100 or as high as 2000 some cases.
@ -188,10 +204,11 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
} // end of the _iSize loop
// Update volume
if (sizeof(ParamBlockType) == sizeof(AXParamBlock) && m_frame->gVolume) // allow us to turn this off in the debugger
//if (sizeof(ParamBlockType) == sizeof(AXParamBlock)) // this is not needed anymore I think
if (gVolume) // allow us to turn this off in the debugger
{
pb.mixer.volume_left = ADPCM_Vol(pb.mixer.volume_left, pb.mixer.unknown, pb.mixer_control);
pb.mixer.volume_right = ADPCM_Vol(pb.mixer.volume_right, pb.mixer.unknown2, pb.mixer_control);
pb.mixer.volume_left = ADPCM_Vol(pb.mixer.volume_left, pb.mixer.unknown);
pb.mixer.volume_right = ADPCM_Vol(pb.mixer.volume_right, pb.mixer.unknown2);
}
pb.src.cur_addr_frac = (u16)frac;