Mercurial > hg > dmlib
changeset 272:64876c3cbcf3
XM sample offset effect '9xx' stops note playing if offset is > sample
length (or loop endpoint if looped.)
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 10 Oct 2012 20:38:56 +0300 |
parents | 6d9a3577741b |
children | 3b5493fac928 |
files | jssplr.c |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/jssplr.c Wed Oct 10 20:27:17 2012 +0300 +++ b/jssplr.c Wed Oct 10 20:38:56 2012 +0300 @@ -1063,10 +1063,20 @@ case '9': // 9xx = Set Sample Offset : IMPL.VERIFIED if (param != 0) chn->lastSampleOffsetParam = param; - if (chn->newDataFlags & cdfNewPitch) + if (chn->newDataFlags & cdfNewPitch && chn->instrument != NULL) { - chn->position = chn->lastSampleOffsetParam * 0x100; - JMPSETNDFLAGS(cdfNewPos); + int pos = chn->lastSampleOffsetParam * 0x100, + end = (chn->instrument->flags & jsfLooped) ? + chn->instrument->loopE : chn->instrument->size; + if (pos <= end) + { + chn->position = pos; + JMPSETNDFLAGS(cdfNewPos); + } + else + { + JMPSETNDFLAGS(cdfStop); + } } break;