From 2eb678b190558cd57f8580a30a8ec5ec83e79acb Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sun, 28 Sep 2014 17:14:32 -0700 Subject: [PATCH] Fix for poorly converted STK->PTMOD modules. --- Frameworks/playptmod/playptmod/playptmod.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Frameworks/playptmod/playptmod/playptmod.c b/Frameworks/playptmod/playptmod/playptmod.c index 081c8e14a..79651309b 100644 --- a/Frameworks/playptmod/playptmod/playptmod.c +++ b/Frameworks/playptmod/playptmod/playptmod.c @@ -1126,6 +1126,20 @@ int playptmod_LoadMem(void *_p, const unsigned char *buf, unsigned long bufLengt p->source->samples[i].loopLength = bufGetWordBigEndian(fmodule) * 2; + // fix for poorly converted STK->PTMOD modules. + if (!mightBeSTK && ((s->loopStart + s->loopLength) > s->length)) + { + if (((s->loopStart >> 1) + s->loopLength) <= s->length) + { + s->loopStart >>= 1; + } + else + { + s->loopStart = 0; + s->loopLength = 2; + } + } + if (p->source->samples[i].loopLength < 2) p->source->samples[i].loopLength = 2; @@ -2250,7 +2264,7 @@ static void fxSampleOffset(player *p, mod_channel *ch) if (p->modTick == 0) { if (ch->param > 0) - ch->offsetTemp = (uint16_t)(ch->param) * 256; + ch->offsetTemp = (unsigned short)(ch->param) * 256; ch->offset += ch->offsetTemp; @@ -2264,7 +2278,7 @@ static void fxSampleOffset_FT2(player *p, mod_channel *ch) if (p->modTick == 0) { if (ch->param > 0) - ch->offset = (uint16_t)(ch->param) * 256; + ch->offset = (unsigned short)(ch->param) * 256; ch->offsetBugNotAdded = true; }