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
@@ -97,6 +97,7 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
97
97
  const DBMFILEHEADER *pfh = (DBMFILEHEADER *)lpStream;
98
98
  DWORD dwMemPos;
99
99
  UINT nOrders, nSamples, nInstruments, nPatterns;
100
+ UINT i;
100
101
 
101
102
  if ((!lpStream) || (dwMemLength <= sizeof(DBMFILEHEADER)) || (!pfh->channels)
102
103
  || (pfh->dbm_id != bswapLE32(DBM_FILE_MAGIC)) || (!pfh->songs) || (pfh->song_id != bswapLE32(DBM_ID_SONG))
@@ -112,10 +113,10 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
112
113
  _this->m_nChannels = bswapBE16(pfh->channels);
113
114
  if (_this->m_nChannels < 4) _this->m_nChannels = 4;
114
115
  if (_this->m_nChannels > 64) _this->m_nChannels = 64;
115
- for (UINT iOrd=0; iOrd < nOrders; iOrd++)
116
+ for (i=0; i < nOrders; i++)
116
117
  {
117
- _this->Order[iOrd] = lpStream[dwMemPos+iOrd*2+1];
118
- if (iOrd >= MAX_ORDERS-2) break;
118
+ _this->Order[i] = lpStream[dwMemPos+i*2+1];
119
+ if (i >= MAX_ORDERS-2) break;
119
120
  }
120
121
  dwMemPos += 2*nOrders;
121
122
  while (dwMemPos + 10 < dwMemLength)
@@ -135,19 +136,19 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
135
136
  if (_this->m_nInstruments) continue;
136
137
 
137
138
  if (nInstruments >= MAX_INSTRUMENTS) nInstruments = MAX_INSTRUMENTS-1;
138
- for (UINT iIns=0; iIns<nInstruments; iIns++)
139
+ for (i=0; i<nInstruments; i++)
139
140
  {
140
141
  MODINSTRUMENT *psmp;
141
142
  INSTRUMENTHEADER *penv;
142
143
  DBMINSTRUMENT *pih;
143
- UINT nsmp;
144
+ UINT nsmp, j;
144
145
 
145
146
  if (chunk_pos + sizeof(DBMINSTRUMENT) > dwMemPos) break;
146
147
  if ((penv = (INSTRUMENTHEADER *) SDL_calloc(1, sizeof (INSTRUMENTHEADER))) == NULL) break;
147
148
  pih = (DBMINSTRUMENT *)(lpStream+chunk_pos);
148
149
  nsmp = bswapBE16(pih->sampleno);
149
150
  psmp = ((nsmp) && (nsmp < MAX_SAMPLES)) ? &_this->Ins[nsmp] : NULL;
150
- _this->Headers[iIns+1] = penv;
151
+ _this->Headers[i+1] = penv;
151
152
  penv->nFadeOut = 1024; // ???
152
153
  penv->nGlobalVol = 64;
153
154
  penv->nPan = bswapBE16(pih->panning);
@@ -156,20 +157,21 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
156
157
  else
157
158
  penv->nPan = 128;
158
159
  penv->nPPC = 5*12;
159
- for (UINT i=0; i<NOTE_MAX; i++)
160
+ for (j=0; j<NOTE_MAX; j++)
160
161
  {
161
- penv->Keyboard[i] = nsmp;
162
- penv->NoteMap[i] = i+1;
162
+ penv->Keyboard[j] = nsmp;
163
+ penv->NoteMap[j] = j+1;
163
164
  }
164
165
  // Sample Info
165
166
  if (psmp)
166
167
  {
167
168
  DWORD sflags = bswapBE16(pih->flags);
169
+ int f2t;
168
170
  psmp->nVolume = bswapBE16(pih->volume) * 4;
169
171
  if ((!psmp->nVolume) || (psmp->nVolume > 256)) psmp->nVolume = 256;
170
172
  psmp->nGlobalVol = 64;
171
173
  psmp->nC4Speed = bswapBE32(pih->finetune);
172
- int f2t = CSoundFile_FrequencyToTranspose(psmp->nC4Speed);
174
+ f2t = CSoundFile_FrequencyToTranspose(psmp->nC4Speed);
173
175
  psmp->RelativeTone = f2t >> 7;
174
176
  psmp->nFineTune = f2t & 0x7F;
175
177
  if ((pih->looplen) && (sflags & 3))
@@ -182,7 +184,7 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
182
184
  }
183
185
  }
184
186
  chunk_pos += sizeof(DBMINSTRUMENT);
185
- _this->m_nInstruments = iIns+1;
187
+ _this->m_nInstruments = i+1;
186
188
  }
187
189
  } else
188
190
  // Volume Envelopes
