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
@@ -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
|
-
|
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 (
|
150
|
+
for (i=0; i<32; i++)
|
150
151
|
{
|
151
|
-
_this->ChnSettings[
|
152
|
-
_this->ChnSettings[
|
152
|
+
_this->ChnSettings[i].nPan = 128;
|
153
|
+
_this->ChnSettings[i].nVolume = 64;
|
153
154
|
|
154
|
-
_this->ChnSettings[
|
155
|
-
if (psfh.channels[
|
155
|
+
_this->ChnSettings[i].dwFlags = CHN_MUTE;
|
156
|
+
if (psfh.channels[i] != 0xFF)
|
156
157
|
{
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
_this->ChnSettings[
|
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
|
-
|
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 (
|
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 (
|
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 (
|
211
|
+
for (i=1; i<=insnum; i++)
|
210
212
|
{
|
211
|
-
UINT nInd = ((DWORD)ptr[
|
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[
|
215
|
-
inspack[
|
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[
|
221
|
-
inspack[
|
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[
|
225
|
-
_this->Ins[
|
226
|
-
_this->Ins[
|
227
|
-
_this->Ins[
|
228
|
-
_this->Ins[
|
229
|
-
if (pSmp.flags&1) _this->Ins[
|
230
|
-
|
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[
|
234
|
-
insfile[
|
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[
|
237
|
-
else if (insfile[
|
238
|
+
if (insfile[i] > dwMemLength) insfile[i] = 0;
|
239
|
+
else if (insfile[i]) {
|
238
240
|
// ignore duplicate samples.
|
239
|
-
|
240
|
-
|
241
|
-
|
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[
|
244
|
-
_this->Ins[
|
245
|
-
_this->Ins[
|
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 (
|
252
|
+
for (i=0; i<patnum; i++)
|
250
253
|
{
|
251
|
-
|
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
|
-
|
260
|
+
len = bswapLE16(*((WORD *)(lpStream+nInd)));
|
254
261
|
nInd += 2;
|
255
|
-
_this->PatternSize[
|
262
|
+
_this->PatternSize[i] = 64;
|
256
263
|
if ((!len) || (nInd + len > dwMemLength - 6)
|
257
|
-
|| ((_this->Patterns[
|
258
|
-
|
264
|
+
|| ((_this->Patterns[i] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL)) continue;
|
265
|
+
src = (LPBYTE)(lpStream+nInd);
|
259
266
|
// Unpacking pattern
|
260
|
-
|
261
|
-
|
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 (
|
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[
|
317
|
-
if (insflags[
|
318
|
-
if (inspack[
|
319
|
-
dwMemPos = insfile[
|
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[
|
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 (
|
82
|
+
for (j=0; j<4; j++)
|
81
83
|
{
|
82
|
-
_this->ChnSettings[
|
83
|
-
_this->ChnSettings[
|
84
|
-
_this->ChnSettings[
|
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 (
|
89
|
+
for (j=0; j<31; j++)
|
88
90
|
{
|
89
|
-
MODINSTRUMENT *pIns = &_this->Ins[
|
90
|
-
const STMSAMPLE *pStm = &phdr->sample[
|
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 (
|
103
|
-
|
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 (
|
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[
|
109
|
-
if ((_this->Patterns[
|
110
|
-
|
111
|
-
|
112
|
-
for (
|
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 (
|
170
|
+
for (j=1; j<=31; j++)
|
166
171
|
{
|
167
|
-
MODINSTRUMENT *pIns = &_this->Ins[
|
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[
|
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 (
|
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
|
-
|
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 (
|
102
|
+
for (j=0; j<_this->m_nChannels; j++)
|
102
103
|
{
|
103
|
-
_this->ChnSettings[
|
104
|
-
_this->ChnSettings[
|
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(
|
111
|
+
for(j=0; j<_this->m_nChannels; j++)
|
111
112
|
{
|
112
|
-
_this->ChnSettings[
|
113
|
-
if (_this->ChnSettings[
|
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 (
|
118
|
+
for (j=0; j<nop; j++)
|
118
119
|
{
|
119
|
-
if (
|
120
|
+
if (j < MAX_PATTERNS)
|
120
121
|
{
|
121
|
-
_this->PatternSize[
|
122
|
-
_this->Patterns[
|
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 (
|
127
|
+
for (j=0; j<_this->m_nChannels; j++)
|
127
128
|
{
|
128
|
-
|
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 +=
|
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
|
-
|
142
|
-
|
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
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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 (
|
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
|
-
|
204
|
-
dwMemPos += CSoundFile_ReadSample(_this, &_this->Ins[
|
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
|
}
|