author | erik <erik> | 2007-01-31 22:21:38 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-31 22:21:38 (UTC) |
commit | ed5fba8cdb27174427b2e7780508bafa05536ca1 (patch) (unidiff) | |
tree | 9dca5bd75617c8f18ba066bbd90ef88dc2473d84 | |
parent | 9395cf2a65184e493714c699bb23b02ea31feef5 (diff) | |
download | opie-ed5fba8cdb27174427b2e7780508bafa05536ca1.zip opie-ed5fba8cdb27174427b2e7780508bafa05536ca1.tar.gz opie-ed5fba8cdb27174427b2e7780508bafa05536ca1.tar.bz2 |
A few files that have dynamically allocated arrays that are not properly
de-allocated (forgot to use []).
-rw-r--r-- | core/multimedia/opieplayer/modplug/load_amf.cpp | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/modplug/load_ams.cpp | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/modplug/load_mdl.cpp | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/modplug/load_amf.cpp b/core/multimedia/opieplayer/modplug/load_amf.cpp index 188b5f5..2cf131b 100644 --- a/core/multimedia/opieplayer/modplug/load_amf.cpp +++ b/core/multimedia/opieplayer/modplug/load_amf.cpp | |||
@@ -341,80 +341,80 @@ BOOL CSoundFile::ReadAMF(LPCBYTE lpStream, DWORD dwMemLength) | |||
341 | if (pfh->version >= 11) | 341 | if (pfh->version >= 11) |
342 | { | 342 | { |
343 | pins->nLoopStart = *(DWORD *)(lpStream+dwMemPos); | 343 | pins->nLoopStart = *(DWORD *)(lpStream+dwMemPos); |
344 | pins->nLoopEnd = *(DWORD *)(lpStream+dwMemPos+4); | 344 | pins->nLoopEnd = *(DWORD *)(lpStream+dwMemPos+4); |
345 | dwMemPos += 8; | 345 | dwMemPos += 8; |
346 | } else | 346 | } else |
347 | { | 347 | { |
348 | pins->nLoopStart = *(WORD *)(lpStream+dwMemPos); | 348 | pins->nLoopStart = *(WORD *)(lpStream+dwMemPos); |
349 | pins->nLoopEnd = pins->nLength; | 349 | pins->nLoopEnd = pins->nLength; |
350 | dwMemPos += 2; | 350 | dwMemPos += 2; |
351 | } | 351 | } |
352 | sampleseekpos[iIns] = 0; | 352 | sampleseekpos[iIns] = 0; |
353 | if ((psh->type) && (psh->offset < dwMemLength-1)) | 353 | if ((psh->type) && (psh->offset < dwMemLength-1)) |
354 | { | 354 | { |
355 | sampleseekpos[iIns] = psh->offset; | 355 | sampleseekpos[iIns] = psh->offset; |
356 | if (psh->offset > maxsampleseekpos) maxsampleseekpos = psh->offset; | 356 | if (psh->offset > maxsampleseekpos) maxsampleseekpos = psh->offset; |
357 | if ((pins->nLoopEnd > pins->nLoopStart + 2) | 357 | if ((pins->nLoopEnd > pins->nLoopStart + 2) |
358 | && (pins->nLoopEnd <= pins->nLength)) pins->uFlags |= CHN_LOOP; | 358 | && (pins->nLoopEnd <= pins->nLength)) pins->uFlags |= CHN_LOOP; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | // Read Track Mapping Table | 361 | // Read Track Mapping Table |
362 | USHORT *pTrackMap = (USHORT *)(lpStream+dwMemPos); | 362 | USHORT *pTrackMap = (USHORT *)(lpStream+dwMemPos); |
363 | UINT realtrackcnt = 0; | 363 | UINT realtrackcnt = 0; |
364 | dwMemPos += pfh->numtracks * sizeof(USHORT); | 364 | dwMemPos += pfh->numtracks * sizeof(USHORT); |
365 | for (UINT iTrkMap=0; iTrkMap<pfh->numtracks; iTrkMap++) | 365 | for (UINT iTrkMap=0; iTrkMap<pfh->numtracks; iTrkMap++) |
366 | { | 366 | { |
367 | if (realtrackcnt < pTrackMap[iTrkMap]) realtrackcnt = pTrackMap[iTrkMap]; | 367 | if (realtrackcnt < pTrackMap[iTrkMap]) realtrackcnt = pTrackMap[iTrkMap]; |
368 | } | 368 | } |
369 | // Store tracks positions | 369 | // Store tracks positions |
370 | BYTE **pTrackData = new BYTE *[realtrackcnt]; | 370 | BYTE **pTrackData = new BYTE *[realtrackcnt]; |
371 | memset(pTrackData, 0, sizeof(pTrackData)); | 371 | memset(pTrackData, 0, sizeof(pTrackData)); |
372 | for (UINT iTrack=0; iTrack<realtrackcnt; iTrack++) if (dwMemPos + 3 <= dwMemLength) | 372 | for (UINT iTrack=0; iTrack<realtrackcnt; iTrack++) if (dwMemPos + 3 <= dwMemLength) |
373 | { | 373 | { |
374 | UINT nTrkSize = *(USHORT *)(lpStream+dwMemPos); | 374 | UINT nTrkSize = *(USHORT *)(lpStream+dwMemPos); |
375 | nTrkSize += (UINT)lpStream[dwMemPos+2] << 16; | 375 | nTrkSize += (UINT)lpStream[dwMemPos+2] << 16; |
376 | if (dwMemPos + nTrkSize * 3 + 3 <= dwMemLength) | 376 | if (dwMemPos + nTrkSize * 3 + 3 <= dwMemLength) |
377 | { | 377 | { |
378 | pTrackData[iTrack] = (BYTE *)(lpStream + dwMemPos); | 378 | pTrackData[iTrack] = (BYTE *)(lpStream + dwMemPos); |
379 | } | 379 | } |
380 | dwMemPos += nTrkSize * 3 + 3; | 380 | dwMemPos += nTrkSize * 3 + 3; |
381 | } | 381 | } |
382 | // Create the patterns from the list of tracks | 382 | // Create the patterns from the list of tracks |
383 | for (UINT iPat=0; iPat<pfh->numorders; iPat++) | 383 | for (UINT iPat=0; iPat<pfh->numorders; iPat++) |
384 | { | 384 | { |
385 | MODCOMMAND *p = AllocatePattern(PatternSize[iPat], m_nChannels); | 385 | MODCOMMAND *p = AllocatePattern(PatternSize[iPat], m_nChannels); |
386 | if (!p) break; | 386 | if (!p) break; |
387 | Patterns[iPat] = p; | 387 | Patterns[iPat] = p; |
388 | for (UINT iChn=0; iChn<m_nChannels; iChn++) | 388 | for (UINT iChn=0; iChn<m_nChannels; iChn++) |
389 | { | 389 | { |
390 | UINT nTrack = ptracks[iPat][iChn]; | 390 | UINT nTrack = ptracks[iPat][iChn]; |
391 | if ((nTrack) && (nTrack <= pfh->numtracks)) | 391 | if ((nTrack) && (nTrack <= pfh->numtracks)) |
392 | { | 392 | { |
393 | UINT realtrk = pTrackMap[nTrack-1]; | 393 | UINT realtrk = pTrackMap[nTrack-1]; |
394 | if (realtrk) | 394 | if (realtrk) |
395 | { | 395 | { |
396 | realtrk--; | 396 | realtrk--; |
397 | if ((realtrk < realtrackcnt) && (pTrackData[realtrk])) | 397 | if ((realtrk < realtrackcnt) && (pTrackData[realtrk])) |
398 | { | 398 | { |
399 | AMF_Unpack(p+iChn, pTrackData[realtrk], PatternSize[iPat], m_nChannels); | 399 | AMF_Unpack(p+iChn, pTrackData[realtrk], PatternSize[iPat], m_nChannels); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | } | 402 | } |
403 | } | 403 | } |
404 | } | 404 | } |
405 | delete pTrackData; | 405 | delete [] pTrackData; |
406 | // Read Sample Data | 406 | // Read Sample Data |
407 | for (UINT iSeek=1; iSeek<=maxsampleseekpos; iSeek++) | 407 | for (UINT iSeek=1; iSeek<=maxsampleseekpos; iSeek++) |
408 | { | 408 | { |
409 | if (dwMemPos >= dwMemLength) break; | 409 | if (dwMemPos >= dwMemLength) break; |
410 | for (UINT iSmp=0; iSmp<m_nSamples; iSmp++) if (iSeek == sampleseekpos[iSmp]) | 410 | for (UINT iSmp=0; iSmp<m_nSamples; iSmp++) if (iSeek == sampleseekpos[iSmp]) |
411 | { | 411 | { |
412 | MODINSTRUMENT *pins = &Ins[iSmp+1]; | 412 | MODINSTRUMENT *pins = &Ins[iSmp+1]; |
413 | dwMemPos += ReadSample(pins, RS_PCM8U, (LPCSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos); | 413 | dwMemPos += ReadSample(pins, RS_PCM8U, (LPCSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos); |
414 | break; | 414 | break; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | return TRUE; | 417 | return TRUE; |
418 | } | 418 | } |
419 | 419 | ||
420 | 420 | ||
diff --git a/core/multimedia/opieplayer/modplug/load_ams.cpp b/core/multimedia/opieplayer/modplug/load_ams.cpp index 3dd1c2b..ad1cc01 100644 --- a/core/multimedia/opieplayer/modplug/load_ams.cpp +++ b/core/multimedia/opieplayer/modplug/load_ams.cpp | |||
@@ -565,67 +565,67 @@ BOOL CSoundFile::ReadAMS2(LPCBYTE lpStream, DWORD dwMemLength) | |||
565 | 565 | ||
566 | void AMSUnpack(const char *psrc, UINT inputlen, char *pdest, UINT dmax, char packcharacter) | 566 | void AMSUnpack(const char *psrc, UINT inputlen, char *pdest, UINT dmax, char packcharacter) |
567 | { | 567 | { |
568 | UINT tmplen = dmax; | 568 | UINT tmplen = dmax; |
569 | signed char *amstmp = new signed char[tmplen]; | 569 | signed char *amstmp = new signed char[tmplen]; |
570 | 570 | ||
571 | if (!amstmp) return; | 571 | if (!amstmp) return; |
572 | // Unpack Loop | 572 | // Unpack Loop |
573 | { | 573 | { |
574 | signed char *p = amstmp; | 574 | signed char *p = amstmp; |
575 | UINT i=0, j=0; | 575 | UINT i=0, j=0; |
576 | while ((i < inputlen) && (j < tmplen)) | 576 | while ((i < inputlen) && (j < tmplen)) |
577 | { | 577 | { |
578 | signed char ch = psrc[i++]; | 578 | signed char ch = psrc[i++]; |
579 | if (ch == packcharacter) | 579 | if (ch == packcharacter) |
580 | { | 580 | { |
581 | BYTE ch2 = psrc[i++]; | 581 | BYTE ch2 = psrc[i++]; |
582 | if (ch2) | 582 | if (ch2) |
583 | { | 583 | { |
584 | ch = psrc[i++]; | 584 | ch = psrc[i++]; |
585 | while (ch2--) | 585 | while (ch2--) |
586 | { | 586 | { |
587 | p[j++] = ch; | 587 | p[j++] = ch; |
588 | if (j >= tmplen) break; | 588 | if (j >= tmplen) break; |
589 | } | 589 | } |
590 | } else p[j++] = packcharacter; | 590 | } else p[j++] = packcharacter; |
591 | } else p[j++] = ch; | 591 | } else p[j++] = ch; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | // Bit Unpack Loop | 594 | // Bit Unpack Loop |
595 | { | 595 | { |
596 | signed char *p = amstmp; | 596 | signed char *p = amstmp; |
597 | UINT bitcount = 0x80, dh; | 597 | UINT bitcount = 0x80, dh; |
598 | UINT k=0; | 598 | UINT k=0; |
599 | for (UINT i=0; i<dmax; i++) | 599 | for (UINT i=0; i<dmax; i++) |
600 | { | 600 | { |
601 | BYTE al = *p++; | 601 | BYTE al = *p++; |
602 | dh = 0; | 602 | dh = 0; |
603 | for (UINT count=0; count<8; count++) | 603 | for (UINT count=0; count<8; count++) |
604 | { | 604 | { |
605 | UINT bl = al & bitcount; | 605 | UINT bl = al & bitcount; |
606 | bl = ((bl|(bl<<8)) >> ((dh+8-count) & 7)) & 0xFF; | 606 | bl = ((bl|(bl<<8)) >> ((dh+8-count) & 7)) & 0xFF; |
607 | bitcount = ((bitcount|(bitcount<<8)) >> 1) & 0xFF; | 607 | bitcount = ((bitcount|(bitcount<<8)) >> 1) & 0xFF; |
608 | pdest[k++] |= bl; | 608 | pdest[k++] |= bl; |
609 | if (k >= dmax) | 609 | if (k >= dmax) |
610 | { | 610 | { |
611 | k = 0; | 611 | k = 0; |
612 | dh++; | 612 | dh++; |
613 | } | 613 | } |
614 | } | 614 | } |
615 | bitcount = ((bitcount|(bitcount<<8)) >> dh) & 0xFF; | 615 | bitcount = ((bitcount|(bitcount<<8)) >> dh) & 0xFF; |
616 | } | 616 | } |
617 | } | 617 | } |
618 | // Delta Unpack | 618 | // Delta Unpack |
619 | { | 619 | { |
620 | signed char old = 0; | 620 | signed char old = 0; |
621 | for (UINT i=0; i<dmax; i++) | 621 | for (UINT i=0; i<dmax; i++) |
622 | { | 622 | { |
623 | int pos = ((LPBYTE)pdest)[i]; | 623 | int pos = ((LPBYTE)pdest)[i]; |
624 | if ((pos != 128) && (pos & 0x80)) pos = -(pos & 0x7F); | 624 | if ((pos != 128) && (pos & 0x80)) pos = -(pos & 0x7F); |
625 | old -= (signed char)pos; | 625 | old -= (signed char)pos; |
626 | pdest[i] = old; | 626 | pdest[i] = old; |
627 | } | 627 | } |
628 | } | 628 | } |
629 | delete amstmp; | 629 | delete [] amstmp; |
630 | } | 630 | } |
631 | 631 | ||
diff --git a/core/multimedia/opieplayer/modplug/load_mdl.cpp b/core/multimedia/opieplayer/modplug/load_mdl.cpp index 806b68b..e1f78d5 100644 --- a/core/multimedia/opieplayer/modplug/load_mdl.cpp +++ b/core/multimedia/opieplayer/modplug/load_mdl.cpp | |||
@@ -184,129 +184,129 @@ BOOL CSoundFile::ReadMDL(const BYTE *lpStream, DWORD dwMemLength) | |||
184 | { | 184 | { |
185 | DWORD dwMemPos, dwPos, blocklen, dwTrackPos; | 185 | DWORD dwMemPos, dwPos, blocklen, dwTrackPos; |
186 | const MDLSONGHEADER *pmsh = (const MDLSONGHEADER *)lpStream; | 186 | const MDLSONGHEADER *pmsh = (const MDLSONGHEADER *)lpStream; |
187 | MDLINFOBLOCK *pmib; | 187 | MDLINFOBLOCK *pmib; |
188 | MDLPATTERNDATA *pmpd; | 188 | MDLPATTERNDATA *pmpd; |
189 | UINT i,j, norders = 0, npatterns = 0, ntracks = 0; | 189 | UINT i,j, norders = 0, npatterns = 0, ntracks = 0; |
190 | UINT ninstruments = 0, nsamples = 0; | 190 | UINT ninstruments = 0, nsamples = 0; |
191 | WORD block; | 191 | WORD block; |
192 | WORD patterntracks[MAX_PATTERNS*32]; | 192 | WORD patterntracks[MAX_PATTERNS*32]; |
193 | BYTE smpinfo[MAX_SAMPLES]; | 193 | BYTE smpinfo[MAX_SAMPLES]; |
194 | BYTE insvolenv[MAX_INSTRUMENTS]; | 194 | BYTE insvolenv[MAX_INSTRUMENTS]; |
195 | BYTE inspanenv[MAX_INSTRUMENTS]; | 195 | BYTE inspanenv[MAX_INSTRUMENTS]; |
196 | LPCBYTE pvolenv, ppanenv, ppitchenv; | 196 | LPCBYTE pvolenv, ppanenv, ppitchenv; |
197 | UINT nvolenv, npanenv, npitchenv; | 197 | UINT nvolenv, npanenv, npitchenv; |
198 | 198 | ||
199 | if ((!lpStream) || (dwMemLength < 1024)) return FALSE; | 199 | if ((!lpStream) || (dwMemLength < 1024)) return FALSE; |
200 | if ((pmsh->id != 0x4C444D44) || ((pmsh->version & 0xF0) > 0x10)) return FALSE; | 200 | if ((pmsh->id != 0x4C444D44) || ((pmsh->version & 0xF0) > 0x10)) return FALSE; |
201 | memset(patterntracks, 0, sizeof(patterntracks)); | 201 | memset(patterntracks, 0, sizeof(patterntracks)); |
202 | memset(smpinfo, 0, sizeof(smpinfo)); | 202 | memset(smpinfo, 0, sizeof(smpinfo)); |
203 | memset(insvolenv, 0, sizeof(insvolenv)); | 203 | memset(insvolenv, 0, sizeof(insvolenv)); |
204 | memset(inspanenv, 0, sizeof(inspanenv)); | 204 | memset(inspanenv, 0, sizeof(inspanenv)); |
205 | dwMemPos = 5; | 205 | dwMemPos = 5; |
206 | dwTrackPos = 0; | 206 | dwTrackPos = 0; |
207 | pvolenv = ppanenv = ppitchenv = NULL; | 207 | pvolenv = ppanenv = ppitchenv = NULL; |
208 | nvolenv = npanenv = npitchenv = 0; | 208 | nvolenv = npanenv = npitchenv = 0; |
209 | m_nSamples = m_nInstruments = 0; | 209 | m_nSamples = m_nInstruments = 0; |
210 | while (dwMemPos+6 < dwMemLength) | 210 | while (dwMemPos+6 < dwMemLength) |
211 | { | 211 | { |
212 | block = *((WORD *)(lpStream+dwMemPos)); | 212 | block = *((WORD *)(lpStream+dwMemPos)); |
213 | blocklen = *((DWORD *)(lpStream+dwMemPos+2)); | 213 | blocklen = *((DWORD *)(lpStream+dwMemPos+2)); |
214 | dwMemPos += 6; | 214 | dwMemPos += 6; |
215 | if (dwMemPos + blocklen > dwMemLength) | 215 | if (dwMemPos + blocklen > dwMemLength) |
216 | { | 216 | { |
217 | if (dwMemPos == 11) return FALSE; | 217 | if (dwMemPos == 11) return FALSE; |
218 | break; | 218 | break; |
219 | } | 219 | } |
220 | switch(block) | 220 | switch(block) |
221 | { | 221 | { |
222 | // IN: infoblock | 222 | // IN: infoblock |
223 | case 0x4E49: | 223 | case 0x4E49: |
224 | pmib = (MDLINFOBLOCK *)(lpStream+dwMemPos); | 224 | pmib = (MDLINFOBLOCK *)(lpStream+dwMemPos); |
225 | memcpy(m_szNames[0], pmib->songname, 32); | 225 | memcpy(m_szNames[0], pmib->songname, 32); |
226 | norders = pmib->norders; | 226 | norders = pmib->norders; |
227 | if (norders > MAX_ORDERS) norders = MAX_ORDERS; | 227 | if (norders > MAX_ORDERS) norders = MAX_ORDERS; |
228 | m_nRestartPos = pmib->repeatpos; | 228 | m_nRestartPos = pmib->repeatpos; |
229 | m_nDefaultGlobalVolume = pmib->globalvol; | 229 | m_nDefaultGlobalVolume = pmib->globalvol; |
230 | m_nDefaultTempo = pmib->tempo; | 230 | m_nDefaultTempo = pmib->tempo; |
231 | m_nDefaultSpeed = pmib->speed; | 231 | m_nDefaultSpeed = pmib->speed; |
232 | m_nChannels = 4; | 232 | m_nChannels = 4; |
233 | for (i=0; i<32; i++) | 233 | for (i=0; i<32; i++) |
234 | { | 234 | { |
235 | ChnSettings[i].nVolume = 64; | 235 | ChnSettings[i].nVolume = 64; |
236 | ChnSettings[i].nPan = (pmib->channelinfo[i] & 0x7F) << 1; | 236 | ChnSettings[i].nPan = (pmib->channelinfo[i] & 0x7F) << 1; |
237 | if (pmib->channelinfo[i] & 0x80) | 237 | if (pmib->channelinfo[i] & 0x80) |
238 | ChnSettings[i].dwFlags |= CHN_MUTE; | 238 | ChnSettings[i].dwFlags |= CHN_MUTE; |
239 | else | 239 | else |
240 | m_nChannels = i+1; | 240 | m_nChannels = i+1; |
241 | } | 241 | } |
242 | for (j=0; j<norders; j++) Order[j] = pmib->seq[j]; | 242 | for (j=0; j<norders; j++) Order[j] = pmib->seq[j]; |
243 | break; | 243 | break; |
244 | // ME: song message | 244 | // ME: song message |
245 | case 0x454D: | 245 | case 0x454D: |
246 | if (blocklen) | 246 | if (blocklen) |
247 | { | 247 | { |
248 | if (m_lpszSongComments) delete m_lpszSongComments; | 248 | if (m_lpszSongComments) delete [] m_lpszSongComments; |
249 | m_lpszSongComments = new char[blocklen]; | 249 | m_lpszSongComments = new char[blocklen]; |
250 | if (m_lpszSongComments) | 250 | if (m_lpszSongComments) |
251 | { | 251 | { |
252 | memcpy(m_lpszSongComments, lpStream+dwMemPos, blocklen); | 252 | memcpy(m_lpszSongComments, lpStream+dwMemPos, blocklen); |
253 | m_lpszSongComments[blocklen-1] = 0; | 253 | m_lpszSongComments[blocklen-1] = 0; |
254 | } | 254 | } |
255 | } | 255 | } |
256 | break; | 256 | break; |
257 | // PA: Pattern Data | 257 | // PA: Pattern Data |
258 | case 0x4150: | 258 | case 0x4150: |
259 | npatterns = lpStream[dwMemPos]; | 259 | npatterns = lpStream[dwMemPos]; |
260 | if (npatterns > MAX_PATTERNS) npatterns = MAX_PATTERNS; | 260 | if (npatterns > MAX_PATTERNS) npatterns = MAX_PATTERNS; |
261 | dwPos = dwMemPos + 1; | 261 | dwPos = dwMemPos + 1; |
262 | for (i=0; i<npatterns; i++) | 262 | for (i=0; i<npatterns; i++) |
263 | { | 263 | { |
264 | if (dwPos+18 >= dwMemLength) break; | 264 | if (dwPos+18 >= dwMemLength) break; |
265 | pmpd = (MDLPATTERNDATA *)(lpStream + dwPos); | 265 | pmpd = (MDLPATTERNDATA *)(lpStream + dwPos); |
266 | if (pmpd->channels > 32) break; | 266 | if (pmpd->channels > 32) break; |
267 | PatternSize[i] = pmpd->lastrow+1; | 267 | PatternSize[i] = pmpd->lastrow+1; |
268 | if (m_nChannels < pmpd->channels) m_nChannels = pmpd->channels; | 268 | if (m_nChannels < pmpd->channels) m_nChannels = pmpd->channels; |
269 | dwPos += 18 + 2*pmpd->channels; | 269 | dwPos += 18 + 2*pmpd->channels; |
270 | for (j=0; j<pmpd->channels; j++) | 270 | for (j=0; j<pmpd->channels; j++) |
271 | { | 271 | { |
272 | patterntracks[i*32+j] = pmpd->data[j]; | 272 | patterntracks[i*32+j] = pmpd->data[j]; |
273 | } | 273 | } |
274 | } | 274 | } |
275 | break; | 275 | break; |
276 | // TR: Track Data | 276 | // TR: Track Data |
277 | case 0x5254: | 277 | case 0x5254: |
278 | if (dwTrackPos) break; | 278 | if (dwTrackPos) break; |
279 | ntracks = *((WORD *)(lpStream+dwMemPos)); | 279 | ntracks = *((WORD *)(lpStream+dwMemPos)); |
280 | dwTrackPos = dwMemPos+2; | 280 | dwTrackPos = dwMemPos+2; |
281 | break; | 281 | break; |
282 | // II: Instruments | 282 | // II: Instruments |
283 | case 0x4949: | 283 | case 0x4949: |
284 | ninstruments = lpStream[dwMemPos]; | 284 | ninstruments = lpStream[dwMemPos]; |
285 | dwPos = dwMemPos+1; | 285 | dwPos = dwMemPos+1; |
286 | for (i=0; i<ninstruments; i++) | 286 | for (i=0; i<ninstruments; i++) |
287 | { | 287 | { |
288 | UINT nins = lpStream[dwPos]; | 288 | UINT nins = lpStream[dwPos]; |
289 | if ((nins >= MAX_INSTRUMENTS) || (!nins)) break; | 289 | if ((nins >= MAX_INSTRUMENTS) || (!nins)) break; |
290 | if (m_nInstruments < nins) m_nInstruments = nins; | 290 | if (m_nInstruments < nins) m_nInstruments = nins; |
291 | if (!Headers[nins]) | 291 | if (!Headers[nins]) |
292 | { | 292 | { |
293 | UINT note = 12; | 293 | UINT note = 12; |
294 | if ((Headers[nins] = new INSTRUMENTHEADER) == NULL) break; | 294 | if ((Headers[nins] = new INSTRUMENTHEADER) == NULL) break; |
295 | INSTRUMENTHEADER *penv = Headers[nins]; | 295 | INSTRUMENTHEADER *penv = Headers[nins]; |
296 | memset(penv, 0, sizeof(INSTRUMENTHEADER)); | 296 | memset(penv, 0, sizeof(INSTRUMENTHEADER)); |
297 | memcpy(penv->name, lpStream+dwPos+2, 32); | 297 | memcpy(penv->name, lpStream+dwPos+2, 32); |
298 | penv->nGlobalVol = 64; | 298 | penv->nGlobalVol = 64; |
299 | penv->nPPC = 5*12; | 299 | penv->nPPC = 5*12; |
300 | for (j=0; j<lpStream[dwPos+1]; j++) | 300 | for (j=0; j<lpStream[dwPos+1]; j++) |
301 | { | 301 | { |
302 | const BYTE *ps = lpStream+dwPos+34+14*j; | 302 | const BYTE *ps = lpStream+dwPos+34+14*j; |
303 | while ((note < (UINT)(ps[1]+12)) && (note < 120)) | 303 | while ((note < (UINT)(ps[1]+12)) && (note < 120)) |
304 | { | 304 | { |
305 | penv->NoteMap[note] = note+1; | 305 | penv->NoteMap[note] = note+1; |
306 | if (ps[0] < MAX_SAMPLES) | 306 | if (ps[0] < MAX_SAMPLES) |
307 | { | 307 | { |
308 | int ismp = ps[0]; | 308 | int ismp = ps[0]; |
309 | penv->Keyboard[note] = ps[0]; | 309 | penv->Keyboard[note] = ps[0]; |
310 | Ins[ismp].nVolume = ps[2]; | 310 | Ins[ismp].nVolume = ps[2]; |
311 | Ins[ismp].nPan = ps[4] << 1; | 311 | Ins[ismp].nPan = ps[4] << 1; |
312 | Ins[ismp].nVibType = ps[11]; | 312 | Ins[ismp].nVibType = ps[11]; |