From 4fbf138ed2a402d1181ccdb661f1ae0c5048720a Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Fri, 30 Oct 2009 07:10:46 +0000 Subject: [PATCH] The beginning of another approach on Zelda HLE UCode: PB debugging and comparison git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4481 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h | 4 ++-- .../Src/UCodes/UCode_Zelda_Voice.cpp | 22 +++++++++++++++++++ docs/DSP/DSP_UC_Zelda.txt | 15 ++++++++----- 3 files changed, 33 insertions(+), 8 deletions(-) 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 038daa94c5..d72c2926ff 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.h @@ -108,8 +108,8 @@ union ZeldaVoicePB u32 StartAddr; // 0x8C | sound start address u32 UnkAddr; // 0x8E | ??? u16 Padding[0x10]; // 0x90 | padding - u16 Padding2[0x8]; // 0xa0 | FIR filter coefs of some sort - u16 FilterEnable; // 0xa8 | FilterBufferInPlace enable. + u16 Padding2[0x8]; // 0xa0 | FIR filter coefs of some sort (0xa4 controls the appearance of 0xa5-0xa7 and is almost always 0x7FFF) + u16 FilterEnable; // 0xa8 | FilterBufferInPlace enable u16 Padding3[0x7]; // 0xa9 | padding u16 Padding4[0x10]; // 0xb0 | padding }; 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 ea9eae6f30..f9d8143db5 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 @@ -22,6 +22,8 @@ #include "../main.h" #include "Mixer.h" +#include + void CUCode_Zelda::ReadVoicePB(u32 _Addr, ZeldaVoicePB& PB) { u16 *memory = (u16*)g_dspInitialize.pGetMemoryPointer(_Addr); @@ -220,9 +222,28 @@ clear_buffer: PB.CurAddr += rem_samples; } +template +void PrintObject(const T &Obj) +{ + char byte[2] = {0}; + std::stringstream ss; + u8 *o = (u8 *)&Obj; + for(int i = 0; i < sizeof(T); i++) { + if(i > 0 && i % 2 == 0) + ss << " "; + + sprintf(byte, "%02X", Common::swap16(o[i])); + ss << byte; + } + + DEBUG_LOG(DSPHLE, "AFC PB: %s", ss.str().c_str()); +} void CUCode_Zelda::RenderVoice_AFC(ZeldaVoicePB &PB, s16 *_Buffer, int _Size) { + // TODO: Compare mono, stereo and surround samples + PrintObject(PB); + int _RealSize = SizeForResampling(PB, _Size, PB.RatioInt); // initialize "decoder" if the sample is played the first time @@ -340,6 +361,7 @@ restart: PB.CurAddr = prev_addr; PB.NeedsReset = 0; + // PB.CurBlock = 0x10 - (PB.LoopStartPos & 0xf); // write back // NumberOfSamples = (NumberOfSamples << 4) | frac; // missing fraction diff --git a/docs/DSP/DSP_UC_Zelda.txt b/docs/DSP/DSP_UC_Zelda.txt index d51b072722..7cd14f2784 100644 --- a/docs/DSP/DSP_UC_Zelda.txt +++ b/docs/DSP/DSP_UC_Zelda.txt @@ -2529,12 +2529,15 @@ void 06f9_Unk_PrepareSampleDecode() void EarlyOutFrom_073d_DECODE_0x05_0x09() { //070e 02bf 06f9 call 0x06f9 06f9_Unk_PrepareSampleDecode() - 0710 8100 clr $ACC0 - 0711 2632 lrs $AC0.M, @0x0032 - 0712 5c00 sub $ACC0, $ACC1 - 0713 2e32 srs @0x0032, $AC0.M - 0714 0092 00ff lri $CR, #0x00ff - 0716 02df ret + // 0710 8100 clr $ACC0 + // 0711 2632 lrs $AC0.M, @0x0032 + // 0712 5c00 sub $ACC0, $ACC1 + // 0713 2e32 srs @0x0032, $AC0.M + + *0x0432 -= _numberOfSamples // PB.CurBlock + + // 0714 0092 00ff lri $CR, #0x00ff + // 0716 02df ret } // Here, CR is 0x04 and thus these are not hw regs.