load_med.cpp   load_med.cpp 
skipping to change at line 507 skipping to change at line 507
Log(" actplayline=%d\n", bswapBE16(pmmh->actplayline)); Log(" actplayline=%d\n", bswapBE16(pmmh->actplayline));
Log(" counter = %d\n", pmmh->counter); Log(" counter = %d\n", pmmh->counter);
Log(" extra_songs = %d\n", pmmh->extra_songs); Log(" extra_songs = %d\n", pmmh->extra_songs);
Log("\n"); Log("\n");
#endif #endif
m_nType = MOD_TYPE_MED; m_nType = MOD_TYPE_MED;
m_nSongPreAmp = 0x20; m_nSongPreAmp = 0x20;
dwBlockArr = bswapBE32(pmmh->blockarr); dwBlockArr = bswapBE32(pmmh->blockarr);
dwSmplArr = bswapBE32(pmmh->smplarr); dwSmplArr = bswapBE32(pmmh->smplarr);
dwExpData = bswapBE32(pmmh->expdata); dwExpData = bswapBE32(pmmh->expdata);
if ((dwExpData) && (dwExpData+sizeof(MMD0EXP) < dwMemLength)) if ((dwExpData) && (dwExpData < dwMemLength - sizeof(MMD0EXP)))
pmex = (MMD0EXP *)(lpStream+dwExpData); pmex = (MMD0EXP *)(lpStream+dwExpData);
else else
pmex = NULL; pmex = NULL;
pmsh = (MMD0SONGHEADER *)(lpStream + dwSong); pmsh = (MMD0SONGHEADER *)(lpStream + dwSong);
pmsh2 = (MMD2SONGHEADER *)pmsh; pmsh2 = (MMD2SONGHEADER *)pmsh;
#ifdef MED_LOG #ifdef MED_LOG
if (version < '2') if (version < '2')
{ {
Log("MMD0 Header:\n"); Log("MMD0 Header:\n");
Log(" numblocks = %d\n", bswapBE16(pmsh->numblocks)); Log(" numblocks = %d\n", bswapBE16(pmsh->numblocks));
skipping to change at line 645 skipping to change at line 645
if ((sectiontable) && (sectiontable < dwMemLength-2) ) if ((sectiontable) && (sectiontable < dwMemLength-2) )
{ {
nplayseq = lpStream[sectiontable+1]; nplayseq = lpStream[sectiontable+1];
sectiontable += 2; // WORDs sectiontable += 2; // WORDs
} else } else
{ {
nSections = 0; nSections = 0;
} }
UINT pseq = 0; UINT pseq = 0;
if ((playseqtable) && (playseqtable + nplayseq*4 < d wMemLength)) if ((playseqtable) && (playseqtable < dwMemLength) & & (nplayseq*4 < dwMemLength - playseqtable))
{ {
pseq = bswapBE32(((LPDWORD)(lpStream+playseq table))[nplayseq]); pseq = bswapBE32(((LPDWORD)(lpStream+playseq table))[nplayseq]);
} }
if ((pseq) && (pseq < dwMemLength - sizeof(MMD2PLAYS EQ))) if ((pseq) && (pseq < dwMemLength - sizeof(MMD2PLAYS EQ)))
{ {
MMD2PLAYSEQ *pmps = (MMD2PLAYSEQ *)(lpStream + pseq); const MMD2PLAYSEQ *pmps = (MMD2PLAYSEQ *)(lp Stream + pseq);
if (!m_szNames[0][0]) memcpy(m_szNames[0], p mps->name, 31); if (!m_szNames[0][0]) memcpy(m_szNames[0], p mps->name, 31);
UINT n = bswapBE16(pmps->length); UINT n = bswapBE16(pmps->length);
if (pseq+n <= dwMemLength) if (pseq+n <= dwMemLength)
{ {
for (UINT i=0; i<n; i++) for (UINT i=0; i<n; i++)
{ {
UINT seqval = pmps->seq[i] > > 8; UINT seqval = pmps->seq[i] > > 8;
if ((seqval < wNumBlocks) && (nOrders < MAX_ORDERS-1)) if ((seqval < wNumBlocks) && (nOrders < MAX_ORDERS-1))
{ {
Order[nOrders++] = s eqval; Order[nOrders++] = s eqval;
skipping to change at line 726 skipping to change at line 726
if (maxnamelen > 32) maxnamelen = 32; if (maxnamelen > 32) maxnamelen = 32;
for (UINT i=0; i<ientries; i++) if (i < m_nS amples) for (UINT i=0; i<ientries; i++) if (i < m_nS amples)
{ {
lstrcpyn(m_szNames[i+1], psznames + i*ientrysz, maxnamelen); lstrcpyn(m_szNames[i+1], psznames + i*ientrysz, maxnamelen);
m_szNames[i+1][31] = '\0'; m_szNames[i+1][31] = '\0';
} }
} }
} }
// Track Names // Track Names
DWORD trackinfo_ofs = bswapBE32(pmex->trackinfo_ofs); DWORD trackinfo_ofs = bswapBE32(pmex->trackinfo_ofs);
if ((trackinfo_ofs) && (trackinfo_ofs + m_nChannels * 4 < dw MemLength)) if ((trackinfo_ofs) && (trackinfo_ofs < dwMemLength) && (m_n Channels * 4 < dwMemLength - trackinfo_ofs))
{ {
DWORD *ptrktags = (DWORD *)(lpStream + trackinfo_ofs ); DWORD *ptrktags = (DWORD *)(lpStream + trackinfo_ofs );
for (UINT i=0; i<m_nChannels; i++) for (UINT i=0; i<m_nChannels; i++)
{ {
DWORD trknameofs = 0, trknamelen = 0; DWORD trknameofs = 0, trknamelen = 0;
DWORD trktagofs = bswapBE32(ptrktags[i]); DWORD trktagofs = bswapBE32(ptrktags[i]);
if (trktagofs) if (trktagofs)
{ {
while (trktagofs+8 < dwMemLength) while (trktagofs+8 < dwMemLength)
{ {
skipping to change at line 833 skipping to change at line 833
p->command = s[1] & 0x0F; p->command = s[1] & 0x0F;
p->param = s[2]; p->param = s[2];
// if (!iBlk) Log("%02X.%02X.%02X | ", s[0], s[1], s[2]); // if (!iBlk) Log("%02X.%02X.%02X | ", s[0], s[1], s[2]);
MedConvert(p, pmsh); MedConvert(p, pmsh);
p++; p++;
} }
//if (!iBlk) Log("\n"); //if (!iBlk) Log("\n");
} }
} else } else
{ {
MMD1BLOCK *pmb = (MMD1BLOCK *)(lpStream + dwPos); const MMD1BLOCK *pmb = (MMD1BLOCK *)(lpStream + dwPo s);
#ifdef MED_LOG #ifdef MED_LOG
Log("MMD1BLOCK: lines=%2d, tracks=%2d, offset=0x%0 4X\n", Log("MMD1BLOCK: lines=%2d, tracks=%2d, offset=0x%0 4X\n",
bswapBE16(pmb->lines), bswapBE16(pmb->numtra cks), bswapBE32(pmb->info)); bswapBE16(pmb->lines), bswapBE16(pmb->numtra cks), bswapBE32(pmb->info));
#endif #endif
MMD1BLOCKINFO *pbi = NULL; const MMD1BLOCKINFO *pbi = NULL;
BYTE *pcmdext = NULL; BYTE *pcmdext = NULL;
lines = (pmb->lines >> 8) + 1; lines = (pmb->lines >> 8) + 1;
tracks = pmb->numtracks >> 8; tracks = pmb->numtracks >> 8;
if (!tracks) tracks = m_nChannels; if (!tracks) tracks = m_nChannels;
if ((Patterns[iBlk] = AllocatePattern(lines, m_nChan nels)) == NULL) continue; if ((Patterns[iBlk] = AllocatePattern(lines, m_nChan nels)) == NULL) continue;
PatternSize[iBlk] = (WORD)lines; PatternSize[iBlk] = (WORD)lines;
DWORD dwBlockInfo = bswapBE32(pmb->info); DWORD dwBlockInfo = bswapBE32(pmb->info);
if ((dwBlockInfo) && (dwBlockInfo < dwMemLength - si zeof(MMD1BLOCKINFO))) if ((dwBlockInfo) && (dwBlockInfo < dwMemLength - si zeof(MMD1BLOCKINFO)))
{ {
pbi = (MMD1BLOCKINFO *)(lpStream + dwBlockIn fo); pbi = (MMD1BLOCKINFO *)(lpStream + dwBlockIn fo);
#ifdef MED_LOG #ifdef MED_LOG
Log(" BLOCKINFO: blockname=0x%04X namelen=% d pagetable=0x%04X &cmdexttable=0x%04X\n", Log(" BLOCKINFO: blockname=0x%04X namelen=% d pagetable=0x%04X &cmdexttable=0x%04X\n",
bswapBE32(pbi->blockname), bswapBE32 (pbi->blocknamelen), bswapBE32(pbi->pagetable), bswapBE32(pbi->cmdexttable) ); bswapBE32(pbi->blockname), bswapBE32 (pbi->blocknamelen), bswapBE32(pbi->pagetable), bswapBE32(pbi->cmdexttable) );
#endif #endif
if ((pbi->blockname) && (pbi->blocknamelen)) if ((pbi->blockname) && (pbi->blocknamelen))
{ {
DWORD nameofs = bswapBE32(pbi->block name); DWORD nameofs = bswapBE32(pbi->block name);
UINT namelen = bswapBE32(pbi->blockn amelen); UINT namelen = bswapBE32(pbi->blockn amelen);
if ((nameofs < dwMemLength) && (name ofs+namelen < dwMemLength)) if ((nameofs < dwMemLength) && (name len < dwMemLength + nameofs))
{ {
SetPatternName(iBlk, (LPCSTR )(lpStream+nameofs)); SetPatternName(iBlk, (LPCSTR )(lpStream+nameofs));
} }
} }
if (pbi->cmdexttable) if (pbi->cmdexttable)
{ {
DWORD cmdexttable = bswapBE32(pbi->c mdexttable); DWORD cmdexttable = bswapBE32(pbi->c mdexttable);
if (cmdexttable < dwMemLength - 4) if (cmdexttable < dwMemLength - 4)
{ {
cmdexttable = bswapBE32(*(DW ORD *)(lpStream + cmdexttable)); cmdexttable = bswapBE32(*(DW ORD *)(lpStream + cmdexttable));
skipping to change at line 888 skipping to change at line 888
if (maxlen + dwPos > dwMemLength - 8) break; if (maxlen + dwPos > dwMemLength - 8) break;
for (UINT y=0; y<lines; y++) for (UINT y=0; y<lines; y++)
{ {
for (UINT x=0; x<tracks; x++, s+=4) if (x < m_nChannels) for (UINT x=0; x<tracks; x++, s+=4) if (x < m_nChannels)
{ {
BYTE note = s[0]; BYTE note = s[0];
if ((note) && (note <= 132)) if ((note) && (note <= 132))
{ {
int rnote = note + playtrans p; int rnote = note + playtrans p;
if (rnote < 1) rnote = 1; if (rnote < 1) rnote = 1;
if (rnote > 120) rnote = 120 ; if (rnote > NOTE_MAX) rnote = NOTE_MAX;
p->note = (BYTE)rnote; p->note = (BYTE)rnote;
} }
p->instr = s[1]; p->instr = s[1];
p->command = s[2]; p->command = s[2];
p->param = s[3]; p->param = s[3];
if (pcmdext) p->vol = pcmdext[x]; if (pcmdext) p->vol = pcmdext[x];
MedConvert(p, pmsh); MedConvert(p, pmsh);
p++; p++;
} }
if (pcmdext) pcmdext += tracks; if (pcmdext) pcmdext += tracks;
 End of changes. 8 change blocks. 
8 lines changed or deleted 8 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/