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 193a53300f..17ffa251f8 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 @@ -113,16 +113,54 @@ void CUCode_Zelda::RenderSynth_Constant(ZeldaVoicePB &PB, s32* _Buffer, int _Siz { // TODO: Header, footer for (int i = 0; i < _Size; i++) - _Buffer[i++] = (s32)PB.RatioInt; + _Buffer[i] = (s32)PB.RatioInt; } void CUCode_Zelda::RenderSynth_WaveTable(ZeldaVoicePB &PB, s32* _Buffer, int _Size) { - WARN_LOG(DSPHLE, "Not synthesizing un-REd format 0x%04x", PB.Format); - // TODO: Header, footer - //for (int i = 0; i < _Size; i++) - //_Buffer[i++] = (s32)PB.RatioInt; + u16 address; + switch(PB.Format) { + default: + case 0x0004: + address = 0x140; + break; + + case 0x0007: + address = 0x100; + break; + + case 0x000b: + address = 0x180; + break; + + case 0x000c: + address = 0x1c0; + break; + } + + // TODO: What about the 0x003f wrap register? + + //WARN_LOG(DSPHLE, "Not synthesizing un-REd format 0x%04x", PB.Format); + u64 ACC0 = PB.CurSampleFrac << 6; + + ACC0 &= 0x3f0000; + + address += (ACC0 >> 16); + ACC0 &= 0xffff; + + for(int i = 0; i < _Size; i++) + { + _Buffer[i] = m_MiscTable[address]; + + ACC0 += PB.RatioInt << 5; + address += ((ACC0 >> 16) & 0x003f) - 1; + + ACC0 &= 0xffff; + } + + ACC0 = address << 16; + PB.CurSampleFrac = (ACC0 >> 6) & 0xffff; } diff --git a/docs/DSP/DSP_UC_Zelda.txt b/docs/DSP/DSP_UC_Zelda.txt index 4f536810f8..6fda79c918 100644 --- a/docs/DSP/DSP_UC_Zelda.txt +++ b/docs/DSP/DSP_UC_Zelda.txt @@ -3165,6 +3165,8 @@ void 08ed_Decoder0x1_SawWave(ACC0, AR0, AX0.L) { void 08f3_Decoder0x4_0xb_0xc_WaveTable(ACC0, AR0, AX0.L) { + // See 091c + 08f3 0082 0180 lri $AR2, #0x0180 // Entrance 1, 0x0b 08f5 029f 08fd jmp 0x08fd @@ -3172,6 +3174,7 @@ void 08f3_Decoder0x4_0xb_0xc_WaveTable(ACC0, AR0, AX0.L) { 08f9 029f 08fd jmp 0x08fd 08fb 0082 0140 lri $AR2, #0x0140 // Entrance 3, 0x04 + 08fd 008a 003f lri $WR2, #0x003f 08ff 0086 0000 lri $IX2, #0x0000 0901 1406 lsl $ACC0, #6 @@ -3235,23 +3238,31 @@ void 091c_Decoder0x7_WaveTable(ACC0, AR0, AX0.L) { AC0.M &= 0x003f; IX2 = AC0.M; - AR2 += 0x0100 + IX2; + AR2 = 0x0100 + IX2; AC0.M = 0; // 092e 1150 0934 bloopi #0x50, 0x0934 for(int i = 0; i < 0x50; i++) { - 0930 4c4a add'l $ACC0, $ACC1 : $AX1.L, @$AR2 - 0931 3606 andr'dr $AC0.M, $AX1.H : $AR2 + // 0930 4c4a add'l $ACC0, $ACC1 : $AX1.L, @$AR2 + + ACC0 += ACC1; + AX1.L = *AR2; + + // 0931 3606 andr'dr $AC0.M, $AX1.H : $AR2 + AC0.M &= 0x003f; + AR2--; // 0932 1cde mrr $IX2, $AC0.M IX2 = AC0.M; - 0933 340e andr'nr $AC0.M, $AX0.H : $AR2 + // 0933 340e andr'nr $AC0.M, $AX0.H : $AR2 + AC0.M = 0; + AR2 += IX2; // 0934 1b19 srri @$AR0, $AX1.L - *AR0++ = AX1.L + *AR0++ = AX1.L; }