diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp index c770afbcf4..07c6525f2d 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp @@ -174,14 +174,17 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PB) #endif u32 blockAddr = m_addressPBs; - + if (!blockAddr) + return; for (int i = 0; i < NUMBER_OF_PBS; i++) { // read out pbs - ReadOutPBWii(blockAddr, PB); + if (!ReadOutPBWii(blockAddr, PB)) + break; ProcessUpdates(PB); MixAddVoice(PB, templbuffer, temprbuffer, _iSize, true); - WriteBackPBWii(blockAddr, PB); + if (!WriteBackPBWii(blockAddr, PB)) + break; // next block blockAddr = (PB.next_pb_hi << 16) | PB.next_pb_lo; diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h index e79e81d570..7eaf19bb45 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h @@ -37,12 +37,14 @@ extern float ratioFactor; template -inline void ReadOutPBWii(u32 pbs_address, ParamBlockType& PB) +inline bool ReadOutPBWii(u32 pbs_address, ParamBlockType& PB) { u32 blockAddr = pbs_address; u32 pAddr = 0; const short *pSrc = (const short *)g_dspInitialize.pGetMemoryPointer(blockAddr); + if (!pSrc) + return false; pAddr = blockAddr; short *pDest = (short *)&PB; for (u32 p = 0; p < sizeof(ParamBlockType) / 2; p++) @@ -58,21 +60,25 @@ inline void ReadOutPBWii(u32 pbs_address, ParamBlockType& PB) } PB.mixer_control = Common::swap32(PB.mixer_control); + return true; } template -inline void WriteBackPBWii(u32 pb_address, ParamBlockType& PB) +inline bool WriteBackPBWii(u32 pb_address, ParamBlockType& PB) //void WriteBackPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num) { // write back and 'halfword'swap short* pSrc = (short*)&PB; short* pDest = (short*)g_dspInitialize.pGetMemoryPointer(pb_address); + if (!pDest) + return false; PB.mixer_control = Common::swap32(PB.mixer_control); for (size_t p = 0; p < sizeof(ParamBlockType) / 2; p++) { if (p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32 else pDest[p] = Common::swap16(pSrc[p]); } + return true; } template @@ -89,7 +95,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, // Read initial parameters // ------------ //constants - const u32 ratio = (u32)(((pb.src.ratio_hi << 16) + pb.src.ratio_lo) * ratioFactor); + 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;