From 68eeef28e42a71f5401e5cb855b16a8cd936ec59 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 Dec 2024 17:55:58 -0500 Subject: [PATCH] YMZ280B: fix sample offset moving loop issue #2213 --- src/engine/platform/ymz280b.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/platform/ymz280b.cpp b/src/engine/platform/ymz280b.cpp index b95e8a9d3..522432d43 100644 --- a/src/engine/platform/ymz280b.cpp +++ b/src/engine/platform/ymz280b.cpp @@ -155,15 +155,6 @@ void DivPlatformYMZ280B::tick(bool sysTick) { start=sampleOff[chan[i].sample]; end=MIN(start+s->getCurBufLen(),getSampleMemCapacity()-1); } - if (chan[i].audPos>0) { - switch (s->depth) { - case DIV_SAMPLE_DEPTH_YMZ_ADPCM: start+=chan[i].audPos/2; break; - case DIV_SAMPLE_DEPTH_8BIT: start+=chan[i].audPos; break; - case DIV_SAMPLE_DEPTH_16BIT: start+=chan[i].audPos*2; break; - default: break; - } - start=MIN(start,end); - } if (s->isLoopable()) { switch (s->depth) { case DIV_SAMPLE_DEPTH_YMZ_ADPCM: loopStart=start+s->loopStart/2; loopEnd=start+s->loopEnd/2; break; @@ -174,6 +165,15 @@ void DivPlatformYMZ280B::tick(bool sysTick) { loopEnd=MIN(loopEnd,end); loopStart=MIN(loopStart,loopEnd); } + if (chan[i].audPos>0) { + switch (s->depth) { + case DIV_SAMPLE_DEPTH_YMZ_ADPCM: start+=chan[i].audPos/2; break; + case DIV_SAMPLE_DEPTH_8BIT: start+=chan[i].audPos; break; + case DIV_SAMPLE_DEPTH_16BIT: start+=chan[i].audPos*2; break; + default: break; + } + start=MIN(start,end); + } rWrite(0x01+i*4,ctrl&~0x80); // force keyoff first rWrite(0x20+i*4,(start>>16)&0xff); rWrite(0x21+i*4,(loopStart>>16)&0xff);