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
@@ -109,14 +109,15 @@ static DWORD boundInput(DWORD input, DWORD smin, DWORD smax)
109
109
  BOOL CSoundFile_ReadS3M(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLength)
110
110
  //---------------------------------------------------------------
111
111
  {
112
- UINT insnum,patnum,nins,npat;
112
+ S3MFILEHEADER psfh;
113
+ UINT insnum,patnum,nins,npat,iord;
113
114
  DWORD insfile[MAX_SAMPLES];
114
115
  WORD ptr[256];
115
116
  DWORD dwMemPos;
116
117
  BYTE insflags[MAX_SAMPLES], inspack[MAX_SAMPLES];
118
+ UINT i, j;
117
119
 
118
120
  if ((!lpStream) || (dwMemLength <= sizeof(S3MFILEHEADER)+sizeof(S3MSAMPLESTRUCT)+64)) return FALSE;
119
- S3MFILEHEADER psfh;
120
121
  SDL_memcpy(&psfh, lpStream, sizeof (psfh));
121
122
 
122
123
  psfh.reserved1 = bswapLE16(psfh.reserved1);
@@ -146,24 +147,25 @@ BOOL CSoundFile_ReadS3M(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
146
147
  _this->m_nSongPreAmp = psfh.mastervol & 0x7F;
147
148
  // Channels
148
149
  _this->m_nChannels = 4;
149
- for (UINT ich=0; ich<32; ich++)
150
+ for (i=0; i<32; i++)
150
151
  {
151
- _this->ChnSettings[ich].nPan = 128;
152
- _this->ChnSettings[ich].nVolume = 64;
152
+ _this->ChnSettings[i].nPan = 128;
153
+ _this->ChnSettings[i].nVolume = 64;
153
154
 
154
- _this->ChnSettings[ich].dwFlags = CHN_MUTE;
155
- if (psfh.channels[ich] != 0xFF)
155
+ _this->ChnSettings[i].dwFlags = CHN_MUTE;
156
+ if (psfh.channels[i] != 0xFF)
156
157
  {
157
- _this->m_nChannels = ich+1;
158
- UINT b = psfh.channels[ich] & 0x0F;
159
- _this->ChnSettings[ich].nPan = (b & 8) ? 0xC0 : 0x40;
160
- _this->ChnSettings[ich].dwFlags = 0;
158
+ UINT b;
159
+ _this->m_nChannels = i+1;
160
+ b = psfh.channels[i] & 0x0F;
161
+ _this->ChnSettings[i].nPan = (b & 8) ? 0xC0 : 0x40;
162
+ _this->ChnSettings[i].dwFlags = 0;
161
163
  }
162
164
  }
163
165
  if (_this->m_nChannels < 4) _this->m_nChannels = 4;
164
166
  if ((psfh.cwtv < 0x1320) || (psfh.flags & 0x40)) _this->m_dwSongFlags |= SONG_FASTVOLSLIDES;
165
167
  // Reading pattern order
166
- UINT iord = psfh.ordnum;
168
+ iord = psfh.ordnum;
167
169
  if (iord<1) iord = 1;
168
170
  if (iord > MAX_ORDERS) iord = MAX_ORDERS;
169
171
  if (dwMemPos + iord + 1 >= dwMemLength) return FALSE;
@@ -190,14 +192,14 @@ BOOL CSoundFile_ReadS3M(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
190
192
  if (dwMemPos + 2*(nins+npat) >= dwMemLength) return FALSE;
191
193
  SDL_memcpy(ptr, lpStream+dwMemPos, 2*(nins+npat));
192
194
  dwMemPos += 2*(nins+npat);
193
- for (UINT j = 0; j < (nins+npat); ++j) {
195
+ for (j = 0; j < (nins+npat); ++j) {
194
196
  ptr[j] = bswapLE16(ptr[j]);
195
197
  }
196
198
  if (psfh.panning_present == 252)
197
199
  {
198
200
  const BYTE *chnpan = lpStream+dwMemPos;
199
201
  if (dwMemPos > dwMemLength - 32) return FALSE;
200
- for (UINT i=0; i<32; i++) if (chnpan[i] & 0x20)
202
+ for (i=0; i<32; i++) if (chnpan[i] & 0x20)
201
203
  {
202
204
  _this->ChnSettings[i].nPan = ((chnpan[i] & 0x0F) << 4) + 8;
203
205
  }
@@ -206,60 +208,64 @@ BOOL CSoundFile_ReadS3M(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
206
208
  if (!_this->m_nChannels) return TRUE;
207
209
  // Reading instrument headers
208
210
  SDL_memset(insfile, 0, sizeof(insfile));
209
- for (UINT iSmp=1; iSmp<=insnum; iSmp++)
211
+ for (i=1; i<=insnum; i++)
210
212
  {
211
- UINT nInd = ((DWORD)ptr[iSmp-1])*16;
213
+ UINT nInd = ((DWORD)ptr[i-1])*16;
214
+ S3MSAMPLESTRUCT pSmp;
212
215
  if ((!nInd) || (nInd + 0x50 > dwMemLength)) {
213
216
  // initialize basic variables.
214
- insflags[iSmp-1] = 0;
215
- inspack[iSmp-1] = 0;
217
+ insflags[i-1] = 0;
218
+ inspack[i-1] = 0;
216
219
  continue;
217
220
  }
218
- S3MSAMPLESTRUCT pSmp;
219
221
  SDL_memcpy(&pSmp, lpStream+nInd, 0x50);
220
- insflags[iSmp-1] = pSmp.flags;
221
- inspack[iSmp-1] = pSmp.pack;
222
+ insflags[i-1] = pSmp.flags;
223
+ inspack[i-1] = pSmp.pack;
222
224
  if ((pSmp.type==1) && (pSmp.scrs[2]=='R') && (pSmp.scrs[3]=='S'))
223
225
  {
224
- _this->Ins[iSmp].nLength = boundInput(bswapLE32(pSmp.length), 4, MAX_SAMPLE_LENGTH);
225
- _this->Ins[iSmp].nLoopStart = boundInput(bswapLE32(pSmp.loopbegin), 4, _this->Ins[iSmp].nLength - 1);
226
- _this->Ins[iSmp].nLoopEnd = boundInput(bswapLE32(pSmp.loopend), 4, _this->Ins[iSmp].nLength);
227
- _this->Ins[iSmp].nVolume = boundInput(pSmp.vol, 0, 64) << 2;
228
- _this->Ins[iSmp].nGlobalVol = 64;
229
- if (pSmp.flags&1) _this->Ins[iSmp].uFlags |= CHN_LOOP;
230
- UINT j = bswapLE32(pSmp.finetune);
226
+ _this->Ins[i].nLength = boundInput(bswapLE32(pSmp.length), 4, MAX_SAMPLE_LENGTH);
227
+ _this->Ins[i].nLoopStart = boundInput(bswapLE32(pSmp.loopbegin), 4, _this->Ins[i].nLength - 1);
228
+ _this->Ins[i].nLoopEnd = boundInput(bswapLE32(pSmp.loopend), 4, _this->Ins[i].nLength);
229
+ _this->Ins[i].nVolume = boundInput(pSmp.vol, 0, 64) << 2;
230
+ _this->Ins[i].nGlobalVol = 64;
231
+ if (pSmp.flags&1) _this->Ins[i].uFlags |= CHN_LOOP;
232
+ j = bswapLE32(pSmp.finetune);
231
233
  if (!j) j = 8363;
232
234
  if (j < 1024) j = 1024;
233
- _this->Ins[iSmp].nC4Speed = j;
234
- insfile[iSmp] = (pSmp.hmem << 20) + (bswapLE16(pSmp.memseg) << 4);
235
+ _this->Ins[i].nC4Speed = j;
236
+ insfile[i] = (pSmp.hmem << 20) + (bswapLE16(pSmp.memseg) << 4);
235
237
  // offset is invalid - ignore this sample.
236
- if (insfile[iSmp] > dwMemLength) insfile[iSmp] = 0;
237
- else if (insfile[iSmp]) {
238
+ if (insfile[i] > dwMemLength) insfile[i] = 0;
239
+ else if (insfile[i]) {
238
240
  // ignore duplicate samples.
239
- for (int z=iSmp-1; z>=0; z--)
240
- if (insfile[iSmp] == insfile[z])
241
- insfile[iSmp] = 0;
241
+ int z = i - 1;
242
+ for (; z>=0; z--)
243
+ if (insfile[i] == insfile[z])
244
+ insfile[i] = 0;
242
245
  }
243
- if ((_this->Ins[iSmp].nLoopStart >= _this->Ins[iSmp].nLoopEnd) || (_this->Ins[iSmp].nLoopEnd - _this->Ins[iSmp].nLoopStart < 8))
244
- _this->Ins[iSmp].nLoopStart = _this->Ins[iSmp].nLoopEnd = 0;
245
- _this->Ins[iSmp].nPan = 0x80;
246
+ if ((_this->Ins[i].nLoopStart >= _this->Ins[i].nLoopEnd) || (_this->Ins[i].nLoopEnd - _this->Ins[i].nLoopStart < 8))
247
+ _this->Ins[i].nLoopStart = _this->Ins[i].nLoopEnd = 0;
248
+ _this->Ins[i].nPan = 0x80;
246
249
  }
247
250
  }
248
251
  // Reading patterns
249
- for (UINT iPat=0; iPat<patnum; iPat++)
252
+ for (i=0; i<patnum; i++)
250
253
  {
251
- UINT nInd = ((DWORD)ptr[nins+iPat]) << 4;
254
+ LPBYTE src;
255
+ MODCOMMAND *p;
256
+ UINT nInd = ((DWORD)ptr[nins+i]) << 4;
257
+ UINT row = 0;
258
+ WORD len;
252
259
  if (nInd + 0x40 > dwMemLength) continue;
253
- WORD len = bswapLE16(*((WORD *)(lpStream+nInd)));
260
+ len = bswapLE16(*((WORD *)(lpStream+nInd)));
254
261
  nInd += 2;
255
- _this->PatternSize[iPat] = 64;
262
+ _this->PatternSize[i] = 64;
256
263
  if ((!len) || (nInd + len > dwMemLength - 6)
257
- || ((_this->Patterns[iPat] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL)) continue;
258
- LPBYTE src = (LPBYTE)(lpStream+nInd);
264
+ || ((_this->Patterns[i] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL)) continue;
265
+ src = (LPBYTE)(lpStream+nInd);
259
266
  // Unpacking pattern
260
- MODCOMMAND *p = _this->Patterns[iPat];
261
- UINT row = 0;
262
- UINT j = 0;
267
+ p = _this->Patterns[i];
268
+ j = 0;
263
269
  while (j < len)
264
270
  {
265
271
  BYTE b = src[j++];
@@ -310,15 +316,15 @@ BOOL CSoundFile_ReadS3M(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
310
316
  }
311
317
  }
312
318
  // Reading samples
313
- for (UINT iRaw=1; iRaw<=insnum; iRaw++) if ((_this->Ins[iRaw].nLength) && (insfile[iRaw]))
319
+ for (i=1; i<=insnum; i++) if ((_this->Ins[i].nLength) && (insfile[i]))
314
320
  {
315
321
  UINT flags = (psfh.version == 1) ? RS_PCM8S : RS_PCM8U;
316
- if (insflags[iRaw-1] & 4) flags += 5;
317
- if (insflags[iRaw-1] & 2) flags |= RSF_STEREO;
318
- if (inspack[iRaw-1] == 4) flags = RS_ADPCM4;
319
- dwMemPos = insfile[iRaw];
322
+ if (insflags[i-1] & 4) flags += 5;
323
+ if (insflags[i-1] & 2) flags |= RSF_STEREO;
324
+ if (inspack[i-1] == 4) flags = RS_ADPCM4;
325
+ dwMemPos = insfile[i];
320
326
  if (dwMemPos < dwMemLength)
321
- CSoundFile_ReadSample(_this, &_this->Ins[iRaw], flags, (LPSTR)(lpStream + dwMemPos), dwMemLength - dwMemPos);
327
+ CSoundFile_ReadSample(_this, &_this->Ins[i], flags, (LPSTR)(lpStream + dwMemPos), dwMemLength - dwMemPos);
322
328
  }
323
329
  _this->m_nMinPeriod = 64;
324
330
  _this->m_nMaxPeriod = 32767;
@@ -58,6 +58,8 @@ BOOL CSoundFile_ReadSTM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
58
58
  {
59
59
  const STMHEADER *phdr = (STMHEADER *)lpStream;
60
60
  DWORD dwMemPos = 0;
61
+ UINT nPatterns;
62
+ UINT j;
61
63
 
62
64
  if ((!lpStream) || (dwMemLength < sizeof(STMHEADER))) return FALSE;
63
65
  if ((phdr->filetype != 2) || (phdr->unused != 0x1A)
@@ -77,17 +79,17 @@ BOOL CSoundFile_ReadSTM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
77
79
  if (_this->m_nDefaultGlobalVolume > 256) _this->m_nDefaultGlobalVolume = 256;
78
80
  SDL_memcpy(_this->Order, phdr->patorder, 128);
79
81
  // Setting up channels
80
- for (UINT nSet=0; nSet<4; nSet++)
82
+ for (j=0; j<4; j++)
81
83
  {
82
- _this->ChnSettings[nSet].dwFlags = 0;
83
- _this->ChnSettings[nSet].nVolume = 64;
84
- _this->ChnSettings[nSet].nPan = (nSet & 1) ? 0x40 : 0xC0;
84
+ _this->ChnSettings[j].dwFlags = 0;
85
+ _this->ChnSettings[j].nVolume = 64;
86
+ _this->ChnSettings[j].nPan = (j & 1) ? 0x40 : 0xC0;
85
87
  }
86
88
  // Reading samples
87
- for (UINT nIns=0; nIns<31; nIns++)
89
+ for (j=0; j<31; j++)
88
90
  {
89
- MODINSTRUMENT *pIns = &_this->Ins[nIns+1];
90
- const STMSAMPLE *pStm = &phdr->sample[nIns]; // STM sample data
91
+ MODINSTRUMENT *pIns = &_this->Ins[j+1];
92
+ const STMSAMPLE *pStm = &phdr->sample[j]; // STM sample data
91
93
  pIns->nC4Speed = bswapLE16(pStm->c2spd);
92
94
  pIns->nGlobalVol = 64;
93
95
  pIns->nVolume = pStm->volume << 2;
@@ -99,17 +101,20 @@ BOOL CSoundFile_ReadSTM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
99
101
  if ((pIns->nLoopEnd > pIns->nLoopStart) && (pIns->nLoopEnd != 0xFFFF)) pIns->uFlags |= CHN_LOOP;
100
102
  }
101
103
  dwMemPos = sizeof(STMHEADER);
102
- for (UINT nOrd=0; nOrd<MAX_ORDERS; nOrd++) if (_this->Order[nOrd] >= 99) _this->Order[nOrd] = 0xFF;
103
- UINT nPatterns = phdr->numpat;
104
+ for (j=0; j<MAX_ORDERS; j++) if (_this->Order[j] >= 99) _this->Order[j] = 0xFF;
105
+ nPatterns = phdr->numpat;
104
106
  if (nPatterns > MAX_PATTERNS) nPatterns = MAX_PATTERNS;
105
- for (UINT nPat=0; nPat<nPatterns; nPat++)
107
+ for (j=0; j<nPatterns; j++)
106
108
  {
109
+ MODCOMMAND *m;
110
+ const STMNOTE *p;
111
+ UINT n;
107
112
  if (dwMemPos + 64*4*4 > dwMemLength) return TRUE;
108
- _this->PatternSize[nPat] = 64;
109
- if ((_this->Patterns[nPat] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL) return TRUE;
110
- MODCOMMAND *m = _this->Patterns[nPat];
111
- const STMNOTE *p = (const STMNOTE *)(lpStream + dwMemPos);
112
- for (UINT n=0; n<64*4; n++, p++, m++)
113
+ _this->PatternSize[j] = 64;
114
+ if ((_this->Patterns[j] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL) return TRUE;
115
+ m = _this->Patterns[j];
116
+ p = (const STMNOTE *)(lpStream + dwMemPos);
117
+ for (n=0; n<64*4; n++, p++, m++)
113
118
  {
114
119
  UINT note,ins,vol,cmd;
115
120
  // extract the various information from the 4 bytes that
@@ -162,13 +167,13 @@ BOOL CSoundFile_ReadSTM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
162
167
  dwMemPos += 64*4*4;
163
168
  }
164
169
  // Reading Samples
165
- for (UINT nSmp=1; nSmp<=31; nSmp++)
170
+ for (j=1; j<=31; j++)
166
171
  {
167
- MODINSTRUMENT *pIns = &_this->Ins[nSmp];
172
+ MODINSTRUMENT *pIns = &_this->Ins[j];
168
173
  dwMemPos = (dwMemPos + 15) & (~15);
169
174
  if (pIns->nLength)
170
175
  {
171
- UINT nPos = ((UINT)phdr->sample[nSmp-1].reserved) << 4;
176
+ UINT nPos = ((UINT)phdr->sample[j-1].reserved) << 4;
172
177
  if ((nPos >= sizeof(STMHEADER)) && (nPos+pIns->nLength <= dwMemLength)) dwMemPos = nPos;
173
178
  if (dwMemPos < dwMemLength)
174
179
  {
@@ -43,8 +43,9 @@ BOOL CSoundFile_ReadUlt(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
43
43
  {
44
44
  ULTHEADER *pmh = (ULTHEADER *)lpStream;
45
45
  ULTSAMPLE *pus;
46
- UINT nos, nop;
46
+ UINT nos, nop, j;
47
47
  DWORD dwMemPos = 0;
48
+ UINT smpsize = 64;
48
49
 
49
50
  // try to read module header
50
51
  if ((!lpStream) || (dwMemLength < 0x100)) return FALSE;
@@ -65,13 +66,13 @@ BOOL CSoundFile_ReadUlt(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
65
66
  nos = lpStream[dwMemPos++];
66
67
  _this->m_nSamples = nos;
67
68
  if (_this->m_nSamples >= MAX_SAMPLES) _this->m_nSamples = MAX_SAMPLES-1;
68
- UINT smpsize = 64;
69
69
  if (pmh->id[14] >= '4') smpsize += 2;
70
70
  if (dwMemPos + nos*smpsize + 256 + 2 > dwMemLength) return TRUE;
71
- for (UINT ins=1; ins<=nos; ins++, dwMemPos+=smpsize) if (ins<=_this->m_nSamples)
71
+ for (j=1; j<=nos; j++, dwMemPos+=smpsize) if (j<=_this->m_nSamples)
72
72
  {
73
+ MODINSTRUMENT *pins;
73
74
  pus = (ULTSAMPLE *)(lpStream+dwMemPos);
74
- MODINSTRUMENT *pins = &_this->Ins[ins];
75
+ pins = &_this->Ins[j];
75
76
  pins->nLoopStart = pus->loopstart;
76
77
  pins->nLoopEnd = pus->loopend;
77
78
  pins->nLength = pus->sizeend - pus->sizestart;
@@ -98,48 +99,50 @@ BOOL CSoundFile_ReadUlt(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
98
99
  dwMemPos += 2;
99
100
  if (_this->m_nChannels > 32) _this->m_nChannels = 32;
100
101
  // Default channel settings
101
- for (UINT nSet=0; nSet<_this->m_nChannels; nSet++)
102
+ for (j=0; j<_this->m_nChannels; j++)
102
103
  {
103
- _this->ChnSettings[nSet].nVolume = 64;
104
- _this->ChnSettings[nSet].nPan = (nSet & 1) ? 0x40 : 0xC0;
104
+ _this->ChnSettings[j].nVolume = 64;
105
+ _this->ChnSettings[j].nPan = (j & 1) ? 0x40 : 0xC0;
105
106
  }
106
107
  // read pan position table for v1.5 and higher
107
108
  if(pmh->id[14]>='3')
108
109
  {
109
110
  if (dwMemPos + _this->m_nChannels > dwMemLength) return TRUE;
110
- for(UINT t=0; t<_this->m_nChannels; t++)
111
+ for(j=0; j<_this->m_nChannels; j++)
111
112
  {
112
- _this->ChnSettings[t].nPan = (lpStream[dwMemPos++] << 4) + 8;
113
- if (_this->ChnSettings[t].nPan > 256) _this->ChnSettings[t].nPan = 256;
113
+ _this->ChnSettings[j].nPan = (lpStream[dwMemPos++] << 4) + 8;
114
+ if (_this->ChnSettings[j].nPan > 256) _this->ChnSettings[j].nPan = 256;
114
115
  }
115
116
  }
116
117
  // Allocating Patterns
117
- for (UINT nAllocPat=0; nAllocPat<nop; nAllocPat++)
118
+ for (j=0; j<nop; j++)
118
119
  {
119
- if (nAllocPat < MAX_PATTERNS)
120
+ if (j < MAX_PATTERNS)
120
121
  {
121
- _this->PatternSize[nAllocPat] = 64;
122
- _this->Patterns[nAllocPat] = CSoundFile_AllocatePattern(64, _this->m_nChannels);
122
+ _this->PatternSize[j] = 64;
123
+ _this->Patterns[j] = CSoundFile_AllocatePattern(64, _this->m_nChannels);
123
124
  }
124
125
  }
125
126
  // Reading Patterns
126
- for (UINT nChn=0; nChn<_this->m_nChannels; nChn++)
127
+ for (j=0; j<_this->m_nChannels; j++)
127
128
  {
128
- for (UINT nPat=0; nPat<nop; nPat++)
129
+ UINT nPat=0;
130
+ for ( ; nPat<nop; nPat++)
129
131
  {
130
132
  MODCOMMAND *pat = NULL;
133
+ UINT row = 0;
131
134
 
132
135
  if (nPat < MAX_PATTERNS)
133
136
  {
134
137
  pat = _this->Patterns[nPat];
135
- if (pat) pat += nChn;
138
+ if (pat) pat += j;
136
139
  }
137
- UINT row = 0;
138
140
  while (row < 64)
139
141
  {
142
+ UINT rep, note, instr, eff, dat1, dat2, cmd1, cmd2;
140
143
  if (dwMemPos > dwMemLength - 5) return TRUE;
141
- UINT rep = 1;
142
- UINT note = lpStream[dwMemPos++];
144
+ rep = 1;
145
+ note = lpStream[dwMemPos++];
143
146
  if (note == 0xFC)
144
147
  {
145
148
  rep = lpStream[dwMemPos];
@@ -148,12 +151,12 @@ BOOL CSoundFile_ReadUlt(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
148
151
  if (dwMemPos > dwMemLength - 4) return TRUE;
149
152
  }
150
153
 
151
- UINT instr = lpStream[dwMemPos++];
152
- UINT eff = lpStream[dwMemPos++];
153
- UINT dat1 = lpStream[dwMemPos++];
154
- UINT dat2 = lpStream[dwMemPos++];
155
- UINT cmd1 = eff & 0x0F;
156
- UINT cmd2 = eff >> 4;
154
+ instr = lpStream[dwMemPos++];
155
+ eff = lpStream[dwMemPos++];
156
+ dat1 = lpStream[dwMemPos++];
157
+ dat2 = lpStream[dwMemPos++];
158
+ cmd1 = eff & 0x0F;
159
+ cmd2 = eff >> 4;
157
160
  if (cmd1 == 0x0C) dat1 >>= 2; else
158
161
  if (cmd1 == 0x0B) { cmd1 = dat1 = 0; }
159
162
  if (cmd2 == 0x0C) dat2 >>= 2; else
@@ -197,11 +200,12 @@ BOOL CSoundFile_ReadUlt(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLeng
197
200
  }
198
201
  }
199
202
  // Reading Instruments
200
- for (UINT smp=1; smp<=_this->m_nSamples; smp++) if (_this->Ins[smp].nLength)
203
+ for (j=1; j<=_this->m_nSamples; j++) if (_this->Ins[j].nLength)
201
204
  {
205
+ UINT flags;
202
206
  if (dwMemPos >= dwMemLength) return TRUE;
203
- UINT flags = (_this->Ins[smp].uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8S;
204
- dwMemPos += CSoundFile_ReadSample(_this, &_this->Ins[smp], flags, (LPSTR)(lpStream+dwMemPos), dwMemLength - dwMemPos);
207
+ flags = (_this->Ins[j].uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8S;
208
+ dwMemPos += CSoundFile_ReadSample(_this, &_this->Ins[j], flags, (LPSTR)(lpStream+dwMemPos), dwMemLength - dwMemPos);
205
209
  }
206
210
  return TRUE;
207
211
  }