XM import: fix 16-bit sample loop

This commit is contained in:
tildearrow 2024-07-04 18:32:54 -05:00
parent 473defff35
commit 68597535fa

View file

@ -555,12 +555,6 @@ bool DivEngine::loadXM(unsigned char* file, size_t len) {
s->loopStart=reader.readI();
s->loopEnd=reader.readI()+s->loopStart;
if (s->loopStart>s->loopEnd) {
s->loopStart^=s->loopEnd;
s->loopEnd^=s->loopStart;
s->loopStart^=s->loopEnd;
}
sampleVol[i][j]=reader.readC();
signed char fine=reader.readC();
@ -582,6 +576,18 @@ bool DivEngine::loadXM(unsigned char* file, size_t len) {
break;
}
if (s->loopStart>s->loopEnd) {
s->loopStart^=s->loopEnd;
s->loopEnd^=s->loopStart;
s->loopStart^=s->loopEnd;
}
if (flags&16) {
s->loopStart>>=1;
s->loopEnd>>=1;
}
reader.readC(); // reserved
s->centerRate=8363.0*pow(2.0,((double)note+((double)fine/128.0))/12.0);