gosu 1.4.5.pre1 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +1 -0
  3. data/dependencies/SDL/include/SDL_assert.h +4 -2
  4. data/dependencies/SDL/include/SDL_atomic.h +20 -0
  5. data/dependencies/SDL/include/SDL_audio.h +40 -4
  6. data/dependencies/SDL/include/SDL_blendmode.h +4 -6
  7. data/dependencies/SDL/include/SDL_clipboard.h +47 -0
  8. data/dependencies/SDL/include/SDL_config.h +71 -45
  9. data/dependencies/SDL/include/SDL_cpuinfo.h +39 -4
  10. data/dependencies/SDL/include/SDL_egl.h +59 -9
  11. data/dependencies/SDL/include/SDL_endian.h +34 -3
  12. data/dependencies/SDL/include/SDL_events.h +32 -1
  13. data/dependencies/SDL/include/SDL_filesystem.h +5 -1
  14. data/dependencies/SDL/include/SDL_gamecontroller.h +78 -5
  15. data/dependencies/SDL/include/SDL_guid.h +100 -0
  16. data/dependencies/SDL/include/SDL_hints.h +645 -43
  17. data/dependencies/SDL/include/SDL_joystick.h +127 -7
  18. data/dependencies/SDL/include/SDL_keyboard.h +38 -1
  19. data/dependencies/SDL/include/SDL_keycode.h +6 -1
  20. data/dependencies/SDL/include/SDL_log.h +2 -2
  21. data/dependencies/SDL/include/SDL_main.h +42 -2
  22. data/dependencies/SDL/include/SDL_metal.h +2 -1
  23. data/dependencies/SDL/include/SDL_mouse.h +12 -1
  24. data/dependencies/SDL/include/SDL_opengl.h +0 -51
  25. data/dependencies/SDL/include/SDL_opengl_glext.h +2260 -231
  26. data/dependencies/SDL/include/SDL_opengles2_gl2.h +374 -339
  27. data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +3479 -1496
  28. data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +6 -9
  29. data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +43 -14
  30. data/dependencies/SDL/include/SDL_platform.h +32 -6
  31. data/dependencies/SDL/include/SDL_rect.h +154 -2
  32. data/dependencies/SDL/include/SDL_render.h +46 -17
  33. data/dependencies/SDL/include/SDL_revision.h +6 -1
  34. data/dependencies/SDL/include/SDL_rwops.h +1 -15
  35. data/dependencies/SDL/include/SDL_scancode.h +46 -21
  36. data/dependencies/SDL/include/SDL_sensor.h +24 -3
  37. data/dependencies/SDL/include/SDL_stdinc.h +119 -8
  38. data/dependencies/SDL/include/SDL_surface.h +3 -1
  39. data/dependencies/SDL/include/SDL_system.h +66 -6
  40. data/dependencies/SDL/include/SDL_syswm.h +2 -0
  41. data/dependencies/SDL/include/SDL_test_common.h +1 -0
  42. data/dependencies/SDL/include/SDL_test_font.h +90 -3
  43. data/dependencies/SDL/include/SDL_thread.h +3 -3
  44. data/dependencies/SDL/include/SDL_touch.h +8 -0
  45. data/dependencies/SDL/include/SDL_version.h +19 -3
  46. data/dependencies/SDL/include/SDL_video.h +71 -9
  47. data/dependencies/SDL/include/begin_code.h +4 -4
  48. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  49. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  50. data/dependencies/SDL_sound/SDL_sound.c +210 -71
  51. data/dependencies/SDL_sound/SDL_sound.h +1 -1
  52. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +111 -168
  53. data/dependencies/SDL_sound/SDL_sound_flac.c +0 -6
  54. data/dependencies/SDL_sound/SDL_sound_internal.h +27 -5
  55. data/dependencies/SDL_sound/SDL_sound_modplug.c +20 -8
  56. data/dependencies/SDL_sound/SDL_sound_mp3.c +11 -7
  57. data/dependencies/SDL_sound/SDL_sound_raw.c +1 -1
  58. data/dependencies/SDL_sound/SDL_sound_shn.c +1 -5
  59. data/dependencies/SDL_sound/SDL_sound_voc.c +1 -1
  60. data/dependencies/SDL_sound/SDL_sound_vorbis.c +2 -4
  61. data/dependencies/SDL_sound/SDL_sound_wav.c +44 -20
  62. data/dependencies/SDL_sound/dr_flac.h +237 -95
  63. data/dependencies/SDL_sound/dr_mp3.h +46 -33
  64. data/dependencies/SDL_sound/libmodplug/fastmix.c +53 -39
  65. data/dependencies/SDL_sound/libmodplug/libmodplug.h +0 -12
  66. data/dependencies/SDL_sound/libmodplug/load_669.c +37 -32
  67. data/dependencies/SDL_sound/libmodplug/load_amf.c +57 -44
  68. data/dependencies/SDL_sound/libmodplug/load_ams.c +127 -100
  69. data/dependencies/SDL_sound/libmodplug/load_dbm.c +40 -37
  70. data/dependencies/SDL_sound/libmodplug/load_dmf.c +61 -49
  71. data/dependencies/SDL_sound/libmodplug/load_dsm.c +18 -13
  72. data/dependencies/SDL_sound/libmodplug/load_far.c +31 -24
  73. data/dependencies/SDL_sound/libmodplug/load_gdm.c +27 -21
  74. data/dependencies/SDL_sound/libmodplug/load_it.c +106 -91
  75. data/dependencies/SDL_sound/libmodplug/load_mdl.c +43 -35
  76. data/dependencies/SDL_sound/libmodplug/load_med.c +66 -52
  77. data/dependencies/SDL_sound/libmodplug/load_mod.c +30 -26
  78. data/dependencies/SDL_sound/libmodplug/load_mt2.c +61 -50
  79. data/dependencies/SDL_sound/libmodplug/load_mtm.c +23 -17
  80. data/dependencies/SDL_sound/libmodplug/load_okt.c +18 -16
  81. data/dependencies/SDL_sound/libmodplug/load_psm.c +44 -32
  82. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -14
  83. data/dependencies/SDL_sound/libmodplug/load_s3m.c +59 -53
  84. data/dependencies/SDL_sound/libmodplug/load_stm.c +23 -18
  85. data/dependencies/SDL_sound/libmodplug/load_ult.c +33 -29
  86. data/dependencies/SDL_sound/libmodplug/load_xm.c +64 -57
  87. data/dependencies/SDL_sound/libmodplug/mmcmp.c +2 -1
  88. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +30 -20
  89. data/dependencies/SDL_sound/libmodplug/snd_flt.c +6 -4
  90. data/dependencies/SDL_sound/libmodplug/snd_fx.c +91 -65
  91. data/dependencies/SDL_sound/libmodplug/sndfile.c +91 -66
  92. data/dependencies/SDL_sound/libmodplug/sndmix.c +58 -35
  93. data/dependencies/SDL_sound/stb_vorbis.h +14 -9
  94. data/dependencies/mojoAL/mojoal.c +41 -24
  95. data/dependencies/utf8proc/utf8proc.c +1 -1
  96. data/dependencies/utf8proc/utf8proc.h +1 -1
  97. data/dependencies/utf8proc/utf8proc_data.h +3366 -3184
  98. data/lib/SDL2.dll +0 -0
  99. data/lib64/SDL2.dll +0 -0
  100. data/src/Window.cpp +3 -0
  101. metadata +5 -4
