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
@@ -229,18 +229,20 @@ BOOL CSoundFile_ReadGDM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
229
229
  const SAMPLEGDM *psmp;
230
230
  BYTE sflags[256];
231
231
  DWORD pos;
232
- UINT npat;
232
+ UINT npat, i;
233
+ DWORD ordersPos, patternsPos, samplesPos, sampleDataPos;
234
+ UINT nPatterns, nOrders, nSamples;
233
235
 
234
236
  if ((!lpStream) || (dwMemLength < sizeof(FILEHEADERGDM))) return FALSE;
235
237
  if ((fixu32(pfh->sig) != GDM_SIG) || (fixu32(pfh->sig2) != GMFS_SIG)) return FALSE;
236
238
 
237
- DWORD ordersPos = fixu32(pfh->ordersPos);
238
- DWORD patternsPos = fixu32(pfh->patternsPos);
239
- DWORD samplesPos = fixu32(pfh->samplesPos);
240
- DWORD sampleDataPos = fixu32(pfh->sampleDataPos);
241
- UINT nPatterns = pfh->nPatterns + 1;
242
- UINT nOrders = pfh->nOrders + 1;
243
- UINT nSamples = pfh->nSamples + 1;
239
+ ordersPos = fixu32(pfh->ordersPos);
240
+ patternsPos = fixu32(pfh->patternsPos);
241
+ samplesPos = fixu32(pfh->samplesPos);
242
+ sampleDataPos = fixu32(pfh->sampleDataPos);
243
+ nPatterns = pfh->nPatterns + 1;
244
+ nOrders = pfh->nOrders + 1;
245
+ nSamples = pfh->nSamples + 1;
244
246
 
245
247
  if (nPatterns > MAX_PATTERNS) nPatterns = MAX_PATTERNS;
246
248
  if (nOrders > MAX_ORDERS) nOrders = MAX_ORDERS;
@@ -265,7 +267,7 @@ BOOL CSoundFile_ReadGDM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
265
267
  _this->m_nSamples = nSamples;
266
268
 
267
269
  // Get initial panning.
