From b4e70422a3455e327433a7471c929ef100ef3b10 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 8 Aug 2020 21:56:15 -0400 Subject: mikmod: Upgrade mikmod core from v3.2.0 to v3.3.11 * Get rid of the non-functional GT2 loader * Add the UMX loader * Add HQ mixer routines (and make it configurable) * Allow samplerate to be configured at run/playtime * Support >64KHz mixing/playback * Correctly restore non-boost status (The diff to upstream is much smaller now too!) Change-Id: Iaa4ac901ba9cd4123bb225656976e78271353a72 --- apps/plugins/mikmod/load_stm.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'apps/plugins/mikmod/load_stm.c') diff --git a/apps/plugins/mikmod/load_stm.c b/apps/plugins/mikmod/load_stm.c index 994b0e5355..c62a6d7f36 100644 --- a/apps/plugins/mikmod/load_stm.c +++ b/apps/plugins/mikmod/load_stm.c @@ -6,12 +6,12 @@ it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA @@ -20,7 +20,7 @@ /*============================================================================== - $Id: load_stm.c,v 1.3 2005/04/07 19:57:38 realtech Exp $ + $Id$ Screamtracker 2 (STM) module loader @@ -74,7 +74,7 @@ typedef struct STMHEADER { UBYTE ver_minor; UBYTE inittempo; /* initspeed= stm inittempo>>4 */ UBYTE numpat; /* number of patterns */ - UBYTE globalvol; + UBYTE globalvol; UBYTE reserved[13]; STMSAMPLE sample[31]; /* STM sample data */ UBYTE patorder[128]; /* Docs say 64 - actually 128 */ @@ -90,7 +90,7 @@ static STMNOTE *stmbuf = NULL; static STMHEADER *mh = NULL; /* tracker identifiers */ -static CHAR* STM_Version[STM_NTRACKERS] = { +static const CHAR * STM_Version[STM_NTRACKERS] = { "Screamtracker 2", "Converted by MOD2STM (STM format)", "Wuzamod (STM format)" @@ -103,6 +103,7 @@ static int STM_Test(void) UBYTE str[44]; int t; + memset(str,0,44); _mm_fseek(modreader,20,SEEK_SET); _mm_read_UBYTES(str,44,modreader); if(str[9]!=2) return 0; /* STM Module = filetype 2 */ @@ -110,7 +111,7 @@ static int STM_Test(void) /* Prevent false positives for S3M files */ if(!memcmp(str+40,"SCRM",4)) return 0; - + for (t=0;tsongname,20,modreader); @@ -272,6 +274,10 @@ static int STM_Load(int curious) mh->numpat =_mm_read_UBYTE(modreader); mh->globalvol =_mm_read_UBYTE(modreader); _mm_read_UBYTES(mh->reserved,13,modreader); + if(mh->numpat > 128) { + _mm_errno = MMERR_NOT_A_MODULE; + return 0; + } for(t=0;t<31;t++) { STMSAMPLE *s=&mh->sample[t]; /* STM sample data */ @@ -299,9 +305,7 @@ static int STM_Load(int curious) /* set module variables */ for(t=0;ttrackername,STM_Signatures[t],8)) break; - if(t == STM_NTRACKERS) - return 0; - of.modtype = StrDup(STM_Version[t]); + of.modtype = MikMod_strdup(STM_Version[t]); of.songname = DupStr(mh->songname,20,1); /* make a cstr of songname */ of.numpat = mh->numpat; of.inittempo = 125; /* mh->inittempo+0x1c; */ @@ -316,7 +320,10 @@ static int STM_Load(int curious) /* 99 terminates the patorder list */ while((mh->patorder[t]<=99)&&(mh->patorder[t]numpat)) { of.positions[t]=mh->patorder[t]; - t++; + if(++t == 0x80) { + _mm_errno = MMERR_NOT_A_MODULE; + return 0; + } } if(mh->patorder[t]<=99) t++; of.numpos=t; @@ -334,7 +341,7 @@ static int STM_Load(int curious) q->speed = (mh->sample[t].c2spd * 8363) / 8448; q->volume = mh->sample[t].volume; q->length = mh->sample[t].length; - if (/*(!mh->sample[t].volume)||*/(q->length==1)) q->length=0; + if (/*!mh->sample[t].volume || */q->length==1) q->length=0; q->loopstart = mh->sample[t].loopbeg; q->loopend = mh->sample[t].loopend; q->seekpos = MikMod_ISA; @@ -374,5 +381,4 @@ MIKMODAPI MLOADER load_stm={ STM_LoadTitle }; - /* ex:set ts=4: */ -- cgit v1.2.3