Mercurial > audlegacy-plugins
diff src/modplug/load_far.cxx @ 2218:6907fc39b53f
That didn't merge properly. I'll try again at some other point.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 07 Dec 2007 12:13:37 -0600 |
parents | 3673c7ec4ea2 |
children | 107c1fed3d92 |
line wrap: on
line diff
--- a/src/modplug/load_far.cxx Fri Dec 07 12:09:16 2007 -0600 +++ b/src/modplug/load_far.cxx Fri Dec 07 12:13:37 2007 -0600 @@ -64,9 +64,10 @@ UINT headerlen; BYTE samplemap[8]; - if ((!lpStream) || (dwMemLength < 1024) || (pmh1->id != FARFILEMAGIC) + if ((!lpStream) || (dwMemLength < 1024) || (bswapLE32(pmh1->id) != FARFILEMAGIC) || (pmh1->magic2[0] != 13) || (pmh1->magic2[1] != 10) || (pmh1->magic2[2] != 26)) return FALSE; - headerlen = pmh1->headerlen; + headerlen = bswapLE16(pmh1->headerlen); + pmh1->stlen = bswapLE16( pmh1->stlen ); /* inplace byteswap -- Toad */ if ((headerlen >= dwMemLength) || (dwMemPos + pmh1->stlen + sizeof(FARHEADER2) >= dwMemLength)) return FALSE; // Globals m_nType = MOD_TYPE_FAR; @@ -111,6 +112,14 @@ dwMemPos += headerlen - (869 + pmh1->stlen); if (dwMemPos >= dwMemLength) return TRUE; + // byteswap pattern data -- Toad + UINT psfix = 0 ; + while( psfix++ < 256 ) + { + pmh2->patsiz[psfix] = bswapLE16( pmh2->patsiz[psfix] ) ; + } + // end byteswap of pattern data + WORD *patsiz = (WORD *)pmh2->patsiz; for (UINT ipat=0; ipat<256; ipat++) if (patsiz[ipat]) { @@ -130,7 +139,6 @@ if (rows > 256) rows = 256; if (rows < 16) rows = 16; PatternSize[ipat] = rows; - PatternAllocSize[ipat] = rows; if ((Patterns[ipat] = AllocatePattern(rows, m_nChannels)) == NULL) return TRUE; MODCOMMAND *m = Patterns[ipat]; UINT patbrk = lpStream[dwMemPos]; @@ -233,9 +241,10 @@ dwMemPos += sizeof(FARSAMPLE); m_nSamples = ismp + 1; memcpy(m_szNames[ismp+1], pfs->samplename, 32); - pins->nLength = pfs->length; - pins->nLoopStart = pfs->reppos; - pins->nLoopEnd = pfs->repend; + pfs->length = bswapLE32( pfs->length ) ; /* endian fix - Toad */ + pins->nLength = pfs->length ; + pins->nLoopStart = bswapLE32(pfs->reppos) ; + pins->nLoopEnd = bswapLE32(pfs->repend) ; pins->nFineTune = 0; pins->nC4Speed = 8363*2; pins->nGlobalVol = 64;