gosu 1.4.4 → 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/include/Gosu/Version.hpp +1 -1
- data/lib/SDL2.dll +0 -0
- data/lib64/SDL2.dll +0 -0
- data/src/RubyGosu.cxx +1 -1
- data/src/Window.cpp +6 -4
- metadata +3 -2
@@ -82,6 +82,7 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
82
82
|
BOOL samples_used[MAX_SAMPLES];
|
83
83
|
UINT unused_samples;
|
84
84
|
XMFILEHEADER xmhead;
|
85
|
+
UINT i, j;
|
85
86
|
|
86
87
|
_this->m_nChannels = 0;
|
87
88
|
if ((!lpStream) || (dwMemLength < 0x200)) return FALSE;
|
@@ -118,7 +119,6 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
118
119
|
SDL_memset(InstUsed, 0, sizeof(InstUsed));
|
119
120
|
if (patterns > MAX_PATTERNS)
|
120
121
|
{
|
121
|
-
UINT i, j;
|
122
122
|
for (i=0; i<norders; i++)
|
123
123
|
{
|
124
124
|
if (_this->Order[i] < patterns) InstUsed[_this->Order[i]] = TRUE;
|
@@ -142,18 +142,21 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
142
142
|
}
|
143
143
|
} else
|
144
144
|
{
|
145
|
-
for (
|
145
|
+
for (i=0; i<256; i++) pattern_map[i] = i;
|
146
146
|
}
|
147
147
|
SDL_memset(InstUsed, 0, sizeof(InstUsed));
|
148
148
|
dwMemPos = dwHdrSize + 60;
|
149
149
|
if (dwMemPos + 8 >= dwMemLength) return TRUE;
|
150
150
|
// Reading patterns
|
151
151
|
SDL_memset(channels_used, 0, sizeof(channels_used));
|
152
|
-
for (
|
152
|
+
for (i=0; i<patterns; i++)
|
153
153
|
{
|
154
|
-
|
154
|
+
MODCOMMAND *p;
|
155
|
+
const BYTE *src;
|
156
|
+
UINT ipatmap = pattern_map[i];
|
155
157
|
DWORD dwSize = 0;
|
156
158
|
WORD rows=64, packsize=0;
|
159
|
+
UINT row, chn;
|
157
160
|
dwSize = bswapLE32(*((DWORD *)(lpStream+dwMemPos)));
|
158
161
|
while ((dwMemPos + dwSize >= dwMemLength) || (dwSize & 0xFFFFFF00))
|
159
162
|
{
|
@@ -168,7 +171,6 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
168
171
|
if (dwMemPos + dwSize + 4 > dwMemLength) return TRUE;
|
169
172
|
dwMemPos += dwSize;
|
170
173
|
if (dwMemPos + packsize + 4 > dwMemLength) return TRUE;
|
171
|
-
MODCOMMAND *p;
|
172
174
|
if (ipatmap < MAX_PATTERNS)
|
173
175
|
{
|
174
176
|
_this->PatternSize[ipatmap] = rows;
|
@@ -176,11 +178,11 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
176
178
|
if (!packsize) continue;
|
177
179
|
p = _this->Patterns[ipatmap];
|
178
180
|
} else p = NULL;
|
179
|
-
|
180
|
-
|
181
|
-
for (
|
181
|
+
src = lpStream+dwMemPos;
|
182
|
+
j = 0;
|
183
|
+
for (row=0; row<rows; row++)
|
182
184
|
{
|
183
|
-
for (
|
185
|
+
for (chn=0; chn<_this->m_nChannels; chn++)
|
184
186
|
{
|
185
187
|
if ((p) && (j < packsize))
|
186
188
|
{
|
@@ -270,28 +272,30 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
270
272
|
SDL_memset(samples_used, 0, sizeof(samples_used));
|
271
273
|
unused_samples = 0;
|
272
274
|
// Reading instruments
|
273
|
-
for (
|
275
|
+
for (i=1; i<=instruments; i++)
|
274
276
|
{
|
275
277
|
XMINSTRUMENTHEADER *pih;
|
278
|
+
INSTRUMENTHEADER *penv;
|
276
279
|
BYTE flags[32];
|
277
280
|
DWORD samplesize[32];
|
278
281
|
UINT samplemap[32];
|
279
|
-
WORD nsamples;
|
280
282
|
DWORD pihlen;
|
283
|
+
UINT newsamples, nmap;
|
284
|
+
WORD nsamples;
|
281
285
|
|
282
286
|
if (dwMemPos + sizeof(XMINSTRUMENTHEADER) >= dwMemLength) return TRUE;
|
283
287
|
pih = (XMINSTRUMENTHEADER *)(lpStream+dwMemPos);
|
284
288
|
pihlen = bswapLE32(pih->size);
|
285
289
|
if (pihlen >= dwMemLength || dwMemPos > dwMemLength - pihlen) return TRUE;
|
286
|
-
if ((_this->Headers[
|
290
|
+
if ((_this->Headers[i] = (INSTRUMENTHEADER *) SDL_calloc(1, sizeof(INSTRUMENTHEADER))) == NULL) continue;
|
287
291
|
if ((nsamples = pih->samples) > 0)
|
288
292
|
{
|
289
293
|
if (dwMemPos + sizeof(XMINSTRUMENTHEADER) + sizeof(XMSAMPLEHEADER) > dwMemLength) return TRUE;
|
290
294
|
SDL_memcpy(&xmsh, lpStream+dwMemPos+sizeof(XMINSTRUMENTHEADER), sizeof(XMSAMPLEHEADER));
|
291
295
|
xmsh.shsize = bswapLE32(xmsh.shsize);
|
292
|
-
for (
|
293
|
-
xmsh.venv[
|
294
|
-
xmsh.penv[
|
296
|
+
for (j = 0; j < 24; ++j) {
|
297
|
+
xmsh.venv[j] = bswapLE16(xmsh.venv[j]);
|
298
|
+
xmsh.penv[j] = bswapLE16(xmsh.penv[j]);
|
295
299
|
}
|
296
300
|
xmsh.volfade = bswapLE16(xmsh.volfade);
|
297
301
|
xmsh.res = bswapLE16(xmsh.res);
|
@@ -304,8 +308,8 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
304
308
|
}
|
305
309
|
SDL_memset(samplemap, 0, sizeof(samplemap));
|
306
310
|
if (nsamples > 32) return TRUE;
|
307
|
-
|
308
|
-
for (
|
311
|
+
newsamples = _this->m_nSamples;
|
312
|
+
for (nmap=0; nmap<nsamples; nmap++)
|
309
313
|
{
|
310
314
|
UINT n = _this->m_nSamples+nmap+1;
|
311
315
|
if (n >= MAX_SAMPLES)
|
@@ -315,14 +319,15 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
315
319
|
{
|
316
320
|
if (!_this->Ins[n].pSample)
|
317
321
|
{
|
318
|
-
for (
|
322
|
+
for (j=0; j < nmap; j++)
|
319
323
|
{
|
320
|
-
if (samplemap[
|
324
|
+
if (samplemap[j] == n) goto alreadymapped;
|
321
325
|
}
|
322
|
-
for (
|
326
|
+
for (j=1; j<i; j++) if (_this->Headers[j])
|
323
327
|
{
|
324
|
-
INSTRUMENTHEADER *pks = _this->Headers[
|
325
|
-
|
328
|
+
INSTRUMENTHEADER *pks = _this->Headers[j];
|
329
|
+
UINT ks=0;
|
330
|
+
for (; ks<128; ks++)
|
326
331
|
{
|
327
332
|
if (pks->Keyboard[ks] == n) pks->Keyboard[ks] = 0;
|
328
333
|
}
|
@@ -342,20 +347,22 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
342
347
|
}
|
343
348
|
if ((unused_samples) && (unused_samples != 0xFFFF))
|
344
349
|
{
|
345
|
-
|
350
|
+
UINT iext=_this->m_nSamples;
|
351
|
+
for (; iext>=1; iext--) if (!samples_used[iext])
|
346
352
|
{
|
347
353
|
unused_samples--;
|
348
354
|
samples_used[iext] = TRUE;
|
349
355
|
CSoundFile_DestroySample(_this, iext);
|
350
356
|
n = iext;
|
351
|
-
for (
|
357
|
+
for (j=0; j<nmap; j++)
|
352
358
|
{
|
353
|
-
if (samplemap[
|
359
|
+
if (samplemap[j] == n) samplemap[j] = 0;
|
354
360
|
}
|
355
|
-
for (
|
361
|
+
for (j=1; j<i; j++) if (_this->Headers[j])
|
356
362
|
{
|
357
|
-
INSTRUMENTHEADER *pks = _this->Headers[
|
358
|
-
|
363
|
+
INSTRUMENTHEADER *pks = _this->Headers[j];
|
364
|
+
UINT ks=0;
|
365
|
+
for (; ks<128; ks++)
|
359
366
|
{
|
360
367
|
if (pks->Keyboard[ks] == n) pks->Keyboard[ks] = 0;
|
361
368
|
}
|
@@ -371,7 +378,7 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
371
378
|
}
|
372
379
|
_this->m_nSamples = newsamples;
|
373
380
|
// Reading Volume Envelope
|
374
|
-
|
381
|
+
penv = _this->Headers[i];
|
375
382
|
penv->nMidiProgram = pih->type;
|
376
383
|
penv->nFadeOut = xmsh.volfade;
|
377
384
|
penv->nPan = 128;
|
@@ -401,37 +408,38 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
401
408
|
if (penv->nPanLoopEnd >= 12) penv->nPanLoopEnd = 0;
|
402
409
|
if (penv->nPanLoopStart >= penv->nPanLoopEnd) penv->dwFlags &= ~ENV_PANLOOP;
|
403
410
|
penv->nGlobalVol = 64;
|
404
|
-
for (
|
411
|
+
for (j=0; j<12; j++)
|
405
412
|
{
|
406
|
-
penv->VolPoints[
|
407
|
-
penv->VolEnv[
|
408
|
-
penv->PanPoints[
|
409
|
-
penv->PanEnv[
|
410
|
-
if (
|
413
|
+
penv->VolPoints[j] = (WORD)xmsh.venv[j*2];
|
414
|
+
penv->VolEnv[j] = (BYTE)xmsh.venv[j*2+1];
|
415
|
+
penv->PanPoints[j] = (WORD)xmsh.penv[j*2];
|
416
|
+
penv->PanEnv[j] = (BYTE)xmsh.penv[j*2+1];
|
417
|
+
if (j)
|
411
418
|
{
|
412
|
-
if (penv->VolPoints[
|
419
|
+
if (penv->VolPoints[j] < penv->VolPoints[j-1])
|
413
420
|
{
|
414
|
-
penv->VolPoints[
|
415
|
-
penv->VolPoints[
|
416
|
-
if (penv->VolPoints[
|
421
|
+
penv->VolPoints[j] &= 0xFF;
|
422
|
+
penv->VolPoints[j] += penv->VolPoints[j-1] & 0xFF00;
|
423
|
+
if (penv->VolPoints[j] < penv->VolPoints[j-1]) penv->VolPoints[j] += 0x100;
|
417
424
|
}
|
418
|
-
if (penv->PanPoints[
|
425
|
+
if (penv->PanPoints[j] < penv->PanPoints[j-1])
|
419
426
|
{
|
420
|
-
penv->PanPoints[
|
421
|
-
penv->PanPoints[
|
422
|
-
if (penv->PanPoints[
|
427
|
+
penv->PanPoints[j] &= 0xFF;
|
428
|
+
penv->PanPoints[j] += penv->PanPoints[j-1] & 0xFF00;
|
429
|
+
if (penv->PanPoints[j] < penv->PanPoints[j-1]) penv->PanPoints[j] += 0x100;
|
423
430
|
}
|
424
431
|
}
|
425
432
|
}
|
426
|
-
for (
|
433
|
+
for (j=0; j<96; j++)
|
427
434
|
{
|
428
435
|
penv->NoteMap[j+12] = j+1+12;
|
429
436
|
if (xmsh.snum[j] < nsamples)
|
430
437
|
penv->Keyboard[j+12] = samplemap[xmsh.snum[j]];
|
431
438
|
}
|
432
439
|
// Reading samples
|
433
|
-
for (
|
440
|
+
for (j=0; j<nsamples; j++)
|
434
441
|
{
|
442
|
+
MODINSTRUMENT *pins;
|
435
443
|
if ((dwMemPos + sizeof(xmss) > dwMemLength)
|
436
444
|
|| (xmsh.shsize >= dwMemLength) || (dwMemPos > dwMemLength - xmsh.shsize)) return TRUE;
|
437
445
|
SDL_memcpy(&xmss, lpStream+dwMemPos, sizeof(xmss));
|
@@ -439,10 +447,10 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
439
447
|
xmss.loopstart = bswapLE32(xmss.loopstart);
|
440
448
|
xmss.looplen = bswapLE32(xmss.looplen);
|
441
449
|
dwMemPos += xmsh.shsize;
|
442
|
-
flags[
|
443
|
-
if (xmss.type & 0x20) flags[
|
444
|
-
samplesize[
|
445
|
-
if (!samplemap[
|
450
|
+
flags[j] = (xmss.type & 0x10) ? RS_PCM16D : RS_PCM8D;
|
451
|
+
if (xmss.type & 0x20) flags[j] = (xmss.type & 0x10) ? RS_STPCM16D : RS_STPCM8D;
|
452
|
+
samplesize[j] = xmss.samplen;
|
453
|
+
if (!samplemap[j]) continue;
|
446
454
|
if (xmss.type & 0x10)
|
447
455
|
{
|
448
456
|
xmss.looplen >>= 1;
|
@@ -460,8 +468,7 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
460
468
|
xmss.looplen += xmss.loopstart;
|
461
469
|
if (xmss.looplen > xmss.samplen) xmss.looplen = xmss.samplen;
|
462
470
|
if (!xmss.looplen) xmss.type &= ~3;
|
463
|
-
|
464
|
-
MODINSTRUMENT *pins = &_this->Ins[imapsmp];
|
471
|
+
pins = &_this->Ins[samplemap[j]];
|
465
472
|
pins->nLength = (xmss.samplen > MAX_SAMPLE_LENGTH) ? MAX_SAMPLE_LENGTH : xmss.samplen;
|
466
473
|
pins->nLoopStart = xmss.loopstart;
|
467
474
|
pins->nLoopEnd = xmss.looplen;
|
@@ -477,8 +484,8 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
477
484
|
pins->nGlobalVol = 64;
|
478
485
|
if ((xmss.res == 0xAD) && (!(xmss.type & 0x30)))
|
479
486
|
{
|
480
|
-
flags[
|
481
|
-
samplesize[
|
487
|
+
flags[j] = RS_ADPCM4;
|
488
|
+
samplesize[j] = (samplesize[j]+1)/2 + 16;
|
482
489
|
}
|
483
490
|
pins->nFineTune = xmss.finetune;
|
484
491
|
pins->RelativeTone = (int)xmss.relnote;
|
@@ -489,13 +496,13 @@ BOOL CSoundFile_ReadXM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLengt
|
|
489
496
|
pins->nVibDepth = xmsh.vibdepth;
|
490
497
|
pins->nVibRate = xmsh.vibrate;
|
491
498
|
}
|
492
|
-
for (
|
499
|
+
for (j=0; j<nsamples; j++)
|
493
500
|
{
|
494
|
-
if ((samplemap[
|
501
|
+
if ((samplemap[j]) && (samplesize[j]) && (dwMemPos < dwMemLength))
|
495
502
|
{
|
496
|
-
CSoundFile_ReadSample(_this, &_this->Ins[samplemap[
|
503
|
+
CSoundFile_ReadSample(_this, &_this->Ins[samplemap[j]], flags[j], (LPSTR)(lpStream + dwMemPos), dwMemLength - dwMemPos);
|
497
504
|
}
|
498
|
-
dwMemPos += samplesize[
|
505
|
+
dwMemPos += samplesize[j];
|
499
506
|
if (dwMemPos >= dwMemLength) break;
|
500
507
|
}
|
501
508
|
}
|
@@ -152,6 +152,7 @@ BOOL MMCMP_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength)
|
|
152
152
|
LPMMCMPHEADER pmmh;
|
153
153
|
const DWORD *pblk_table;
|
154
154
|
DWORD dwFileSize;
|
155
|
+
UINT nBlock;
|
155
156
|
BYTE tmp0[32], tmp1[32];
|
156
157
|
|
157
158
|
if (PP20_Unpack(ppMemFile, pdwMemLength))
|
@@ -179,7 +180,7 @@ BOOL MMCMP_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength)
|
|
179
180
|
return FALSE;
|
180
181
|
pBufEnd = pBuffer + dwFileSize;
|
181
182
|
pblk_table = (const DWORD *)(lpMemFile+pmmh->blktable);
|
182
|
-
for (
|
183
|
+
for (nBlock = 0; nBlock < pmmh->nblocks; nBlock++)
|
183
184
|
{
|
184
185
|
DWORD dwMemPos = bswapLE32(pblk_table[nBlock]);
|
185
186
|
DWORD dwSubPos;
|
@@ -18,6 +18,7 @@ static UINT GetMaskFromSize(UINT len)
|
|
18
18
|
void CSoundFile_InitializeDSP(CSoundFile *_this, BOOL bReset)
|
19
19
|
//-----------------------------------------
|
20
20
|
{
|
21
|
+
BOOL bResetBass = FALSE;
|
21
22
|
if (!_this->m_nReverbDelay) _this->m_nReverbDelay = 100;
|
22
23
|
if (!_this->m_nXBassRange) _this->m_nXBassRange = XBASS_DELAY;
|
23
24
|
if (!_this->m_nProLogicDelay) _this->m_nProLogicDelay = 20;
|
@@ -74,13 +75,13 @@ void CSoundFile_InitializeDSP(CSoundFile *_this, BOOL bReset)
|
|
74
75
|
}
|
75
76
|
} else _this->nReverbSize = 0;
|
76
77
|
#endif
|
77
|
-
BOOL bResetBass = FALSE;
|
78
78
|
// Bass Expansion Reset
|
79
79
|
if (_this->gdwSoundSetup & SNDMIX_MEGABASS)
|
80
80
|
{
|
81
81
|
UINT nXBassSamples = (_this->gdwMixingFreq * _this->m_nXBassRange) / 10000;
|
82
|
+
UINT mask;
|
82
83
|
if (nXBassSamples > XBASSBUFFERSIZE) nXBassSamples = XBASSBUFFERSIZE;
|
83
|
-
|
84
|
+
mask = GetMaskFromSize(nXBassSamples);
|
84
85
|
if ((bReset) || (mask != (UINT)_this->nXBassMask))
|
85
86
|
{
|
86
87
|
_this->nXBassMask = mask;
|
@@ -110,22 +111,24 @@ void CSoundFile_ProcessStereoDSP(CSoundFile *_this, int count)
|
|
110
111
|
int *pr = _this->MixSoundBuffer, *pin = _this->MixReverbBuffer, rvbcount = count;
|
111
112
|
do
|
112
113
|
{
|
113
|
-
int echo
|
114
|
+
int echo, echodly, n, tmp, v, vlp;
|
115
|
+
|
116
|
+
echo = _this->ReverbBuffer[_this->nReverbBufferPos] + _this->ReverbBuffer2[_this->nReverbBufferPos2]
|
114
117
|
+ _this->ReverbBuffer3[_this->nReverbBufferPos3] + _this->ReverbBuffer4[_this->nReverbBufferPos4]; // echo = reverb signal
|
115
118
|
// Delay line and remove Low Frequencies // v = original signal
|
116
|
-
|
119
|
+
echodly = _this->ReverbLoFilterDelay[_this->nReverbLoDlyPos]; // echodly = delayed signal
|
117
120
|
_this->ReverbLoFilterDelay[_this->nReverbLoDlyPos] = echo >> 1;
|
118
121
|
_this->nReverbLoDlyPos++;
|
119
122
|
_this->nReverbLoDlyPos &= 0x1F;
|
120
|
-
|
123
|
+
n = _this->nReverbLoFltPos;
|
121
124
|
_this->nReverbLoFltSum -= _this->ReverbLoFilterBuffer[n];
|
122
|
-
|
125
|
+
tmp = echo / 128;
|
123
126
|
_this->ReverbLoFilterBuffer[n] = tmp;
|
124
127
|
_this->nReverbLoFltSum += tmp;
|
125
128
|
echodly -= _this->nReverbLoFltSum;
|
126
129
|
_this->nReverbLoFltPos = (n + 1) & 0x3F;
|
127
130
|
// Reverb
|
128
|
-
|
131
|
+
v = (pin[0]+pin[1]) >> _this->nFilterAttn;
|
129
132
|
pr[0] += pin[0] + echodly;
|
130
133
|
pr[1] += pin[1] + echodly;
|
131
134
|
v += echodly >> 2;
|
@@ -138,7 +141,7 @@ void CSoundFile_ProcessStereoDSP(CSoundFile *_this, int count)
|
|
138
141
|
_this->gRvbLowPass[_this->gRvbLPPos] = v;
|
139
142
|
_this->gRvbLPPos++;
|
140
143
|
_this->gRvbLPPos &= 7;
|
141
|
-
|
144
|
+
vlp = _this->gRvbLPSum >> 2;
|
142
145
|
_this->ReverbBuffer[_this->nReverbBufferPos] = vlp;
|
143
146
|
_this->ReverbBuffer2[_this->nReverbBufferPos2] = vlp;
|
144
147
|
if (++_this->nReverbBufferPos >= _this->nReverbSize) _this->nReverbBufferPos = 0;
|
@@ -154,9 +157,11 @@ void CSoundFile_ProcessStereoDSP(CSoundFile *_this, int count)
|
|
154
157
|
if (_this->gdwSoundSetup & SNDMIX_SURROUND)
|
155
158
|
{
|
156
159
|
int *pr = _this->MixSoundBuffer, n = _this->nDolbyLoFltPos;
|
157
|
-
|
160
|
+
int r = count;
|
161
|
+
for (; r; r--)
|
158
162
|
{
|
159
|
-
int v
|
163
|
+
int v, secho, tmp;
|
164
|
+
v = (pr[0]+pr[1]+DOLBYATTNROUNDUP) >> (nDolbyHiFltAttn+1);
|
160
165
|
v *= (int)_this->nDolbyDepth;
|
161
166
|
// Low-Pass Filter
|
162
167
|
_this->nDolbyHiFltSum -= _this->DolbyHiFilterBuffer[_this->nDolbyHiFltPos];
|
@@ -166,7 +171,7 @@ void CSoundFile_ProcessStereoDSP(CSoundFile *_this, int count)
|
|
166
171
|
_this->nDolbyHiFltPos++;
|
167
172
|
_this->nDolbyHiFltPos &= nDolbyHiFltMask;
|
168
173
|
// Surround
|
169
|
-
|
174
|
+
secho = _this->SurroundBuffer[_this->nSurroundPos];
|
170
175
|
_this->SurroundBuffer[_this->nSurroundPos] = v;
|
171
176
|
// Delay line and remove low frequencies
|
172
177
|
v = _this->DolbyLoFilterDelay[_this->nDolbyLoDlyPos]; // v = delayed signal
|
@@ -174,7 +179,7 @@ void CSoundFile_ProcessStereoDSP(CSoundFile *_this, int count)
|
|
174
179
|
_this->nDolbyLoDlyPos++;
|
175
180
|
_this->nDolbyLoDlyPos &= 0x1F;
|
176
181
|
_this->nDolbyLoFltSum -= _this->DolbyLoFilterBuffer[n];
|
177
|
-
|
182
|
+
tmp = secho / 64;
|
178
183
|
_this->DolbyLoFilterBuffer[n] = tmp;
|
179
184
|
_this->nDolbyLoFltSum += tmp;
|
180
185
|
v -= _this->nDolbyLoFltSum;
|
@@ -194,14 +199,16 @@ void CSoundFile_ProcessStereoDSP(CSoundFile *_this, int count)
|
|
194
199
|
int *px = _this->MixSoundBuffer;
|
195
200
|
int xba = _this->m_nXBassDepth+1, xbamask = (1 << xba) - 1;
|
196
201
|
int n = _this->nXBassBufferPos;
|
197
|
-
|
202
|
+
int x = count;
|
203
|
+
for (; x; x--)
|
198
204
|
{
|
205
|
+
int tmp0, tmp, v;
|
199
206
|
_this->nXBassSum -= _this->XBassBuffer[n];
|
200
|
-
|
201
|
-
|
207
|
+
tmp0 = px[0] + px[1];
|
208
|
+
tmp = (tmp0 + ((tmp0 >> 31) & xbamask)) >> xba;
|
202
209
|
_this->XBassBuffer[n] = tmp;
|
203
210
|
_this->nXBassSum += tmp;
|
204
|
-
|
211
|
+
v = _this->XBassDelay[_this->nXBassDlyPos];
|
205
212
|
_this->XBassDelay[_this->nXBassDlyPos] = px[0];
|
206
213
|
px[0] = v + _this->nXBassSum;
|
207
214
|
v = _this->XBassDelay[_this->nXBassDlyPos+1];
|
@@ -219,7 +226,8 @@ void CSoundFile_ProcessStereoDSP(CSoundFile *_this, int count)
|
|
219
226
|
{
|
220
227
|
int n1 = _this->nLeftNR, n2 = _this->nRightNR;
|
221
228
|
int *pnr = _this->MixSoundBuffer;
|
222
|
-
|
229
|
+
int nr = count;
|
230
|
+
for (; nr; nr--)
|
223
231
|
{
|
224
232
|
int vnr = pnr[0] >> 1;
|
225
233
|
pnr[0] = vnr + n1;
|
@@ -242,8 +250,9 @@ void CSoundFile_ProcessStereoDSP(CSoundFile *_this, int count)
|
|
242
250
|
BOOL CSoundFile_SetReverbParameters(CSoundFile *_this, UINT nDepth, UINT nDelay)
|
243
251
|
//------------------------------------------------------------
|
244
252
|
{
|
253
|
+
UINT gain;
|
245
254
|
if (nDepth > 100) nDepth = 100;
|
246
|
-
|
255
|
+
gain = nDepth / 20;
|
247
256
|
if (gain > 4) gain = 4;
|
248
257
|
_this->m_nReverbDepth = 4 - gain;
|
249
258
|
if (nDelay < 40) nDelay = 40;
|
@@ -257,11 +266,12 @@ BOOL CSoundFile_SetReverbParameters(CSoundFile *_this, UINT nDepth, UINT nDelay)
|
|
257
266
|
BOOL CSoundFile_SetXBassParameters(CSoundFile *_this, UINT nDepth, UINT nRange)
|
258
267
|
//-----------------------------------------------------------
|
259
268
|
{
|
269
|
+
UINT gain, range;
|
260
270
|
if (nDepth > 100) nDepth = 100;
|
261
|
-
|
271
|
+
gain = nDepth / 20;
|
262
272
|
if (gain > 4) gain = 4;
|
263
273
|
_this->m_nXBassDepth = 8 - gain; // filter attenuation 1/256 .. 1/16
|
264
|
-
|
274
|
+
range = nRange / 5;
|
265
275
|
if (range > 5) range -= 5; else range = 0;
|
266
276
|
if (nRange > 16) nRange = 16;
|
267
277
|
_this->m_nXBassRange = 21 - range; // filter average on 0.5-1.6ms
|
@@ -16,12 +16,13 @@ static DWORD CutOffToFrequency(CSoundFile *_this, UINT nCutOff, int flt_modifier
|
|
16
16
|
//-----------------------------------------------------------------------
|
17
17
|
{
|
18
18
|
float Fc;
|
19
|
+
LONG freq;
|
19
20
|
|
20
21
|
if (_this->m_dwSongFlags & SONG_EXFILTERRANGE)
|
21
22
|
Fc = 110.0f * SDL_pow(2.0f, 0.25f + ((float)(nCutOff*(flt_modifier+256)))/(21.0f*512.0f));
|
22
23
|
else
|
23
24
|
Fc = 110.0f * SDL_pow(2.0f, 0.25f + ((float)(nCutOff*(flt_modifier+256)))/(24.0f*512.0f));
|
24
|
-
|
25
|
+
freq = (LONG)Fc;
|
25
26
|
if (freq < 120) return 120;
|
26
27
|
if (freq > 10000) return 10000;
|
27
28
|
if (freq*2 > (LONG)_this->gdwMixingFreq) freq = _this->gdwMixingFreq>>1;
|
@@ -36,13 +37,14 @@ void CSoundFile_SetupChannelFilter(CSoundFile *_this, MODCHANNEL *pChn, BOOL bRe
|
|
36
37
|
float fc = (float)CutOffToFrequency(_this, pChn->nCutOff, flt_modifier);
|
37
38
|
float fs = (float)_this->gdwMixingFreq;
|
38
39
|
float fg, fb0, fb1;
|
40
|
+
float dmpfac, d, e;
|
39
41
|
|
40
42
|
fc *= (float)(2.0*3.14159265358/fs);
|
41
|
-
|
42
|
-
|
43
|
+
dmpfac = SDL_pow(10.0f, -((24.0f / 128.0f)*(float)pChn->nResonance) / 20.0f);
|
44
|
+
d = (1.0f-2.0f*dmpfac)* fc;
|
43
45
|
if (d>2.0) d = 2.0;
|
44
46
|
d = (2.0f*dmpfac - d)/fc;
|
45
|
-
|
47
|
+
e = SDL_pow(1.0f/fc,2.0f);
|
46
48
|
|
47
49
|
fg=1/(1+d+e);
|
48
50
|
fb0=(d+e+e)/(1+d+e);
|