diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 36052bb75..549d47e2b 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,3 +1,6 @@ +Progress to next release: +- Upgrade internal libmikmod to 3.3.11.1, for Aarch64 support - McMartin + 0.8: - Grouping ship properties together at the top of the ship .c files, from oldlaptop. diff --git a/sc2/src/libs/mikmod/AUTHORS b/sc2/src/libs/mikmod/AUTHORS index 5752fdf82..35c1a0043 100644 --- a/sc2/src/libs/mikmod/AUTHORS +++ b/sc2/src/libs/mikmod/AUTHORS @@ -9,25 +9,35 @@ libmikmod main authors maintained MikMod version 3 until it was discontinued. He still works on the WinAmp module plugin, roughly based on MikMod. * Miod Vallat - current overbooked libmikmod maintainer (since version 3.0.4), made + [email doesn't work anymore...] + maintainer MikMod'Unix (since version 3.0.4), made an audit of the code resulting in many bugs fixed. +* Raphael Assenat + Revived the project after many years of inactivity, in 2004. Former + maintainer. +* Shlomi Fish ( http://www.shlomifish.org/ ). + Took over maintenance after many years of inactivity, in 2012. +* Ozkan Sezer + Took over maintenance in 2013. (current maintainer.) Previous Unix maintainers ------------------------- -* Steve McIntyre +* Steve McIntyre maintained MikMod'Unix version 2. Used to maintain the Debian package for MikMod. * Peter Amstutz maintained MikMod'Unix version 3 up to version 3.0.3. - + General contributors -------------------- * Arne de Bruijn wrote the compressed IT sample support. -* Shlomi Fish - wrote the Java port, bug fixes. +* Shlomi Fish + wrote the Java port, bug fixes, CMake build system. +* Ozkan Sezer + overall bug fixes, configury updates. * Juan Linietsky overall bug fixes. * Claudio Matsuoka @@ -48,6 +58,9 @@ General contributors Contributors on the Unix side ----------------------------- +* Axel "awe" Wefers + wrote the OSX CoreAudio driver, the AIFF driver and + updated the Mac Audio Carbon driver * Douglas Carmichael ported MikMod to FreeBSD. * Chris Conn @@ -84,6 +97,22 @@ Contributors on the Windows side created the DirectSound driver. * Bjornar Henden created the Multimedia API windows driver. +* Paul Spark + created the SDL windows driver and made changes to build with MSVC++ 6. + +Contributors on the Android side +-------------------------------- + +* Radovan Cervenka + provided the Android building artifacts and ported the old OpenSL ES + driver from the old http://github.com/0xD34D/libmikmod-android project + to libmikmod-3. + +Contributors on the Amiga side +------------------------------ + +* Szilárd Biró + provided the AHI driver. Contributors on the Dos side ---------------------------- @@ -108,7 +137,7 @@ Contributors on the Macintosh side Contributors on the OS/2 side ----------------------------- -* Stefan Tibus +* Stefan Tibus ported libmikmod to OS/2. * Andrew Zabolotny improved the existing OS/2 drivers. @@ -119,6 +148,5 @@ Contributors on the BeOS side * Thomas Neumann integrated libmikmod into his BeOS APlayer, and contributed many bug fixes. --- -If your name is missing, don't hesitate to remind me at - +-- +If your name is missing, don't hesitate to remind the current maintainer. diff --git a/sc2/src/libs/mikmod/Makeinfo b/sc2/src/libs/mikmod/Makeinfo index cd037f9fc..4dc65222f 100644 --- a/sc2/src/libs/mikmod/Makeinfo +++ b/sc2/src/libs/mikmod/Makeinfo @@ -1,5 +1,5 @@ uqm_CFILES="drv_nos.c load_it.c load_mod.c load_s3m.c load_stm.c load_xm.c - mdreg.c mdriver.c mloader.c + mdreg.c mdriver.c mdulaw.c mloader.c mlreg.c mlutil.c mmalloc.c mmerror.c mmio.c mplayer.c munitrk.c mwav.c npertab.c sloader.c virtch.c virtch2.c virtch_common.c" uqm_HFILES="mikmod_build.h mikmod.h mikmod_internals.h" diff --git a/sc2/src/libs/mikmod/README b/sc2/src/libs/mikmod/README index c5c0be22a..2cf00d823 100644 --- a/sc2/src/libs/mikmod/README +++ b/sc2/src/libs/mikmod/README @@ -1,5 +1,11 @@ NOTE by UQM developers: this is a modified version of libmikmod. This version of the library is based on the official libmikmod library -version 3.1.11a with some internal and API changes backported from v3.2.2. +version 3.3.11.1. Alterations have been marked with comments that +begin with the text UQM MOD, along with brief descriptions. The +changes are largely limited to removal of unused-by-UQM formats and +drivers, hardcoding static-library behavior for the remainder, and +reliance on UQM's own configuration files for cross-compatibility +defines. + The official library is found at http://sourceforge.net/projects/mikmod. diff --git a/sc2/src/libs/mikmod/drv_nos.c b/sc2/src/libs/mikmod/drv_nos.c index 0ea3d1f9a..b87098540 100644 --- a/sc2/src/libs/mikmod/drv_nos.c +++ b/sc2/src/libs/mikmod/drv_nos.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 @@ -51,7 +51,7 @@ static BOOL NS_IsThere(void) return 1; } -static BOOL NS_Init(void) +static int NS_Init(void) { zerobuf=(SBYTE*)MikMod_malloc(ZEROLEN); return VC_Init(); @@ -61,6 +61,7 @@ static void NS_Exit(void) { VC_Exit(); MikMod_free(zerobuf); + zerobuf=NULL; } static void NS_Update(void) @@ -75,7 +76,7 @@ MIKMODAPI MDRIVER drv_nos={ "Nosound Driver v3.0", 255,255, "nosound", - + NULL, NULL, NS_IsThere, VC_SampleLoad, @@ -103,5 +104,4 @@ MIKMODAPI MDRIVER drv_nos={ VC_VoiceRealVolume }; - /* ex:set ts=4: */ diff --git a/sc2/src/libs/mikmod/load_it.c b/sc2/src/libs/mikmod/load_it.c index 747f23a05..84b776547 100644 --- a/sc2/src/libs/mikmod/load_it.c +++ b/sc2/src/libs/mikmod/load_it.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 @@ -34,7 +34,6 @@ #include #endif -#include #include #ifdef HAVE_MEMORY_H #include @@ -42,10 +41,10 @@ #include #include "mikmod_internals.h" +#include "mikmod_ctype.h" #ifdef SUNOS extern int fprintf(FILE *, const char *, ...); -extern int toupper(int); #endif /*========== Module structure */ @@ -67,7 +66,7 @@ typedef struct ITHEADER { UBYTE initspeed; UBYTE inittempo; UBYTE pansep; /* panning separation between channels */ - UBYTE zerobyte; + UBYTE zerobyte; UWORD msglength; ULONG msgoffset; UBYTE blank02[4]; @@ -107,19 +106,19 @@ typedef struct ITINSTHEADER { CHAR filename[12]; /* (char) Instrument filename */ UBYTE zerobyte; /* (byte) Instrument type (always 0) */ UBYTE volflg; - UBYTE volpts; + UBYTE volpts; UBYTE volbeg; /* (byte) Volume loop start (node) */ UBYTE volend; /* (byte) Volume loop end (node) */ UBYTE volsusbeg; /* (byte) Volume sustain begin (node) */ UBYTE volsusend; /* (byte) Volume Sustain end (node) */ UBYTE panflg; - UBYTE panpts; + UBYTE panpts; UBYTE panbeg; /* (byte) channel loop start (node) */ UBYTE panend; /* (byte) channel loop end (node) */ UBYTE pansusbeg; /* (byte) channel sustain begin (node) */ UBYTE pansusend; /* (byte) channel Sustain end (node) */ UBYTE pitflg; - UBYTE pitpts; + UBYTE pitpts; UBYTE pitbeg; /* (byte) pitch loop start (node) */ UBYTE pitend; /* (byte) pitch loop end (node) */ UBYTE pitsusbeg; /* (byte) pitch sustain begin (node) */ @@ -149,7 +148,7 @@ typedef struct ITINSTHEADER { UWORD pantick[ITENVCNT]; /* tick value of panning nodes */ SBYTE pitnode[ITENVCNT]; /* pitchenv - node points */ UWORD pittick[ITENVCNT]; /* tick value of pitch nodes */ -} ITINSTHEADER; +} ITINSTHEADER; /* unpacked note */ @@ -166,8 +165,8 @@ static UBYTE *mask=NULL; /* arrays allocated to 64 elements and used for */ static ITNOTE *last=NULL; /* uncompressing IT's pattern information */ static int numtrk=0; static unsigned int old_effect; /* if set, use S3M old-effects stuffs */ - -static CHAR* IT_Version[]={ + +static const CHAR* IT_Version[]={ "ImpulseTracker . ", "Compressed ImpulseTracker . ", "ImpulseTracker 2.14p3", @@ -177,11 +176,11 @@ static CHAR* IT_Version[]={ }; /* table for porta-to-note command within volume/panning column */ -static UBYTE portatable[10]= {0,1,4,8,16,32,64,96,128,255}; +static const UBYTE portatable[10]= {0,1,4,8,16,32,64,96,128,255}; /*========== Loader code */ -BOOL IT_Test(void) +static BOOL IT_Test(void) { UBYTE id[4]; @@ -190,7 +189,7 @@ BOOL IT_Test(void) return 0; } -BOOL IT_Init(void) +static BOOL IT_Init(void) { if(!(mh=(ITHEADER*)MikMod_malloc(sizeof(ITHEADER)))) return 0; if(!(poslookup=(UBYTE*)MikMod_malloc(256*sizeof(UBYTE)))) return 0; @@ -201,7 +200,7 @@ BOOL IT_Init(void) return 1; } -void IT_Cleanup(void) +static void IT_Cleanup(void) { FreeLinear(); @@ -212,40 +211,48 @@ void IT_Cleanup(void) MikMod_free(last); MikMod_free(paraptr); MikMod_free(origpositions); + mh=NULL; + poslookup=NULL; + itpat=NULL; + mask=NULL; + last=NULL; + paraptr=NULL; + origpositions=NULL; } /* Because so many IT files have 64 channels as the set number used, but really only use far less (usually from 8 to 24 still), I had to make this function, which determines the number of channels that are actually USED by a pattern. - - NOTE: You must first seek to the file location of the pattern before calling - this procedure. - Returns 1 on error + NOTE: You must first seek to the file location of the pattern before calling + this procedure. + + Returns 0 on error */ static BOOL IT_GetNumChannels(UWORD patrows) { int row=0,flag,ch; do { - if((flag=_mm_read_UBYTE(modreader))==EOF) { + if(_mm_eof(modreader)) { _mm_errno=MMERR_LOADING_PATTERN; - return 1; + return 0; } + flag=_mm_read_UBYTE(modreader); if(!flag) row++; else { ch=(flag-1)&63; remap[ch]=0; if(flag & 128) mask[ch]=_mm_read_UBYTE(modreader); - if(mask[ch]&1) _mm_read_UBYTE(modreader); - if(mask[ch]&2) _mm_read_UBYTE(modreader); - if(mask[ch]&4) _mm_read_UBYTE(modreader); - if(mask[ch]&8) { _mm_read_UBYTE(modreader);_mm_read_UBYTE(modreader); } + if(mask[ch]&1) _mm_skip_BYTE(modreader); + if(mask[ch]&2) _mm_skip_BYTE(modreader); + if(mask[ch]&4) _mm_skip_BYTE(modreader); + if(mask[ch]&8) { _mm_skip_BYTE(modreader);_mm_skip_BYTE(modreader); } } } while(row ite) { /* malformed file */ + _mm_errno = MMERR_NOT_A_MODULE; + return 0; + } + } else + { n=l=&dummy; + blah = 0; + m=(UBYTE*)&blah; + } - if(flag&128) mask[ch]=_mm_read_UBYTE(modreader); - if(mask[ch]&1) + if(flag&128) *m=_mm_read_UBYTE(modreader); + if(*m&1) /* convert IT note off to internal note off */ - if((l->note=n->note=_mm_read_UBYTE(modreader))==255) + if((l->note=n->note=_mm_read_UBYTE(modreader))==255) l->note=n->note=253; - if(mask[ch]&2) + if(*m&2) l->ins=n->ins=_mm_read_UBYTE(modreader); - if(mask[ch]&4) + if(*m&4) l->volpan=n->volpan=_mm_read_UBYTE(modreader); - if(mask[ch]&8) { + if(*m&8) { l->cmd=n->cmd=_mm_read_UBYTE(modreader); l->inf=n->inf=_mm_read_UBYTE(modreader); } - if(mask[ch]&16) + if(*m&16) n->note=l->note; - if(mask[ch]&32) + if(*m&32) n->ins=l->ins; - if(mask[ch]&64) + if(*m&64) n->volpan=l->volpan; - if(mask[ch]&128) { + if(*m&128) { n->cmd=l->cmd; n->inf=l->inf; } @@ -379,38 +399,38 @@ static BOOL IT_ReadPattern(UWORD patrows) return 1; } -static void LoadMidiString(MREADER* modreader,CHAR* dest) +static void LoadMidiString(MREADER* r,CHAR* dest) { - CHAR *cur,*last; + CHAR *curp,*lastp; - _mm_read_UBYTES(dest,32,modreader); - cur=last=dest; + _mm_read_UBYTES(dest,32,r); + curp=lastp=dest; /* remove blanks and uppercase all */ - while(*last) { - if(isalnum((int)*last)) *(cur++)=toupper((int)*last); - last++; + while(*lastp) { + if(mik_isalnum((int)*lastp)) *(curp++)=mik_toupper((int)*lastp); + lastp++; } - *cur=0; + *curp=0; } /* Load embedded midi information for resonant filters */ -static void IT_LoadMidiConfiguration(MREADER* modreader) +static void IT_LoadMidiConfiguration(MREADER* r) { int i; memset(filtermacros,0,sizeof(filtermacros)); memset(filtersettings,0,sizeof(filtersettings)); - if (modreader) { /* information is embedded in file */ + if (r) { /* information is embedded in file */ UWORD dat; CHAR midiline[33]; - dat=_mm_read_I_UWORD(modreader); - _mm_fseek(modreader,8*dat+0x120,SEEK_CUR); + dat=_mm_read_I_UWORD(r); + _mm_fseek(r,8*dat+0x120,SEEK_CUR); /* read midi macros */ for(i=0;iordnum > 256 || mh->insnum > 255 || mh->smpnum > 255 || mh->patnum > 255) { + _mm_errno=MMERR_NOT_A_MODULE; + return 0; + } /* set module variables */ of.songname = DupStr(mh->songname,26,0); /* make a cstr of songname */ @@ -506,11 +530,11 @@ BOOL IT_Load(BOOL curious) /* 2.16 : IT 2.14p3 with resonant filters */ /* 2.15 : IT 2.14p3 (improved compression) */ if((mh->cwt<=0x219)&&(mh->cwt>=0x217)) - of.modtype=strdup(IT_Version[mh->cmwt<0x214?4:5]); + of.modtype=MikMod_strdup(IT_Version[mh->cmwt<0x214?4:5]); else if (mh->cwt>=0x215) - of.modtype=strdup(IT_Version[mh->cmwt<0x214?2:3]); + of.modtype=MikMod_strdup(IT_Version[mh->cmwt<0x214?2:3]); else { - of.modtype = strdup(IT_Version[mh->cmwt<0x214?0:1]); + of.modtype = MikMod_strdup(IT_Version[mh->cmwt<0x214?0:1]); of.modtype[mh->cmwt<0x214?15:26] = (mh->cwt>>8)+'0'; of.modtype[mh->cmwt<0x214?17:28] = ((mh->cwt>>4)&0xf)+'0'; of.modtype[mh->cmwt<0x214?18:29] = ((mh->cwt)&0xf)+'0'; @@ -550,7 +574,7 @@ BOOL IT_Load(BOOL curious) /* read the order data */ if(!AllocPositions(mh->ordnum)) return 0; - if(!(origpositions=MikMod_calloc(mh->ordnum,sizeof(UWORD)))) return 0; + if(!(origpositions=(UWORD*)MikMod_calloc(mh->ordnum,sizeof(UWORD)))) return 0; for(t=0;tordnum;t++) { origpositions[t]=_mm_read_UBYTE(modreader); @@ -672,14 +696,14 @@ BOOL IT_Load(BOOL curious) if(s.flag&2) q->flags|=SF_16BITS; if((s.flag&8)&&(mh->cwt>=0x214)) { q->flags|=SF_ITPACKED; - compressed=1; + /*compressed=1;*/ } if(s.flag&16) q->flags|=SF_LOOP; if(s.flag&64) q->flags|=SF_BIDI; if(mh->cwt>=0x200) { if(s.convert&1) q->flags|=SF_SIGNED; - if(s.convert&4) q->flags|=SF_DELTA; + if(s.convert&4) q->flags|=SF_DELTA; } q++; } @@ -726,7 +750,7 @@ BOOL IT_Load(BOOL curious) ih.trkvers = _mm_read_I_UWORD(modreader); ih.numsmp = _mm_read_UBYTE(modreader); - _mm_read_UBYTE(modreader); + _mm_skip_BYTE(modreader); _mm_read_string(ih.name,26,modreader); _mm_read_UBYTES(ih.blank01,6,modreader); _mm_read_I_UWORDS(ih.samptable,ITNOTECNT,modreader); @@ -736,13 +760,15 @@ BOOL IT_Load(BOOL curious) for(lp=0;lp ITENVCNT) \ + ih. name##pts = ITENVCNT; \ ih. name##beg =_mm_read_UBYTE(modreader); \ ih. name##end =_mm_read_UBYTE(modreader); \ ih. name##susbeg=_mm_read_UBYTE(modreader); \ @@ -751,11 +777,13 @@ BOOL IT_Load(BOOL curious) ih. name##node[lp]=_mm_read_##type (modreader); \ ih. name##tick[lp]=_mm_read_I_UWORD(modreader); \ } \ - _mm_read_UBYTE(modreader) + _mm_skip_BYTE(modreader) #else #define IT_LoadEnvelope(name,type) \ ih. name/**/flg =_mm_read_UBYTE(modreader); \ ih. name/**/pts =_mm_read_UBYTE(modreader); \ + if (ih. name/**/pts > ITENVCNT) \ + ih. name/**/pts = ITENVCNT; \ ih. name/**/beg =_mm_read_UBYTE(modreader); \ ih. name/**/end =_mm_read_UBYTE(modreader); \ ih. name/**/susbeg=_mm_read_UBYTE(modreader); \ @@ -764,7 +792,7 @@ BOOL IT_Load(BOOL curious) ih. name/**/node[lp]=_mm_read_/**/type (modreader); \ ih. name/**/tick[lp]=_mm_read_I_UWORD(modreader); \ } \ - _mm_read_UBYTE(modreader) + _mm_skip_BYTE(modreader) #endif IT_LoadEnvelope(vol,UBYTE); @@ -772,7 +800,7 @@ BOOL IT_Load(BOOL curious) IT_LoadEnvelope(pit,SBYTE); #undef IT_LoadEnvelope } - + if(_mm_eof(modreader)) { _mm_errno = MMERR_LOADING_SAMPLEINFO; return 0; @@ -791,10 +819,10 @@ BOOL IT_Load(BOOL curious) if(ih.volflg&1) d->volflg|=EF_ON; if(ih.volflg&2) d->volflg|=EF_LOOP; - if(ih.volflg&4) d->volflg|=EF_SUSTAIN; + if(ih.volflg&4) d->volflg|=EF_SUSTAIN; /* XM conversion of IT envelope Array */ - d->volbeg = ih.volbeg; + d->volbeg = ih.volbeg; d->volend = ih.volend; d->volsusbeg = ih.volsusbeg; d->volsusend = ih.volsusend; @@ -807,7 +835,7 @@ BOOL IT_Load(BOOL curious) d->volpts++; } else break; - } + } } else { d->panning=((ih.chanpan&127)==64)?255:(ih.chanpan&127)<<2; if(!(ih.chanpan&128)) d->flags|=IF_OWNPAN; @@ -862,6 +890,7 @@ BOOL IT_Load(BOOL curious) #endif IT_ProcessEnvelope(vol); + for(u=0;uvolenv[u].val=(ih.volnode[u]<<2); @@ -882,7 +911,7 @@ BOOL IT_Load(BOOL curious) #ifdef MIKMOD_DEBUG { static int warn=0; - + if(!warn) fprintf(stderr, "\rFilter envelopes not supported yet\n"); warn=1; @@ -903,7 +932,7 @@ BOOL IT_Load(BOOL curious) } } - d++; + d++; } } else if(of.flags & UF_LINEAR) { if(!AllocInstruments()) return 0; @@ -941,12 +970,12 @@ BOOL IT_Load(BOOL curious) return 0; } _mm_read_I_ULONG(modreader); - if(IT_GetNumChannels(packlen)) return 0; + if(!IT_GetNumChannels(packlen)) return 0; } } /* give each of them a different number */ - for(t=0;tinsnum+mh->smpnum+t]),SEEK_SET); packlen=_mm_read_I_UWORD(modreader); + (void)packlen; /* unused */ of.pattrows[t]=_mm_read_I_UWORD(modreader); _mm_read_I_ULONG(modreader); if(!IT_ReadPattern(of.pattrows[t])) return 0; @@ -982,13 +1012,13 @@ BOOL IT_Load(BOOL curious) return 1; } -CHAR *IT_LoadTitle(void) +static CHAR *IT_LoadTitle(void) { CHAR s[26]; _mm_fseek(modreader,4,SEEK_SET); if(!_mm_read_UBYTES(s,26,modreader)) return NULL; - + return(DupStr(s,26,0)); } diff --git a/sc2/src/libs/mikmod/load_mod.c b/sc2/src/libs/mikmod/load_mod.c index 40d4b9acf..6fffac08f 100644 --- a/sc2/src/libs/mikmod/load_mod.c +++ b/sc2/src/libs/mikmod/load_mod.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 @@ -34,7 +34,6 @@ #include #endif -#include #include #ifdef HAVE_MEMORY_H #include @@ -42,6 +41,7 @@ #include #include "mikmod_internals.h" +#include "mikmod_ctype.h" #ifdef SUNOS extern int fprintf(FILE *, const char *, ...); @@ -108,10 +108,10 @@ static BOOL MOD_CheckType(UBYTE *id, UBYTE *numchn, CHAR **descr) *numchn = 4; return 1; } - + /* Star Tracker */ if (((!memcmp(id, "FLT", 3)) || (!memcmp(id, "EXO", 3))) && - (isdigit(id[3]))) { + (mik_isdigit(id[3]))) { *descr = startrekker; modtype = trekker = 1; *numchn = id[3] - '0'; @@ -141,7 +141,7 @@ static BOOL MOD_CheckType(UBYTE *id, UBYTE *numchn, CHAR **descr) } /* Fasttracker */ - if ((!memcmp(id + 1, "CHN", 3)) && (isdigit(id[0]))) { + if ((!memcmp(id + 1, "CHN", 3)) && (mik_isdigit(id[0]))) { *descr = fasttracker; modtype = 1; *numchn = id[0] - '0'; @@ -149,7 +149,7 @@ static BOOL MOD_CheckType(UBYTE *id, UBYTE *numchn, CHAR **descr) } /* Fasttracker or Taketracker */ if (((!memcmp(id + 2, "CH", 2)) || (!memcmp(id + 2, "CN", 2))) - && (isdigit(id[0])) && (isdigit(id[1]))) { + && (mik_isdigit(id[0])) && (mik_isdigit(id[1]))) { if (id[3] == 'H') { *descr = fasttracker; modtype = 2; /* this can also be Imago Orpheus */ @@ -190,6 +190,8 @@ static void MOD_Cleanup(void) { MikMod_free(mh); MikMod_free(patbuf); + mh=NULL; + patbuf=NULL; } /* @@ -277,7 +279,7 @@ static UBYTE ConvertNote(MODNOTE *n, UBYTE lasteffect) /* Handle ``heavy'' volumes correctly */ if ((effect == 0xc) && (effdat > 0x40)) effdat = 0x40; - + /* An isolated 100, 200 or 300 effect should be ignored (no "standalone" porta memory in mod files). However, a sequence such as 1XX, 100, 100, 100 is fine. */ @@ -288,7 +290,7 @@ static UBYTE ConvertNote(MODNOTE *n, UBYTE lasteffect) UniPTEffect(effect, effdat); if (effect == 8) of.flags |= UF_PANNING; - + return effect; } @@ -315,7 +317,7 @@ static BOOL ML_LoadPatterns(void) return 0; if (!AllocTracks()) return 0; - + /* Allocate temporary buffer for loading and converting the patterns */ if (!(patbuf = (MODNOTE *)MikMod_calloc(64U * of.numchn, sizeof(MODNOTE)))) return 0; @@ -323,7 +325,7 @@ static BOOL ML_LoadPatterns(void) if (trekker && of.numchn == 8) { /* Startrekker module dual pattern */ for (t = 0; t < of.numpat; t++) { - for (s = 0; s < (64 * 4); s++) { + for (s = 0; s < (64U * 4); s++) { patbuf[s].a = _mm_read_UBYTE(modreader); patbuf[s].b = _mm_read_UBYTE(modreader); patbuf[s].c = _mm_read_UBYTE(modreader); @@ -332,7 +334,7 @@ static BOOL ML_LoadPatterns(void) for (s = 0; s < 4; s++) if (!(of.tracks[tracks++] = ConvertTrack(patbuf + s, 4))) return 0; - for (s = 0; s < (64 * 4); s++) { + for (s = 0; s < (64U * 4); s++) { patbuf[s].a = _mm_read_UBYTE(modreader); patbuf[s].b = _mm_read_UBYTE(modreader); patbuf[s].c = _mm_read_UBYTE(modreader); @@ -346,7 +348,7 @@ static BOOL ML_LoadPatterns(void) /* Generic module pattern */ for (t = 0; t < of.numpat; t++) { /* Load the pattern into the temp buffer and convert it */ - for (s = 0; s < (64 * of.numchn); s++) { + for (s = 0; s < (64U * of.numchn); s++) { patbuf[s].a = _mm_read_UBYTE(modreader); patbuf[s].b = _mm_read_UBYTE(modreader); patbuf[s].c = _mm_read_UBYTE(modreader); @@ -384,10 +386,10 @@ static BOOL MOD_Load(BOOL curious) mh->songlength = _mm_read_UBYTE(modreader); - /* this fixes mods which declare more than 128 positions. + /* this fixes mods which declare more than 128 positions. * eg: beatwave.mod */ if (mh->songlength > 128) { mh->songlength = 128; } - + mh->magic1 = _mm_read_UBYTE(modreader); _mm_read_UBYTES(mh->positions, 128, modreader); _mm_read_UBYTES(mh->magic2, 4, modreader); @@ -476,11 +478,11 @@ static BOOL MOD_Load(BOOL curious) q++; } - of.modtype = strdup(descr); + of.modtype = MikMod_strdup(descr); if (!ML_LoadPatterns()) return 0; - + return 1; } diff --git a/sc2/src/libs/mikmod/load_s3m.c b/sc2/src/libs/mikmod/load_s3m.c index 782ee23c3..32e6c2324 100644 --- a/sc2/src/libs/mikmod/load_s3m.c +++ b/sc2/src/libs/mikmod/load_s3m.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 @@ -104,7 +104,7 @@ static unsigned int tracker; /* tracker id */ /* tracker identifiers */ #define NUMTRACKERS 4 -static CHAR* S3M_Version[] = { +static const CHAR * S3M_Version[] = { "Screamtracker x.xx", "Imago Orpheus x.xx (S3M format)", "Impulse Tracker x.xx (S3M format)", @@ -113,11 +113,11 @@ static CHAR* S3M_Version[] = { "Impulse Tracker 2.14p4 (S3M format)" }; /* version number position in above array */ -static int numeric[NUMTRACKERS]={14,14,16,16}; +static const int numeric[NUMTRACKERS]={14,14,16,16}; /*========== Loader code */ -BOOL S3M_Test(void) +static BOOL S3M_Test(void) { UBYTE id[4]; @@ -127,7 +127,7 @@ BOOL S3M_Test(void) return 0; } -BOOL S3M_Init(void) +static BOOL S3M_Init(void) { if(!(s3mbuf=(S3MNOTE*)MikMod_malloc(32*64*sizeof(S3MNOTE)))) return 0; if(!(mh=(S3MHEADER*)MikMod_malloc(sizeof(S3MHEADER)))) return 0; @@ -137,13 +137,18 @@ BOOL S3M_Init(void) return 1; } -void S3M_Cleanup(void) +static void S3M_Cleanup(void) { MikMod_free(s3mbuf); MikMod_free(paraptr); MikMod_free(poslookup); MikMod_free(mh); MikMod_free(origpositions); + s3mbuf=NULL; + paraptr=NULL; + poslookup=NULL; + mh=NULL; + origpositions=NULL; } /* Because so many s3m files have 16 channels as the set number used, but really @@ -154,9 +159,9 @@ void S3M_Cleanup(void) global variable 'remap' NOTE: You must first seek to the file location of the pattern before calling - this procedure. + this procedure. - Returns 1 on fail. */ + Returns 0 on fail. */ static BOOL S3M_GetNumChannels(void) { int row=0,flag,ch; @@ -166,19 +171,19 @@ static BOOL S3M_GetNumChannels(void) if(_mm_eof(modreader)) { _mm_errno = MMERR_LOADING_PATTERN; - return 1; + return 0; } if(flag) { ch=flag&31; if(mh->channels[ch]<32) remap[ch] = 0; - if(flag&32) {_mm_read_UBYTE(modreader);_mm_read_UBYTE(modreader);} - if(flag&64) _mm_read_UBYTE(modreader); - if(flag&128){_mm_read_UBYTE(modreader);_mm_read_UBYTE(modreader);} + if(flag&32) {_mm_skip_BYTE(modreader);_mm_skip_BYTE(modreader);} + if(flag&64) _mm_skip_BYTE(modreader); + if(flag&128){_mm_skip_BYTE(modreader);_mm_skip_BYTE(modreader);} } else row++; } - return 0; -} + return 1; +} static BOOL S3M_ReadPattern(void) { @@ -250,7 +255,7 @@ static UBYTE* S3M_ConvertTrack(S3MNOTE* tr) return UniDup(); } -BOOL S3M_Load(BOOL curious) +static BOOL S3M_Load(BOOL curious) { int t,u,track = 0; SAMPLE *q; @@ -282,6 +287,10 @@ BOOL S3M_Load(BOOL curious) _mm_errno = MMERR_LOADING_HEADER; return 0; } + if(mh->ordnum > 255 || mh->insnum > 255 || mh->patnum > 255) { + _mm_errno = MMERR_NOT_A_MODULE; + return 0; + } /* then we can decide the module type */ tracker=mh->tracker>>12; @@ -294,7 +303,7 @@ BOOL S3M_Load(BOOL curious) tracker=NUMTRACKERS; /* IT 2.14p3 */ else tracker--; } - of.modtype = strdup(S3M_Version[tracker]); + of.modtype = MikMod_strdup(S3M_Version[tracker]); if(trackertracker>>8) &0xf)+'0'; of.modtype[numeric[tracker]+2] = ((mh->tracker>>4)&0xf)+'0'; @@ -315,7 +324,7 @@ BOOL S3M_Load(BOOL curious) /* read the order data */ if(!AllocPositions(mh->ordnum)) return 0; - if(!(origpositions=MikMod_calloc(mh->ordnum,sizeof(UWORD)))) return 0; + if(!(origpositions=(UWORD*)MikMod_calloc(mh->ordnum,sizeof(UWORD)))) return 0; for(t=0;tordnum;t++) { origpositions[t]=_mm_read_UBYTE(modreader); @@ -374,7 +383,8 @@ BOOL S3M_Load(BOOL curious) _mm_read_string(s.scrs,4,modreader); /* ScreamTracker imposes a 64000 bytes (not 64k !) limit */ - if (s.length > 64000) + /* enforce it, if we'll use S3MIT_SCREAM in S3M_ConvertTrack() */ + if (s.length > 64000 && tracker == 1) s.length = 64000; if(_mm_eof(modreader)) { @@ -388,7 +398,7 @@ BOOL S3M_Load(BOOL curious) q->loopstart = s.loopbeg; q->loopend = s.loopend; q->volume = s.volume; - q->seekpos = (((long)s.memsegh)<<16|s.memsegl)<<4; + q->seekpos = (((ULONG)s.memsegh)<<16|s.memsegl)<<4; if(s.flags&1) q->flags |= SF_LOOP; if(s.flags&4) q->flags |= SF_16BITS; @@ -406,16 +416,16 @@ BOOL S3M_Load(BOOL curious) for(t=0;tchannels[t]<32)&&(remap[t]!=-1)) { if(mh->channels[t]<8) of.panning[remap[t]]=0x30; @@ -444,7 +454,7 @@ BOOL S3M_Load(BOOL curious) return 1; } -CHAR *S3M_LoadTitle(void) +static CHAR *S3M_LoadTitle(void) { CHAR s[28]; diff --git a/sc2/src/libs/mikmod/load_stm.c b/sc2/src/libs/mikmod/load_stm.c index 299f33bf3..07538c0cd 100644 --- a/sc2/src/libs/mikmod/load_stm.c +++ b/sc2/src/libs/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 @@ -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)" @@ -98,7 +98,7 @@ static CHAR* STM_Version[STM_NTRACKERS] = { /*========== Loader code */ -BOOL STM_Test(void) +static BOOL STM_Test(void) { UBYTE str[44]; int t; @@ -110,7 +110,7 @@ BOOL STM_Test(void) /* Prevent false positives for S3M files */ if(!memcmp(str+40,"SCRM",4)) return 0; - + for (t=0;tsongname,20,modreader); _mm_read_string(mh->trackername,8,modreader); @@ -272,6 +272,10 @@ BOOL STM_Load(BOOL 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,7 +303,7 @@ BOOL STM_Load(BOOL curious) /* set module variables */ for(t=0;ttrackername,STM_Signatures[t],8)) break; - 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; */ @@ -314,7 +318,10 @@ BOOL STM_Load(BOOL 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; @@ -332,7 +339,7 @@ BOOL STM_Load(BOOL 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; @@ -349,7 +356,7 @@ BOOL STM_Load(BOOL curious) return 1; } -CHAR *STM_LoadTitle(void) +static CHAR *STM_LoadTitle(void) { CHAR s[20]; @@ -372,5 +379,4 @@ MIKMODAPI MLOADER load_stm={ STM_LoadTitle }; - /* ex:set ts=4: */ diff --git a/sc2/src/libs/mikmod/load_xm.c b/sc2/src/libs/mikmod/load_xm.c index 97e0b738b..4456320e8 100644 --- a/sc2/src/libs/mikmod/load_xm.c +++ b/sc2/src/libs/mikmod/load_xm.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 @@ -59,7 +59,7 @@ typedef struct XMHEADER { UWORD numchn; /* Number of channels (2,4,6,8,10,...,32) */ UWORD numpat; /* Number of patterns (max 256) */ UWORD numins; /* Number of instruments (max 128) */ - UWORD flags; + UWORD flags; UWORD tempo; /* Default tempo */ UWORD bpm; /* Default BPM */ UBYTE orders[256]; /* Pattern order table */ @@ -136,7 +136,7 @@ static XMWAVHEADER *wh=NULL,*s=NULL; /*========== Loader code */ -BOOL XM_Test(void) +static BOOL XM_Test(void) { UBYTE id[38]; @@ -146,15 +146,16 @@ BOOL XM_Test(void) return 0; } -BOOL XM_Init(void) +static BOOL XM_Init(void) { if(!(mh=(XMHEADER *)MikMod_malloc(sizeof(XMHEADER)))) return 0; return 1; } -void XM_Cleanup(void) +static void XM_Cleanup(void) { MikMod_free(mh); + mh=NULL; } static int XM_ReadNote(XMNOTE* n) @@ -359,8 +360,8 @@ static BOOL LoadPatterns(BOOL dummypat) return 0; /* when packsize is 0, don't try to load a pattern.. it's empty. */ - if(ph.packsize) - for(u=0;u=_mm_ftell(modreader)) { + for(u=headend-_mm_ftell(modreader);u;u--) { + _mm_skip_BYTE(modreader); + } + } /* we can't trust the envelope point count here, as some modules have incorrect values (K_OSPACE.XM reports 32 volume @@ -502,8 +517,8 @@ static BOOL LoadInstruments(void) if(pth.panpts>XMENVCNT/2) pth.panpts=XMENVCNT/2; if((_mm_eof(modreader))||(pth.volpts>XMENVCNT/2)||(pth.panpts>XMENVCNT/2)) { - if(nextwav) { MikMod_free(nextwav);nextwav=NULL; } - if(wh) { MikMod_free(wh);wh=NULL; } + MikMod_free(nextwav);nextwav=NULL; + MikMod_free(wh);wh=NULL; _mm_errno = MMERR_LOADING_SAMPLEINFO; return 0; } @@ -553,7 +568,7 @@ static BOOL LoadInstruments(void) \ if ((d-> name/**/flg&EF_ON)&&(d-> name/**/pts<2)) \ d-> name/**/flg&=~EF_ON -#endif +#endif XM_ProcessEnvelope(vol); XM_ProcessEnvelope(pan); @@ -570,15 +585,23 @@ static BOOL LoadInstruments(void) everything over */ if(mh->version>0x0103) next = 0; for(u=0;ufilend) { + MikMod_free(nextwav);MikMod_free(wh); + nextwav=NULL;wh=NULL; + _mm_errno = MMERR_LOADING_SAMPLEINFO; + return 0; + } /* Allocate more room for sample information if necessary */ if(of.numsmp+u==wavcnt) { wavcnt+=XM_SMPINCR; - if(!(nextwav=MikMod_realloc(nextwav,wavcnt*sizeof(ULONG)))){ - if(wh) { MikMod_free(wh);wh=NULL; } + if(!(nextwav=(ULONG*)MikMod_realloc(nextwav,wavcnt*sizeof(ULONG)))){ + MikMod_free(wh);wh=NULL; _mm_errno = MMERR_OUT_OF_MEMORY; return 0; } - if(!(wh=MikMod_realloc(wh,wavcnt*sizeof(XMWAVHEADER)))) { + if(!(wh=(XMWAVHEADER*)MikMod_realloc(wh,wavcnt*sizeof(XMWAVHEADER)))) { MikMod_free(nextwav);nextwav=NULL; _mm_errno = MMERR_OUT_OF_MEMORY; return 0; @@ -603,13 +626,6 @@ static BOOL LoadInstruments(void) nextwav[of.numsmp+u]=next; next+=s->length; - - if(_mm_eof(modreader)) { - MikMod_free(nextwav);MikMod_free(wh); - nextwav=NULL;wh=NULL; - _mm_errno = MMERR_LOADING_SAMPLEINFO; - return 0; - } } if(mh->version>0x0103) { @@ -620,9 +636,16 @@ static BOOL LoadInstruments(void) of.numsmp+=ih.numsmp; } else { /* read the remainder of the header */ - for(u=headend-_mm_ftell(modreader);u;u--) _mm_read_UBYTE(modreader); + ck = _mm_ftell(modreader); + if ((headend<0) || (filendversion<0x0104 || tid,17,modreader); _mm_read_string(mh->songname,21,modreader); _mm_read_string(mh->trackername,20,modreader); mh->version =_mm_read_I_UWORD(modreader); - if((mh->version<0x102)||(mh->version>0x104)) { - _mm_errno=MMERR_NOT_A_MODULE; - return 0; - } + if(mh->version < 0x102 || mh->version > 0x104) + goto bad_xm; mh->headersize =_mm_read_I_ULONG(modreader); mh->songlength =_mm_read_I_UWORD(modreader); mh->restart =_mm_read_I_UWORD(modreader); @@ -671,23 +690,25 @@ BOOL XM_Load(BOOL curious) mh->flags =_mm_read_I_UWORD(modreader); mh->tempo =_mm_read_I_UWORD(modreader); mh->bpm =_mm_read_I_UWORD(modreader); - if(!mh->bpm) { - _mm_errno=MMERR_NOT_A_MODULE; - return 0; - } - _mm_read_UBYTES(mh->orders,256,modreader); - - if(_mm_eof(modreader)) { - _mm_errno = MMERR_LOADING_HEADER; - return 0; - } + if(mh->numchn > 64) goto bad_xm; + if(mh->tempo > 32 || mh->bpm < 32 || mh->bpm > 255) + goto bad_xm; + if(mh->songlength > 256 || mh->headersize < 20 || mh->headersize > 20+256) + goto bad_xm; + if(mh->numpat > 256 || mh->numins > 255 || mh->restart > 255) + goto bad_xm; +/* _mm_read_UBYTES(mh->orders,256,modreader);*/ +/* _mm_read_UBYTES(mh->orders,mh->headersize-20,modreader);*/ + _mm_read_UBYTES(mh->orders,mh->songlength,modreader); + if(_mm_fseek(modreader, mh->headersize+60, SEEK_SET) || _mm_eof(modreader)) + goto bad_hdr; /* set module variables */ - of.initspeed = mh->tempo; + of.initspeed = mh->tempo; of.inittempo = mh->bpm; strncpy(tracker,mh->trackername,20);tracker[20]=0; - for(t=20;(tracker[t]<=' ')&&(t>=0);t--) tracker[t]=0; - + for(t=20;(t>=0)&&(tracker[t]<=' ');t--) tracker[t]=0; + /* some modules have the tracker name empty */ if (!tracker[0]) strcpy(tracker,"Unknown tracker"); @@ -699,7 +720,7 @@ BOOL XM_Load(BOOL curious) sprintf(modtype,"%s (XM format %d.%02d)", tracker,mh->version>>8,mh->version&0xff); #endif - of.modtype = strdup(modtype); + of.modtype = MikMod_strdup(modtype); of.numchn = mh->numchn; of.numpat = mh->numpat; of.numtrk = (UWORD)of.numpat*of.numchn; /* get number of channels */ @@ -707,8 +728,7 @@ BOOL XM_Load(BOOL curious) of.numpos = mh->songlength; /* copy the songlength */ of.reppos = mh->restartsonglength?mh->restart:0; of.numins = mh->numins; - of.flags |= UF_XMPERIODS | UF_INST | UF_NOWRAP | UF_FT2QUIRKS | - UF_PANNING; + of.flags |= UF_XMPERIODS | UF_INST | UF_NOWRAP | UF_FT2QUIRKS | UF_PANNING; if(mh->flags&1) of.flags |= UF_LINEAR; of.bpmlimit = 32; @@ -789,16 +809,19 @@ BOOL XM_Load(BOOL curious) MikMod_free(wh);MikMod_free(nextwav); wh=NULL;nextwav=NULL; return 1; + +bad_hdr: _mm_errno = MMERR_LOADING_HEADER; return 0; +bad_xm: _mm_errno = MMERR_NOT_A_MODULE; return 0; } -CHAR *XM_LoadTitle(void) +static CHAR *XM_LoadTitle(void) { - CHAR s[21]; + CHAR str[21]; _mm_fseek(modreader,17,SEEK_SET); - if(!_mm_read_UBYTES(s,21,modreader)) return NULL; + if(!_mm_read_UBYTES(str, 21, modreader)) return NULL; - return(DupStr(s,21,1)); + return(DupStr(str,21,1)); } /*========== Loader information */ diff --git a/sc2/src/libs/mikmod/mdreg.c b/sc2/src/libs/mikmod/mdreg.c index 2ad65c2ad..9c2742708 100644 --- a/sc2/src/libs/mikmod/mdreg.c +++ b/sc2/src/libs/mikmod/mdreg.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,24 +20,20 @@ /*============================================================================== - $Id$ - Routine for registering all drivers in libmikmod for the current platform. ==============================================================================*/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include "mikmod_internals.h" -void _mm_registeralldrivers(void) +static void _mm_registeralldrivers(void) { + /* UQM Edit: cut down driver list to our one driver */ + /* Register 'nosound' driver */ _mm_registerdriver(&drv_nos); } -void MikMod_RegisterAllDrivers(void) +MIKMODAPI void MikMod_RegisterAllDrivers(void) { MUTEX_LOCK(lists); _mm_registeralldrivers(); diff --git a/sc2/src/libs/mikmod/mdriver.c b/sc2/src/libs/mikmod/mdriver.c index 68a2e7991..26855d179 100644 --- a/sc2/src/libs/mikmod/mdriver.c +++ b/sc2/src/libs/mikmod/mdriver.c @@ -1,17 +1,17 @@ /* MikMod sound library - (c) 1998, 1999, 2000, 2001 Miodrag Vallat and others - see file AUTHORS - for complete list. + (c) 1998-2014 Miodrag Vallat and others - see file AUTHORS + for a complete list. This library is free software; you can redistribute it and/or modify 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,8 +20,6 @@ /*============================================================================== - $Id$ - These routines are used to access the available soundcard drivers. ==============================================================================*/ @@ -34,54 +32,62 @@ #include #endif -#if defined unix || (defined __APPLE__ && defined __MACH__) -#include -#include -#include -#include -#endif - #include -#ifdef HAVE_STRINGS_H -#include -#endif #include "mikmod_internals.h" +#if (MIKMOD_UNIX) +#include +#include +#endif + #ifdef SUNOS extern int fprintf(FILE *, const char *, ...); #endif -static MDRIVER *firstdriver=NULL; -MIKMODAPI MDRIVER *md_driver=NULL; +/* UQM mod: include the UQM file that manages stricmp vs strcasecmp. */ +#include "port.h" + extern MODULE *pf; /* modfile being played */ +/* EXPORTED GLOBALS */ +MIKMODAPI MDRIVER *md_driver = NULL; + /* Initial global settings */ -MIKMODAPI UWORD md_device = 0; /* autodetect */ -MIKMODAPI UWORD md_mixfreq = 44100; -MIKMODAPI UWORD md_mode = DMODE_STEREO | DMODE_16BITS | - DMODE_SURROUND |DMODE_SOFT_MUSIC | - DMODE_SOFT_SNDFX; -MIKMODAPI UBYTE md_pansep = 128; /* 128 == 100% (full left/right) */ -MIKMODAPI UBYTE md_reverb = 0; /* no reverb */ -MIKMODAPI UBYTE md_volume = 128; /* global sound volume (0-128) */ -MIKMODAPI UBYTE md_musicvolume = 128; /* volume of song */ -MIKMODAPI UBYTE md_sndfxvolume = 128; /* volume of sound effects */ - UWORD md_bpm = 125; /* tempo */ +MIKMODAPI UWORD md_device = 0; /* autodetect */ +MIKMODAPI UWORD md_mixfreq = 44100; +MIKMODAPI UWORD md_mode = DMODE_STEREO | DMODE_16BITS | + DMODE_SURROUND | + DMODE_SOFT_MUSIC | DMODE_SOFT_SNDFX; +MIKMODAPI UBYTE md_pansep = 128; /* 128 == 100% (full left/right) */ +MIKMODAPI UBYTE md_reverb = 0; /* no reverb */ +MIKMODAPI UBYTE md_volume = 128; /* global sound volume (0-128) */ +MIKMODAPI UBYTE md_musicvolume = 128; /* volume of song */ +MIKMODAPI UBYTE md_sndfxvolume = 128; /* volume of sound effects */ -/* Do not modify the numchn variables yourself! use MD_SetVoices() */ - UBYTE md_numchn=0,md_sngchn=0,md_sfxchn=0; - UBYTE md_hardchn=0,md_softchn=0; +/* INTERNAL GLOBALS */ +UWORD md_bpm = 125; /* tempo */ - void (*md_player)(void) = Player_HandleTick; -static BOOL isplaying=0, initialized = 0; -static UBYTE *sfxinfo; -static int sfxpool; +/* Do not modify the numchn variables yourself! use MikMod_SetNumVoices() */ +UBYTE md_numchn = 0, md_sngchn = 0, md_sfxchn = 0; +UBYTE md_hardchn = 0, md_softchn= 0; -static SAMPLE **md_sample = NULL; +void (*md_player)(void) = Player_HandleTick; + +MikMod_callback_t vc_callback = NULL; + +/* PRIVATE VARS */ +static MDRIVER *firstdriver = NULL; + +static volatile BOOL isplaying = 0, initialized = 0; + +static UBYTE *sfxinfo; +static int sfxpool; + +static SAMPLE **md_sample = NULL; /* Previous driver in use */ -static SWORD olddevice = -1; +static SWORD olddevice = -1; /* Limits the number of hardware voices to the specified amount. This function should only be used by the low-level drivers. */ @@ -183,17 +189,18 @@ MIKMODAPI CHAR* MikMod_InfoDriver(void) MUTEX_LOCK(lists); /* compute size of buffer */ - for(l=firstdriver;l;l=l->next) - len+=4+(l->next?1:0)+strlen(l->Version); + for(l = firstdriver; l; l = l->next) + len += 4 + (l->next ? 1 : 0) + strlen(l->Version); if(len) - if((list=MikMod_malloc(len*sizeof(CHAR)))) { - list[0]=0; - /* list all registered device drivers : */ - for(t=1,l=firstdriver;l;l=l->next,t++) - sprintf(list,(l->next)?"%s%2d %s\n":"%s%2d %s", - list,t,l->Version); + if((list=(CHAR*)MikMod_malloc(len*sizeof(CHAR))) != NULL) { + CHAR *list_end = list; + list[0] = 0; + /* list all registered device drivers : */ + for(t = 1, l = firstdriver; l; l = l->next, t++) { + list_end += sprintf(list_end, "%2d %s%s", t, l->Version, (l->next)? "\n" : ""); } + } MUTEX_UNLOCK(lists); return list; } @@ -205,10 +212,16 @@ void _mm_registerdriver(struct MDRIVER* drv) /* don't register a MISSING() driver */ if ((drv->Name) && (drv->Version)) { if (cruise) { - while (cruise->next) cruise = cruise->next; + if ( cruise == drv ) + return; + while(cruise->next) { + cruise = cruise->next; + if ( cruise == drv ) + return; + } cruise->next = drv; } else - firstdriver = drv; + firstdriver = drv; } } @@ -224,7 +237,7 @@ MIKMODAPI void MikMod_RegisterDriver(struct MDRIVER* drv) MUTEX_UNLOCK(lists); } -MIKMODAPI int MikMod_DriverFromAlias(CHAR *alias) +MIKMODAPI int MikMod_DriverFromAlias(const CHAR *alias) { int rank=1; MDRIVER *cruise; @@ -244,6 +257,21 @@ MIKMODAPI int MikMod_DriverFromAlias(CHAR *alias) return rank; } +MIKMODAPI MDRIVER *MikMod_DriverByOrdinal(int ordinal) +{ + MDRIVER *cruise; + + /* Allow only driver ordinals > 0 */ + if (!ordinal) return NULL; + + MUTEX_LOCK(lists); + cruise = firstdriver; + while (cruise && --ordinal) + cruise = cruise->next; + MUTEX_UNLOCK(lists); + return cruise; +} + SWORD MD_SampleLoad(SAMPLOAD* s, int type) { SWORD result; @@ -474,7 +502,12 @@ MIKMODAPI ULONG Voice_RealVolume(SBYTE voice) return result; } -static BOOL _mm_init(CHAR *cmdline) +MIKMODAPI void VC_SetCallback(MikMod_callback_t callback) +{ + vc_callback = callback; +} + +static int _mm_init(const CHAR *cmdline) { UWORD t; @@ -532,9 +565,9 @@ static BOOL _mm_init(CHAR *cmdline) return 0; } -MIKMODAPI BOOL MikMod_Init(CHAR *cmdline) +MIKMODAPI int MikMod_Init(const CHAR *cmdline) { - BOOL result; + int result; MUTEX_LOCK(vars); MUTEX_LOCK(lists); @@ -552,8 +585,8 @@ void MikMod_Exit_internal(void) md_numchn = md_sfxchn = md_sngchn = 0; md_driver = &drv_nos; - if(sfxinfo) MikMod_free(sfxinfo); - if(md_sample) MikMod_free(md_sample); + MikMod_free(sfxinfo); + MikMod_free(md_sample); md_sample = NULL; sfxinfo = NULL; @@ -569,14 +602,14 @@ MIKMODAPI void MikMod_Exit(void) MUTEX_UNLOCK(vars); } -/* Reset the driver using the new global variable settings. +/* Reset the driver using the new global variable settings. If the driver has not been initialized, it will be now. */ -static BOOL _mm_reset(CHAR *cmdline) +static int _mm_reset(const CHAR *cmdline) { BOOL wasplaying = 0; if(!initialized) return _mm_init(cmdline); - + if (isplaying) { wasplaying = 1; md_driver->PlayStop(); @@ -600,14 +633,14 @@ static BOOL _mm_reset(CHAR *cmdline) return 1; } } - - if (wasplaying) md_driver->PlayStart(); + + if (wasplaying) return md_driver->PlayStart(); return 0; } -MIKMODAPI BOOL MikMod_Reset(CHAR *cmdline) +MIKMODAPI int MikMod_Reset(const CHAR *cmdline) { - BOOL result; + int result; MUTEX_LOCK(vars); MUTEX_LOCK(lists); @@ -619,7 +652,7 @@ MIKMODAPI BOOL MikMod_Reset(CHAR *cmdline) } /* If either parameter is -1, the current set value will be retained. */ -BOOL MikMod_SetNumVoices_internal(int music, int sfx) +int MikMod_SetNumVoices_internal(int music, int sfx) { BOOL resume = 0; int t, oldchn = 0; @@ -632,8 +665,8 @@ BOOL MikMod_SetNumVoices_internal(int music, int sfx) resume = 1; } - if(sfxinfo) MikMod_free(sfxinfo); - if(md_sample) MikMod_free(md_sample); + MikMod_free(sfxinfo); + MikMod_free(md_sample); md_sample = NULL; sfxinfo = NULL; @@ -667,9 +700,9 @@ BOOL MikMod_SetNumVoices_internal(int music, int sfx) return 0; } -MIKMODAPI BOOL MikMod_SetNumVoices(int music, int sfx) +MIKMODAPI int MikMod_SetNumVoices(int music, int sfx) { - BOOL result; + int result; MUTEX_LOCK(vars); result=MikMod_SetNumVoices_internal(music,sfx); @@ -678,7 +711,7 @@ MIKMODAPI BOOL MikMod_SetNumVoices(int music, int sfx) return result; } -BOOL MikMod_EnableOutput_internal(void) +int MikMod_EnableOutput_internal(void) { _mm_critical = 1; if(!isplaying) { @@ -689,9 +722,9 @@ BOOL MikMod_EnableOutput_internal(void) return 0; } -MIKMODAPI BOOL MikMod_EnableOutput(void) +MIKMODAPI int MikMod_EnableOutput(void) { - BOOL result; + int result; MUTEX_LOCK(vars); result=MikMod_EnableOutput_internal(); @@ -735,8 +768,8 @@ MIKMODAPI BOOL MikMod_Active(void) allocated for use as sound effects (loops through voices, skipping all active criticals). - Returns the voice that the sound is being played on. */ -SBYTE Sample_Play_internal(SAMPLE *s,ULONG start,UBYTE flags) + Returns the voice that the sound is being played on. */ +static SBYTE Sample_Play_internal(SAMPLE *s,ULONG start,UBYTE flags) { int orig=sfxpool;/* for cases where all channels are critical */ int c; @@ -796,12 +829,15 @@ MIKMODAPI long MikMod_GetVersion(void) #ifdef HAVE_PTHREAD #define INIT_MUTEX(name) \ pthread_mutex_t _mm_mutex_##name=PTHREAD_MUTEX_INITIALIZER + #elif defined(__OS2__)||defined(__EMX__) #define INIT_MUTEX(name) \ HMTX _mm_mutex_##name -#elif defined(WIN32) + +#elif defined(_WIN32) #define INIT_MUTEX(name) \ HANDLE _mm_mutex_##name + #else #define INIT_MUTEX(name) \ void *_mm_mutex_##name = NULL @@ -813,8 +849,8 @@ INIT_MUTEX(lists); MIKMODAPI BOOL MikMod_InitThreads(void) { static int firstcall=1; - static int result=0; - + static BOOL result = 0; + if (firstcall) { firstcall=0; #ifdef HAVE_PTHREAD @@ -826,9 +862,9 @@ MIKMODAPI BOOL MikMod_InitThreads(void) result=0; } else result=1; -#elif defined(WIN32) - if((!(_mm_mutex_lists=CreateMutex(NULL,FALSE,"libmikmod(lists)")))|| - (!(_mm_mutex_vars=CreateMutex(NULL,FALSE,"libmikmod(vars)")))) +#elif defined(_WIN32) + if((!(_mm_mutex_lists=CreateMutex(NULL,FALSE,TEXT("libmikmod(lists)"))))|| + (!(_mm_mutex_vars=CreateMutex(NULL,FALSE,TEXT("libmikmod(vars)"))))) result=0; else result=1; @@ -851,24 +887,24 @@ MIKMODAPI void MikMod_Lock(void) /*========== Parameter extraction helper */ -CHAR *MD_GetAtom(CHAR *atomname,CHAR *cmdline,BOOL implicit) +CHAR *MD_GetAtom(const CHAR *atomname, const CHAR *cmdline, BOOL implicit) { CHAR *ret=NULL; if(cmdline) { - CHAR *buf=strstr(cmdline,atomname); + const CHAR *buf=strstr(cmdline,atomname); if((buf)&&((buf==cmdline)||(*(buf-1)==','))) { - CHAR *ptr=buf+strlen(atomname); + const CHAR *ptr=buf+strlen(atomname); if(*ptr=='=') { for(buf=++ptr;(*ptr)&&((*ptr)!=',');ptr++); - ret=MikMod_malloc((1+ptr-buf)*sizeof(CHAR)); + ret=(CHAR *)MikMod_malloc((1+ptr-buf)*sizeof(CHAR)); if(ret) strncpy(ret,buf,ptr-buf); } else if((*ptr==',')||(!*ptr)) { if(implicit) { - ret=MikMod_malloc((1+ptr-buf)*sizeof(CHAR)); + ret=(CHAR *)MikMod_malloc((1+ptr-buf)*sizeof(CHAR)); if(ret) strncpy(ret,buf,ptr-buf); } @@ -878,7 +914,7 @@ CHAR *MD_GetAtom(CHAR *atomname,CHAR *cmdline,BOOL implicit) return ret; } -#if defined unix || (defined __APPLE__ && defined __MACH__) +#if (MIKMOD_UNIX) /*========== Posix helper functions */ @@ -887,7 +923,7 @@ CHAR *MD_GetAtom(CHAR *atomname,CHAR *cmdline,BOOL implicit) reasonable. Returns 1 if it is safe to rewrite the file, 0 otherwise. The goal is to prevent a setuid root libmikmod application from overriding files like /etc/passwd with digital sound... */ -BOOL MD_Access(CHAR *filename) +BOOL MD_Access(const CHAR * filename) { struct stat buf; @@ -904,12 +940,12 @@ BOOL MD_Access(CHAR *filename) } else if(!(buf.st_mode&S_IWOTH)) return 0; } - + return 1; } /* Drop all root privileges we might have */ -BOOL MD_DropPrivileges(void) +int MD_DropPrivileges(void) { if(!geteuid()) { if(getuid()) { @@ -932,4 +968,4 @@ BOOL MD_DropPrivileges(void) #endif -/* ex:set ts=4: */ +/* ex:set ts=8: */ diff --git a/sc2/src/libs/mikmod/mdulaw.c b/sc2/src/libs/mikmod/mdulaw.c new file mode 100644 index 000000000..7cee49bda --- /dev/null +++ b/sc2/src/libs/mikmod/mdulaw.c @@ -0,0 +1,2119 @@ +/* MikMod sound library + (c) 1998, 1999, 2002 Miodrag Vallat and others - see file AUTHORS for + complete list. + + This library is free software; you can redistribute it and/or modify + 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 + 02111-1307, USA. +*/ + +/*============================================================================== + + $Id$ + + Mu-law routines + +==============================================================================*/ + +/* + The contents of this file are derived from the files libst.h and raw.c from + an old version of the sox (SOund eXchange) package written by Lance Norskog + and Jef Poskanzer. + The following copyright notice applies: + + ** Copyright (C) 1989 by Jef Poskanzer. + ** + ** Permission to use, copy, modify, and distribute this software and its + ** documentation for any purpose and without fee is hereby granted, provided + ** that the above copyright notice appear in all copies and that both that + ** copyright notice and this permission notice appear in supporting + ** documentation. This software is provided "as is" without express or + ** implied warranty. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "mikmod_internals.h" + +static const unsigned char ulaw_comp_table[16384] = { + 0xff, 0xfe, 0xfe, 0xfd, 0xfd, 0xfc, 0xfc, 0xfb, + 0xfb, 0xfa, 0xfa, 0xf9, 0xf9, 0xf8, 0xf8, 0xf7, + 0xf7, 0xf6, 0xf6, 0xf5, 0xf5, 0xf4, 0xf4, 0xf3, + 0xf3, 0xf2, 0xf2, 0xf1, 0xf1, 0xf0, 0xf0, 0xef, + 0xef, 0xef, 0xef, 0xee, 0xee, 0xee, 0xee, 0xed, + 0xed, 0xed, 0xed, 0xec, 0xec, 0xec, 0xec, 0xeb, + 0xeb, 0xeb, 0xeb, 0xea, 0xea, 0xea, 0xea, 0xe9, + 0xe9, 0xe9, 0xe9, 0xe8, 0xe8, 0xe8, 0xe8, 0xe7, + 0xe7, 0xe7, 0xe7, 0xe6, 0xe6, 0xe6, 0xe6, 0xe5, + 0xe5, 0xe5, 0xe5, 0xe4, 0xe4, 0xe4, 0xe4, 0xe3, + 0xe3, 0xe3, 0xe3, 0xe2, 0xe2, 0xe2, 0xe2, 0xe1, + 0xe1, 0xe1, 0xe1, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, + 0xdf, 0xdf, 0xdf, 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0xad, + 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, + 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, + 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, + 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, + 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, + 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, + 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xac, + 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, + 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, + 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, + 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, + 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, + 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, + 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, + 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0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 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90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a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, + 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, + 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, + 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, + 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, + 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, + 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 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 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, + 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, + 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0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 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, + 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, + 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, + 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, + 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, + 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, + 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, + 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, + 0x28, 0x28, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, + 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, + 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, + 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, + 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, + 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, + 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, + 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, + 0x29, 0x29, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, + 0x2a, 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30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, + 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, + 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, + 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, + 0x31, 0x31, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, + 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, + 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, + 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, + 0x32, 0x32, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, + 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, + 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, + 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, + 0x33, 0x33, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, + 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, + 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, + 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, + 0x34, 0x34, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, + 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, + 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, + 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, + 0x35, 0x35, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, + 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, + 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, + 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, + 0x37, 0x37, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, + 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, + 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, + 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, + 0x38, 0x38, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, + 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, + 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, + 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, + 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, + 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, + 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, + 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, + 0x3a, 0x3a, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, + 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, + 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, + 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, + 0x3b, 0x3b, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, + 0x3c, 0x3c, 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43, 0x43, 0x43, 0x43, 0x43, 0x43, + 0x43, 0x43, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, + 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, + 0x45, 0x45, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, + 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, + 0x47, 0x47, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, + 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, + 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, + 0x49, 0x49, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, + 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, + 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, + 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, + 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, + 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, + 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, + 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, + 0x4d, 0x4d, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, + 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, + 0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, + 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, + 0x4f, 0x4f, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, + 0x50, 0x50, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, + 0x51, 0x51, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, + 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, + 0x53, 0x53, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, + 0x54, 0x54, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, + 0x56, 0x56, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, + 0x57, 0x57, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, + 0x58, 0x58, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, + 0x59, 0x59, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, + 0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, + 0x5b, 0x5b, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, + 0x5c, 0x5c, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, + 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, + 0x5e, 0x5e, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, + 0x5f, 0x5f, 0x60, 0x60, 0x60, 0x60, 0x61, 0x61, + 0x61, 0x61, 0x62, 0x62, 0x62, 0x62, 0x63, 0x63, + 0x63, 0x63, 0x64, 0x64, 0x64, 0x64, 0x65, 0x65, + 0x65, 0x65, 0x66, 0x66, 0x66, 0x66, 0x67, 0x67, + 0x67, 0x67, 0x68, 0x68, 0x68, 0x68, 0x69, 0x69, + 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b, + 0x6b, 0x6b, 0x6c, 0x6c, 0x6c, 0x6c, 0x6d, 0x6d, + 0x6d, 0x6d, 0x6e, 0x6e, 0x6e, 0x6e, 0x6f, 0x6f, + 0x6f, 0x6f, 0x70, 0x70, 0x71, 0x71, 0x72, 0x72, + 0x73, 0x73, 0x74, 0x74, 0x75, 0x75, 0x76, 0x76, + 0x77, 0x77, 0x78, 0x78, 0x79, 0x79, 0x7a, 0x7a, + 0x7b, 0x7b, 0x7c, 0x7c, 0x7d, 0x7d, 0x7e, 0x7e +}; + +#define st_linear_to_ulaw(x) ulaw_comp_table[(x / 4) & 0x3fff] + +/* convert unsigned linear data from Mixer_WriteBytes() to ulaw */ +void unsignedtoulaw(char *buf, int nsamp) +{ + while (nsamp--) { + register long datum = (long)*((unsigned char *)buf); + + datum ^= 128; /* convert to signed */ + datum <<= 8; + /* round up to 12 bits of data */ + datum += 0x8; /* + 0b1000 */ + datum = st_linear_to_ulaw(datum); + *buf++ = (char)datum; + } +} + +/* ex:set ts=4: */ diff --git a/sc2/src/libs/mikmod/mikmod.h b/sc2/src/libs/mikmod/mikmod.h index 1fd5322de..d7dde79c9 100644 --- a/sc2/src/libs/mikmod/mikmod.h +++ b/sc2/src/libs/mikmod/mikmod.h @@ -1,33 +1,31 @@ -/* MikMod sound library - (c) 1998, 1999, 2000 Miodrag Vallat and others - see file AUTHORS - for complete list. +/* MikMod sound library + (c) 1998-2014 Miodrag Vallat and others - see the AUTHORS file + for complete list. - This library is free software; you can redistribute it and/or modify - 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 - 02111-1307, USA. + This library is free software; you can redistribute it and/or modify + 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 + 02111-1307, USA. */ /*============================================================================== - $Id$ - MikMod sound library include file -==============================================================================*/ + ==============================================================================*/ -#ifndef LIBS_MIKMOD_MIKMOD_H_ -#define LIBS_MIKMOD_MIKMOD_H_ +#ifndef _MIKMOD_H_ +#define _MIKMOD_H_ #include #include @@ -36,170 +34,237 @@ extern "C" { #endif -/* - * ========== Compiler magic for shared libraries - */ - -#if defined(LIBMIKMOD_DLL) -#if defined(DLL_EXPORTS) -#define MIKMODAPI __declspec(dllexport) -#else -#define MIKMODAPI __declspec(dllimport) -#endif -#else +/* UQM MOD: Internal mikmod never has to worry about shared library symbol visibility. */ #define MIKMODAPI -#endif /* - * ========== Library version + * ========== Library version */ #define LIBMIKMOD_VERSION_MAJOR 3L -#define LIBMIKMOD_VERSION_MINOR 1L -#define LIBMIKMOD_REVISION 12L +#define LIBMIKMOD_VERSION_MINOR 3L +#define LIBMIKMOD_REVISION 11L #define LIBMIKMOD_VERSION \ - ((LIBMIKMOD_VERSION_MAJOR<<16)| \ - (LIBMIKMOD_VERSION_MINOR<< 8)| \ - (LIBMIKMOD_REVISION)) + ((LIBMIKMOD_VERSION_MAJOR<<16)| \ + (LIBMIKMOD_VERSION_MINOR<< 8)| \ + (LIBMIKMOD_REVISION)) MIKMODAPI extern long MikMod_GetVersion(void); /* - * ========== Platform independent-type definitions + * ========== Dependency platform headers */ -#if defined(WIN32)||defined(WIN64) +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include #include #include +#define _MIKMOD_WIN32 #endif -#if defined(__OS2__)||defined(__EMX__) +#if defined(__DJGPP__) || defined(MSDOS) || defined(__MSDOS__) || defined(__DOS__) +#define _MIKMOD_DOS +#endif + +#if defined(__OS2__) || defined(__EMX__) #define INCL_DOSSEMAPHORES #include -#else -typedef char CHAR; +#include +#define _MIKMOD_OS2 #endif - - -#if defined(__arch64__) || defined(__alpha) || defined(__x86_64) \ - || defined(__powerpc64__) || defined(_M_IA64) || defined(_M_AMD64) -/* 64 bit architectures */ - -typedef signed char SBYTE; /* 1 byte, signed */ -typedef unsigned char UBYTE; /* 1 byte, unsigned */ -typedef signed short SWORD; /* 2 bytes, signed */ -typedef unsigned short UWORD; /* 2 bytes, unsigned */ -typedef signed int SLONG; /* 4 bytes, signed */ -typedef unsigned int ULONG; /* 4 bytes, unsigned */ -typedef int BOOL; /* 0=false, <>0 true */ - -#else -/* 32 bit architectures */ - -typedef signed char SBYTE; /* 1 byte, signed */ -typedef unsigned char UBYTE; /* 1 byte, unsigned */ -typedef signed short SWORD; /* 2 bytes, signed */ -typedef unsigned short UWORD; /* 2 bytes, unsigned */ -typedef signed long SLONG; /* 4 bytes, signed */ -#if !defined(__OS2__)&&!defined(__EMX__)&&!defined(WIN32) -typedef unsigned long ULONG; /* 4 bytes, unsigned */ -typedef int BOOL; /* 0=false, <>0 true */ -#endif +#if defined(__MORPHOS__) || defined(__AROS__) || defined(_AMIGA) || defined(__AMIGA__) || defined(__amigaos__) || defined(AMIGAOS) +#include +#define _MIKMOD_AMIGA #endif /* - * ========== Error codes + * ========== Platform independent-type definitions + * (pain when it comes to cross-platform maintenance..) + */ + +#if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32)) +typedef char CHAR; +#endif + +/* BOOL: 0=false, <>0 true -- 16 bits on Amiga, int-wide on others. */ +#if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32) || defined(_MIKMOD_AMIGA)) +typedef int BOOL; +#endif + +/* 1 byte, signed and unsigned: */ +typedef signed char SBYTE; +#ifndef _MIKMOD_AMIGA +typedef unsigned char UBYTE; +#endif + +/* 2 bytes, signed and unsigned: */ +#ifndef __LCC__ +typedef signed short int SWORD; +#endif +#if !(defined(__LCC__) || defined(_MIKMOD_AMIGA)) +typedef unsigned short int UWORD; +#endif + +/* 4 bytes, signed and unsigned: */ +#if defined(_LP64) || defined(__LP64__) || defined(__arch64__) || defined(__alpha) || defined(__x86_64) || defined(__powerpc64__) + /* 64 bit architectures: */ +typedef signed int SLONG; +#if !(defined(_WIN32) || defined(_MIKMOD_AMIGA)) +typedef unsigned int ULONG; +#endif + +#else /* 32 bit architectures: */ +typedef signed long int SLONG; +#if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32) || defined(_MIKMOD_AMIGA)) +typedef unsigned long int ULONG; +#endif +#endif + +/* make sure types are of correct sizes: */ +typedef int __mikmod_typetest [ + ( + (sizeof(SBYTE)==1) && (sizeof(UBYTE)==1) + && (sizeof(SWORD)==2) && (sizeof(UWORD)==2) + && (sizeof(SLONG)==4) && (sizeof(ULONG)==4) +#ifndef _MIKMOD_AMIGA + && (sizeof(BOOL) == sizeof(int)) +#endif + && (sizeof(CHAR) == sizeof(char)) + ) * 2 - 1 ]; + +/* + * ========== Error codes */ enum { - MMERR_OPENING_FILE = 1, - MMERR_OUT_OF_MEMORY, - MMERR_DYNAMIC_LINKING, + MMERR_OPENING_FILE = 1, + MMERR_OUT_OF_MEMORY, + MMERR_DYNAMIC_LINKING, - MMERR_SAMPLE_TOO_BIG, - MMERR_OUT_OF_HANDLES, - MMERR_UNKNOWN_WAVE_TYPE, + MMERR_SAMPLE_TOO_BIG, + MMERR_OUT_OF_HANDLES, + MMERR_UNKNOWN_WAVE_TYPE, - MMERR_LOADING_PATTERN, - MMERR_LOADING_TRACK, - MMERR_LOADING_HEADER, - MMERR_LOADING_SAMPLEINFO, - MMERR_NOT_A_MODULE, - MMERR_NOT_A_STREAM, - MMERR_MED_SYNTHSAMPLES, - MMERR_ITPACK_INVALID_DATA, + MMERR_LOADING_PATTERN, + MMERR_LOADING_TRACK, + MMERR_LOADING_HEADER, + MMERR_LOADING_SAMPLEINFO, + MMERR_NOT_A_MODULE, + MMERR_NOT_A_STREAM, + MMERR_MED_SYNTHSAMPLES, + MMERR_ITPACK_INVALID_DATA, - MMERR_DETECTING_DEVICE, - MMERR_INVALID_DEVICE, - MMERR_INITIALIZING_MIXER, - MMERR_OPENING_AUDIO, - MMERR_8BIT_ONLY, - MMERR_16BIT_ONLY, - MMERR_STEREO_ONLY, - MMERR_ULAW, - MMERR_NON_BLOCK, + MMERR_DETECTING_DEVICE, + MMERR_INVALID_DEVICE, + MMERR_INITIALIZING_MIXER, + MMERR_OPENING_AUDIO, + MMERR_8BIT_ONLY, + MMERR_16BIT_ONLY, + MMERR_STEREO_ONLY, + MMERR_ULAW, + MMERR_NON_BLOCK, - MMERR_AF_AUDIO_PORT, + MMERR_AF_AUDIO_PORT, - MMERR_AIX_CONFIG_INIT, - MMERR_AIX_CONFIG_CONTROL, - MMERR_AIX_CONFIG_START, + MMERR_AIX_CONFIG_INIT, + MMERR_AIX_CONFIG_CONTROL, + MMERR_AIX_CONFIG_START, - MMERR_GUS_SETTINGS, - MMERR_GUS_RESET, - MMERR_GUS_TIMER, + MMERR_GUS_SETTINGS, + MMERR_GUS_RESET, + MMERR_GUS_TIMER, - MMERR_HP_SETSAMPLESIZE, - MMERR_HP_SETSPEED, - MMERR_HP_CHANNELS, - MMERR_HP_AUDIO_OUTPUT, - MMERR_HP_AUDIO_DESC, - MMERR_HP_BUFFERSIZE, + MMERR_HP_SETSAMPLESIZE, + MMERR_HP_SETSPEED, + MMERR_HP_CHANNELS, + MMERR_HP_AUDIO_OUTPUT, + MMERR_HP_AUDIO_DESC, + MMERR_HP_BUFFERSIZE, - MMERR_OSS_SETFRAGMENT, - MMERR_OSS_SETSAMPLESIZE, - MMERR_OSS_SETSTEREO, - MMERR_OSS_SETSPEED, + MMERR_OSS_SETFRAGMENT, + MMERR_OSS_SETSAMPLESIZE, + MMERR_OSS_SETSTEREO, + MMERR_OSS_SETSPEED, - MMERR_SGI_SPEED, - MMERR_SGI_16BIT, - MMERR_SGI_8BIT, - MMERR_SGI_STEREO, - MMERR_SGI_MONO, + MMERR_SGI_SPEED, + MMERR_SGI_16BIT, + MMERR_SGI_8BIT, + MMERR_SGI_STEREO, + MMERR_SGI_MONO, - MMERR_SUN_INIT, + MMERR_SUN_INIT, - MMERR_OS2_MIXSETUP, - MMERR_OS2_SEMAPHORE, - MMERR_OS2_TIMER, - MMERR_OS2_THREAD, + MMERR_OS2_MIXSETUP, + MMERR_OS2_SEMAPHORE, + MMERR_OS2_TIMER, + MMERR_OS2_THREAD, - MMERR_DS_PRIORITY, - MMERR_DS_BUFFER, - MMERR_DS_FORMAT, - MMERR_DS_NOTIFY, - MMERR_DS_EVENT, - MMERR_DS_THREAD, - MMERR_DS_UPDATE, + MMERR_DS_PRIORITY, + MMERR_DS_BUFFER, + MMERR_DS_FORMAT, + MMERR_DS_NOTIFY, + MMERR_DS_EVENT, + MMERR_DS_THREAD, + MMERR_DS_UPDATE, - MMERR_WINMM_HANDLE, - MMERR_WINMM_ALLOCATED, - MMERR_WINMM_DEVICEID, - MMERR_WINMM_FORMAT, - MMERR_WINMM_UNKNOWN, + MMERR_WINMM_HANDLE, + MMERR_WINMM_ALLOCATED, + MMERR_WINMM_DEVICEID, + MMERR_WINMM_FORMAT, + MMERR_WINMM_UNKNOWN, - MMERR_MAC_SPEED, - MMERR_MAC_START, + MMERR_MAC_SPEED, + MMERR_MAC_START, - MMERR_MAX + MMERR_OSX_UNKNOWN_DEVICE, + MMERR_OSX_BAD_PROPERTY, + MMERR_OSX_UNSUPPORTED_FORMAT, + MMERR_OSX_SET_STEREO, + MMERR_OSX_BUFFER_ALLOC, + MMERR_OSX_ADD_IO_PROC, + MMERR_OSX_DEVICE_START, + MMERR_OSX_PTHREAD, + + MMERR_DOSWSS_STARTDMA, + MMERR_DOSSB_STARTDMA, + + MMERR_NO_FLOAT32,/* should actually be after MMERR_ULAW or something */ + + MMERR_OPENAL_CREATECTX, + MMERR_OPENAL_CTXCURRENT, + MMERR_OPENAL_GENBUFFERS, + MMERR_OPENAL_GENSOURCES, + MMERR_OPENAL_SOURCE, + MMERR_OPENAL_QUEUEBUFFERS, + MMERR_OPENAL_UNQUEUEBUFFERS, + MMERR_OPENAL_BUFFERDATA, + MMERR_OPENAL_GETSOURCE, + MMERR_OPENAL_SOURCEPLAY, + MMERR_OPENAL_SOURCESTOP, + + MMERR_ALSA_NOCONFIG, + MMERR_ALSA_SETPARAMS, + MMERR_ALSA_SETFORMAT, + MMERR_ALSA_SETRATE, + MMERR_ALSA_SETCHANNELS, + MMERR_ALSA_BUFFERSIZE, + MMERR_ALSA_PCM_START, + MMERR_ALSA_PCM_WRITE, + MMERR_ALSA_PCM_RECOVER, + + MMERR_SNDIO_SETPARAMS, + MMERR_SNDIO_BADPARAMS, + + MMERR_MAX }; /* - * ========== Error handling + * ========== Error handling */ typedef void (MikMod_handler)(void); @@ -207,12 +272,12 @@ typedef MikMod_handler *MikMod_handler_t; MIKMODAPI extern int MikMod_errno; MIKMODAPI extern BOOL MikMod_critical; -MIKMODAPI extern char *MikMod_strerror(int); +MIKMODAPI extern const char *MikMod_strerror(int); MIKMODAPI extern MikMod_handler_t MikMod_RegisterErrorHandler(MikMod_handler_t); /* - * ========== Library initialization and core functions + * ========== Library initialization and core functions */ struct MDRIVER; @@ -221,14 +286,15 @@ MIKMODAPI extern void MikMod_RegisterAllDrivers(void); MIKMODAPI extern CHAR* MikMod_InfoDriver(void); MIKMODAPI extern void MikMod_RegisterDriver(struct MDRIVER*); -MIKMODAPI extern int MikMod_DriverFromAlias(CHAR*); +MIKMODAPI extern int MikMod_DriverFromAlias(const CHAR*); +MIKMODAPI extern struct MDRIVER *MikMod_DriverByOrdinal(int); -MIKMODAPI extern BOOL MikMod_Init(CHAR*); +MIKMODAPI extern int MikMod_Init(const CHAR*); MIKMODAPI extern void MikMod_Exit(void); -MIKMODAPI extern BOOL MikMod_Reset(CHAR*); -MIKMODAPI extern BOOL MikMod_SetNumVoices(int,int); +MIKMODAPI extern int MikMod_Reset(const CHAR*); +MIKMODAPI extern int MikMod_SetNumVoices(int,int); MIKMODAPI extern BOOL MikMod_Active(void); -MIKMODAPI extern BOOL MikMod_EnableOutput(void); +MIKMODAPI extern int MikMod_EnableOutput(void); MIKMODAPI extern void MikMod_DisableOutput(void); MIKMODAPI extern void MikMod_Update(void); @@ -237,33 +303,34 @@ MIKMODAPI extern void MikMod_Lock(void); MIKMODAPI extern void MikMod_Unlock(void); MIKMODAPI extern void* MikMod_malloc(size_t); -MIKMODAPI extern void* MikMod_realloc(void *, size_t); MIKMODAPI extern void* MikMod_calloc(size_t,size_t); -MIKMODAPI extern void MikMod_free(void *); +MIKMODAPI extern void* MikMod_realloc(void*,size_t); +MIKMODAPI extern CHAR* MikMod_strdup(const CHAR*); +MIKMODAPI extern void MikMod_free(void*); /* frees if ptr != NULL */ /* - * ========== Reader, Writer + * ========== Reader, Writer */ typedef struct MREADER { - BOOL (*Seek)(struct MREADER*,long,int); - long (*Tell)(struct MREADER*); - BOOL (*Read)(struct MREADER*,void*,size_t); - int (*Get)(struct MREADER*); - BOOL (*Eof)(struct MREADER*); - long iobase; - long prev_iobase; + int (*Seek)(struct MREADER*,long,int); + long (*Tell)(struct MREADER*); + BOOL (*Read)(struct MREADER*,void*,size_t); + int (*Get)(struct MREADER*); + BOOL (*Eof)(struct MREADER*); + long iobase; + long prev_iobase; } MREADER; typedef struct MWRITER { - BOOL (*Seek)(struct MWRITER*,long,int); - long (*Tell)(struct MWRITER*); - BOOL (*Write)(struct MWRITER*,void*,size_t); - BOOL (*Put)(struct MWRITER*,int); + int (*Seek)(struct MWRITER*, long, int); + long (*Tell)(struct MWRITER*); + BOOL (*Write)(struct MWRITER*, const void*, size_t); + int (*Put)(struct MWRITER*, int); } MWRITER; /* - * ========== Samples + * ========== Samples */ /* Sample playback should not be interrupted */ @@ -275,9 +342,9 @@ typedef struct MWRITER { #define SF_SIGNED 0x0004 #define SF_BIG_ENDIAN 0x0008 #define SF_DELTA 0x0010 -#define SF_ITPACKED 0x0020 +#define SF_ITPACKED 0x0020 -#define SF_FORMATMASK 0x003F +#define SF_FORMATMASK 0x003F /* General Playback flags */ @@ -286,54 +353,61 @@ typedef struct MWRITER { #define SF_REVERSE 0x0400 #define SF_SUSTAIN 0x0800 -#define SF_PLAYBACKMASK 0x0C00 +#define SF_PLAYBACKMASK 0x0C00 /* Module-only Playback Flags */ -#define SF_OWNPAN 0x1000 +#define SF_OWNPAN 0x1000 #define SF_UST_LOOP 0x2000 -#define SF_EXTRAPLAYBACKMASK 0x3000 +#define SF_EXTRAPLAYBACKMASK 0x3000 /* Panning constants */ -#define PAN_LEFT 0 -#define PAN_HALFLEFT 64 -#define PAN_CENTER 128 -#define PAN_HALFRIGHT 192 -#define PAN_RIGHT 255 -#define PAN_SURROUND 512 /* panning value for Dolby Surround */ +#define PAN_LEFT 0 +#define PAN_HALFLEFT 64 +#define PAN_CENTER 128 +#define PAN_HALFRIGHT 192 +#define PAN_RIGHT 255 +#define PAN_SURROUND 512 /* panning value for Dolby Surround */ typedef struct SAMPLE { - SWORD panning; /* panning (0-255 or PAN_SURROUND) */ - ULONG speed; /* Base playing speed/frequency of note */ - UBYTE volume; /* volume 0-64 */ - UWORD inflags; /* sample format on disk */ - UWORD flags; /* sample format in memory */ - ULONG length; /* length of sample (in samples!) */ - ULONG loopstart; /* repeat position (relative to start, in samples) */ - ULONG loopend; /* repeat end */ - ULONG susbegin; /* sustain loop begin (in samples) \ Not Supported */ - ULONG susend; /* sustain loop end / Yet! */ + SWORD panning; /* panning (0-255 or PAN_SURROUND) */ + ULONG speed; /* Base playing speed/frequency of note */ + UBYTE volume; /* volume 0-64 */ + UWORD inflags; /* sample format on disk */ + UWORD flags; /* sample format in memory */ + ULONG length; /* length of sample (in samples!) */ + ULONG loopstart; /* repeat position (relative to start, in samples) */ + ULONG loopend; /* repeat end */ + ULONG susbegin; /* sustain loop begin (in samples) \ Not Supported */ + ULONG susend; /* sustain loop end / Yet! */ - /* Variables used by the module player only! (ignored for sound effects) */ - UBYTE globvol; /* global volume */ - UBYTE vibflags; /* autovibrato flag stuffs */ - UBYTE vibtype; /* Vibratos moved from INSTRUMENT to SAMPLE */ - UBYTE vibsweep; - UBYTE vibdepth; - UBYTE vibrate; - CHAR* samplename; /* name of the sample */ + /* Variables used by the module player only! (ignored for sound effects) */ + UBYTE globvol; /* global volume */ + UBYTE vibflags; /* autovibrato flag stuffs */ + UBYTE vibtype; /* Vibratos moved from INSTRUMENT to SAMPLE */ + UBYTE vibsweep; + UBYTE vibdepth; + UBYTE vibrate; + CHAR* samplename; /* name of the sample */ - /* Values used internally only */ - UWORD avibpos; /* autovibrato pos [player use] */ - UBYTE divfactor; /* for sample scaling, maintains proper period slides */ - ULONG seekpos; /* seek position in file */ - SWORD handle; /* sample handle used by individual drivers */ + /* Values used internally only */ + UWORD avibpos; /* autovibrato pos [player use] */ + UBYTE divfactor; /* for sample scaling, maintains proper period slides */ + ULONG seekpos; /* seek position in file */ + SWORD handle; /* sample handle used by individual drivers */ + void (*onfree)(void *ctx); /* called from Sample_Free if not NULL */ + void *ctx; /* context passed to previous function*/ } SAMPLE; /* Sample functions */ -MIKMODAPI extern SAMPLE *Sample_Load(CHAR*); +MIKMODAPI extern SAMPLE *Sample_LoadRaw(const CHAR *,ULONG rate, ULONG channel, ULONG flags); +MIKMODAPI extern SAMPLE *Sample_LoadRawFP(FILE *fp,ULONG rate,ULONG channel, ULONG flags); +MIKMODAPI extern SAMPLE *Sample_LoadRawMem(const char *buf, int len, ULONG rate, ULONG channel, ULONG flags); +MIKMODAPI extern SAMPLE *Sample_LoadRawGeneric(MREADER*reader,ULONG rate, ULONG channel, ULONG flags); + +MIKMODAPI extern SAMPLE *Sample_Load(const CHAR*); MIKMODAPI extern SAMPLE *Sample_LoadFP(FILE*); MIKMODAPI extern SAMPLE *Sample_LoadMem(const char *buf, int len); MIKMODAPI extern SAMPLE *Sample_LoadGeneric(MREADER*); @@ -353,12 +427,12 @@ MIKMODAPI extern SLONG Voice_GetPosition(SBYTE); MIKMODAPI extern ULONG Voice_RealVolume(SBYTE); /* - * ========== Internal module representation (UniMod) + * ========== Internal module representation (UniMod) */ /* - Instrument definition - for information only, the only field which may be - of use in user programs is the name field + Instrument definition - for information only, the only field which may be + of use in user programs is the name field */ /* Instrument note count */ @@ -366,8 +440,8 @@ MIKMODAPI extern ULONG Voice_RealVolume(SBYTE); /* Envelope point */ typedef struct ENVPT { - SWORD pos; - SWORD val; + SWORD pos; + SWORD val; } ENVPT; /* Envelope point count */ @@ -375,143 +449,156 @@ typedef struct ENVPT { /* Instrument structure */ typedef struct INSTRUMENT { - CHAR* insname; + CHAR* insname; - UBYTE flags; - UWORD samplenumber[INSTNOTES]; - UBYTE samplenote[INSTNOTES]; + UBYTE flags; + UWORD samplenumber[INSTNOTES]; + UBYTE samplenote[INSTNOTES]; - UBYTE nnatype; - UBYTE dca; /* duplicate check action */ - UBYTE dct; /* duplicate check type */ - UBYTE globvol; - UWORD volfade; - SWORD panning; /* instrument-based panning var */ + UBYTE nnatype; + UBYTE dca; /* duplicate check action */ + UBYTE dct; /* duplicate check type */ + UBYTE globvol; + UWORD volfade; + SWORD panning; /* instrument-based panning var */ - UBYTE pitpansep; /* pitch pan separation (0 to 255) */ - UBYTE pitpancenter; /* pitch pan center (0 to 119) */ - UBYTE rvolvar; /* random volume varations (0 - 100%) */ - UBYTE rpanvar; /* random panning varations (0 - 100%) */ + UBYTE pitpansep; /* pitch pan separation (0 to 255) */ + UBYTE pitpancenter; /* pitch pan center (0 to 119) */ + UBYTE rvolvar; /* random volume varations (0 - 100%) */ + UBYTE rpanvar; /* random panning varations (0 - 100%) */ - /* volume envelope */ - UBYTE volflg; /* bit 0: on 1: sustain 2: loop */ - UBYTE volpts; - UBYTE volsusbeg; - UBYTE volsusend; - UBYTE volbeg; - UBYTE volend; - ENVPT volenv[ENVPOINTS]; - /* panning envelope */ - UBYTE panflg; /* bit 0: on 1: sustain 2: loop */ - UBYTE panpts; - UBYTE pansusbeg; - UBYTE pansusend; - UBYTE panbeg; - UBYTE panend; - ENVPT panenv[ENVPOINTS]; - /* pitch envelope */ - UBYTE pitflg; /* bit 0: on 1: sustain 2: loop */ - UBYTE pitpts; - UBYTE pitsusbeg; - UBYTE pitsusend; - UBYTE pitbeg; - UBYTE pitend; - ENVPT pitenv[ENVPOINTS]; + /* volume envelope */ + UBYTE volflg; /* bit 0: on 1: sustain 2: loop */ + UBYTE volpts; + UBYTE volsusbeg; + UBYTE volsusend; + UBYTE volbeg; + UBYTE volend; + ENVPT volenv[ENVPOINTS]; + /* panning envelope */ + UBYTE panflg; /* bit 0: on 1: sustain 2: loop */ + UBYTE panpts; + UBYTE pansusbeg; + UBYTE pansusend; + UBYTE panbeg; + UBYTE panend; + ENVPT panenv[ENVPOINTS]; + /* pitch envelope */ + UBYTE pitflg; /* bit 0: on 1: sustain 2: loop */ + UBYTE pitpts; + UBYTE pitsusbeg; + UBYTE pitsusend; + UBYTE pitbeg; + UBYTE pitend; + ENVPT pitenv[ENVPOINTS]; } INSTRUMENT; struct MP_CONTROL; struct MP_VOICE; /* - Module definition + Module definition */ /* maximum master channels supported */ -#define UF_MAXCHAN 64 +#define UF_MAXCHAN 64 /* Module flags */ -#define UF_XMPERIODS 0x0001 /* XM periods / finetuning */ -#define UF_LINEAR 0x0002 /* LINEAR periods (UF_XMPERIODS must be set) */ -#define UF_INST 0x0004 /* Instruments are used */ -#define UF_NNA 0x0008 /* IT: NNA used, set numvoices rather - than numchn */ -#define UF_S3MSLIDES 0x0010 /* uses old S3M volume slides */ -#define UF_BGSLIDES 0x0020 /* continue volume slides in the background */ -#define UF_HIGHBPM 0x0040 /* MED: can use >255 bpm */ -#define UF_NOWRAP 0x0080 /* XM-type (i.e. illogical) pattern break - semantics */ -#define UF_ARPMEM 0x0100 /* IT: need arpeggio memory */ -#define UF_FT2QUIRKS 0x0200 /* emulate some FT2 replay quirks */ -#define UF_PANNING 0x0400 /* module uses panning effects or have - non-tracker default initial panning */ +#define UF_XMPERIODS 0x0001 /* XM periods / finetuning */ +#define UF_LINEAR 0x0002 /* LINEAR periods (UF_XMPERIODS must be set) */ +#define UF_INST 0x0004 /* Instruments are used */ +#define UF_NNA 0x0008 /* IT: NNA used, set numvoices rather + than numchn */ +#define UF_S3MSLIDES 0x0010 /* uses old S3M volume slides */ +#define UF_BGSLIDES 0x0020 /* continue volume slides in the background */ +#define UF_HIGHBPM 0x0040 /* MED: can use >255 bpm */ +#define UF_NOWRAP 0x0080 /* XM-type (i.e. illogical) pattern break + semantics */ +#define UF_ARPMEM 0x0100 /* IT: need arpeggio memory */ +#define UF_FT2QUIRKS 0x0200 /* emulate some FT2 replay quirks */ +#define UF_PANNING 0x0400 /* module uses panning effects or have + non-tracker default initial panning */ typedef struct MODULE { - /* general module information */ - CHAR* songname; /* name of the song */ - CHAR* modtype; /* string type of module loaded */ - CHAR* comment; /* module comments */ + /* general module information */ + CHAR* songname; /* name of the song */ + CHAR* modtype; /* string type of module loaded */ + CHAR* comment; /* module comments */ - UWORD flags; /* See module flags above */ - UBYTE numchn; /* number of module channels */ - UBYTE numvoices; /* max # voices used for full NNA playback */ - UWORD numpos; /* number of positions in this song */ - UWORD numpat; /* number of patterns in this song */ - UWORD numins; /* number of instruments */ - UWORD numsmp; /* number of samples */ -struct INSTRUMENT* instruments; /* all instruments */ -struct SAMPLE* samples; /* all samples */ - UBYTE realchn; /* real number of channels used */ - UBYTE totalchn; /* total number of channels used (incl NNAs) */ + UWORD flags; /* See module flags above */ + UBYTE numchn; /* number of module channels */ + UBYTE numvoices; /* max # voices used for full NNA playback */ + UWORD numpos; /* number of positions in this song */ + UWORD numpat; /* number of patterns in this song */ + UWORD numins; /* number of instruments */ + UWORD numsmp; /* number of samples */ - /* playback settings */ - UWORD reppos; /* restart position */ - UBYTE initspeed; /* initial song speed */ - UWORD inittempo; /* initial song tempo */ - UBYTE initvolume; /* initial global volume (0 - 128) */ - UWORD panning[UF_MAXCHAN]; /* panning positions */ - UBYTE chanvol[UF_MAXCHAN]; /* channel positions */ - UWORD bpm; /* current beats-per-minute speed */ - UWORD sngspd; /* current song speed */ - SWORD volume; /* song volume (0-128) (or user volume) */ + struct INSTRUMENT* instruments; /* all instruments */ + struct SAMPLE* samples; /* all samples */ - BOOL extspd; /* extended speed flag (default enabled) */ - BOOL panflag; /* panning flag (default enabled) */ - BOOL wrap; /* wrap module ? (default disabled) */ - BOOL loop; /* allow module to loop ? (default enabled) */ - BOOL fadeout; /* volume fade out during last pattern */ + UBYTE realchn; /* real number of channels used */ + UBYTE totalchn; /* total number of channels used (incl NNAs) */ - UWORD patpos; /* current row number */ - SWORD sngpos; /* current song position */ - ULONG sngtime; /* current song time in 2^-10 seconds */ + /* playback settings */ + UWORD reppos; /* restart position */ + UBYTE initspeed; /* initial song speed */ + UWORD inittempo; /* initial song tempo */ + UBYTE initvolume; /* initial global volume (0 - 128) */ + UWORD panning[UF_MAXCHAN]; /* panning positions */ + UBYTE chanvol[UF_MAXCHAN]; /* channel positions */ + UWORD bpm; /* current beats-per-minute speed */ + UWORD sngspd; /* current song speed */ + SWORD volume; /* song volume (0-128) (or user volume) */ - SWORD relspd; /* relative speed factor */ + BOOL extspd; /* extended speed flag (default enabled) */ + BOOL panflag; /* panning flag (default enabled) */ + BOOL wrap; /* wrap module ? (default disabled) */ + BOOL loop; /* allow module to loop ? (default enabled) */ + BOOL fadeout; /* volume fade out during last pattern */ - /* internal module representation */ - UWORD numtrk; /* number of tracks */ - UBYTE** tracks; /* array of numtrk pointers to tracks */ - UWORD* patterns; /* array of Patterns */ - UWORD* pattrows; /* array of number of rows for each pattern */ - UWORD* positions; /* all positions */ + UWORD patpos; /* current row number */ + SWORD sngpos; /* current song position */ + ULONG sngtime; /* current song time in 2^-10 seconds */ - BOOL forbid; /* if true, no player update! */ - UWORD numrow; /* number of rows on current pattern */ - UWORD vbtick; /* tick counter (counts from 0 to sngspd) */ - UWORD sngremainder;/* used for song time computation */ + SWORD relspd; /* relative speed factor */ -struct MP_CONTROL* control; /* Effects Channel info (size pf->numchn) */ -struct MP_VOICE* voice; /* Audio Voice information (size md_numchn) */ + /* internal module representation */ + UWORD numtrk; /* number of tracks */ + UBYTE** tracks; /* array of numtrk pointers to tracks */ + UWORD* patterns; /* array of Patterns */ + UWORD* pattrows; /* array of number of rows for each pattern */ + UWORD* positions; /* all positions */ - UBYTE globalslide; /* global volume slide rate */ - UBYTE pat_repcrazy;/* module has just looped to position -1 */ - UWORD patbrk; /* position where to start a new pattern */ - UBYTE patdly; /* patterndelay counter (command memory) */ - UBYTE patdly2; /* patterndelay counter (real one) */ - SWORD posjmp; /* flag to indicate a jump is needed... */ - UWORD bpmlimit; /* threshold to detect bpm or speed values */ + BOOL forbid; /* if true, no player update! */ + UWORD numrow; /* number of rows on current pattern */ + UWORD vbtick; /* tick counter (counts from 0 to sngspd) */ + UWORD sngremainder;/* used for song time computation */ + + struct MP_CONTROL* control; /* Effects Channel info (size pf->numchn) */ + struct MP_VOICE* voice; /* Audio Voice information (size md_numchn) */ + + UBYTE globalslide; /* global volume slide rate */ + UBYTE pat_repcrazy;/* module has just looped to position -1 */ + UWORD patbrk; /* position where to start a new pattern */ + UBYTE patdly; /* patterndelay counter (command memory) */ + UBYTE patdly2; /* patterndelay counter (real one) */ + SWORD posjmp; /* flag to indicate a jump is needed... */ + UWORD bpmlimit; /* threshold to detect bpm or speed values */ } MODULE; + +/* This structure is used to query current playing voices status */ +typedef struct VOICEINFO { + INSTRUMENT* i; /* Current channel instrument */ + SAMPLE* s; /* Current channel sample */ + SWORD panning; /* panning position */ + SBYTE volume; /* channel's "global" volume (0..64) */ + UWORD period; /* period to play the sample at */ + UBYTE kick; /* if true = sample has been restarted */ +} VOICEINFO; + /* - * ========== Module loaders + * ========== Module loaders */ struct MLOADER; @@ -522,9 +609,11 @@ MIKMODAPI extern void MikMod_RegisterLoader(struct MLOADER*); MIKMODAPI extern struct MLOADER load_669; /* 669 and Extended-669 (by Tran/Renaissance) */ MIKMODAPI extern struct MLOADER load_amf; /* DMP Advanced Module Format (by Otto Chrons) */ +MIKMODAPI extern struct MLOADER load_asy; /* ASYLUM Music Format 1.0 */ MIKMODAPI extern struct MLOADER load_dsm; /* DSIK internal module format */ MIKMODAPI extern struct MLOADER load_far; /* Farandole Composer (by Daniel Potter) */ MIKMODAPI extern struct MLOADER load_gdm; /* General DigiMusic (by Edward Schlunder) */ +MIKMODAPI extern struct MLOADER load_gt2; /* Graoumf tracker */ MIKMODAPI extern struct MLOADER load_it; /* Impulse Tracker (by Jeffrey Lim) */ MIKMODAPI extern struct MLOADER load_imf; /* Imago Orpheus (by Lutz Roeder) */ MIKMODAPI extern struct MLOADER load_med; /* Amiga MED modules (by Teijo Kinnunen) */ @@ -536,18 +625,19 @@ MIKMODAPI extern struct MLOADER load_stm; /* ScreamTracker 2 (by Future Crew) */ MIKMODAPI extern struct MLOADER load_stx; /* STMIK 0.2 (by Future Crew) */ MIKMODAPI extern struct MLOADER load_s3m; /* ScreamTracker 3 (by Future Crew) */ MIKMODAPI extern struct MLOADER load_ult; /* UltraTracker (by MAS) */ +MIKMODAPI extern struct MLOADER load_umx; /* Unreal UMX container of Epic Games */ MIKMODAPI extern struct MLOADER load_uni; /* MikMod and APlayer internal module format */ MIKMODAPI extern struct MLOADER load_xm; /* FastTracker 2 (by Triton) */ /* - * ========== Module player + * ========== Module player */ -MIKMODAPI extern MODULE* Player_Load(CHAR*,int,BOOL); +MIKMODAPI extern MODULE* Player_Load(const CHAR*,int,BOOL); MIKMODAPI extern MODULE* Player_LoadFP(FILE*,int,BOOL); MIKMODAPI extern MODULE* Player_LoadMem(const char *buffer,int len,int maxchan,BOOL curious); MIKMODAPI extern MODULE* Player_LoadGeneric(MREADER*,int,BOOL); -MIKMODAPI extern CHAR* Player_LoadTitle(CHAR*); +MIKMODAPI extern CHAR* Player_LoadTitle(const CHAR*); MIKMODAPI extern CHAR* Player_LoadTitleFP(FILE*); MIKMODAPI extern CHAR* Player_LoadTitleMem(const char *buffer,int len); MIKMODAPI extern CHAR* Player_LoadTitleGeneric(MREADER*); @@ -571,9 +661,12 @@ MIKMODAPI extern void Player_Mute(SLONG,...); MIKMODAPI extern void Player_ToggleMute(SLONG,...); MIKMODAPI extern int Player_GetChannelVoice(UBYTE); MIKMODAPI extern UWORD Player_GetChannelPeriod(UBYTE); +MIKMODAPI extern int Player_QueryVoices(UWORD numvoices, VOICEINFO *vinfo); +MIKMODAPI extern int Player_GetRow(void); +MIKMODAPI extern int Player_GetOrder(void); -typedef void (MikMod_player)(void); -typedef MikMod_player *MikMod_player_t; +typedef void (*MikMod_player_t)(void); +typedef void (*MikMod_callback_t)(unsigned char *data, size_t len); MIKMODAPI extern MikMod_player_t MikMod_RegisterPlayer(MikMod_player_t); @@ -581,17 +674,17 @@ MIKMODAPI extern MikMod_player_t MikMod_RegisterPlayer(MikMod_player_t); #define MUTE_INCLUSIVE 32001 /* - * ========== Drivers + * ========== Drivers */ enum { - MD_MUSIC = 0, - MD_SNDFX + MD_MUSIC = 0, + MD_SNDFX }; enum { - MD_HARDWARE = 0, - MD_SOFTWARE + MD_HARDWARE = 0, + MD_SOFTWARE }; /* Mixing flags */ @@ -602,47 +695,53 @@ enum { #define DMODE_SOFT_SNDFX 0x0004 /* Process sound effects via software mixer */ #define DMODE_SOFT_MUSIC 0x0008 /* Process music via software mixer */ #define DMODE_HQMIXER 0x0010 /* Use high-quality (slower) software mixer */ +#define DMODE_FLOAT 0x0020 /* enable float output */ /* These take effect immediately. */ #define DMODE_SURROUND 0x0100 /* enable surround sound */ #define DMODE_INTERP 0x0200 /* enable interpolation */ #define DMODE_REVERSE 0x0400 /* reverse stereo */ +#define DMODE_SIMDMIXER 0x0800 /* enable SIMD mixing */ +#define DMODE_NOISEREDUCTION 0x1000 /* Low pass filtering */ + struct SAMPLOAD; + typedef struct MDRIVER { -struct MDRIVER* next; - CHAR* Name; - CHAR* Version; + struct MDRIVER* next; + const CHAR* Name; + const CHAR* Version; - UBYTE HardVoiceLimit; /* Limit of hardware mixer voices */ - UBYTE SoftVoiceLimit; /* Limit of software mixer voices */ + UBYTE HardVoiceLimit; /* Limit of hardware mixer voices */ + UBYTE SoftVoiceLimit; /* Limit of software mixer voices */ - CHAR* Alias; + const CHAR* Alias; + const CHAR* CmdLineHelp; - void (*CommandLine) (CHAR*); - BOOL (*IsPresent) (void); - SWORD (*SampleLoad) (struct SAMPLOAD*,int); - void (*SampleUnload) (SWORD); - ULONG (*FreeSampleSpace) (int); - ULONG (*RealSampleLength) (int,struct SAMPLE*); - BOOL (*Init) (void); - void (*Exit) (void); - BOOL (*Reset) (void); - BOOL (*SetNumVoices) (void); - BOOL (*PlayStart) (void); - void (*PlayStop) (void); - void (*Update) (void); - void (*Pause) (void); - void (*VoiceSetVolume) (UBYTE,UWORD); - UWORD (*VoiceGetVolume) (UBYTE); - void (*VoiceSetFrequency)(UBYTE,ULONG); - ULONG (*VoiceGetFrequency)(UBYTE); - void (*VoiceSetPanning) (UBYTE,ULONG); - ULONG (*VoiceGetPanning) (UBYTE); - void (*VoicePlay) (UBYTE,SWORD,ULONG,ULONG,ULONG,ULONG,UWORD); - void (*VoiceStop) (UBYTE); - BOOL (*VoiceStopped) (UBYTE); - SLONG (*VoiceGetPosition) (UBYTE); - ULONG (*VoiceRealVolume) (UBYTE); + void (*CommandLine) (const CHAR*); + BOOL (*IsPresent) (void); + SWORD (*SampleLoad) (struct SAMPLOAD*,int); + void (*SampleUnload) (SWORD); + ULONG (*FreeSampleSpace) (int); + ULONG (*RealSampleLength) (int,struct SAMPLE*); + int (*Init) (void); + void (*Exit) (void); + int (*Reset) (void); + int (*SetNumVoices) (void); + int (*PlayStart) (void); + void (*PlayStop) (void); + void (*Update) (void); + void (*Pause) (void); + void (*VoiceSetVolume) (UBYTE,UWORD); + UWORD (*VoiceGetVolume) (UBYTE); + void (*VoiceSetFrequency)(UBYTE,ULONG); + ULONG (*VoiceGetFrequency)(UBYTE); + void (*VoiceSetPanning) (UBYTE,ULONG); + ULONG (*VoiceGetPanning) (UBYTE); + void (*VoicePlay) (UBYTE,SWORD,ULONG,ULONG,ULONG,ULONG,UWORD); + void (*VoiceStop) (UBYTE); + BOOL (*VoiceStopped) (UBYTE); + SLONG (*VoiceGetPosition) (UBYTE); + ULONG (*VoiceRealVolume) (UBYTE); } MDRIVER; /* These variables can be changed at ANY time and results will be immediate */ @@ -670,36 +769,55 @@ MIKMODAPI extern struct MDRIVER drv_pipe; /* piped output */ MIKMODAPI extern struct MDRIVER drv_raw; /* raw file disk writer [music.raw] */ MIKMODAPI extern struct MDRIVER drv_stdout; /* output to stdout */ MIKMODAPI extern struct MDRIVER drv_wav; /* RIFF WAVE file disk writer [music.wav] */ +MIKMODAPI extern struct MDRIVER drv_aiff; /* AIFF file disk writer [music.aiff] */ MIKMODAPI extern struct MDRIVER drv_ultra; /* Linux Ultrasound driver */ -MIKMODAPI extern struct MDRIVER drv_sam9407; /* Linux sam9407 driver */ +MIKMODAPI extern struct MDRIVER drv_sam9407;/* Linux sam9407 driver */ MIKMODAPI extern struct MDRIVER drv_AF; /* Dec Alpha AudioFile */ +MIKMODAPI extern struct MDRIVER drv_ahi; /* Amiga AHI */ MIKMODAPI extern struct MDRIVER drv_aix; /* AIX audio device */ MIKMODAPI extern struct MDRIVER drv_alsa; /* Advanced Linux Sound Architecture (ALSA) */ MIKMODAPI extern struct MDRIVER drv_esd; /* Enlightened sound daemon (EsounD) */ +MIKMODAPI extern struct MDRIVER drv_pulseaudio; /* PulseAudio */ MIKMODAPI extern struct MDRIVER drv_hp; /* HP-UX audio device */ +MIKMODAPI extern struct MDRIVER drv_nas; /* Network Audio System (NAS) */ MIKMODAPI extern struct MDRIVER drv_oss; /* OpenSound System (Linux,FreeBSD...) */ +MIKMODAPI extern struct MDRIVER drv_openal; /* OpenAL driver */ +MIKMODAPI extern struct MDRIVER drv_sdl; /* SDL audio driver */ MIKMODAPI extern struct MDRIVER drv_sgi; /* SGI audio library */ +MIKMODAPI extern struct MDRIVER drv_sndio; /* OpenBSD sndio */ MIKMODAPI extern struct MDRIVER drv_sun; /* Sun/NetBSD/OpenBSD audio device */ MIKMODAPI extern struct MDRIVER drv_dart; /* OS/2 Direct Audio RealTime */ MIKMODAPI extern struct MDRIVER drv_os2; /* OS/2 MMPM/2 */ MIKMODAPI extern struct MDRIVER drv_ds; /* Win32 DirectSound driver */ +MIKMODAPI extern struct MDRIVER drv_xaudio2;/* Win32 XAudio2 driver */ MIKMODAPI extern struct MDRIVER drv_win; /* Win32 multimedia API driver */ MIKMODAPI extern struct MDRIVER drv_mac; /* Macintosh Sound Manager driver */ +MIKMODAPI extern struct MDRIVER drv_osx; /* MacOS X CoreAudio Driver */ + +MIKMODAPI extern struct MDRIVER drv_dc; /* Dreamcast driver */ +MIKMODAPI extern struct MDRIVER drv_gp32; /* GP32 Sound driver */ +MIKMODAPI extern struct MDRIVER drv_psp; /* PlayStation Portable driver */ + +MIKMODAPI extern struct MDRIVER drv_wss; /* DOS WSS driver */ +MIKMODAPI extern struct MDRIVER drv_sb; /* DOS S/B driver */ + +MIKMODAPI extern struct MDRIVER drv_osles; /* OpenSL ES driver for android */ /*========== Virtual channel mixer interface (for user-supplied drivers only) */ -MIKMODAPI extern BOOL VC_Init(void); +MIKMODAPI extern int VC_Init(void); MIKMODAPI extern void VC_Exit(void); -MIKMODAPI extern BOOL VC_SetNumVoices(void); +MIKMODAPI extern void VC_SetCallback(MikMod_callback_t callback); +MIKMODAPI extern int VC_SetNumVoices(void); MIKMODAPI extern ULONG VC_SampleSpace(int); MIKMODAPI extern ULONG VC_SampleLength(int,SAMPLE*); -MIKMODAPI extern BOOL VC_PlayStart(void); +MIKMODAPI extern int VC_PlayStart(void); MIKMODAPI extern void VC_PlayStop(void); MIKMODAPI extern SWORD VC_SampleLoad(struct SAMPLOAD*,int); diff --git a/sc2/src/libs/mikmod/mikmod_ctype.h b/sc2/src/libs/mikmod/mikmod_ctype.h new file mode 100644 index 000000000..ea32e9e60 --- /dev/null +++ b/sc2/src/libs/mikmod/mikmod_ctype.h @@ -0,0 +1,84 @@ +/* Locale insensitive ctype.h functions taken from the RPM library. + * RPM is Copyright (c) 1998 by Red Hat Software, Inc. + * + * This library is free software; you can redistribute it and/or modify + * 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 + * 02111-1307, USA. + */ + +#ifndef MIKMOD_CTYPE_H +#define MIKMOD_CTYPE_H + +static inline int mik_isascii(int c) { + return ((c & ~0x7f) == 0); +} + +static inline int mik_islower(int c) { + return (c >= 'a' && c <= 'z'); +} + +static inline int mik_isupper(int c) { + return (c >= 'A' && c <= 'Z'); +} + +static inline int mik_isalpha(int c) { + return (mik_islower(c) || mik_isupper(c)); +} + +static inline int mik_isdigit(int c) { + return (c >= '0' && c <= '9'); +} + +static inline int mik_isxdigit(int c) { + return (mik_isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); +} + +static inline int mik_isalnum(int c) { + return (mik_isalpha(c) || mik_isdigit(c)); +} + +static inline int mik_isblank(int c) { + return (c == ' ' || c == '\t'); +} + +static inline int mik_isspace(int c) { + switch (c) { + case ' ': case '\t': + case '\n': case '\r': + case '\f': case '\v': return 1; + } + return 0; +} + +static inline int mik_isgraph(int c) { + return (c > 0x20 && c <= 0x7e); +} + +static inline int mik_isprint(int c) { + return (c >= 0x20 && c <= 0x7e); +} + +static inline int mik_toascii(int c) { + return (c & 0x7f); +} + +static inline int mik_tolower(int c) { + return ((mik_isupper(c)) ? (c | ('a' - 'A')) : c); +} + +static inline int mik_toupper(int c) { + return ((mik_islower(c)) ? (c & ~('a' - 'A')) : c); +} + +#endif /* MIKMOD_CTYPE_H */ diff --git a/sc2/src/libs/mikmod/mikmod_internals.h b/sc2/src/libs/mikmod/mikmod_internals.h index f84c4b714..1622a2d71 100644 --- a/sc2/src/libs/mikmod/mikmod_internals.h +++ b/sc2/src/libs/mikmod/mikmod_internals.h @@ -1,5 +1,5 @@ /* MikMod sound library - (c) 1998, 1999, 2000 Miodrag Vallat and others - see file AUTHORS for + (c) 1998, 1999, 2005 Miodrag Vallat and others - see file AUTHORS for complete list. This library is free software; you can redistribute it and/or modify @@ -20,47 +20,64 @@ /*============================================================================== - $Id$ - MikMod sound library internal definitions -==============================================================================*/ + ==============================================================================*/ -#ifndef LIBS_MIKMOD_MIKMOD_INTERNALS_H_ -#define LIBS_MIKMOD_MIKMOD_INTERNALS_H_ +#ifndef _MIKMOD_INTERNALS_H +#define _MIKMOD_INTERNALS_H #ifdef __cplusplus extern "C" { #endif #include -#if defined(__OS2__)||defined(__EMX__)||defined(WIN32)||defined(WIN64) -#define strcasecmp(s,t) stricmp(s,t) + +#if defined(_MSC_VER) && !defined(__cplusplus) && !defined(HAVE_CONFIG_H) +#define inline __inline #endif -#define MIKMOD_INTERNAL -#include "mikmod_build.h" +#include "mikmod.h" + +#ifndef MIKMOD_UNIX +#if (defined(unix) || defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) && \ + !(defined(_MIKMOD_WIN32) || defined(_MIKMOD_OS2) || defined(_MIKMOD_DOS) || defined(_MIKMOD_AMIGA) || defined(macintosh)) +#define MIKMOD_UNIX 1 +#else +#define MIKMOD_UNIX 0 +#endif +#endif /* MIKMOD_UNIX */ /*========== More type definitions */ /* SLONGLONG: 64bit, signed */ -#if defined(__arch64__) || defined(__alpha) || defined(__x86_64) \ - || defined(_M_IA64) || defined(_M_AMD64) -typedef long SLONGLONG; +#if !defined(_WIN32) && \ + (defined(_LP64) || defined(__LP64__) || defined(__arch64__) || defined(__alpha) || defined(__x64_64) || defined(__powerpc64__)) +typedef long SLONGLONG; #define NATIVE_64BIT_INT -#elif defined(__powerpc64__) -typedef long long SLONGLONG; +#elif defined(_WIN64) /* win64 is LLP64, not LP64 */ #define NATIVE_64BIT_INT +typedef long long SLONGLONG; #elif defined(__WATCOMC__) -typedef __int64 SLONGLONG; -#elif defined(WIN32) && !defined(__MWERKS__) -typedef LONGLONG SLONGLONG; -#elif macintosh && !TYPE_LONGLONG +typedef __int64 SLONGLONG; +#elif defined(_WIN32) && !defined(__MWERKS__) +typedef LONGLONG SLONGLONG; +#elif defined(macintosh) && !TYPE_LONGLONG #include -typedef SInt64 SLONGLONG; +typedef SInt64 SLONGLONG; #else -typedef long long SLONGLONG; +typedef long long SLONGLONG; #endif +typedef int __s64_typetest [(sizeof(SLONGLONG)==8) * 2 - 1]; + +/* pointer-sized signed int (ssize_t/intptr_t) : */ +#if defined(_WIN64) /* win64 is LLP64, not LP64 */ +typedef long long SINTPTR_T; +#else +/* long should be pointer-sized for all others : */ +typedef long SINTPTR_T; +#endif +typedef int __iptr_typetest [(sizeof(SINTPTR_T)==sizeof(void*)) * 2 - 1]; /*========== Error handling */ @@ -73,33 +90,36 @@ extern MikMod_handler_t _mm_errorhandler; #ifdef HAVE_PTHREAD #include #define DECLARE_MUTEX(name) \ - extern pthread_mutex_t _mm_mutex_##name -#define MUTEX_LOCK(name) \ - pthread_mutex_lock(&_mm_mutex_##name) -#define MUTEX_UNLOCK(name) \ - pthread_mutex_unlock(&_mm_mutex_##name) + extern pthread_mutex_t _mm_mutex_##name +#define MUTEX_LOCK(name) \ + pthread_mutex_lock(&_mm_mutex_##name) +#define MUTEX_UNLOCK(name) \ + pthread_mutex_unlock(&_mm_mutex_##name) + #elif defined(__OS2__)||defined(__EMX__) -#define DECLARE_MUTEX(name) \ - extern HMTX _mm_mutex_##name -#define MUTEX_LOCK(name) \ - if(_mm_mutex_##name) \ - DosRequestMutexSem(_mm_mutex_##name,SEM_INDEFINITE_WAIT) -#define MUTEX_UNLOCK(name) \ - if(_mm_mutex_##name) \ - DosReleaseMutexSem(_mm_mutex_##name) -#elif defined(WIN32) || defined(WIN64) +#define DECLARE_MUTEX(name) \ + extern HMTX _mm_mutex_##name +#define MUTEX_LOCK(name) \ + if(_mm_mutex_##name)\ + DosRequestMutexSem(_mm_mutex_##name,SEM_INDEFINITE_WAIT) +#define MUTEX_UNLOCK(name) \ + if(_mm_mutex_##name)\ + DosReleaseMutexSem(_mm_mutex_##name) + +#elif defined(_WIN32) #include -#define DECLARE_MUTEX(name) \ - extern HANDLE _mm_mutex_##name -#define MUTEX_LOCK(name) \ - if(_mm_mutex_##name) \ - WaitForSingleObject(_mm_mutex_##name,INFINITE) -#define MUTEX_UNLOCK(name) \ - if(_mm_mutex_##name) \ - ReleaseMutex(_mm_mutex_##name) +#define DECLARE_MUTEX(name) \ + extern HANDLE _mm_mutex_##name +#define MUTEX_LOCK(name) \ + if(_mm_mutex_##name)\ + WaitForSingleObject(_mm_mutex_##name,INFINITE) +#define MUTEX_UNLOCK(name) \ + if(_mm_mutex_##name)\ + ReleaseMutex(_mm_mutex_##name) + #else -#define DECLARE_MUTEX(name) \ - extern void *_mm_mutex_##name +#define DECLARE_MUTEX(name) \ + extern void *_mm_mutex_##name #define MUTEX_LOCK(name) #define MUTEX_UNLOCK(name) #endif @@ -107,9 +127,13 @@ extern MikMod_handler_t _mm_errorhandler; DECLARE_MUTEX(lists); DECLARE_MUTEX(vars); +/*========== Replacement funcs */ + +extern int _mm_strcasecmp (const char *__s1, const char *__s2); + /*========== Portable file I/O */ -extern MREADER* _mm_new_mem_reader(const void *buffer, int len); +extern MREADER* _mm_new_mem_reader(const void *buffer, long len); extern void _mm_delete_mem_reader(MREADER *reader); extern MREADER* _mm_new_file_reader(FILE* fp); @@ -118,31 +142,32 @@ extern void _mm_delete_file_reader(MREADER*); extern MWRITER* _mm_new_file_writer(FILE *fp); extern void _mm_delete_file_writer(MWRITER*); -extern BOOL _mm_FileExists(CHAR *fname); +extern BOOL _mm_FileExists(const CHAR *fname); -#define _mm_write_SBYTE(x,y) y->Put(y,(int)x) -#define _mm_write_UBYTE(x,y) y->Put(y,(int)x) +#define _mm_write_SBYTE(x,y) y->Put(y,(int)x) +#define _mm_write_UBYTE(x,y) y->Put(y,(int)x) -#define _mm_read_SBYTE(x) (SBYTE)x->Get(x) -#define _mm_read_UBYTE(x) (UBYTE)x->Get(x) +#define _mm_read_SBYTE(x) (SBYTE)x->Get(x) +#define _mm_read_UBYTE(x) (UBYTE)x->Get(x) +#define _mm_skip_BYTE(x) (void)x->Get(x) -#define _mm_write_SBYTES(x,y,z) z->Write(z,(void *)x,y) -#define _mm_write_UBYTES(x,y,z) z->Write(z,(void *)x,y) +#define _mm_write_SBYTES(x,y,z) z->Write(z,(const void *)x,y) +#define _mm_write_UBYTES(x,y,z) z->Write(z,(const void *)x,y) #define _mm_read_SBYTES(x,y,z) z->Read(z,(void *)x,y) #define _mm_read_UBYTES(x,y,z) z->Read(z,(void *)x,y) -#define _mm_fseek(x,y,z) x->Seek(x,y,z) -#define _mm_ftell(x) x->Tell(x) -#define _mm_rewind(x) _mm_fseek(x,0,SEEK_SET) +#define _mm_fseek(x,y,z) x->Seek(x,y,z) +#define _mm_ftell(x) x->Tell(x) +#define _mm_rewind(x) _mm_fseek(x,0,SEEK_SET) -#define _mm_eof(x) x->Eof(x) +#define _mm_eof(x) x->Eof(x) extern void _mm_iobase_setcur(MREADER*); extern void _mm_iobase_revert(MREADER*); -extern FILE *_mm_fopen(CHAR*,CHAR*); -extern int _mm_fclose(FILE *); -extern void _mm_write_string(CHAR*,MWRITER*); -extern int _mm_read_string (CHAR*,int,MREADER*); +extern FILE* _mm_fopen(const CHAR *, const CHAR *); +extern int _mm_fclose(FILE *); +extern void _mm_write_string(const CHAR*,MWRITER*); +extern BOOL _mm_read_string (CHAR*,int,MREADER*); extern SWORD _mm_read_M_SWORD(MREADER*); extern SWORD _mm_read_I_SWORD(MREADER*); @@ -154,15 +179,15 @@ extern SLONG _mm_read_I_SLONG(MREADER*); extern ULONG _mm_read_M_ULONG(MREADER*); extern ULONG _mm_read_I_ULONG(MREADER*); -extern int _mm_read_M_SWORDS(SWORD*,int,MREADER*); -extern int _mm_read_I_SWORDS(SWORD*,int,MREADER*); -extern int _mm_read_M_UWORDS(UWORD*,int,MREADER*); -extern int _mm_read_I_UWORDS(UWORD*,int,MREADER*); +extern BOOL _mm_read_M_SWORDS(SWORD*,int,MREADER*); +extern BOOL _mm_read_I_SWORDS(SWORD*,int,MREADER*); +extern BOOL _mm_read_M_UWORDS(UWORD*,int,MREADER*); +extern BOOL _mm_read_I_UWORDS(UWORD*,int,MREADER*); -extern int _mm_read_M_SLONGS(SLONG*,int,MREADER*); -extern int _mm_read_I_SLONGS(SLONG*,int,MREADER*); -extern int _mm_read_M_ULONGS(ULONG*,int,MREADER*); -extern int _mm_read_I_ULONGS(ULONG*,int,MREADER*); +extern BOOL _mm_read_M_SLONGS(SLONG*,int,MREADER*); +extern BOOL _mm_read_I_SLONGS(SLONG*,int,MREADER*); +extern BOOL _mm_read_M_ULONGS(ULONG*,int,MREADER*); +extern BOOL _mm_read_I_ULONGS(ULONG*,int,MREADER*); extern void _mm_write_M_SWORD(SWORD,MWRITER*); extern void _mm_write_I_SWORD(SWORD,MWRITER*); @@ -186,19 +211,21 @@ extern void _mm_write_I_ULONGS(ULONG*,int,MWRITER*); /*========== Samples */ +#define MAX_SAMPLE_SIZE 0x10000000 /* a sane value guaranteed to not overflow an SLONG */ + /* This is a handle of sorts attached to any sample registered with SL_RegisterSample. Generally, this only need be used or changed by the loaders and drivers of mikmod. */ typedef struct SAMPLOAD { - struct SAMPLOAD *next; + struct SAMPLOAD *next; - ULONG length; /* length of sample (in samples!) */ - ULONG loopstart; /* repeat position (relative to start, in samples) */ - ULONG loopend; /* repeat end */ - UWORD infmt,outfmt; - int scalefactor; - SAMPLE* sample; - MREADER* reader; + ULONG length; /* length of sample (in samples!) */ + ULONG loopstart; /* repeat position (relative to start, in samples) */ + ULONG loopend; /* repeat end */ + UWORD infmt,outfmt; + int scalefactor; + SAMPLE* sample; + MREADER* reader; } SAMPLOAD; /*========== Sample and waves loading interface */ @@ -208,9 +235,9 @@ extern void SL_Sample8to16(SAMPLOAD*); extern void SL_Sample16to8(SAMPLOAD*); extern void SL_SampleSigned(SAMPLOAD*); extern void SL_SampleUnsigned(SAMPLOAD*); -extern BOOL SL_LoadSamples(void); +extern int SL_LoadSamples(void); extern SAMPLOAD* SL_RegisterSample(SAMPLE*,int,MREADER*); -extern BOOL SL_Load(void*,SAMPLOAD*,ULONG); +extern int SL_Load(void*,SAMPLOAD*,ULONG); extern BOOL SL_Init(SAMPLOAD*); extern void SL_Exit(SAMPLOAD*); @@ -232,126 +259,126 @@ extern UBYTE* UniDup(void); extern BOOL UniInit(void); extern void UniCleanup(void); extern void UniEffect(UWORD,UWORD); -#define UniInstrument(x) UniEffect(UNI_INSTRUMENT,x) -#define UniNote(x) UniEffect(UNI_NOTE,x) +#define UniInstrument(x) UniEffect(UNI_INSTRUMENT,x) +#define UniNote(x) UniEffect(UNI_NOTE,x) extern void UniPTEffect(UBYTE,UBYTE); extern void UniVolEffect(UWORD,UBYTE); /*========== Module Commands */ enum { - /* Simple note */ - UNI_NOTE = 1, - /* Instrument change */ - UNI_INSTRUMENT, - /* Protracker effects */ - UNI_PTEFFECT0, /* arpeggio */ - UNI_PTEFFECT1, /* porta up */ - UNI_PTEFFECT2, /* porta down */ - UNI_PTEFFECT3, /* porta to note */ - UNI_PTEFFECT4, /* vibrato */ - UNI_PTEFFECT5, /* dual effect 3+A */ - UNI_PTEFFECT6, /* dual effect 4+A */ - UNI_PTEFFECT7, /* tremolo */ - UNI_PTEFFECT8, /* pan */ - UNI_PTEFFECT9, /* sample offset */ - UNI_PTEFFECTA, /* volume slide */ - UNI_PTEFFECTB, /* pattern jump */ - UNI_PTEFFECTC, /* set volume */ - UNI_PTEFFECTD, /* pattern break */ - UNI_PTEFFECTE, /* extended effects */ - UNI_PTEFFECTF, /* set speed */ - /* Scream Tracker effects */ - UNI_S3MEFFECTA, /* set speed */ - UNI_S3MEFFECTD, /* volume slide */ - UNI_S3MEFFECTE, /* porta down */ - UNI_S3MEFFECTF, /* porta up */ - UNI_S3MEFFECTI, /* tremor */ - UNI_S3MEFFECTQ, /* retrig */ - UNI_S3MEFFECTR, /* tremolo */ - UNI_S3MEFFECTT, /* set tempo */ - UNI_S3MEFFECTU, /* fine vibrato */ - UNI_KEYOFF, /* note off */ - /* Fast Tracker effects */ - UNI_KEYFADE, /* note fade */ - UNI_VOLEFFECTS, /* volume column effects */ - UNI_XMEFFECT4, /* vibrato */ - UNI_XMEFFECT6, /* dual effect 4+A */ - UNI_XMEFFECTA, /* volume slide */ - UNI_XMEFFECTE1, /* fine porta up */ - UNI_XMEFFECTE2, /* fine porta down */ - UNI_XMEFFECTEA, /* fine volume slide up */ - UNI_XMEFFECTEB, /* fine volume slide down */ - UNI_XMEFFECTG, /* set global volume */ - UNI_XMEFFECTH, /* global volume slide */ - UNI_XMEFFECTL, /* set envelope position */ - UNI_XMEFFECTP, /* pan slide */ - UNI_XMEFFECTX1, /* extra fine porta up */ - UNI_XMEFFECTX2, /* extra fine porta down */ - /* Impulse Tracker effects */ - UNI_ITEFFECTG, /* porta to note */ - UNI_ITEFFECTH, /* vibrato */ - UNI_ITEFFECTI, /* tremor (xy not incremented) */ - UNI_ITEFFECTM, /* set channel volume */ - UNI_ITEFFECTN, /* slide / fineslide channel volume */ - UNI_ITEFFECTP, /* slide / fineslide channel panning */ - UNI_ITEFFECTT, /* slide tempo */ - UNI_ITEFFECTU, /* fine vibrato */ - UNI_ITEFFECTW, /* slide / fineslide global volume */ - UNI_ITEFFECTY, /* panbrello */ - UNI_ITEFFECTZ, /* resonant filters */ - UNI_ITEFFECTS0, - /* UltraTracker effects */ - UNI_ULTEFFECT9, /* Sample fine offset */ - /* OctaMED effects */ - UNI_MEDSPEED, - UNI_MEDEFFECTF1, /* play note twice */ - UNI_MEDEFFECTF2, /* delay note */ - UNI_MEDEFFECTF3, /* play note three times */ - /* Oktalyzer effects */ - UNI_OKTARP, /* arpeggio */ + /* Simple note */ + UNI_NOTE = 1, + /* Instrument change */ + UNI_INSTRUMENT, + /* Protracker effects */ + UNI_PTEFFECT0, /* arpeggio */ + UNI_PTEFFECT1, /* porta up */ + UNI_PTEFFECT2, /* porta down */ + UNI_PTEFFECT3, /* porta to note */ + UNI_PTEFFECT4, /* vibrato */ + UNI_PTEFFECT5, /* dual effect 3+A */ + UNI_PTEFFECT6, /* dual effect 4+A */ + UNI_PTEFFECT7, /* tremolo */ + UNI_PTEFFECT8, /* pan */ + UNI_PTEFFECT9, /* sample offset */ + UNI_PTEFFECTA, /* volume slide */ + UNI_PTEFFECTB, /* pattern jump */ + UNI_PTEFFECTC, /* set volume */ + UNI_PTEFFECTD, /* pattern break */ + UNI_PTEFFECTE, /* extended effects */ + UNI_PTEFFECTF, /* set speed */ + /* Scream Tracker effects */ + UNI_S3MEFFECTA, /* set speed */ + UNI_S3MEFFECTD, /* volume slide */ + UNI_S3MEFFECTE, /* porta down */ + UNI_S3MEFFECTF, /* porta up */ + UNI_S3MEFFECTI, /* tremor */ + UNI_S3MEFFECTQ, /* retrig */ + UNI_S3MEFFECTR, /* tremolo */ + UNI_S3MEFFECTT, /* set tempo */ + UNI_S3MEFFECTU, /* fine vibrato */ + UNI_KEYOFF, /* note off */ + /* Fast Tracker effects */ + UNI_KEYFADE, /* note fade */ + UNI_VOLEFFECTS, /* volume column effects */ + UNI_XMEFFECT4, /* vibrato */ + UNI_XMEFFECT6, /* dual effect 4+A */ + UNI_XMEFFECTA, /* volume slide */ + UNI_XMEFFECTE1, /* fine porta up */ + UNI_XMEFFECTE2, /* fine porta down */ + UNI_XMEFFECTEA, /* fine volume slide up */ + UNI_XMEFFECTEB, /* fine volume slide down */ + UNI_XMEFFECTG, /* set global volume */ + UNI_XMEFFECTH, /* global volume slide */ + UNI_XMEFFECTL, /* set envelope position */ + UNI_XMEFFECTP, /* pan slide */ + UNI_XMEFFECTX1, /* extra fine porta up */ + UNI_XMEFFECTX2, /* extra fine porta down */ + /* Impulse Tracker effects */ + UNI_ITEFFECTG, /* porta to note */ + UNI_ITEFFECTH, /* vibrato */ + UNI_ITEFFECTI, /* tremor (xy not incremented) */ + UNI_ITEFFECTM, /* set channel volume */ + UNI_ITEFFECTN, /* slide / fineslide channel volume */ + UNI_ITEFFECTP, /* slide / fineslide channel panning */ + UNI_ITEFFECTT, /* slide tempo */ + UNI_ITEFFECTU, /* fine vibrato */ + UNI_ITEFFECTW, /* slide / fineslide global volume */ + UNI_ITEFFECTY, /* panbrello */ + UNI_ITEFFECTZ, /* resonant filters */ + UNI_ITEFFECTS0, + /* UltraTracker effects */ + UNI_ULTEFFECT9, /* Sample fine offset */ + /* OctaMED effects */ + UNI_MEDSPEED, + UNI_MEDEFFECTF1,/* play note twice */ + UNI_MEDEFFECTF2,/* delay note */ + UNI_MEDEFFECTF3,/* play note three times */ + /* Oktalyzer effects */ + UNI_OKTARP, /* arpeggio */ - UNI_LAST + UNI_LAST }; -extern UWORD unioperands[UNI_LAST]; +extern const UWORD unioperands[UNI_LAST]; /* IT / S3M Extended SS effects: */ enum { - SS_GLISSANDO = 1, - SS_FINETUNE, - SS_VIBWAVE, - SS_TREMWAVE, - SS_PANWAVE, - SS_FRAMEDELAY, - SS_S7EFFECTS, - SS_PANNING, - SS_SURROUND, - SS_HIOFFSET, - SS_PATLOOP, - SS_NOTECUT, - SS_NOTEDELAY, - SS_PATDELAY + SS_GLISSANDO = 1, + SS_FINETUNE, + SS_VIBWAVE, + SS_TREMWAVE, + SS_PANWAVE, + SS_FRAMEDELAY, + SS_S7EFFECTS, + SS_PANNING, + SS_SURROUND, + SS_HIOFFSET, + SS_PATLOOP, + SS_NOTECUT, + SS_NOTEDELAY, + SS_PATDELAY }; /* IT Volume column effects */ enum { - VOL_VOLUME = 1, - VOL_PANNING, - VOL_VOLSLIDE, - VOL_PITCHSLIDEDN, - VOL_PITCHSLIDEUP, - VOL_PORTAMENTO, - VOL_VIBRATO + VOL_VOLUME = 1, + VOL_PANNING, + VOL_VOLSLIDE, + VOL_PITCHSLIDEDN, + VOL_PITCHSLIDEUP, + VOL_PORTAMENTO, + VOL_VIBRATO }; /* IT resonant filter information */ -#define UF_MAXMACRO 0x10 -#define UF_MAXFILTER 0x100 +#define UF_MAXMACRO 0x10 +#define UF_MAXFILTER 0x100 -#define FILT_CUT 0x80 -#define FILT_RESONANT 0x81 +#define FILT_CUT 0x80 +#define FILT_RESONANT 0x81 typedef struct FILTER { UBYTE filter,inf; @@ -400,163 +427,164 @@ typedef struct FILTER { /*========== Playing */ -#define POS_NONE (-2) /* no loop position defined */ +#define POS_NONE (-2) /* no loop position defined */ -#define LAST_PATTERN (UWORD)(-1) /* special ``end of song'' pattern */ +#define LAST_PATTERN (UWORD)(-1) /* special ``end of song'' pattern */ typedef struct ENVPR { - UBYTE flg; /* envelope flag */ - UBYTE pts; /* number of envelope points */ - UBYTE susbeg; /* envelope sustain index begin */ - UBYTE susend; /* envelope sustain index end */ - UBYTE beg; /* envelope loop begin */ - UBYTE end; /* envelope loop end */ - SWORD p; /* current envelope counter */ - UWORD a; /* envelope index a */ - UWORD b; /* envelope index b */ - ENVPT* env; /* envelope points */ + UBYTE flg; /* envelope flag */ + UBYTE pts; /* number of envelope points */ + UBYTE susbeg; /* envelope sustain index begin */ + UBYTE susend; /* envelope sustain index end */ + UBYTE beg; /* envelope loop begin */ + UBYTE end; /* envelope loop end */ + SWORD p; /* current envelope counter */ + UWORD a; /* envelope index a */ + UWORD b; /* envelope index b */ + ENVPT* env; /* envelope points */ } ENVPR; typedef struct MP_CHANNEL { - INSTRUMENT* i; - SAMPLE* s; - UBYTE sample; /* which sample number */ - UBYTE note; /* the audible note as heard, direct rep of period */ - SWORD outvolume; /* output volume (vol + sampcol + instvol) */ - SBYTE chanvol; /* channel's "global" volume */ - UWORD fadevol; /* fading volume rate */ - SWORD panning; /* panning position */ - UBYTE kick; /* if true = sample has to be restarted */ - UWORD period; /* period to play the sample at */ - UBYTE nna; /* New note action type + master/slave flags */ + INSTRUMENT* i; + SAMPLE *s; + UBYTE sample; /* which sample number */ + UBYTE note; /* the audible note as heard, direct rep of period */ + SWORD outvolume; /* output volume (vol + sampcol + instvol) */ + SBYTE chanvol; /* channel's "global" volume */ + UWORD fadevol; /* fading volume rate */ + SWORD panning; /* panning position */ + UBYTE kick; /* if true = sample has to be restarted */ + UBYTE kick_flag; /* kick has been true */ + UWORD period; /* period to play the sample at */ + UBYTE nna; /* New note action type + master/slave flags */ - UBYTE volflg; /* volume envelope settings */ - UBYTE panflg; /* panning envelope settings */ - UBYTE pitflg; /* pitch envelope settings */ + UBYTE volflg; /* volume envelope settings */ + UBYTE panflg; /* panning envelope settings */ + UBYTE pitflg; /* pitch envelope settings */ - UBYTE keyoff; /* if true = fade out and stuff */ - SWORD handle; /* which sample-handle */ - UBYTE notedelay; /* (used for note delay) */ - SLONG start; /* The starting byte index in the sample */ + UBYTE keyoff; /* if true = fade out and stuff */ + SWORD handle; /* which sample-handle */ + UBYTE notedelay; /* (used for note delay) */ + SLONG start; /* The starting byte index in the sample */ } MP_CHANNEL; typedef struct MP_CONTROL { - struct MP_CHANNEL main; + struct MP_CHANNEL main; - struct MP_VOICE *slave; /* Audio Slave of current effects control channel */ + struct MP_VOICE* slave; /* Audio Slave of current effects control channel */ - UBYTE slavechn; /* Audio Slave of current effects control channel */ - UBYTE muted; /* if set, channel not played */ - UWORD ultoffset; /* fine sample offset memory */ - UBYTE anote; /* the note that indexes the audible */ - UBYTE oldnote; - SWORD ownper; - SWORD ownvol; - UBYTE dca; /* duplicate check action */ - UBYTE dct; /* duplicate check type */ - UBYTE* row; /* row currently playing on this channel */ - SBYTE retrig; /* retrig value (0 means don't retrig) */ - ULONG speed; /* what finetune to use */ - SWORD volume; /* amiga volume (0 t/m 64) to play the sample at */ + UBYTE slavechn; /* Audio Slave of current effects control channel */ + UBYTE muted; /* if set, channel not played */ + UWORD ultoffset; /* fine sample offset memory */ + UBYTE anote; /* the note that indexes the audible */ + UBYTE oldnote; + SWORD ownper; + SWORD ownvol; + UBYTE dca; /* duplicate check action */ + UBYTE dct; /* duplicate check type */ + UBYTE* row; /* row currently playing on this channel */ + SBYTE retrig; /* retrig value (0 means don't retrig) */ + ULONG speed; /* what finetune to use */ + SWORD volume; /* amiga volume (0 t/m 64) to play the sample at */ - SWORD tmpvolume; /* tmp volume */ - UWORD tmpperiod; /* tmp period */ - UWORD wantedperiod; /* period to slide to (with effect 3 or 5) */ + SWORD tmpvolume; /* tmp volume */ + UWORD tmpperiod; /* tmp period */ + UWORD wantedperiod;/* period to slide to (with effect 3 or 5) */ - UBYTE arpmem; /* arpeggio command memory */ - UBYTE pansspd; /* panslide speed */ - UWORD slidespeed; - UWORD portspeed; /* noteslide speed (toneportamento) */ + UBYTE arpmem; /* arpeggio command memory */ + UBYTE pansspd; /* panslide speed */ + UWORD slidespeed; + UWORD portspeed; /* noteslide speed (toneportamento) */ - UBYTE s3mtremor; /* s3m tremor (effect I) counter */ - UBYTE s3mtronof; /* s3m tremor ontime/offtime */ - UBYTE s3mvolslide; /* last used volslide */ - SBYTE sliding; - UBYTE s3mrtgspeed; /* last used retrig speed */ - UBYTE s3mrtgslide; /* last used retrig slide */ + UBYTE s3mtremor; /* s3m tremor (effect I) counter */ + UBYTE s3mtronof; /* s3m tremor ontime/offtime */ + UBYTE s3mvolslide;/* last used volslide */ + SBYTE sliding; + UBYTE s3mrtgspeed;/* last used retrig speed */ + UBYTE s3mrtgslide;/* last used retrig slide */ - UBYTE glissando; /* glissando (0 means off) */ - UBYTE wavecontrol; + UBYTE glissando; /* glissando (0 means off) */ + UBYTE wavecontrol; - SBYTE vibpos; /* current vibrato position */ - UBYTE vibspd; /* "" speed */ - UBYTE vibdepth; /* "" depth */ + SBYTE vibpos; /* current vibrato position */ + UBYTE vibspd; /* "" speed */ + UBYTE vibdepth; /* "" depth */ - SBYTE trmpos; /* current tremolo position */ - UBYTE trmspd; /* "" speed */ - UBYTE trmdepth; /* "" depth */ + SBYTE trmpos; /* current tremolo position */ + UBYTE trmspd; /* "" speed */ + UBYTE trmdepth; /* "" depth */ - UBYTE fslideupspd; - UBYTE fslidednspd; - UBYTE fportupspd; /* fx E1 (extra fine portamento up) data */ - UBYTE fportdnspd; /* fx E2 (extra fine portamento dn) data */ - UBYTE ffportupspd; /* fx X1 (extra fine portamento up) data */ - UBYTE ffportdnspd; /* fx X2 (extra fine portamento dn) data */ + UBYTE fslideupspd; + UBYTE fslidednspd; + UBYTE fportupspd; /* fx E1 (extra fine portamento up) data */ + UBYTE fportdnspd; /* fx E2 (extra fine portamento dn) data */ + UBYTE ffportupspd;/* fx X1 (extra fine portamento up) data */ + UBYTE ffportdnspd;/* fx X2 (extra fine portamento dn) data */ - ULONG hioffset; /* last used high order of sample offset */ - UWORD soffset; /* last used low order of sample-offset (effect 9) */ + ULONG hioffset; /* last used high order of sample offset */ + UWORD soffset; /* last used low order of sample-offset (effect 9) */ - UBYTE sseffect; /* last used Sxx effect */ - UBYTE ssdata; /* last used Sxx data info */ - UBYTE chanvolslide; /* last used channel volume slide */ + UBYTE sseffect; /* last used Sxx effect */ + UBYTE ssdata; /* last used Sxx data info */ + UBYTE chanvolslide;/* last used channel volume slide */ - UBYTE panbwave; /* current panbrello waveform */ - UBYTE panbpos; /* current panbrello position */ - SBYTE panbspd; /* "" speed */ - UBYTE panbdepth; /* "" depth */ + UBYTE panbwave; /* current panbrello waveform */ + UBYTE panbpos; /* current panbrello position */ + SBYTE panbspd; /* "" speed */ + UBYTE panbdepth; /* "" depth */ - UWORD newsamp; /* set to 1 upon a sample / inst change */ - UBYTE voleffect; /* Volume Column Effect Memory as used by IT */ - UBYTE voldata; /* Volume Column Data Memory */ + UWORD newsamp; /* set to 1 upon a sample / inst change */ + UBYTE voleffect; /* Volume Column Effect Memory as used by IT */ + UBYTE voldata; /* Volume Column Data Memory */ - SWORD pat_reppos; /* patternloop position */ - UWORD pat_repcnt; /* times to loop */ + SWORD pat_reppos; /* patternloop position */ + UWORD pat_repcnt; /* times to loop */ } MP_CONTROL; /* Used by NNA only player (audio control. AUDTMP is used for full effects control). */ typedef struct MP_VOICE { - struct MP_CHANNEL main; + struct MP_CHANNEL main; - ENVPR venv; - ENVPR penv; - ENVPR cenv; + ENVPR venv; + ENVPR penv; + ENVPR cenv; - UWORD avibpos; /* autovibrato pos */ - UWORD aswppos; /* autovibrato sweep pos */ + UWORD avibpos; /* autovibrato pos */ + UWORD aswppos; /* autovibrato sweep pos */ - ULONG totalvol; /* total volume of channel (before global mixings) */ + ULONG totalvol; /* total volume of channel (before global mixings) */ - BOOL mflag; - SWORD masterchn; - UWORD masterperiod; + BOOL mflag; + SWORD masterchn; + UWORD masterperiod; - MP_CONTROL* master; /* index of "master" effects channel */ + MP_CONTROL* master; /* index of "master" effects channel */ } MP_VOICE; /*========== Loaders */ typedef struct MLOADER { -struct MLOADER* next; - CHAR* type; - CHAR* version; - BOOL (*Init)(void); - BOOL (*Test)(void); - BOOL (*Load)(BOOL); - void (*Cleanup)(void); - CHAR* (*LoadTitle)(void); + struct MLOADER* next; + const CHAR* type; + const CHAR* version; + BOOL (*Init)(void); + BOOL (*Test)(void); + BOOL (*Load)(BOOL); + void (*Cleanup)(void); + CHAR* (*LoadTitle)(void); } MLOADER; /* internal loader variables */ extern MREADER* modreader; -extern UWORD finetune[16]; extern MODULE of; /* static unimod loading space */ -extern UWORD npertab[7*OCTAVE]; /* used by the original MOD loaders */ +extern const UWORD finetune[16]; +extern const UWORD npertab[7*OCTAVE];/* used by the original MOD loaders */ extern SBYTE remap[UF_MAXCHAN]; /* for removing empty channels */ extern UBYTE* poslookup; /* lookup table for pattern jumps after - blank pattern removal */ -extern UBYTE poslookupcnt; + blank pattern removal */ +extern UWORD poslookupcnt; extern UWORD* origpositions; extern BOOL filters; /* resonant filters in use */ @@ -575,7 +603,7 @@ extern BOOL AllocPatterns(void); extern BOOL AllocTracks(void); extern BOOL AllocInstruments(void); extern BOOL AllocSamples(void); -extern CHAR* DupStr(CHAR*,UWORD,BOOL); +extern CHAR* DupStr(const CHAR*, UWORD, BOOL); /* loader utility functions */ extern int* AllocLinear(void); @@ -585,28 +613,38 @@ extern void S3MIT_ProcessCmd(UBYTE,UBYTE,unsigned int); extern void S3MIT_CreateOrders(BOOL); /* flags for S3MIT_ProcessCmd */ -#define S3MIT_OLDSTYLE 1 /* behave as old scream tracker */ -#define S3MIT_IT 2 /* behave as impulse tracker */ -#define S3MIT_SCREAM 4 /* enforce scream tracker specific limits */ +#define S3MIT_OLDSTYLE 1 /* behave as old scream tracker */ +#define S3MIT_IT 2 /* behave as impulse tracker */ +#define S3MIT_SCREAM 4 /* enforce scream tracker specific limits */ /* used to convert c4spd to linear XM periods (IT and IMF loaders). */ extern UWORD getlinearperiod(UWORD,ULONG); extern ULONG getfrequency(UWORD,ULONG); /* loader shared data */ -#define STM_NTRACKERS 3 -extern CHAR *STM_Signatures[STM_NTRACKERS]; +#define STM_NTRACKERS 3 +extern const CHAR *STM_Signatures[STM_NTRACKERS]; /*========== Player interface */ -extern BOOL Player_Init(MODULE*); +extern int Player_Init(MODULE*); extern void Player_Exit(MODULE*); extern void Player_HandleTick(void); +/*========== UnPackers */ + +typedef BOOL (*MUNPACKER) (struct MREADER*, + void** /* unpacked data out */ , + long* /* unpacked data size */ ); +extern BOOL PP20_Unpack(MREADER*, void**, long*); +extern BOOL MMCMP_Unpack(MREADER*, void**, long*); +extern BOOL XPK_Unpack(MREADER*, void**, long*); +extern BOOL S404_Unpack(MREADER*, void**, long*); + /*========== Drivers */ /* max. number of handles a driver has to provide. (not strict) */ -#define MAXSAMPLEHANDLES 384 +#define MAXSAMPLEHANDLES 384 /* These variables can be changed at ANY time and results will be immediate */ extern UWORD md_bpm; /* current song / hardware BPM rate */ @@ -633,17 +671,17 @@ extern ULONG MD_SampleLength(int,SAMPLE*); extern void unsignedtoulaw(char *,int); /* Parameter extraction helper */ -extern CHAR *MD_GetAtom(CHAR*,CHAR*,BOOL); +extern CHAR *MD_GetAtom(const CHAR*, const CHAR*, BOOL); /* Internal software mixer stuff */ extern void VC_SetupPointers(void); -extern BOOL VC1_Init(void); -extern BOOL VC2_Init(void); +extern int VC1_Init(void); +extern int VC2_Init(void); -#if defined(unix) || defined(__APPLE__) && defined(__MACH__) +#if (MIKMOD_UNIX) /* POSIX helper functions */ -extern BOOL MD_Access(CHAR *); -extern BOOL MD_DropPrivileges(void); +extern BOOL MD_Access(const CHAR *); +extern int MD_DropPrivileges(void); #endif /* Macro to define a missing driver, yet allowing binaries to dynamically link @@ -656,9 +694,9 @@ extern void _mm_registerdriver(struct MDRIVER*); extern void _mm_registerloader(struct MLOADER*); extern BOOL MikMod_Active_internal(void); extern void MikMod_DisableOutput_internal(void); -extern BOOL MikMod_EnableOutput_internal(void); +extern int MikMod_EnableOutput_internal(void); extern void MikMod_Exit_internal(void); -extern BOOL MikMod_SetNumVoices_internal(int,int); +extern int MikMod_SetNumVoices_internal(int,int); extern void Player_Exit_internal(MODULE*); extern void Player_Stop_internal(void); extern BOOL Player_Paused_internal(void); @@ -670,10 +708,162 @@ extern void Voice_SetVolume_internal(SBYTE,UWORD); extern void Voice_Stop_internal(SBYTE); extern BOOL Voice_Stopped_internal(SBYTE); +extern int VC1_PlayStart(void); +extern int VC2_PlayStart(void); +extern void VC1_PlayStop(void); +extern void VC2_PlayStop(void); +extern int VC1_SetNumVoices(void); +extern int VC2_SetNumVoices(void); + +extern MikMod_callback_t vc_callback; + #ifdef __cplusplus } #endif +/*========== SIMD mixing routines */ +#undef HAVE_ALTIVEC +#undef HAVE_SSE2 +#if defined(MIKMOD_SIMD) + +#if (defined(__ppc__) || defined(__ppc64__)) && defined(__VEC__) && !(defined(__GNUC__) && (__GNUC__ < 3)) +#define HAVE_ALTIVEC + +#elif defined(__GNUC__) && defined(__SSE2__) /* x86 / x86_64 */ +#define HAVE_SSE2 + +#elif defined(_MSC_VER) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64)) +/* FIXME: emmintrin.h requires VC6 processor pack or VC2003+ */ +#define HAVE_SSE2 +/* avoid some warnings */ +#pragma warning(disable:4761) +#pragma warning(disable:4391) +#pragma warning(disable:4244) + +#endif /* AltiVec/SSE2 */ +#endif /* MIKMOD_SIMD */ + +/*========== SIMD mixing helper functions =============*/ + +#if defined(_WIN64) +# if defined(_MSC_VER) +# define IS_ALIGNED_16(ptr) (!((__int64)(ptr) & 15i64)) +# else /* GCC, LCC, .. */ +# define IS_ALIGNED_16(ptr) (!((long long)(ptr) & 15LL)) +# endif +#else /* long cast should be OK for all else */ +#define IS_ALIGNED_16(ptr) (!((long)(ptr) & 15L)) #endif +/* Altivec helper function */ +#if defined HAVE_ALTIVEC + +#define simd_m128i vector signed int +#define simd_m128 vector float + +#ifdef __GNUC__ +#include +#endif + +/* Helper functions */ + +/* Set single float across the four values */ +static inline vector float vec_mul(const vector float a, const vector float b) { + return vec_madd(a, b, (const vector float)(0.f)); +} + +/* Set single float across the four values */ +static inline vector float vec_load_ps1(const float *pF) { + vector float data = vec_lde(0, pF); + return vec_splat(vec_perm(data, data, vec_lvsl(0, pF)), 0); +} + +/* Set vector to 0 */ +static inline vector float vec_setzero() { + return (vector float) (0.); +} + +static inline vector signed char vec_set1_8(unsigned char splatchar) { + vector unsigned char splatmap = vec_lvsl(0, &splatchar); + vector unsigned char result = vec_lde(0, &splatchar); + splatmap = vec_splat(splatmap, 0); + return (vector signed char)vec_perm(result, result, splatmap); +} + +#define PERM_A0 0x00,0x01,0x02,0x03 +#define PERM_A1 0x04,0x05,0x06,0x07 +#define PERM_A2 0x08,0x09,0x0A,0x0B +#define PERM_A3 0x0C,0x0D,0x0E,0x0F +#define PERM_B0 0x10,0x11,0x12,0x13 +#define PERM_B1 0x14,0x15,0x16,0x17 +#define PERM_B2 0x18,0x19,0x1A,0x1B +#define PERM_B3 0x1C,0x1D,0x1E,0x1F + +/* Equivalent to _mm_unpacklo_epi32 */ +static inline vector signed int vec_unpacklo(vector signed int a, vector signed int b) { + return vec_perm(a, b, (vector unsigned char)(PERM_A0,PERM_A1,PERM_B0,PERM_B1)); +} + +/* Equivalent to _mm_srli_si128(a, 8) (without the zeroing in high part). */ +static inline vector signed int vec_hiqq(vector signed int a) { + vector signed int b = vec_splat_s32(0); + return vec_perm(a, b, (vector unsigned char)(PERM_A2,PERM_A3,PERM_B2,PERM_B3)); +} + +/* vec_sra is max +15. We have to do in two times ... */ +#define EXTRACT_SAMPLE_SIMD_F(srce, var, size, mul) var = vec_mul(vec_ctf(vec_sra(vec_ld(0, (vector signed int const *)(srce)), vec_splat_u32(BITSHIFT-size)),0), mul); +#define EXTRACT_SAMPLE_SIMD_0(srce, var) var = vec_sra(vec_sra(vec_ld(0, (vector signed int const *)(srce)), vec_splat_u32(15)), vec_splat_u32(BITSHIFT+16-15-0)); +#define EXTRACT_SAMPLE_SIMD_8(srce, var) var = vec_sra(vec_sra(vec_ld(0, (vector signed int const *)(srce)), vec_splat_u32(15)), vec_splat_u32(BITSHIFT+16-15-8)); +#define EXTRACT_SAMPLE_SIMD_16(srce, var) var = vec_sra(vec_ld(0, (vector signed int const *)(srce)), vec_splat_u32(BITSHIFT+16-16)); +#define PUT_SAMPLE_SIMD_W(dste, v1, v2) vec_st(vec_packs(v1, v2), 0, dste); +#define PUT_SAMPLE_SIMD_B(dste, v1, v2, v3, v4) vec_st(vec_add(vec_packs((vector signed short)vec_packs(v1, v2), (vector signed short)vec_packs(v3, v4)), vec_set1_8(128)), 0, dste); +#define PUT_SAMPLE_SIMD_F(dste, v1) vec_st(v1, 0, dste); +#define LOAD_PS1_SIMD(ptr) vec_load_ps1(ptr) + +#elif defined HAVE_SSE2 + +#include + +/* SSE2 helper function */ + +static __inline __m128i mm_hiqq(const __m128i a) { + return _mm_srli_si128(a, 8); /* get the 64bit upper part. new 64bit upper is undefined (zeroed is fine). */ +} + +/* 128-bit mixing macros */ +#define EXTRACT_SAMPLE_SIMD(srce, var, size) var = _mm_srai_epi32(_mm_load_si128((__m128i const *)(srce)), BITSHIFT+16-size); +#define EXTRACT_SAMPLE_SIMD_F(srce, var, size, mul) var = _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_load_si128((__m128i const *)(srce)), BITSHIFT-size)), mul); +#define EXTRACT_SAMPLE_SIMD_0(srce, var) EXTRACT_SAMPLE_SIMD(srce, var, 0) +#define EXTRACT_SAMPLE_SIMD_8(srce, var) EXTRACT_SAMPLE_SIMD(srce, var, 8) +#define EXTRACT_SAMPLE_SIMD_16(srce, var) EXTRACT_SAMPLE_SIMD(srce, var, 16) +#define PUT_SAMPLE_SIMD_W(dste, v1, v2) _mm_store_si128((__m128i*)(dste), _mm_packs_epi32(v1, v2)); +#define PUT_SAMPLE_SIMD_B(dste, v1, v2, v3, v4) _mm_store_si128((__m128i*)(dste), _mm_add_epi8(_mm_packs_epi16(_mm_packs_epi32(v1, v2), _mm_packs_epi32(v3, v4)), _mm_set1_epi8(128))); +#define PUT_SAMPLE_SIMD_F(dste, v1) _mm_store_ps((float*)(dste), v1); +#define LOAD_PS1_SIMD(ptr) _mm_load_ps1(ptr) +#define simd_m128i __m128i +#define simd_m128 __m128 + +#endif + +#if defined(HAVE_SSE2) || defined(HAVE_ALTIVEC) +/* MikMod_amalloc() returns a 16 byte aligned zero-filled + memory in SIMD-enabled builds. + - the returned memory can be freed with MikMod_afree() + - the returned memory CAN NOT be realloc()'ed safely. */ +#ifdef __cplusplus +extern "C" { +#endif +void* MikMod_amalloc(size_t); +void MikMod_afree(void *); /* frees if ptr != NULL */ +#ifdef __cplusplus +} +#endif + +#else /* NO SIMD */ +#define MikMod_amalloc MikMod_malloc +#define MikMod_afree MikMod_free +#endif + +#endif /* _MIKMOD_INTERNALS_H */ + /* ex:set ts=4: */ diff --git a/sc2/src/libs/mikmod/mloader.c b/sc2/src/libs/mikmod/mloader.c index 494334cf9..68e3a4f77 100644 --- a/sc2/src/libs/mikmod/mloader.c +++ b/sc2/src/libs/mikmod/mloader.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 @@ -45,12 +45,16 @@ extern int fprintf(FILE *, const char *, ...); #endif - MREADER *modreader; - MODULE of; +MREADER *modreader; +MODULE of; static MLOADER *firstloader=NULL; -UWORD finetune[16]={ +static MUNPACKER unpackers[] = { + NULL +}; + +const UWORD finetune[16] = { 8363,8413,8463,8529,8581,8651,8723,8757, 7895,7941,7985,8046,8107,8169,8232,8280 }; @@ -63,15 +67,18 @@ MIKMODAPI CHAR* MikMod_InfoLoader(void) MUTEX_LOCK(lists); /* compute size of buffer */ - for(l=firstloader;l;l=l->next) len+=1+(l->next?1:0)+strlen(l->version); + for(l = firstloader; l; l = l->next) + len += 1 + (l->next ? 1 : 0) + strlen(l->version); if(len) - if((list=MikMod_malloc(len*sizeof(CHAR)))) { - list[0]=0; - /* list all registered module loders */ - for(l=firstloader;l;l=l->next) - sprintf(list,(l->next)?"%s%s\n":"%s%s",list,l->version); + if((list=(CHAR*)MikMod_malloc(len*sizeof(CHAR))) != NULL) { + CHAR *list_end = list; + list[0] = 0; + /* list all registered module loders */ + for(l = firstloader; l; l = l->next) { + list_end += sprintf(list_end, "%s%s", l->version, (l->next) ? "\n" : ""); } + } MUTEX_UNLOCK(lists); return list; } @@ -84,7 +91,7 @@ void _mm_registerloader(MLOADER* ldr) while(cruise->next) cruise = cruise->next; cruise->next=ldr; } else - firstloader=ldr; + firstloader=ldr; } MIKMODAPI void MikMod_RegisterLoader(struct MLOADER* ldr) @@ -106,7 +113,7 @@ BOOL ReadComment(UWORD len) if(!(of.comment=(CHAR*)MikMod_malloc(len+1))) return 0; _mm_read_UBYTES(of.comment,len,modreader); - + /* translate IT linefeeds */ for(i=0;i=0)&&(line[i]==' ');i--) line[i]=0; - for(i=0;ilines) { - if(!(of.comment=(CHAR*)MikMod_malloc(total+1))) { - MikMod_free(storage); - MikMod_free(tempcomment); - return 0; + _mm_read_UBYTES(buf,len,modreader); + storage[cnt] = 0; + for (line = 0, fpos = 0, cpos = 0; line < numlines; line++, fpos += linelen, cpos += (linelen + 1)) + { + cnt = len - fpos; + if (cnt > linelen) cnt = linelen; + p = storage + cpos; + memcpy(p, buf + fpos, cnt); + p[cnt] = '\r'; + /* fix weird chars */ + for (lpos = 0; lpos < linelen; lpos++, p++) { + switch (*p) { + case '\0': + case '\n': + case '\r': + *p = ' '; + break; } - - /* convert message */ - for(line=tempcomment,t=0;thandle>=0) MD_SampleUnload(s->handle); - if(s->samplename) MikMod_free(s->samplename); + +/* moved samplename freeing to our caller ML_FreeEx(), + * because we are called conditionally. */ } static void ML_XFreeInstrument(INSTRUMENT *i) { - if(i->insname) MikMod_free(i->insname); + MikMod_free(i->insname); } static void ML_FreeEx(MODULE *mf) { UWORD t; - if(mf->songname) MikMod_free(mf->songname); - if(mf->comment) MikMod_free(mf->comment); + MikMod_free(mf->songname); + MikMod_free(mf->comment); - if(mf->modtype) MikMod_free(mf->modtype); - if(mf->positions) MikMod_free(mf->positions); - if(mf->patterns) MikMod_free(mf->patterns); - if(mf->pattrows) MikMod_free(mf->pattrows); + MikMod_free(mf->modtype); + MikMod_free(mf->positions); + MikMod_free(mf->patterns); + MikMod_free(mf->pattrows); if(mf->tracks) { for(t=0;tnumtrk;t++) - if(mf->tracks[t]) MikMod_free(mf->tracks[t]); + MikMod_free(mf->tracks[t]); MikMod_free(mf->tracks); } if(mf->instruments) { @@ -319,8 +328,10 @@ static void ML_FreeEx(MODULE *mf) MikMod_free(mf->instruments); } if(mf->samples) { - for(t=0;tnumsmp;t++) + for(t=0;tnumsmp;t++) { + MikMod_free(mf->samples[t].samplename); if(mf->samples[t].length) ML_XFreeSample(&mf->samples[t]); + } MikMod_free(mf->samples); } memset(mf,0,sizeof(MODULE)); @@ -329,12 +340,24 @@ static void ML_FreeEx(MODULE *mf) static MODULE *ML_AllocUniMod(void) { - MODULE *mf; - - return (mf=MikMod_malloc(sizeof(MODULE))); + return (MODULE *) MikMod_malloc(sizeof(MODULE)); } -void Player_Free_internal(MODULE *mf) +static BOOL ML_TryUnpack(MREADER *reader,void **out,long *outlen) +{ + int i; + + *out = NULL; + *outlen = 0; + + for(i=0;unpackers[i]!=NULL;++i) { + _mm_rewind(reader); + if(unpackers[i](reader,out,outlen)) return 1; + } + return 0; +} + +static void Player_Free_internal(MODULE *mf) { if(mf) { Player_Exit_internal(mf); @@ -352,25 +375,44 @@ MIKMODAPI void Player_Free(MODULE *mf) static CHAR* Player_LoadTitle_internal(MREADER *reader) { MLOADER *l; + CHAR *title; + void *unpk; + long newlen; modreader=reader; _mm_errno = 0; _mm_critical = 0; _mm_iobase_setcur(modreader); + if(ML_TryUnpack(modreader,&unpk,&newlen)) { + if(!(modreader=_mm_new_mem_reader(unpk,newlen))) { + modreader=reader; + MikMod_free(unpk); + return NULL; + } + } + /* Try to find a loader that recognizes the module */ for(l=firstloader;l;l=l->next) { _mm_rewind(modreader); if(l->Test()) break; } - if(!l) { + if(l) { + title = l->LoadTitle(); + } + else { _mm_errno = MMERR_NOT_A_MODULE; if(_mm_errorhandler) _mm_errorhandler(); - return NULL; + title = NULL; } - return l->LoadTitle(); + if (modreader!=reader) { + _mm_delete_mem_reader(modreader); + modreader=reader; + MikMod_free(unpk); + } + return title; } MIKMODAPI CHAR* Player_LoadTitleFP(FILE *fp) @@ -378,7 +420,7 @@ MIKMODAPI CHAR* Player_LoadTitleFP(FILE *fp) CHAR* result=NULL; MREADER* reader; - if(fp && (reader=_mm_new_file_reader(fp))) { + if(fp && (reader=_mm_new_file_reader(fp)) != NULL) { MUTEX_LOCK(lists); result=Player_LoadTitle_internal(reader); MUTEX_UNLOCK(lists); @@ -392,22 +434,22 @@ MIKMODAPI CHAR* Player_LoadTitleMem(const char *buffer,int len) CHAR *result=NULL; MREADER* reader; - if ((reader=_mm_new_mem_reader(buffer,len))) + if (!buffer || len <= 0) return NULL; + if ((reader=_mm_new_mem_reader(buffer,len)) != NULL) { MUTEX_LOCK(lists); result=Player_LoadTitle_internal(reader); MUTEX_UNLOCK(lists); _mm_delete_mem_reader(reader); } - - + return result; } MIKMODAPI CHAR* Player_LoadTitleGeneric(MREADER *reader) -{ +{ CHAR *result=NULL; - + if (reader) { MUTEX_LOCK(lists); result=Player_LoadTitle_internal(reader); @@ -416,14 +458,14 @@ MIKMODAPI CHAR* Player_LoadTitleGeneric(MREADER *reader) return result; } -MIKMODAPI CHAR* Player_LoadTitle(CHAR* filename) +MIKMODAPI CHAR* Player_LoadTitle(const CHAR* filename) { CHAR* result=NULL; FILE* fp; MREADER* reader; - if((fp=_mm_fopen(filename,"rb"))) { - if((reader=_mm_new_file_reader(fp))) { + if((fp=_mm_fopen(filename,"rb")) != NULL) { + if((reader=_mm_new_file_reader(fp)) != NULL) { MUTEX_LOCK(lists); result=Player_LoadTitle_internal(reader); MUTEX_UNLOCK(lists); @@ -435,18 +477,28 @@ MIKMODAPI CHAR* Player_LoadTitle(CHAR* filename) } /* Loads a module given an reader */ -MODULE* Player_LoadGeneric_internal(MREADER *reader,int maxchan,BOOL curious) +static MODULE* Player_LoadGeneric_internal(MREADER *reader,int maxchan,BOOL curious) { int t; MLOADER *l; BOOL ok; MODULE *mf; + void *unpk; + long newlen; modreader = reader; _mm_errno = 0; _mm_critical = 0; _mm_iobase_setcur(modreader); + if(ML_TryUnpack(modreader,&unpk,&newlen)) { + if(!(modreader=_mm_new_mem_reader(unpk,newlen))) { + modreader=reader; + MikMod_free(unpk); + return NULL; + } + } + /* Try to find a loader that recognizes the module */ for(l=firstloader;l;l=l->next) { _mm_rewind(modreader); @@ -455,15 +507,27 @@ MODULE* Player_LoadGeneric_internal(MREADER *reader,int maxchan,BOOL curious) if(!l) { _mm_errno = MMERR_NOT_A_MODULE; + if(modreader!=reader) { + _mm_delete_mem_reader(modreader); + modreader=reader; + MikMod_free(unpk); + } if(_mm_errorhandler) _mm_errorhandler(); - _mm_rewind(modreader);_mm_iobase_revert(modreader); + _mm_rewind(modreader); + _mm_iobase_revert(modreader); return NULL; } /* init unitrk routines */ if(!UniInit()) { + if(modreader!=reader) { + _mm_delete_mem_reader(modreader); + modreader=reader; + MikMod_free(unpk); + } if(_mm_errorhandler) _mm_errorhandler(); - _mm_rewind(modreader);_mm_iobase_revert(modreader); + _mm_rewind(modreader); + _mm_iobase_revert(modreader); return NULL; } @@ -479,7 +543,7 @@ MODULE* Player_LoadGeneric_internal(MREADER *reader,int maxchan,BOOL curious) if (!l->Init || l->Init()) { _mm_rewind(modreader); ok = l->Load(curious); - if (ok) { + if (ok) { /* propagate inflags=flags for in-module samples */ for (t = 0; t < of.numsmp; t++) if (of.samples[t].inflags == 0) @@ -492,27 +556,21 @@ MODULE* Player_LoadGeneric_internal(MREADER *reader,int maxchan,BOOL curious) if (l->Cleanup) l->Cleanup(); UniCleanup(); + if(ok) ok = ML_LoadSamples(); + if(ok) ok = ((mf=ML_AllocUniMod()) != NULL); if(!ok) { ML_FreeEx(&of); + if(modreader!=reader) { + _mm_delete_mem_reader(modreader); + modreader=reader; + MikMod_free(unpk); + } if(_mm_errorhandler) _mm_errorhandler(); - _mm_rewind(modreader);_mm_iobase_revert(modreader); + _mm_rewind(modreader); + _mm_iobase_revert(modreader); return NULL; } - if(!ML_LoadSamples()) { - ML_FreeEx(&of); - if(_mm_errorhandler) _mm_errorhandler(); - _mm_rewind(modreader);_mm_iobase_revert(modreader); - return NULL; - } - - if(!(mf=ML_AllocUniMod())) { - ML_FreeEx(&of); - _mm_rewind(modreader);_mm_iobase_revert(modreader); - if(_mm_errorhandler) _mm_errorhandler(); - return NULL; - } - /* If the module doesn't have any specific panning, create a MOD-like panning, with the channels half-separated. */ if (!(of.flags & UF_PANNING)) @@ -531,23 +589,23 @@ MODULE* Player_LoadGeneric_internal(MREADER *reader,int maxchan,BOOL curious) if(maxchannumchn) mf->flags |= UF_NNA; - if(MikMod_SetNumVoices_internal(maxchan,-1)) { - _mm_iobase_revert(modreader); - Player_Free(mf); - return NULL; - } + ok = !MikMod_SetNumVoices_internal(maxchan,-1); } - if(SL_LoadSamples()) { - _mm_iobase_revert(modreader); + + if(ok) ok = !SL_LoadSamples(); + if(ok) ok = !Player_Init(mf); + + if(modreader!=reader) { + _mm_delete_mem_reader(modreader); + modreader=reader; + MikMod_free(unpk); + } + _mm_iobase_revert(modreader); + + if(!ok) { Player_Free_internal(mf); return NULL; } - if(Player_Init(mf)) { - _mm_iobase_revert(modreader); - Player_Free_internal(mf); - mf=NULL; - } - _mm_iobase_revert(modreader); return mf; } @@ -569,7 +627,8 @@ MIKMODAPI MODULE* Player_LoadMem(const char *buffer,int len,int maxchan,BOOL cur MODULE* result=NULL; MREADER* reader; - if ((reader=_mm_new_mem_reader(buffer, len))) { + if (!buffer || len <= 0) return NULL; + if ((reader=_mm_new_mem_reader(buffer, len)) != NULL) { result=Player_LoadGeneric(reader,maxchan,curious); _mm_delete_mem_reader(reader); } @@ -581,9 +640,9 @@ MIKMODAPI MODULE* Player_LoadMem(const char *buffer,int len,int maxchan,BOOL cur MIKMODAPI MODULE* Player_LoadFP(FILE* fp,int maxchan,BOOL curious) { MODULE* result=NULL; - struct MREADER* reader=_mm_new_file_reader (fp); + struct MREADER* reader; - if (reader) { + if (fp && (reader=_mm_new_file_reader(fp)) != NULL) { result=Player_LoadGeneric(reader,maxchan,curious); _mm_delete_file_reader(reader); } @@ -592,12 +651,12 @@ MIKMODAPI MODULE* Player_LoadFP(FILE* fp,int maxchan,BOOL curious) /* Open a module via its filename. The loader will initialize the specified song-player 'player'. */ -MIKMODAPI MODULE* Player_Load(CHAR* filename,int maxchan,BOOL curious) +MIKMODAPI MODULE* Player_Load(const CHAR* filename,int maxchan,BOOL curious) { FILE *fp; MODULE *mf=NULL; - if((fp=_mm_fopen(filename,"rb"))) { + if((fp=_mm_fopen(filename,"rb")) != NULL) { mf=Player_LoadFP(fp,maxchan,curious); _mm_fclose(fp); } diff --git a/sc2/src/libs/mikmod/mlreg.c b/sc2/src/libs/mikmod/mlreg.c index 14f2d7f9a..85ceb18f8 100644 --- a/sc2/src/libs/mikmod/mlreg.c +++ b/sc2/src/libs/mikmod/mlreg.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 @@ -32,8 +32,9 @@ #include "mikmod_internals.h" -void MikMod_RegisterAllLoaders_internal(void) +static void MikMod_RegisterAllLoaders_internal(void) { + /* UQM edit: Cut down the loader list to those we support */ _mm_registerloader(&load_it); _mm_registerloader(&load_mod); _mm_registerloader(&load_s3m); @@ -41,7 +42,7 @@ void MikMod_RegisterAllLoaders_internal(void) _mm_registerloader(&load_xm); } -void MikMod_RegisterAllLoaders(void) +MIKMODAPI void MikMod_RegisterAllLoaders(void) { MUTEX_LOCK(lists); MikMod_RegisterAllLoaders_internal(); diff --git a/sc2/src/libs/mikmod/mlutil.c b/sc2/src/libs/mikmod/mlutil.c index 2ecf64eff..21dcb2087 100644 --- a/sc2/src/libs/mikmod/mlutil.c +++ b/sc2/src/libs/mikmod/mlutil.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 @@ -43,13 +43,13 @@ extern int fprintf(FILE *, const char *, ...); /*========== Shared tracker identifiers */ -CHAR *STM_Signatures[STM_NTRACKERS] = { +const CHAR *STM_Signatures[STM_NTRACKERS] = { "!Scream!", "BMOD2STM", "WUZAMOD!" }; -CHAR *STM_Version[STM_NTRACKERS] = { +const CHAR *STM_Version[STM_NTRACKERS] = { "Screamtracker 2", "Converted by MOD2STM (STM format)", "Wuzamod (STM format)" @@ -60,7 +60,7 @@ CHAR *STM_Version[STM_NTRACKERS] = { SBYTE remap[UF_MAXCHAN]; /* for removing empty channels */ UBYTE* poslookup=NULL; /* lookup table for pattern jumps after blank pattern removal */ -UBYTE poslookupcnt; +UWORD poslookupcnt; UWORD* origpositions=NULL; BOOL filters; /* resonant filters in use */ @@ -71,30 +71,27 @@ FILTER filtersettings[UF_MAXFILTER]; /* computed filter settings */ /*========== Linear periods stuff */ int* noteindex=NULL; /* remap value for linear period modules */ -static int noteindexcount=0; +static unsigned noteindexcount=0; int *AllocLinear(void) { if(of.numsmp>noteindexcount) { noteindexcount=of.numsmp; - noteindex=realloc(noteindex,noteindexcount*sizeof(int)); + noteindex=(int*)MikMod_realloc(noteindex,noteindexcount*sizeof(int)); } return noteindex; } void FreeLinear(void) { - if(noteindex) { - MikMod_free(noteindex); - noteindex=NULL; - } + MikMod_free(noteindex); + noteindex=NULL; noteindexcount=0; } int speed_to_finetune(ULONG speed,int sample) { - int note=1,finetune=0; - ULONG ctmp=0,tmp; + int ctmp=0,tmp,note=1,ft=0; speed>>=1; while((tmp=getfrequency(of.flags,getlinearperiod(note<<1,0)))speed) - tmp=getfrequency(of.flags,getlinearperiod(note<<1,--finetune)); + tmp=getfrequency(of.flags,getlinearperiod(note<<1,--ft)); else { note--; while(ctmp>4; - + UBYTE lo = inf&0xF; /* process S3M / IT specific command structure */ if(cmd!=255) { @@ -197,7 +190,7 @@ void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,unsigned int flags) case 9: /* Ixy tremor, ontime x, offtime y */ if (flags & S3MIT_OLDSTYLE) UniEffect(UNI_S3MEFFECTI,inf); - else + else UniEffect(UNI_ITEFFECTI,inf); break; case 0xa: /* Jxy arpeggio */ @@ -205,7 +198,7 @@ void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,unsigned int flags) break; case 0xb: /* Kxy Dual command H00 & Dxy */ if (flags & S3MIT_OLDSTYLE) - UniPTEffect(0x4,0); + UniPTEffect(0x4,0); else UniEffect(UNI_ITEFFECTH,0); UniEffect(UNI_S3MEFFECTD,inf); @@ -219,7 +212,7 @@ void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,unsigned int flags) break; case 0xd: /* Mxx Set Channel Volume */ UniEffect(UNI_ITEFFECTM,inf); - break; + break; case 0xe: /* Nxy Slide Channel Volume */ UniEffect(UNI_ITEFFECTN,inf); break; @@ -234,7 +227,7 @@ void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,unsigned int flags) if(inf && !lo && !(flags & S3MIT_OLDSTYLE)) UniWriteByte(1); else - UniWriteByte(inf); + UniWriteByte(inf); break; case 0x12: /* Rxy tremolo speed x, depth y */ UniEffect(UNI_S3MEFFECTR,inf); diff --git a/sc2/src/libs/mikmod/mmalloc.c b/sc2/src/libs/mikmod/mmalloc.c index cc8f8d916..ed5fd4684 100644 --- a/sc2/src/libs/mikmod/mmalloc.c +++ b/sc2/src/libs/mikmod/mmalloc.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 @@ -30,44 +30,113 @@ #include "config.h" #endif +#ifdef HAVE_POSIX_MEMALIGN +#define _XOPEN_SOURCE 600 /* for posix_memalign */ +#endif + +#include "string.h" #include "mikmod_internals.h" +#if defined(HAVE_SSE2) || defined(HAVE_ALTIVEC) +#undef WIN32_ALIGNED_MALLOC +#if defined(_WIN32) && !defined(_WIN32_WCE) +# if defined(_WIN64) /* OK with MSVC and MinGW */ +# define WIN32_ALIGNED_MALLOC +# elif defined(_MSC_VER) && (_MSC_VER >= 1300) +# define WIN32_ALIGNED_MALLOC +# elif defined(__MINGW32__) + /* no guarantees that msvcrt.dll will have it */ +# endif +#endif + +#define PTRSIZE (sizeof(void*)) + +/* return a 16 byte aligned address */ +void* MikMod_amalloc(size_t size) +{ + void *d; +#if defined(HAVE_POSIX_MEMALIGN) + if (!posix_memalign(&d, 16, size)) { + memset(d, 0, size); + return d; + } +#elif defined(WIN32_ALIGNED_MALLOC) + d = _aligned_malloc(size, 16); + if (d) { + ZeroMemory(d, size); + return d; + } +#else + size_t s = (size)? ((size + (PTRSIZE-1)) & ~(PTRSIZE-1)) : PTRSIZE; + s += PTRSIZE + 16; + d = calloc(1, s); + if (d) { + char *pptr = (char *)d + PTRSIZE; + size_t err = ((size_t)pptr) & 15; + char *fptr = pptr + (16 - err); + *(size_t*)(fptr - PTRSIZE) = (size_t)d; + return fptr; + } +#endif + + _mm_errno = MMERR_OUT_OF_MEMORY; + if(_mm_errorhandler) _mm_errorhandler(); + return NULL; +} + +void MikMod_afree(void *data) +{ + if (!data) return; +#if defined(HAVE_POSIX_MEMALIGN) + free(data); +#elif defined(WIN32_ALIGNED_MALLOC) + _aligned_free(data); +#else + free((void *) *(size_t*)((unsigned char *)data - PTRSIZE)); +#endif +} +#endif /* (HAVE_SSE2) || (HAVE_ALTIVEC) */ + void* MikMod_realloc(void *data, size_t size) { - if (data) - return realloc(data, size); - else - return MikMod_malloc(size); + if (data) return realloc(data, size); + return calloc(1, size); } /* Same as malloc, but sets error variable _mm_error when fails */ void* MikMod_malloc(size_t size) { - void *d; - - if(!(d=calloc(1,size))) { - _mm_errno = MMERR_OUT_OF_MEMORY; - if(_mm_errorhandler) _mm_errorhandler(); - } - return d; + return MikMod_calloc(1, size); } /* Same as calloc, but sets error variable _mm_error when fails */ -void* MikMod_calloc(size_t nitems,size_t size) +void* MikMod_calloc(size_t nitems, size_t size) { - void *d; - - if(!(d=calloc(nitems,size))) { - _mm_errno = MMERR_OUT_OF_MEMORY; - if(_mm_errorhandler) _mm_errorhandler(); - } + void *d = calloc(nitems, size); + if (d) return d; + + _mm_errno = MMERR_OUT_OF_MEMORY; + if(_mm_errorhandler) _mm_errorhandler(); + return NULL; +} + +void MikMod_free(void *data) +{ + if (data) free(data); +} + +/* like strdup(), but the result must be freed using MikMod_free() */ +CHAR *MikMod_strdup(const CHAR *s) +{ + size_t l; + CHAR *d; + + if (!s) return NULL; + + l = strlen(s) + 1; + d = (CHAR *) MikMod_calloc(1, l * sizeof(CHAR)); + if (d) strcpy(d, s); return d; } -void MikMod_free(void *p) -{ - if (p) - free(p); -} - /* ex:set ts=4: */ diff --git a/sc2/src/libs/mikmod/mmerror.c b/sc2/src/libs/mikmod/mmerror.c index efbde1949..cf4c99ea7 100644 --- a/sc2/src/libs/mikmod/mmerror.c +++ b/sc2/src/libs/mikmod/mmerror.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 @@ -40,7 +40,9 @@ #include "mikmod_internals.h" -CHAR *_mm_errmsg[MMERR_MAX+1] = +#define _mmerr_invalid "Invalid error code" + +static const char *_mm_errmsg[MMERR_MAX+1] = { /* No error */ @@ -82,62 +84,89 @@ CHAR *_mm_errmsg[MMERR_MAX+1] = "Unable to set non-blocking mode for audio device", /* AudioFile driver errors */ - +#ifdef DRV_AF "Cannot find suitable AudioFile audio port", +#else + _mmerr_invalid, +#endif /* AIX driver errors */ - +#ifdef DRV_AIX "Configuration (init step) of audio device failed", "Configuration (control step) of audio device failed", "Configuration (start step) of audio device failed", - -/* ALSA driver errors */ - -/* EsounD driver errors */ +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, +#endif /* Ultrasound driver errors */ - +#ifdef DRV_ULTRA "Ultrasound driver only works in 16 bit stereo 44 KHz", "Ultrasound card could not be reset", "Could not start Ultrasound timer", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, +#endif /* HP driver errors */ - +#ifdef DRV_HP "Unable to select 16bit-linear sample format", "Could not select requested sample-rate", "Could not select requested number of channels", "Unable to select audio output", "Unable to get audio description", "Could not set transmission buffer size", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, +#endif /* Open Sound System driver errors */ - +#ifdef DRV_OSS "Could not set fragment size", "Could not set sample size", "Could not set mono/stereo setting", "Could not set sample rate", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, +#endif /* SGI driver errors */ - +#ifdef DRV_SGI "Unsupported sample rate", "Hardware does not support 16 bit sound", "Hardware does not support 8 bit sound", "Hardware does not support stereo sound", "Hardware does not support mono sound", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, +#endif /* Sun driver errors */ - +#ifdef DRV_SUN "Sound device initialization failed", +#else + _mmerr_invalid, +#endif /* OS/2 drivers errors */ - +#if defined(DRV_OS2) || defined(DRV_DART) "Could not set mixing parameters", +#else + _mmerr_invalid, +#endif +#ifdef DRV_OS2 "Could not create playback semaphores", "Could not create playback timer", "Could not create playback thread", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, +#endif /* DirectSound driver errors */ - +#ifdef DRV_DS "Could not set playback priority", "Could not create playback buffers", "Could not set playback format", @@ -145,28 +174,117 @@ CHAR *_mm_errmsg[MMERR_MAX+1] = "Could not register event", "Could not create playback thread", "Could not initialize playback thread", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, +#endif /* Windows Multimedia API driver errors */ - +#ifdef DRV_WIN "Invalid device handle", "The resource is already allocated", "Invalid device identifier", "Unsupported output format", "Unknown error", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, +#endif /* Macintosh driver errors */ - +#ifdef DRV_MAC "Unsupported sample rate", "Could not start playback", +#else + _mmerr_invalid, _mmerr_invalid, +#endif + +/* MacOS X/Darwin driver errors */ +#ifdef DRV_OSX + "Unknown device", + "Bad property", + "Could not set playback format", + "Could not set mono/stereo setting", + "Could not create playback buffers", + "Could not create playback thread", + "Could not start audio device", + "Could not create buffer thread", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, +#endif + +/* DOS driver errors */ +#ifdef DRV_WSS + "WSS_STARTDMA", +#else + _mmerr_invalid, +#endif +#ifdef DRV_SB + "SB_STARTDMA", +#else + _mmerr_invalid, +#endif + +/* float32 output */ + + "This driver doesn't support 32 bit float output", + +/* OpenAL driver errors */ +#ifdef DRV_OPENAL + "Could not create context", + "Could not make context current", + "Could not create buffers", + "Could not create sources", + "Could not change source parameters", + "Could not queue buffers", + "Could not unqueue buffers", + "Could not copy buffer data", + "Could not get source parameters", + "Could not play source", + "Could not stop source", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, +#endif + +/* ALSA driver errors */ +#ifdef DRV_ALSA + "No ALSA configurations available", + "Could not set ALSA output params", + "Could not set playback format", + "Could not set sample rate", + "Could not set mono/stereo setting", + "Could not get buffer size from ALSA", + "ALSA PCM start error", + "ALSA PCM write error", + "ALSA PCM recovery failure", +#else + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, + _mmerr_invalid, _mmerr_invalid, _mmerr_invalid, +#endif + +/* Sndio errors */ +#ifdef DRV_SNDIO + "Could not set SNDIO output params", + "Unsupported SNDIO output params", +#else + _mmerr_invalid, _mmerr_invalid, +#endif /* Invalid error */ - "Invalid error code" + _mmerr_invalid }; -MIKMODAPI char *MikMod_strerror(int code) +MIKMODAPI const char *MikMod_strerror(int code) { - if ((code<0)||(code>MMERR_MAX)) code=MMERR_MAX+1; + if ((code<0)||(code>MMERR_MAX)) code=MMERR_MAX; return _mm_errmsg[code]; } @@ -175,7 +293,7 @@ MikMod_handler_t _mm_errorhandler = NULL; MIKMODAPI int _mm_errno = 0; MIKMODAPI BOOL _mm_critical = 0; -MikMod_handler_t _mm_registererrorhandler(MikMod_handler_t proc) +static MikMod_handler_t _mm_registererrorhandler(MikMod_handler_t proc) { MikMod_handler_t oldproc=_mm_errorhandler; diff --git a/sc2/src/libs/mikmod/mmio.c b/sc2/src/libs/mikmod/mmio.c index 0f8a07970..caf5d887b 100644 --- a/sc2/src/libs/mikmod/mmio.c +++ b/sc2/src/libs/mikmod/mmio.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 @@ -43,18 +43,14 @@ */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #ifdef HAVE_UNISTD_H #include #endif +#include #include #include -//#include "mikmod.h" #include "mikmod_internals.h" #ifdef SUNOS @@ -66,17 +62,14 @@ extern int fseek(FILE *, long, int); extern size_t fwrite(const void *, size_t, size_t, FILE *); #endif -#define COPY_BUFSIZE 1024 - /* some prototypes */ static BOOL _mm_MemReader_Eof(MREADER* reader); static BOOL _mm_MemReader_Read(MREADER* reader,void* ptr,size_t size); static int _mm_MemReader_Get(MREADER* reader); -static BOOL _mm_MemReader_Seek(MREADER* reader,long offset,int whence); +static int _mm_MemReader_Seek(MREADER* reader,long offset,int whence); static long _mm_MemReader_Tell(MREADER* reader); - -FILE* _mm_fopen(CHAR* fname,CHAR* attrib) +FILE* _mm_fopen(const CHAR* fname, const CHAR* attrib) { FILE *fp; @@ -87,7 +80,7 @@ FILE* _mm_fopen(CHAR* fname,CHAR* attrib) return fp; } -BOOL _mm_FileExists(CHAR* fname) +BOOL _mm_FileExists(const CHAR* fname) { FILE *fp; @@ -137,7 +130,7 @@ static int _mm_FileReader_Get(MREADER* reader) return fgetc(((MFILEREADER*)reader)->file); } -static BOOL _mm_FileReader_Seek(MREADER* reader,long offset,int whence) +static int _mm_FileReader_Seek(MREADER* reader,long offset,int whence) { return fseek(((MFILEREADER*)reader)->file, (whence==SEEK_SET)?offset+reader->iobase:offset,whence); @@ -150,7 +143,7 @@ static long _mm_FileReader_Tell(MREADER* reader) MREADER *_mm_new_file_reader(FILE* fp) { - MFILEREADER* reader=(MFILEREADER*)MikMod_malloc(sizeof(MFILEREADER)); + MFILEREADER* reader=(MFILEREADER*)MikMod_calloc(1,sizeof(MFILEREADER)); if (reader) { reader->core.Eof =&_mm_FileReader_Eof; reader->core.Read=&_mm_FileReader_Read; @@ -164,7 +157,7 @@ MREADER *_mm_new_file_reader(FILE* fp) void _mm_delete_file_reader (MREADER* reader) { - if(reader) MikMod_free(reader); + MikMod_free(reader); } /*========== File Writer */ @@ -174,7 +167,7 @@ typedef struct MFILEWRITER { FILE* file; } MFILEWRITER; -static BOOL _mm_FileWriter_Seek(MWRITER* writer,long offset,int whence) +static int _mm_FileWriter_Seek(MWRITER* writer,long offset,int whence) { return fseek(((MFILEWRITER*)writer)->file,offset,whence); } @@ -184,19 +177,19 @@ static long _mm_FileWriter_Tell(MWRITER* writer) return ftell(((MFILEWRITER*)writer)->file); } -static BOOL _mm_FileWriter_Write(MWRITER* writer,void* ptr,size_t size) +static BOOL _mm_FileWriter_Write(MWRITER* writer, const void* ptr, size_t size) { return (fwrite(ptr,size,1,((MFILEWRITER*)writer)->file)==size); } -static BOOL _mm_FileWriter_Put(MWRITER* writer,int value) +static int _mm_FileWriter_Put(MWRITER* writer,int value) { return fputc(value,((MFILEWRITER*)writer)->file); } MWRITER *_mm_new_file_writer(FILE* fp) { - MFILEWRITER* writer=(MFILEWRITER*)MikMod_malloc(sizeof(MFILEWRITER)); + MFILEWRITER* writer=(MFILEWRITER*)MikMod_calloc(1,sizeof(MFILEWRITER)); if (writer) { writer->core.Seek =&_mm_FileWriter_Seek; writer->core.Tell =&_mm_FileWriter_Tell; @@ -209,12 +202,11 @@ MWRITER *_mm_new_file_writer(FILE* fp) void _mm_delete_file_writer (MWRITER* writer) { - if(writer) MikMod_free (writer); + MikMod_free (writer); } /*========== Memory Reader */ - typedef struct MMEMREADER { MREADER core; const void *buffer; @@ -224,12 +216,12 @@ typedef struct MMEMREADER { void _mm_delete_mem_reader(MREADER* reader) { - if (reader) { MikMod_free(reader); } + MikMod_free(reader); } -MREADER *_mm_new_mem_reader(const void *buffer, int len) +MREADER *_mm_new_mem_reader(const void *buffer, long len) { - MMEMREADER* reader=(MMEMREADER*)MikMod_malloc(sizeof(MMEMREADER)); + MMEMREADER* reader=(MMEMREADER*)MikMod_calloc(1,sizeof(MMEMREADER)); if (reader) { reader->core.Eof =&_mm_MemReader_Eof; @@ -246,74 +238,86 @@ MREADER *_mm_new_mem_reader(const void *buffer, int len) static BOOL _mm_MemReader_Eof(MREADER* reader) { - if (!reader) { return 1; } - if ( ((MMEMREADER*)reader)->pos > ((MMEMREADER*)reader)->len ) { - return 1; - } + MMEMREADER* mr = (MMEMREADER*) reader; + if (!mr) return 1; + if (mr->pos >= mr->len) return 1; return 0; } static BOOL _mm_MemReader_Read(MREADER* reader,void* ptr,size_t size) { - unsigned char *d=ptr; + unsigned char *d; const unsigned char *s; - - if (!reader) { return 0; } + MMEMREADER* mr; + long siz; + BOOL ret; - if (reader->Eof(reader)) { return 0; } + if (!reader || !size || (size > (size_t) LONG_MAX)) + return 0; - s = ((MMEMREADER*)reader)->buffer; - s += ((MMEMREADER*)reader)->pos; - - if ( ((MMEMREADER*)reader)->pos + (long)size > ((MMEMREADER*)reader)->len) - { - ((MMEMREADER*)reader)->pos = ((MMEMREADER*)reader)->len; - return 0; /* not enough remaining bytes */ + mr = (MMEMREADER*) reader; + siz = (long) size; + if (mr->pos >= mr->len) return 0; /* @ eof */ + if (mr->pos + siz > mr->len) { + siz = mr->len - mr->pos; + ret = 0; /* not enough remaining bytes */ + } + else { + ret = 1; } - ((MMEMREADER*)reader)->pos += (long)size; + s = (const unsigned char *) mr->buffer; + s += mr->pos; + mr->pos += siz; + d = (unsigned char *) ptr; - while (size--) - { - *d = *s; - s++; - d++; + while (siz) { + *d++ = *s++; + siz--; } - - return 1; + + return ret; } static int _mm_MemReader_Get(MREADER* reader) { - int pos; + MMEMREADER* mr; + int c; - if (reader->Eof(reader)) { return 0; } - - pos = ((MMEMREADER*)reader)->pos; - ((MMEMREADER*)reader)->pos++; + mr = (MMEMREADER*) reader; + if (mr->pos >= mr->len) return EOF; + c = ((const unsigned char*) mr->buffer)[mr->pos]; + mr->pos++; - return ((unsigned char*)(((MMEMREADER*)reader)->buffer))[pos]; + return c; } -static BOOL _mm_MemReader_Seek(MREADER* reader,long offset,int whence) +static int _mm_MemReader_Seek(MREADER* reader,long offset,int whence) { - if (!reader) { return -1; } - + MMEMREADER* mr; + + if (!reader) return -1; + mr = (MMEMREADER*) reader; switch(whence) { - case SEEK_CUR: - ((MMEMREADER*)reader)->pos += offset; - break; - case SEEK_SET: - ((MMEMREADER*)reader)->pos = offset; - break; - case SEEK_END: - ((MMEMREADER*)reader)->pos = ((MMEMREADER*)reader)->len - offset - 1; - break; + case SEEK_CUR: + mr->pos += offset; + break; + case SEEK_SET: + mr->pos = reader->iobase + offset; + break; + case SEEK_END: + mr->pos = mr->len + offset; + break; + default: /* invalid */ + return -1; } - if ( ((MMEMREADER*)reader)->pos < 0) { ((MMEMREADER*)reader)->pos = 0; } - if ( ((MMEMREADER*)reader)->pos > ((MMEMREADER*)reader)->len ) { - ((MMEMREADER*)reader)->pos = ((MMEMREADER*)reader)->len; + if (mr->pos < reader->iobase) { + mr->pos = mr->core.iobase; + return -1; + } + if (mr->pos > mr->len) { + mr->pos = mr->len; } return 0; } @@ -321,14 +325,14 @@ static BOOL _mm_MemReader_Seek(MREADER* reader,long offset,int whence) static long _mm_MemReader_Tell(MREADER* reader) { if (reader) { - return ((MMEMREADER*)reader)->pos; + return ((MMEMREADER*)reader)->pos - reader->iobase; } return 0; } /*========== Write functions */ -void _mm_write_string(CHAR* data,MWRITER* writer) +void _mm_write_string(const CHAR* data,MWRITER* writer) { if(data) _mm_write_UBYTES(data,strlen(data),writer); @@ -378,37 +382,51 @@ void _mm_write_I_SLONG(SLONG data,MWRITER* writer) _mm_write_I_ULONG((ULONG)data,writer); } -#if defined __STDC__ || defined _MSC_VER || defined MPW_C -#define DEFINE_MULTIPLE_WRITE_FUNCTION(type_name,type) \ -void _mm_write_##type_name##S (type *buffer,int number,MWRITER* writer) \ -{ \ - while(number-->0) \ - _mm_write_##type_name(*(buffer++),writer); \ +void _mm_write_M_SWORDS(SWORD *buffer,int cnt,MWRITER* writer) +{ + while(cnt-- > 0) _mm_write_M_SWORD(*(buffer++),writer); } -#else -#define DEFINE_MULTIPLE_WRITE_FUNCTION(type_name,type) \ -void _mm_write_/**/type_name/**/S (type *buffer,int number,MWRITER* writer) \ -{ \ - while(number-->0) \ - _mm_write_/**/type_name(*(buffer++),writer); \ + +void _mm_write_M_UWORDS(UWORD *buffer,int cnt,MWRITER* writer) +{ + while(cnt-- > 0) _mm_write_M_UWORD(*(buffer++),writer); } -#endif -DEFINE_MULTIPLE_WRITE_FUNCTION(M_SWORD,SWORD) -DEFINE_MULTIPLE_WRITE_FUNCTION(M_UWORD,UWORD) -DEFINE_MULTIPLE_WRITE_FUNCTION(I_SWORD,SWORD) -DEFINE_MULTIPLE_WRITE_FUNCTION(I_UWORD,UWORD) +void _mm_write_I_SWORDS(SWORD *buffer,int cnt,MWRITER* writer) +{ + while(cnt-- > 0) _mm_write_I_SWORD(*(buffer++),writer); +} -DEFINE_MULTIPLE_WRITE_FUNCTION(M_SLONG,SLONG) -DEFINE_MULTIPLE_WRITE_FUNCTION(M_ULONG,ULONG) -DEFINE_MULTIPLE_WRITE_FUNCTION(I_SLONG,SLONG) -DEFINE_MULTIPLE_WRITE_FUNCTION(I_ULONG,ULONG) +void _mm_write_I_UWORDS(UWORD *buffer,int cnt,MWRITER* writer) +{ + while(cnt-- > 0) _mm_write_I_UWORD(*(buffer++),writer); +} + +void _mm_write_M_SLONGS(SLONG *buffer,int cnt,MWRITER* writer) +{ + while(cnt-- > 0) _mm_write_M_SLONG(*(buffer++),writer); +} + +void _mm_write_M_ULONGS(ULONG *buffer,int cnt,MWRITER* writer) +{ + while(cnt-- > 0) _mm_write_M_ULONG(*(buffer++),writer); +} + +void _mm_write_I_SLONGS(SLONG *buffer,int cnt,MWRITER* writer) +{ + while(cnt-- > 0) _mm_write_I_SLONG(*(buffer++),writer); +} + +void _mm_write_I_ULONGS(ULONG *buffer,int cnt,MWRITER* writer) +{ + while(cnt-- > 0) _mm_write_I_ULONG(*(buffer++),writer); +} /*========== Read functions */ -int _mm_read_string(CHAR* buffer,int number,MREADER* reader) +BOOL _mm_read_string(CHAR* buffer,int cnt,MREADER* reader) { - return reader->Read(reader,buffer,number); + return reader->Read(reader,buffer,cnt); } UWORD _mm_read_M_UWORD(MREADER* reader) @@ -459,32 +477,52 @@ SLONG _mm_read_I_SLONG(MREADER* reader) return((SLONG)_mm_read_I_ULONG(reader)); } -#if defined __STDC__ || defined _MSC_VER || defined MPW_C -#define DEFINE_MULTIPLE_READ_FUNCTION(type_name,type) \ -int _mm_read_##type_name##S (type *buffer,int number,MREADER* reader) \ -{ \ - while(number-->0) \ - *(buffer++)=_mm_read_##type_name(reader); \ - return !reader->Eof(reader); \ +BOOL _mm_read_M_SWORDS(SWORD *buffer,int cnt,MREADER* reader) +{ + while(cnt-- > 0) *(buffer++)=_mm_read_M_SWORD(reader); + return !reader->Eof(reader); } -#else -#define DEFINE_MULTIPLE_READ_FUNCTION(type_name,type) \ -int _mm_read_/**/type_name/**/S (type *buffer,int number,MREADER* reader) \ -{ \ - while(number-->0) \ - *(buffer++)=_mm_read_/**/type_name(reader); \ - return !reader->Eof(reader); \ + +BOOL _mm_read_M_UWORDS(UWORD *buffer,int cnt,MREADER* reader) +{ + while(cnt-- > 0) *(buffer++)=_mm_read_M_UWORD(reader); + return !reader->Eof(reader); } -#endif -DEFINE_MULTIPLE_READ_FUNCTION(M_SWORD,SWORD) -DEFINE_MULTIPLE_READ_FUNCTION(M_UWORD,UWORD) -DEFINE_MULTIPLE_READ_FUNCTION(I_SWORD,SWORD) -DEFINE_MULTIPLE_READ_FUNCTION(I_UWORD,UWORD) +BOOL _mm_read_I_SWORDS(SWORD *buffer,int cnt,MREADER* reader) +{ + while(cnt-- > 0) *(buffer++)=_mm_read_I_SWORD(reader); + return !reader->Eof(reader); +} -DEFINE_MULTIPLE_READ_FUNCTION(M_SLONG,SLONG) -DEFINE_MULTIPLE_READ_FUNCTION(M_ULONG,ULONG) -DEFINE_MULTIPLE_READ_FUNCTION(I_SLONG,SLONG) -DEFINE_MULTIPLE_READ_FUNCTION(I_ULONG,ULONG) +BOOL _mm_read_I_UWORDS(UWORD *buffer,int cnt,MREADER* reader) +{ + while(cnt-- > 0) *(buffer++)=_mm_read_I_UWORD(reader); + return !reader->Eof(reader); +} + +BOOL _mm_read_M_SLONGS(SLONG *buffer,int cnt,MREADER* reader) +{ + while(cnt-- > 0) *(buffer++)=_mm_read_M_SLONG(reader); + return !reader->Eof(reader); +} + +BOOL _mm_read_M_ULONGS(ULONG *buffer,int cnt,MREADER* reader) +{ + while(cnt-- > 0) *(buffer++)=_mm_read_M_ULONG(reader); + return !reader->Eof(reader); +} + +BOOL _mm_read_I_SLONGS(SLONG *buffer,int cnt,MREADER* reader) +{ + while(cnt-- > 0) *(buffer++)=_mm_read_I_SLONG(reader); + return !reader->Eof(reader); +} + +BOOL _mm_read_I_ULONGS(ULONG *buffer,int cnt,MREADER* reader) +{ + while(cnt-- > 0) *(buffer++)=_mm_read_I_ULONG(reader); + return !reader->Eof(reader); +} /* ex:set ts=4: */ diff --git a/sc2/src/libs/mikmod/mplayer.c b/sc2/src/libs/mikmod/mplayer.c index 812410a15..e8c46ea1b 100644 --- a/sc2/src/libs/mikmod/mplayer.c +++ b/sc2/src/libs/mikmod/mplayer.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 @@ -48,25 +48,25 @@ extern long int random(void); #endif /* The currently playing module */ -/* This variable should better be static, but it would break the ABI, so this - will wait */ -/*static*/ MODULE *pf = NULL; +MODULE *pf = NULL; + +#define NUMVOICES(mod) (md_sngchn < (mod)->numvoices ? md_sngchn : (mod)->numvoices) #define HIGH_OCTAVE 2 /* number of above-range octaves */ -static UWORD oldperiods[OCTAVE*2]={ +static const UWORD oldperiods[OCTAVE*2]={ 0x6b00, 0x6800, 0x6500, 0x6220, 0x5f50, 0x5c80, 0x5a00, 0x5740, 0x54d0, 0x5260, 0x5010, 0x4dc0, 0x4b90, 0x4960, 0x4750, 0x4540, 0x4350, 0x4160, 0x3f90, 0x3dc0, 0x3c10, 0x3a40, 0x38b0, 0x3700 }; -static UBYTE VibratoTable[32]={ +static const UBYTE VibratoTable[32]={ 0, 24, 49, 74, 97,120,141,161,180,197,212,224,235,244,250,253, 255,253,250,244,235,224,212,197,180,161,141,120, 97, 74, 49, 24 }; -static UBYTE avibtab[128]={ +static const UBYTE avibtab[128]={ 0, 1, 3, 4, 6, 7, 9,10,12,14,15,17,18,20,21,23, 24,25,27,28,30,31,32,34,35,36,38,39,40,41,42,44, 45,46,47,48,49,50,51,52,53,54,54,55,56,57,57,58, @@ -78,7 +78,7 @@ static UBYTE avibtab[128]={ }; /* Triton's linear periods to frequency translation table (for XM modules) */ -static ULONG lintab[768]={ +static const ULONG lintab[768]={ 535232,534749,534266,533784,533303,532822,532341,531861, 531381,530902,530423,529944,529466,528988,528511,528034, 527558,527082,526607,526131,525657,525183,524709,524236, @@ -178,7 +178,7 @@ static ULONG lintab[768]={ }; #define LOGFAC 2*16 -static UWORD logtab[104]={ +static const UWORD logtab[104]={ LOGFAC*907,LOGFAC*900,LOGFAC*894,LOGFAC*887, LOGFAC*881,LOGFAC*875,LOGFAC*868,LOGFAC*862, LOGFAC*856,LOGFAC*850,LOGFAC*844,LOGFAC*838, @@ -207,7 +207,7 @@ static UWORD logtab[104]={ LOGFAC*440,LOGFAC*437,LOGFAC*434,LOGFAC*431 }; -static SBYTE PanbrelloTable[256]={ +static const SBYTE PanbrelloTable[256]={ 0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 16, 17, 19, 20, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, @@ -227,12 +227,12 @@ static SBYTE PanbrelloTable[256]={ }; /* returns a random value between 0 and ceil-1, ceil must be a power of two */ -static int getrandom(int ceil) +static int getrandom(int ceilval) { -#ifdef HAVE_SRANDOM - return random()&(ceil-1); +#if defined(HAVE_SRANDOM) && !defined(_MIKMOD_AMIGA) + return random()&(ceilval-1); #else - return (rand()*ceil)/(RAND_MAX+1.0); + return (rand()*ceilval)/(RAND_MAX+1.0); #endif } @@ -248,14 +248,14 @@ static int MP_FindEmptyChannel(MODULE *mod) MP_VOICE *a; ULONG t,k,tvol,pp; - for (t=0;tvoice[t].main.kick==KICK_ABSENT)|| (mod->voice[t].main.kick==KICK_ENV))&& Voice_Stopped_internal(t)) return t; tvol=0xffffffUL;t=-1;a=mod->voice; - for (k=0;kmain.s) return k; @@ -327,9 +327,9 @@ static UWORD GetPeriod(UWORD flags, UWORD note, ULONG speed) { if (flags & UF_XMPERIODS) { if (flags & UF_LINEAR) - return getlinearperiod(note, speed); + return getlinearperiod(note, speed); else - return getlogperiod(note, speed); + return getlogperiod(note, speed); } else return getoldperiod(note, speed); } @@ -363,7 +363,8 @@ static SWORD StartEnvelope(ENVPR *t,UBYTE flg,UBYTE pts,UBYTE susbeg,UBYTE susen /* Imago Orpheus sometimes stores an extra initial point in the envelope */ if ((t->pts>=2)&&(t->env[0].pos==t->env[1].pos)) { - t->a++;t->b++; + t->a++; + t->b++; } /* Fit in the envelope, still */ @@ -549,9 +550,6 @@ static int DoPTEffect0(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat = UniGetByte(); if (!tick) { if (!dat && (flags & UF_ARPMEM)) @@ -569,10 +567,6 @@ static int DoPTEffect1(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat = UniGetByte(); if (!tick && dat) a->slidespeed = (UWORD)dat << 2; @@ -587,10 +581,6 @@ static int DoPTEffect2(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat = UniGetByte(); if (!tick && dat) a->slidespeed = (UWORD)dat << 2; @@ -620,10 +610,10 @@ static void DoToneSlide(UWORD tick, MP_CONTROL *a) /* ...make tmpperiod equal tperiod */ a->tmpperiod=a->main.period=a->wantedperiod; else if (dist>0) { - a->tmpperiod-=a->portspeed; + a->tmpperiod-=a->portspeed; a->main.period-=a->portspeed; /* dist>0, slide up */ } else { - a->tmpperiod+=a->portspeed; + a->tmpperiod+=a->portspeed; a->main.period+=a->portspeed; /* dist<0, slide down */ } } else @@ -635,10 +625,6 @@ static int DoPTEffect3(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if ((!tick)&&(dat)) a->portspeed=(UWORD)dat<<2; if (a->main.period) @@ -691,10 +677,6 @@ static int DoPTEffect4(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (!tick) { if (dat&0x0f) a->vibdepth=dat&0xf; @@ -723,10 +705,6 @@ static int DoPTEffect5(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (a->main.period) DoToneSlide(tick, a); @@ -745,10 +723,6 @@ static int DoPTEffect7(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR UBYTE q; UWORD temp = 0; /* silence warning */ - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (!tick) { if (dat&0x0f) a->trmdepth=dat&0xf; @@ -796,9 +770,6 @@ static int DoPTEffect8(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)tick; /* unused arg */ - (void)flags; /* unused arg */ - dat = UniGetByte(); if (mod->panflag) a->main.panning = mod->panning[channel] = dat; @@ -810,10 +781,6 @@ static int DoPTEffect9(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (!tick) { if (dat) a->soffset=(UWORD)dat<<8; @@ -831,10 +798,6 @@ static int DoPTEffectA(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (tick) DoVolSlide(a, dat); @@ -855,9 +818,6 @@ static int DoPTEffectB(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (tick || mod->patdly2) @@ -870,8 +830,8 @@ static int DoPTEffectB(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR if (!mod->loop && !mod->patbrk && (dat < mod->sngpos || (mod->sngpos == (mod->numpos - 1) && !mod->patbrk) || - (dat == mod->sngpos && (flags & UF_NOWRAP)) - )) { + (dat == mod->sngpos && (flags & UF_NOWRAP)) ) ) + { /* if we don't loop, better not to skip the end of the pattern, after all... so: mod->patbrk=0; */ @@ -883,6 +843,9 @@ static int DoPTEffectB(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR mod->sngpos=dat; mod->posjmp=2; mod->patpos=0; + /* cancel the FT2 pattern loop (E60) bug. + * also see DoEEffects() below for it. */ + if (flags & UF_FT2QUIRKS) mod->patbrk=0; } return 0; @@ -892,15 +855,11 @@ static int DoPTEffectC(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - - dat=UniGetByte(); - if (tick) return 0; - if (dat==(UBYTE)-1) a->anote=dat=0; /* note cut */ - else if (dat>64) dat=64; - a->tmpvolume=dat; + dat=UniGetByte(); + if (tick) return 0; + if (dat==(UBYTE)-1) a->anote=dat=0; /* note cut */ + else if (dat>64) dat=64; + a->tmpvolume=dat; return 0; } @@ -909,29 +868,26 @@ static int DoPTEffectD(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - - dat=UniGetByte(); - if ((tick)||(mod->patdly2)) return 0; - if ((mod->positions[mod->sngpos]!=LAST_PATTERN)&& - (dat>mod->pattrows[mod->positions[mod->sngpos]])) - dat=mod->pattrows[mod->positions[mod->sngpos]]; - mod->patbrk=dat; - if (!mod->posjmp) { - /* don't ask me to explain this code - it makes - backwards.s3m and children.xm (heretic's version) play - correctly, among others. Take that for granted, or write - the page of comments yourself... you might need some - aspirin - Miod */ - if ((mod->sngpos==mod->numpos-1)&&(dat)&&((mod->loop)|| - (mod->positions[mod->sngpos]==(mod->numpat-1) - && !(flags&UF_NOWRAP)))) { - mod->sngpos=0; - mod->posjmp=2; - } else - mod->posjmp=3; - } + dat=UniGetByte(); + if ((tick)||(mod->patdly2)) return 0; + if ((mod->positions[mod->sngpos]!=LAST_PATTERN)&& + (dat>mod->pattrows[mod->positions[mod->sngpos]])) { + dat=mod->pattrows[mod->positions[mod->sngpos]]; + } + mod->patbrk=dat; + if (!mod->posjmp) { + /* don't ask me to explain this code - it makes + backwards.s3m and children.xm (heretic's version) play + correctly, among others. Take that for granted, or write + the page of comments yourself... you might need some + aspirin - Miod */ + if ((mod->sngpos==mod->numpos-1)&&(dat)&& + ((mod->loop) || (mod->positions[mod->sngpos]==(mod->numpat-1) && !(flags&UF_NOWRAP)))) { + mod->sngpos=0; + mod->posjmp=2; + } else + mod->posjmp=3; + } return 0; } @@ -997,8 +953,13 @@ static void DoEEffects(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, } else mod->patpos=a->pat_reppos; } else a->pat_reppos=POS_NONE; - } else + } else { a->pat_reppos=mod->patpos-1; /* set reppos - can be (-1) */ + /* emulate the FT2 pattern loop (E60) bug: + * http://milkytracker.org/docs/MilkyTracker.html#fxE6x + * roadblas.xm plays correctly with this. */ + if (flags & UF_FT2QUIRKS) mod->patbrk=mod->patpos; + } break; case 0x7: /* set tremolo waveform */ a->wavecontrol&=0x0f; @@ -1073,15 +1034,11 @@ static int DoPTEffectF(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (tick||mod->patdly2) return 0; if (mod->extspd&&(dat>=mod->bpmlimit)) mod->bpm=dat; - else + else if (dat) { mod->sngspd=(dat>=mod->bpmlimit)?mod->bpmlimit-1:dat; mod->vbtick=0; @@ -1096,10 +1053,6 @@ static int DoS3MEffectA(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE speed; - (void)flags; /* unused arg */ - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - speed = UniGetByte(); if (tick || mod->patdly2) @@ -1149,9 +1102,6 @@ static void DoS3MVolSlide(UWORD tick, UWORD flags, MP_CONTROL *a, UBYTE inf) static int DoS3MEffectD(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD channel) { - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - DoS3MVolSlide(tick, flags, a, UniGetByte()); return 1; @@ -1183,10 +1133,6 @@ static int DoS3MEffectE(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (a->main.period) DoS3MSlideDn(tick, a,dat); @@ -1218,10 +1164,6 @@ static int DoS3MEffectF(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (a->main.period) DoS3MSlideUp(tick, a,dat); @@ -1233,10 +1175,6 @@ static int DoS3MEffectI(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE inf, on, off; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - inf = UniGetByte(); if (inf) a->s3mtronof = inf; @@ -1263,9 +1201,6 @@ static int DoS3MEffectQ(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE inf; - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - inf = UniGetByte(); if (a->main.period) { if (inf) { @@ -1328,10 +1263,6 @@ static int DoS3MEffectR(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO UBYTE dat, q; UWORD temp=0; /* silence warning */ - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat = UniGetByte(); if (!tick) { if (dat&0x0f) a->trmdepth=dat&0xf; @@ -1379,10 +1310,6 @@ static int DoS3MEffectT(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE tempo; - (void)flags; /* unused arg */ - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - tempo = UniGetByte(); if (tick || mod->patdly2) @@ -1398,10 +1325,6 @@ static int DoS3MEffectU(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO UBYTE dat, q; UWORD temp = 0; /* silence warning */ - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat = UniGetByte(); if (!tick) { if (dat&0x0f) a->vibdepth=dat&0xf; @@ -1446,11 +1369,6 @@ static int DoS3MEffectU(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO static int DoKeyOff(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD channel) { - (void)tick; /* unused arg */ - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - a->main.keyoff|=KEY_OFF; if ((!(a->main.volflg&EF_ON))||(a->main.volflg&EF_LOOP)) a->main.keyoff=KEY_KILL; @@ -1462,9 +1380,6 @@ static int DoKeyFade(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD { UBYTE dat; - (void)flags; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if ((tick>=dat)||(tick==mod->sngspd-1)) { a->main.keyoff=KEY_KILL; @@ -1483,16 +1398,12 @@ static int DoXMEffectA(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE inf, lo, hi; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - inf = UniGetByte(); if (inf) a->s3mvolslide = inf; else inf = a->s3mvolslide; - + if (tick) { lo=inf&0xf; hi=inf>>4; @@ -1521,10 +1432,6 @@ static int DoXMEffectE1(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (!tick) { if (dat) a->fportupspd=dat; @@ -1539,10 +1446,6 @@ static int DoXMEffectE2(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (!tick) { if (dat) a->fportdnspd=dat; @@ -1557,10 +1460,6 @@ static int DoXMEffectEA(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (!tick) if (dat) a->fslideupspd=dat; @@ -1574,10 +1473,6 @@ static int DoXMEffectEB(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if (!tick) if (dat) a->fslidednspd=dat; @@ -1589,11 +1484,6 @@ static int DoXMEffectEB(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO static int DoXMEffectG(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD channel) { - (void)tick; /* unused arg */ - (void)flags; /* unused arg */ - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - mod->volume=UniGetByte()<<1; if (mod->volume>128) mod->volume=128; @@ -1604,10 +1494,6 @@ static int DoXMEffectH(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE inf; - (void)flags; /* unused arg */ - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - inf = UniGetByte(); if (tick) { @@ -1629,17 +1515,13 @@ static int DoXMEffectL(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat=UniGetByte(); if ((!tick)&&(a->main.i)) { UWORD points; INSTRUMENT *i=a->main.i; MP_VOICE *aout; - if ((aout=a->slave)) { + if ((aout=a->slave) != NULL) { if (aout->venv.env) { points=i->volenv[i->volpts-1].pos; aout->venv.p=aout->venv.env[(dat>points)?points:dat].pos; @@ -1659,9 +1541,6 @@ static int DoXMEffectP(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR UBYTE inf, lo, hi; SWORD pan; - (void)flags; /* unused arg */ - (void)channel; /* unused arg */ - inf = UniGetByte(); if (!mod->panflag) return 0; @@ -1690,10 +1569,6 @@ static int DoXMEffectX1(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat = UniGetByte(); if (dat) a->ffportupspd = dat; @@ -1714,10 +1589,6 @@ static int DoXMEffectX2(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE dat; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat = UniGetByte(); if (dat) a->ffportdnspd=dat; @@ -1744,7 +1615,7 @@ static void DoITToneSlide(UWORD tick, MP_CONTROL *a, UBYTE dat) /* if we don't come from another note, ignore the slide and play the note as is */ if (!a->oldnote || !a->main.period) - return; + return; if ((!tick)&&(a->newsamp)){ a->main.kick=KICK_NOTE; @@ -1759,15 +1630,15 @@ static void DoITToneSlide(UWORD tick, MP_CONTROL *a, UBYTE dat) difference between those two values */ dist=a->main.period-a->wantedperiod; - /* if they are equal or if portamentospeed is too big... */ + /* if they are equal or if portamentospeed is too big... */ if ((!dist)||((a->portspeed<<2)>abs(dist))) /* ... make tmpperiod equal tperiod */ a->tmpperiod=a->main.period=a->wantedperiod; else - if (dist>0) { + if (dist>0) { a->tmpperiod-=a->portspeed<<2; a->main.period-=a->portspeed<<2; /* dist>0 slide up */ - } else { + } else { a->tmpperiod+=a->portspeed<<2; a->main.period+=a->portspeed<<2; /* dist<0 slide down */ } @@ -1778,10 +1649,6 @@ static void DoITToneSlide(UWORD tick, MP_CONTROL *a, UBYTE dat) static int DoITEffectG(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD channel) { - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - DoITToneSlide(tick, a, UniGetByte()); return 0; @@ -1797,7 +1664,7 @@ static void DoITVibrato(UWORD tick, MP_CONTROL *a, UBYTE dat) if (dat&0xf0) a->vibspd=(dat&0xf0)>>2; } if (!a->main.period) - return; + return; q=(a->vibpos>>2)&0x1f; @@ -1833,10 +1700,6 @@ static void DoITVibrato(UWORD tick, MP_CONTROL *a, UBYTE dat) static int DoITEffectH(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD channel) { - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - DoITVibrato(tick, a, UniGetByte()); return 0; @@ -1846,11 +1709,6 @@ static int DoITEffectI(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE inf, on, off; - (void)tick; /* unused arg */ - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - inf = UniGetByte(); if (inf) a->s3mtronof = inf; @@ -1873,11 +1731,6 @@ static int DoITEffectI(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR static int DoITEffectM(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD channel) { - (void)tick; /* unused arg */ - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - a->main.chanvol=UniGetByte(); if (a->main.chanvol>64) a->main.chanvol=64; @@ -1891,10 +1744,6 @@ static int DoITEffectN(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE inf, lo, hi; - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - inf = UniGetByte(); if (inf) @@ -1905,7 +1754,7 @@ static int DoITEffectN(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR lo=inf&0xf; hi=inf>>4; - if (!hi) + if (!hi) a->main.chanvol-=lo; else if (!lo) { @@ -1931,9 +1780,6 @@ static int DoITEffectP(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR UBYTE inf, lo, hi; SWORD pan; - (void)flags; /* unused arg */ - (void)channel; /* unused arg */ - inf = UniGetByte(); if (inf) a->pansspd = inf; @@ -1971,12 +1817,7 @@ static int DoITEffectT(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR UBYTE tempo; SWORD temp; - (void)tick; /* unused arg */ - (void)flags; /* unused arg */ - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - - tempo = UniGetByte(); + tempo = UniGetByte(); if (mod->patdly2) return 0; @@ -1997,10 +1838,6 @@ static int DoITEffectU(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR UBYTE dat, q; UWORD temp = 0; /* silence warning */ - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat = UniGetByte(); if (!tick) { if (dat&0x0f) a->vibdepth=dat&0xf; @@ -2045,10 +1882,6 @@ static int DoITEffectW(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR { UBYTE inf, lo, hi; - (void)flags; /* unused arg */ - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - inf = UniGetByte(); if (inf) @@ -2085,7 +1918,6 @@ static int DoITEffectY(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWOR UBYTE dat, q; SLONG temp = 0; /* silence warning */ - (void)flags; /* unused arg */ dat=UniGetByte(); if (!tick) { @@ -2146,13 +1978,13 @@ static int DoITEffectS0(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO switch (c) { case SS_GLISSANDO: /* S1x set glissando voice */ DoEEffects(tick, flags, a, mod, channel, 0x30|inf); - break; + break; case SS_FINETUNE: /* S2x set finetune */ DoEEffects(tick, flags, a, mod, channel, 0x50|inf); break; case SS_VIBWAVE: /* S3x set vibrato waveform */ DoEEffects(tick, flags, a, mod, channel, 0x40|inf); - break; + break; case SS_TREMWAVE: /* S4x set tremolo waveform */ DoEEffects(tick, flags, a, mod, channel, 0x70|inf); break; @@ -2171,7 +2003,7 @@ static int DoITEffectS0(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO case SS_SURROUND: /* S9x set surround sound */ if (mod->panflag) a->main.panning = mod->panning[channel] = PAN_SURROUND; - break; + break; case SS_HIOFFSET: /* SAy set high order sample offset yxx00h */ if (!tick) { a->hioffset=inf<<16; @@ -2210,10 +2042,8 @@ static int DoVolEffects(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UBYTE c, inf; - (void)channel; /* unused arg */ - - c = UniGetByte(); - inf = UniGetByte(); + c = UniGetByte(); + inf = UniGetByte(); if ((!c)&&(!inf)) { c=a->voleffect; @@ -2262,11 +2092,6 @@ static int DoULTEffect9(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWO { UWORD offset=UniGetWord(); - (void)tick; /* unused arg */ - (void)flags; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - if (offset) a->ultoffset=offset; @@ -2284,11 +2109,6 @@ static int DoMEDSpeed(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD { UWORD speed=UniGetWord(); - (void)tick; /* unused arg */ - (void)flags; /* unused arg */ - (void)a; /* unused arg */ - (void)channel; /* unused arg */ - mod->bpm=speed; return 0; @@ -2321,9 +2141,6 @@ static int DoOktArp(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD c { UBYTE dat, dat2; - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - dat2 = UniGetByte(); /* arpeggio style */ dat = UniGetByte(); if (!tick) { @@ -2342,12 +2159,6 @@ static int DoOktArp(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD c static int DoNothing(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD channel) { - (void)tick; /* unused arg */ - (void)flags; /* unused arg */ - (void)a; /* unused arg */ - (void)mod; /* unused arg */ - (void)channel; /* unused arg */ - UniSkipOpcode(); return 0; @@ -2356,68 +2167,68 @@ static int DoNothing(UWORD tick, UWORD flags, MP_CONTROL *a, MODULE *mod, SWORD typedef int (*effect_func) (UWORD, UWORD, MP_CONTROL *, MODULE *, SWORD); static effect_func effects[UNI_LAST] = { - DoNothing, /* 0 */ - DoNothing, /* UNI_NOTE */ - DoNothing, /* UNI_INSTRUMENT */ - DoPTEffect0, /* UNI_PTEFFECT0 */ - DoPTEffect1, /* UNI_PTEFFECT1 */ - DoPTEffect2, /* UNI_PTEFFECT2 */ - DoPTEffect3, /* UNI_PTEFFECT3 */ - DoPTEffect4, /* UNI_PTEFFECT4 */ - DoPTEffect5, /* UNI_PTEFFECT5 */ - DoPTEffect6, /* UNI_PTEFFECT6 */ - DoPTEffect7, /* UNI_PTEFFECT7 */ - DoPTEffect8, /* UNI_PTEFFECT8 */ - DoPTEffect9, /* UNI_PTEFFECT9 */ - DoPTEffectA, /* UNI_PTEFFECTA */ - DoPTEffectB, /* UNI_PTEFFECTB */ - DoPTEffectC, /* UNI_PTEFFECTC */ - DoPTEffectD, /* UNI_PTEFFECTD */ - DoPTEffectE, /* UNI_PTEFFECTE */ - DoPTEffectF, /* UNI_PTEFFECTF */ - DoS3MEffectA, /* UNI_S3MEFFECTA */ - DoS3MEffectD, /* UNI_S3MEFFECTD */ - DoS3MEffectE, /* UNI_S3MEFFECTE */ - DoS3MEffectF, /* UNI_S3MEFFECTF */ - DoS3MEffectI, /* UNI_S3MEFFECTI */ - DoS3MEffectQ, /* UNI_S3MEFFECTQ */ - DoS3MEffectR, /* UNI_S3MEFFECTR */ - DoS3MEffectT, /* UNI_S3MEFFECTT */ - DoS3MEffectU, /* UNI_S3MEFFECTU */ - DoKeyOff, /* UNI_KEYOFF */ - DoKeyFade, /* UNI_KEYFADE */ - DoVolEffects, /* UNI_VOLEFFECTS */ - DoPTEffect4, /* UNI_XMEFFECT4 */ - DoXMEffect6, /* UNI_XMEFFECT6 */ - DoXMEffectA, /* UNI_XMEFFECTA */ - DoXMEffectE1, /* UNI_XMEFFECTE1 */ - DoXMEffectE2, /* UNI_XMEFFECTE2 */ - DoXMEffectEA, /* UNI_XMEFFECTEA */ - DoXMEffectEB, /* UNI_XMEFFECTEB */ - DoXMEffectG, /* UNI_XMEFFECTG */ - DoXMEffectH, /* UNI_XMEFFECTH */ - DoXMEffectL, /* UNI_XMEFFECTL */ - DoXMEffectP, /* UNI_XMEFFECTP */ - DoXMEffectX1, /* UNI_XMEFFECTX1 */ - DoXMEffectX2, /* UNI_XMEFFECTX2 */ - DoITEffectG, /* UNI_ITEFFECTG */ - DoITEffectH, /* UNI_ITEFFECTH */ - DoITEffectI, /* UNI_ITEFFECTI */ - DoITEffectM, /* UNI_ITEFFECTM */ - DoITEffectN, /* UNI_ITEFFECTN */ - DoITEffectP, /* UNI_ITEFFECTP */ - DoITEffectT, /* UNI_ITEFFECTT */ - DoITEffectU, /* UNI_ITEFFECTU */ - DoITEffectW, /* UNI_ITEFFECTW */ - DoITEffectY, /* UNI_ITEFFECTY */ - DoNothing, /* UNI_ITEFFECTZ */ - DoITEffectS0, /* UNI_ITEFFECTS0 */ - DoULTEffect9, /* UNI_ULTEFFECT9 */ - DoMEDSpeed, /* UNI_MEDSPEED */ - DoMEDEffectF1, /* UNI_MEDEFFECTF1 */ - DoMEDEffectF2, /* UNI_MEDEFFECTF2 */ - DoMEDEffectF3, /* UNI_MEDEFFECTF3 */ - DoOktArp, /* UNI_OKTARP */ + DoNothing, /* 0 */ + DoNothing, /* UNI_NOTE */ + DoNothing, /* UNI_INSTRUMENT */ + DoPTEffect0, /* UNI_PTEFFECT0 */ + DoPTEffect1, /* UNI_PTEFFECT1 */ + DoPTEffect2, /* UNI_PTEFFECT2 */ + DoPTEffect3, /* UNI_PTEFFECT3 */ + DoPTEffect4, /* UNI_PTEFFECT4 */ + DoPTEffect5, /* UNI_PTEFFECT5 */ + DoPTEffect6, /* UNI_PTEFFECT6 */ + DoPTEffect7, /* UNI_PTEFFECT7 */ + DoPTEffect8, /* UNI_PTEFFECT8 */ + DoPTEffect9, /* UNI_PTEFFECT9 */ + DoPTEffectA, /* UNI_PTEFFECTA */ + DoPTEffectB, /* UNI_PTEFFECTB */ + DoPTEffectC, /* UNI_PTEFFECTC */ + DoPTEffectD, /* UNI_PTEFFECTD */ + DoPTEffectE, /* UNI_PTEFFECTE */ + DoPTEffectF, /* UNI_PTEFFECTF */ + DoS3MEffectA, /* UNI_S3MEFFECTA */ + DoS3MEffectD, /* UNI_S3MEFFECTD */ + DoS3MEffectE, /* UNI_S3MEFFECTE */ + DoS3MEffectF, /* UNI_S3MEFFECTF */ + DoS3MEffectI, /* UNI_S3MEFFECTI */ + DoS3MEffectQ, /* UNI_S3MEFFECTQ */ + DoS3MEffectR, /* UNI_S3MEFFECTR */ + DoS3MEffectT, /* UNI_S3MEFFECTT */ + DoS3MEffectU, /* UNI_S3MEFFECTU */ + DoKeyOff, /* UNI_KEYOFF */ + DoKeyFade, /* UNI_KEYFADE */ + DoVolEffects, /* UNI_VOLEFFECTS */ + DoPTEffect4, /* UNI_XMEFFECT4 */ + DoXMEffect6, /* UNI_XMEFFECT6 */ + DoXMEffectA, /* UNI_XMEFFECTA */ + DoXMEffectE1, /* UNI_XMEFFECTE1 */ + DoXMEffectE2, /* UNI_XMEFFECTE2 */ + DoXMEffectEA, /* UNI_XMEFFECTEA */ + DoXMEffectEB, /* UNI_XMEFFECTEB */ + DoXMEffectG, /* UNI_XMEFFECTG */ + DoXMEffectH, /* UNI_XMEFFECTH */ + DoXMEffectL, /* UNI_XMEFFECTL */ + DoXMEffectP, /* UNI_XMEFFECTP */ + DoXMEffectX1, /* UNI_XMEFFECTX1 */ + DoXMEffectX2, /* UNI_XMEFFECTX2 */ + DoITEffectG, /* UNI_ITEFFECTG */ + DoITEffectH, /* UNI_ITEFFECTH */ + DoITEffectI, /* UNI_ITEFFECTI */ + DoITEffectM, /* UNI_ITEFFECTM */ + DoITEffectN, /* UNI_ITEFFECTN */ + DoITEffectP, /* UNI_ITEFFECTP */ + DoITEffectT, /* UNI_ITEFFECTT */ + DoITEffectU, /* UNI_ITEFFECTU */ + DoITEffectW, /* UNI_ITEFFECTW */ + DoITEffectY, /* UNI_ITEFFECTY */ + DoNothing, /* UNI_ITEFFECTZ */ + DoITEffectS0, /* UNI_ITEFFECTS0 */ + DoULTEffect9, /* UNI_ULTEFFECT9 */ + DoMEDSpeed, /* UNI_MEDSPEED */ + DoMEDEffectF1, /* UNI_MEDEFFECTF1 */ + DoMEDEffectF2, /* UNI_MEDEFFECTF2 */ + DoMEDEffectF3, /* UNI_MEDEFFECTF3 */ + DoOktArp, /* UNI_OKTARP */ }; static int pt_playeffects(MODULE *mod, SWORD channel, MP_CONTROL *a) @@ -2428,10 +2239,14 @@ static int pt_playeffects(MODULE *mod, SWORD channel, MP_CONTROL *a) int explicitslides = 0; effect_func f; - while((c=UniGetByte())) { + while((c=UniGetByte()) != 0) { +#if 0 /* this doesn't normally happen unless things go fubar elsewhere */ + if (c >= UNI_LAST) + fprintf(stderr,"fubar'ed opcode %u\n",c); +#endif f = effects[c]; if (f != DoNothing) - a->sliding = 0; + a->sliding = 0; explicitslides |= f(tick, flags, a, mod, channel); } return explicitslides; @@ -2442,17 +2257,17 @@ static void DoNNAEffects(MODULE *mod, MP_CONTROL *a, UBYTE dat) int t; MP_VOICE *aout; - dat&=0xf; + dat&=0xf; aout=(a->slave)?a->slave:NULL; switch (dat) { case 0x0: /* past note cut */ - for (t=0;tvoice[t].master==a) mod->voice[t].main.fadevol=0; break; case 0x1: /* past note off */ - for (t=0;tvoice[t].master==a) { mod->voice[t].main.keyoff|=KEY_OFF; if ((!(mod->voice[t].venv.flg & EF_ON))|| @@ -2461,7 +2276,7 @@ static void DoNNAEffects(MODULE *mod, MP_CONTROL *a, UBYTE dat) } break; case 0x2: /* past note fade */ - for (t=0;tvoice[t].master==a) mod->voice[t].main.keyoff|=KEY_FADE; break; @@ -2473,7 +2288,7 @@ static void DoNNAEffects(MODULE *mod, MP_CONTROL *a, UBYTE dat) break; case 0x5: /* set NNA note off */ a->main.nna=(a->main.nna&~NNA_MASK)|NNA_OFF; - break; + break; case 0x6: /* set NNA note fade */ a->main.nna=(a->main.nna&~NNA_MASK)|NNA_FADE; break; @@ -2488,7 +2303,7 @@ static void DoNNAEffects(MODULE *mod, MP_CONTROL *a, UBYTE dat) case 0x9: /* disable panning envelope */ if (aout) aout->main.panflg&=~EF_ON; - break; + break; case 0xa: /* enable panning envelope */ if (aout) aout->main.panflg|=EF_ON; @@ -2504,7 +2319,7 @@ static void DoNNAEffects(MODULE *mod, MP_CONTROL *a, UBYTE dat) } } -void pt_UpdateVoices(MODULE *mod, int max_volume) +static void pt_UpdateVoices(MODULE *mod, int max_volume) { SWORD envpan,envvol,envpit,channel; UWORD playperiod; @@ -2516,7 +2331,7 @@ void pt_UpdateVoices(MODULE *mod, int max_volume) SAMPLE *s; mod->totalchn=mod->realchn=0; - for (channel=0;channelvoice[channel]; i=aout->main.i; s=aout->main.s; @@ -2563,6 +2378,9 @@ void pt_UpdateVoices(MODULE *mod, int max_volume) if (aout->main.pitflg & EF_ON) envpit = ProcessEnvelope(aout,&aout->cenv,32); } + if (aout->main.kick == KICK_NOTE) { + aout->main.kick_flag = 1; + } aout->main.kick=KICK_ABSENT; tmpvol = aout->main.fadevol; /* max 32768 */ @@ -2704,7 +2522,7 @@ void pt_UpdateVoices(MODULE *mod, int max_volume) } /* Handles new notes or instruments */ -void pt_Notes(MODULE *mod) +static void pt_Notes(MODULE *mod) { SWORD channel; MP_CONTROL *a; @@ -2730,7 +2548,7 @@ void pt_Notes(MODULE *mod) UniSetRow(a->row); funky=0; - while((c=UniGetByte())) + while((c=UniGetByte()) != 0) switch (c) { case UNI_NOTE: funky|=1; @@ -2763,7 +2581,7 @@ void pt_Notes(MODULE *mod) INSTRUMENT *i; SAMPLE *s; - if ((i=a->main.i)) { + if ((i=a->main.i) != NULL) { if (i->samplenumber[a->anote] >= mod->numsmp) continue; s=&mod->samples[i->samplenumber[a->anote]]; a->main.note=i->samplenote[a->anote]; @@ -2842,7 +2660,7 @@ void pt_Notes(MODULE *mod) } /* Handles effects */ -void pt_EffectsPass1(MODULE *mod) +static void pt_EffectsPass1(MODULE *mod) { SWORD channel; MP_CONTROL *a; @@ -2852,7 +2670,7 @@ void pt_EffectsPass1(MODULE *mod) for (channel=0;channelnumchn;channel++) { a=&mod->control[channel]; - if ((aout=a->slave)) { + if ((aout=a->slave) != NULL) { a->main.fadevol=aout->main.fadevol; a->main.period=aout->main.period; if (a->main.kick==KICK_KEYOFF) @@ -2893,7 +2711,7 @@ void pt_EffectsPass1(MODULE *mod) } /* NNA management */ -void pt_NNA(MODULE *mod) +static void pt_NNA(MODULE *mod) { SWORD channel; MP_CONTROL *a; @@ -2934,7 +2752,7 @@ void pt_NNA(MODULE *mod) if (a->dct!=DCT_OFF) { int t; - for (t=0;tvoice[t].masterchn==channel)&& (a->main.sample==mod->voice[t].main.sample)) { @@ -2974,7 +2792,7 @@ void pt_NNA(MODULE *mod) } /* Setup module and NNA voices */ -void pt_SetupVoices(MODULE *mod) +static void pt_SetupVoices(MODULE *mod) { SWORD channel; MP_CONTROL *a; @@ -2994,11 +2812,11 @@ void pt_SetupVoices(MODULE *mod) if ((newchn=MP_FindEmptyChannel(mod))!=-1) a->slave=&mod->voice[a->slavechn=newchn]; } - } else + } else a->slave=&mod->voice[a->slavechn=channel]; /* assign parts of MP_VOICE only done for a KICK_NOTE */ - if ((aout=a->slave)) { + if ((aout=a->slave) != NULL) { if (aout->mflag && aout->master) aout->master->slave=NULL; aout->master=a; a->slave=aout; @@ -3015,7 +2833,7 @@ void pt_SetupVoices(MODULE *mod) } /* second effect pass */ -void pt_EffectsPass2(MODULE *mod) +static void pt_EffectsPass2(MODULE *mod) { SWORD channel; MP_CONTROL *a; @@ -3027,7 +2845,7 @@ void pt_EffectsPass2(MODULE *mod) if (!a->row) continue; UniSetRow(a->row); - while((c=UniGetByte())) + while((c=UniGetByte()) != 0) if (c==UNI_ITEFFECTS0) { c=UniGetByte(); if ((c>>4)==SS_S7EFFECTS) @@ -3059,7 +2877,7 @@ void Player_HandleTick(void) pf->sngremainder%=pf->bpm; if (++pf->vbtick>=pf->sngspd) { - if (pf->pat_repcrazy) + if (pf->pat_repcrazy) pf->pat_repcrazy=0; /* play 2 times row 0 */ else pf->patpos++; @@ -3089,6 +2907,9 @@ void Player_HandleTick(void) pf->control[channel].pat_reppos=-1; pf->patbrk=pf->posjmp=0; + + if (pf->sngpos<0) pf->sngpos=(SWORD)(pf->numpos-1); + /* handle the "---" (end of song) pattern since it can occur *inside* the module in some formats */ if ((pf->sngpos>=pf->numpos)|| @@ -3103,7 +2924,6 @@ void Player_HandleTick(void) pf->bpm=pf->inittempo<32?32:pf->inittempo; } } - if (pf->sngpos<0) pf->sngpos=pf->numpos-1; } if (!pf->patdly2) @@ -3136,7 +2956,7 @@ static void Player_Init_internal(MODULE* mod) mod->control[t].main.chanvol=mod->chanvol[t]; mod->control[t].main.panning=mod->panning[t]; } - + mod->sngtime=0; mod->sngremainder=0; @@ -3160,7 +2980,7 @@ static void Player_Init_internal(MODULE* mod) mod->patbrk=0; } -BOOL Player_Init(MODULE* mod) +int Player_Init(MODULE* mod) { mod->extspd=1; mod->panflag=1; @@ -3176,6 +2996,11 @@ BOOL Player_Init(MODULE* mod) if (!(mod->voice=(MP_VOICE*)MikMod_calloc(md_sngchn,sizeof(MP_VOICE)))) return 1; + /* mod->numvoices was used during loading to clamp md_sngchn. + After loading it's used to remember how big mod->voice is. + */ + mod->numvoices = md_sngchn; + Player_Init_internal(mod); return 0; } @@ -3191,10 +3016,8 @@ void Player_Exit_internal(MODULE* mod) pf=NULL; } - if (mod->control) - MikMod_free(mod->control); - if (mod->voice) - MikMod_free(mod->voice); + MikMod_free(mod->control); + MikMod_free(mod->voice); mod->control=NULL; mod->voice=NULL; } @@ -3209,8 +3032,10 @@ void Player_Exit(MODULE* mod) MIKMODAPI void Player_SetVolume(SWORD volume) { MUTEX_LOCK(vars); - if (pf) + if (pf) { pf->volume=(volume<0)?0:(volume>128)?128:volume; + pf->initvolume=pf->volume; + } MUTEX_UNLOCK(vars); } @@ -3284,7 +3109,7 @@ MIKMODAPI void Player_NextPosition(void) pf->patbrk=0; pf->vbtick=pf->sngspd; - for (t=0;tvoice[t].main.i=NULL; pf->voice[t].main.s=NULL; @@ -3309,7 +3134,7 @@ MIKMODAPI void Player_PrevPosition(void) pf->patbrk=0; pf->vbtick=pf->sngspd; - for (t=0;tvoice[t].main.i=NULL; pf->voice[t].main.s=NULL; @@ -3336,7 +3161,7 @@ MIKMODAPI void Player_SetPosition(UWORD pos) pf->sngpos=pos; pf->vbtick=pf->sngspd; - for (t=0;tvoice[t].main.i=NULL; pf->voice[t].main.s=NULL; @@ -3346,12 +3171,12 @@ MIKMODAPI void Player_SetPosition(UWORD pos) pf->control[t].main.s=NULL; } pf->forbid=0; - + if (!pos) Player_Init_internal(pf); } MUTEX_UNLOCK(vars); -} +} static void Player_Unmute_internal(SLONG arg1,va_list ap) { @@ -3439,7 +3264,7 @@ MIKMODAPI void Player_Mute(SLONG arg1,...) static void Player_ToggleMute_internal(SLONG arg1,va_list ap) { SLONG arg2,arg3=0; - SLONG t; + ULONG t; if (pf) { switch (arg1) { @@ -3461,7 +3286,7 @@ static void Player_ToggleMute_internal(SLONG arg1,va_list ap) } break; default: - if (arg1numchn) + if (arg1numchn) pf->control[arg1].muted=1-pf->control[arg1].muted; break; } @@ -3508,7 +3333,7 @@ MIKMODAPI UWORD Player_GetChannelPeriod(UBYTE chan) UWORD result=0; MUTEX_LOCK(vars); - if (pf) + if (pf) result=(channumchn)?pf->control[chan].main.period:0; MUTEX_UNLOCK(vars); @@ -3542,7 +3367,7 @@ MIKMODAPI void Player_TogglePause(void) MIKMODAPI void Player_SetSpeed(UWORD speed) { MUTEX_LOCK(vars); - if (pf) + if (pf) pf->sngspd=speed?(speed<32?speed:32):1; MUTEX_UNLOCK(vars); } @@ -3558,4 +3383,47 @@ MIKMODAPI void Player_SetTempo(UWORD tempo) MUTEX_UNLOCK(vars); } +MIKMODAPI int Player_QueryVoices(UWORD numvoices, VOICEINFO *vinfo) +{ + int i; + + if (numvoices > md_sngchn) + numvoices = md_sngchn; + + MUTEX_LOCK(vars); + if (pf) + for (i = 0; i < md_sngchn; i++) { + vinfo [i].i = pf->voice[i].main.i; + vinfo [i].s = pf->voice[i].main.s; + vinfo [i].panning = pf->voice [i].main.panning; + vinfo [i].volume = pf->voice [i].main.chanvol; + vinfo [i].period = pf->voice [i].main.period; + vinfo [i].kick = pf->voice [i].main.kick_flag; + pf->voice [i].main.kick_flag = 0; + } + MUTEX_UNLOCK(vars); + + return numvoices; +} + +/* Get current module order */ +MIKMODAPI int Player_GetOrder(void) +{ + int ret; + MUTEX_LOCK(vars); + ret = pf ? pf->sngpos :0; /* pf->positions[pf->sngpos ? pf->sngpos-1 : 0]: 0; */ + MUTEX_UNLOCK(vars); + return ret; +} + +/* Get current module row */ +MIKMODAPI int Player_GetRow(void) +{ + int ret; + MUTEX_LOCK(vars); + ret = pf ? pf->patpos : 0; + MUTEX_UNLOCK(vars); + return ret; +} + /* ex:set ts=4: */ diff --git a/sc2/src/libs/mikmod/munitrk.c b/sc2/src/libs/mikmod/munitrk.c index 28189694f..349038c8f 100644 --- a/sc2/src/libs/mikmod/munitrk.c +++ b/sc2/src/libs/mikmod/munitrk.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 @@ -37,7 +37,7 @@ /* Unibuffer chunk size */ #define BUFPAGE 128 -UWORD unioperands[UNI_LAST]={ +const UWORD unioperands[UNI_LAST] = { 0, /* not used */ 1, /* UNI_NOTE */ 1, /* UNI_INSTRUMENT */ @@ -209,12 +209,12 @@ static BOOL UniExpand(int wanted) /* Expand the buffer by BUFPAGE bytes */ newbuf=(UBYTE*)MikMod_realloc(unibuf,(unimax+BUFPAGE)*sizeof(UBYTE)); - /* Check if realloc succeeded */ + /* Check if MikMod_realloc succeeded */ if(newbuf) { unibuf = newbuf; unimax+=BUFPAGE; return 1; - } else + } else return 0; } return 1; @@ -236,7 +236,7 @@ void UniWriteWord(UWORD data) } } -static BOOL MyCmp(UBYTE* a,UBYTE* b,UWORD l) +static BOOL MyCmp(const UBYTE* a,const UBYTE* b,UWORD l) { UWORD t; @@ -275,15 +275,15 @@ void UniNewline(void) stream. */ UBYTE* UniDup(void) { - UBYTE *d; + void *d; - if (!UniExpand(unitt-unipc)) return NULL; + if (!UniExpand(unipc-unitt)) return NULL; unibuf[unitt] = 0; - if(!(d=(UBYTE *)MikMod_malloc(unipc))) return NULL; + if(!(d=MikMod_malloc(unipc))) return NULL; memcpy(d,unibuf,unipc); - return d; + return (UBYTE *)d; } BOOL UniInit(void) @@ -296,7 +296,7 @@ BOOL UniInit(void) void UniCleanup(void) { - if(unibuf) MikMod_free(unibuf); + MikMod_free(unibuf); unibuf = NULL; } diff --git a/sc2/src/libs/mikmod/mwav.c b/sc2/src/libs/mikmod/mwav.c index b6299855b..6f2394fbc 100644 --- a/sc2/src/libs/mikmod/mwav.c +++ b/sc2/src/libs/mikmod/mwav.c @@ -1,4 +1,5 @@ /* MikMod sound library + (c) 2004, Raphael Assenat (c) 1998, 1999, 2000, 2001 Miodrag Vallat and others - see file AUTHORS for complete list. @@ -6,12 +7,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,8 +21,6 @@ /*============================================================================== - $Id$ - WAV sample loader ==============================================================================*/ @@ -46,6 +45,9 @@ extern int fprintf(FILE *, const char *, ...); #endif +static void extract_channel(const char *src, char *dst, int num_chan, int num_samples, int samp_size, int channel); + + typedef struct WAV { CHAR rID[4]; ULONG rLen; @@ -60,12 +62,32 @@ typedef struct WAV { UWORD nFormatSpecific; } WAV; -SAMPLE* Sample_LoadGeneric_internal(MREADER* reader) +static BOOL isWaveFile(MREADER* reader) +{ + WAV wh; + + _mm_fseek(reader, SEEK_SET, 0); + + /* read wav header */ + _mm_read_string(wh.rID,4,reader); + wh.rLen = _mm_read_I_ULONG(reader); + _mm_read_string(wh.wID,4,reader); + + /* check for correct header */ + if(_mm_eof(reader)|| memcmp(wh.rID,"RIFF",4) || memcmp(wh.wID,"WAVE",4)) { + return 0; + } + return 1; +} + +static SAMPLE* Sample_LoadGeneric_internal_wav(MREADER* reader) { SAMPLE *si=NULL; WAV wh; BOOL have_fmt=0; + _mm_fseek(reader, SEEK_SET, 0); + /* read wav header */ _mm_read_string(wh.rID,4,reader); wh.rLen = _mm_read_I_ULONG(reader); @@ -103,7 +125,7 @@ SAMPLE* Sample_LoadGeneric_internal(MREADER* reader) #ifdef MIKMOD_DEBUG fprintf(stderr,"\rwavloader : wFormatTag=%04x blockalign=%04x nFormatSpc=%04x\n", - wh.wFormatTag,wh.nBlockAlign,wh.nFormatSpecific); + wh.wFormatTag,wh.nBlockAlign,wh.nFormatSpecific); #endif if((have_fmt)||(wh.nChannels>1)) { @@ -130,7 +152,7 @@ SAMPLE* Sample_LoadGeneric_internal(MREADER* reader) si->inflags = si->flags; SL_RegisterSample(si,MD_SNDFX,reader); SL_LoadSamples(); - + /* skip any other remaining blocks - so in case of repeated sample fragments, we'll return the first anyway instead of an error */ break; @@ -144,23 +166,159 @@ SAMPLE* Sample_LoadGeneric_internal(MREADER* reader) return si; } -MIKMODAPI SAMPLE* Sample_LoadGeneric(MREADER* reader) +static SAMPLE* Sample_LoadRawGeneric_internal(MREADER* reader, ULONG rate, ULONG channel, ULONG flags) +{ + SAMPLE *si; + long len; + int samp_size=1; + + if(!(si=(SAMPLE*)MikMod_malloc(sizeof(SAMPLE)))) return NULL; + + /* length */ + _mm_fseek(reader, 0, SEEK_END); + len = _mm_ftell(reader); + + si->panning = PAN_CENTER; + si->speed = rate/1; + si->volume = 64; + si->length = len; + si->loopstart=0; + si->loopend = len; + si->susbegin = 0; + si->susend = 0; + si->inflags = si->flags = flags; + if (si->flags & SF_16BITS) { + si->length >>= 1; + si->loopstart >>= 1; + si->loopend >>= 1; + samp_size = 2; + } + + if (si->flags & SF_STEREO) + { + char *data, *channel_data; + int num_samp = si->length/samp_size/2; + MREADER *chn_reader; + + data = (char*)MikMod_malloc(si->length); + if (!data) { MikMod_free(si); return NULL; } + + channel_data = (char*)MikMod_malloc(si->length/2); + if (!channel_data) { MikMod_free(data); MikMod_free(si); return NULL; } + + /* load the raw samples completely, and fully extract the + * requested channel. Create a memory reader pointing to + * the channel data. */ + _mm_fseek(reader, 0, SEEK_SET); + reader->Read(reader, data, si->length); + + extract_channel(data, channel_data, 2, num_samp, samp_size, channel); + chn_reader = _mm_new_mem_reader(channel_data, num_samp * samp_size); + if (!chn_reader) { + MikMod_free(channel_data); + MikMod_free(data); + MikMod_free(si); + return NULL; + } + + /* half of the samples were in the other channel */ + si->loopstart=0; + si->length=num_samp; + si->loopend=num_samp; + + SL_RegisterSample(si, MD_SNDFX, chn_reader); + SL_LoadSamples(); + + _mm_delete_mem_reader(chn_reader); + MikMod_free(channel_data); + MikMod_free(data); + + return si; + } + + _mm_fseek(reader, 0, SEEK_SET); + SL_RegisterSample(si, MD_SNDFX, reader); + SL_LoadSamples(); + + return si; +} + +static SAMPLE* Sample_LoadGeneric_internal(MREADER* reader, const char *options) +{ + if (isWaveFile(reader)) { + return Sample_LoadGeneric_internal_wav(reader); + } + + return NULL; +} + +MIKMODAPI SAMPLE* Sample_LoadRawGeneric(MREADER* reader, ULONG rate, ULONG channel, ULONG flags) { SAMPLE* result; MUTEX_LOCK(vars); - result=Sample_LoadGeneric_internal(reader); + result = Sample_LoadRawGeneric_internal(reader, rate, channel, flags); MUTEX_UNLOCK(vars); return result; } -MIKMODAPI extern SAMPLE *Sample_LoadMem(const char *buf, int len) +MIKMODAPI SAMPLE *Sample_LoadRawMem(const char *buf, int len, ULONG rate, ULONG channel, ULONG flags) +{ + SAMPLE *result=NULL; + MREADER *reader; + + if (!buf || len <= 0) return NULL; + if ((reader=_mm_new_mem_reader(buf, len)) != NULL) { + result=Sample_LoadRawGeneric(reader, rate, channel, flags); + _mm_delete_mem_reader(reader); + } + return result; +} + +MIKMODAPI SAMPLE* Sample_LoadRawFP(FILE *fp, ULONG rate, ULONG channel, ULONG flags) { SAMPLE* result=NULL; MREADER* reader; - if ((reader=_mm_new_mem_reader(buf, len))) { + if(fp && (reader=_mm_new_file_reader(fp)) != NULL) { + result=Sample_LoadRawGeneric(reader, rate, channel, flags); + _mm_delete_file_reader(reader); + } + return result; +} + +MIKMODAPI SAMPLE* Sample_LoadRaw(const CHAR* filename, ULONG rate, ULONG channel, ULONG flags) +{ + FILE *fp; + SAMPLE *si=NULL; + + if(!(md_mode & DMODE_SOFT_SNDFX)) return NULL; + if((fp=_mm_fopen(filename,"rb")) != NULL) { + si = Sample_LoadRawFP(fp, rate, channel, flags); + _mm_fclose(fp); + } + return si; +} + +MIKMODAPI SAMPLE* Sample_LoadGeneric(MREADER* reader) +{ + SAMPLE* result; + + MUTEX_LOCK(vars); + result=Sample_LoadGeneric_internal(reader, NULL); + MUTEX_UNLOCK(vars); + + return result; +} + +MIKMODAPI SAMPLE *Sample_LoadMem(const char *buf, int len) +{ + SAMPLE* result=NULL; + MREADER* reader; + + if (!buf || len <= 0) return NULL; + if ((reader=_mm_new_mem_reader(buf, len)) != NULL) { result=Sample_LoadGeneric(reader); _mm_delete_mem_reader(reader); } @@ -172,20 +330,20 @@ MIKMODAPI SAMPLE* Sample_LoadFP(FILE *fp) SAMPLE* result=NULL; MREADER* reader; - if((reader=_mm_new_file_reader(fp))) { + if(fp && (reader=_mm_new_file_reader(fp)) != NULL) { result=Sample_LoadGeneric(reader); _mm_delete_file_reader(reader); } return result; } -MIKMODAPI SAMPLE* Sample_Load(CHAR* filename) +MIKMODAPI SAMPLE* Sample_Load(const CHAR* filename) { FILE *fp; SAMPLE *si=NULL; if(!(md_mode & DMODE_SOFT_SNDFX)) return NULL; - if((fp=_mm_fopen(filename,"rb"))) { + if((fp=_mm_fopen(filename,"rb")) != NULL) { si = Sample_LoadFP(fp); _mm_fclose(fp); } @@ -195,6 +353,7 @@ MIKMODAPI SAMPLE* Sample_Load(CHAR* filename) MIKMODAPI void Sample_Free(SAMPLE* si) { if(si) { + if (si->onfree) si->onfree(si->ctx); MD_SampleUnload(si->handle); MikMod_free(si); } @@ -207,4 +366,23 @@ void Sample_Free_internal(SAMPLE *si) MUTEX_UNLOCK(vars); } -/* ex:set ts=4: */ +static void extract_channel(const char *src, char *dst, int num_chan, int num_samples, int samp_size, int channel) +{ + int i; +#ifdef MIKMOD_DEBUG + fprintf(stderr,"Extract channel: %p %p, num_chan=%d, num_samples=%d, samp_size=%d, channel=%d\n", + src,dst,num_chan,num_samples,samp_size,channel); +#endif + src += channel * samp_size; + + while (num_samples--) + { + for (i=0; i 0 */ /* C C# D D# E F F# G G# A A# B */ 0x6b0,0x650,0x5f4,0x5a0,0x54c,0x500,0x4b8,0x474,0x434,0x3f8,0x3c0,0x38a, diff --git a/sc2/src/libs/mikmod/sloader.c b/sc2/src/libs/mikmod/sloader.c index 0b8c68553..b10bcd19f 100644 --- a/sc2/src/libs/mikmod/sloader.c +++ b/sc2/src/libs/mikmod/sloader.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 @@ -56,7 +56,7 @@ typedef struct ITPACK { BOOL SL_Init(SAMPLOAD* s) { if(!sl_buffer) - if(!(sl_buffer=MikMod_malloc(SLBUFSIZE*sizeof(SWORD)))) return 0; + if(!(sl_buffer=(SWORD*)MikMod_malloc(SLBUFSIZE*sizeof(SWORD)))) return 0; sl_rlength = s->length; if(s->infmt & SF_16BITS) sl_rlength>>=1; @@ -68,16 +68,15 @@ BOOL SL_Init(SAMPLOAD* s) void SL_Exit(SAMPLOAD *s) { if(sl_rlength>0) _mm_fseek(s->reader,sl_rlength,SEEK_CUR); - if(sl_buffer) { - MikMod_free(sl_buffer); - sl_buffer=NULL; - } + + MikMod_free(sl_buffer); + sl_buffer=NULL; } /* unpack a 8bit IT packed sample */ -static BOOL read_itcompr8(ITPACK* status,MREADER *reader,SWORD *sl_buffer,UWORD count,UWORD* incnt) +static int read_itcompr8(ITPACK* status,MREADER *reader,SWORD *out,UWORD count,UWORD* incnt) { - SWORD *dest=sl_buffer,*end=sl_buffer+count; + SWORD *dest=out,*end=out+count; UWORD x,y,needbits,havebits,new_count=0; UWORD bits = status->bits; UWORD bufbits = status->bufbits; @@ -145,13 +144,13 @@ static BOOL read_itcompr8(ITPACK* status,MREADER *reader,SWORD *sl_buffer,UWORD status->bufbits = bufbits; status->last = last; status->buf = buf; - return !!(dest-sl_buffer); + return (dest-out); } /* unpack a 16bit IT packed sample */ -static BOOL read_itcompr16(ITPACK *status,MREADER *reader,SWORD *sl_buffer,UWORD count,UWORD* incnt) +static int read_itcompr16(ITPACK *status,MREADER *reader,SWORD *out,UWORD count,UWORD* incnt) { - SWORD *dest=sl_buffer,*end=sl_buffer+count; + SWORD *dest=out,*end=out+count; SLONG x,y,needbits,havebits,new_count=0; UWORD bits = status->bits; UWORD bufbits = status->bufbits; @@ -174,15 +173,15 @@ static BOOL read_itcompr16(ITPACK *status,MREADER *reader,SWORD *sl_buffer,UWORD y=needbits>=y; - bufbits-=y; - needbits-=y; - havebits+=y; + bufbits-=(UWORD)y; + needbits-=(UWORD)y; + havebits+=(UWORD)y; } if (new_count) { new_count = 0; if (++x >= bits) x++; - bits = x; + bits = (UWORD)x; continue; } if (bits<7) { @@ -196,13 +195,13 @@ static BOOL read_itcompr16(ITPACK *status,MREADER *reader,SWORD *sl_buffer,UWORD if ((x>y)&&(x<=y+16)) { if ((x-=y)>=bits) x++; - bits = x; + bits = (UWORD)x; continue; } } else if (bits<18) { if (x>=0x10000) { - bits=x-0x10000+1; + bits=(UWORD)(x-0x10000+1); continue; } } else { @@ -219,10 +218,10 @@ static BOOL read_itcompr16(ITPACK *status,MREADER *reader,SWORD *sl_buffer,UWORD status->bufbits = bufbits; status->last = last; status->buf = buf; - return !!(dest-sl_buffer); + return (dest-out); } -static BOOL SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefactor,ULONG length,MREADER* reader,BOOL dither) +static int SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefactor,ULONG length,MREADER* reader,BOOL dither) { SBYTE *bptr = (SBYTE*)buffer; SWORD *wptr = (SWORD*)buffer; @@ -230,7 +229,12 @@ static BOOL SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefacto int result,c_block=0; /* compression bytes until next block */ ITPACK status; - UWORD incnt; + UWORD incnt = 0; + + status.buf = 0; + status.last = 0; + status.bufbits = 0; + status.bits = 0; while(length) { stodo=(lengthRead(reader,sl_buffer,sizeof(SBYTE)*stodo); src = (SBYTE*)sl_buffer; dest = sl_buffer; @@ -285,7 +297,7 @@ static BOOL SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefacto sl_old = sl_buffer[t]; } - if((infmt^outfmt) & SF_SIGNED) + if((infmt^outfmt) & SF_SIGNED) for(t=0;t>1; + sl_buffer[idx++]=(SWORD)(avgval>>1); length-=2; } stodo = idx; @@ -334,10 +346,10 @@ static BOOL SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefacto return 0; } -BOOL SL_Load(void* buffer,SAMPLOAD *smp,ULONG length) +int SL_Load(void* buffer,SAMPLOAD *smp,ULONG length) { return SL_LoadInternal(buffer,smp->infmt,smp->outfmt,smp->scalefactor, - length,smp->reader,0); + length,smp->reader,0); } /* Registers a sample for loading when SL_LoadSamples() is called. */ @@ -354,7 +366,7 @@ SAMPLOAD* SL_RegisterSample(SAMPLE* s,int type,MREADER* reader) cruise = sndfxlist; } else return NULL; - + /* Allocate and add structure to the END of the list */ if(!(news=(SAMPLOAD*)MikMod_malloc(sizeof(SAMPLOAD)))) return NULL; @@ -404,9 +416,9 @@ static ULONG SampleTotal(SAMPLOAD* samplist,int type) static ULONG RealSpeed(SAMPLOAD *s) { return(s->sample->speed/(s->scalefactor?s->scalefactor:1)); -} +} -static BOOL DitherSamples(SAMPLOAD* samplist,int type) +static int DitherSamples(SAMPLOAD* samplist,int type) { SAMPLOAD *c2smp=NULL; ULONG maxsize, speed; @@ -414,7 +426,7 @@ static BOOL DitherSamples(SAMPLOAD* samplist,int type) if(!samplist) return 0; - if((maxsize=MD_SampleSpace(type)*1024)) + if((maxsize=MD_SampleSpace(type)*1024) != 0) while(SampleTotal(samplist,type)>maxsize) { /* First Pass - check for any 16 bit samples */ s = samplist; @@ -468,17 +480,17 @@ static BOOL DitherSamples(SAMPLOAD* samplist,int type) return 0; } -BOOL SL_LoadSamples(void) +int SL_LoadSamples(void) { - BOOL ok; + int rc; _mm_critical = 0; if((!musiclist)&&(!sndfxlist)) return 0; - ok=DitherSamples(musiclist,MD_MUSIC)||DitherSamples(sndfxlist,MD_SNDFX); + rc=DitherSamples(musiclist,MD_MUSIC)||DitherSamples(sndfxlist,MD_SNDFX); musiclist=sndfxlist=NULL; - return ok; + return rc; } void SL_Sample16to8(SAMPLOAD* s) @@ -515,5 +527,4 @@ void SL_HalveSample(SAMPLOAD* s,int factor) s->sample->loopend = s->loopend / s->scalefactor; } - /* ex:set ts=4: */ diff --git a/sc2/src/libs/mikmod/virtch.c b/sc2/src/libs/mikmod/virtch.c index 0bbb470c1..934297841 100644 --- a/sc2/src/libs/mikmod/virtch.c +++ b/sc2/src/libs/mikmod/virtch.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 @@ -38,7 +38,6 @@ #include "config.h" #endif -#include #ifdef HAVE_MEMORY_H #include #endif @@ -50,7 +49,7 @@ Constant definitions ==================== - BITSHIFT + BITSHIFT Controls the maximum volume of the sound output. All data is shifted right by BITSHIFT after being mixed. Higher values result in quieter sound and less chance of distortion. @@ -127,40 +126,195 @@ static SLONG *RVbufR1=NULL,*RVbufR2=NULL,*RVbufR3=NULL,*RVbufR4=NULL, #define NATIVE SLONG #endif +#if defined HAVE_SSE2 || defined HAVE_ALTIVEC + +# if !defined(NATIVE_64BIT_INT) +static SINTPTR_T MixSIMDMonoNormal(const SWORD* srce,SLONG* dest,SINTPTR_T idx,SINTPTR_T increment,SINTPTR_T todo) +{ + /* TODO: */ + SWORD sample; + SLONG lvolsel = vnf->lvolsel; + + while(todo--) { + sample = srce[idx >> FRACBITS]; + idx += increment; + + *dest++ += lvolsel * sample; + } + return idx; +} +# endif /* !NATIVE_64BIT_INT */ + +static SINTPTR_T MixSIMDStereoNormal(const SWORD* srce,SLONG* dest,SINTPTR_T idx,SINTPTR_T increment,SINTPTR_T todo) +{ + SWORD vol[8] = {vnf->lvolsel, vnf->rvolsel}; + SWORD sample; + SLONG remain = todo; + + /* Dest can be misaligned */ + while(!IS_ALIGNED_16(dest)) { + sample=srce[idx >> FRACBITS]; + idx += increment; + *dest++ += vol[0] * sample; + *dest++ += vol[1] * sample; + todo--; + if(!todo) return idx; + } + + /* Srce is always aligned */ + +#if defined HAVE_SSE2 + remain = todo&3; + { + __m128i v0 = _mm_set_epi16(0, vol[1], + 0, vol[0], + 0, vol[1], + 0, vol[0]); + for(todo>>=2;todo; todo--) + { + SWORD s0 = srce[idx >> FRACBITS]; + SWORD s1 = srce[(idx += increment) >> FRACBITS]; + SWORD s2 = srce[(idx += increment) >> FRACBITS]; + SWORD s3 = srce[(idx += increment) >> FRACBITS]; + __m128i v1 = _mm_set_epi16(0, s1, 0, s1, 0, s0, 0, s0); + __m128i v2 = _mm_set_epi16(0, s3, 0, s3, 0, s2, 0, s2); + __m128i v3 = _mm_load_si128((__m128i*)(dest+0)); + __m128i v4 = _mm_load_si128((__m128i*)(dest+4)); + _mm_store_si128((__m128i*)(dest+0), _mm_add_epi32(v3, _mm_madd_epi16(v0, v1))); + _mm_store_si128((__m128i*)(dest+4), _mm_add_epi32(v4, _mm_madd_epi16(v0, v2))); + dest+=8; + idx += increment; + } + } + +#elif defined HAVE_ALTIVEC + remain = todo&3; + { + SWORD s[8]; + vector signed short r0 = vec_ld(0, vol); + vector signed short v0 = vec_perm(r0, r0, (vector unsigned char)(0, 1, /* l */ + 0, 1, /* l */ + 2, 3, /* r */ + 2, 1, /* r */ + 0, 1, /* l */ + 0, 1, /* l */ + 2, 3, /* r */ + 2, 3 /* r */ + )); + + for(todo>>=2;todo; todo--) + { + vector short int r1; + vector signed short v1, v2; + vector signed int v3, v4, v5, v6; + + /* Load constants */ + s[0] = srce[idx >> FRACBITS]; + s[1] = srce[(idx += increment) >> FRACBITS]; + s[2] = srce[(idx += increment) >> FRACBITS]; + s[3] = srce[(idx += increment) >> FRACBITS]; + s[4] = 0; + + r1 = vec_ld(0, s); + v1 = vec_perm(r1, r1, (vector unsigned char) + (0*2, 0*2+1, /* s0 */ + 4*2, 4*2+1, /* 0 */ + 0*2, 0*2+1, /* s0 */ + 4*2, 4*2+1, /* 0 */ + 1*2, 1*2+1, /* s1 */ + 4*2, 4*2+1, /* 0 */ + 1*2, 1*2+1, /* s1 */ + 4*2, 4*2+1 /* 0 */ + ) ); + v2 = vec_perm(r1, r1, (vector unsigned char) + (2*2, 2*2+1, /* s2 */ + 4*2, 4*2+1, /* 0 */ + 2*2, 2*2+1, /* s2 */ + 4*2, 4*2+1, /* 0 */ + 3*2, 3*2+1, /* s3 */ + 4*2, 4*2+1, /* 0 */ + 3*2, 3*2+1, /* s3 */ + 4*2, 4*2+1 /* 0 */ + ) ); + + v3 = vec_ld(0, dest); + v4 = vec_ld(0, dest + 4); + v5 = vec_mule(v0, v1); + v6 = vec_mule(v0, v2); + + vec_st(vec_add(v3, v5), 0, dest); + vec_st(vec_add(v4, v6), 0x10, dest); + + dest+=8; + idx += increment; + } + } +#endif /* HAVE_ALTIVEC */ + + /* Remaining bits */ + while(remain--) { + sample=srce[idx >> FRACBITS]; + idx += increment; + + *dest++ += vol[0] * sample; + *dest++ += vol[1] * sample; + } + return idx; +} +#endif + /*========== 32 bit sample mixers - only for 32 bit platforms */ #ifndef NATIVE_64BIT_INT -static SLONG Mix32MonoNormal(const SWORD* srce,SLONG* dest,SLONG index,SLONG increment,SLONG todo) +static SLONG Mix32MonoNormal(const SWORD* srce,SLONG* dest,SLONG idx,SLONG increment,SLONG todo) { - SWORD sample; - SLONG lvolsel = vnf->lvolsel; - - while(todo--) { - sample = srce[index >> FRACBITS]; - index += increment; - - *dest++ += lvolsel * sample; +#if defined HAVE_ALTIVEC || defined HAVE_SSE2 + if (md_mode & DMODE_SIMDMIXER) { + return MixSIMDMonoNormal(srce, dest, idx, increment, todo); } - return index; + else +#endif + { + SWORD sample; + SLONG lvolsel = vnf->lvolsel; + + while(todo--) { + sample = srce[idx >> FRACBITS]; + idx += increment; + + *dest++ += lvolsel * sample; + } + } + return idx; } -static SLONG Mix32StereoNormal(const SWORD* srce,SLONG* dest,SLONG index,SLONG increment,SLONG todo) +/* FIXME: This mixer should works also on 64-bit platform */ +/* Hint : changes SLONG / SLONGLONG mess with intptr */ +static SLONG Mix32StereoNormal(const SWORD* srce,SLONG* dest,SLONG idx,SLONG increment,SLONG todo) { - SWORD sample; - SLONG lvolsel = vnf->lvolsel; - SLONG rvolsel = vnf->rvolsel; - - while(todo--) { - sample=srce[index >> FRACBITS]; - index += increment; - - *dest++ += lvolsel * sample; - *dest++ += rvolsel * sample; +#if defined HAVE_ALTIVEC || defined HAVE_SSE2 + if (md_mode & DMODE_SIMDMIXER) { + return MixSIMDStereoNormal(srce, dest, idx, increment, todo); } - return index; + else +#endif + { + SWORD sample; + SLONG lvolsel = vnf->lvolsel; + SLONG rvolsel = vnf->rvolsel; + + while(todo--) { + sample=srce[idx >> FRACBITS]; + idx += increment; + + *dest++ += lvolsel * sample; + *dest++ += rvolsel * sample; + } + } + return idx; } -static SLONG Mix32SurroundNormal(const SWORD* srce,SLONG* dest,SLONG index,SLONG increment,SLONG todo) +static SLONG Mix32SurroundNormal(const SWORD* srce,SLONG* dest,SLONG idx,SLONG increment,SLONG todo) { SWORD sample; SLONG lvolsel = vnf->lvolsel; @@ -168,25 +322,26 @@ static SLONG Mix32SurroundNormal(const SWORD* srce,SLONG* dest,SLONG index,SLONG if (lvolsel>=rvolsel) { while(todo--) { - sample = srce[index >> FRACBITS]; - index += increment; + sample = srce[idx >> FRACBITS]; + idx += increment; *dest++ += lvolsel*sample; *dest++ -= lvolsel*sample; } - } else { + } + else { while(todo--) { - sample = srce[index >> FRACBITS]; - index += increment; + sample = srce[idx >> FRACBITS]; + idx += increment; *dest++ -= rvolsel*sample; *dest++ += rvolsel*sample; } } - return index; + return idx; } -static SLONG Mix32MonoInterp(const SWORD* srce,SLONG* dest,SLONG index,SLONG increment,SLONG todo) +static SLONG Mix32MonoInterp(const SWORD* srce,SLONG* dest,SLONG idx,SLONG increment,SLONG todo) { SLONG sample; SLONG lvolsel = vnf->lvolsel; @@ -195,33 +350,33 @@ static SLONG Mix32MonoInterp(const SWORD* srce,SLONG* dest,SLONG index,SLONG inc if (rampvol) { SLONG oldlvol = vnf->oldlvol - lvolsel; while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ += ((lvolsel << CLICK_SHIFT) + oldlvol * rampvol) - * sample >> CLICK_SHIFT; + * sample >> CLICK_SHIFT; if (!--rampvol) break; } vnf->rampvol = rampvol; if (todo < 0) - return index; + return idx; } while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ += lvolsel * sample; } - return index; + return idx; } -static SLONG Mix32StereoInterp(const SWORD* srce,SLONG* dest,SLONG index,SLONG increment,SLONG todo) +static SLONG Mix32StereoInterp(const SWORD* srce,SLONG* dest,SLONG idx,SLONG increment,SLONG todo) { SLONG sample; SLONG lvolsel = vnf->lvolsel; @@ -232,13 +387,13 @@ static SLONG Mix32StereoInterp(const SWORD* srce,SLONG* dest,SLONG index,SLONG i SLONG oldlvol = vnf->oldlvol - lvolsel; SLONG oldrvol = vnf->oldrvol - rvolsel; while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ += ((lvolsel << CLICK_SHIFT) + oldlvol * rampvol) - * sample >> CLICK_SHIFT; + * sample >> CLICK_SHIFT; *dest++ += ((rvolsel << CLICK_SHIFT) + oldrvol * rampvol) * sample >> CLICK_SHIFT; if (!--rampvol) @@ -246,22 +401,22 @@ static SLONG Mix32StereoInterp(const SWORD* srce,SLONG* dest,SLONG index,SLONG i } vnf->rampvol = rampvol; if (todo < 0) - return index; + return idx; } while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ += lvolsel * sample; *dest++ += rvolsel * sample; } - return index; + return idx; } -static SLONG Mix32SurroundInterp(const SWORD* srce,SLONG* dest,SLONG index,SLONG increment,SLONG todo) +static SLONG Mix32SurroundInterp(const SWORD* srce,SLONG* dest,SLONG idx,SLONG increment,SLONG todo) { SLONG sample; SLONG lvolsel = vnf->lvolsel; @@ -280,13 +435,13 @@ static SLONG Mix32SurroundInterp(const SWORD* srce,SLONG* dest,SLONG index,SLONG if (rampvol) { oldvol -= vol; while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; sample=((vol << CLICK_SHIFT) + oldvol * rampvol) - * sample >> CLICK_SHIFT; + * sample >> CLICK_SHIFT; *dest++ += sample; *dest++ -= sample; @@ -295,55 +450,55 @@ static SLONG Mix32SurroundInterp(const SWORD* srce,SLONG* dest,SLONG index,SLONG } vnf->rampvol = rampvol; if (todo < 0) - return index; + return idx; } while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ += vol*sample; *dest++ -= vol*sample; } - return index; + return idx; } #endif /*========== 64 bit sample mixers - all platforms */ -static SLONGLONG MixMonoNormal(const SWORD* srce,SLONG* dest,SLONGLONG index,SLONGLONG increment,SLONG todo) +static SLONGLONG MixMonoNormal(const SWORD* srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,SLONG todo) { SWORD sample; SLONG lvolsel = vnf->lvolsel; while(todo--) { - sample = srce[index >> FRACBITS]; - index += increment; + sample = srce[idx >> FRACBITS]; + idx += increment; *dest++ += lvolsel * sample; } - return index; + return idx; } -static SLONGLONG MixStereoNormal(const SWORD* srce,SLONG* dest,SLONGLONG index,SLONGLONG increment,SLONG todo) +static SLONGLONG MixStereoNormal(const SWORD* srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,SLONG todo) { SWORD sample; SLONG lvolsel = vnf->lvolsel; SLONG rvolsel = vnf->rvolsel; while(todo--) { - sample=srce[index >> FRACBITS]; - index += increment; + sample=srce[idx >> FRACBITS]; + idx += increment; *dest++ += lvolsel * sample; *dest++ += rvolsel * sample; } - return index; + return idx; } -static SLONGLONG MixSurroundNormal(const SWORD* srce,SLONG* dest,SLONGLONG index,SLONGLONG increment,SLONG todo) +static SLONGLONG MixSurroundNormal(const SWORD* srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,SLONG todo) { SWORD sample; SLONG lvolsel = vnf->lvolsel; @@ -351,25 +506,26 @@ static SLONGLONG MixSurroundNormal(const SWORD* srce,SLONG* dest,SLONGLONG index if(vnf->lvolsel>=vnf->rvolsel) { while(todo--) { - sample = srce[index >> FRACBITS]; - index += increment; + sample = srce[idx >> FRACBITS]; + idx += increment; *dest++ += lvolsel*sample; *dest++ -= lvolsel*sample; } - } else { + } + else { while(todo--) { - sample = srce[index >> FRACBITS]; - index += increment; + sample = srce[idx >> FRACBITS]; + idx += increment; *dest++ -= rvolsel*sample; *dest++ += rvolsel*sample; } } - return index; + return idx; } -static SLONGLONG MixMonoInterp(const SWORD* srce,SLONG* dest,SLONGLONG index,SLONGLONG increment,SLONG todo) +static SLONGLONG MixMonoInterp(const SWORD* srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,SLONG todo) { SLONG sample; SLONG lvolsel = vnf->lvolsel; @@ -378,10 +534,10 @@ static SLONGLONG MixMonoInterp(const SWORD* srce,SLONG* dest,SLONGLONG index,SLO if (rampvol) { SLONG oldlvol = vnf->oldlvol - lvolsel; while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ += ((lvolsel << CLICK_SHIFT) + oldlvol * rampvol) * sample >> CLICK_SHIFT; @@ -390,21 +546,21 @@ static SLONGLONG MixMonoInterp(const SWORD* srce,SLONG* dest,SLONGLONG index,SLO } vnf->rampvol = rampvol; if (todo < 0) - return index; + return idx; } while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ += lvolsel * sample; } - return index; + return idx; } -static SLONGLONG MixStereoInterp(const SWORD* srce,SLONG* dest,SLONGLONG index,SLONGLONG increment,SLONG todo) +static SLONGLONG MixStereoInterp(const SWORD* srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,SLONG todo) { SLONG sample; SLONG lvolsel = vnf->lvolsel; @@ -415,10 +571,10 @@ static SLONGLONG MixStereoInterp(const SWORD* srce,SLONG* dest,SLONGLONG index,S SLONG oldlvol = vnf->oldlvol - lvolsel; SLONG oldrvol = vnf->oldrvol - rvolsel; while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ +=((lvolsel << CLICK_SHIFT) + oldlvol * rampvol) * sample >> CLICK_SHIFT; @@ -429,22 +585,22 @@ static SLONGLONG MixStereoInterp(const SWORD* srce,SLONG* dest,SLONGLONG index,S } vnf->rampvol = rampvol; if (todo < 0) - return index; + return idx; } while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ += lvolsel * sample; *dest++ += rvolsel * sample; } - return index; + return idx; } -static SLONGLONG MixSurroundInterp(const SWORD* srce,SLONG* dest,SLONGLONG index,SLONGLONG increment,SLONG todo) +static SLONGLONG MixSurroundInterp(const SWORD* srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,SLONG todo) { SLONG sample; SLONG lvolsel = vnf->lvolsel; @@ -463,13 +619,13 @@ static SLONGLONG MixSurroundInterp(const SWORD* srce,SLONG* dest,SLONGLONG index if (rampvol) { oldvol -= vol; while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; sample=((vol << CLICK_SHIFT) + oldvol * rampvol) - * sample >> CLICK_SHIFT; + * sample >> CLICK_SHIFT; *dest++ += sample; *dest++ -= sample; if (!--rampvol) @@ -477,19 +633,19 @@ static SLONGLONG MixSurroundInterp(const SWORD* srce,SLONG* dest,SLONGLONG index } vnf->rampvol = rampvol; if (todo < 0) - return index; + return idx; } while(todo--) { - sample=(SLONG)srce[index>>FRACBITS]+ - ((SLONG)(srce[(index>>FRACBITS)+1]-srce[index>>FRACBITS]) - *(index&FRACMASK)>>FRACBITS); - index += increment; + sample=(SLONG)srce[idx>>FRACBITS]+ + ((SLONG)(srce[(idx>>FRACBITS)+1]-srce[idx>>FRACBITS]) + *(idx&FRACMASK)>>FRACBITS); + idx += increment; *dest++ += vol*sample; *dest++ -= vol*sample; } - return index; + return idx; } static void (*MixReverb)(SLONG* srce,NATIVE count); @@ -526,7 +682,7 @@ static void MixReverb_Normal(SLONG* srce,NATIVE count) /* left channel */ *srce++ +=RVbufL1[loc1]-RVbufL2[loc2]+RVbufL3[loc3]-RVbufL4[loc4]+ - RVbufL5[loc5]-RVbufL6[loc6]+RVbufL7[loc7]-RVbufL8[loc8]; + RVbufL5[loc5]-RVbufL6[loc6]+RVbufL7[loc7]-RVbufL8[loc8]; } } @@ -563,19 +719,89 @@ static void MixReverb_Stereo(SLONG* srce,NATIVE count) /* left channel then right channel */ *srce++ +=RVbufL1[loc1]-RVbufL2[loc2]+RVbufL3[loc3]-RVbufL4[loc4]+ - RVbufL5[loc5]-RVbufL6[loc6]+RVbufL7[loc7]-RVbufL8[loc8]; + RVbufL5[loc5]-RVbufL6[loc6]+RVbufL7[loc7]-RVbufL8[loc8]; *srce++ +=RVbufR1[loc1]-RVbufR2[loc2]+RVbufR3[loc3]-RVbufR4[loc4]+ - RVbufR5[loc5]-RVbufR6[loc6]+RVbufR7[loc7]-RVbufR8[loc8]; + RVbufR5[loc5]-RVbufR6[loc6]+RVbufR7[loc7]-RVbufR8[loc8]; } } +static void (*MixLowPass)(SLONG* srce,NATIVE count); + +static int nLeftNR, nRightNR; + +static void MixLowPass_Stereo(SLONG* srce,NATIVE count) +{ + int n1 = nLeftNR, n2 = nRightNR; + SLONG *pnr = srce; + int nr=count; + for (; nr; nr--) + { + int vnr = pnr[0] >> 1; + pnr[0] = vnr + n1; + n1 = vnr; + vnr = pnr[1] >> 1; + pnr[1] = vnr + n2; + n2 = vnr; + pnr += 2; + } + nLeftNR = n1; + nRightNR = n2; +} + +static void MixLowPass_Normal(SLONG* srce,NATIVE count) +{ + int n1 = nLeftNR; + SLONG *pnr = srce; + int nr=count; + for (; nr; nr--) + { + int vnr = pnr[0] >> 1; + pnr[0] = vnr + n1; + n1 = vnr; + pnr ++; + } + nLeftNR = n1; +} + +/* shifting fudge factor for FP scaling, should be 0 < FP_SHIFT < BITSHIFT */ +#define FP_SHIFT 4 + +/* Mixing macros */ +#define EXTRACT_SAMPLE_FP(var,size) var=(*srce++>>(BITSHIFT-size)) * ((1.0f / 32768.0f) / (1 << size)) +#define CHECK_SAMPLE_FP(var,bound) var=(var>bound)?bound:(var<-bound)?-bound:var +#define PUT_SAMPLE_FP(var) *dste++=var + +static void Mix32ToFP(float* dste,const SLONG *srce,NATIVE count) +{ + float x1,x2,x3,x4; + int remain; + + remain=count&3; + for(count>>=2;count;count--) { + EXTRACT_SAMPLE_FP(x1,FP_SHIFT); EXTRACT_SAMPLE_FP(x2,FP_SHIFT); + EXTRACT_SAMPLE_FP(x3,FP_SHIFT); EXTRACT_SAMPLE_FP(x4,FP_SHIFT); + + CHECK_SAMPLE_FP(x1,1.0f); CHECK_SAMPLE_FP(x2,1.0f); + CHECK_SAMPLE_FP(x3,1.0f); CHECK_SAMPLE_FP(x4,1.0f); + + PUT_SAMPLE_FP(x1); PUT_SAMPLE_FP(x2); + PUT_SAMPLE_FP(x3); PUT_SAMPLE_FP(x4); + } + while(remain--) { + EXTRACT_SAMPLE_FP(x1,FP_SHIFT); + CHECK_SAMPLE_FP(x1,1.0f); + PUT_SAMPLE_FP(x1); + } +} + + /* Mixing macros */ #define EXTRACT_SAMPLE(var,size) var=*srce++>>(BITSHIFT+16-size) #define CHECK_SAMPLE(var,bound) var=(var>=bound)?bound-1:(var<-bound)?-bound:var #define PUT_SAMPLE(var) *dste++=var -static void Mix32To16(SWORD* dste,const SLONG* srce,NATIVE count) +static void Mix32To16(SWORD* dste,const SLONG *srce,NATIVE count) { SLONG x1,x2,x3,x4; int remain; @@ -597,7 +823,7 @@ static void Mix32To16(SWORD* dste,const SLONG* srce,NATIVE count) } } -static void Mix32To8(SBYTE* dste,const SLONG* srce,NATIVE count) +static void Mix32To8(SBYTE* dste,const SLONG *srce,NATIVE count) { SWORD x1,x2,x3,x4; int remain; @@ -620,6 +846,122 @@ static void Mix32To8(SBYTE* dste,const SLONG* srce,NATIVE count) } } +#if defined HAVE_ALTIVEC || defined HAVE_SSE2 + +/* Mix 32bit input to floating point. 32 samples per iteration */ +/* PC: ?, Mac OK */ +static void Mix32ToFP_SIMD(float* dste,const SLONG* srce,NATIVE count) +{ + const float k = ((1.0f / 32768.0f) / (1 << FP_SHIFT)); + int remain=count; + simd_m128 x1, x2, xk; + + while(!IS_ALIGNED_16(dste) || !IS_ALIGNED_16(srce)) + { + float xf; + EXTRACT_SAMPLE_FP(xf,FP_SHIFT); + CHECK_SAMPLE_FP(xf,1.0f); + PUT_SAMPLE_FP(xf); + count--; + if (!count) return; + } + + remain = count&7; + + xk = LOAD_PS1_SIMD(&k); /* Scale factor */ + + for(count>>=3;count;count--) { + EXTRACT_SAMPLE_SIMD_F(srce, x1, FP_SHIFT, xk); /* Load 4 samples */ + EXTRACT_SAMPLE_SIMD_F(srce+4, x2, FP_SHIFT, xk); /* Load 4 samples */ + PUT_SAMPLE_SIMD_F(dste, x1); /* Store 4 samples */ + PUT_SAMPLE_SIMD_F(dste+4, x2); /* Store 4 samples */ + srce+=8; + dste+=8; + } + + if (remain&4) { + EXTRACT_SAMPLE_SIMD_F(srce, x1, FP_SHIFT, xk); /* Load 4 samples */ + PUT_SAMPLE_SIMD_F(dste, x1); /* Store 4 samples */ + srce+=4; + dste+=4; + remain &= 3; + } + + while(remain--) { + float xf; + EXTRACT_SAMPLE_FP(xf,FP_SHIFT); + CHECK_SAMPLE_FP(xf,1.0f); + PUT_SAMPLE_FP(xf); + } +} + +/* PC: Ok, Mac Ok */ +static void Mix32To16_SIMD(SWORD* dste,const SLONG* srce,NATIVE count) +{ + int remain = count; + + while(!IS_ALIGNED_16(dste) || !IS_ALIGNED_16(srce)) + { + SLONG x1; + EXTRACT_SAMPLE(x1,16); + CHECK_SAMPLE(x1,32768); + PUT_SAMPLE(x1); + count--; + if (!count) return; + } + + remain = count&7; + + for(count>>=3;count;count--) + { + simd_m128i x1,x2; + EXTRACT_SAMPLE_SIMD_16(srce, x1); /* Load 4 samples */ + EXTRACT_SAMPLE_SIMD_16(srce+4, x2); /* Load 4 samples */ + PUT_SAMPLE_SIMD_W(dste, x1, x2); /* Store 8 samples */ + srce+=8; + dste+=8; + } + + if (remain) + Mix32To16(dste, srce, remain); +} + +/* Mix 32bit input to 8bit. 128 samples per iteration */ +/* PC:OK, Mac: Ok */ +static void Mix32To8_SIMD(SBYTE* dste,const SLONG* srce,NATIVE count) +{ + int remain=count; + + while(!IS_ALIGNED_16(dste) || !IS_ALIGNED_16(srce)) + { + SWORD x1; + EXTRACT_SAMPLE(x1,8); + CHECK_SAMPLE(x1,128); + PUT_SAMPLE(x1+128); + count--; + if (!count) return; + } + + remain = count&15; + + for(count>>=4;count;count--) { + simd_m128i x1,x2,x3,x4; + EXTRACT_SAMPLE_SIMD_8(srce, x1); /* Load 4 samples */ + EXTRACT_SAMPLE_SIMD_8(srce+4, x2); /* Load 4 samples */ + EXTRACT_SAMPLE_SIMD_8(srce+8, x3); /* Load 4 samples */ + EXTRACT_SAMPLE_SIMD_8(srce+12, x4); /* Load 4 samples */ + PUT_SAMPLE_SIMD_B(dste, x1, x2, x3, x4); /* Store 16 samples */ + srce+=16; + dste+=16; + } + + if (remain) + Mix32To8(dste, srce, remain); +} + +#endif + + static void AddChannel(SLONG* ptr,NATIVE todo) { SLONGLONG end,done; @@ -709,47 +1051,64 @@ static void AddChannel(SLONG* ptr,NATIVE todo) if(vc_mode & DMODE_STEREO) { if((vnf->pan==PAN_SURROUND)&&(md_mode&DMODE_SURROUND)) vnf->current=Mix32SurroundInterp - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); else vnf->current=Mix32StereoInterp - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); } else vnf->current=Mix32MonoInterp - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); } else if(vc_mode & DMODE_STEREO) { if((vnf->pan==PAN_SURROUND)&&(md_mode&DMODE_SURROUND)) vnf->current=Mix32SurroundNormal - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); else + { +#if defined HAVE_ALTIVEC || defined HAVE_SSE2 + if (md_mode & DMODE_SIMDMIXER) + vnf->current=MixSIMDStereoNormal + (s,ptr,vnf->current,vnf->increment,done); + else +#endif vnf->current=Mix32StereoNormal - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); + } } else vnf->current=Mix32MonoNormal - (s,ptr,vnf->current,vnf->increment,done); - } else + (s,ptr,vnf->current,vnf->increment,done); + } + else #endif - { + { if((md_mode & DMODE_INTERP)) { if(vc_mode & DMODE_STEREO) { if((vnf->pan==PAN_SURROUND)&&(md_mode&DMODE_SURROUND)) vnf->current=MixSurroundInterp - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); else vnf->current=MixStereoInterp - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); } else vnf->current=MixMonoInterp - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); } else if(vc_mode & DMODE_STEREO) { if((vnf->pan==PAN_SURROUND)&&(md_mode&DMODE_SURROUND)) vnf->current=MixSurroundNormal - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); else + { +#if defined HAVE_ALTIVEC || defined HAVE_SSE2 + if (md_mode & DMODE_SIMDMIXER) + vnf->current=MixSIMDStereoNormal + (s,ptr,vnf->current,vnf->increment,done); + else +#endif vnf->current=MixStereoNormal - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); + } } else vnf->current=MixMonoNormal - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); } } else /* update sample position */ @@ -760,6 +1119,33 @@ static void AddChannel(SLONG* ptr,NATIVE todo) } } +#ifdef NO_HQMIXER +#define VC_SetupPointers() do{}while(0) +#define VC1_Init VC_Init +#define VC1_Exit VC_Exit +#define VC1_PlayStart VC_PlayStart +#define VC1_PlayStop VC_PlayStop +#define VC1_SampleLength VC_SampleLength +#define VC1_SampleSpace VC_SampleSpace +#define VC1_SampleLoad VC_SampleLoad +#define VC1_SampleUnload VC_SampleUnload +#define VC1_SetNumVoices VC_SetNumVoices +#define VC1_SilenceBytes VC_SilenceBytes +#define VC1_VoicePlay VC_VoicePlay +#define VC1_VoiceStop VC_VoiceStop +#define VC1_VoiceGetFrequency VC_VoiceGetFrequency +#define VC1_VoiceGetPanning VC_VoiceGetPanning +#define VC1_VoiceGetPosition VC_VoiceGetPosition +#define VC1_VoiceGetVolume VC_VoiceGetVolume +#define VC1_VoiceRealVolume VC_VoiceRealVolume +#define VC1_VoiceSetFrequency VC_VoiceSetFrequency +#define VC1_VoiceSetPanning VC_VoiceSetPanning +#define VC1_VoiceSetVolume VC_VoiceSetVolume +#define VC1_VoiceStopped VC_VoiceStopped +#define VC1_WriteBytes VC_WriteBytes +#define VC1_WriteSamples VC_WriteSamples +#endif + #define _IN_VIRTCH_ #include "virtch_common.c" #undef _IN_VIRTCH_ @@ -775,7 +1161,7 @@ void VC1_WriteSamples(SBYTE* buf,ULONG todo) if(vc_mode & DMODE_SOFT_MUSIC) md_player(); tickleft=(md_mixfreq*125L)/(md_bpm*50L); } - left = MIN(tickleft, (long)todo); + left = MIN(tickleft, todo); buffer = buf; tickleft -= left; todo -= left; @@ -818,45 +1204,72 @@ void VC1_WriteSamples(SBYTE* buf,ULONG todo) } } + if(md_mode & DMODE_NOISEREDUCTION) { + MixLowPass(vc_tickbuf, portion); + } + if(md_reverb) { if(md_reverb>15) md_reverb=15; MixReverb(vc_tickbuf, portion); } - if(vc_mode & DMODE_16BITS) - Mix32To16((SWORD*) buffer, vc_tickbuf, count); - else - Mix32To8((SBYTE*) buffer, vc_tickbuf, count); + if (vc_callback) { + vc_callback((unsigned char*)vc_tickbuf, portion); + } +#if defined HAVE_ALTIVEC || defined HAVE_SSE2 + if (md_mode & DMODE_SIMDMIXER) + { + if(vc_mode & DMODE_FLOAT) + Mix32ToFP_SIMD((float*) buffer, vc_tickbuf, count); + else if(vc_mode & DMODE_16BITS) + Mix32To16_SIMD((SWORD*) buffer, vc_tickbuf, count); + else + Mix32To8_SIMD((SBYTE*) buffer, vc_tickbuf, count); + } + else +#endif + { + if(vc_mode & DMODE_FLOAT) + Mix32ToFP((float*) buffer, vc_tickbuf, count); + else if(vc_mode & DMODE_16BITS) + Mix32To16((SWORD*) buffer, vc_tickbuf, count); + else + Mix32To8((SBYTE*) buffer, vc_tickbuf, count); + } buffer += samples2bytes(portion); left -= portion; } } } -BOOL VC1_Init(void) +int VC1_Init(void) { +#ifndef NO_HQMIXER VC_SetupPointers(); - + if (md_mode&DMODE_HQMIXER) return VC2_Init(); +#endif - if(!(Samples=(SWORD**)MikMod_calloc(MAXSAMPLEHANDLES,sizeof(SWORD*)))) { + if(!(Samples=(SWORD**)MikMod_amalloc(MAXSAMPLEHANDLES*sizeof(SWORD*)))) { _mm_errno = MMERR_INITIALIZING_MIXER; return 1; } - if(!vc_tickbuf) - if(!(vc_tickbuf=(SLONG*)MikMod_malloc((TICKLSIZE+32)*sizeof(SLONG)))) { + if(!vc_tickbuf) { + if(!(vc_tickbuf=(SLONG*)MikMod_amalloc((TICKLSIZE+32)*sizeof(SLONG)))) { _mm_errno = MMERR_INITIALIZING_MIXER; return 1; } + } MixReverb=(md_mode&DMODE_STEREO)?MixReverb_Stereo:MixReverb_Normal; + MixLowPass=(md_mode&DMODE_STEREO)?MixLowPass_Stereo:MixLowPass_Normal; vc_mode = md_mode; return 0; } -BOOL VC1_PlayStart(void) +int VC1_PlayStart(void) { samplesthatfit=TICKLSIZE; if(vc_mode & DMODE_STEREO) samplesthatfit >>= 1; @@ -880,14 +1293,17 @@ BOOL VC1_PlayStart(void) if(!(RVbufL7=(SLONG*)MikMod_calloc((RVc7+1),sizeof(SLONG)))) return 1; if(!(RVbufL8=(SLONG*)MikMod_calloc((RVc8+1),sizeof(SLONG)))) return 1; - if(!(RVbufR1=(SLONG*)MikMod_calloc((RVc1+1),sizeof(SLONG)))) return 1; - if(!(RVbufR2=(SLONG*)MikMod_calloc((RVc2+1),sizeof(SLONG)))) return 1; - if(!(RVbufR3=(SLONG*)MikMod_calloc((RVc3+1),sizeof(SLONG)))) return 1; - if(!(RVbufR4=(SLONG*)MikMod_calloc((RVc4+1),sizeof(SLONG)))) return 1; - if(!(RVbufR5=(SLONG*)MikMod_calloc((RVc5+1),sizeof(SLONG)))) return 1; - if(!(RVbufR6=(SLONG*)MikMod_calloc((RVc6+1),sizeof(SLONG)))) return 1; - if(!(RVbufR7=(SLONG*)MikMod_calloc((RVc7+1),sizeof(SLONG)))) return 1; - if(!(RVbufR8=(SLONG*)MikMod_calloc((RVc8+1),sizeof(SLONG)))) return 1; + /* allocate reverb buffers for the right channel if in stereo mode only. */ + if (vc_mode & DMODE_STEREO) { + if(!(RVbufR1=(SLONG*)MikMod_calloc((RVc1+1),sizeof(SLONG)))) return 1; + if(!(RVbufR2=(SLONG*)MikMod_calloc((RVc2+1),sizeof(SLONG)))) return 1; + if(!(RVbufR3=(SLONG*)MikMod_calloc((RVc3+1),sizeof(SLONG)))) return 1; + if(!(RVbufR4=(SLONG*)MikMod_calloc((RVc4+1),sizeof(SLONG)))) return 1; + if(!(RVbufR5=(SLONG*)MikMod_calloc((RVc5+1),sizeof(SLONG)))) return 1; + if(!(RVbufR6=(SLONG*)MikMod_calloc((RVc6+1),sizeof(SLONG)))) return 1; + if(!(RVbufR7=(SLONG*)MikMod_calloc((RVc7+1),sizeof(SLONG)))) return 1; + if(!(RVbufR8=(SLONG*)MikMod_calloc((RVc8+1),sizeof(SLONG)))) return 1; + } RVRindex = 0; return 0; @@ -895,34 +1311,34 @@ BOOL VC1_PlayStart(void) void VC1_PlayStop(void) { - if(RVbufL1) MikMod_free(RVbufL1); - if(RVbufL2) MikMod_free(RVbufL2); - if(RVbufL3) MikMod_free(RVbufL3); - if(RVbufL4) MikMod_free(RVbufL4); - if(RVbufL5) MikMod_free(RVbufL5); - if(RVbufL6) MikMod_free(RVbufL6); - if(RVbufL7) MikMod_free(RVbufL7); - if(RVbufL8) MikMod_free(RVbufL8); + MikMod_free(RVbufL1); + MikMod_free(RVbufL2); + MikMod_free(RVbufL3); + MikMod_free(RVbufL4); + MikMod_free(RVbufL5); + MikMod_free(RVbufL6); + MikMod_free(RVbufL7); + MikMod_free(RVbufL8); RVbufL1=RVbufL2=RVbufL3=RVbufL4=RVbufL5=RVbufL6=RVbufL7=RVbufL8=NULL; - if(RVbufR1) MikMod_free(RVbufR1); - if(RVbufR2) MikMod_free(RVbufR2); - if(RVbufR3) MikMod_free(RVbufR3); - if(RVbufR4) MikMod_free(RVbufR4); - if(RVbufR5) MikMod_free(RVbufR5); - if(RVbufR6) MikMod_free(RVbufR6); - if(RVbufR7) MikMod_free(RVbufR7); - if(RVbufR8) MikMod_free(RVbufR8); + MikMod_free(RVbufR1); + MikMod_free(RVbufR2); + MikMod_free(RVbufR3); + MikMod_free(RVbufR4); + MikMod_free(RVbufR5); + MikMod_free(RVbufR6); + MikMod_free(RVbufR7); + MikMod_free(RVbufR8); RVbufR1=RVbufR2=RVbufR3=RVbufR4=RVbufR5=RVbufR6=RVbufR7=RVbufR8=NULL; } -BOOL VC1_SetNumVoices(void) +int VC1_SetNumVoices(void) { int t; if(!(vc_softchn=md_softchn)) return 0; - if(vinf) MikMod_free(vinf); - if(!(vinf= MikMod_calloc(sizeof(VINFO),vc_softchn))) return 1; + MikMod_free(vinf); + if(!(vinf=(VINFO*)MikMod_calloc(vc_softchn,sizeof(VINFO)))) return 1; for(t=0;t #endif #include #include "mikmod_internals.h" - + /* Constant Definitions ==================== @@ -76,7 +78,8 @@ */ -#define MAXVOL_FACTOR (1<<9) +#define BITSHIFT 9 +#define MAXVOL_FACTOR (1<>FRACBITS,f=index&FRACMASK; - sample=(((SLONG)(srce[i]*(FRACMASK+1L-f)) + - ((SLONG)srce[i+1]*f)) >> FRACBITS); - index+=increment; + i=idx>>FRACBITS,f=idx&FRACMASK; + sample=(SWORD)( (((SLONG)(srce[i]*(FRACMASK+1L-f)) + + ((SLONG)srce[i+1]*f)) >> FRACBITS)); + idx+=increment; if(vnf->rampvol) { *dest++ += (long)( @@ -179,19 +187,19 @@ static SLONG Mix32MonoNormal(const SWORD* srce,SLONG* dest,SLONG index,SLONG inc } vnf->lastvalL=vnf->lvolsel * sample; - return index; + return idx; } -static SLONG Mix32StereoNormal(const SWORD* srce,SLONG* dest,SLONG index,SLONG increment,ULONG todo) +static SLONG Mix32StereoNormal(const SWORD* const srce,SLONG* dest,SLONG idx,SLONG increment,ULONG todo) { SWORD sample=0; SLONG i,f; while(todo--) { - i=index>>FRACBITS,f=index&FRACMASK; - sample=((((SLONG)srce[i]*(FRACMASK+1L-f)) + - ((SLONG)srce[i+1] * f)) >> FRACBITS); - index += increment; + i=idx>>FRACBITS,f=idx&FRACMASK; + sample=(SWORD)(((((SLONG)srce[i]*(FRACMASK+1L-f)) + + ((SLONG)srce[i+1] * f)) >> FRACBITS)); + idx += increment; if(vnf->rampvol) { *dest++ += (long)( @@ -222,20 +230,20 @@ static SLONG Mix32StereoNormal(const SWORD* srce,SLONG* dest,SLONG index,SLONG i vnf->lastvalL=vnf->lvolsel*sample; vnf->lastvalR=vnf->rvolsel*sample; - return index; + return idx; } -static SLONG Mix32StereoSurround(const SWORD* srce,SLONG* dest,SLONG index,SLONG increment,ULONG todo) +static SLONG Mix32StereoSurround(const SWORD* const srce,SLONG* dest,SLONG idx,SLONG increment,ULONG todo) { SWORD sample=0; long whoop; SLONG i, f; while(todo--) { - i=index>>FRACBITS,f=index&FRACMASK; - sample=((((SLONG)srce[i]*(FRACMASK+1L-f)) + - ((SLONG)srce[i+1]*f)) >> FRACBITS); - index+=increment; + i=idx>>FRACBITS,f=idx&FRACMASK; + sample=(SWORD)(((((SLONG)srce[i]*(FRACMASK+1L-f)) + + ((SLONG)srce[i+1]*f)) >> FRACBITS)); + idx+=increment; if(vnf->rampvol) { whoop=(long)( @@ -262,22 +270,22 @@ static SLONG Mix32StereoSurround(const SWORD* srce,SLONG* dest,SLONG index,SLONG vnf->lastvalL=vnf->lvolsel*sample; vnf->lastvalR=vnf->lvolsel*sample; - return index; + return idx; } #endif /*========== 64 bit mixers */ -static SLONGLONG MixMonoNormal(const SWORD* srce,SLONG* dest,SLONGLONG index,SLONGLONG increment,SLONG todo) +static SLONGLONG MixMonoNormal(const SWORD* const srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,SLONG todo) { SWORD sample=0; SLONGLONG i,f; while(todo--) { - i=index>>FRACBITS,f=index&FRACMASK; - sample=(((SLONGLONG)(srce[i]*(FRACMASK+1L-f)) + - ((SLONGLONG)srce[i+1]*f)) >> FRACBITS); - index+=increment; + i=idx>>FRACBITS,f=idx&FRACMASK; + sample=(SWORD)((((SLONGLONG)(srce[i]*(FRACMASK+1L-f)) + + ((SLONGLONG)srce[i+1]*f)) >> FRACBITS)); + idx+=increment; if(vnf->rampvol) { *dest++ += (long)( @@ -297,19 +305,225 @@ static SLONGLONG MixMonoNormal(const SWORD* srce,SLONG* dest,SLONGLONG index,SLO } vnf->lastvalL=vnf->lvolsel * sample; - return index; + return idx; } -static SLONGLONG MixStereoNormal(const SWORD* srce,SLONG* dest,SLONGLONG index,SLONGLONG increment,ULONG todo) +/* Slowest part... */ + +#if defined HAVE_SSE2 || defined HAVE_ALTIVEC + +static __inline SWORD GetSample(const SWORD* const srce, SLONGLONG idx) +{ + SLONGLONG i=idx>>FRACBITS; + SLONGLONG f=idx&FRACMASK; + return (SWORD)(((((SLONGLONG)srce[i]*(FRACMASK+1L-f)) + + ((SLONGLONG)srce[i+1] * f)) >> FRACBITS)); +} + +static SLONGLONG MixSIMDStereoNormal(const SWORD* const srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,ULONG todo) +{ + SWORD vol[8] = {vnf->lvolsel, vnf->rvolsel}; + SWORD sample=0; + SLONG remain = todo; + + /* Dest can be misaligned */ + while(!IS_ALIGNED_16(dest)) { + sample=srce[idx >> FRACBITS]; + idx += increment; + *dest++ += vol[0] * sample; + *dest++ += vol[1] * sample; + todo--; + if(!todo) goto end; + } + + /* Srce is always aligned */ + +#if defined HAVE_SSE2 + remain = todo&3; + { + __m128i v0 = _mm_set_epi16(0, vol[1], + 0, vol[0], + 0, vol[1], + 0, vol[0]); + for(todo>>=2;todo; todo--) + { + SWORD s0 = GetSample(srce, idx); + SWORD s1 = GetSample(srce, idx += increment); + SWORD s2 = GetSample(srce, idx += increment); + SWORD s3 = GetSample(srce, idx += increment); + __m128i v1 = _mm_set_epi16(0, s1, 0, s1, 0, s0, 0, s0); + __m128i v2 = _mm_set_epi16(0, s3, 0, s3, 0, s2, 0, s2); + __m128i v3 = _mm_load_si128((__m128i*)(dest+0)); + __m128i v4 = _mm_load_si128((__m128i*)(dest+4)); + _mm_store_si128((__m128i*)(dest+0), _mm_add_epi32(v3, _mm_madd_epi16(v0, v1))); + _mm_store_si128((__m128i*)(dest+4), _mm_add_epi32(v4, _mm_madd_epi16(v0, v2))); + dest+=8; + idx += increment; + } + } + +#elif defined HAVE_ALTIVEC + remain = todo&3; + { + SWORD s[8]; + vector signed short r0 = vec_ld(0, vol); + vector signed short v0 = vec_perm(r0, r0, (vector unsigned char)(0, 1, /* l */ + 0, 1, /* l */ + 2, 3, /* r */ + 2, 1, /* r */ + 0, 1, /* l */ + 0, 1, /* l */ + 2, 3, /* r */ + 2, 3 /* r */ + )); + + for(todo>>=2;todo; todo--) + { + vector short int r1; + vector signed short v1, v2; + vector signed int v3, v4, v5, v6; + + /* Load constants */ + s[0] = GetSample(srce, idx); + s[1] = GetSample(srce, idx += increment); + s[2] = GetSample(srce, idx += increment); + s[3] = GetSample(srce, idx += increment); + s[4] = 0; + + r1 = vec_ld(0, s); + v1 = vec_perm(r1, r1, (vector unsigned char) + (0*2, 0*2+1, /* s0 */ + 4*2, 4*2+1, /* 0 */ + 0*2, 0*2+1, /* s0 */ + 4*2, 4*2+1, /* 0 */ + 1*2, 1*2+1, /* s1 */ + 4*2, 4*2+1, /* 0 */ + 1*2, 1*2+1, /* s1 */ + 4*2, 4*2+1 /* 0 */ + ) ); + v2 = vec_perm(r1, r1, (vector unsigned char) + (2*2, 2*2+1, /* s2 */ + 4*2, 4*2+1, /* 0 */ + 2*2, 2*2+1, /* s2 */ + 4*2, 4*2+1, /* 0 */ + 3*2, 3*2+1, /* s3 */ + 4*2, 4*2+1, /* 0 */ + 3*2, 3*2+1, /* s3 */ + 4*2, 4*2+1 /* 0 */ + ) ); + + v3 = vec_ld(0, dest); + v4 = vec_ld(0x10, dest); + v5 = vec_mule(v0, v1); + v6 = vec_mule(v0, v2); + + vec_st(vec_add(v3, v5), 0, dest); + vec_st(vec_add(v4, v6), 0x10, dest); + + dest+=8; + idx += increment; + } + } +#endif /* HAVE_ALTIVEC */ + + /* Remaining bits */ + while(remain--) { + sample=GetSample(srce, idx); + idx+= increment; + *dest++ += vol[0] * sample; + *dest++ += vol[1] * sample; + } +end: + vnf->lastvalL=vnf->lvolsel*sample; + vnf->lastvalR=vnf->rvolsel*sample; + return idx; +} + +static SLONGLONG MixStereoNormal(const SWORD* const srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,ULONG todo) +{ + SWORD sample=0; + SLONGLONG i,f; + + if (vnf->rampvol) + while(todo) { + todo--; + i=idx>>FRACBITS,f=idx&FRACMASK; + sample=(SWORD)(((((SLONGLONG)srce[i]*(FRACMASK+1L-f)) + + ((SLONGLONG)srce[i+1] * f)) >> FRACBITS)); + idx += increment; + + *dest++ += (long)( + ( ( ((SLONGLONG)vnf->oldlvol*vnf->rampvol) + + (vnf->lvolsel*(CLICK_BUFFER-vnf->rampvol)) + ) * (SLONGLONG)sample ) >> CLICK_SHIFT ); + *dest++ += (long)( + ( ( ((SLONGLONG)vnf->oldrvol*vnf->rampvol) + + (vnf->rvolsel*(CLICK_BUFFER-vnf->rampvol)) + ) * (SLONGLONG)sample ) >> CLICK_SHIFT ); + vnf->rampvol--; + + if (!vnf->rampvol) + break; + } + + if (vnf->click) + while(todo) { + todo--; + i=idx>>FRACBITS,f=idx&FRACMASK; + sample=(SWORD)(((((SLONGLONG)srce[i]*(FRACMASK+1L-f)) + + ((SLONGLONG)srce[i+1] * f)) >> FRACBITS)); + idx += increment; + + *dest++ += (long)( + ( ( (SLONGLONG)(vnf->lvolsel*(CLICK_BUFFER-vnf->click)) * + (SLONGLONG)sample ) + (vnf->lastvalL * vnf->click) ) + >> CLICK_SHIFT ); + + *dest++ += (long)( + ( ( ((SLONGLONG)vnf->rvolsel*(CLICK_BUFFER-vnf->click)) * + (SLONGLONG)sample ) + (vnf->lastvalR * vnf->click) ) + >> CLICK_SHIFT ); + vnf->click--; + + if (!vnf->click) + break; + } + + if (todo) + { + if (md_mode & DMODE_SIMDMIXER) { + return MixSIMDStereoNormal(srce, dest, idx, increment, todo); + } + while(todo) + { + i=idx>>FRACBITS, + f=idx&FRACMASK; + sample=(SWORD)(((((SLONGLONG)srce[i]*(FRACMASK+1L-f)) + + ((SLONGLONG)srce[i+1] * f)) >> FRACBITS)); + idx += increment; + + *dest++ +=vnf->lvolsel*sample; + *dest++ +=vnf->rvolsel*sample; + todo--; + } + } + vnf->lastvalL=vnf->lvolsel*sample; + vnf->lastvalR=vnf->rvolsel*sample; + + return idx; +} + +#else /* HAVE_SSE2 || HAVE_ALTIVEC */ +static SLONGLONG MixStereoNormal(const SWORD* const srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,ULONG todo) { SWORD sample=0; SLONGLONG i,f; while(todo--) { - i=index>>FRACBITS,f=index&FRACMASK; - sample=((((SLONGLONG)srce[i]*(FRACMASK+1L-f)) + - ((SLONGLONG)srce[i+1] * f)) >> FRACBITS); - index += increment; + i=idx>>FRACBITS,f=idx&FRACMASK; + sample=(SWORD)(((((SLONGLONG)srce[i]*(FRACMASK+1L-f)) + + ((SLONGLONG)srce[i+1] * f)) >> FRACBITS)); + idx += increment; if(vnf->rampvol) { *dest++ += (long)( @@ -340,20 +554,22 @@ static SLONGLONG MixStereoNormal(const SWORD* srce,SLONG* dest,SLONGLONG index,S vnf->lastvalL=vnf->lvolsel*sample; vnf->lastvalR=vnf->rvolsel*sample; - return index; + return idx; } +#endif /* HAVE_SSE2 || HAVE_ALTIVEC */ -static SLONGLONG MixStereoSurround(const SWORD* srce,SLONG* dest,SLONGLONG index,SLONGLONG increment,ULONG todo) + +static SLONGLONG MixStereoSurround(const SWORD* srce,SLONG* dest,SLONGLONG idx,SLONGLONG increment,ULONG todo) { SWORD sample=0; long whoop; SLONGLONG i, f; while(todo--) { - i=index>>FRACBITS,f=index&FRACMASK; - sample=((((SLONGLONG)srce[i]*(FRACMASK+1L-f)) + - ((SLONGLONG)srce[i+1]*f)) >> FRACBITS); - index+=increment; + i=idx>>FRACBITS,f=idx&FRACMASK; + sample=(SWORD)(((((SLONGLONG)srce[i]*(FRACMASK+1L-f)) + + ((SLONGLONG)srce[i+1]*f)) >> FRACBITS)); + idx+=increment; if(vnf->rampvol) { whoop=(long)( @@ -380,19 +596,20 @@ static SLONGLONG MixStereoSurround(const SWORD* srce,SLONG* dest,SLONGLONG index vnf->lastvalL=vnf->lvolsel*sample; vnf->lastvalR=vnf->lvolsel*sample; - return index; + return idx; } -static void(*Mix32to16)(SWORD* dste,const SLONG* srce,NATIVE count); -static void(*Mix32to8)(SBYTE* dste,const SLONG* srce,NATIVE count); -static void(*MixReverb)(SLONG* srce,NATIVE count); +static void(*Mix32toFP)(float* dste,const SLONG *srce,NATIVE count); +static void(*Mix32to16)(SWORD* dste,const SLONG *srce,NATIVE count); +static void(*Mix32to8)(SBYTE* dste,const SLONG *srce,NATIVE count); +static void(*MixReverb)(SLONG *srce,NATIVE count); /* Reverb macros */ #define COMPUTE_LOC(n) loc##n = RVRindex % RVc##n #define COMPUTE_LECHO(n) RVbufL##n [loc##n ]=speedup+((ReverbPct*RVbufL##n [loc##n ])>>7) #define COMPUTE_RECHO(n) RVbufR##n [loc##n ]=speedup+((ReverbPct*RVbufR##n [loc##n ])>>7) -static void MixReverb_Normal(SLONG* srce,NATIVE count) +static void MixReverb_Normal(SLONG *srce,NATIVE count) { NATIVE speedup; int ReverbPct; @@ -418,7 +635,7 @@ static void MixReverb_Normal(SLONG* srce,NATIVE count) /* left channel */ *srce++ +=RVbufL1[loc1]-RVbufL2[loc2]+RVbufL3[loc3]-RVbufL4[loc4]+ - RVbufL5[loc5]-RVbufL6[loc6]+RVbufL7[loc7]-RVbufL8[loc8]; + RVbufL5[loc5]-RVbufL6[loc6]+RVbufL7[loc7]-RVbufL8[loc8]; } } @@ -453,12 +670,96 @@ static void MixReverb_Stereo(SLONG *srce,NATIVE count) COMPUTE_LOC(5); COMPUTE_LOC(6); COMPUTE_LOC(7); COMPUTE_LOC(8); /* left channel */ - *srce++ +=RVbufL1[loc1]-RVbufL2[loc2]+RVbufL3[loc3]-RVbufL4[loc4]+ - RVbufL5[loc5]-RVbufL6[loc6]+RVbufL7[loc7]-RVbufL8[loc8]; + *srce++ +=RVbufL1[loc1]-RVbufL2[loc2]+RVbufL3[loc3]-RVbufL4[loc4]+ + RVbufL5[loc5]-RVbufL6[loc6]+RVbufL7[loc7]-RVbufL8[loc8]; /* right channel */ *srce++ +=RVbufR1[loc1]-RVbufR2[loc2]+RVbufR3[loc3]-RVbufR4[loc4]+ - RVbufR5[loc5]-RVbufR6[loc6]+RVbufR7[loc7]-RVbufR8[loc8]; + RVbufR5[loc5]-RVbufR6[loc6]+RVbufR7[loc7]-RVbufR8[loc8]; + } +} + +static void (*MixLowPass)(SLONG* srce,NATIVE count); + +static int nLeftNR, nRightNR; + +static void MixLowPass_Stereo(SLONG* srce,NATIVE count) +{ + int n1 = nLeftNR, n2 = nRightNR; + SLONG *pnr = srce; + int nr=count; + for (; nr; nr--) + { + int vnr = pnr[0] >> 1; + pnr[0] = vnr + n1; + n1 = vnr; + vnr = pnr[1] >> 1; + pnr[1] = vnr + n2; + n2 = vnr; + pnr += 2; + } + nLeftNR = n1; + nRightNR = n2; +} + +static void MixLowPass_Normal(SLONG* srce,NATIVE count) +{ + int n1 = nLeftNR; + SLONG *pnr = srce; + int nr=count; + for (; nr; nr--) + { + int vnr = pnr[0] >> 1; + pnr[0] = vnr + n1; + n1 = vnr; + pnr ++; + } + nLeftNR = n1; +} + +/* Mixing macros */ +#define EXTRACT_SAMPLE_FP(var,attenuation) var=*srce++*((1.0f / 32768.0f) / (MAXVOL_FACTOR*attenuation)) +#define CHECK_SAMPLE_FP(var,bound) var=(var>bound)?bound:(var<-bound)?-bound:var + +static void Mix32ToFP_Normal(float* dste,const SLONG *srce,NATIVE count) +{ + float x1,x2,tmpx; + int i; + + for(count/=SAMPLING_FACTOR;count;count--) { + tmpx=0.0f; + + for(i=SAMPLING_FACTOR/2;i;i--) { + EXTRACT_SAMPLE_FP(x1,1.0f); EXTRACT_SAMPLE_FP(x2,1.0f); + + CHECK_SAMPLE_FP(x1,1.0f); CHECK_SAMPLE_FP(x2,1.0f); + + tmpx+=x1+x2; + } + *dste++ =tmpx*(1.0f/SAMPLING_FACTOR); + } +} + +static void Mix32ToFP_Stereo(float* dste,const SLONG *srce,NATIVE count) +{ + float x1,x2,x3,x4,tmpx,tmpy; + int i; + + for(count/=SAMPLING_FACTOR;count;count--) { + tmpx=tmpy=0.0f; + + for(i=SAMPLING_FACTOR/2;i;i--) { + EXTRACT_SAMPLE_FP(x1,1.0f); EXTRACT_SAMPLE_FP(x2,1.0f); + EXTRACT_SAMPLE_FP(x3,1.0f); EXTRACT_SAMPLE_FP(x4,1.0f); + + CHECK_SAMPLE_FP(x1,1.0f); CHECK_SAMPLE_FP(x2,1.0f); + CHECK_SAMPLE_FP(x3,1.0f); CHECK_SAMPLE_FP(x4,1.0f); + + tmpx+=x1+x3; + tmpy+=x2+x4; + } + *dste++ =tmpx*(1.0f/SAMPLING_FACTOR); + *dste++ =tmpy*(1.0f/SAMPLING_FACTOR); } } @@ -466,7 +767,7 @@ static void MixReverb_Stereo(SLONG *srce,NATIVE count) #define EXTRACT_SAMPLE(var,attenuation) var=*srce++/(MAXVOL_FACTOR*attenuation) #define CHECK_SAMPLE(var,bound) var=(var>=bound)?bound-1:(var<-bound)?-bound:var -static void Mix32To16_Normal(SWORD* dste,const SLONG* srce,NATIVE count) +static void Mix32To16_Normal(SWORD* dste,const SLONG *srce,NATIVE count) { NATIVE x1,x2,tmpx; int i; @@ -481,11 +782,12 @@ static void Mix32To16_Normal(SWORD* dste,const SLONG* srce,NATIVE count) tmpx+=x1+x2; } - *dste++ =tmpx/SAMPLING_FACTOR; + *dste++ =(SWORD)(tmpx/SAMPLING_FACTOR); } } -static void Mix32To16_Stereo(SWORD* dste,const SLONG* srce,NATIVE count) + +static void Mix32To16_Stereo(SWORD* dste,const SLONG *srce,NATIVE count) { NATIVE x1,x2,x3,x4,tmpx,tmpy; int i; @@ -503,12 +805,12 @@ static void Mix32To16_Stereo(SWORD* dste,const SLONG* srce,NATIVE count) tmpx+=x1+x3; tmpy+=x2+x4; } - *dste++ =tmpx/SAMPLING_FACTOR; - *dste++ =tmpy/SAMPLING_FACTOR; + *dste++ =(SWORD)(tmpx/SAMPLING_FACTOR); + *dste++ =(SWORD)(tmpy/SAMPLING_FACTOR); } } -static void Mix32To8_Normal(SBYTE* dste,const SLONG* srce,NATIVE count) +static void Mix32To8_Normal(SBYTE* dste,const SLONG *srce,NATIVE count) { NATIVE x1,x2,tmpx; int i; @@ -523,11 +825,11 @@ static void Mix32To8_Normal(SBYTE* dste,const SLONG* srce,NATIVE count) tmpx+=x1+x2; } - *dste++ =(tmpx/SAMPLING_FACTOR)+128; + *dste++ = (SBYTE)((tmpx/SAMPLING_FACTOR)+128); } } -static void Mix32To8_Stereo(SBYTE* dste,const SLONG* srce,NATIVE count) +static void Mix32To8_Stereo(SBYTE* dste,const SLONG *srce,NATIVE count) { NATIVE x1,x2,x3,x4,tmpx,tmpy; int i; @@ -545,11 +847,163 @@ static void Mix32To8_Stereo(SBYTE* dste,const SLONG* srce,NATIVE count) tmpx+=x1+x3; tmpy+=x2+x4; } - *dste++ =(tmpx/SAMPLING_FACTOR)+128; - *dste++ =(tmpy/SAMPLING_FACTOR)+128; + *dste++ =(SBYTE)((tmpx/SAMPLING_FACTOR)+128); + *dste++ =(SBYTE)((tmpy/SAMPLING_FACTOR)+128); } } +#if defined HAVE_SSE2 +#define SHIFT_MIX_TO_16 (BITSHIFT + 16 - 16) +/* TEST: Ok */ +static void Mix32To16_Stereo_SIMD_4Tap(SWORD* dste, const SLONG* srce, NATIVE count) +{ + int remain = count; + + /* Check unaligned dste buffer. srce is always aligned. */ + while(!IS_ALIGNED_16(dste)) + { + Mix32To16_Stereo(dste, srce, SAMPLING_FACTOR); + dste+=2; + srce+=8; + count--; + if(!count) return; + } + + /* dste and srce aligned. srce is always aligned. */ + remain = count & 15; + /* count / 2 for 1 sample */ + + for(count>>=4;count;count--) + { + /* Load 32bit sample. 1st average */ + __m128i v0 = _mm_add_epi32( + _mm_srai_epi32(_mm_loadu_si128((__m128i const *)(srce+0)), SHIFT_MIX_TO_16), + _mm_srai_epi32(_mm_loadu_si128((__m128i const *)(srce+4)), SHIFT_MIX_TO_16) + ); /* v0: s0.l+s2.l | s0.r+s2.r | s1.l+s3.l | s1.r+s3.r */ + + /* 2nd average (s0.l+s2.l+s1.l+s3.l / 4, s0.r+s2.r+s1.r+s3.r / 4). Upper 64bit is unused (1 stereo sample) */ + __m128i v1 = _mm_srai_epi32(_mm_add_epi32(v0, mm_hiqq(v0)), 2); + /* v1: s0.l+s2.l / 4 | s0.r+s2.r / 4 | s1.l+s3.l+s0.l+s2.l / 4 | s1.r+s3.r+s0.r+s2.r / 4 */ + + __m128i v2 = _mm_add_epi32( + _mm_srai_epi32(_mm_loadu_si128((__m128i const *)(srce+8)), SHIFT_MIX_TO_16), + _mm_srai_epi32(_mm_loadu_si128((__m128i const *)(srce+12)), SHIFT_MIX_TO_16) + ); /* v2: s4.l+s6.l | s4.r+s6.r | s5.l+s7.l | s5.r+s7.r */ + + __m128i v3 = _mm_srai_epi32(_mm_add_epi32(v2, mm_hiqq(v2)), 2); /* Upper 64bit is unused */ + /* v3: s4.l+s6.l /4 | s4.r+s6.r / 4| s5.l+s7.l+s4.l+s6.l / 4 | s5.r+s7.r+s4.r+s6.l / 4 */ + + /* pack two stereo samples in one */ + __m128i v4 = _mm_unpacklo_epi64(v1, v3); /* v4 = avg(s0,s1,s2,s3) | avg(s4,s5,s6,s7) */ + + __m128i v6; + + /* Load 32bit sample. 1st average (s0.l+s2.l, s0.r+s2.r, s1.l+s3.l, s1.r+s3.r) */ + v0 = _mm_add_epi32( + _mm_srai_epi32(_mm_loadu_si128((__m128i const *)(srce+16)), SHIFT_MIX_TO_16), + _mm_srai_epi32(_mm_loadu_si128((__m128i const *)(srce+20)), SHIFT_MIX_TO_16) + ); /* 128bit = 2 stereo samples */ + + /* 2nd average (s0.l+s2.l+s1.l+s3.l / 4, s0.r+s2.r+s1.r+s3.r / 4). Upper 64bit is unused (1 stereo sample) */ + v1 = _mm_srai_epi32(_mm_add_epi32(v0, mm_hiqq(v0)), 2); + + v2 = _mm_add_epi32( + _mm_srai_epi32(_mm_loadu_si128((__m128i const *)(srce+24)), SHIFT_MIX_TO_16), + _mm_srai_epi32(_mm_loadu_si128((__m128i const *)(srce+28)), SHIFT_MIX_TO_16) + ); + + v3 = _mm_srai_epi32(_mm_add_epi32(v2, mm_hiqq(v2)), 2); /* Upper 64bit is unused */ + + /* pack two stereo samples in one */ + v6 = _mm_unpacklo_epi64(v1, v3); /* v6 = avg(s8,s9,s10,s11) | avg(s12,s13,s14,s15) */ + + _mm_store_si128((__m128i*)dste, _mm_packs_epi32(v4, v6)); /* 4 interpolated stereo sample 32bit to 4 */ + + dste+=8; + srce+=32; /* 32 = 4 * 8 */ + } + + /* FIXME: THIS PART WRITES PAST DST !! */ + if (remain) + { + Mix32To16_Stereo(dste, srce, remain); + } +} + +#elif defined HAVE_ALTIVEC +#define SHIFT_MIX_TO_16 vec_splat_u32(BITSHIFT + 16 - 16) +/* TEST: Ok */ +static void Mix32To16_Stereo_SIMD_4Tap(SWORD* dste, const SLONG* srce, NATIVE count) +{ + int remain = count; + + /* Check unaligned dste buffer. srce is always aligned. */ + while(!IS_ALIGNED_16(dste)) + { + Mix32To16_Stereo(dste, srce, SAMPLING_FACTOR); + dste+=2; + srce+=8; + count--; + if(!count) return; + } + + /* dste and srce aligned. srce is always aligned. */ + remain = count & 15; + for(count>>=4;count;count--) + { + /* Load 32bit sample. 1st average (s0.l+s2.l, s0.r+s2.r, s1.l+s3.l, s1.r+s3.r) */ + vector signed int v0 = vec_add( + vec_sra(vec_ld(0, srce), SHIFT_MIX_TO_16), /* 128bit = 2 stereo samples */ + vec_sra(vec_ld(0x10, srce), SHIFT_MIX_TO_16) + ); /* 128bit = 2 stereo samples */ + + /* 2nd average (s0.l+s2.l+s1.l+s3.l / 4, s0.r+s2.r+s1.r+s3.r / 4). Upper 64bit is unused (1 stereo sample) */ + vector signed int v1 = vec_sra(vec_add(v0, vec_hiqq(v0)), vec_splat_u32(2)); + + vector signed int v2 = vec_add( + vec_sra(vec_ld(0x20, srce), SHIFT_MIX_TO_16), + vec_sra(vec_ld(0x30, srce), SHIFT_MIX_TO_16) + ); + + vector signed int v3 = vec_sra(vec_add(v2, vec_hiqq(v2)), vec_splat_u32(2)); /* Upper 64bit is unused */ + + /* pack two stereo samples in one */ + vector signed int v6, v4 = vec_unpacklo(v1, v3); /* v4 = lo64(v1) | lo64(v3) */ + + /* Load 32bit sample. 1st average (s0.l+s2.l, s0.r+s2.r, s1.l+s3.l, s1.r+s3.r) */ + v0 = vec_add( + vec_sra(vec_ld(0x40, srce), SHIFT_MIX_TO_16), /* 128bit = 2 stereo samples */ + vec_sra(vec_ld(0x50, srce), SHIFT_MIX_TO_16) + ); /* 128bit = 2 stereo samples */ + + /* 2nd average (s0.l+s2.l+s1.l+s3.l / 4, s0.r+s2.r+s1.r+s3.r / 4). Upper 64bit is unused (1 stereo sample) */ + v1 = vec_sra(vec_add(v0, vec_hiqq(v0)), vec_splat_u32(2)); + + v2 = vec_add( + vec_sra(vec_ld(0x60, srce), SHIFT_MIX_TO_16), + vec_sra(vec_ld(0x70, srce), SHIFT_MIX_TO_16) + ); + + v3 = vec_sra(vec_add(v2, vec_hiqq(v2)), vec_splat_u32(2)); /* Upper 64bit is unused */ + + /* pack two stereo samples in one */ + v6 = vec_unpacklo(v1, v3); + + vec_st(vec_packs(v4, v6), 0, dste); /* 4 interpolated stereo sample 32bit to 4 interpolated stereo sample 16bit + saturation */ + + dste+=8; + srce+=32; /* 32 = 4 * 8 */ + } + + if (remain) + { + Mix32To16_Stereo(dste, srce, remain); + } +} + +#endif + + static void AddChannel(SLONG* ptr,NATIVE todo) { SLONGLONG end,done; @@ -638,27 +1092,28 @@ static void AddChannel(SLONG* ptr,NATIVE todo) if((vnf->current<0x7fffffff)&&(endpos<0x7fffffff)) { if(vc_mode & DMODE_STEREO) { if((vnf->pan==PAN_SURROUND)&&(vc_mode&DMODE_SURROUND)) - vnf->current=Mix32StereoSurround - (s,ptr,vnf->current,vnf->increment,done); + vnf->current=(SLONGLONG)Mix32StereoSurround + (s,ptr,vnf->current,vnf->increment,done); else vnf->current=Mix32StereoNormal - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); } else vnf->current=Mix32MonoNormal - (s,ptr,vnf->current,vnf->increment,done); - } else + (s,ptr,vnf->current,vnf->increment,done); + } + else #endif - { + { if(vc_mode & DMODE_STEREO) { if((vnf->pan==PAN_SURROUND)&&(vc_mode&DMODE_SURROUND)) vnf->current=MixStereoSurround - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); else vnf->current=MixStereoNormal - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); } else vnf->current=MixMonoNormal - (s,ptr,vnf->current,vnf->increment,done); + (s,ptr,vnf->current,vnf->increment,done); } } else { vnf->lastvalL = vnf->lastvalR = 0; @@ -667,7 +1122,7 @@ static void AddChannel(SLONG* ptr,NATIVE todo) } todo -= done; - ptr +=(vc_mode & DMODE_STEREO)?(done<<1):done; + ptr += (vc_mode & DMODE_STEREO)?(done<<1):done; } } @@ -710,7 +1165,7 @@ void VC2_WriteSamples(SBYTE* buf,ULONG todo) tickleft=(md_mixfreq*125L*SAMPLING_FACTOR)/(md_bpm*50L); tickleft&=~(SAMPLING_FACTOR-1); } - left = MIN(tickleft, (long)todo); + left = MIN(tickleft, todo); buffer = buf; tickleft -= left; todo -= left; @@ -756,12 +1211,22 @@ void VC2_WriteSamples(SBYTE* buf,ULONG todo) } } + if(md_mode & DMODE_NOISEREDUCTION) { + MixLowPass(vc_tickbuf, portion); + } + if(md_reverb) { if(md_reverb>15) md_reverb=15; MixReverb(vc_tickbuf,portion); } - if(vc_mode & DMODE_16BITS) + if (vc_callback) { + vc_callback((unsigned char*)vc_tickbuf, portion); + } + + if(vc_mode & DMODE_FLOAT) + Mix32toFP((float*)buffer,vc_tickbuf,portion); + else if(vc_mode & DMODE_16BITS) Mix32to16((SWORD*)buffer,vc_tickbuf,portion); else Mix32to8((SBYTE*)buffer,vc_tickbuf,portion); @@ -772,38 +1237,49 @@ void VC2_WriteSamples(SBYTE* buf,ULONG todo) } } -BOOL VC2_Init(void) +int VC2_Init(void) { VC_SetupPointers(); - + if (!(md_mode&DMODE_HQMIXER)) return VC1_Init(); - - if(!(Samples=(SWORD**)MikMod_calloc(MAXSAMPLEHANDLES,sizeof(SWORD*)))) { + + if(!(Samples=(SWORD**)MikMod_amalloc(MAXSAMPLEHANDLES*sizeof(SWORD*)))) { _mm_errno = MMERR_INITIALIZING_MIXER; return 1; } - if(!vc_tickbuf) - if(!(vc_tickbuf=(SLONG*)MikMod_malloc((TICKLSIZE+32)*sizeof(SLONG)))) { + if(!vc_tickbuf) { + if(!(vc_tickbuf=(SLONG*)MikMod_amalloc((TICKLSIZE+32)*sizeof(SLONG)))) { _mm_errno = MMERR_INITIALIZING_MIXER; return 1; } + } if(md_mode & DMODE_STEREO) { - Mix32to16 = Mix32To16_Stereo; + Mix32toFP = Mix32ToFP_Stereo; +#if ((defined HAVE_ALTIVEC || defined HAVE_SSE2) && (SAMPLING_FACTOR == 4)) + if (md_mode & DMODE_SIMDMIXER) + Mix32to16 = Mix32To16_Stereo_SIMD_4Tap; + else +#endif + Mix32to16 = Mix32To16_Stereo; Mix32to8 = Mix32To8_Stereo; MixReverb = MixReverb_Stereo; + MixLowPass = MixLowPass_Stereo; } else { + Mix32toFP = Mix32ToFP_Normal; Mix32to16 = Mix32To16_Normal; Mix32to8 = Mix32To8_Normal; MixReverb = MixReverb_Normal; + MixLowPass = MixLowPass_Normal; } + md_mode |= DMODE_INTERP; vc_mode = md_mode; return 0; } -BOOL VC2_PlayStart(void) +int VC2_PlayStart(void) { md_mode|=DMODE_INTERP; @@ -829,14 +1305,17 @@ BOOL VC2_PlayStart(void) if(!(RVbufL7=(SLONG*)MikMod_calloc((RVc7+1),sizeof(SLONG)))) return 1; if(!(RVbufL8=(SLONG*)MikMod_calloc((RVc8+1),sizeof(SLONG)))) return 1; - if(!(RVbufR1=(SLONG*)MikMod_calloc((RVc1+1),sizeof(SLONG)))) return 1; - if(!(RVbufR2=(SLONG*)MikMod_calloc((RVc2+1),sizeof(SLONG)))) return 1; - if(!(RVbufR3=(SLONG*)MikMod_calloc((RVc3+1),sizeof(SLONG)))) return 1; - if(!(RVbufR4=(SLONG*)MikMod_calloc((RVc4+1),sizeof(SLONG)))) return 1; - if(!(RVbufR5=(SLONG*)MikMod_calloc((RVc5+1),sizeof(SLONG)))) return 1; - if(!(RVbufR6=(SLONG*)MikMod_calloc((RVc6+1),sizeof(SLONG)))) return 1; - if(!(RVbufR7=(SLONG*)MikMod_calloc((RVc7+1),sizeof(SLONG)))) return 1; - if(!(RVbufR8=(SLONG*)MikMod_calloc((RVc8+1),sizeof(SLONG)))) return 1; + /* allocate reverb buffers for the right channel if in stereo mode only. */ + if (vc_mode & DMODE_STEREO) { + if(!(RVbufR1=(SLONG*)MikMod_calloc((RVc1+1),sizeof(SLONG)))) return 1; + if(!(RVbufR2=(SLONG*)MikMod_calloc((RVc2+1),sizeof(SLONG)))) return 1; + if(!(RVbufR3=(SLONG*)MikMod_calloc((RVc3+1),sizeof(SLONG)))) return 1; + if(!(RVbufR4=(SLONG*)MikMod_calloc((RVc4+1),sizeof(SLONG)))) return 1; + if(!(RVbufR5=(SLONG*)MikMod_calloc((RVc5+1),sizeof(SLONG)))) return 1; + if(!(RVbufR6=(SLONG*)MikMod_calloc((RVc6+1),sizeof(SLONG)))) return 1; + if(!(RVbufR7=(SLONG*)MikMod_calloc((RVc7+1),sizeof(SLONG)))) return 1; + if(!(RVbufR8=(SLONG*)MikMod_calloc((RVc8+1),sizeof(SLONG)))) return 1; + } RVRindex = 0; return 0; @@ -844,28 +1323,28 @@ BOOL VC2_PlayStart(void) void VC2_PlayStop(void) { - if(RVbufL1) MikMod_free(RVbufL1); - if(RVbufL2) MikMod_free(RVbufL2); - if(RVbufL3) MikMod_free(RVbufL3); - if(RVbufL4) MikMod_free(RVbufL4); - if(RVbufL5) MikMod_free(RVbufL5); - if(RVbufL6) MikMod_free(RVbufL6); - if(RVbufL7) MikMod_free(RVbufL7); - if(RVbufL8) MikMod_free(RVbufL8); - if(RVbufR1) MikMod_free(RVbufR1); - if(RVbufR2) MikMod_free(RVbufR2); - if(RVbufR3) MikMod_free(RVbufR3); - if(RVbufR4) MikMod_free(RVbufR4); - if(RVbufR5) MikMod_free(RVbufR5); - if(RVbufR6) MikMod_free(RVbufR6); - if(RVbufR7) MikMod_free(RVbufR7); - if(RVbufR8) MikMod_free(RVbufR8); + MikMod_free(RVbufL1); + MikMod_free(RVbufL2); + MikMod_free(RVbufL3); + MikMod_free(RVbufL4); + MikMod_free(RVbufL5); + MikMod_free(RVbufL6); + MikMod_free(RVbufL7); + MikMod_free(RVbufL8); + MikMod_free(RVbufR1); + MikMod_free(RVbufR2); + MikMod_free(RVbufR3); + MikMod_free(RVbufR4); + MikMod_free(RVbufR5); + MikMod_free(RVbufR6); + MikMod_free(RVbufR7); + MikMod_free(RVbufR8); RVbufL1=RVbufL2=RVbufL3=RVbufL4=RVbufL5=RVbufL6=RVbufL7=RVbufL8=NULL; RVbufR1=RVbufR2=RVbufR3=RVbufR4=RVbufR5=RVbufR6=RVbufR7=RVbufR8=NULL; } -BOOL VC2_SetNumVoices(void) +int VC2_SetNumVoices(void) { int t; @@ -873,8 +1352,8 @@ BOOL VC2_SetNumVoices(void) if(!(vc_softchn=md_softchn)) return 0; - if(vinf) MikMod_free(vinf); - if(!(vinf=MikMod_calloc(sizeof(VINFO),vc_softchn))) return 1; + MikMod_free(vinf); + if(!(vinf=(VINFO*)MikMod_calloc(vc_softchn,sizeof(VINFO)))) return 1; for(t=0;t>= 1; + if(vc_mode & DMODE_FLOAT) bytes >>= 2; + else if(vc_mode & DMODE_16BITS) bytes >>= 1; if(vc_mode & DMODE_STEREO) bytes >>= 1; return bytes; } @@ -244,7 +256,7 @@ ULONG VC1_SilenceBytes(SBYTE* buf,ULONG todo) todo=samples2bytes(bytes2samples(todo)); /* clear the buffer to zero (16 bits signed) or 0x80 (8 bits unsigned) */ - if(vc_mode & DMODE_16BITS) + if(vc_mode &(DMODE_16BITS|DMODE_FLOAT)) memset(buf,0,todo); else memset(buf,0x80,todo); @@ -270,14 +282,14 @@ ULONG VC1_WriteBytes(SBYTE* buf,ULONG todo) void VC1_Exit(void) { - if(vc_tickbuf) MikMod_free(vc_tickbuf); - if(vinf) MikMod_free(vinf); - if(Samples) MikMod_free(Samples); + MikMod_free(vinf); + MikMod_afree(vc_tickbuf); + MikMod_afree(Samples); vc_tickbuf = NULL; vinf = NULL; Samples = NULL; - + VC_SetupPointers(); } @@ -303,19 +315,19 @@ ULONG VC1_VoiceGetFrequency(UBYTE voice) void VC1_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags) { - vinf[voice].flags = flags; - vinf[voice].handle = handle; - vinf[voice].start = start; - vinf[voice].size = size; - vinf[voice].reppos = reppos; - vinf[voice].repend = repend; - vinf[voice].kick = 1; + vinf[voice].flags = flags; + vinf[voice].handle = handle; + vinf[voice].start = start; + vinf[voice].size = size; + vinf[voice].reppos = reppos; + vinf[voice].repend = repend; + vinf[voice].kick = 1; } void VC1_VoiceStop(UBYTE voice) { vinf[voice].active = 0; -} +} BOOL VC1_VoiceStopped(UBYTE voice) { @@ -324,11 +336,11 @@ BOOL VC1_VoiceStopped(UBYTE voice) SLONG VC1_VoiceGetPosition(UBYTE voice) { - return(vinf[voice].current>>FRACBITS); + return (SLONG)(vinf[voice].current>>FRACBITS); } void VC1_VoiceSetVolume(UBYTE voice,UWORD vol) -{ +{ /* protect against clicks if volume variation is too high */ if(abs((int)vinf[voice].vol-(int)vol)>32) vinf[voice].rampvol=CLICK_BUFFER; @@ -347,9 +359,8 @@ void VC1_VoiceSetPanning(UBYTE voice,ULONG pan) void VC1_SampleUnload(SWORD handle) { - if (handlesample; int handle; - ULONG t, length,loopstart,loopend; + ULONG t, length,loopstart,loopend,looplen; if(type==MD_HARDWARE) return -1; + if(s->length > MAX_SAMPLE_SIZE) { + _mm_errno = MMERR_NOT_A_STREAM; /* better error? */ + return -1; + } + /* Find empty slot to put sample address in */ for(handle=0;handleloopend > s->length) s->loopend = s->length; @@ -384,22 +400,26 @@ SWORD VC1_SampleLoad(struct SAMPLOAD* sload,int type) SL_SampleSigned(sload); SL_Sample8to16(sload); - if(!(Samples[handle]=(SWORD*)MikMod_malloc((length+20)<<1))) { + if(!(Samples[handle]=(SWORD*)MikMod_amalloc((length+20)<<1))) { _mm_errno = MMERR_SAMPLE_TOO_BIG; return -1; } /* read sample into buffer */ - if (SL_Load(Samples[handle],sload,length)) + if (SL_Load(Samples[handle],sload,length)) { + MikMod_afree(Samples[handle]); + Samples[handle]=NULL; return -1; + } /* Unclick sample */ if(s->flags & SF_LOOP) { + looplen = loopend - loopstart;/* handle short samples */ if(s->flags & SF_BIDI) - for(t=0;t<16;t++) + for(t=0;t<16 && tlength*((s->flags&SF_16BITS)?2:1))+16; @@ -431,7 +447,7 @@ ULONG VC1_VoiceRealVolume(UBYTE voice) SWORD *smp; SLONG t; - t = vinf[voice].current>>FRACBITS; + t = (SLONG)(vinf[voice].current>>FRACBITS); if(!vinf[voice].active) return 0; s = vinf[voice].handle; @@ -452,8 +468,8 @@ ULONG VC1_VoiceRealVolume(UBYTE voice) return abs(k-j); } -#endif +#endif /* _VIRTCH_COMMON_ */ -#endif +#endif /* _IN_VIRTCH_ */ /* ex:set ts=4: */