diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Debugger.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Debugger.cpp index 8f58dc3ea8..e311713cd7 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Debugger.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Debugger.cpp @@ -37,7 +37,13 @@ #include "../Logging/Console.h" // open and close console -// externals +// externals that are needed even in Release builds +bool gSSBM = true; +bool gSSBMremedy1 = true; +bool gSSBMremedy2 = true; +bool gSequenced = true; +bool gVolume = true; +bool gReset = false; extern std::vector sMailLog, sMailTime; @@ -73,13 +79,6 @@ CDebugger::CDebugger(wxWindow *parent, wxWindowID id, const wxString &title, //, gUpdFreq(5) // loaded from file , gPreset(0) , giShowAll(-1) - - , gSSBM(true) - , gSSBMremedy1(true) - , gSSBMremedy2(true) - , gSequenced(true) - , gVolume(true) - , gReset(false) { CreateGUIControls(); diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/Logging/Console.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/Logging/Console.cpp index a506fc66fd..057e53d4b1 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/Logging/Console.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/Logging/Console.cpp @@ -94,7 +94,7 @@ void startConsoleWin(int width, int height, char* fname) // File printf function int aprintf(int a, char *fmt, ...) { -#if defined(DEBUG_HLE) && defined(_WIN32) +#if defined(DEBUG_HLE) && defined(_WIN32) && (defined(_DEBUG) || defined(DEBUGFAST)) if(m_frame->gSaveFile) { char s[5000]; // WARNING: mind this value diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/Logging/Logging.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/Logging/Logging.cpp index bd079d4ad7..53de093da0 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/Logging/Logging.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/Logging/Logging.cpp @@ -56,6 +56,7 @@ extern CDebugger* m_frame; std::vector gsamplePos(NUMBER_OF_PBS); // main + std::vector running(NUMBER_OF_PBS); std::vector gsrc_type(NUMBER_OF_PBS); std::vector gis_stream(NUMBER_OF_PBS); @@ -72,6 +73,7 @@ extern CDebugger* m_frame; std::vector gvolume_right(NUMBER_OF_PBS); std::vector gmix_unknown2(NUMBER_OF_PBS); std::vector gmixer_control(NUMBER_OF_PBS); + std::vector gmixer_control_wii(NUMBER_OF_PBS); std::vector gmixer_vol1(NUMBER_OF_PBS); std::vector gmixer_vol2(NUMBER_OF_PBS); @@ -152,15 +154,15 @@ std::string writeTitle(int a) if(a == 0) { b = " adpcm adpcm_loop\n"; - b = b + " Nr pos / end lpos | voll volr | isl iss | pre yn1 yn2 pre yn1 yn2 | frac ratio[hi lo]\n"; + b = b + " Nr pos / end lpos | voll volr | isl iss | pre yn1 yn2 pre yn1 yn2 | frac ratio[hi lo]\n"; } else if(a == 1) { - b = " Nr pos / end lpos | voll volr | src form coef | 1 2 3 4 5\n"; + b = " Nr pos / end lpos | voll volr | src form coef | 1 2 3 4 5\n"; } else if(a == 2) { - b = " Nr pos / end lpos | voll volr | isl iss | e-l e-s\n"; + b = " Nr pos / end lpos | voll volr | isl iss | e-l e-s\n"; } else if(a == 3) { @@ -184,20 +186,20 @@ std::string writeMessage(int a, int i) // --------------------------------------------------------------------------------------- /* PRESET 0 - " Nr pos / end lpos | voll volr | isl iss | pre yn1 yn2 pre yn1 yn2 | frac ratio[hi lo]\n"; - "---------------|00 12341234/12341234 12341234 | 00000 00000 | 0 0 | 000 00000 00000 000 00000 00000 | 00000 00000[0 00000] + " Nr pos / end lpos | voll volr | isl iss | pre yn1 yn2 pre yn1 yn2 | frac ratio[hi lo]\n"; + "---------------|00 12341234/1234123412 12341234 | 00000 00000 | 0 0 | 000 00000 00000 000 00000 00000 | 00000 00000[0 00000] PRESET 1 (updates) - " Nr pos / end lpos | voll volr | src form coef | 1 2 3 4 5\n"; + " Nr pos / end lpos | voll volr | src form coef | 1 2 3 4 5\n"; "---------------|00 12341234/12341234 12341234 | 00000 00000 | 0 0 0 | 0 0 0 0 0 PRESET 2 - " Nr pos / end lpos | voll volr | isl iss | e-l e-s\n"; + " Nr pos / end lpos | voll volr | isl iss | e-l e-s\n"; "---------------|00 12341234/12341234 12341234 | 00000 00000 | 0 0 | 000000 000000 */ if(a == 0) { - sprintf(buf,"%c%02i %08i/%08i %08i | %05i %05i | %i %i | %03i %05i %05i %03i %05i %05i | %05i %05i[%i %05i]", + sprintf(buf,"%c%02i %08x/%08x %08x | %05u %05u | %i %i | %03i %05i %05i %03i %05i %05i | %05i %05i[%i %05i]", 223, i, gsamplePos[i], gsampleEnd[i], gloopPos[i], gvolume_left[i], gvolume_right[i], glooping[i], gis_stream[i], @@ -207,7 +209,7 @@ std::string writeMessage(int a, int i) } else if(a == 1) { - sprintf(buf,"%c%02i %08i/%08i %08i | %05i %05i | %i %i %i | %i %i %i %i %i %08x %08x", + sprintf(buf,"%c%02i %08x/%08x %08x | %05u %05u | %i %i %i | %i %i %i %i %i %08x %08x", 223, i, gsamplePos[i], gsampleEnd[i], gloopPos[i], gvolume_left[i], gvolume_right[i], gsrc_type[i], gaudioFormat[i], gcoef[i], @@ -284,23 +286,21 @@ template void CollectPB(bool Wii, int i, ParamBlockType &P //void CollectPB(bool Wii, int i, AXParamBlockWii * PBw, AXParamBlock * PBs) { // AXPB base + gsrc_type[i] = PBs[i].src_type; gcoef[i] = PBs[i].coef_select; + if(Wii) gmixer_control_wii[i] = PBs[i].mixer_control; + else gmixer_control[i] = PBs[i].mixer_control; - gloopPos[i] = (PBs[i].audio_addr.loop_addr_hi << 16) | PBs[i].audio_addr.loop_addr_lo; - gsampleEnd[i] = (PBs[i].audio_addr.end_addr_hi << 16) | PBs[i].audio_addr.end_addr_lo; - gsamplePos[i] = (PBs[i].audio_addr.cur_addr_hi << 16) | PBs[i].audio_addr.cur_addr_lo; + running[i] = PBs[i].running; + gis_stream[i] = PBs[i].is_stream; // mixer (some differences) gvolume_left[i] = PBs[i].mixer.volume_left; gvolume_right[i] = PBs[i].mixer.volume_right; - if(i == 94 && (PBs[i].mixer.unknown > 0 || PBs[i].mixer.unknown2 > 0)) - DebugLog("(%i) | LOG Read Left: %04x | Right: %04x", i, PBs[i].mixer.unknown, PBs[i].mixer.unknown2); - gmix_unknown[i] = PBs[i].mixer.unknown; gmix_unknown2[i] = PBs[i].mixer.unknown2; - gmixer_control[i] = PBs[i].mixer_control; gcur_volume[i] = PBs[i].vol_env.cur_volume; gcur_volume_delta[i] = PBs[i].vol_env.cur_volume_delta; @@ -320,7 +320,14 @@ template void CollectPB(bool Wii, int i, ParamBlockType &P gmixer_d6[i] = PBs[i].mixer.unknown4[3]; gmixer_d7[i] = PBs[i].mixer.unknown4[5]; - // adpcm_loop_info (same in GC and Wii) + // PBAudioAddr audio_addr + glooping[i] = PBs[i].audio_addr.looping; + gaudioFormat[i] = PBs[i].audio_addr.sample_format; + gloopPos[i] = (PBs[i].audio_addr.loop_addr_hi << 16) | PBs[i].audio_addr.loop_addr_lo; + gsampleEnd[i] = (PBs[i].audio_addr.end_addr_hi << 16) | PBs[i].audio_addr.end_addr_lo; + gsamplePos[i] = (PBs[i].audio_addr.cur_addr_hi << 16) | PBs[i].audio_addr.cur_addr_lo; + + // PBADPCMLoopInfo adpcm_loop_info (same in GC and Wii) gadloop1[i] = PBs[i].adpcm.pred_scale; gadloop2[i] = PBs[i].adpcm.yn1; gadloop3[i] = PBs[i].adpcm.yn2; @@ -338,12 +345,7 @@ template void CollectPB(bool Wii, int i, ParamBlockType &P gupdates_addr[i] = (PBs[i].updates.data_hi << 16) | PBs[i].updates.data_lo; gupdates_data[i] = Memory_Read_U32(gupdates_addr[i]); - - gaudioFormat[i] = PBs[i].audio_addr.sample_format; - glooping[i] = PBs[i].audio_addr.looping; - gsrc_type[i] = PBs[i].src_type; - gis_stream[i] = PBs[i].is_stream; - + // PBSampleRateConverter src gratio[i] = (u32)(((PBs[i].src.ratio_hi << 16) + PBs[i].src.ratio_lo) * ratioFactor); @@ -413,15 +415,6 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii) else numberOfPBs = numberOfPBsGC; - - /* - DebugLog("After Read LOG: Left: %04x | Right: %04x || Left: %04x | Right: %04x ", - PBs[94].mixer.unknown, PBs[94].mixer.unknown2, - PBw[94].mixer.unknown, PBw[94].mixer.unknown2 - ); - */ - - // Select blocks to show bool Conditions; @@ -433,7 +426,11 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii) //if (PBs[i].running) int irun = 0; for (int i = 0; i < numberOfPBs; i++) - { + { + if(Wii) + running[i] = PBs[i].running; + else + running[i] = PBs[i].running; // -------------------------------------------------------------------- // Write a line for the text log if nothing is playing @@ -482,7 +479,7 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii) // write running char cbuf[10]; - sprintf(cbuf, "%i", PBs[i].running); + sprintf(cbuf, "%i", running[i]); sfbuff = sfbuff + cbuf; sfbuff = sfbuff + writeMessage(ii, i); @@ -510,7 +507,7 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii) { // ======================================================================================= - // Move all items back. Vector1 is a vector1[NUMBER_OF_PBS][100] vector. + // Save the running history for each block. Vector1 is a vector1[NUMBER_OF_PBS][100] vector. // -------------- /* Move all items back like this: @@ -529,7 +526,16 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii) // Save the latest value for (int i = 0; i < numberOfPBs; i++) { - vector1.at(i).at(vectorLength-1) = PBs[i].running ? true : false; + if(Wii) + { + //DebugLog("Writing %i to %i | m_addressPBs: %08x", running[i], i, m_addressPBs); + vector1.at(i).at(vectorLength-1) = running[i] ? true : false; + } + else + { + //DebugLog("Writing %i to %i", running[i], i); + vector1.at(i).at(vectorLength-1) = running[i] ? true : false; + } } // ============== @@ -554,7 +560,7 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii) // Save the latest value for (int i = 0; i < numberOfPBs; i++) { - vector2.at(i).at(vectorLength2-1) = PBs[i].running; + vector2.at(i).at(vectorLength2-1) = running[i]; } // ============== diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp index 419582415e..168111a495 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp @@ -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; } 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 017e689534..f758046f27 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp @@ -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]; diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_ADPCM.h b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_ADPCM.h index c612dec541..ebaf3285d9 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_ADPCM.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_ADPCM.h @@ -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) 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 92a2455c60..1c53c058c4 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 @@ -21,6 +21,12 @@ #include "UCode_AX_ADPCM.h" #include "../main.h" +// ---------------------------------------------------- +// Externals +// ----------- +extern bool gSequenced; +extern bool gVolume; + template 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;