@@ -191,7 +193,7 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
191
193
  UINT nEnvelopes = lpStream[chunk_pos+1];
192
194
 
193
195
  chunk_pos += 2;
194
- for (UINT iEnv=0; iEnv<nEnvelopes; iEnv++)
196
+ for (i=0; i<nEnvelopes; i++)
195
197
  {
196
198
  DBMENVELOPE *peh;
197
199
  UINT nins;
@@ -202,6 +204,7 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
202
204
  if ((nins) && (nins < MAX_INSTRUMENTS) && (_this->Headers[nins]) && (peh->numpoints))
203
205
  {
204
206
  INSTRUMENTHEADER *penv = _this->Headers[nins];
207
+ UINT j;
205
208
 
206
209
  if (peh->flags & 1) penv->dwFlags |= ENV_VOLUME;
207
210
  if (peh->flags & 2) penv->dwFlags |= ENV_VOLSUSTAIN;
@@ -211,10 +214,10 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
211
214
  penv->nVolLoopStart = peh->loopbegin;
212
215
  penv->nVolLoopEnd = peh->loopend;
213
216
  penv->nVolSustainBegin = penv->nVolSustainEnd = peh->sustain1;
214
- for (UINT i=0; i<penv->nVolEnv; i++)
217
+ for (j=0; j<penv->nVolEnv; j++)
215
218
  {
216
- penv->VolPoints[i] = bswapBE16(peh->volenv[i*2]);
217
- penv->VolEnv[i] = (BYTE)bswapBE16(peh->volenv[i*2+1]);
219
+ penv->VolPoints[j] = bswapBE16(peh->volenv[j*2]);
220
+ penv->VolEnv[j] = (BYTE)bswapBE16(peh->volenv[j*2+1]);
218
221
  }
219
222
  }
220
223
  chunk_pos += sizeof(DBMENVELOPE);
@@ -224,14 +227,14 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
224
227
  if (chunk_id == bswapLE32(DBM_ID_PATT))
225
228
  {
226
229
  if (nPatterns > MAX_PATTERNS) nPatterns = MAX_PATTERNS;
227
- for (UINT iPat=0; iPat<nPatterns; iPat++)
230
+ for (i=0; i<nPatterns; i++)
228
231
  {
229
232
  DBMPATTERN *pph;
230
233
  DWORD pksize;
231
234
  UINT nRows;
232
235
 
233
236
  // Skip duplicate chunks.
234
- if (_this->Patterns[iPat]) break;
237
+ if (_this->Patterns[i]) break;
235
238
 
236
239
  if (chunk_pos + sizeof(DBMPATTERN) > dwMemPos) break;
237
240
  pph = (DBMPATTERN *)(lpStream+chunk_pos);
@@ -245,23 +248,23 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
245
248
  {
246
249
  LPBYTE pkdata = (LPBYTE)pph->patterndata;
247
250
  UINT row = 0;
248
- UINT i = 0;
251
+ UINT n = 0;
249
252
 
250
- _this->PatternSize[iPat] = nRows;
251
- _this->Patterns[iPat] = m;
252
- while ((i+3<pksize) && (row < nRows))
253
+ _this->PatternSize[i] = nRows;
254
+ _this->Patterns[i] = m;
255
+ while ((n+3<pksize) && (row < nRows))
253
256
  {
254
- UINT ch = pkdata[i++];
257
+ UINT ch = pkdata[n++];
255
258
 
256
259
  if (ch)
257
260
  {
258
- BYTE b = pkdata[i++];
261
+ BYTE b = pkdata[n++];
259
262
  ch--;
260
263
  if (ch < _this->m_nChannels)
261
264
  {
262
265
  if (b & 0x01)
263
266
  {
264
- UINT note = pkdata[i++];
267
+ UINT note = pkdata[n++];
265
268
 
266
269
  if (note == 0x1F) note = 0xFF; else
267
270
  if ((note) && (note < 0xFE))
@@ -270,14 +273,14 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
270
273
  }
271
274
  m[ch].note = note;
272
275
  }
273
- if (b & 0x02) m[ch].instr = pkdata[i++];
276
+ if (b & 0x02) m[ch].instr = pkdata[n++];
274
277
  if (b & 0x3C)
275
278
  {
276
279
  UINT cmd1 = 0xFF, param1 = 0, cmd2 = 0xFF, param2 = 0;
277
- if (b & 0x04) cmd1 = (UINT)pkdata[i++];
278
- if (b & 0x08) param1 = pkdata[i++];
279
- if (b & 0x10) cmd2 = (UINT)pkdata[i++];
280
- if (b & 0x20) param2 = pkdata[i++];
280
+ if (b & 0x04) cmd1 = (UINT)pkdata[n++];
281
+ if (b & 0x08) param1 = pkdata[n++];
282
+ if (b & 0x10) cmd2 = (UINT)pkdata[n++];
283
+ if (b & 0x20) param2 = pkdata[n++];
281
284
  if (cmd1 == 0x0C)
282
285
  {
283
286
  m[ch].volcmd = VOLCMD_VOLUME;
@@ -305,12 +308,12 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
305
308
  }
306
309
  } else
307
310
  {
308
- if (b & 0x01) i++;
309
- if (b & 0x02) i++;
310
- if (b & 0x04) i++;
311
- if (b & 0x08) i++;
312
- if (b & 0x10) i++;
313
- if (b & 0x20) i++;
311
+ if (b & 0x01) n++;
312
+ if (b & 0x02) n++;
313
+ if (b & 0x04) n++;
314
+ if (b & 0x08) n++;
315
+ if (b & 0x10) n++;
316
+ if (b & 0x20) n++;
314
317
  }
315
318
  } else
316
319
  {
@@ -328,7 +331,7 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
328
331
  {
329
332
  if (nSamples >= MAX_SAMPLES) nSamples = MAX_SAMPLES-1;
330
333
  _this->m_nSamples = nSamples;
331
- for (UINT iSmp=1; iSmp<=nSamples; iSmp++)
334
+ for (i=1; i<=nSamples; i++)
332
335
  {
333
336
  MODINSTRUMENT *pins;
334
337
  DBMSAMPLE *psh;
@@ -340,7 +343,7 @@ BOOL CSoundFile_ReadDBM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
340
343
  chunk_pos += 8;
341
344
  samplesize = bswapBE32(psh->samplesize);
342
345
  sampleflags = bswapBE32(psh->flags);
343
- pins = &_this->Ins[iSmp];
346
+ pins = &_this->Ins[i];
344
347
  pins->nLength = samplesize;
345
348
  if (sampleflags & 2)
346
349
  {
@@ -83,6 +83,7 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
83
83
  DWORD dwMemPos;
84
84
  BYTE infobyte[32];
85
85
  BYTE smplflags[MAX_SAMPLES], hasSMPI = 0, hasSMPD = 0;
86
+ UINT i;
86
87
 
87
88
  if ((!lpStream) || (dwMemLength < 1024)) return FALSE;
88
89
  if ((pfh->id != 0x464d4444) || (!pfh->version) || (pfh->version & 0xF0)) return FALSE;
@@ -114,7 +115,7 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
114
115
  UINT nseq = (sequ->seqsize - 4) >> 1;
115
116
  if (nseq >= MAX_ORDERS-1) nseq = MAX_ORDERS-1;
116
117
  if (sequ->loopstart < nseq) _this->m_nRestartPos = sequ->loopstart;
117
- for (UINT i=0; i<nseq; i++) _this->Order[i] = (BYTE)sequ->sequ[i];
118
+ for (i=0; i<nseq; i++) _this->Order[i] = (BYTE)sequ->sequ[i];
118
119
  }
119
120
  dwMemPos += sequ->seqsize + 8;
120
121
  break;
@@ -125,7 +126,7 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
125
126
  if ((patt->patsize >= dwMemLength) || (dwMemPos + 8 > dwMemLength - patt->patsize)) goto dmfexit;
126
127
  if (patt->patsize >= 4 && !_this->m_nChannels)
127
128
  {
128
- UINT numpat;
129
+ UINT numpat, c;
129
130
  DWORD dwPos = dwMemPos + 11;
130
131
  numpat = patt->numpat;
131
132
  if (numpat > MAX_PATTERNS) numpat = MAX_PATTERNS;
@@ -133,38 +134,44 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
133
134
  if (_this->m_nChannels < patt->firstpatinfo) _this->m_nChannels = patt->firstpatinfo;
134
135
  if (_this->m_nChannels > 32) _this->m_nChannels = 32;
135
136
  if (_this->m_nChannels < 4) _this->m_nChannels = 4;
136
- for (UINT npat=0; npat<numpat; npat++)
137
+ for (c=0; c<numpat; c++)
137
138
  {
138
139
  const DMFTRACK *pt = (DMFTRACK *)(lpStream+dwPos);
140
+ MODCOMMAND *m;
141
+ UINT tracks, ticks, row;
142
+ UINT ttype, tempo, glbinfobyte, pbeat;
143
+ BOOL tempochange;
144
+ DWORD d;
139
145
  if (dwPos + 8 >= dwMemLength) break;
140
- UINT tracks = pt->tracks;
146
+ tracks = pt->tracks;
141
147
  if (tracks > 32) tracks = 32;
142
- UINT ticks = pt->ticks;
148
+ ticks = pt->ticks;
143
149
  if (ticks > 256) ticks = 256;
144
150
  if (ticks < 16) ticks = 16;
145
151
  dwPos += 8;
146
152
  if ((pt->jmpsize >= dwMemLength) || (dwPos + 4 > dwMemLength - pt->jmpsize)) break;
147
- _this->PatternSize[npat] = (WORD)ticks;
148
- MODCOMMAND *m = CSoundFile_AllocatePattern(_this->PatternSize[npat], _this->m_nChannels);
153
+ _this->PatternSize[c] = (WORD)ticks;
154
+ m = CSoundFile_AllocatePattern(_this->PatternSize[c], _this->m_nChannels);
149
155
  if (!m) goto dmfexit;
150
- _this->Patterns[npat] = m;
151
- DWORD d = dwPos;
156
+ _this->Patterns[c] = m;
157
+ d = dwPos;
152
158
  dwPos += pt->jmpsize;
153
- UINT ttype = 1;
154
- UINT tempo = 125;
155
- UINT glbinfobyte = 0;
156
- UINT pbeat = (pt->beat & 0xf0) ? pt->beat>>4 : 8;
157
- BOOL tempochange = (pt->beat & 0xf0) ? TRUE : FALSE;
159
+ ttype = 1;
160
+ tempo = 125;
161
+ glbinfobyte = 0;
162
+ pbeat = (pt->beat & 0xf0) ? pt->beat>>4 : 8;
163
+ tempochange = (pt->beat & 0xf0) ? TRUE : FALSE;
158
164
  SDL_memset(infobyte, 0, sizeof(infobyte));
159
- for (UINT row=0; row<ticks; row++)
165
+ for (row=0; row<ticks; row++)
160
166
  {
161
167
  MODCOMMAND *p = &m[row*_this->m_nChannels];
162
168
  // Parse track global effects
163
169
  if (!glbinfobyte)
164
170
  {
171
+ BYTE info, infoval;
165
172
  if (d+1 > dwPos) break;
166
- BYTE info = lpStream[d++];
167
- BYTE infoval = 0;
173
+ info = lpStream[d++];
174
+ infoval = 0;
168
175
  if ((info & 0x80) && (d < dwPos)) glbinfobyte = lpStream[d++];
169
176
  info &= 0x7f;
170
177
  if ((info) && (d < dwPos)) infoval = lpStream[d++];
@@ -179,12 +186,13 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
179
186
  glbinfobyte--;
180
187
  }
181
188
  // Parse channels
182
- for (UINT i=0; i<tracks; i++) if (!infobyte[i])
189
+ for (i=0; i<tracks; i++) if (!infobyte[i])
183
190
  {
184
- if (d+1 > dwPos) break;
185
191
  MODCOMMAND cmd;
192
+ BYTE info;
193
+ if (d+1 > dwPos) break;
186
194
  SDL_zero(cmd);
187
- BYTE info = lpStream[d++];
195
+ info = lpStream[d++];
188
196
  if (info & 0x80)
189
197
  {
190
198
  if (d+1 > dwPos) break;
@@ -214,10 +222,11 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
214
222
  // Effect 1
215
223
  if (info & 0x08)
216
224
  {
225
+ BYTE efx, eval;
217
226
  if (d+2 > dwPos) break;
218
227
 
219
- BYTE efx = lpStream[d++];
220
- BYTE eval = lpStream[d++];
228
+ efx = lpStream[d++];
229
+ eval = lpStream[d++];
221
230
  switch(efx)
222
231
  {
223
232
  // 1: Key Off
@@ -234,10 +243,11 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
234
243
  // Effect 2
235
244
  if (info & 0x04)
236
245
  {
246
+ BYTE efx, eval;
237
247
  if (d+2 > dwPos) break;
238
248
 
239
- BYTE efx = lpStream[d++];
240
- BYTE eval = lpStream[d++];
249
+ efx = lpStream[d++];
250
+ eval = lpStream[d++];
241
251
  switch(efx)
242
252
  {
243
253
  // 1: Finetune
@@ -263,10 +273,11 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
263
273
  // Effect 3
264
274
  if (info & 0x02)
265
275
  {
276
+ BYTE efx, eval;
266
277
  if (d+2 > dwPos) break;
267
278
 
268
- BYTE efx = lpStream[d++];
269
- BYTE eval = lpStream[d++];
279
+ efx = lpStream[d++];
280
+ eval = lpStream[d++];
270
281
  switch(efx)
271
282
  {
272
283
  // 1: Vol Slide Up
@@ -303,27 +314,27 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
303
314
  // Find free channel for tempo change
304
315
  if (tempochange)
305
316
  {
306
- tempochange = FALSE;
307
317
  UINT speed=6, modtempo=tempo;
308
318
  UINT rpm = ((ttype) && (pbeat)) ? tempo*pbeat : (tempo+1)*15;
319
+ tempochange = FALSE;
309
320
  for (speed=30; speed>1; speed--)
310
321
  {
311
322
  modtempo = rpm*speed/24;
312
323
  if (modtempo <= 200) break;
313
324
  if ((speed < 6) && (modtempo < 256)) break;
314
325
  }
315
- for (UINT ich=0; ich<_this->m_nChannels; ich++) if (!p[ich].command)
326
+ for (i=0; i<_this->m_nChannels; i++) if (!p[i].command)
316
327
  {
317
328
  if (speed)
318
329
  {
319
- p[ich].command = CMD_SPEED;
320
- p[ich].param = (BYTE)speed;
330
+ p[i].command = CMD_SPEED;
331
+ p[i].param = (BYTE)speed;
321
332
  speed = 0;
322
333
  } else
323
334
  if ((modtempo >= 32) && (modtempo < 256))
324
335
  {
325
- p[ich].command = CMD_TEMPO;
326
- p[ich].param = (BYTE)modtempo;
336
+ p[i].command = CMD_TEMPO;
337
+ p[i].param = (BYTE)modtempo;
327
338
  modtempo = 0;
328
339
  } else
329
340
  {
@@ -342,23 +353,26 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
342
353
  // "SMPI": Sample Info
343
354
  case 0x49504d53:
344
355
  {
345
- hasSMPI = 1;
346
356
  const DMFSMPI *pds = (DMFSMPI *)(lpStream+dwMemPos);
357
+ hasSMPI = 1;
347
358
  if ((pds->size >= dwMemLength) || (dwMemPos + 8 > dwMemLength - pds->size)) goto dmfexit;
348
359
  if (pds->size >= 1)
349
360
  {
350
361
  DWORD dwPos = dwMemPos + 9;
351
362
  _this->m_nSamples = pds->samples;
352
363
  if (_this->m_nSamples >= MAX_SAMPLES) _this->m_nSamples = MAX_SAMPLES-1;
353
- for (UINT iSmp=1; iSmp<=_this->m_nSamples; iSmp++)
364
+ for (i=1; i<=_this->m_nSamples; i++)
354
365
  {
366
+ const DMFSAMPLE *psh;
367
+ MODINSTRUMENT *psmp;
368
+ UINT namelen;
355
369
  if (dwPos >= dwMemPos + pds->size + 8) break;
356
- const UINT namelen = lpStream[dwPos];
357
- smplflags[iSmp] = 0;
370
+ namelen = lpStream[dwPos];
371
+ smplflags[i] = 0;
358
372
  if (dwPos+namelen+1+sizeof(DMFSAMPLE) > dwMemPos+pds->size+8) break;
359
373
  dwPos += namelen + 1;
360
- const DMFSAMPLE *psh = (DMFSAMPLE *)(lpStream+dwPos);
361
- MODINSTRUMENT *psmp = &_this->Ins[iSmp];
374
+ psh = (DMFSAMPLE *)(lpStream+dwPos);
375
+ psmp = &_this->Ins[i];
362
376
  psmp->nLength = psh->len;
363
377
  psmp->nLoopStart = psh->loopstart;
364
378
  psmp->nLoopEnd = psh->loopend;
@@ -368,7 +382,7 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
368
382
  psmp->uFlags = (psh->flags & 2) ? CHN_16BIT : 0;
369
383
  if (psmp->uFlags & CHN_16BIT) psmp->nLength >>= 1;
370
384
  if (psh->flags & 1) psmp->uFlags |= CHN_LOOP;
371
- smplflags[iSmp] = psh->flags;
385
+ smplflags[i] = psh->flags;
372
386
  dwPos += (pfh->version < 8) ? 22 : 30;
373
387
  }
374
388
  }
@@ -381,10 +395,10 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
381
395
  {
382
396
  DWORD dwPos = dwMemPos + 8;
383
397
  UINT ismpd = 0;
384
- for (UINT iSmp=1; iSmp<=_this->m_nSamples && !hasSMPD; iSmp++)
398
+ for (i=1; i<=_this->m_nSamples && !hasSMPD; i++)
385
399
  {
386
- ismpd++;
387
400
  DWORD pksize;
401
+ ismpd++;
388
402
  if (dwPos + 4 >= dwMemLength)
389
403
  {
390
404
  break;
@@ -395,12 +409,12 @@ BOOL CSoundFile_ReadDMF(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
395
409
  {
396
410
  pksize = dwMemLength - dwPos;
397
411
  }
398
- if ((pksize) && (iSmp <= _this->m_nSamples))
412
+ if ((pksize) && (i <= _this->m_nSamples))
399
413
  {
400
- UINT flags = (_this->Ins[iSmp].uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8S;
414
+ UINT flags = (_this->Ins[i].uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8S;
401
415
  if (hasSMPI && smplflags[ismpd] & 4)
402
- flags = (_this->Ins[iSmp].uFlags & CHN_16BIT) ? RS_DMF16 : RS_DMF8;
403
- CSoundFile_ReadSample(_this, &_this->Ins[iSmp], flags, (LPSTR)(lpStream+dwPos), pksize);
416
+ flags = (_this->Ins[i].uFlags & CHN_16BIT) ? RS_DMF16 : RS_DMF8;
417
+ CSoundFile_ReadSample(_this, &_this->Ins[i], flags, (LPSTR)(lpStream+dwPos), pksize);
404
418
  }
405
419
  dwPos += pksize;
406
420
  }
@@ -521,7 +535,7 @@ int DMFUnpack(LPBYTE psample, LPBYTE ibuf, LPBYTE ibufmax, UINT maxlen)
521
535
  //----------------------------------------------------------------------
522
536
  {
523
537
  DMF_HTREE tree;
524
- UINT actnode;
538
+ UINT actnode,i;
525
539
  BYTE value, sign, delta = 0;
526
540
 
527
541
  SDL_memset(&tree, 0, sizeof(tree));
@@ -532,7 +546,7 @@ int DMFUnpack(LPBYTE psample, LPBYTE ibuf, LPBYTE ibufmax, UINT maxlen)
532
546
 
533
547
  if (tree.ibuf >= ibufmax) return tree.ibuf - ibuf;
534
548
 
535
- for (UINT i=0; i<maxlen; i++)
549
+ for (i=0; i<maxlen; i++)
536
550
  {
537
551
  if ((tree.ibuf >= tree.ibufmax) && (!tree.bitnum))
538
552
  {
@@ -557,5 +571,3 @@ int DMFUnpack(LPBYTE psample, LPBYTE ibuf, LPBYTE ibufmax, UINT maxlen)
557
571
  }
558
572
  return tree.ibuf - ibuf;
559
573
  }
560
-
561
-
@@ -87,7 +87,7 @@ BOOL CSoundFile_ReadDSM(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
87
87
  DSMFILEHEADER *pfh = (DSMFILEHEADER *)lpStream;
88
88
  DSMSONG *psong;
89
89
  DWORD dwMemPos;
90
- UINT nPat, nSmp;
90
+ UINT i, nPat, nSmp;
91
91
 
92
92
  if ((!lpStream) || (dwMemLength < 1024) || (pfh->id_RIFF != DSMID_RIFF)
93
93
  || (pfh->riff_len + 8 > dwMemLength) || (pfh->riff_len < 1024)
@@ -106,16 +106,16 @@ BOOL CSoundFile_ReadDSM(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
106
106
  _this->m_nDefaultGlobalVolume = psong->globalvol << 2;
107
107
  if ((!_this->m_nDefaultGlobalVolume) || (_this->m_nDefaultGlobalVolume > 256)) _this->m_nDefaultGlobalVolume = 256;
108
108
  _this->m_nSongPreAmp = psong->mastervol & 0x7F;
109
- for (UINT iOrd=0; iOrd<sizeof(psong->orders); iOrd++)
109
+ for (i=0; i<sizeof(psong->orders); i++)
110
110
  {
111
- _this->Order[iOrd] = (BYTE)((iOrd < psong->numord) ? psong->orders[iOrd] : 0xFF);
111
+ _this->Order[i] = (BYTE)((i < psong->numord) ? psong->orders[i] : 0xFF);
112
112
  }
113
- for (UINT iPan=0; iPan<16; iPan++)
113
+ for (i=0; i<16; i++)
114
114
  {
115
- _this->ChnSettings[iPan].nPan = 0x80;
116
- if (psong->panpos[iPan] <= 0x80)
115
+ _this->ChnSettings[i].nPan = 0x80;
116
+ if (psong->panpos[i] <= 0x80)
117
117
  {
118
- _this->ChnSettings[iPan].nPan = psong->panpos[iPan] << 1;
118
+ _this->ChnSettings[i].nPan = psong->panpos[i] << 1;
119
119
  }
120
120
  }
121
121
  nPat = 0;
@@ -127,15 +127,17 @@ BOOL CSoundFile_ReadDSM(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
127
127
  // Reading Patterns
128
128
  if (ppatt->id_PATT == DSMID_PATT)
129
129
  {
130
+ MODCOMMAND *m;
131
+ DWORD dwPos;
132
+ UINT row = 0;
130
133
  dwMemPos += 8;
131
134
  if (dwMemPos + ppatt->patt_len >= dwMemLength) break;
132
- DWORD dwPos = dwMemPos;
135
+ dwPos = dwMemPos;
133
136
  dwMemPos += ppatt->patt_len;
134
- MODCOMMAND *m = CSoundFile_AllocatePattern(64, _this->m_nChannels);
137
+ m = CSoundFile_AllocatePattern(64, _this->m_nChannels);
135
138
  if (!m) break;
136
139
  _this->PatternSize[nPat] = 64;
137
140
  _this->Patterns[nPat] = m;
138
- UINT row = 0;
139
141
  while ((row < 64) && (dwPos + 2 <= dwMemPos))
140
142
  {
141
143
  UINT flag = lpStream[dwPos++];
@@ -207,10 +209,13 @@ BOOL CSoundFile_ReadDSM(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
207
209
  // Reading Samples
208
210
  if ((nSmp <= _this->m_nSamples) && (pins->id_INST == DSMID_INST))
209
211
  {
212
+ MODINSTRUMENT *psmp;
213
+ DWORD dwPos;
214
+ UINT smptype;
210
215
  if (dwMemPos + pins->inst_len >= dwMemLength - 8) break;
211
- DWORD dwPos = dwMemPos + sizeof(DSMINST);
216
+ dwPos = dwMemPos + sizeof(DSMINST);
212
217
  dwMemPos += 8 + pins->inst_len;
213
- MODINSTRUMENT *psmp = &_this->Ins[nSmp];
218
+ psmp = &_this->Ins[nSmp];
214
219
  psmp->nGlobalVol = 64;
215
220
  psmp->nC4Speed = pins->c2spd;
216
221
  psmp->uFlags = (WORD)((pins->flags & 1) ? CHN_LOOP : 0);
@@ -219,7 +224,7 @@ BOOL CSoundFile_ReadDSM(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
219
224
  psmp->nLoopEnd = pins->loopend;
220
225
  psmp->nVolume = (WORD)(pins->volume << 2);
221
226
  if (psmp->nVolume > 256) psmp->nVolume = 256;
222
- UINT smptype = (pins->flags & 2) ? RS_PCM8S : RS_PCM8U;
227
+ smptype = (pins->flags & 2) ? RS_PCM8S : RS_PCM8U;
223
228
  CSoundFile_ReadSample(_this, psmp, smptype, (LPCSTR)(lpStream+dwPos), dwMemLength - dwPos);
224
229
  nSmp++;
225
230
  } else
@@ -57,9 +57,11 @@ BOOL CSoundFile_ReadFAR(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
57
57
  {
58
58
  const FARHEADER1 *pmh1 = (const FARHEADER1 *)lpStream;
59
59
  const FARHEADER2 *pmh2;
60
+ MODINSTRUMENT *pins;
60
61
  DWORD dwMemPos = sizeof(FARHEADER1);
61
- UINT headerlen, stlen;
62
+ UINT headerlen, stlen, i;
62
63
  BYTE samplemap[8];
64
+ WORD *patsiz;
63
65
 
64
66
  if ((!lpStream) || (dwMemLength < 1024) || (bswapLE32(pmh1->id) != FARFILEMAGIC)
65
67
  || (pmh1->magic2[0] != 13) || (pmh1->magic2[1] != 10) || (pmh1->magic2[2] != 26)) return FALSE;
@@ -77,11 +79,11 @@ BOOL CSoundFile_ReadFAR(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
77
79
  _this->m_nDefaultGlobalVolume = 256;
78
80
 
79
81
  // Channel Setting
80
- for (UINT nchpan=0; nchpan<16; nchpan++)
82
+ for (i=0; i<16; i++)
81
83
  {
82
- _this->ChnSettings[nchpan].dwFlags = 0;
83
- _this->ChnSettings[nchpan].nPan = ((pmh1->panning[nchpan] & 0x0F) << 4) + 8;
84
- _this->ChnSettings[nchpan].nVolume = 64;
84
+ _this->ChnSettings[i].dwFlags = 0;
85
+ _this->ChnSettings[i].nPan = ((pmh1->panning[i] & 0x0F) << 4) + 8;
86
+ _this->ChnSettings[i].nVolume = 64;
85
87
  }
86
88
  // Reading comment
87
89
  if (stlen)
@@ -93,27 +95,30 @@ BOOL CSoundFile_ReadFAR(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
93
95
  pmh2 = (const FARHEADER2 *)(lpStream + dwMemPos);
94
96
  dwMemPos += sizeof(FARHEADER2);
95
97
  if (dwMemPos >= dwMemLength) return TRUE;
96
- for (UINT iorder=0; iorder<MAX_ORDERS; iorder++)
98
+ for (i=0; i<MAX_ORDERS; i++)
97
99
  {
98
- _this->Order[iorder] = (iorder <= pmh2->snglen) ? pmh2->orders[iorder] : 0xFF;
100
+ _this->Order[i] = (i <= pmh2->snglen) ? pmh2->orders[i] : 0xFF;
99
101
  }
100
102
  _this->m_nRestartPos = pmh2->loopto;
101
103
  // Reading Patterns
102
104
  dwMemPos += headerlen - (869 + stlen);
103
105
  if (dwMemPos >= dwMemLength) return TRUE;
104
106
 
105
- WORD *patsiz = (WORD *)pmh2->patsiz;
106
- for (UINT ipat=0; ipat<256; ipat++) if (patsiz[ipat])
107
+ patsiz = (WORD *)pmh2->patsiz;
108
+ for (i=0; i<256; i++) if (patsiz[i])
107
109
  {
108
- UINT patlen = bswapLE16(patsiz[ipat]);
109
- if ((ipat >= MAX_PATTERNS) || (patlen < 2))
110
+ MODCOMMAND *m;
111
+ const BYTE *p;
112
+ UINT len, max, rows, patbrk, patlen;
113
+ patlen = bswapLE16(patsiz[i]);
114
+ if ((i >= MAX_PATTERNS) || (patlen < 2))
110
115
  {
111
116
  dwMemPos += patlen;
112
117
  continue;
113
118
  }
114
119
  if (dwMemPos + patlen >= dwMemLength) return TRUE;
115
- UINT max = (patlen - 2) & ~3;
116
- UINT rows = (patlen - 2) >> 6;
120
+ max = (patlen - 2) & ~3;
121
+ rows = (patlen - 2) >> 6;
117
122
  if (!rows)
118
123
  {
119
124
  dwMemPos += patlen;
@@ -122,12 +127,12 @@ BOOL CSoundFile_ReadFAR(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
122
127
  if (rows > 256) rows = 256;
123
128
  if (rows < 16) rows = 16;
124
129
  if (max > rows*16*4) max = rows*16*4;
125
- _this->PatternSize[ipat] = rows;
126
- if ((_this->Patterns[ipat] = CSoundFile_AllocatePattern(rows, _this->m_nChannels)) == NULL) return TRUE;
127
- MODCOMMAND *m = _this->Patterns[ipat];
128
- UINT patbrk = lpStream[dwMemPos];
129
- const BYTE *p = lpStream + dwMemPos + 2;
130
- for (UINT len=0; len<max; len += 4, m++)
130
+ _this->PatternSize[i] = rows;
131
+ if ((_this->Patterns[i] = CSoundFile_AllocatePattern(rows, _this->m_nChannels)) == NULL) return TRUE;
132
+ m = _this->Patterns[i];
133
+ patbrk = lpStream[dwMemPos];
134
+ p = lpStream + dwMemPos + 2;
135
+ for (len=0; len<max; len += 4, m++)
131
136
  {
132
137
  BYTE note = p[len];
133
138
  BYTE ins = p[len+1];
@@ -214,14 +219,16 @@ BOOL CSoundFile_ReadFAR(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
214
219
  if (dwMemPos + 8 >= dwMemLength) return TRUE;
215
220
  SDL_memcpy(samplemap, lpStream+dwMemPos, 8);
216
221
  dwMemPos += 8;
217
- MODINSTRUMENT *pins = &_this->Ins[1];
218
- for (UINT ismp=0; ismp<64; ismp++, pins++) if (samplemap[ismp >> 3] & (1 << (ismp & 7)))
222
+ pins = &_this->Ins[1];
223
+ for (i=0; i<64; i++, pins++) if (samplemap[i >> 3] & (1 << (i & 7)))
219
224
  {
225
+ const FARSAMPLE *pfs;
226
+ DWORD length;
220
227
  if (dwMemPos + sizeof(FARSAMPLE) > dwMemLength) return TRUE;
221
- const FARSAMPLE *pfs = (const FARSAMPLE*)(lpStream + dwMemPos);
228
+ pfs = (const FARSAMPLE*)(lpStream + dwMemPos);
222
229
  dwMemPos += sizeof(FARSAMPLE);
223
- _this->m_nSamples = ismp + 1;
224
- const DWORD length = bswapLE32(pfs->length); /* endian fix - Toad */
230
+ _this->m_nSamples = i + 1;
231
+ length = bswapLE32(pfs->length); /* endian fix - Toad */
225
232
  pins->nLength = length;
226
233
  pins->nLoopStart = bswapLE32(pfs->reppos);
227
234
  pins->nLoopEnd = bswapLE32(pfs->repend);