Zelda UCode: Synth fixes and some RE. (Why does it still sound awful?)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3707 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
XTra.KrazzY
2009-07-08 01:08:43 +00:00
parent 47ea4936b3
commit 25b77d4654
4 changed files with 69 additions and 29 deletions

View File

@ -221,7 +221,8 @@ private:
// Voice formats
void RenderSynth_Constant(ZeldaVoicePB &PB, s32* _Buffer, int _Size);
void RenderSynth_Waveform(ZeldaVoicePB &PB, s32* _Buffer, int _Size);
void RenderSynth_RectWave(ZeldaVoicePB &PB, s32* _Buffer, int _Size);
void RenderSynth_SawWave(ZeldaVoicePB &PB, s32* _Buffer, int _Size);
void RenderVoice_PCM16(ZeldaVoicePB& PB, s32* _Buffer, int _Size);
void RenderVoice_AFC(ZeldaVoicePB& PB, s32* _Buffer, int _Size);
void RenderVoice_Raw(ZeldaVoicePB& PB, s32* _Buffer, int _Size);

View File

@ -22,14 +22,14 @@
#include "../main.h"
#include "Mixer.h"
void CUCode_Zelda::RenderSynth_Waveform(ZeldaVoicePB &PB, s32* _Buffer, int _Size)
void CUCode_Zelda::RenderSynth_RectWave(ZeldaVoicePB &PB, s32* _Buffer, int _Size)
{
float ratioFactor = 32000.0f / (float)soundStream->GetMixer()->GetSampleRate();
u32 _ratio = (PB.RatioInt << 16);
s64 ratio = (_ratio * ratioFactor) * 16;
s64 TrueSamplePosition = (s64)(PB.Length - PB.RemLength) << 16;
TrueSamplePosition += PB.CurSampleFrac;
s64 TrueSamplePosition = PB.CurSampleFrac;
// PB.Format == 0x3 -> Rectangular Wave, 0x0 -> Square Wave
int mask = PB.Format ? 3 : 1, shift = PB.Format ? 2 : 1;
u32 pos[2] = {0, 0};
@ -93,6 +93,19 @@ _lRestart:
PB.CurSampleFrac = TrueSamplePosition & 0xFFFF;
}
void CUCode_Zelda::RenderSynth_SawWave(ZeldaVoicePB &PB, s32* _Buffer, int _Size)
{
s32 ratio = PB.RatioInt * 2;
s64 pos = PB.CurSampleFrac;
for(int i = 0; i < 0x50; i++) {
pos += ratio;
_Buffer[i] = pos & 0xFFFF;
}
PB.CurSampleFrac = pos & 0xFFFF;
}
void CUCode_Zelda::RenderSynth_Constant(ZeldaVoicePB &PB, s32* _Buffer, int _Size)
{

View File

@ -386,9 +386,13 @@ void CUCode_Zelda::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _Righ
{
// Synthesized sounds
case 0x0000: // Example: Magic meter filling up in ZWW
case 0x0003:
RenderSynth_RectWave(PB, m_TempBuffer, _Size);
break;
case 0x0001: // Example: "Denied" sound when trying to pull out a sword
// indoors in ZWW
RenderSynth_Waveform(PB, m_TempBuffer, _Size);
// indoors in ZWW
RenderSynth_SawWave(PB, m_TempBuffer, _Size);
break;
case 0x0006: