mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
DSPHLE: zelda ucode: add some comments, a little crash safety hack
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3620 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
8f4e56c61c
commit
fc63424bce
@ -145,8 +145,7 @@ void CUCode_Zelda::MixAddVoice_AFC(ZeldaVoicePB &PB, s32* _Buffer, int _Size)
|
|||||||
PB.YN2 = 0x00; // history1
|
PB.YN2 = 0x00; // history1
|
||||||
PB.YN1 = 0x00; // history2
|
PB.YN1 = 0x00; // history2
|
||||||
|
|
||||||
// samplerate? length? num of samples? i dunno...
|
// Length in samples.
|
||||||
// Likely length...
|
|
||||||
PB.RemLength = PB.Length;
|
PB.RemLength = PB.Length;
|
||||||
|
|
||||||
// Copy ARAM addr from r to rw area.
|
// Copy ARAM addr from r to rw area.
|
||||||
@ -164,8 +163,11 @@ void CUCode_Zelda::MixAddVoice_AFC(ZeldaVoicePB &PB, s32* _Buffer, int _Size)
|
|||||||
u32 sampleCount = 0;
|
u32 sampleCount = 0;
|
||||||
|
|
||||||
u8 *source;
|
u8 *source;
|
||||||
if (m_CRC == 0xD643001F)
|
u32 ram_mask = 1024 * 1024 * 16 - 1;
|
||||||
|
if (m_CRC == 0xD643001F) {
|
||||||
source = g_dspInitialize.pGetMemoryPointer(m_DMABaseAddr);
|
source = g_dspInitialize.pGetMemoryPointer(m_DMABaseAddr);
|
||||||
|
ram_mask = 1024 * 1024 * 64 - 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
source = g_dspInitialize.pGetARAMPointer();
|
source = g_dspInitialize.pGetARAMPointer();
|
||||||
|
|
||||||
@ -192,6 +194,7 @@ restart:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This needs adjustment. It's not right for AFC, was just copied from PCM16.
|
// This needs adjustment. It's not right for AFC, was just copied from PCM16.
|
||||||
|
// We should also probably reinitialize YN1 and YN2 with something - but with what?
|
||||||
PB.RestartPos = PB.LoopStartPos;
|
PB.RestartPos = PB.LoopStartPos;
|
||||||
PB.RemLength = PB.Length - PB.RestartPos;
|
PB.RemLength = PB.Length - PB.RestartPos;
|
||||||
PB.CurAddr = PB.StartAddr + (PB.RestartPos << 1);
|
PB.CurAddr = PB.StartAddr + (PB.RestartPos << 1);
|
||||||
@ -206,7 +209,7 @@ restart:
|
|||||||
u32 prev_addr = PB.CurAddr;
|
u32 prev_addr = PB.CurAddr;
|
||||||
|
|
||||||
// Prefill the decode buffer.
|
// Prefill the decode buffer.
|
||||||
AFCdecodebuffer(m_AFCCoefTable, (char*)(source + PB.CurAddr), outbuf, (short*)&PB.YN2, (short*)&PB.YN1, 9);
|
AFCdecodebuffer(m_AFCCoefTable, (char*)(source + (PB.CurAddr & ram_mask)), outbuf, (short*)&PB.YN2, (short*)&PB.YN1, 9);
|
||||||
PB.CurAddr += 9;
|
PB.CurAddr += 9;
|
||||||
|
|
||||||
s64 TrueSamplePosition = (s64)(PB.Length - PB.RemLength) << 32;
|
s64 TrueSamplePosition = (s64)(PB.Length - PB.RemLength) << 32;
|
||||||
@ -238,7 +241,7 @@ restart:
|
|||||||
prev_yn2 = PB.YN2;
|
prev_yn2 = PB.YN2;
|
||||||
prev_addr = PB.CurAddr;
|
prev_addr = PB.CurAddr;
|
||||||
|
|
||||||
AFCdecodebuffer(m_AFCCoefTable, (char*)(source + PB.CurAddr), outbuf, (short*)&PB.YN2, (short*)&PB.YN1, 9);
|
AFCdecodebuffer(m_AFCCoefTable, (char*)(source + (PB.CurAddr & ram_mask)), outbuf, (short*)&PB.YN2, (short*)&PB.YN1, 9);
|
||||||
PB.CurAddr += 9;
|
PB.CurAddr += 9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,24 +281,26 @@ void CUCode_Zelda::MixAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _RightBu
|
|||||||
{
|
{
|
||||||
switch (PB.Format)
|
switch (PB.Format)
|
||||||
{
|
{
|
||||||
case 0x0000: // Silences sound and stops all looping sounds
|
// AFC formats
|
||||||
for (int i = 0; i < _Size; i++)
|
case 0x0005: // AFC with extra low bitrate (32:5 compression). Not yet seen.
|
||||||
_LeftBuffer[i] = _RightBuffer[i] = 0;
|
WARN_LOG(DSPHLE, "5 byte AFC - does it work?");
|
||||||
return;
|
case 0x0009: // AFC with normal bitrate (32:9 compression).
|
||||||
|
|
||||||
case 0x0005: // AFC / unknown
|
|
||||||
case 0x0009: // AFC / ADPCM
|
|
||||||
MixAddVoice_AFC(PB, m_TempBuffer, _Size);
|
MixAddVoice_AFC(PB, m_TempBuffer, _Size);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0010: // PCM16
|
case 0x0010: // PCM16 - normal PCM 16-bit audio.
|
||||||
MixAddVoice_PCM16(PB, m_TempBuffer, _Size);
|
MixAddVoice_PCM16(PB, m_TempBuffer, _Size);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Cases we're missing: 0x0008, 0x0020, 0x0021
|
// These are "synth" formats - square wave, saw wave etc.
|
||||||
case 0x0008:
|
case 0x0000:
|
||||||
|
case 0x0001: // Used for "Denied" sound in Zelda
|
||||||
|
case 0x0002:
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 0x0008: // Likely PCM8 - normal PCM 8-bit audio. Used in Mario Kart DD.
|
||||||
case 0x0020:
|
case 0x0020:
|
||||||
case 0x0021:
|
case 0x0021: // Important for Zelda WW. Really need to implement - missing it causes hangs.
|
||||||
WARN_LOG(DSPHLE, "Unimplemented MixAddVoice format in zelda %04x", PB.Format);
|
WARN_LOG(DSPHLE, "Unimplemented MixAddVoice format in zelda %04x", PB.Format);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -305,6 +310,7 @@ void CUCode_Zelda::MixAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _RightBu
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Necessary for SMG, not for Zelda. Weird.
|
||||||
PB.NeedsReset = 0;
|
PB.NeedsReset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user