268
- for (UINT i = 0; i < 32; i++)
270
+ for (i = 0; i < 32; i++)
269
271
  {
270
272
  if (pfh->panning[i] < 16)
271
273
  {
@@ -276,10 +278,10 @@ BOOL CSoundFile_ReadGDM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
276
278
 
277
279
  // Samples.
278
280
  psmp = (const SAMPLEGDM *)(lpStream + samplesPos);
279
- for (UINT nins = 0; nins < nSamples; nins++)
281
+ for (i = 0; i < nSamples; i++)
280
282
  {
281
- const SAMPLEGDM *smp = &psmp[nins];
282
- MODINSTRUMENT *ins = &_this->Ins[nins + 1];
283
+ const SAMPLEGDM *smp = &psmp[i];
284
+ MODINSTRUMENT *ins = &_this->Ins[i + 1];
283
285
 
284
286
  DWORD len = fixu32(smp->length);
285
287
  DWORD loopstart = fixu32(smp->loopstart);
@@ -290,7 +292,7 @@ BOOL CSoundFile_ReadGDM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
290
292
  // Note: BWSB and 2GDM don't support LZW, stereo samples, sample panning.
291
293
  if (flags & S_16BIT)
292
294
  {
293
- sflags[nins] = RS_PCM16U;
295
+ sflags[i] = RS_PCM16U;
294
296
  // Due to a 2GDM bug, the sample size is halved.
295
297
  // (Note BWSB doesn't even check for these anyway.)
296
298
  len /= 2;
@@ -298,7 +300,7 @@ BOOL CSoundFile_ReadGDM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
298
300
  loopend /= 2;
299
301
  }
300
302
  else
301
- sflags[nins] = RS_PCM8U;
303
+ sflags[i] = RS_PCM8U;
302
304
 
303
305
  if (len > MAX_SAMPLE_LENGTH) len = MAX_SAMPLE_LENGTH;
304
306
  if (loopend > len) loopend = len;
@@ -379,23 +381,27 @@ BadPattern:
379
381
  UINT patLen = fixu16(lpStream + pos);
380
382
  DWORD patEnd = pos + patLen;
381
383
  UINT row = 0;
384
+ MODCOMMAND *m;
382
385
 
383
386
  pos += 2;
384
387
 
385
388
  _this->Patterns[npat] = CSoundFile_AllocatePattern(_this->PatternSize[npat], _this->m_nChannels);
386
389
  if (!_this->Patterns[npat]) break;
387
390
 
388
- MODCOMMAND *m = _this->Patterns[npat];
391
+ m = _this->Patterns[npat];
389
392
  while (pos < patEnd)
390
393
  {
391
394
  while (pos < patEnd)
392
395
  {
393
- BYTE dat = lpStream[pos++];
396
+ MODCOMMAND *ev;
397
+ BYTE channel, dat;
398
+
399
+ dat = lpStream[pos++];
394
400
  if (!dat)
395
401
  break;
396
402
 
397
- BYTE channel = dat & 0x1f;
398
- MODCOMMAND *ev = &m[row * _this->m_nChannels + channel];
403
+ channel = dat & 0x1f;
404
+ ev = &m[row * _this->m_nChannels + channel];
399
405
 
400
406
  if (dat & 0x20)
401
407
  {
@@ -431,15 +437,15 @@ BadPattern:
431
437
 
432
438
  // Reading Samples
433
439
  pos = sampleDataPos;
434
- for (UINT n = 0; n < nSamples; n++)
440
+ for (i = 0; i < nSamples; i++)
435
441
  {
436
- MODINSTRUMENT *ins = &_this->Ins[n + 1];
442
+ MODINSTRUMENT *ins = &_this->Ins[i + 1];
437
443
  UINT len = ins->nLength;
438
444
 
439
445
  if (pos >= dwMemLength) break;
440
446
  if (len)
441
447
  {
442
- len = CSoundFile_ReadSample(_this, ins, sflags[n], (LPSTR)(lpStream + pos), dwMemLength - pos);
448
+ len = CSoundFile_ReadSample(_this, ins, sflags[i], (LPSTR)(lpStream + pos), dwMemLength - pos);
443
449
  pos += len;
444
450
  }
445
451
  }
@@ -19,13 +19,14 @@ BYTE autovibit2xm[8] =
19
19
  static BOOL ITInstrToMPT(const void *p, INSTRUMENTHEADER *penv, UINT trkvers)
20
20
  //--------------------------------------------------------------------------------
21
21
  {
22
+ UINT j;
22
23
  if (trkvers < 0x0200)
23
24
  {
24
25
  const ITOLDINSTRUMENT *pis = (const ITOLDINSTRUMENT *)p;
25
26
  SDL_memcpy(penv->filename, pis->filename, 12);
26
27
  penv->nFadeOut = bswapLE16(pis->fadeout) << 6;
27
28
  penv->nGlobalVol = 64;
28
- for (UINT j=0; j<NOTE_MAX; j++)
29
+ for (j=0; j<NOTE_MAX; j++)
29
30
  {
30
31
  UINT note = pis->keyboard[j*2];
31
32
  UINT ins = pis->keyboard[j*2+1];
@@ -41,14 +42,14 @@ static BOOL ITInstrToMPT(const void *p, INSTRUMENTHEADER *penv, UINT trkvers)
41
42
  penv->nVolSustainBegin = pis->sls;
42
43
  penv->nVolSustainEnd = pis->sle;
43
44
  penv->nVolEnv = 25;
44
- for (UINT ev=0; ev<25; ev++)
45
+ for (j=0; j<25; j++)
45
46
  {
46
- if ((penv->VolPoints[ev] = pis->nodes[ev*2]) == 0xFF)
47
+ if ((penv->VolPoints[j] = pis->nodes[j*2]) == 0xFF)
47
48
  {
48
- penv->nVolEnv = ev;
49
+ penv->nVolEnv = j;
49
50
  break;
50
51
  }
51
- penv->VolEnv[ev] = pis->nodes[ev*2+1];
52
+ penv->VolEnv[j] = pis->nodes[j*2+1];
52
53
  }
53
54
  penv->nNNA = pis->nna;
54
55
  penv->nDCT = pis->dnc;
@@ -63,7 +64,7 @@ static BOOL ITInstrToMPT(const void *p, INSTRUMENTHEADER *penv, UINT trkvers)
63
64
  penv->nFadeOut = bswapLE16(pis->fadeout) << 5;
64
65
  penv->nGlobalVol = pis->gbv >> 1;
65
66
  if (penv->nGlobalVol > 64) penv->nGlobalVol = 64;
66
- for (UINT j=0; j<NOTE_MAX; j++)
67
+ for (j=0; j<NOTE_MAX; j++)
67
68
  {
68
69
  UINT note = pis->keyboard[j*2];
69
70
  UINT ins = pis->keyboard[j*2+1];
@@ -107,14 +108,14 @@ static BOOL ITInstrToMPT(const void *p, INSTRUMENTHEADER *penv, UINT trkvers)
107
108
  penv->nPitchSustainBegin = pis->pitchenv.slb;
108
109
  penv->nPitchSustainEnd = pis->pitchenv.sle;
109
110
  // Envelopes Data
110
- for (UINT ev=0; ev<25; ev++)
111
+ for (j=0; j<25; j++)
111
112
  {
112
- penv->VolEnv[ev] = pis->volenv.data[ev*3];
113
- penv->VolPoints[ev] = (pis->volenv.data[ev*3+2] << 8) | (pis->volenv.data[ev*3+1]);
114
- penv->PanEnv[ev] = pis->panenv.data[ev*3] + 32;
115
- penv->PanPoints[ev] = (pis->panenv.data[ev*3+2] << 8) | (pis->panenv.data[ev*3+1]);
116
- penv->PitchEnv[ev] = pis->pitchenv.data[ev*3] + 32;
117
- penv->PitchPoints[ev] = (pis->pitchenv.data[ev*3+2] << 8) | (pis->pitchenv.data[ev*3+1]);
113
+ penv->VolEnv[j] = pis->volenv.data[j*3];
114
+ penv->VolPoints[j] = (pis->volenv.data[j*3+2] << 8) | (pis->volenv.data[j*3+1]);
115
+ penv->PanEnv[j] = pis->panenv.data[j*3] + 32;
116
+ penv->PanPoints[j] = (pis->panenv.data[j*3+2] << 8) | (pis->panenv.data[j*3+1]);
117
+ penv->PitchEnv[j] = pis->pitchenv.data[j*3] + 32;
118
+ penv->PitchPoints[j] = (pis->pitchenv.data[j*3+2] << 8) | (pis->pitchenv.data[j*3+1]);
118
119
  }
119
120
  penv->nNNA = pis->nna;
120
121
  penv->nDCT = pis->dct;
@@ -144,10 +145,10 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
144
145
  DWORD patpos[MAX_PATTERNS];
145
146
  BYTE chnmask[64];//, channels_used[64]
146
147
  MODCOMMAND lastvalue[64];
147
- UINT j;
148
+ ITFILEHEADER pifh;
149
+ UINT j, npatterns, siz;
148
150
 
149
151
  if ((!lpStream) || (dwMemLength < sizeof(ITFILEHEADER))) return FALSE;
150
- ITFILEHEADER pifh;
151
152
  SDL_memcpy(&pifh, lpStream, sizeof(pifh));
152
153
 
153
154
  pifh.id = bswapLE32(pifh.id);
@@ -185,48 +186,49 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
185
186
  if (pifh.tempo) _this->m_nDefaultTempo = pifh.tempo;
186
187
  _this->m_nSongPreAmp = pifh.mv & 0x7F;
187
188
  // Reading Channels Pan Positions
188
- for (int ipan=0; ipan<64; ipan++) if (pifh.chnpan[ipan] != 0xFF)
189
+ for (j=0; j<64; j++) if (pifh.chnpan[j] != 0xFF)
189
190
  {
190
- _this->ChnSettings[ipan].nVolume = pifh.chnvol[ipan];
191
- _this->ChnSettings[ipan].nPan = 128;
192
- if (pifh.chnpan[ipan] & 0x80) _this->ChnSettings[ipan].dwFlags |= CHN_MUTE;
193
- UINT n = pifh.chnpan[ipan] & 0x7F;
194
- if (n <= 64) _this->ChnSettings[ipan].nPan = n << 2;
195
- if (n == 100) _this->ChnSettings[ipan].dwFlags |= CHN_SURROUND;
191
+ UINT n;
192
+ _this->ChnSettings[j].nVolume = pifh.chnvol[j];
193
+ _this->ChnSettings[j].nPan = 128;
194
+ if (pifh.chnpan[j] & 0x80) _this->ChnSettings[j].dwFlags |= CHN_MUTE;
195
+ n = pifh.chnpan[j] & 0x7F;
196
+ if (n <= 64) _this->ChnSettings[j].nPan = n << 2;
197
+ if (n == 100) _this->ChnSettings[j].dwFlags |= CHN_SURROUND;
196
198
  }
197
199
  if (_this->m_nChannels < 4) _this->m_nChannels = 4;
198
200
  // Reading orders
199
- UINT nordsize = pifh.ordnum;
200
- if (nordsize > MAX_ORDERS) nordsize = MAX_ORDERS;
201
- SDL_memcpy(_this->Order, lpStream+dwMemPos, nordsize);
201
+ siz = pifh.ordnum;
202
+ if (siz > MAX_ORDERS) siz = MAX_ORDERS;
203
+ SDL_memcpy(_this->Order, lpStream+dwMemPos, siz);
202
204
  dwMemPos += pifh.ordnum;
203
205
  // Reading Instrument Offsets
204
206
  SDL_memset(inspos, 0, sizeof(inspos));
205
- UINT inspossize = pifh.insnum;
206
- if (inspossize > MAX_INSTRUMENTS) inspossize = MAX_INSTRUMENTS;
207
- inspossize <<= 2;
208
- SDL_memcpy(inspos, lpStream+dwMemPos, inspossize);
209
- for (j=0; j < (inspossize>>2); j++) {
207
+ siz = pifh.insnum;
208
+ if (siz > MAX_INSTRUMENTS) siz = MAX_INSTRUMENTS;
209
+ siz <<= 2;
210
+ SDL_memcpy(inspos, lpStream+dwMemPos, siz);
211
+ for (j=0; j < (siz>>2); j++) {
210
212
  inspos[j] = bswapLE32(inspos[j]);
211
213
  }
212
214
  dwMemPos += pifh.insnum * 4;
213
215
  // Reading Samples Offsets
214
216
  SDL_memset(smppos, 0, sizeof(smppos));
215
- UINT smppossize = pifh.smpnum;
216
- if (smppossize > MAX_SAMPLES) smppossize = MAX_SAMPLES;
217
- smppossize <<= 2;
218
- SDL_memcpy(smppos, lpStream+dwMemPos, smppossize);
219
- for (j=0; j < (smppossize>>2); j++) {
217
+ siz = pifh.smpnum;
218
+ if (siz > MAX_SAMPLES) siz = MAX_SAMPLES;
219
+ siz <<= 2;
220
+ SDL_memcpy(smppos, lpStream+dwMemPos, siz);
221
+ for (j=0; j < (siz>>2); j++) {
220
222
  smppos[j] = bswapLE32(smppos[j]);
221
223
  }
222
224
  dwMemPos += pifh.smpnum * 4;
223
225
  // Reading Patterns Offsets
224
226
  SDL_memset(patpos, 0, sizeof(patpos));
225
- UINT patpossize = pifh.patnum;
226
- if (patpossize > MAX_PATTERNS) patpossize = MAX_PATTERNS;
227
- patpossize <<= 2;
228
- SDL_memcpy(patpos, lpStream+dwMemPos, patpossize);
229
- for (j=0; j < (patpossize>>2); j++) {
227
+ siz = pifh.patnum;
228
+ if (siz > MAX_PATTERNS) siz = MAX_PATTERNS;
229
+ siz <<= 2;
230
+ SDL_memcpy(patpos, lpStream+dwMemPos, siz);
231
+ for (j=0; j < (siz>>2); j++) {
230
232
  patpos[j] = bswapLE32(patpos[j]);
231
233
  }
232
234
  dwMemPos += pifh.patnum * 4;
@@ -282,29 +284,32 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
282
284
  dwMemPos += CSoundFile_LoadMixPlugins(_this, lpStream+dwMemPos, dwMemLength-dwMemPos);
283
285
  }
284
286
  // Checking for unused channels
285
- UINT npatterns = pifh.patnum;
287
+ npatterns = pifh.patnum;
286
288
  if (npatterns > MAX_PATTERNS) npatterns = MAX_PATTERNS;
287
- for (UINT patchk=0; patchk<npatterns; patchk++)
289
+ for (j=0; j<npatterns; j++)
288
290
  {
291
+ UINT i, len, rows, nrow;
292
+ const BYTE *p;
289
293
  SDL_memset(chnmask, 0, sizeof(chnmask));
290
- if ((!patpos[patchk]) || ((DWORD)patpos[patchk] >= dwMemLength - 4)) continue;
291
- UINT len = bswapLE16(*((WORD *)(lpStream+patpos[patchk])));
292
- UINT rows = bswapLE16(*((WORD *)(lpStream+patpos[patchk]+2)));
294
+ if ((!patpos[j]) || ((DWORD)patpos[j] >= dwMemLength - 4)) continue;
295
+ len = bswapLE16(*((WORD *)(lpStream+patpos[j])));
296
+ rows = bswapLE16(*((WORD *)(lpStream+patpos[j]+2)));
293
297
  if ((rows < 4) || (rows > 256)) continue;
294
- if (8+len > dwMemLength || patpos[patchk] > dwMemLength - (8+len)) continue;
295
- UINT i = 0;
296
- const BYTE *p = lpStream+patpos[patchk]+8;
297
- UINT nrow = 0;
298
+ if (8+len > dwMemLength || patpos[j] > dwMemLength - (8+len)) continue;
299
+ p = lpStream+patpos[j]+8;
300
+ i = nrow = 0;
298
301
  while (nrow<rows)
299
302
  {
303
+ UINT ch;
304
+ BYTE b;
300
305
  if (i >= len) break;
301
- BYTE b = p[i++];
306
+ b = p[i++];
302
307
  if (!b)
303
308
  {
304
309
  nrow++;
305
310
  continue;
306
311
  }
307
- UINT ch = b & 0x7F;
312
+ ch = b & 0x7F;
308
313
  if (ch) ch = (ch - 1) & 0x3F;
309
314
  if (b & 0x80)
310
315
  {
@@ -331,24 +336,24 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
331
336
  _this->m_nInstruments = 0;
332
337
  if (pifh.flags & 0x04) _this->m_nInstruments = pifh.insnum;
333
338
  if (_this->m_nInstruments >= MAX_INSTRUMENTS) _this->m_nInstruments = MAX_INSTRUMENTS-1;
334
- for (UINT nins=0; nins<_this->m_nInstruments; nins++)
339
+ for (j=0; j<_this->m_nInstruments; j++)
335
340
  {
336
- if ((inspos[nins] > 0) && dwMemLength > sizeof(ITOLDINSTRUMENT) &&
337
- (inspos[nins] < dwMemLength - sizeof(ITOLDINSTRUMENT)))
341
+ if ((inspos[j] > 0) && dwMemLength > sizeof(ITOLDINSTRUMENT) &&
342
+ (inspos[j] < dwMemLength - sizeof(ITOLDINSTRUMENT)))
338
343
  {
339
344
  INSTRUMENTHEADER *penv = (INSTRUMENTHEADER *) SDL_calloc(1, sizeof (INSTRUMENTHEADER));
340
345
  if (!penv) continue;
341
- _this->Headers[nins+1] = penv;
342
- ITInstrToMPT(lpStream + inspos[nins], penv, pifh.cmwt);
346
+ _this->Headers[j+1] = penv;
347
+ ITInstrToMPT(lpStream + inspos[j], penv, pifh.cmwt);
343
348
  }
344
349
  }
345
350
  // Reading Samples
346
351
  _this->m_nSamples = pifh.smpnum;
347
352
  if (_this->m_nSamples >= MAX_SAMPLES) _this->m_nSamples = MAX_SAMPLES-1;
348
- for (UINT nsmp=0; nsmp<pifh.smpnum; nsmp++) if ((smppos[nsmp]) && (smppos[nsmp] <= dwMemLength - sizeof(ITSAMPLESTRUCT)))
353
+ for (j=0; j<pifh.smpnum; j++) if ((smppos[j]) && (smppos[j] <= dwMemLength - sizeof(ITSAMPLESTRUCT)))
349
354
  {
350
355
  ITSAMPLESTRUCT pis;
351
- SDL_memcpy(&pis, lpStream+smppos[nsmp], sizeof (pis));
356
+ SDL_memcpy(&pis, lpStream+smppos[j], sizeof (pis));
352
357
  pis.id = bswapLE32(pis.id);
353
358
  pis.length = bswapLE32(pis.length);
354
359
  pis.loopbegin = bswapLE32(pis.loopbegin);
@@ -360,7 +365,7 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
360
365
 
361
366
  if (pis.id == 0x53504D49)
362
367
  {
363
- MODINSTRUMENT *pins = &_this->Ins[nsmp+1];
368
+ MODINSTRUMENT *pins = &_this->Ins[j+1];
364
369
  pins->uFlags = 0;
365
370
  pins->nLength = 0;
366
371
  pins->nLoopStart = pis.loopbegin;
@@ -387,9 +392,9 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
387
392
  pins->nVibSweep = (pis.vir + 3) / 4;
388
393
  if ((pis.samplepointer) && (pis.samplepointer < dwMemLength) && (pis.length))
389
394
  {
395
+ UINT flags = (pis.cvt & 1) ? RS_PCM8S : RS_PCM8U;
390
396
  pins->nLength = pis.length;
391
397
  if (pins->nLength > MAX_SAMPLE_LENGTH) pins->nLength = MAX_SAMPLE_LENGTH;
392
- UINT flags = (pis.cvt & 1) ? RS_PCM8S : RS_PCM8U;
393
398
  if (pis.flags & 2)
394
399
  {
395
400
  flags += 5;
@@ -404,43 +409,47 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
404
409
  if (pis.flags & 8) flags = ((pifh.cmwt >= 0x215) && (pis.cvt & 4)) ? RS_IT2158 : RS_IT2148;
405
410
  if (pis.flags & 4) flags |= RSF_STEREO;
406
411
  }
407
- CSoundFile_ReadSample(_this, &_this->Ins[nsmp+1], flags, (LPSTR)(lpStream+pis.samplepointer), dwMemLength - pis.samplepointer);
412
+ CSoundFile_ReadSample(_this, &_this->Ins[j+1], flags, (LPSTR)(lpStream+pis.samplepointer), dwMemLength - pis.samplepointer);
408
413
  }
409
414
  }
410
415
  }
411
416
  // Reading Patterns
412
- for (UINT npat=0; npat<npatterns; npat++)
417
+ for (j=0; j<npatterns; j++)
413
418
  {
414
- if ((!patpos[npat]) || ((DWORD)patpos[npat] >= dwMemLength - 4))
419
+ MODCOMMAND *m;
420
+ const BYTE *p;
421
+ UINT i, len, rows, nrow;
422
+ if ((!patpos[j]) || ((DWORD)patpos[j] >= dwMemLength - 4))
415
423
  {
416
- _this->PatternSize[npat] = 64;
417
- _this->Patterns[npat] = CSoundFile_AllocatePattern(64, _this->m_nChannels);
424
+ _this->PatternSize[j] = 64;
425
+ _this->Patterns[j] = CSoundFile_AllocatePattern(64, _this->m_nChannels);
418
426
  continue;
419
427
  }
420
428
 
421
- UINT len = bswapLE16(*((WORD *)(lpStream+patpos[npat])));
422
- UINT rows = bswapLE16(*((WORD *)(lpStream+patpos[npat]+2)));
429
+ len = bswapLE16(*((WORD *)(lpStream+patpos[j])));
430
+ rows = bswapLE16(*((WORD *)(lpStream+patpos[j]+2)));
423
431
  if ((rows < 4) || (rows > 256)) continue;
424
- if (8+len > dwMemLength || patpos[npat] > dwMemLength - (8+len)) continue;
425
- _this->PatternSize[npat] = rows;
426
- if ((_this->Patterns[npat] = CSoundFile_AllocatePattern(rows, _this->m_nChannels)) == NULL) continue;
432
+ if (8+len > dwMemLength || patpos[j] > dwMemLength - (8+len)) continue;
433
+ _this->PatternSize[j] = rows;
434
+ if ((_this->Patterns[j] = CSoundFile_AllocatePattern(rows, _this->m_nChannels)) == NULL) continue;
427
435
  SDL_memset(lastvalue, 0, sizeof(lastvalue));
428
436
  SDL_memset(chnmask, 0, sizeof(chnmask));
429
- MODCOMMAND *m = _this->Patterns[npat];
430
- UINT i = 0;
431
- const BYTE *p = lpStream+patpos[npat]+8;
432
- UINT nrow = 0;
437
+ m = _this->Patterns[j];
438
+ p = lpStream+patpos[j]+8;
439
+ i = nrow = 0;
433
440
  while (nrow<rows)
434
441
  {
442
+ UINT ch;
443
+ BYTE b;
435
444
  if (i >= len) break;
436
- BYTE b = p[i++];
445
+ b = p[i++];
437
446
  if (!b)
438
447
  {
439
448
  nrow++;
440
449
  m+=_this->m_nChannels;
441
450
  continue;
442
451
  }
443
- UINT ch = b & 0x7F;
452
+ ch = b & 0x7F;
444
453
  if (ch) ch = (ch - 1) & 0x3F;
445
454
  if (b & 0x80)
446
455
  {
@@ -467,8 +476,9 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
467
476
  }
468
477
  if (chnmask[ch] & 1) // Note
469
478
  {
479
+ UINT note;
470
480
  if (i >= len) break;
471
- UINT note = p[i++];
481
+ note = p[i++];
472
482
  if (ch < _this->m_nChannels)
473
483
  {
474
484
  if (note < 0x80) note++;
@@ -479,8 +489,9 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
479
489
  }
480
490
  if (chnmask[ch] & 2)
481
491
  {
492
+ UINT instr;
482
493
  if (i >= len) break;
483
- UINT instr = p[i++];
494
+ instr = p[i++];
484
495
  if (ch < _this->m_nChannels)
485
496
  {
486
497
  m[ch].instr = instr;
@@ -489,8 +500,9 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
489
500
  }
490
501
  if (chnmask[ch] & 4)
491
502
  {
503
+ UINT vol;
492
504
  if (i >= len) break;
493
- UINT vol = p[i++];
505
+ vol = p[i++];
494
506
  if (ch < _this->m_nChannels)
495
507
  {
496
508
  // 0-64: Set Volume
@@ -520,9 +532,10 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
520
532
  // Reading command/param
521
533
  if (chnmask[ch] & 8)
522
534
  {
535
+ UINT cmd, param;
523
536
  if (i > len - 2) break;
524
- UINT cmd = p[i++];
525
- UINT param = p[i++];
537
+ cmd = p[i++];
538
+ param = p[i++];
526
539
  if (ch < _this->m_nChannels)
527
540
  {
528
541
  if (cmd)
@@ -537,12 +550,12 @@ BOOL CSoundFile_ReadIT(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
537
550
  }
538
551
  }
539
552
  }
540
- for (UINT ncu=0; ncu<MAX_BASECHANNELS; ncu++)
553
+ for (j=0; j<MAX_BASECHANNELS; j++)
541
554
  {
542
- if (ncu>=_this->m_nChannels)
555
+ if (j>=_this->m_nChannels)
543
556
  {
544
- _this->ChnSettings[ncu].nVolume = 64;
545
- _this->ChnSettings[ncu].dwFlags &= ~CHN_MUTE;
557
+ _this->ChnSettings[j].nVolume = 64;
558
+ _this->ChnSettings[j].dwFlags &= ~CHN_MUTE;
546
559
  }
547
560
  }
548
561
  _this->m_nMinPeriod = 8;
@@ -607,6 +620,7 @@ DWORD ITUnpack8Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dw
607
620
 
608
621
  while (dwLen)
609
622
  {
623
+ DWORD d, dwPos;
610
624
  if (!wCount)
611
625
  {
612
626
  wCount = 0x8000;
@@ -616,10 +630,10 @@ DWORD ITUnpack8Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dw
616
630
  bTemp = bTemp2 = 0;
617
631
  bitbuf = bitnum = 0;
618
632
  }
619
- DWORD d = wCount;
633
+ d = wCount;
620
634
  if (d > dwLen) d = dwLen;
621
635
  // Unpacking
622
- DWORD dwPos = 0;
636
+ dwPos = 0;
623
637
  do
624
638
  {
625
639
  WORD wBits = (WORD)ITReadBits(&bitbuf, &bitnum, &pSrc, pStop, bLeft);
@@ -693,6 +707,7 @@ DWORD ITUnpack16Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD d
693
707
 
694
708
  while (dwLen)
695
709
  {
710
+ DWORD d, dwPos;
696
711
  if (!wCount)
697
712
  {
698
713
  wCount = 0x4000;
@@ -702,10 +717,10 @@ DWORD ITUnpack16Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD d
702
717
  wTemp = wTemp2 = 0;
703
718
  bitbuf = bitnum = 0;
704
719
  }
705
- DWORD d = wCount;
720
+ d = wCount;
706
721
  if (d > dwLen) d = dwLen;
707
722
  // Unpacking
708
- DWORD dwPos = 0;
723
+ dwPos = 0;
709
724
  do
710
725
  {
711
726
  DWORD dwBits = ITReadBits(&bitbuf, &bitnum, &pSrc, pStop, bLeft);
@@ -767,7 +782,7 @@ UINT CSoundFile_LoadMixPlugins(CSoundFile *_this, const void *pData, UINT nLen)
767
782
  //-----------------------------------------------------------
768
783
  {
769
784
  const BYTE *p = (const BYTE *)pData;
770
- UINT nPos = 0;
785
+ UINT nPos = 0, ch;
771
786
 
772
787
  while (nPos+8 < nLen)
773
788
  {
@@ -777,7 +792,7 @@ UINT CSoundFile_LoadMixPlugins(CSoundFile *_this, const void *pData, UINT nLen)
777
792
  if (nPluginSize > nLen-nPos-8) break;;
778
793
  if ((bswapLE32(*(DWORD *)(p+nPos))) == 0x58464843)
779
794
  {
780
- for (UINT ch=0; ch<64; ch++) if (ch*4 < nPluginSize)
795
+ for (ch=0; ch<64; ch++) if (ch*4 < nPluginSize)
781
796
  {
782
797
  _this->ChnSettings[ch].nMixPlugin = bswapLE32(*(DWORD *)(p+nPos+8+ch*4));
783
798
  }