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
@@ -122,17 +122,18 @@ static void UnpackMDLTrack(MODCOMMAND *pat, UINT nChannels, UINT nRows, UINT nTr
122
122
 
123
123
  case 0x03:
124
124
  {
125
+ UINT volume, commands, command1, command2, param1, param2;
125
126
  cmd.note = (xx & 0x01) ? (pos < len ? lpTracks[pos++] : 0) : 0;
126
127
  cmd.instr = (xx & 0x02) ? (pos < len ? lpTracks[pos++] : 0) : 0;
127
128
  cmd.volcmd = cmd.vol = 0;
128
129
  cmd.command = cmd.param = 0;
129
130
  if ((cmd.note < NOTE_MAX-12) && (cmd.note)) cmd.note += 12;
130
- UINT volume = (xx & 0x04) ? (pos < len ? lpTracks[pos++] : 0) : 0;
131
- UINT commands = (xx & 0x08) ? (pos < len ? lpTracks[pos++] : 0) : 0;
132
- UINT command1 = commands & 0x0F;
133
- UINT command2 = commands & 0xF0;
134
- UINT param1 = (xx & 0x10) ? (pos < len ? lpTracks[pos++] : 0) : 0;
135
- UINT param2 = (xx & 0x20) ? (pos < len ? lpTracks[pos++] : 0) : 0;
131
+ volume = (xx & 0x04) ? (pos < len ? lpTracks[pos++] : 0) : 0;
132
+ commands = (xx & 0x08) ? (pos < len ? lpTracks[pos++] : 0) : 0;
133
+ command1 = commands & 0x0F;
134
+ command2 = commands & 0xF0;
135
+ param1 = (xx & 0x10) ? (pos < len ? lpTracks[pos++] : 0) : 0;
136
+ param2 = (xx & 0x20) ? (pos < len ? lpTracks[pos++] : 0) : 0;
136
137
  if ((command1 == 0x0E) && ((param1 & 0xF0) == 0xF0) && (!command2))
137
138
  {
138
139
  param1 = ((param1 & 0x0F) << 8) | param2;
@@ -180,10 +181,11 @@ BOOL CSoundFile_ReadMDL(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
180
181
  BYTE inspanenv[MAX_INSTRUMENTS];
181
182
  LPCBYTE pvolenv, ppanenv, ppitchenv;
182
183
  UINT nvolenv, npanenv, npitchenv;
184
+ UINT hdrLen;
183
185
 
184
186
  if ((!lpStream) || (dwMemLength < 1024)) return FALSE;
185
187
  if ((pmsh->id != 0x4C444D44) || ((pmsh->version & 0xF0) > 0x10)) return FALSE;
186
- const UINT hdrLen = (pmsh->version>0)? 59 : 57;
188
+ hdrLen = (pmsh->version>0)? 59 : 57;
187
189
  SDL_memset(patterntracks, 0, sizeof(patterntracks));
188
190
  SDL_memset(smpinfo, 0, sizeof(smpinfo));
189
191
  SDL_memset(insvolenv, 0, sizeof(insvolenv));
@@ -245,8 +247,9 @@ BOOL CSoundFile_ReadMDL(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
245
247
  if (_this->m_nChannels < 32) _this->m_nChannels = 32;
246
248
  ch = 32;
247
249
  } else {
250
+ const MDLPATTERNDATA *pmpd;
248
251
  if (dwPos+18 >= dwMemLength) break;
249
- const MDLPATTERNDATA *pmpd = (const MDLPATTERNDATA *)(lpStream + dwPos);
252
+ pmpd = (const MDLPATTERNDATA *)(lpStream + dwPos);
250
253
  if (pmpd->channels > 32) break;
251
254
  _this->PatternSize[i] = pmpd->lastrow+1;
252
255
  if (_this->m_nChannels < pmpd->channels) _this->m_nChannels = pmpd->channels;
@@ -283,9 +286,10 @@ BOOL CSoundFile_ReadMDL(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
283
286
  if (_this->m_nInstruments < nins) _this->m_nInstruments = nins;
284
287
  if (!_this->Headers[nins])
285
288
  {
289
+ INSTRUMENTHEADER *penv;
286
290
  UINT note = 12;
287
291
  if ((_this->Headers[nins] = (INSTRUMENTHEADER *) SDL_calloc(1, sizeof (INSTRUMENTHEADER))) == NULL) break;
288
- INSTRUMENTHEADER *penv = _this->Headers[nins];
292
+ penv = _this->Headers[nins];
289
293
  if (dwPos > dwMemLength - 34) break;
290
294
  penv->nGlobalVol = 64;
291
295
  penv->nPPC = 5*12;
@@ -357,9 +361,10 @@ BOOL CSoundFile_ReadMDL(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
357
361
  for (i=0; i<nsamples; i++, dwPos += hdrLen)
358
362
  {
359
363
  UINT nins = lpStream[dwPos];
364
+ MODINSTRUMENT *pins;
360
365
  if ((nins >= MAX_SAMPLES) || (!nins)) continue;
361
366
  if (_this->m_nSamples < nins) _this->m_nSamples = nins;
362
- MODINSTRUMENT *pins = &_this->Ins[nins];
367
+ pins = &_this->Ins[nins];
363
368
  pp = lpStream + dwPos + 41;
364
369
  pins->nC4Speed = pp[0] | (pp[1] << 8); pp += 2;
365
370
  if (pmsh->version > 0) {
@@ -412,10 +417,11 @@ BOOL CSoundFile_ReadMDL(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
412
417
  // Unpack Patterns
413
418
  if ((dwTrackPos) && (npatterns) && (_this->m_nChannels) && (ntracks))
414
419
  {
415
- for (UINT ipat=0; ipat<npatterns; ipat++)
420
+ for (i=0; i<npatterns; i++)
416
421
  {
417
- if ((_this->Patterns[ipat] = CSoundFile_AllocatePattern(_this->PatternSize[ipat], _this->m_nChannels)) == NULL) break;
418
- for (UINT chn=0; chn<_this->m_nChannels; chn++) if ((patterntracks[ipat*32+chn]) && (patterntracks[ipat*32+chn] <= ntracks))
422
+ UINT chn;
423
+ if ((_this->Patterns[i] = CSoundFile_AllocatePattern(_this->PatternSize[i], _this->m_nChannels)) == NULL) break;
424
+ for (chn=0; chn<_this->m_nChannels; chn++) if ((patterntracks[i*32+chn]) && (patterntracks[i*32+chn] <= ntracks))
419
425
  {
420
426
  const BYTE *lpTracks = lpStream + dwTrackPos;
421
427
  UINT len = 0;
@@ -423,11 +429,11 @@ BOOL CSoundFile_ReadMDL(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
423
429
  len = lpTracks[0] | (lpTracks[1] << 8);
424
430
 
425
431
  if (len < dwMemLength-dwTrackPos) {
426
- MODCOMMAND *m = _this->Patterns[ipat] + chn;
427
- UINT nTrack = patterntracks[ipat*32+chn];
432
+ MODCOMMAND *m = _this->Patterns[i] + chn;
433
+ UINT nTrack = patterntracks[i*32+chn];
428
434
 
429
435
  lpTracks += 2;
430
- for (UINT ntrk=1; ntrk<nTrack && lpTracks < (dwMemLength + lpStream - len - 2); ntrk++)
436
+ for (j=1; j<nTrack && lpTracks < (dwMemLength + lpStream - len - 2); j++)
431
437
  {
432
438
  lpTracks += len;
433
439
  len = lpTracks[0] | (lpTracks[1] << 8);
@@ -436,31 +442,32 @@ BOOL CSoundFile_ReadMDL(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
436
442
 
437
443
  if ( len > dwMemLength - (lpTracks - lpStream) ) len = 0;
438
444
 
439
- UnpackMDLTrack(m, _this->m_nChannels, _this->PatternSize[ipat], nTrack, lpTracks, len);
445
+ UnpackMDLTrack(m, _this->m_nChannels, _this->PatternSize[i], nTrack, lpTracks, len);
440
446
  }
441
447
  }
442
448
  }
443
449
  }
444
450
  // Set up envelopes
445
- for (UINT iIns=1; iIns<=_this->m_nInstruments; iIns++) if (_this->Headers[iIns])
451
+ for (i=1; i<=_this->m_nInstruments; i++) if (_this->Headers[i])
446
452
  {
447
- INSTRUMENTHEADER *penv = _this->Headers[iIns];
453
+ INSTRUMENTHEADER *penv = _this->Headers[i];
448
454
  // Setup volume envelope
449
- if ((nvolenv) && (pvolenv) && (insvolenv[iIns]))
455
+ if ((nvolenv) && (pvolenv) && (insvolenv[i]))
450
456
  {
451
457
  LPCBYTE pve = pvolenv;
452
- for (UINT nve=0; nve<nvolenv; nve++, pve+=33) if (pve[0]+1 == insvolenv[iIns])
458
+ UINT nve;
459
+ for (nve=0; nve<nvolenv; nve++, pve+=33) if (pve[0]+1 == insvolenv[i])
453
460
  {
454
461
  WORD vtick = 1;
455
462
  penv->nVolEnv = 15;
456
- for (UINT iv=0; iv<15; iv++)
463
+ for (j=0; j<15; j++)
457
464
  {
458
- if (iv) vtick += pve[iv*2+1];
459
- penv->VolPoints[iv] = vtick;
460
- penv->VolEnv[iv] = pve[iv*2+2];
461
- if (!pve[iv*2+1])
465
+ if (j) vtick += pve[j*2+1];
466
+ penv->VolPoints[j] = vtick;
467
+ penv->VolEnv[j] = pve[j*2+2];
468
+ if (!pve[j*2+1])
462
469
  {
463
- penv->nVolEnv = iv+1;
470
+ penv->nVolEnv = j+1;
464
471
  break;
465
472
  }
466
473
  }
@@ -472,21 +479,22 @@ BOOL CSoundFile_ReadMDL(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
472
479
  }
473
480
  }
474
481
  // Setup panning envelope
475
- if ((npanenv) && (ppanenv) && (inspanenv[iIns]))
482
+ if ((npanenv) && (ppanenv) && (inspanenv[i]))
476
483
  {
477
484
  LPCBYTE ppe = ppanenv;
478
- for (UINT npe=0; npe<npanenv; npe++, ppe+=33) if (ppe[0]+1 == inspanenv[iIns])
485
+ UINT npe;
486
+ for (npe=0; npe<npanenv; npe++, ppe+=33) if (ppe[0]+1 == inspanenv[i])
479
487
  {
480
488
  WORD vtick = 1;
481
489
  penv->nPanEnv = 15;
482
- for (UINT iv=0; iv<15; iv++)
490
+ for (j=0; j<15; j++)
483
491
  {
484
- if (iv) vtick += ppe[iv*2+1];
485
- penv->PanPoints[iv] = vtick;
486
- penv->PanEnv[iv] = ppe[iv*2+2];
487
- if (!ppe[iv*2+1])
492
+ if (j) vtick += ppe[j*2+1];
493
+ penv->PanPoints[j] = vtick;
494
+ penv->PanEnv[j] = ppe[j*2+2];
495
+ if (!ppe[j*2+1])
488
496
  {
489
- penv->nPanEnv = iv+1;
497
+ penv->nPanEnv = j+1;
490
498
  break;
491
499
  }
492
500
  }
@@ -466,16 +466,17 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
466
466
  const MMD2SONGHEADER *pmsh2;
467
467
  const MMD0EXP *pmex;
468
468
  DWORD dwBlockArr, dwSmplArr, dwExpData, wNumBlocks;
469
+ DWORD dwSong;
469
470
  LPDWORD pdwTable;
470
- CHAR version;
471
- UINT deftempo;
471
+ UINT deftempo, j;
472
+ int version;
472
473
  int playtransp = 0;
473
474
 
474
475
  if ((!lpStream) || (dwMemLength < 0x200)) return FALSE;
475
476
  pmmh = (MEDMODULEHEADER *)lpStream;
476
477
  if (((pmmh->id & 0x00FFFFFF) != 0x444D4D) || (!pmmh->song)) return FALSE;
477
478
  // Check for 'MMDx'
478
- DWORD dwSong = bswapBE32(pmmh->song);
479
+ dwSong = bswapBE32(pmmh->song);
479
480
  if ((dwSong >= dwMemLength) || (dwSong + sizeof(MMD0SONGHEADER) >= dwMemLength)) return FALSE;
480
481
  version = (signed char)((pmmh->id >> 24) & 0xFF);
481
482
  if ((version < '0') || (version > '3')) return FALSE;
@@ -528,15 +529,15 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
528
529
  }
529
530
  _this->m_nDefaultTempo = deftempo;
530
531
  // Reading Samples
531
- for (UINT iSHdr=0; iSHdr<_this->m_nSamples; iSHdr++)
532
+ for (j=0; j<_this->m_nSamples; j++)
532
533
  {
533
- MODINSTRUMENT *pins = &_this->Ins[iSHdr+1];
534
- pins->nLoopStart = bswapBE16(pmsh->sample[iSHdr].rep) << 1;
535
- pins->nLoopEnd = pins->nLoopStart + (bswapBE16(pmsh->sample[iSHdr].replen) << 1);
536
- pins->nVolume = (pmsh->sample[iSHdr].svol << 2);
534
+ MODINSTRUMENT *pins = &_this->Ins[j+1];
535
+ pins->nLoopStart = bswapBE16(pmsh->sample[j].rep) << 1;
536
+ pins->nLoopEnd = pins->nLoopStart + (bswapBE16(pmsh->sample[j].replen) << 1);
537
+ pins->nVolume = (pmsh->sample[j].svol << 2);
537
538
  pins->nGlobalVol = 64;
538
539
  if (pins->nVolume > 256) pins->nVolume = 256;
539
- pins->RelativeTone = -12 * pmsh->sample[iSHdr].strans;
540
+ pins->RelativeTone = -12 * pmsh->sample[j].strans;
540
541
  pins->nPan = 128;
541
542
  if (pins->nLoopEnd) pins->uFlags |= CHN_LOOP;
542
543
  }
@@ -554,18 +555,22 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
554
555
  {
555
556
  UINT nOrders, nSections;
556
557
  UINT nTrks = bswapBE16(pmsh2->numtracks);
558
+ DWORD playseqtable;
559
+ UINT numplayseqs;
560
+ DWORD sectiontable;
557
561
  if ((nTrks >= 4) && (nTrks <= 32)) _this->m_nChannels = nTrks;
558
- DWORD playseqtable = bswapBE32(pmsh2->playseqtable);
559
- UINT numplayseqs = bswapBE16(pmsh2->numpseqs);
562
+ playseqtable = bswapBE32(pmsh2->playseqtable);
563
+ numplayseqs = bswapBE16(pmsh2->numpseqs);
560
564
  if (!numplayseqs) numplayseqs = 1;
561
565
  nOrders = 0;
562
566
  nSections = bswapBE16(pmsh2->numsections);
563
- DWORD sectiontable = bswapBE32(pmsh2->sectiontable);
567
+ sectiontable = bswapBE32(pmsh2->sectiontable);
564
568
  if ((!nSections) || (!sectiontable) || (sectiontable >= dwMemLength-2)) nSections = 1;
565
569
  nOrders = 0;
566
- for (UINT iSection=0; iSection<nSections; iSection++)
570
+ for (j=0; j<nSections; j++)
567
571
  {
568
572
  UINT nplayseq = 0;
573
+ UINT pseq = 0;
569
574
  if ((sectiontable) && (sectiontable < dwMemLength-2))
570
575
  {
571
576
  nplayseq = lpStream[sectiontable+1];
@@ -574,7 +579,6 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
574
579
  {
575
580
  nSections = 0;
576
581
  }
577
- UINT pseq = 0;
578
582
 
579
583
  if ((playseqtable) && (playseqtable < dwMemLength - 4) && ((nplayseq+1)*4 < dwMemLength - playseqtable))
580
584
  {
@@ -584,10 +588,10 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
584
588
  (pseq < dwMemLength - sizeof(MMD2PLAYSEQ)))
585
589
  {
586
590
  const MMD2PLAYSEQ *pmps = (MMD2PLAYSEQ *)(lpStream + pseq);
587
- UINT n = bswapBE16(pmps->length);
591
+ UINT i, n = bswapBE16(pmps->length);
588
592
  if (n < (dwMemLength - (pseq + sizeof(*pmps)) + sizeof(pmps->seq)) / sizeof(pmps->seq[0]))
589
593
  {
590
- for (UINT i=0; i<n; i++)
594
+ for (i=0; i<n; i++)
591
595
  {
592
596
  UINT seqval = pmps->seq[i] >> 8;
593
597
  if ((seqval < wNumBlocks) && (nOrders < MAX_ORDERS-1))
@@ -607,25 +611,28 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
607
611
  // Channel Split
608
612
  if ((_this->m_nChannels == 4) && (pmsh->flags & MMD_FLAG_8CHANNEL))
609
613
  {
610
- for (UINT i8ch=0; i8ch<4; i8ch++)
614
+ for (j=0; j<4; j++)
611
615
  {
612
- if (pmex->channelsplit[i8ch]) _this->m_nChannels++;
616
+ if (pmex->channelsplit[j]) _this->m_nChannels++;
613
617
  }
614
618
  }
615
619
  }
616
620
  // Reading samples
617
621
  if (dwSmplArr > dwMemLength - 4*_this->m_nSamples) return TRUE;
618
622
  pdwTable = (LPDWORD)(lpStream + dwSmplArr);
619
- for (UINT iSmp=0; iSmp<_this->m_nSamples; iSmp++) if (pdwTable[iSmp])
623
+ for (j=0; j<_this->m_nSamples; j++) if (pdwTable[j])
620
624
  {
621
- UINT dwPos = bswapBE32(pdwTable[iSmp]);
625
+ MMDSAMPLEHEADER *psdh;
626
+ LPSTR psdata;
627
+ UINT dwPos = bswapBE32(pdwTable[j]);
628
+ UINT len, flags, stype, bLimit;
622
629
  if ((dwPos >= dwMemLength) || (dwPos + sizeof(MMDSAMPLEHEADER) >= dwMemLength)) continue;
623
- MMDSAMPLEHEADER *psdh = (MMDSAMPLEHEADER *)(lpStream + dwPos);
624
- UINT len = bswapBE32(psdh->length);
630
+ psdh = (MMDSAMPLEHEADER *)(lpStream + dwPos);
631
+ len = bswapBE32(psdh->length);
625
632
  if ((len > MAX_SAMPLE_LENGTH) || (dwPos + len + 6 > dwMemLength)) len = 0;
626
- UINT flags = RS_PCM8S, stype = bswapBE16(psdh->type);
627
- LPSTR psdata = (LPSTR)(lpStream + dwPos + 6);
628
- UINT bLimit = dwMemLength - dwPos - 6;
633
+ flags = RS_PCM8S, stype = bswapBE16(psdh->type);
634
+ psdata = (LPSTR)(lpStream + dwPos + 6);
635
+ bLimit = dwMemLength - dwPos - 6;
629
636
  if (stype & 0x80)
630
637
  {
631
638
  psdata += (stype & 0x20) ? 14 : 6;
@@ -634,7 +641,7 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
634
641
  {
635
642
  if (stype & 0x10)
636
643
  {
637
- _this->Ins[iSmp+1].uFlags |= CHN_16BIT;
644
+ _this->Ins[j+1].uFlags |= CHN_16BIT;
638
645
  len /= 2;
639
646
  flags = (stype & 0x20) ? RS_STPCM16M : RS_PCM16M;
640
647
  } else
@@ -643,8 +650,8 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
643
650
  }
644
651
  if (stype & 0x20) len /= 2;
645
652
  }
646
- _this->Ins[iSmp+1].nLength = len;
647
- CSoundFile_ReadSample(_this, &_this->Ins[iSmp+1], flags, psdata, bLimit);
653
+ _this->Ins[j+1].nLength = len;
654
+ CSoundFile_ReadSample(_this, &_this->Ins[j+1], flags, psdata, bLimit);
648
655
  }
649
656
  // Reading patterns (blocks)
650
657
  if (wNumBlocks > MAX_PATTERNS) wNumBlocks = MAX_PATTERNS;
@@ -652,26 +659,29 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
652
659
  (dwBlockArr > dwMemLength - 4*wNumBlocks)) return TRUE;
653
660
  pdwTable = (LPDWORD)(lpStream + dwBlockArr);
654
661
  playtransp += (version == '3') ? 24 : 48;
655
- for (UINT iBlk=0; iBlk<wNumBlocks; iBlk++)
662
+ for (j=0; j<wNumBlocks; j++)
656
663
  {
657
- UINT dwPos = bswapBE32(pdwTable[iBlk]);
658
- if ((!dwPos) || (dwPos >= dwMemLength) || (dwPos >= dwMemLength - 8)) continue;
664
+ UINT dwPos = bswapBE32(pdwTable[j]);
659
665
  UINT lines = 64, tracks = 4;
666
+ if ((!dwPos) || (dwPos >= dwMemLength) || (dwPos >= dwMemLength - 8)) continue;
660
667
  if (version == '0')
661
668
  {
662
669
  const MMD0BLOCK *pmb = (const MMD0BLOCK *)(lpStream + dwPos);
670
+ MODCOMMAND *p;
671
+ LPBYTE s;
672
+ UINT x, y, maxlen;
663
673
  lines = pmb->lines + 1;
664
674
  tracks = pmb->numtracks;
665
675
  if (!tracks) tracks = _this->m_nChannels;
666
- if ((_this->Patterns[iBlk] = CSoundFile_AllocatePattern(lines, _this->m_nChannels)) == NULL) continue;
667
- _this->PatternSize[iBlk] = lines;
668
- MODCOMMAND *p = _this->Patterns[iBlk];
669
- LPBYTE s = (LPBYTE)(lpStream + dwPos + 2);
670
- UINT maxlen = tracks*lines*3;
676
+ if ((_this->Patterns[j] = CSoundFile_AllocatePattern(lines, _this->m_nChannels)) == NULL) continue;
677
+ _this->PatternSize[j] = lines;
678
+ p = _this->Patterns[j];
679
+ s = (LPBYTE)(lpStream + dwPos + 2);
680
+ maxlen = tracks*lines*3;
671
681
  if (maxlen + dwPos > dwMemLength - 2) break;
672
- for (UINT y=0; y<lines; y++)
682
+ for (y=0; y<lines; y++)
673
683
  {
674
- for (UINT x=0; x<tracks; x++, s+=3) if (x < _this->m_nChannels)
684
+ for (x=0; x<tracks; x++, s+=3) if (x < _this->m_nChannels)
675
685
  {
676
686
  BYTE note = s[0] & 0x3F;
677
687
  BYTE instr = s[1] >> 4;
@@ -681,23 +691,27 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
681
691
  p->instr = instr;
682
692
  p->command = s[1] & 0x0F;
683
693
  p->param = s[2];
684
- // if (!iBlk) Log("%02X.%02X.%02X | ", s[0], s[1], s[2]);
694
+ // if (!j) Log("%02X.%02X.%02X | ", s[0], s[1], s[2]);
685
695
  MedConvert(p, pmsh);
686
696
  p++;
687
697
  }
688
- //if (!iBlk) Log("\n");
698
+ //if (!j) Log("\n");
689
699
  }
690
700
  } else
691
701
  {
692
702
  const MMD1BLOCK *pmb = (MMD1BLOCK *)(lpStream + dwPos);
693
703
  const MMD1BLOCKINFO *pbi = NULL;
694
704
  BYTE *pcmdext = NULL;
705
+ MODCOMMAND *p;
706
+ LPBYTE s;
707
+ DWORD dwBlockInfo;
708
+ UINT x, y, maxlen;
695
709
  lines = (pmb->lines >> 8) + 1;
696
710
  tracks = pmb->numtracks >> 8;
697
711
  if (!tracks) tracks = _this->m_nChannels;
698
- if ((_this->Patterns[iBlk] = CSoundFile_AllocatePattern(lines, _this->m_nChannels)) == NULL) continue;
699
- _this->PatternSize[iBlk] = (WORD)lines;
700
- DWORD dwBlockInfo = bswapBE32(pmb->info);
712
+ if ((_this->Patterns[j] = CSoundFile_AllocatePattern(lines, _this->m_nChannels)) == NULL) continue;
713
+ _this->PatternSize[j] = (WORD)lines;
714
+ dwBlockInfo = bswapBE32(pmb->info);
701
715
  if ((dwBlockInfo) && (dwBlockInfo < dwMemLength - sizeof(MMD1BLOCKINFO)))
702
716
  {
703
717
  pbi = (MMD1BLOCKINFO *)(lpStream + dwBlockInfo);
@@ -713,7 +727,7 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
713
727
  SDL_memcpy(blockname, lpStream + nameofs, namelen);
714
728
  blockname[namelen] = '\0';
715
729
 
716
- CSoundFile_SetPatternName(_this, iBlk, blockname);
730
+ CSoundFile_SetPatternName(_this, j, blockname);
717
731
  }
718
732
  }
719
733
  if (pbi->cmdexttable)
@@ -729,13 +743,13 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
729
743
  }
730
744
  }
731
745
  }
732
- MODCOMMAND *p = _this->Patterns[iBlk];
733
- LPBYTE s = (LPBYTE)(lpStream + dwPos + 8);
734
- UINT maxlen = tracks*lines*4;
746
+ p = _this->Patterns[j];
747
+ s = (LPBYTE)(lpStream + dwPos + 8);
748
+ maxlen = tracks*lines*4;
735
749
  if (maxlen + dwPos > dwMemLength - 8) break;
736
- for (UINT y=0; y<lines; y++)
750
+ for (y=0; y<lines; y++)
737
751
  {
738
- for (UINT x=0; x<tracks; x++, s+=4) if (x < _this->m_nChannels)
752
+ for (x=0; x<tracks; x++, s+=4) if (x < _this->m_nChannels)
739
753
  {
740
754
  BYTE note = s[0];
741
755
  if ((note) && (note <= 132))
@@ -757,10 +771,10 @@ BOOL CSoundFile_ReadMed(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
757
771
  }
758
772
  }
759
773
  // Setup channel pan positions
760
- for (UINT iCh=0; iCh<_this->m_nChannels; iCh++)
774
+ for (j=0; j<_this->m_nChannels; j++)
761
775
  {
762
- _this->ChnSettings[iCh].nPan = (((iCh&3) == 1) || ((iCh&3) == 2)) ? 0xC0 : 0x40;
763
- _this->ChnSettings[iCh].nVolume = 64;
776
+ _this->ChnSettings[j].nPan = (((j&3) == 1) || ((j&3) == 2)) ? 0xC0 : 0x40;
777
+ _this->ChnSettings[j].nVolume = 64;
764
778
  }
765
779
  return TRUE;
766
780
  }
@@ -102,7 +102,9 @@ BOOL CSoundFile_ReadMod(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
102
102
  char s[1024]; // changed from CHAR
103
103
  DWORD dwMemPos, dwTotalSampleLen;
104
104
  PMODMAGIC pMagic;
105
- UINT nErr;
105
+ UINT nbp, nbpbuggy, nbpbuggy2, norders;
106
+ UINT i, nErr;
107
+ DWORD dwWowTest, dwErrCheck;
106
108
 
107
109
  if ((!lpStream) || (dwMemLength < 0x600)) return FALSE;
108
110
  dwMemPos = 20;
@@ -131,7 +133,7 @@ BOOL CSoundFile_ReadMod(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
131
133
  // Load Samples
132
134
  nErr = 0;
133
135
  dwTotalSampleLen = 0;
134
- for (UINT i=1; i<=_this->m_nSamples; i++)
136
+ for (i=1; i<=_this->m_nSamples; i++)
135
137
  {
136
138
  PMODSAMPLE pms = (PMODSAMPLE)(lpStream+dwMemPos);
137
139
  MODINSTRUMENT *psmp = &_this->Ins[i];
@@ -192,8 +194,6 @@ BOOL CSoundFile_ReadMod(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
192
194
  SDL_memset(_this->Order, 0,sizeof(_this->Order));
193
195
  SDL_memcpy(_this->Order, pMagic->Orders, 128);
194
196
 
195
- UINT nbp, nbpbuggy, nbpbuggy2, norders;
196
-
197
197
  norders = pMagic->nOrders;
198
198
  if ((!norders) || (norders > 0x80))
199
199
  {
@@ -203,23 +203,23 @@ BOOL CSoundFile_ReadMod(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
203
203
  nbpbuggy = 0;
204
204
  nbpbuggy2 = 0;
205
205
  nbp = 0;
206
- for (UINT iord=0; iord<128; iord++)
206
+ for (i=0; i<128; i++)
207
207
  {
208
- UINT i = _this->Order[iord];
209
- if ((i < 0x80) && (nbp <= i))
208
+ UINT j = _this->Order[i];
209
+ if ((j < 0x80) && (nbp <= j))
210
210
  {
211
- nbp = i+1;
212
- if (iord<norders) nbpbuggy = nbp;
211
+ nbp = j+1;
212
+ if (i<norders) nbpbuggy = nbp;
213
213
  }
214
- if (i >= nbpbuggy2) nbpbuggy2 = i+1;
214
+ if (j >= nbpbuggy2) nbpbuggy2 = j+1;
215
215
  }
216
- for (UINT iend=norders; iend<MAX_ORDERS; iend++) _this->Order[iend] = 0xFF;
216
+ for (i=norders; i<MAX_ORDERS; i++) _this->Order[i] = 0xFF;
217
217
  norders--;
218
218
  _this->m_nRestartPos = pMagic->nRestartPos;
219
219
  if (_this->m_nRestartPos >= 0x78) _this->m_nRestartPos = 0;
220
220
  if (_this->m_nRestartPos + 1 >= (UINT)norders) _this->m_nRestartPos = 0;
221
221
  if (!nbp) return FALSE;
222
- DWORD dwWowTest = dwTotalSampleLen+dwMemPos;
222
+ dwWowTest = dwTotalSampleLen+dwMemPos;
223
223
  if ((IsMagic(pMagic->Magic, "M.K.")) && (dwWowTest + nbp*8*256 == dwMemLength)) _this->m_nChannels = 8;
224
224
  if ((nbp != nbpbuggy) && (dwWowTest + nbp*_this->m_nChannels*256 != dwMemLength))
225
225
  {
@@ -239,25 +239,28 @@ BOOL CSoundFile_ReadMod(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
239
239
  _this->m_nMinPeriod = 14 << 2;
240
240
  _this->m_nMaxPeriod = 3424 << 2;
241
241
  // Setting channels pan
242
- for (UINT ich=0; ich<_this->m_nChannels; ich++)
242
+ for (i=0; i<_this->m_nChannels; i++)
243
243
  {
244
- _this->ChnSettings[ich].nVolume = 64;
244
+ _this->ChnSettings[i].nVolume = 64;
245
245
  if (_this->gdwSoundSetup & SNDMIX_MAXDEFAULTPAN)
246
- _this->ChnSettings[ich].nPan = (((ich&3)==1) || ((ich&3)==2)) ? 256 : 0;
246
+ _this->ChnSettings[i].nPan = (((i&3)==1) || ((i&3)==2)) ? 256 : 0;
247
247
  else
248
- _this->ChnSettings[ich].nPan = (((ich&3)==1) || ((ich&3)==2)) ? 0xC0 : 0x40;
248
+ _this->ChnSettings[i].nPan = (((i&3)==1) || ((i&3)==2)) ? 0xC0 : 0x40;
249
249
  }
250
250
  // Reading channels
251
- for (UINT ipat=0; ipat<nbp; ipat++)
251
+ for (i=0; i<nbp; i++)
252
252
  {
253
- if (ipat < MAX_PATTERNS)
253
+ if (i < MAX_PATTERNS)
254
254
  {
255
- if ((_this->Patterns[ipat] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL) break;
256
- _this->PatternSize[ipat] = 64;
255
+ MODCOMMAND *m;
256
+ LPCBYTE p;
257
+ UINT j;
258
+ if ((_this->Patterns[i] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL) break;
259
+ _this->PatternSize[i] = 64;
257
260
  if (dwMemPos + _this->m_nChannels*256 >= dwMemLength) break;
258
- MODCOMMAND *m = _this->Patterns[ipat];
259
- LPCBYTE p = lpStream + dwMemPos;
260
- for (UINT j=_this->m_nChannels*64; j; m++,p+=4,j--)
261
+ m = _this->Patterns[i];
262
+ p = lpStream + dwMemPos;
263
+ for (j=_this->m_nChannels*64; j; m++,p+=4,j--)
261
264
  {
262
265
  BYTE A0=p[0], A1=p[1], A2=p[2], A3=p[3];
263
266
  UINT n = ((((UINT)A0 & 0x0F) << 8) | (A1));
@@ -271,11 +274,12 @@ BOOL CSoundFile_ReadMod(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
271
274
  dwMemPos += _this->m_nChannels*256;
272
275
  }
273
276
  // Reading instruments
274
- DWORD dwErrCheck = 0;
275
- for (UINT ismp=1; ismp<=_this->m_nSamples; ismp++) if (_this->Ins[ismp].nLength)
277
+ dwErrCheck = 0;
278
+ for (i=1; i<=_this->m_nSamples; i++) if (_this->Ins[i].nLength)
276
279
  {
277
280
  LPSTR p = (LPSTR)(lpStream+dwMemPos);
278
281
  UINT flags = 0;
282
+ DWORD dwSize;
279
283
  if (dwMemPos + 5 >= dwMemLength) break;
280
284
  if (!SDL_strncmp(p, "ADPCM", 5))
281
285
  {
@@ -283,7 +287,7 @@ BOOL CSoundFile_ReadMod(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
283
287
  p += 5;
284
288
  dwMemPos += 5;
285
289
  }
286
- DWORD dwSize = CSoundFile_ReadSample(_this, &_this->Ins[ismp], flags, p, dwMemLength - dwMemPos);
290
+ dwSize = CSoundFile_ReadSample(_this, &_this->Ins[i], flags, p, dwMemLength - dwMemPos);
287
291
  if (dwSize)
288
292
  {
289
293
  dwMemPos += dwSize;