Skip to content

Commit

Permalink
YMZ280B: fix sample offset moving loop
Browse files Browse the repository at this point in the history
issue #2213
  • Loading branch information
tildearrow committed Dec 29, 2024
1 parent 5ffd47e commit 68eeef2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/engine/platform/ymz280b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 68eeef2

Please sign in to comment.