From 85a3661afcb16e46bec2fffe56fda6f00249d572 Mon Sep 17 00:00:00 2001 From: luigi2us Date: Mon, 6 Jul 2009 12:20:01 +0000 Subject: [PATCH] Make AFCdecodebuffer static. Also remove some #include UCode_Zelda_ADPCM.h I forgot. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3691 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.cpp | 24 ++++++++++++----- .../Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h | 2 +- .../Src/UCodes/UCode_Zelda_Synth.cpp | 1 - .../Src/UCodes/UCode_Zelda_Voice.cpp | 26 +++++++++---------- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.cpp index 55c9024ce2..a05099f0bb 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.cpp @@ -21,7 +21,6 @@ #include "../Globals.h" #include "UCodes.h" #include "UCode_Zelda.h" -#include "UCode_Zelda_ADPCM.h" #include "../MailHandler.h" #include "../main.h" @@ -92,8 +91,19 @@ CUCode_Zelda::~CUCode_Zelda() void CUCode_Zelda::Update(int cycles) { - if (!m_rMailHandler.IsEmpty()) +// if (!m_rMailHandler.IsEmpty()) +// g_dspInitialize.pGenerateDSPInterrupt(); + if (m_bSyncCmdPending && (m_CurBuffer == m_NumBuffers) && (m_rMailHandler.IsEmpty())) + { + m_rMailHandler.PushMail(DSP_FRAME_END); g_dspInitialize.pGenerateDSPInterrupt(); + + soundStream->GetMixer()->SetHLEReady(true); + DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync"); + soundStream->Update(); //do it in this thread to avoid sync problems + + m_bSyncCmdPending = false; + } } void CUCode_Zelda::HandleMail(u32 _uMail) @@ -143,14 +153,14 @@ void CUCode_Zelda::HandleMail(u32 _uMail) if (m_CurBuffer == m_NumBuffers) { - m_rMailHandler.PushMail(DSP_FRAME_END); + //m_rMailHandler.PushMail(DSP_FRAME_END); //g_dspInitialize.pGenerateDSPInterrupt(); - soundStream->GetMixer()->SetHLEReady(true); - DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync"); - soundStream->Update(); //do it in this thread to avoid sync problems + // soundStream->GetMixer()->SetHLEReady(true); + // DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync"); + // soundStream->Update(); //do it in this thread to avoid sync problems - m_bSyncCmdPending = false; + //m_bSyncCmdPending = false; } } } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h index 4b5538a830..280d007707 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h @@ -214,7 +214,7 @@ private: void ExecuteList(); // AFC decoder - void AFCdecodebuffer(const s16 *coef, const char *input, signed short *out, short *histp, short *hist2p, int type); + static void AFCdecodebuffer(const s16 *coef, const char *input, signed short *out, short *histp, short *hist2p, int type); void ReadVoicePB(u32 _Addr, ZeldaVoicePB& PB); void WritebackVoicePB(u32 _Addr, ZeldaVoicePB& PB); diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Synth.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Synth.cpp index 9fe87f4fb9..c2e26eeadb 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Synth.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Synth.cpp @@ -18,7 +18,6 @@ #include "../Globals.h" #include "UCodes.h" #include "UCode_Zelda.h" -#include "UCode_Zelda_ADPCM.h" #include "../main.h" #include "Mixer.h" diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp index 0acb3c9cc4..7db6e7d3b3 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp @@ -18,7 +18,6 @@ #include "../Globals.h" #include "UCodes.h" #include "UCode_Zelda.h" -#include "UCode_Zelda_ADPCM.h" #include "../main.h" #include "Mixer.h" @@ -60,8 +59,8 @@ void CUCode_Zelda::RenderVoice_PCM16(ZeldaVoicePB &PB, s32* _Buffer, int _Size) u32 _ratio = (((PB.RatioInt * 80) + PB.CurSampleFrac) << 4) & 0xFFFF0000; u64 ratio = (u64)(((_ratio / 80) << 16) * ratioFactor); - u32 pos[2] = {0, 0}; - int i = 0; + u32 inpos[2] = {0, 0}; + int outpos = 0; if (PB.KeyOff != 0) return; @@ -90,7 +89,7 @@ _lRestart: PB.RestartPos = PB.LoopStartPos; PB.RemLength = PB.Length - PB.RestartPos; PB.CurAddr = PB.StartAddr + (PB.RestartPos << 1); - pos[1] = 0; pos[0] = 0; + inpos[1] = 0; inpos[0] = 0; } } @@ -100,29 +99,29 @@ _lRestart: else source = (s16*)(g_dspInitialize.pGetARAMPointer() + PB.CurAddr); - for (; i < _Size;) + for (; outpos < _Size;) { - s16 sample = Common::swap16(source[pos[1]]); + s16 sample = Common::swap16(source[inpos[1]]); - _Buffer[i++] = (s32)sample; + _Buffer[outpos++] = (s32)sample; - (*(u64*)&pos) += ratio; - if ((pos[1] + ((PB.CurAddr - PB.StartAddr) >> 1)) >= PB.Length) + (*(u64*)&inpos) += ratio; + if ((inpos[1] + ((PB.CurAddr - PB.StartAddr) >> 1)) >= PB.Length) { PB.ReachedEnd = 1; goto _lRestart; } } - if (PB.RemLength < pos[1]) + if (PB.RemLength < inpos[1]) { PB.RemLength = 0; PB.ReachedEnd = 1; } else - PB.RemLength -= pos[1]; + PB.RemLength -= inpos[1]; - PB.CurAddr += pos[1] << 1; + PB.CurAddr += inpos[1] << 1; // There should be a position fraction as well. } @@ -272,7 +271,7 @@ restart: // end of block (Zelda 03b2) } - +//u32 last_remlength = 0; // Researching what's actually inside the mysterious 0x21 case void CUCode_Zelda::RenderVoice_Raw(ZeldaVoicePB &PB, s32* _Buffer, int _Size) { @@ -414,6 +413,7 @@ void CUCode_Zelda::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _Righ case 0x0010: // PCM16 - normal PCM 16-bit audio. RenderVoice_PCM16(PB, m_TempBuffer, _Size); + //last_remlength = PB.RemLength; break;