@@ -49,8 +49,10 @@ CSoundFile *new_CSoundFile(LPCBYTE lpStream, DWORD dwMemLength, const ModPlug_Se
49
49
  //----------------------------------------------------------
50
50
  {
51
51
  int i;
52
+ CSoundFile *_this;
53
+ MODINSTRUMENT *pins;
52
54
 
53
- CSoundFile *_this = (CSoundFile *) SDL_calloc(1, sizeof (CSoundFile));
55
+ _this = (CSoundFile *) SDL_calloc(1, sizeof (CSoundFile));
54
56
  if (!_this) return NULL;
55
57
 
56
58
  _this->m_nXBassDepth = 6;
@@ -78,11 +80,11 @@ CSoundFile *new_CSoundFile(LPCBYTE lpStream, DWORD dwMemLength, const ModPlug_Se
78
80
  _this->m_nSongPreAmp = 0x30;
79
81
  SDL_memset(_this->Order, 0xFF, sizeof(_this->Order));
80
82
  CSoundFile_ResetMidiCfg(_this);
81
- for (UINT npt=0; npt<MAX_PATTERNS; npt++) _this->PatternSize[npt] = 64;
82
- for (UINT nch=0; nch<MAX_BASECHANNELS; nch++)
83
+ for (i=0; i<MAX_PATTERNS; i++) _this->PatternSize[i] = 64;
84
+ for (i=0; i<MAX_BASECHANNELS; i++)
83
85
  {
84
- _this->ChnSettings[nch].nPan = 128;
85
- _this->ChnSettings[nch].nVolume = 64;
86
+ _this->ChnSettings[i].nPan = 128;
87
+ _this->ChnSettings[i].nVolume = 64;
86
88
  }
87
89
  if (lpStream)
88
90
  {
@@ -129,7 +131,7 @@ CSoundFile *new_CSoundFile(LPCBYTE lpStream, DWORD dwMemLength, const ModPlug_Se
129
131
  _this->Chn[i].nCutOff = 0x7F;
130
132
  }
131
133
  // Checking instruments
132
- MODINSTRUMENT *pins = _this->Ins;
134
+ pins = _this->Ins;
133
135
 
134
136
  for (i=0; i<MAX_INSTRUMENTS; i++, pins++)
135
137
  {
@@ -269,6 +271,7 @@ void CSoundFile_FreeSample(LPVOID p)
269
271
  void CSoundFile_ResetMidiCfg(CSoundFile *_this)
270
272
  //-----------------------------
271
273
  {
274
+ int iz;
272
275
  SDL_memset(&_this->m_MidiCfg, 0, sizeof(_this->m_MidiCfg));
273
276
  SDL_strlcpy(&_this->m_MidiCfg.szMidiGlb[MIDIOUT_START*32], "FF", 32);
274
277
  SDL_strlcpy(&_this->m_MidiCfg.szMidiGlb[MIDIOUT_STOP*32], "FC", 32);
@@ -276,7 +279,7 @@ void CSoundFile_ResetMidiCfg(CSoundFile *_this)
276
279
  SDL_strlcpy(&_this->m_MidiCfg.szMidiGlb[MIDIOUT_NOTEOFF*32], "9c n 0", 32);
277
280
  SDL_strlcpy(&_this->m_MidiCfg.szMidiGlb[MIDIOUT_PROGRAM*32], "Cc p", 32);
278
281
  SDL_strlcpy(&_this->m_MidiCfg.szMidiSFXExt[0], "F0F000z", 32);
279
- for (int iz=0; iz<16; iz++) SDL_snprintf(&_this->m_MidiCfg.szMidiZXXExt[iz*32], 32, "F0F001%02X", iz*8);
282
+ for (iz=0; iz<16; iz++) SDL_snprintf(&_this->m_MidiCfg.szMidiZXXExt[iz*32], 32, "F0F001%02X", iz*8);
280
283
  }
281
284
 
282
285
 
@@ -339,7 +342,7 @@ UINT CSoundFile_GetMaxPosition(CSoundFile *_this)
339
342
  void CSoundFile_SetCurrentPos(CSoundFile *_this, UINT nPos)
340
343
  //---------------------------------------
341
344
  {
342
- UINT i, nPattern;
345
+ UINT i, nPattern, nRow;
343
346
 
344
347
  for (i=0; i<MAX_CHANNELS; i++)
345
348
  {
@@ -408,7 +411,7 @@ void CSoundFile_SetCurrentPos(CSoundFile *_this, UINT nPos)
408
411
  nPos = 0;
409
412
  nPattern = 0;
410
413
  }
411
- UINT nRow = nPos;
414
+ nRow = nPos;
412
415
  if ((nRow) && (_this->Order[nPattern] < MAX_PATTERNS))
413
416
  {
414
417
  MODCOMMAND *p = _this->Patterns[_this->Order[nPattern]];
@@ -418,7 +421,8 @@ void CSoundFile_SetCurrentPos(CSoundFile *_this, UINT nPos)
418
421
  while ((!bOk) && (nRow > 0))
419
422
  {
420
423
  UINT n = nRow * _this->m_nChannels;
421
- for (UINT k=0; k<_this->m_nChannels; k++, n++)
424
+ UINT k=0;
425
+ for (; k<_this->m_nChannels; k++, n++)
422
426
  {
423
427
  if (p[n].note)
424
428
  {
@@ -453,7 +457,7 @@ void CSoundFile_SetCurrentPos(CSoundFile *_this, UINT nPos)
453
457
  UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags, LPCSTR lpMemFile, DWORD dwMemLength)
454
458
  //------------------------------------------------------------------------------
455
459
  {
456
- UINT len = 0, mem;
460
+ UINT len = 0, j, mem;
457
461
 
458
462
  // Disable >2Gb samples,(preventing buffer overflow in AllocateSample)
459
463
  if ((!pIns) || ((int)pIns->nLength < 4) || (!lpMemFile)) return 0;
@@ -480,23 +484,26 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
480
484
  // 1: 8-bit unsigned PCM data
481
485
  case RS_PCM8U:
482
486
  {
487
+ signed char *pSample;
483
488
  len = pIns->nLength;
484
489
  if (len > dwMemLength) len = pIns->nLength = dwMemLength;
485
- signed char *pSample = pIns->pSample;
486
- for (UINT j=0; j<len; j++) pSample[j] = (signed char)(lpMemFile[j] - 0x80);
490
+ pSample = pIns->pSample;
491
+ for (j=0; j<len; j++) pSample[j] = (signed char)(lpMemFile[j] - 0x80);
487
492
  }
488
493
  break;
489
494
 
490
495
  // 2: 8-bit ADPCM data with linear table
491
496
  case RS_PCM8D:
492
497
  {
498
+ signed char *pSample;
499
+ const signed char *p;
500
+ int delta = 0;
493
501
  len = pIns->nLength;
494
502
  if (len > dwMemLength) break;
495
- signed char *pSample = pIns->pSample;
496
- const signed char *p = (const signed char *)lpMemFile;
497
- int delta = 0;
503
+ pSample = pIns->pSample;
504
+ p = (const signed char *)lpMemFile;
498
505
 
499
- for (UINT j=0; j<len; j++)
506
+ for (j=0; j<len; j++)
500
507
  {
501
508
  delta += p[j];
502
509
  *pSample++ = (signed char)delta;
@@ -507,13 +514,15 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
507
514
  // 3: 4-bit ADPCM data
508
515
  case RS_ADPCM4:
509
516
  {
517
+ signed char *pSample;
518
+ signed char delta;
510
519
  len = (pIns->nLength + 1) / 2;
511
520
  if (len > dwMemLength - 16 || dwMemLength < 16) break;
512
521
  SDL_memcpy(_this->CompressionTable, lpMemFile, 16);
513
522
  lpMemFile += 16;
514
- signed char *pSample = pIns->pSample;
515
- signed char delta = 0;
516
- for (UINT j=0; j<len; j++)
523
+ pSample = pIns->pSample;
524
+ delta = 0;
525
+ for (j=0; j<len; j++)
517
526
  {
518
527
  const BYTE b0 = (BYTE)lpMemFile[j];
519
528
  const BYTE b1 = (BYTE)(lpMemFile[j] >> 4);
@@ -530,12 +539,13 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
530
539
  // 4: 16-bit ADPCM data with linear table
531
540
  case RS_PCM16D:
532
541
  {
542
+ int16_t *pSample, *p;
543
+ int delta16 = 0;
533
544
  len = pIns->nLength * 2;
534
545
  if (len > dwMemLength) break;
535
- int16_t *pSample = (int16_t *)pIns->pSample;
536
- int16_t *p = (int16_t *)lpMemFile;
537
- int delta16 = 0;
538
- for (UINT j=0; j<len; j+=2)
546
+ pSample = (int16_t *)pIns->pSample;
547
+ p = (int16_t *)lpMemFile;
548
+ for (j=0; j<len; j+=2)
539
549
  {
540
550
  delta16 += bswapLE16(*p++);
541
551
  *pSample++ = (int16_t )delta16;
@@ -546,10 +556,11 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
546
556
  // 5: 16-bit signed PCM data
547
557
  case RS_PCM16S:
548
558
  {
559
+ int16_t *pSample;
549
560
  len = pIns->nLength * 2;
550
561
  if (len <= dwMemLength) SDL_memcpy(pIns->pSample, lpMemFile, len);
551
- int16_t *pSample = (int16_t *)pIns->pSample;
552
- for (UINT j=0; j<len; j+=2)
562
+ pSample = (int16_t *)pIns->pSample;
563
+ for (j=0; j<len; j+=2)
553
564
  {
554
565
  int16_t rawSample = *pSample;
555
566
  *pSample++ = bswapLE16(rawSample);
@@ -565,7 +576,7 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
565
576
  {
566
577
  signed char *pSample = (signed char *)pIns->pSample;
567
578
  signed char *pSrc = (signed char *)lpMemFile;
568
- for (UINT j=0; j<len; j+=2)
579
+ for (j=0; j<len; j+=2)
569
580
  {
570
581
  // pSample[j] = pSrc[j+1];
571
582
  // pSample[j+1] = pSrc[j];
@@ -577,11 +588,12 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
577
588
  // 6: 16-bit unsigned PCM data
578
589
  case RS_PCM16U:
579
590
  {
591
+ int16_t *pSample, *pSrc;
580
592
  len = pIns->nLength * 2;
581
593
  if (len > dwMemLength) break;
582
- int16_t *pSample = (int16_t *)pIns->pSample;
583
- int16_t *pSrc = (int16_t *)lpMemFile;
584
- for (UINT j=0; j<len; j+=2) *pSample++ = bswapLE16(*(pSrc++)) - 0x8000;
594
+ pSample = (int16_t *)pIns->pSample;
595
+ pSrc = (int16_t *)lpMemFile;
596
+ for (j=0; j<len; j+=2) *pSample++ = bswapLE16(*(pSrc++)) - 0x8000;
585
597
  }
586
598
  break;
587
599
 
@@ -592,7 +604,7 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
592
604
  {
593
605
  signed char *pSample = (signed char *)pIns->pSample;
594
606
  signed char *pSrc = (signed char *)lpMemFile;
595
- for (UINT j=0; j<len; j+=2)
607
+ for (j=0; j<len; j+=2)
596
608
  {
597
609
  // pSample[j*2] = pSrc[j+1];
598
610
  // pSample[j*2+1] = pSrc[j];
@@ -611,12 +623,13 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
611
623
  case RS_STPCM8D:
612
624
  {
613
625
  int iadd_l = 0, iadd_r = 0;
626
+ signed char *psrc,*pSample;
614
627
  if (nFlags == RS_STPCM8U) { iadd_l = iadd_r = -128; }
615
628
  len = pIns->nLength;
616
- signed char *psrc = (signed char *)lpMemFile;
617
- signed char *pSample = (signed char *)pIns->pSample;
629
+ psrc = (signed char *)lpMemFile;
630
+ pSample = (signed char *)pIns->pSample;
618
631
  if (len*2 > dwMemLength) break;
619
- for (UINT j=0; j<len; j++)
632
+ for (j=0; j<len; j++)
620
633
  {
621
634
  pSample[j*2] = (signed char)(psrc[0] + iadd_l);
622
635
  pSample[j*2+1] = (signed char)(psrc[len] + iadd_r);
@@ -637,12 +650,13 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
637
650
  case RS_STPCM16D:
638
651
  {
639
652
  int iadd_l = 0, iadd_r = 0;
653
+ int16_t *psrc, *pSample;
640
654
  if (nFlags == RS_STPCM16U) { iadd_l = iadd_r = -0x8000; }
641
655
  len = pIns->nLength;
642
- int16_t *psrc = (int16_t *)lpMemFile;
643
- int16_t *pSample = (int16_t *)pIns->pSample;
656
+ psrc = (int16_t *)lpMemFile;
657
+ pSample = (int16_t *)pIns->pSample;
644
658
  if (len*4 > dwMemLength) break;
645
- for (UINT j=0; j<len; j++)
659
+ for (j=0; j<len; j++)
646
660
  {
647
661
  pSample[j*2] = (int16_t) (bswapLE16(psrc[0]) + iadd_l);
648
662
  pSample[j*2+1] = (int16_t) (bswapLE16(psrc[len]) + iadd_r);
@@ -693,12 +707,13 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
693
707
  case RS_STIPCM8U:
694
708
  {
695
709
  int iadd = 0;
710
+ LPBYTE psrc, pSample;
696
711
  if (nFlags == RS_STIPCM8U) { iadd = -0x80; }
697
712
  len = pIns->nLength;
698
713
  if (len*2 > dwMemLength) len = dwMemLength >> 1;
699
- LPBYTE psrc = (LPBYTE)lpMemFile;
700
- LPBYTE pSample = (LPBYTE)pIns->pSample;
701
- for (UINT j=0; j<len; j++)
714
+ psrc = (LPBYTE)lpMemFile;
715
+ pSample = (LPBYTE)pIns->pSample;
716
+ for (j=0; j<len; j++)
702
717
  {
703
718
  pSample[j*2] = (signed char)(psrc[0] + iadd);
704
719
  pSample[j*2+1] = (signed char)(psrc[1] + iadd);
@@ -713,12 +728,13 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
713
728
  case RS_STIPCM16U:
714
729
  {
715
730
  int iadd = 0;
731
+ int16_t *psrc, *pSample;
716
732
  if (nFlags == RS_STIPCM16U) iadd = -32768;
717
733
  len = pIns->nLength;
718
734
  if (len*4 > dwMemLength) len = dwMemLength >> 2;
719
- int16_t *psrc = (int16_t *)lpMemFile;
720
- int16_t *pSample = (int16_t *)pIns->pSample;
721
- for (UINT j=0; j<len; j++)
735
+ psrc = (int16_t *)lpMemFile;
736
+ pSample = (int16_t *)pIns->pSample;
737
+ for (j=0; j<len; j++)
722
738
  {
723
739
  pSample[j*2] = (int16_t)(bswapLE16(psrc[0]) + iadd);
724
740
  pSample[j*2+1] = (int16_t)(bswapLE16(psrc[1]) + iadd);
@@ -737,9 +753,10 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
737
753
  const char *psrc = lpMemFile;
738
754
  char packcharacter = lpMemFile[8], *pdest = (char *)pIns->pSample;
739
755
  UINT smplen = bswapLE32(*((LPDWORD)(lpMemFile+4)));
756
+ UINT dmax;
740
757
  if (smplen > dwMemLength - 9) smplen = dwMemLength - 9;
741
758
  len += smplen;
742
- UINT dmax = pIns->nLength;
759
+ dmax = pIns->nLength;
743
760
  if (pIns->uFlags & CHN_16BIT) dmax <<= 1;
744
761
  AMSUnpack(psrc+9, smplen, pdest, dmax, packcharacter);
745
762
  }
@@ -748,17 +765,18 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
748
765
  // PTM 8bit delta to 16-bit sample
749
766
  case RS_PTM8DTO16:
750
767
  {
751
- UINT j;
768
+ int8_t *pSample;
769
+ int8_t delta8 = 0;
770
+ uint16_t *pSampleW;
752
771
  len = pIns->nLength * 2;
753
772
  if (len > dwMemLength) break;
754
- int8_t *pSample = (int8_t *)pIns->pSample;
755
- int8_t delta8 = 0;
773
+ pSample = (int8_t *)pIns->pSample;
756
774
  for (j=0; j<len; j++)
757
775
  {
758
776
  delta8 += lpMemFile[j];
759
777
  *pSample++ = delta8;
760
778
  }
761
- uint16_t *pSampleW = (uint16_t *)pIns->pSample;
779
+ pSampleW = (uint16_t *)pIns->pSample;
762
780
  for (j=0; j<len; j+=2) // swaparoni!
763
781
  {
764
782
  uint16_t rawSample = *pSampleW;
@@ -780,7 +798,7 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
780
798
  BYTE dlt = 0, lowbyte = 0;
781
799
  LPBYTE ibufend = (LPBYTE)lpMemFile + dwMemLength - 1;
782
800
  ibuf += 4;
783
- for (UINT j=0; j<pIns->nLength && ibuf < ibufend; j++)
801
+ for (j=0; j<pIns->nLength && ibuf < ibufend; j++)
784
802
  {
785
803
  BYTE hibyte;
786
804
  BYTE sign;
@@ -816,8 +834,9 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
816
834
  if (len >= 4)
817
835
  {
818
836
  UINT maxlen = pIns->nLength;
837
+ LPBYTE ibuf, ibufmax;
819
838
  if (pIns->uFlags & CHN_16BIT) maxlen <<= 1;
820
- LPBYTE ibuf = (LPBYTE)lpMemFile, ibufmax = (LPBYTE)(lpMemFile+dwMemLength);
839
+ ibuf = (LPBYTE)lpMemFile, ibufmax = (LPBYTE)(lpMemFile+dwMemLength);
821
840
  len = DMFUnpack((LPBYTE)pIns->pSample, ibuf, ibufmax, maxlen);
822
841
  }
823
842
  break;
@@ -847,6 +866,7 @@ UINT CSoundFile_ReadSample(CSoundFile *_this, MODINSTRUMENT *pIns, UINT nFlags,
847
866
  void CSoundFile_AdjustSampleLoop(CSoundFile *_this, MODINSTRUMENT *pIns)
848
867
  //----------------------------------------------------
849
868
  {
869
+ UINT len;
850
870
  if (!pIns->pSample) return;
851
871
  if (pIns->nLength > MAX_SAMPLE_LENGTH) pIns->nLength = MAX_SAMPLE_LENGTH;
852
872
  if (pIns->nLoopEnd > pIns->nLength) pIns->nLoopEnd = pIns->nLength;
@@ -856,7 +876,7 @@ void CSoundFile_AdjustSampleLoop(CSoundFile *_this, MODINSTRUMENT *pIns)
856
876
  pIns->nLoopStart = pIns->nLoopEnd = 0;
857
877
  pIns->uFlags &= ~CHN_LOOP;
858
878
  }
859
- UINT len = pIns->nLength;
879
+ len = pIns->nLength;
860
880
  if (pIns->uFlags & CHN_16BIT)
861
881
  {
862
882
  int16_t *pSample = (int16_t *)pIns->pSample;
@@ -888,13 +908,13 @@ void CSoundFile_AdjustSampleLoop(CSoundFile *_this, MODINSTRUMENT *pIns)
888
908
  if ((pIns->nLength > 0x100) && (_this->m_nType & (MOD_TYPE_MOD|MOD_TYPE_S3M))
889
909
  && (!(pIns->uFlags & CHN_STEREO)))
890
910
  {
891
- int smpend = pSample[pIns->nLength-1], smpfix = 0, kscan;
911
+ int smpend = pSample[pIns->nLength-1], smpfix = 0, kscan, delta;
892
912
  for (kscan=pIns->nLength-1; kscan>0; kscan--)
893
913
  {
894
914
  smpfix = pSample[kscan-1];
895
915
  if (smpfix != smpend) break;
896
916
  }
897
- int delta = smpfix - smpend;
917
+ delta = smpfix - smpend;
898
918
  if (((!(pIns->uFlags & CHN_LOOP)) || (kscan > (int)pIns->nLoopEnd))
899
919
  && ((delta < -8) || (delta > 8)))
900
920
  {
@@ -991,9 +1011,11 @@ BOOL CSoundFile_SetPatternName(CSoundFile *_this, UINT nPat, LPCSTR lpszName)
991
1011
  if (!_this->m_lpszPatternNames) _this->m_nPatternNames = 0;
992
1012
  if (nPat >= _this->m_nPatternNames)
993
1013
  {
1014
+ UINT len;
1015
+ char *p;
994
1016
  if (!lpszName[0]) return TRUE;
995
- UINT len = (nPat+1)*MAX_PATTERNNAME;
996
- char *p = (char *) SDL_calloc(1, len);
1017
+ len = (nPat+1)*MAX_PATTERNNAME;
1018
+ p = (char *) SDL_calloc(1, len);
997
1019
  if (!p) return FALSE;
998
1020
  if (_this->m_lpszPatternNames)
999
1021
  {
@@ -1012,19 +1034,19 @@ BOOL CSoundFile_SetPatternName(CSoundFile *_this, UINT nPat, LPCSTR lpszName)
1012
1034
  UINT CSoundFile_DetectUnusedSamples(CSoundFile *_this, BOOL *pbIns)
1013
1035
  //-----------------------------------------------
1014
1036
  {
1015
- UINT nExt = 0;
1037
+ UINT nExt = 0, i, j, k;
1016
1038
 
1017
1039
  if (!pbIns) return 0;
1018
1040
  if (_this->m_nInstruments)
1019
1041
  {
1020
1042
  SDL_memset(pbIns, 0, MAX_SAMPLES * sizeof(BOOL));
1021
- for (UINT ipat=0; ipat<MAX_PATTERNS; ipat++)
1043
+ for (i=0; i<MAX_PATTERNS; i++)
1022
1044
  {
1023
- MODCOMMAND *p = _this->Patterns[ipat];
1045
+ MODCOMMAND *p = _this->Patterns[i];
1024
1046
  if (p)
1025
1047
  {
1026
- UINT jmax = _this->PatternSize[ipat] * _this->m_nChannels;
1027
- for (UINT j=0; j<jmax; j++, p++)
1048
+ UINT jmax = _this->PatternSize[i] * _this->m_nChannels;
1049
+ for (j=0; j<jmax; j++, p++)
1028
1050
  {
1029
1051
  if ((p->note) && (p->note <= NOTE_MAX))
1030
1052
  {
@@ -1038,7 +1060,7 @@ UINT CSoundFile_DetectUnusedSamples(CSoundFile *_this, BOOL *pbIns)
1038
1060
  }
1039
1061
  } else
1040
1062
  {
1041
- for (UINT k=1; k<=_this->m_nInstruments; k++)
1063
+ for (k=1; k<=_this->m_nInstruments; k++)
1042
1064
  {
1043
1065
  INSTRUMENTHEADER *penv = _this->Headers[k];
1044
1066
  if (penv)
@@ -1052,9 +1074,9 @@ UINT CSoundFile_DetectUnusedSamples(CSoundFile *_this, BOOL *pbIns)
1052
1074
  }
1053
1075
  }
1054
1076
  }
1055
- for (UINT ichk=1; ichk<=_this->m_nSamples; ichk++)
1077
+ for (k=1; k<=_this->m_nSamples; k++)
1056
1078
  {
1057
- if ((!pbIns[ichk]) && (_this->Ins[ichk].pSample)) nExt++;
1079
+ if ((!pbIns[k]) && (_this->Ins[k].pSample)) nExt++;
1058
1080
  }
1059
1081
  }
1060
1082
  return nExt;
@@ -1064,14 +1086,17 @@ UINT CSoundFile_DetectUnusedSamples(CSoundFile *_this, BOOL *pbIns)
1064
1086
  BOOL CSoundFile_DestroySample(CSoundFile *_this, UINT nSample)
1065
1087
  //------------------------------------------
1066
1088
  {
1089
+ MODINSTRUMENT *pins;
1090
+ signed char *pSample;
1091
+ int i;
1067
1092
  if ((!nSample) || (nSample >= MAX_SAMPLES)) return FALSE;
1068
1093
  if (!_this->Ins[nSample].pSample) return TRUE;
1069
- MODINSTRUMENT *pins = &_this->Ins[nSample];
1070
- signed char *pSample = pins->pSample;
1094
+ pins = &_this->Ins[nSample];
1095
+ pSample = pins->pSample;
1071
1096
  pins->pSample = NULL;
1072
1097
  pins->nLength = 0;
1073
1098
  pins->uFlags &= ~(CHN_16BIT);
1074
- for (UINT i=0; i<MAX_CHANNELS; i++)
1099
+ for (i=0; i<MAX_CHANNELS; i++)
1075
1100
  {
1076
1101
  if (_this->Chn[i].pSample == pSample)
1077
1102
  {