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 | |||
@@ -277,144 +277,144 @@ BOOL CSoundFile::ReadAMF(LPCBYTE lpStream, DWORD dwMemLength) | |||
277 | m_nSamples = pfh->numsamples; | 277 | m_nSamples = pfh->numsamples; |
278 | m_nInstruments = 0; | 278 | m_nInstruments = 0; |
279 | // Setup Channel Pan Positions | 279 | // Setup Channel Pan Positions |
280 | if (pfh->version >= 11) | 280 | if (pfh->version >= 11) |
281 | { | 281 | { |
282 | signed char *panpos = (signed char *)(lpStream + dwMemPos); | 282 | signed char *panpos = (signed char *)(lpStream + dwMemPos); |
283 | UINT nchannels = (pfh->version >= 13) ? 32 : 16; | 283 | UINT nchannels = (pfh->version >= 13) ? 32 : 16; |
284 | for (UINT i=0; i<nchannels; i++) | 284 | for (UINT i=0; i<nchannels; i++) |
285 | { | 285 | { |
286 | int pan = (panpos[i] + 64) * 2; | 286 | int pan = (panpos[i] + 64) * 2; |
287 | if (pan < 0) pan = 0; | 287 | if (pan < 0) pan = 0; |
288 | if (pan > 256) { pan = 128; ChnSettings[i].dwFlags |= CHN_SURROUND; } | 288 | if (pan > 256) { pan = 128; ChnSettings[i].dwFlags |= CHN_SURROUND; } |
289 | ChnSettings[i].nPan = pan; | 289 | ChnSettings[i].nPan = pan; |
290 | } | 290 | } |
291 | dwMemPos += nchannels; | 291 | dwMemPos += nchannels; |
292 | } else | 292 | } else |
293 | { | 293 | { |
294 | for (UINT i=0; i<16; i++) | 294 | for (UINT i=0; i<16; i++) |
295 | { | 295 | { |
296 | ChnSettings[i].nPan = (lpStream[dwMemPos+i] & 1) ? 0x30 : 0xD0; | 296 | ChnSettings[i].nPan = (lpStream[dwMemPos+i] & 1) ? 0x30 : 0xD0; |
297 | } | 297 | } |
298 | dwMemPos += 16; | 298 | dwMemPos += 16; |
299 | } | 299 | } |
300 | // Get Tempo/Speed | 300 | // Get Tempo/Speed |
301 | m_nDefaultTempo = 125; | 301 | m_nDefaultTempo = 125; |
302 | m_nDefaultSpeed = 6; | 302 | m_nDefaultSpeed = 6; |
303 | if (pfh->version >= 13) | 303 | if (pfh->version >= 13) |
304 | { | 304 | { |
305 | if (lpStream[dwMemPos] >= 32) m_nDefaultTempo = lpStream[dwMemPos]; | 305 | if (lpStream[dwMemPos] >= 32) m_nDefaultTempo = lpStream[dwMemPos]; |
306 | if (lpStream[dwMemPos+1] <= 32) m_nDefaultSpeed = lpStream[dwMemPos+1]; | 306 | if (lpStream[dwMemPos+1] <= 32) m_nDefaultSpeed = lpStream[dwMemPos+1]; |
307 | dwMemPos += 2; | 307 | dwMemPos += 2; |
308 | } | 308 | } |
309 | // Setup sequence list | 309 | // Setup sequence list |
310 | for (UINT iOrd=0; iOrd<MAX_ORDERS; iOrd++) | 310 | for (UINT iOrd=0; iOrd<MAX_ORDERS; iOrd++) |
311 | { | 311 | { |
312 | Order[iOrd] = 0xFF; | 312 | Order[iOrd] = 0xFF; |
313 | if (iOrd < pfh->numorders) | 313 | if (iOrd < pfh->numorders) |
314 | { | 314 | { |
315 | Order[iOrd] = iOrd; | 315 | Order[iOrd] = iOrd; |
316 | PatternSize[iOrd] = 64; | 316 | PatternSize[iOrd] = 64; |
317 | if (pfh->version >= 14) | 317 | if (pfh->version >= 14) |
318 | { | 318 | { |
319 | PatternSize[iOrd] = *(USHORT *)(lpStream+dwMemPos); | 319 | PatternSize[iOrd] = *(USHORT *)(lpStream+dwMemPos); |
320 | dwMemPos += 2; | 320 | dwMemPos += 2; |
321 | } | 321 | } |
322 | ptracks[iOrd] = (USHORT *)(lpStream+dwMemPos); | 322 | ptracks[iOrd] = (USHORT *)(lpStream+dwMemPos); |
323 | dwMemPos += m_nChannels * sizeof(USHORT); | 323 | dwMemPos += m_nChannels * sizeof(USHORT); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | if (dwMemPos + m_nSamples * (sizeof(AMFSAMPLE)+8) > dwMemLength) return TRUE; | 326 | if (dwMemPos + m_nSamples * (sizeof(AMFSAMPLE)+8) > dwMemLength) return TRUE; |
327 | // Read Samples | 327 | // Read Samples |
328 | UINT maxsampleseekpos = 0; | 328 | UINT maxsampleseekpos = 0; |
329 | for (UINT iIns=0; iIns<m_nSamples; iIns++) | 329 | for (UINT iIns=0; iIns<m_nSamples; iIns++) |
330 | { | 330 | { |
331 | MODINSTRUMENT *pins = &Ins[iIns+1]; | 331 | MODINSTRUMENT *pins = &Ins[iIns+1]; |
332 | AMFSAMPLE *psh = (AMFSAMPLE *)(lpStream + dwMemPos); | 332 | AMFSAMPLE *psh = (AMFSAMPLE *)(lpStream + dwMemPos); |
333 | 333 | ||
334 | dwMemPos += sizeof(AMFSAMPLE); | 334 | dwMemPos += sizeof(AMFSAMPLE); |
335 | memcpy(m_szNames[iIns+1], psh->samplename, 32); | 335 | memcpy(m_szNames[iIns+1], psh->samplename, 32); |
336 | memcpy(pins->name, psh->filename, 13); | 336 | memcpy(pins->name, psh->filename, 13); |
337 | pins->nLength = psh->length; | 337 | pins->nLength = psh->length; |
338 | pins->nC4Speed = psh->c2spd; | 338 | pins->nC4Speed = psh->c2spd; |
339 | pins->nGlobalVol = 64; | 339 | pins->nGlobalVol = 64; |
340 | pins->nVolume = psh->volume * 4; | 340 | pins->nVolume = psh->volume * 4; |
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 | |||
@@ -501,131 +501,131 @@ BOOL CSoundFile::ReadAMS2(LPCBYTE lpStream, DWORD dwMemLength) | |||
501 | MODCOMMAND *m = Patterns[ipat] + row * m_nChannels; | 501 | MODCOMMAND *m = Patterns[ipat] + row * m_nChannels; |
502 | UINT byte1 = psrc[pos++]; | 502 | UINT byte1 = psrc[pos++]; |
503 | UINT ch = byte1 & 0x1F; | 503 | UINT ch = byte1 & 0x1F; |
504 | // Read Note + Instr | 504 | // Read Note + Instr |
505 | if (!(byte1 & 0x40)) | 505 | if (!(byte1 & 0x40)) |
506 | { | 506 | { |
507 | UINT byte2 = psrc[pos++]; | 507 | UINT byte2 = psrc[pos++]; |
508 | UINT note = byte2 & 0x7F; | 508 | UINT note = byte2 & 0x7F; |
509 | if (note) m[ch].note = (note > 1) ? (note-1) : 0xFF; | 509 | if (note) m[ch].note = (note > 1) ? (note-1) : 0xFF; |
510 | m[ch].instr = psrc[pos++]; | 510 | m[ch].instr = psrc[pos++]; |
511 | // Read Effect | 511 | // Read Effect |
512 | while (byte2 & 0x80) | 512 | while (byte2 & 0x80) |
513 | { | 513 | { |
514 | byte2 = psrc[pos++]; | 514 | byte2 = psrc[pos++]; |
515 | if (byte2 & 0x40) | 515 | if (byte2 & 0x40) |
516 | { | 516 | { |
517 | m[ch].volcmd = VOLCMD_VOLUME; | 517 | m[ch].volcmd = VOLCMD_VOLUME; |
518 | m[ch].vol = byte2 & 0x3F; | 518 | m[ch].vol = byte2 & 0x3F; |
519 | } else | 519 | } else |
520 | { | 520 | { |
521 | UINT command = byte2 & 0x3F; | 521 | UINT command = byte2 & 0x3F; |
522 | UINT param = psrc[pos++]; | 522 | UINT param = psrc[pos++]; |
523 | if (command == 0x0C) | 523 | if (command == 0x0C) |
524 | { | 524 | { |
525 | m[ch].volcmd = VOLCMD_VOLUME; | 525 | m[ch].volcmd = VOLCMD_VOLUME; |
526 | m[ch].vol = param / 2; | 526 | m[ch].vol = param / 2; |
527 | } else | 527 | } else |
528 | if (command < 0x10) | 528 | if (command < 0x10) |
529 | { | 529 | { |
530 | m[ch].command = command; | 530 | m[ch].command = command; |
531 | m[ch].param = param; | 531 | m[ch].param = param; |
532 | ConvertModCommand(&m[ch]); | 532 | ConvertModCommand(&m[ch]); |
533 | } else | 533 | } else |
534 | { | 534 | { |
535 | // TODO: AMS effects | 535 | // TODO: AMS effects |
536 | } | 536 | } |
537 | } | 537 | } |
538 | } | 538 | } |
539 | } | 539 | } |
540 | if (byte1 & 0x80) row++; | 540 | if (byte1 & 0x80) row++; |
541 | } | 541 | } |
542 | } | 542 | } |
543 | dwMemPos += packedlen; | 543 | dwMemPos += packedlen; |
544 | } | 544 | } |
545 | // Read Samples | 545 | // Read Samples |
546 | for (UINT iSmp=1; iSmp<=m_nSamples; iSmp++) if (Ins[iSmp].nLength) | 546 | for (UINT iSmp=1; iSmp<=m_nSamples; iSmp++) if (Ins[iSmp].nLength) |
547 | { | 547 | { |
548 | if (dwMemPos >= dwMemLength - 9) return TRUE; | 548 | if (dwMemPos >= dwMemLength - 9) return TRUE; |
549 | UINT flags; | 549 | UINT flags; |
550 | if (packedsamples[iSmp] & 0x03) | 550 | if (packedsamples[iSmp] & 0x03) |
551 | { | 551 | { |
552 | flags = (Ins[iSmp].uFlags & CHN_16BIT) ? RS_AMS16 : RS_AMS8; | 552 | flags = (Ins[iSmp].uFlags & CHN_16BIT) ? RS_AMS16 : RS_AMS8; |
553 | } else | 553 | } else |
554 | { | 554 | { |
555 | flags = (Ins[iSmp].uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8S; | 555 | flags = (Ins[iSmp].uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8S; |
556 | } | 556 | } |
557 | dwMemPos += ReadSample(&Ins[iSmp], flags, (LPSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos); | 557 | dwMemPos += ReadSample(&Ins[iSmp], flags, (LPSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos); |
558 | } | 558 | } |
559 | return TRUE; | 559 | return TRUE; |
560 | } | 560 | } |
561 | 561 | ||
562 | 562 | ||
563 | ///////////////////////////////////////////////////////////////////// | 563 | ///////////////////////////////////////////////////////////////////// |
564 | // AMS Sample unpacking | 564 | // AMS Sample unpacking |
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 | |||
@@ -120,257 +120,257 @@ void UnpackMDLTrack(MODCOMMAND *pat, UINT nChannels, UINT nRows, UINT nTrack, co | |||
120 | case 0x01: | 120 | case 0x01: |
121 | for (i=0; i<=xx; i++) | 121 | for (i=0; i<=xx; i++) |
122 | { | 122 | { |
123 | if (row) *m = *(m-nChannels); | 123 | if (row) *m = *(m-nChannels); |
124 | m += nChannels; | 124 | m += nChannels; |
125 | row++; | 125 | row++; |
126 | if (row >= nRows) break; | 126 | if (row >= nRows) break; |
127 | } | 127 | } |
128 | break; | 128 | break; |
129 | 129 | ||
130 | case 0x02: | 130 | case 0x02: |
131 | if (xx < row) *m = pat[nChannels*xx]; | 131 | if (xx < row) *m = pat[nChannels*xx]; |
132 | m += nChannels; | 132 | m += nChannels; |
133 | row++; | 133 | row++; |
134 | break; | 134 | break; |
135 | 135 | ||
136 | case 0x03: | 136 | case 0x03: |
137 | { | 137 | { |
138 | cmd.note = (xx & 0x01) ? lpTracks[pos++] : 0; | 138 | cmd.note = (xx & 0x01) ? lpTracks[pos++] : 0; |
139 | cmd.instr = (xx & 0x02) ? lpTracks[pos++] : 0; | 139 | cmd.instr = (xx & 0x02) ? lpTracks[pos++] : 0; |
140 | cmd.volcmd = cmd.vol = 0; | 140 | cmd.volcmd = cmd.vol = 0; |
141 | cmd.command = cmd.param = 0; | 141 | cmd.command = cmd.param = 0; |
142 | if ((cmd.note < 120-12) && (cmd.note)) cmd.note += 12; | 142 | if ((cmd.note < 120-12) && (cmd.note)) cmd.note += 12; |
143 | UINT volume = (xx & 0x04) ? lpTracks[pos++] : 0; | 143 | UINT volume = (xx & 0x04) ? lpTracks[pos++] : 0; |
144 | UINT commands = (xx & 0x08) ? lpTracks[pos++] : 0; | 144 | UINT commands = (xx & 0x08) ? lpTracks[pos++] : 0; |
145 | UINT command1 = commands & 0x0F; | 145 | UINT command1 = commands & 0x0F; |
146 | UINT command2 = commands & 0xF0; | 146 | UINT command2 = commands & 0xF0; |
147 | UINT param1 = (xx & 0x10) ? lpTracks[pos++] : 0; | 147 | UINT param1 = (xx & 0x10) ? lpTracks[pos++] : 0; |
148 | UINT param2 = (xx & 0x20) ? lpTracks[pos++] : 0; | 148 | UINT param2 = (xx & 0x20) ? lpTracks[pos++] : 0; |
149 | if ((command1 == 0x0E) && ((param1 & 0xF0) == 0xF0) && (!command2)) | 149 | if ((command1 == 0x0E) && ((param1 & 0xF0) == 0xF0) && (!command2)) |
150 | { | 150 | { |
151 | param1 = ((param1 & 0x0F) << 8) | param2; | 151 | param1 = ((param1 & 0x0F) << 8) | param2; |
152 | command1 = 0xEF; | 152 | command1 = 0xEF; |
153 | command2 = param2 = 0; | 153 | command2 = param2 = 0; |
154 | } | 154 | } |
155 | if (volume) | 155 | if (volume) |
156 | { | 156 | { |
157 | cmd.volcmd = VOLCMD_VOLUME; | 157 | cmd.volcmd = VOLCMD_VOLUME; |
158 | cmd.vol = (volume+1) >> 2; | 158 | cmd.vol = (volume+1) >> 2; |
159 | } | 159 | } |
160 | ConvertMDLCommand(&cmd, command1, param1); | 160 | ConvertMDLCommand(&cmd, command1, param1); |
161 | if ((cmd.command != CMD_SPEED) | 161 | if ((cmd.command != CMD_SPEED) |
162 | && (cmd.command != CMD_TEMPO) | 162 | && (cmd.command != CMD_TEMPO) |
163 | && (cmd.command != CMD_PATTERNBREAK)) | 163 | && (cmd.command != CMD_PATTERNBREAK)) |
164 | ConvertMDLCommand(&cmd, command2, param2); | 164 | ConvertMDLCommand(&cmd, command2, param2); |
165 | *m = cmd; | 165 | *m = cmd; |
166 | m += nChannels; | 166 | m += nChannels; |
167 | row++; | 167 | row++; |
168 | } | 168 | } |
169 | break; | 169 | break; |
170 | 170 | ||
171 | // Empty Slots | 171 | // Empty Slots |
172 | default: | 172 | default: |
173 | row += xx+1; | 173 | row += xx+1; |
174 | m += (xx+1)*nChannels; | 174 | m += (xx+1)*nChannels; |
175 | if (row >= nRows) break; | 175 | if (row >= nRows) break; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | 181 | ||
182 | BOOL CSoundFile::ReadMDL(const BYTE *lpStream, DWORD dwMemLength) | 182 | BOOL CSoundFile::ReadMDL(const BYTE *lpStream, DWORD dwMemLength) |
183 | //--------------------------------------------------------------- | 183 | //--------------------------------------------------------------- |
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]; |
313 | Ins[ismp].nVibSweep = ps[10]; | 313 | Ins[ismp].nVibSweep = ps[10]; |
314 | Ins[ismp].nVibDepth = ps[9]; | 314 | Ins[ismp].nVibDepth = ps[9]; |
315 | Ins[ismp].nVibRate = ps[8]; | 315 | Ins[ismp].nVibRate = ps[8]; |
316 | } | 316 | } |
317 | penv->nFadeOut = (ps[7] << 8) | ps[6]; | 317 | penv->nFadeOut = (ps[7] << 8) | ps[6]; |
318 | if (penv->nFadeOut == 0xFFFF) penv->nFadeOut = 0; | 318 | if (penv->nFadeOut == 0xFFFF) penv->nFadeOut = 0; |
319 | note++; | 319 | note++; |
320 | } | 320 | } |
321 | // Use volume envelope ? | 321 | // Use volume envelope ? |
322 | if (ps[3] & 0x80) | 322 | if (ps[3] & 0x80) |
323 | { | 323 | { |
324 | penv->dwFlags |= ENV_VOLUME; | 324 | penv->dwFlags |= ENV_VOLUME; |
325 | insvolenv[nins] = (ps[3] & 0x3F) + 1; | 325 | insvolenv[nins] = (ps[3] & 0x3F) + 1; |
326 | } | 326 | } |
327 | // Use panning envelope ? | 327 | // Use panning envelope ? |
328 | if (ps[5] & 0x80) | 328 | if (ps[5] & 0x80) |
329 | { | 329 | { |
330 | penv->dwFlags |= ENV_PANNING; | 330 | penv->dwFlags |= ENV_PANNING; |
331 | inspanenv[nins] = (ps[5] & 0x3F) + 1; | 331 | inspanenv[nins] = (ps[5] & 0x3F) + 1; |
332 | } | 332 | } |
333 | } | 333 | } |
334 | } | 334 | } |
335 | dwPos += 34 + 14*lpStream[dwPos+1]; | 335 | dwPos += 34 + 14*lpStream[dwPos+1]; |
336 | } | 336 | } |
337 | for (j=1; j<=m_nInstruments; j++) if (!Headers[j]) | 337 | for (j=1; j<=m_nInstruments; j++) if (!Headers[j]) |
338 | { | 338 | { |
339 | Headers[j] = new INSTRUMENTHEADER; | 339 | Headers[j] = new INSTRUMENTHEADER; |
340 | if (Headers[j]) memset(Headers[j], 0, sizeof(INSTRUMENTHEADER)); | 340 | if (Headers[j]) memset(Headers[j], 0, sizeof(INSTRUMENTHEADER)); |
341 | } | 341 | } |
342 | break; | 342 | break; |
343 | // VE: Volume Envelope | 343 | // VE: Volume Envelope |
344 | case 0x4556: | 344 | case 0x4556: |
345 | if ((nvolenv = lpStream[dwMemPos]) == 0) break; | 345 | if ((nvolenv = lpStream[dwMemPos]) == 0) break; |
346 | if (dwMemPos + nvolenv*32 + 1 <= dwMemLength) pvolenv = lpStream + dwMemPos + 1; | 346 | if (dwMemPos + nvolenv*32 + 1 <= dwMemLength) pvolenv = lpStream + dwMemPos + 1; |
347 | break; | 347 | break; |
348 | // PE: Panning Envelope | 348 | // PE: Panning Envelope |
349 | case 0x4550: | 349 | case 0x4550: |
350 | if ((npanenv = lpStream[dwMemPos]) == 0) break; | 350 | if ((npanenv = lpStream[dwMemPos]) == 0) break; |
351 | if (dwMemPos + npanenv*32 + 1 <= dwMemLength) ppanenv = lpStream + dwMemPos + 1; | 351 | if (dwMemPos + npanenv*32 + 1 <= dwMemLength) ppanenv = lpStream + dwMemPos + 1; |
352 | break; | 352 | break; |
353 | // FE: Pitch Envelope | 353 | // FE: Pitch Envelope |
354 | case 0x4546: | 354 | case 0x4546: |
355 | if ((npitchenv = lpStream[dwMemPos]) == 0) break; | 355 | if ((npitchenv = lpStream[dwMemPos]) == 0) break; |
356 | if (dwMemPos + npitchenv*32 + 1 <= dwMemLength) ppitchenv = lpStream + dwMemPos + 1; | 356 | if (dwMemPos + npitchenv*32 + 1 <= dwMemLength) ppitchenv = lpStream + dwMemPos + 1; |
357 | break; | 357 | break; |
358 | // IS: Sample Infoblock | 358 | // IS: Sample Infoblock |
359 | case 0x5349: | 359 | case 0x5349: |
360 | nsamples = lpStream[dwMemPos]; | 360 | nsamples = lpStream[dwMemPos]; |
361 | dwPos = dwMemPos+1; | 361 | dwPos = dwMemPos+1; |
362 | for (i=0; i<nsamples; i++, dwPos += 59) | 362 | for (i=0; i<nsamples; i++, dwPos += 59) |
363 | { | 363 | { |
364 | UINT nins = lpStream[dwPos]; | 364 | UINT nins = lpStream[dwPos]; |
365 | if ((nins >= MAX_SAMPLES) || (!nins)) continue; | 365 | if ((nins >= MAX_SAMPLES) || (!nins)) continue; |
366 | if (m_nSamples < nins) m_nSamples = nins; | 366 | if (m_nSamples < nins) m_nSamples = nins; |
367 | MODINSTRUMENT *pins = &Ins[nins]; | 367 | MODINSTRUMENT *pins = &Ins[nins]; |
368 | memcpy(m_szNames[nins], lpStream+dwPos+1, 32); | 368 | memcpy(m_szNames[nins], lpStream+dwPos+1, 32); |
369 | memcpy(pins->name, lpStream+dwPos+33, 8); | 369 | memcpy(pins->name, lpStream+dwPos+33, 8); |
370 | pins->nC4Speed = *((DWORD *)(lpStream+dwPos+41)); | 370 | pins->nC4Speed = *((DWORD *)(lpStream+dwPos+41)); |
371 | pins->nLength = *((DWORD *)(lpStream+dwPos+45)); | 371 | pins->nLength = *((DWORD *)(lpStream+dwPos+45)); |
372 | pins->nLoopStart = *((DWORD *)(lpStream+dwPos+49)); | 372 | pins->nLoopStart = *((DWORD *)(lpStream+dwPos+49)); |
373 | pins->nLoopEnd = pins->nLoopStart + *((DWORD *)(lpStream+dwPos+53)); | 373 | pins->nLoopEnd = pins->nLoopStart + *((DWORD *)(lpStream+dwPos+53)); |
374 | if (pins->nLoopEnd > pins->nLoopStart) pins->uFlags |= CHN_LOOP; | 374 | if (pins->nLoopEnd > pins->nLoopStart) pins->uFlags |= CHN_LOOP; |
375 | pins->nGlobalVol = 64; | 375 | pins->nGlobalVol = 64; |
376 | if (lpStream[dwPos+58] & 0x01) | 376 | if (lpStream[dwPos+58] & 0x01) |