diff --git a/src/engine/fileOps/xm.cpp b/src/engine/fileOps/xm.cpp index f4474add5..45fb30c6d 100644 --- a/src/engine/fileOps/xm.cpp +++ b/src/engine/fileOps/xm.cpp @@ -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);