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.
- checksums.yaml +4 -4
- data/dependencies/SDL/include/SDL.h +1 -0
- data/dependencies/SDL/include/SDL_assert.h +4 -2
- data/dependencies/SDL/include/SDL_atomic.h +20 -0
- data/dependencies/SDL/include/SDL_audio.h +40 -4
- data/dependencies/SDL/include/SDL_blendmode.h +4 -6
- data/dependencies/SDL/include/SDL_clipboard.h +47 -0
- data/dependencies/SDL/include/SDL_config.h +71 -45
- data/dependencies/SDL/include/SDL_cpuinfo.h +39 -4
- data/dependencies/SDL/include/SDL_egl.h +59 -9
- data/dependencies/SDL/include/SDL_endian.h +34 -3
- data/dependencies/SDL/include/SDL_events.h +32 -1
- data/dependencies/SDL/include/SDL_filesystem.h +5 -1
- data/dependencies/SDL/include/SDL_gamecontroller.h +78 -5
- data/dependencies/SDL/include/SDL_guid.h +100 -0
- data/dependencies/SDL/include/SDL_hints.h +645 -43
- data/dependencies/SDL/include/SDL_joystick.h +127 -7
- data/dependencies/SDL/include/SDL_keyboard.h +38 -1
- data/dependencies/SDL/include/SDL_keycode.h +6 -1
- data/dependencies/SDL/include/SDL_log.h +2 -2
- data/dependencies/SDL/include/SDL_main.h +42 -2
- data/dependencies/SDL/include/SDL_metal.h +2 -1
- data/dependencies/SDL/include/SDL_mouse.h +12 -1
- data/dependencies/SDL/include/SDL_opengl.h +0 -51
- data/dependencies/SDL/include/SDL_opengl_glext.h +2260 -231
- data/dependencies/SDL/include/SDL_opengles2_gl2.h +374 -339
- data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +3479 -1496
- data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +6 -9
- data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +43 -14
- data/dependencies/SDL/include/SDL_platform.h +32 -6
- data/dependencies/SDL/include/SDL_rect.h +154 -2
- data/dependencies/SDL/include/SDL_render.h +46 -17
- data/dependencies/SDL/include/SDL_revision.h +6 -1
- data/dependencies/SDL/include/SDL_rwops.h +1 -15
- data/dependencies/SDL/include/SDL_scancode.h +46 -21
- data/dependencies/SDL/include/SDL_sensor.h +24 -3
- data/dependencies/SDL/include/SDL_stdinc.h +119 -8
- data/dependencies/SDL/include/SDL_surface.h +3 -1
- data/dependencies/SDL/include/SDL_system.h +66 -6
- data/dependencies/SDL/include/SDL_syswm.h +2 -0
- data/dependencies/SDL/include/SDL_test_common.h +1 -0
- data/dependencies/SDL/include/SDL_test_font.h +90 -3
- data/dependencies/SDL/include/SDL_thread.h +3 -3
- data/dependencies/SDL/include/SDL_touch.h +8 -0
- data/dependencies/SDL/include/SDL_version.h +19 -3
- data/dependencies/SDL/include/SDL_video.h +71 -9
- data/dependencies/SDL/include/begin_code.h +4 -4
- data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
- data/dependencies/SDL_sound/SDL_sound.c +210 -71
- data/dependencies/SDL_sound/SDL_sound.h +1 -1
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +111 -168
- data/dependencies/SDL_sound/SDL_sound_flac.c +0 -6
- data/dependencies/SDL_sound/SDL_sound_internal.h +27 -5
- data/dependencies/SDL_sound/SDL_sound_modplug.c +20 -8
- data/dependencies/SDL_sound/SDL_sound_mp3.c +11 -7
- data/dependencies/SDL_sound/SDL_sound_raw.c +1 -1
- data/dependencies/SDL_sound/SDL_sound_shn.c +1 -5
- data/dependencies/SDL_sound/SDL_sound_voc.c +1 -1
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +2 -4
- data/dependencies/SDL_sound/SDL_sound_wav.c +44 -20
- data/dependencies/SDL_sound/dr_flac.h +237 -95
- data/dependencies/SDL_sound/dr_mp3.h +46 -33
- data/dependencies/SDL_sound/libmodplug/fastmix.c +53 -39
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +0 -12
- data/dependencies/SDL_sound/libmodplug/load_669.c +37 -32
- data/dependencies/SDL_sound/libmodplug/load_amf.c +57 -44
- data/dependencies/SDL_sound/libmodplug/load_ams.c +127 -100
- data/dependencies/SDL_sound/libmodplug/load_dbm.c +40 -37
- data/dependencies/SDL_sound/libmodplug/load_dmf.c +61 -49
- data/dependencies/SDL_sound/libmodplug/load_dsm.c +18 -13
- data/dependencies/SDL_sound/libmodplug/load_far.c +31 -24
- data/dependencies/SDL_sound/libmodplug/load_gdm.c +27 -21
- data/dependencies/SDL_sound/libmodplug/load_it.c +106 -91
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +43 -35
- data/dependencies/SDL_sound/libmodplug/load_med.c +66 -52
- data/dependencies/SDL_sound/libmodplug/load_mod.c +30 -26
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +61 -50
- data/dependencies/SDL_sound/libmodplug/load_mtm.c +23 -17
- data/dependencies/SDL_sound/libmodplug/load_okt.c +18 -16
- data/dependencies/SDL_sound/libmodplug/load_psm.c +44 -32
- data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -14
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +59 -53
- data/dependencies/SDL_sound/libmodplug/load_stm.c +23 -18
- data/dependencies/SDL_sound/libmodplug/load_ult.c +33 -29
- data/dependencies/SDL_sound/libmodplug/load_xm.c +64 -57
- data/dependencies/SDL_sound/libmodplug/mmcmp.c +2 -1
- data/dependencies/SDL_sound/libmodplug/snd_dsp.c +30 -20
- data/dependencies/SDL_sound/libmodplug/snd_flt.c +6 -4
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +91 -65
- data/dependencies/SDL_sound/libmodplug/sndfile.c +91 -66
- data/dependencies/SDL_sound/libmodplug/sndmix.c +58 -35
- data/dependencies/SDL_sound/stb_vorbis.h +14 -9
- data/dependencies/mojoAL/mojoal.c +41 -24
- data/dependencies/utf8proc/utf8proc.c +1 -1
- data/dependencies/utf8proc/utf8proc.h +1 -1
- data/dependencies/utf8proc/utf8proc_data.h +3366 -3184
- data/lib/SDL2.dll +0 -0
- data/lib64/SDL2.dll +0 -0
- data/src/Window.cpp +3 -0
- metadata +5 -4
@@ -44,7 +44,7 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
44
44
|
// BYTE pkinf[MAX_SAMPLES];
|
45
45
|
const AMSFILEHEADER *pfh = (AMSFILEHEADER *)lpStream;
|
46
46
|
DWORD dwMemPos;
|
47
|
-
UINT tmp, tmp2;
|
47
|
+
UINT tmp, tmp2, i;
|
48
48
|
|
49
49
|
if ((!lpStream) || (dwMemLength < 1024)) return FALSE;
|
50
50
|
if ((pfh->verhi != 0x01) || (SDL_strncmp(pfh->szHeader, "Extreme", 7))
|
@@ -59,10 +59,10 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
59
59
|
_this->m_nInstruments = 0;
|
60
60
|
_this->m_nChannels = (pfh->chncfg & 0x1F) + 1;
|
61
61
|
_this->m_nSamples = pfh->samples;
|
62
|
-
for (
|
62
|
+
for (i=1; i<=_this->m_nSamples; i++, dwMemPos += sizeof(AMSSAMPLEHEADER))
|
63
63
|
{
|
64
64
|
const AMSSAMPLEHEADER *psh = (AMSSAMPLEHEADER *)(lpStream + dwMemPos);
|
65
|
-
MODINSTRUMENT *pins = &_this->Ins[
|
65
|
+
MODINSTRUMENT *pins = &_this->Ins[i];
|
66
66
|
pins->nLength = psh->length;
|
67
67
|
pins->nLoopStart = psh->loopstart;
|
68
68
|
pins->nLoopEnd = psh->loopend;
|
@@ -74,21 +74,21 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
74
74
|
pins->nFineTune = MOD2XMFineTune(psh->finetune_and_pan & 0x0F);
|
75
75
|
pins->uFlags = (psh->infobyte & 0x80) ? CHN_16BIT : 0;
|
76
76
|
if ((pins->nLoopEnd <= pins->nLength) && (pins->nLoopStart+4 <= pins->nLoopEnd)) pins->uFlags |= CHN_LOOP;
|
77
|
-
// pkinf[
|
77
|
+
// pkinf[i] = psh->infobyte;
|
78
78
|
}
|
79
79
|
// Read Song Name
|
80
80
|
tmp = lpStream[dwMemPos++];
|
81
81
|
if (dwMemPos + tmp + 1 >= dwMemLength) return TRUE;
|
82
82
|
dwMemPos += tmp;
|
83
83
|
// Read sample names
|
84
|
-
for (
|
84
|
+
for (i=1; i<=_this->m_nSamples; i++)
|
85
85
|
{
|
86
86
|
if (dwMemPos + 32 >= dwMemLength) return TRUE;
|
87
87
|
tmp = lpStream[dwMemPos++];
|
88
88
|
dwMemPos += tmp;
|
89
89
|
}
|
90
90
|
// Skip Channel names
|
91
|
-
for (
|
91
|
+
for (i=0; i<_this->m_nChannels; i++)
|
92
92
|
{
|
93
93
|
if (dwMemPos + 32 >= dwMemLength) return TRUE;
|
94
94
|
tmp = lpStream[dwMemPos++];
|
@@ -98,12 +98,12 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
98
98
|
_this->m_lpszPatternNames = (char *) SDL_calloc(pfh->patterns, 32); // changed from CHAR
|
99
99
|
if (!_this->m_lpszPatternNames) return TRUE;
|
100
100
|
_this->m_nPatternNames = pfh->patterns;
|
101
|
-
for (
|
101
|
+
for (i=0; i < _this->m_nPatternNames; i++)
|
102
102
|
{
|
103
103
|
if (dwMemPos + 32 >= dwMemLength) return TRUE;
|
104
104
|
tmp = lpStream[dwMemPos++];
|
105
105
|
tmp2 = (tmp < 32) ? tmp : 31;
|
106
|
-
if (tmp2) SDL_memcpy(_this->m_lpszPatternNames+
|
106
|
+
if (tmp2) SDL_memcpy(_this->m_lpszPatternNames+i*32, lpStream+dwMemPos, tmp2);
|
107
107
|
dwMemPos += tmp;
|
108
108
|
}
|
109
109
|
// Read Song Comments
|
@@ -117,27 +117,34 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
117
117
|
}
|
118
118
|
// Read Order List
|
119
119
|
if (2*pfh->orders >= dwMemLength || dwMemPos > dwMemLength - 2*pfh->orders) return TRUE;
|
120
|
-
for (
|
120
|
+
for (i=0; i<pfh->orders; i++, dwMemPos += 2)
|
121
121
|
{
|
122
122
|
UINT n = *((WORD *)(lpStream+dwMemPos));
|
123
|
-
_this->Order[
|
123
|
+
_this->Order[i] = (BYTE)n;
|
124
124
|
}
|
125
125
|
// Read Patterns
|
126
|
-
for (
|
126
|
+
for (i=0; i<pfh->patterns; i++)
|
127
127
|
{
|
128
|
+
MODCOMMAND *m;
|
129
|
+
const BYTE *p;
|
130
|
+
UINT len, row, j;
|
128
131
|
if (dwMemPos + 4 >= dwMemLength) return TRUE;
|
129
|
-
|
132
|
+
len = *((DWORD *)(lpStream + dwMemPos));
|
130
133
|
dwMemPos += 4;
|
131
134
|
if ((len >= dwMemLength) || (dwMemPos > dwMemLength - len)) return TRUE;
|
132
|
-
_this->PatternSize[
|
133
|
-
|
135
|
+
_this->PatternSize[i] = 64;
|
136
|
+
m = CSoundFile_AllocatePattern(_this->PatternSize[i], _this->m_nChannels);
|
134
137
|
if (!m) return TRUE;
|
135
|
-
_this->Patterns[
|
136
|
-
|
137
|
-
|
138
|
-
while ((row < _this->PatternSize[
|
138
|
+
_this->Patterns[i] = m;
|
139
|
+
p = lpStream + dwMemPos;
|
140
|
+
row = 0, j = 0;
|
141
|
+
while ((row < _this->PatternSize[i]) && (j+2 < len))
|
139
142
|
{
|
140
|
-
BYTE b0
|
143
|
+
BYTE b0, b1, b2;
|
144
|
+
UINT ch;
|
145
|
+
|
146
|
+
b0 = p[j++];
|
147
|
+
ch = b0 & 0x3F;
|
141
148
|
|
142
149
|
if (b0 == 0xff)
|
143
150
|
{
|
@@ -145,14 +152,14 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
145
152
|
continue;
|
146
153
|
}
|
147
154
|
|
148
|
-
|
149
|
-
|
150
|
-
|
155
|
+
b1 = p[j++];
|
156
|
+
b2 = 0;
|
157
|
+
ch = b0 & 0x3F;
|
151
158
|
// Note+Instr
|
152
159
|
if (!(b0 & 0x40))
|
153
160
|
{
|
154
|
-
if (
|
155
|
-
b2 = p[
|
161
|
+
if (j+1 > len) break;
|
162
|
+
b2 = p[j++];
|
156
163
|
if (ch < _this->m_nChannels)
|
157
164
|
{
|
158
165
|
if (b1 & 0x7F) m[ch].note = (b1 & 0x7F) + 25;
|
@@ -160,9 +167,9 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
160
167
|
}
|
161
168
|
if (b1 & 0x80)
|
162
169
|
{
|
163
|
-
if (
|
170
|
+
if (j+1 > len) break;
|
164
171
|
b0 |= 0x40;
|
165
|
-
b1 = p[
|
172
|
+
b1 = p[j++];
|
166
173
|
}
|
167
174
|
}
|
168
175
|
// Effect
|
@@ -178,8 +185,8 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
178
185
|
}
|
179
186
|
} else
|
180
187
|
{
|
181
|
-
if (
|
182
|
-
b2 = p[
|
188
|
+
if (j+1 > len) break;
|
189
|
+
b2 = p[j++];
|
183
190
|
if (ch < _this->m_nChannels)
|
184
191
|
{
|
185
192
|
UINT cmd = b1 & 0x3F;
|
@@ -221,9 +228,9 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
221
228
|
}
|
222
229
|
if (b1 & 0x80)
|
223
230
|
{
|
224
|
-
if (
|
225
|
-
b1 = p[
|
226
|
-
if (
|
231
|
+
if (j+1 > len) break;
|
232
|
+
b1 = p[j++];
|
233
|
+
if (j <= len) goto anothercommand;
|
227
234
|
}
|
228
235
|
}
|
229
236
|
if (b0 & 0x80)
|
@@ -235,12 +242,13 @@ BOOL CSoundFile_ReadAMS(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
235
242
|
dwMemPos += len;
|
236
243
|
}
|
237
244
|
// Read Samples
|
238
|
-
for (
|
245
|
+
for (i=1; i<=_this->m_nSamples; i++) if (_this->Ins[i].nLength)
|
239
246
|
{
|
247
|
+
UINT flags;
|
240
248
|
if (dwMemPos >= dwMemLength - 9) return TRUE;
|
241
|
-
|
242
|
-
if (!AMSUnpackCheck(lpStream+dwMemPos, dwMemLength-dwMemPos, &_this->Ins[
|
243
|
-
dwMemPos += CSoundFile_ReadSample(_this, &_this->Ins[
|
249
|
+
flags = (_this->Ins[i].uFlags & CHN_16BIT) ? RS_AMS16 : RS_AMS8;
|
250
|
+
if (!AMSUnpackCheck(lpStream+dwMemPos, dwMemLength-dwMemPos, &_this->Ins[i])) break;
|
251
|
+
dwMemPos += CSoundFile_ReadSample(_this, &_this->Ins[i], flags, (LPCSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos);
|
244
252
|
}
|
245
253
|
return TRUE;
|
246
254
|
}
|
@@ -314,6 +322,7 @@ BOOL CSoundFile_ReadAMS2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
314
322
|
DWORD dwMemPos;
|
315
323
|
BYTE smpmap[16];
|
316
324
|
BYTE packedsamples[MAX_SAMPLES];
|
325
|
+
UINT i;
|
317
326
|
|
318
327
|
if ((pfh->dwHdr1 != 0x68534D41) || (pfh->wHdr2 != 0x7264)
|
319
328
|
|| (pfh->b1A != 0x1A) || (pfh->titlelen > 30)) return FALSE;
|
@@ -329,14 +338,17 @@ BOOL CSoundFile_ReadAMS2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
329
338
|
_this->m_nInstruments = psh->instruments;
|
330
339
|
_this->m_nSamples = 0;
|
331
340
|
if (psh->flags & 0x40) _this->m_dwSongFlags |= SONG_LINEARSLIDES;
|
332
|
-
for (
|
341
|
+
for (i=1; i<=_this->m_nInstruments; i++)
|
333
342
|
{
|
343
|
+
const AMS2INSTRUMENT *pins;
|
344
|
+
const AMS2ENVELOPE *volenv, *panenv, *pitchenv;
|
345
|
+
INSTRUMENTHEADER *penv;
|
346
|
+
UINT c, envflags;
|
334
347
|
if (dwMemPos >= dwMemLength) return TRUE;
|
335
|
-
|
336
|
-
dwMemPos +=
|
337
|
-
|
348
|
+
c = lpStream[dwMemPos];/* insnamelen */
|
349
|
+
dwMemPos += c + 1;
|
350
|
+
pins = (AMS2INSTRUMENT *)(lpStream + dwMemPos);
|
338
351
|
dwMemPos += sizeof(AMS2INSTRUMENT);
|
339
|
-
const AMS2ENVELOPE *volenv, *panenv, *pitchenv;
|
340
352
|
if (dwMemPos + sizeof(AMS2ENVELOPE) > dwMemLength) return TRUE;
|
341
353
|
volenv = (AMS2ENVELOPE *)(lpStream+dwMemPos);
|
342
354
|
dwMemPos += 5 + volenv->points*3;
|
@@ -347,53 +359,55 @@ BOOL CSoundFile_ReadAMS2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
347
359
|
pitchenv = (AMS2ENVELOPE *)(lpStream+dwMemPos);
|
348
360
|
dwMemPos += 5 + pitchenv->points*3;
|
349
361
|
if (dwMemPos >= dwMemLength) return TRUE;
|
350
|
-
|
362
|
+
penv = (INSTRUMENTHEADER *) SDL_calloc(1, sizeof (INSTRUMENTHEADER));
|
351
363
|
if (!penv) return TRUE;
|
352
364
|
SDL_memset(smpmap, 0, sizeof(smpmap));
|
353
|
-
for (
|
365
|
+
for (c=0; c<pins->samples; c++)
|
354
366
|
{
|
355
|
-
if ((
|
367
|
+
if ((c >= 16) || (_this->m_nSamples+1 >= MAX_SAMPLES)) break;
|
356
368
|
_this->m_nSamples++;
|
357
|
-
smpmap[
|
369
|
+
smpmap[c] = _this->m_nSamples;
|
358
370
|
}
|
359
371
|
penv->nGlobalVol = 64;
|
360
372
|
penv->nPan = 128;
|
361
373
|
penv->nPPC = 60;
|
362
|
-
_this->Headers[
|
363
|
-
for (
|
374
|
+
_this->Headers[i] = penv;
|
375
|
+
for (c=0; c<NOTE_MAX; c++)
|
364
376
|
{
|
365
|
-
penv->NoteMap[
|
366
|
-
penv->Keyboard[
|
377
|
+
penv->NoteMap[c] = c+1;
|
378
|
+
penv->Keyboard[c] = smpmap[pins->notemap[c] & 0x0F];
|
367
379
|
}
|
368
380
|
// Volume Envelope
|
369
381
|
{
|
370
|
-
UINT pos = 0;
|
382
|
+
UINT e, pos = 0;
|
371
383
|
penv->nVolEnv = (volenv->points > 16) ? 16 : volenv->points;
|
372
384
|
penv->nVolSustainBegin = penv->nVolSustainEnd = volenv->sustain;
|
373
385
|
penv->nVolLoopStart = volenv->loopbegin;
|
374
386
|
penv->nVolLoopEnd = volenv->loopend;
|
375
|
-
for (
|
387
|
+
for (e=0; e<penv->nVolEnv; e++)
|
376
388
|
{
|
377
|
-
penv->VolEnv[
|
378
|
-
pos += volenv->info[
|
379
|
-
penv->VolPoints[
|
389
|
+
penv->VolEnv[e] = (BYTE)((volenv->info[e*3+2] & 0x7F) >> 1);
|
390
|
+
pos += volenv->info[e*3] + ((volenv->info[e*3+1] & 1) << 8);
|
391
|
+
penv->VolPoints[e] = (WORD)pos;
|
380
392
|
}
|
381
393
|
}
|
382
394
|
if (dwMemPos + 5 > dwMemLength) return TRUE;
|
383
395
|
penv->nFadeOut = (((lpStream[dwMemPos+2] & 0x0F) << 8) | (lpStream[dwMemPos+1])) << 3;
|
384
|
-
|
396
|
+
envflags = lpStream[dwMemPos+3];
|
385
397
|
if (envflags & 0x01) penv->dwFlags |= ENV_VOLLOOP;
|
386
398
|
if (envflags & 0x02) penv->dwFlags |= ENV_VOLSUSTAIN;
|
387
399
|
if (envflags & 0x04) penv->dwFlags |= ENV_VOLUME;
|
388
400
|
dwMemPos += 5;
|
389
401
|
// Read Samples
|
390
|
-
for (
|
402
|
+
for (c=0; c<pins->samples; c++)
|
391
403
|
{
|
404
|
+
MODINSTRUMENT *psmp;
|
405
|
+
UINT l;
|
392
406
|
if (dwMemPos + 1 > dwMemLength) return TRUE;
|
393
|
-
|
394
|
-
|
395
|
-
if (dwMemPos +
|
396
|
-
dwMemPos +=
|
407
|
+
psmp = ((c < 16) && (smpmap[c])) ? &_this->Ins[smpmap[c]] : NULL;
|
408
|
+
l = lpStream[dwMemPos]; /* namelen */
|
409
|
+
if (dwMemPos + l + 1 > dwMemLength) return TRUE;
|
410
|
+
dwMemPos += l + 1;
|
397
411
|
if (dwMemPos + sizeof(AMS2SAMPLE) > dwMemLength) return TRUE;
|
398
412
|
if (psmp)
|
399
413
|
{
|
@@ -406,7 +420,7 @@ BOOL CSoundFile_ReadAMS2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
406
420
|
psmp->nC4Speed = pams->c4speed;
|
407
421
|
psmp->RelativeTone = pams->transpose;
|
408
422
|
psmp->nVolume = pams->volume / 2;
|
409
|
-
packedsamples[smpmap[
|
423
|
+
packedsamples[smpmap[c]] = pams->flags;
|
410
424
|
if (pams->flags & 0x04) psmp->uFlags |= CHN_16BIT;
|
411
425
|
if (pams->flags & 0x08) psmp->uFlags |= CHN_LOOP;
|
412
426
|
if (pams->flags & 0x10) psmp->uFlags |= CHN_PINGPONGLOOP;
|
@@ -417,23 +431,23 @@ BOOL CSoundFile_ReadAMS2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
417
431
|
if (dwMemPos + 256 >= dwMemLength) return TRUE;
|
418
432
|
// Comments
|
419
433
|
{
|
420
|
-
UINT
|
421
|
-
dwMemPos +=
|
434
|
+
UINT c = lpStream[dwMemPos]; /* namelen */
|
435
|
+
dwMemPos += c + 1;
|
422
436
|
// channel names
|
423
|
-
for (
|
437
|
+
for (i=0; i<32; i++)
|
424
438
|
{
|
425
|
-
|
426
|
-
dwMemPos +=
|
427
|
-
if (dwMemPos +
|
439
|
+
c = lpStream[dwMemPos]; /* namelen */
|
440
|
+
dwMemPos += c + 1;
|
441
|
+
if (dwMemPos + c + 256 >= dwMemLength) return TRUE;
|
428
442
|
}
|
429
443
|
// packed comments (ignored)
|
430
|
-
|
431
|
-
dwMemPos +=
|
444
|
+
c = *((LPDWORD)(lpStream+dwMemPos)); /* songtextlen */
|
445
|
+
dwMemPos += c;
|
432
446
|
if (dwMemPos + 256 >= dwMemLength) return TRUE;
|
433
447
|
}
|
434
448
|
// Order List
|
435
449
|
{
|
436
|
-
for (
|
450
|
+
for (i=0; i<MAX_ORDERS; i++)
|
437
451
|
{
|
438
452
|
_this->Order[i] = 0xFF;
|
439
453
|
if (dwMemPos + 2 >= dwMemLength) return TRUE;
|
@@ -445,34 +459,40 @@ BOOL CSoundFile_ReadAMS2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
445
459
|
}
|
446
460
|
}
|
447
461
|
// Pattern Data
|
448
|
-
for (
|
462
|
+
for (i=0; i<psh->patterns; i++)
|
449
463
|
{
|
464
|
+
//UINT patchn, patcmds;
|
465
|
+
UINT packedlen;
|
466
|
+
UINT numrows;
|
467
|
+
UINT patnamlen;
|
450
468
|
if (dwMemPos+8 >= dwMemLength) return TRUE;
|
451
|
-
|
452
|
-
|
453
|
-
//
|
454
|
-
//
|
455
|
-
|
469
|
+
packedlen = *((LPDWORD)(lpStream+dwMemPos));
|
470
|
+
numrows = 1 + (UINT)(lpStream[dwMemPos+4]);
|
471
|
+
//patchn = 1 + (UINT)(lpStream[dwMemPos+5] & 0x1F);
|
472
|
+
//patcmds = 1 + (UINT)(lpStream[dwMemPos+5] >> 5);
|
473
|
+
patnamlen = lpStream[dwMemPos+6];
|
456
474
|
dwMemPos += 4;
|
457
|
-
if ((
|
475
|
+
if ((i < MAX_PATTERNS) && (packedlen < dwMemLength-dwMemPos) && (numrows >= 8))
|
458
476
|
{
|
477
|
+
LPCBYTE psrc;
|
478
|
+
UINT pos,row;
|
459
479
|
if ((patnamlen) && (patnamlen < MAX_PATTERNNAME))
|
460
480
|
{
|
461
481
|
char s[MAX_PATTERNNAME]; // changed from CHAR
|
462
482
|
SDL_memcpy(s, lpStream+dwMemPos+3, patnamlen);
|
463
483
|
s[patnamlen] = 0;
|
464
|
-
CSoundFile_SetPatternName(_this,
|
484
|
+
CSoundFile_SetPatternName(_this, i, s);
|
465
485
|
}
|
466
|
-
_this->PatternSize[
|
467
|
-
_this->Patterns[
|
468
|
-
if (!_this->Patterns[
|
486
|
+
_this->PatternSize[i] = numrows;
|
487
|
+
_this->Patterns[i] = CSoundFile_AllocatePattern(numrows, _this->m_nChannels);
|
488
|
+
if (!_this->Patterns[i]) return TRUE;
|
469
489
|
// Unpack Pattern Data
|
470
|
-
|
471
|
-
|
472
|
-
|
490
|
+
psrc = lpStream + dwMemPos;
|
491
|
+
pos = 3 + patnamlen;
|
492
|
+
row = 0;
|
473
493
|
while ((pos < packedlen) && (row < numrows))
|
474
494
|
{
|
475
|
-
MODCOMMAND *m = _this->Patterns[
|
495
|
+
MODCOMMAND *m = _this->Patterns[i] + row * _this->m_nChannels;
|
476
496
|
UINT byte1 = psrc[pos++];
|
477
497
|
UINT byte2;
|
478
498
|
UINT ch = byte1 & 0x1F;
|
@@ -485,8 +505,9 @@ BOOL CSoundFile_ReadAMS2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
485
505
|
// Read Note + Instr
|
486
506
|
if (!(byte1 & 0x40))
|
487
507
|
{
|
508
|
+
UINT note;
|
488
509
|
byte2 = psrc[pos++];
|
489
|
-
|
510
|
+
note = byte2 & 0x7F;
|
490
511
|
if (note) m[ch].note = (note > 1) ? (note-1) : 0xFF;
|
491
512
|
m[ch].instr = psrc[pos++];
|
492
513
|
} else {
|
@@ -526,19 +547,19 @@ BOOL CSoundFile_ReadAMS2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
526
547
|
dwMemPos += packedlen;
|
527
548
|
}
|
528
549
|
// Read Samples
|
529
|
-
for (
|
550
|
+
for (i=1; i<=_this->m_nSamples; i++) if (_this->Ins[i].nLength)
|
530
551
|
{
|
531
|
-
if (dwMemPos >= dwMemLength - 9) return TRUE;
|
532
552
|
UINT flags;
|
533
|
-
if (
|
553
|
+
if (dwMemPos >= dwMemLength - 9) return TRUE;
|
554
|
+
if (packedsamples[i] & 0x03)
|
534
555
|
{
|
535
|
-
flags = (_this->Ins[
|
536
|
-
if (!AMSUnpackCheck(lpStream+dwMemPos, dwMemLength-dwMemPos, &_this->Ins[
|
556
|
+
flags = (_this->Ins[i].uFlags & CHN_16BIT) ? RS_AMS16 : RS_AMS8;
|
557
|
+
if (!AMSUnpackCheck(lpStream+dwMemPos, dwMemLength-dwMemPos, &_this->Ins[i])) break;
|
537
558
|
} else
|
538
559
|
{
|
539
|
-
flags = (_this->Ins[
|
560
|
+
flags = (_this->Ins[i].uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8S;
|
540
561
|
}
|
541
|
-
dwMemPos += CSoundFile_ReadSample(_this, &_this->Ins[
|
562
|
+
dwMemPos += CSoundFile_ReadSample(_this, &_this->Ins[i], flags, (LPCSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos);
|
542
563
|
}
|
543
564
|
return TRUE;
|
544
565
|
}
|
@@ -548,15 +569,19 @@ BOOL CSoundFile_ReadAMS2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
|
548
569
|
static BOOL AMSUnpackCheck(const BYTE *lpStream, DWORD dwMemLength, MODINSTRUMENT *ins)
|
549
570
|
// -----------------------------------------------------------------------------------
|
550
571
|
{
|
572
|
+
DWORD packedbytes;
|
573
|
+
DWORD samplebytes;
|
574
|
+
DWORD packedmin;
|
575
|
+
|
551
576
|
if (dwMemLength < 9) return FALSE;
|
552
|
-
|
577
|
+
packedbytes = *((DWORD *)(lpStream + 4));
|
553
578
|
|
554
|
-
|
579
|
+
samplebytes = ins->nLength;
|
555
580
|
if (samplebytes > MAX_SAMPLE_LENGTH) samplebytes = MAX_SAMPLE_LENGTH;
|
556
581
|
if (ins->uFlags & CHN_16BIT) samplebytes *= 2;
|
557
582
|
|
558
583
|
// RLE can pack a run of up to 255 bytes into 3 bytes.
|
559
|
-
|
584
|
+
packedmin = (samplebytes * 3) >> 8;
|
560
585
|
if (packedbytes < packedmin)
|
561
586
|
{
|
562
587
|
samplebytes = packedbytes * (255 / 3) + 2;
|
@@ -585,8 +610,9 @@ void AMSUnpack(const char *psrc, UINT inputlen, char *pdest, UINT dmax, char pac
|
|
585
610
|
signed char ch = psrc[i++];
|
586
611
|
if (ch == packcharacter)
|
587
612
|
{
|
613
|
+
BYTE ch2;
|
588
614
|
if (i >= inputlen) break;
|
589
|
-
|
615
|
+
ch2 = psrc[i++];
|
590
616
|
if (ch2)
|
591
617
|
{
|
592
618
|
if (i >= inputlen) break;
|
@@ -610,12 +636,12 @@ void AMSUnpack(const char *psrc, UINT inputlen, char *pdest, UINT dmax, char pac
|
|
610
636
|
{
|
611
637
|
signed char *p = amstmp;
|
612
638
|
UINT bitcount = 0x80, dh;
|
613
|
-
UINT k=0;
|
614
|
-
for (
|
639
|
+
UINT k=0, i, count;
|
640
|
+
for (i=0; i<dmax; i++)
|
615
641
|
{
|
616
642
|
BYTE al = *p++;
|
617
643
|
dh = 0;
|
618
|
-
for (
|
644
|
+
for (count=0; count<8; count++)
|
619
645
|
{
|
620
646
|
UINT bl = al & bitcount;
|
621
647
|
bl = ((bl|(bl<<8)) >> ((dh+8-count) & 7)) & 0xFF;
|
@@ -633,7 +659,8 @@ void AMSUnpack(const char *psrc, UINT inputlen, char *pdest, UINT dmax, char pac
|
|
633
659
|
// Delta Unpack
|
634
660
|
{
|
635
661
|
signed char old = 0;
|
636
|
-
|
662
|
+
UINT i;
|
663
|
+
for (i=0; i<dmax; i++)
|
637
664
|
{
|
638
665
|
int pos = ((LPBYTE)pdest)[i];
|
639
666
|
if ((pos != 128) && (pos & 0x80)) pos = -(pos & 0x7F);
|