DS Audio: Fix ADPCM looping
Vicki Pfau vi@endrift.com
Wed, 08 Mar 2017 23:03:15 -0800
1 files changed,
7 insertions(+),
7 deletions(-)
jump to
M
src/ds/audio.c
→
src/ds/audio.c
@@ -242,7 +242,7 @@ case 2:
_updateAdpcm(ch, (cpu->memory.load8(cpu, ch->offset + ch->source, NULL) >> ch->adpcmOffset) & 0xF); ch->offset += ch->adpcmOffset >> 2; ch->adpcmOffset ^= 4; - if (ch->offset == ch->loopPoint) { + if (ch->offset == ch->loopPoint && !ch->adpcmOffset) { ch->adpcmStartSample = ch->adpcmSample; ch->adpcmStartIndex = ch->adpcmIndex; }@@ -251,18 +251,18 @@ }
_updateMixer(ch->p); switch (ch->repeat) { case 1: - if (ch->offset >= ch->length) { + if (ch->offset >= ch->length + ch->loopPoint) { ch->offset = ch->loopPoint; + if (ch->format == 2) { + ch->adpcmSample = ch->adpcmStartSample; + ch->adpcmIndex = ch->adpcmStartIndex; + } } break; case 2: - if (ch->offset >= ch->length) { + if (ch->offset >= ch->length + ch->loopPoint) { ch->enable = false; ch->p->p->memory.io7[(DS7_REG_SOUND0CNT_HI + (ch->index << 4)) >> 1] &= 0x7FFF; - if (ch->format == 2) { - ch->adpcmSample = ch->adpcmStartSample; - ch->adpcmIndex = ch->adpcmStartIndex; - } } break; }