Merge pull request #12693 from Tilka/zelda3

DSPHLE/Zelda: simplify AFC decoding
This commit is contained in:
Admiral H. Curtiss 2024-04-13 03:57:13 +02:00 committed by GitHub
commit 1bfeeb8a63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 10 deletions

View File

@ -1735,6 +1735,7 @@ void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count)
if (vpb->samples_source_type == VPB::SRC_AFC_HQ_FROM_ARAM) if (vpb->samples_source_type == VPB::SRC_AFC_HQ_FROM_ARAM)
{ {
// 4-bit samples
for (size_t i = 0; i < 16; i += 2) for (size_t i = 0; i < 16; i += 2)
{ {
nibbles[i + 0] = *src >> 4; nibbles[i + 0] = *src >> 4;
@ -1742,14 +1743,11 @@ void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count)
src++; src++;
} }
for (auto& nibble : nibbles) for (auto& nibble : nibbles)
{ nibble = s16(nibble << 12) >> 1;
if (nibble >= 8)
nibble -= 16;
nibble <<= 11;
}
} }
else else
{ {
// 2-bit samples
for (size_t i = 0; i < 16; i += 4) for (size_t i = 0; i < 16; i += 4)
{ {
nibbles[i + 0] = (*src >> 6) & 3; nibbles[i + 0] = (*src >> 6) & 3;
@ -1759,11 +1757,7 @@ void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count)
src++; src++;
} }
for (auto& nibble : nibbles) for (auto& nibble : nibbles)
{ nibble = s16(nibble << 14) >> 1;
if (nibble >= 2)
nibble -= 4;
nibble <<= 13;
}
} }
s32 yn1 = *vpb->AFCYN1(), yn2 = *vpb->AFCYN2(); s32 yn1 = *vpb->AFCYN1(), yn2 = *vpb->AFCYN2();