Mercurial > mm7
annotate AudioPlayer.cpp @ 1423:350959f13283
Слияние
author | Ritor1 |
---|---|
date | Tue, 30 Jul 2013 09:34:14 +0600 |
parents | 6bbcb91b3b7d c9e3b93ec570 |
children | 16a24dc103e7 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
4 |
0 | 5 #include <string> |
378 | 6 #include <assert.h> |
0 | 7 |
1262 | 8 #include "mm7_data.h" |
1016 | 9 #include "VideoPlayer.h" |
0 | 10 #include "AudioPlayer.h" |
11 #include "Allocator.h" | |
12 #include "FrameTableInc.h" | |
13 #include "Indoor.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
14 #include "SpriteObject.h" |
0 | 15 #include "Party.h" |
16 #include "Actor.h" | |
17 #include "Game.h" | |
18 #include "DecorationList.h" | |
19 #include "Time.h" | |
20 #include "OSInfo.h" | |
21 #include "Math.h" | |
22 #include "MapInfo.h" | |
378 | 23 #include "GUIWindow.h" |
0 | 24 #include "Log.h" |
25 | |
26 #include "Bink_Smacker.h" | |
27 | |
848 | 28 #include "MM7.h" |
0 | 29 |
30 | |
31 PCMWAVEFORMAT pcmWaveFormat; | |
32 | |
33 int Aureal3D_SplashScreen; | |
34 int Aureal3D_SplashAudio; | |
35 int uFindSound_BinSearch_ResultID; // weak | |
36 int uLastLoadedSoundID; // weak | |
37 int sLastTrackLengthMS; | |
1202 | 38 std::array<Sound, 3000> pSounds; |
0 | 39 AudioPlayer *pAudioPlayer; |
40 SoundList *pSoundList; | |
41 | |
42 | |
1202 | 43 std::array<stru339_spell_sound, 4> stru_A750F8; |
44 std::array<stru339_spell_sound, 4> stru_AA1058; | |
0 | 45 |
46 | |
47 | |
48 unsigned __int8 uSoundVolumeMultiplier = 4; | |
49 unsigned __int8 uVoicesVolumeMultiplier = 4; | |
50 unsigned __int8 uMusicVolimeMultiplier = 4; | |
51 int bWalkSound; // idb | |
52 | |
1202 | 53 std::array<float, 10> pSoundVolumeLevels = |
0 | 54 { |
328 | 55 0.0000000f, 0.1099999f, 0.2199999f, 0.3300000f, 0.4399999f, |
1265 | 56 0.5500000f, 0.6600000f, 0.7699999f, 0.8799999f, 0.9700000f //changed 0.9900000f to 0.9700000f. for some reason it only works for values below this |
328 | 57 }; |
0 | 58 |
59 | |
60 | |
61 | |
62 void ReleaseSoundData(void *_this); | |
63 | |
64 | |
65 | |
66 | |
67 //----- (004A9953) -------------------------------------------------------- | |
68 void SoundList::Initialize() | |
69 { | |
70 SoundDesc *pSoundDesc; // eax@5 | |
71 void *pSoundData; // ebx@7 | |
72 unsigned int uSoundSize; // eax@7 | |
73 char *pSoundBytes; // ebx@7 | |
74 AILFILETYPE pType; // eax@7 | |
75 int v8; // eax@8 | |
76 char pSoundName[120]; // [sp+4h] [bp-A4h]@4 | |
77 AILSOUNDINFO pInfo; // [sp+7Ch] [bp-2Ch]@10 | |
78 int v12; // [sp+A0h] [bp-8h]@12 | |
79 | |
764 | 80 if ( sNumSounds > 1 ) |
0 | 81 { |
1408 | 82 for ( uint i = 1; i < pSoundList->sNumSounds; ++i ) |
0 | 83 { |
1408 | 84 sprintf(pSoundName, "%s", pSounds[i].pSoundName); |
85 pSoundDesc = &pSoundList->pSounds[i]; | |
86 if ( pSoundList->pSounds[i].eType != SOUND_DESC_SYSTEM || (sprintf(pSoundName, "%s", pSounds[i].pSoundName), | |
87 pSoundList->pSounds[i].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[i].uSoundID), | |
0 | 88 !pAudioPlayer->b3DSoundInitialized) |
1408 | 89 || (pSoundDesc = &pSoundList->pSounds[i], !(pSoundDesc->uFlags & SOUND_DESC_SWAP)) |
90 || !pSoundDesc->pSoundData[0] ) | |
91 continue; | |
0 | 92 pSoundData = pSoundDesc->pSoundData[0]; |
93 uSoundSize = *(int *)pSoundData; | |
94 pSoundBytes = (char *)pSoundData + 4; | |
95 pType = AIL_file_type(pSoundBytes, uSoundSize); | |
96 if ( !pType ) | |
1408 | 97 { |
98 pSoundList->pSounds[i].bDecompressed = false; | |
99 pSoundList->UnloadSound(i, 1); | |
100 continue; | |
101 } | |
0 | 102 v8 = pType - 1; |
103 if ( v8 ) | |
104 { | |
1408 | 105 if ( v8 == 1 ) |
0 | 106 { |
1408 | 107 if ( AIL_WAV_info(pSoundBytes, &pInfo) && pInfo.uChannels != 2 ) |
0 | 108 { |
1408 | 109 if ( !AIL_decompress_ADPCM(&pInfo, &pSoundList->pSounds[i].p3DSound, &v12) ) |
110 { | |
111 pSoundList->pSounds[i].p3DSound = 0; | |
112 pSoundList->pSounds[i].bDecompressed = true; | |
113 } | |
0 | 114 } |
1408 | 115 pSoundList->UnloadSound(i, 1); |
116 continue; | |
0 | 117 } |
1408 | 118 pSoundList->pSounds[i].bDecompressed = false; |
119 pSoundList->UnloadSound(i, 1); | |
120 continue; | |
0 | 121 } |
1408 | 122 pSoundList->pSounds[i].p3DSound = pSoundList->pSounds[i].pSoundData[0]; |
123 pSoundList->UnloadSound(i, 1); | |
0 | 124 } |
125 } | |
126 } | |
127 | |
128 //----- (004A9A67) -------------------------------------------------------- | |
129 __int16 SoundList::LoadSound(int a1, unsigned int a3) | |
130 { | |
131 AILSOUNDINFO v24; // [sp+84h] [bp-28h]@23 | |
132 | |
764 | 133 if (bNoSound || !sNumSounds) |
0 | 134 return 0; |
135 | |
136 uint uSoundIdx = 0; | |
137 SoundDesc *pSound = nullptr; | |
764 | 138 for (uint i = 1; i < sNumSounds; ++i) |
0 | 139 if (pSounds[i].uSoundID == a1) |
140 { | |
141 uSoundIdx = i; | |
142 pSound = &pSounds[i]; | |
143 break; | |
144 } | |
145 if (!pSound) | |
146 return 0; | |
147 | |
592 | 148 if (pSound->uFlags & SOUND_DESC_SWAP && pSound->p3DSound || |
149 ~pSound->uFlags & SOUND_DESC_SWAP && pSound->pSoundData[0]) | |
0 | 150 return uSoundIdx; |
151 | |
152 if (!pSound->pSoundData[0]) | |
153 pSound->pSoundData[0] = ::LoadSound(pSound->pSoundName, (SoundData *)0xFFFFFFFF, pSound->uSoundID); | |
154 | |
155 if (!pSound->pSoundData[0]) | |
156 return 0; | |
157 | |
158 if (a3) | |
592 | 159 pSound->uFlags |= SOUND_DESC_SYSTEM; |
0 | 160 |
161 if (!pAudioPlayer->b3DSoundInitialized) | |
162 return uSoundIdx; | |
163 | |
592 | 164 if (~pSound->uFlags & SOUND_DESC_SWAP || !pSound->pSoundData[0]) |
0 | 165 return uSoundIdx; |
166 | |
167 | |
168 auto pSoundData = pSound->pSoundData[0]; | |
169 switch (AIL_file_type((void *)pSoundData->pData, pSoundData->uDataSize)) | |
170 { | |
171 default: | |
172 case AILFILETYPE_UNKNOWN: | |
173 pSound->bDecompressed = false; | |
174 return 0; | |
175 | |
176 case AILFILETYPE_PCM_WAV: | |
177 pSound->p3DSound = pSound->pSoundData[0]; | |
178 return uSoundIdx; | |
179 | |
180 case AILFILETYPE_ADPCM_WAV: | |
181 if (AIL_WAV_info((void *)pSoundData->pData, &v24) && v24.uChannels != 2) | |
182 { | |
183 if (!AIL_decompress_ADPCM(&v24, &pSound->p3DSound, &a1) ) | |
184 { | |
185 pSound->p3DSound = nullptr; | |
186 pSound->bDecompressed = true; | |
764 | 187 UnloadSound(uSoundIdx, 0); |
0 | 188 } |
189 } | |
190 return uSoundIdx; | |
191 }; | |
192 } | |
193 | |
194 //----- (004A9BBD) -------------------------------------------------------- | |
195 int SoundList::LoadSound(unsigned int a2, LPVOID lpBuffer, int uBufferSizeLeft, int *pOutSoundSize, int a6) | |
196 { | |
197 //SoundList *v6; // edi@1 | |
198 signed int v7; // esi@1 | |
199 //unsigned __int8 v8; // zf@1 | |
200 //unsigned __int8 v9; // sf@1 | |
201 SoundDesc *v10; // eax@3 | |
202 SoundDesc *v11; // ecx@3 | |
203 int v12; // ebx@7 | |
204 int result; // eax@13 | |
205 SoundHeader *v14; // esi@16 | |
206 DWORD *v15; // edi@16 | |
207 int v16; // ebx@16 | |
208 unsigned int v17; // eax@18 | |
209 void *v18; // ebx@19 | |
210 std::string v19; // [sp-18h] [bp-38h]@22 | |
211 const char *v20; // [sp-8h] [bp-28h]@22 | |
212 int v21; // [sp-4h] [bp-24h]@22 | |
213 //SoundList *v22; // [sp+Ch] [bp-14h]@1 | |
214 SoundDesc *Args; // [sp+10h] [bp-10h]@3 | |
215 unsigned int v24; // [sp+14h] [bp-Ch]@2 | |
216 int v25; // [sp+18h] [bp-8h]@2 | |
217 int v26; // [sp+1Ch] [bp-4h]@1 | |
218 | |
219 //v6 = this; | |
220 v7 = 0; | |
221 //v22 = this; | |
222 //v8 = this->uNumSounds == 0; | |
223 //v9 = (this->uNumSounds & 0x80000000u) != 0; | |
224 v26 = 0; | |
764 | 225 if (!sNumSounds) |
0 | 226 return 0; |
227 | |
228 | |
229 v24 = 0; | |
230 v25 = 44; | |
231 while ( 1 ) | |
232 { | |
233 v10 = pSounds; | |
234 v11 = &v10[v24 / 0x78]; | |
235 Args = &v10[v24 / 0x78]; | |
236 if ( a2 == v10[v24 / 0x78].uSoundID ) | |
237 { | |
238 if ( a6 == v7 && *(int *)&v10->pSoundName[v25] != v7 ) | |
239 return v26; | |
240 if ( (signed int)pAudioPlayer->uNumSoundHeaders > v7 ) | |
241 break; | |
242 } | |
243 LABEL_12: | |
244 ++v26; | |
245 v25 += 120; | |
246 v24 += 120; | |
764 | 247 if ( v26 >= (signed int)sNumSounds ) |
0 | 248 return 0; |
249 } | |
250 v12 = 0; | |
1104 | 251 while ( _stricmp(pAudioPlayer->pSoundHeaders[v12].pSoundName, v11->pSoundName) ) |
0 | 252 { |
253 ++v7; | |
254 ++v12; | |
255 if ( v7 >= (signed int)pAudioPlayer->uNumSoundHeaders ) | |
256 { | |
257 v7 = 0; | |
258 goto LABEL_12; | |
259 } | |
260 v11 = Args; | |
261 } | |
262 v14 = &pAudioPlayer->pSoundHeaders[v7]; | |
263 v15 = (DWORD *)&v14->uDecompressedSize; | |
264 a2 = v14->uDecompressedSize; | |
265 v16 = a2; | |
266 if ( (signed int)a2 > uBufferSizeLeft ) | |
267 Abortf("Sound %s is size %i bytes, sound buffer size is %i bytes", Args, a2, uBufferSizeLeft); | |
268 SetFilePointer(pAudioPlayer->hAudioSnd, v14->uFileOffset, 0, 0); | |
269 v17 = v14->uCompressedSize; | |
270 if ( (signed int)v17 >= (signed int)*v15 ) | |
271 { | |
272 if ( v17 == *v15 ) | |
273 { | |
274 ReadFile(pAudioPlayer->hAudioSnd, lpBuffer, *v15, (LPDWORD)&Args, 0); | |
275 } | |
276 else | |
277 { | |
278 MessageBoxW(nullptr, L"Can't load sound file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Sound.cpp:666", 0); | |
279 } | |
280 } | |
281 else | |
282 { | |
283 v18 = malloc(v14->uCompressedSize); | |
284 ReadFile(pAudioPlayer->hAudioSnd, v18, v14->uCompressedSize, (LPDWORD)&Args, 0); | |
285 zlib::MemUnzip(lpBuffer, &v14->uDecompressedSize, v18, v14->uCompressedSize); | |
286 free(v18); | |
287 v16 = a2; | |
288 } | |
289 result = v26; | |
290 pSounds->pSoundData[a6 + 30 * v26] = (SoundData *)lpBuffer; | |
291 *pOutSoundSize = v16; | |
292 | |
293 return result; | |
294 } | |
295 | |
296 //----- (004A9D3E) -------------------------------------------------------- | |
297 SoundDesc *SoundList::Release() | |
298 { | |
299 SoundDesc *result; // eax@3 | |
300 void *v5; // ecx@3 | |
301 | |
764 | 302 if ( (signed int)this->sNumSounds > 0 ) |
0 | 303 { |
1408 | 304 for ( uint i = 0; i < (signed int)this->sNumSounds; ++i ) |
0 | 305 { |
1408 | 306 result = this->pSounds; |
307 v5 = result[i].pSoundData[0]; | |
0 | 308 if ( v5 ) |
309 { | |
310 ReleaseSoundData(v5); | |
1408 | 311 this->pSounds[i].pSoundData[0] = 0; |
312 result = (SoundDesc *)((char *)&this->pSounds[i] + 40); | |
0 | 313 *(int *)&result->pSoundName[0] &= 0xFFFFFFFEu; |
314 } | |
315 } | |
316 } | |
317 return result; | |
318 } | |
319 | |
320 //----- (004A9D79) -------------------------------------------------------- | |
321 void SoundList::_4A9D79(int a2) | |
322 { | |
323 SoundList *v2; // esi@1 | |
324 int v3; // edi@1 | |
325 signed int i; // ebx@1 | |
326 SoundDesc *v5; // eax@2 | |
327 SOUND_DESC_TYPE v6; // ecx@2 | |
328 void *v7; // eax@5 | |
329 | |
330 v2 = this; | |
331 v3 = 0; | |
764 | 332 for ( i = 0; i < (signed int)v2->sNumSounds; ++v3 ) |
0 | 333 { |
334 v5 = &v2->pSounds[v3]; | |
335 v6 = v5->eType; | |
336 if ( v6 != SOUND_DESC_SYSTEM && (a2 || v6 != SOUND_DESC_LOCK) ) | |
337 { | |
338 v7 = v5->pSoundData[0]; | |
339 if ( v7 ) | |
340 { | |
341 ReleaseSoundData(v7); | |
342 v2->pSounds[v3].pSoundData[0] = 0; | |
343 } | |
592 | 344 v2->pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM; |
0 | 345 } |
346 ++i; | |
347 } | |
348 } | |
349 | |
350 //----- (004A9DCD) -------------------------------------------------------- | |
764 | 351 void SoundList::UnloadSound(unsigned int uSoundID, char a3) |
0 | 352 { |
764 | 353 if ( pSounds[uSoundID].eType != SOUND_DESC_SYSTEM ) |
0 | 354 { |
764 | 355 if ( (pSounds[uSoundID].uFlags & SOUND_DESC_SWAP) && pSounds[uSoundID].p3DSound && a3 ) |
0 | 356 { |
764 | 357 if ( pSounds[uSoundID].bDecompressed) |
358 AIL_mem_free_lock(pSounds[uSoundID].p3DSound); | |
359 pSounds[uSoundID].p3DSound = 0; | |
360 pSounds[uSoundID].uFlags &= ~SOUND_DESC_SYSTEM; | |
0 | 361 } |
764 | 362 if ( pSounds[uSoundID].pSoundData[0] ) |
0 | 363 { |
764 | 364 ReleaseSoundData(pSounds[uSoundID].pSoundData[0]); |
365 pSounds[uSoundID].pSoundData[0] = NULL; | |
366 pSounds[uSoundID].uFlags &= ~SOUND_DESC_SYSTEM; | |
0 | 367 } |
368 } | |
369 } | |
370 | |
371 | |
372 //----- (004A9E3D) -------------------------------------------------------- | |
373 void SoundList::ToFile() | |
374 { | |
375 SoundList *v1; // esi@1 | |
376 FILE *v2; // eax@1 | |
377 FILE *v3; // edi@1 | |
378 | |
379 v1 = this; | |
380 v2 = fopen("data\\dsounds.bin", "wb"); | |
381 v3 = v2; | |
382 if ( !v2 ) | |
383 Abortf("Unable to save dsounds.bin!"); | |
384 fwrite(v1, 4u, 1u, v2); | |
764 | 385 fwrite(v1->pSounds, 0x78u, v1->sNumSounds, v3); |
0 | 386 fclose(v3); |
387 } | |
388 | |
389 //----- (004A9E89) -------------------------------------------------------- | |
390 void *SoundList::FromFile(void *pSerialized) | |
391 { | |
764 | 392 sNumSounds = *(int *)pSerialized; |
393 pSounds = (SoundDesc *)pAllocator->AllocNamedChunk(pSounds, 120 * sNumSounds, "Snd Des."); | |
394 return memcpy(pSounds, (char *)pSerialized + 4, 120 * sNumSounds); | |
0 | 395 } |
396 | |
397 //----- (004A9ED0) -------------------------------------------------------- | |
398 int SoundList::FromFileTxt(const char *Args) | |
399 { | |
400 SoundList *v2; // ebx@1 | |
401 __int32 v3; // edi@1 | |
402 FILE *v4; // eax@1 | |
403 unsigned int v5; // esi@3 | |
404 void *v6; // eax@9 | |
405 FILE *v7; // ST0C_4@11 | |
406 char *i; // eax@11 | |
407 int v9; // eax@14 | |
408 const char *v10; // ST0C_4@14 | |
409 int v11; // eax@18 | |
410 SoundDesc *v12; // ecx@18 | |
411 char v13; // zf@18 | |
412 unsigned int v14; // eax@18 | |
413 int v15; // eax@23 | |
414 char Buf; // [sp+Ch] [bp-2F0h]@3 | |
415 FrameTableTxtLine v18; // [sp+200h] [bp-FCh]@4 | |
416 FrameTableTxtLine v19; // [sp+27Ch] [bp-80h]@4 | |
417 FILE *File; // [sp+2F8h] [bp-4h]@1 | |
418 unsigned int Argsa; // [sp+304h] [bp+8h]@3 | |
419 | |
420 v2 = this; | |
421 pAllocator->FreeChunk(this->pSounds); | |
422 v3 = 0; | |
423 v2->pSounds = 0; | |
764 | 424 v2->sNumSounds = 0; |
0 | 425 v4 = fopen(Args, "r"); |
426 File = v4; | |
427 if ( !v4 ) | |
428 Abortf("SoundListClass::load - Unable to open file: %s."); | |
429 v5 = 0; | |
430 Argsa = 0; | |
431 if ( fgets(&Buf, 490, v4) ) | |
432 { | |
433 do | |
434 { | |
435 *strchr(&Buf, 10) = 0; | |
703 | 436 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); |
701 | 437 if ( v19.uPropCount && *v19.pProperties[0] != 47 ) |
0 | 438 ++Argsa; |
439 } | |
440 while ( fgets(&Buf, 490, File) ); | |
441 v5 = Argsa; | |
442 v3 = 0; | |
443 } | |
764 | 444 v2->sNumSounds = v5; |
0 | 445 v6 = pAllocator->AllocNamedChunk(v2->pSounds, 120 * v5, "Snd Des."); |
446 v2->pSounds = (SoundDesc *)v6; | |
447 if ( v6 == (void *)v3 ) | |
448 Abortf("SoundListClass::load - Out of Memory!"); | |
764 | 449 memset(v6, v3, 120 * v2->sNumSounds); |
0 | 450 v7 = File; |
764 | 451 v2->sNumSounds = v3; |
0 | 452 fseek(v7, v3, v3); |
453 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | |
454 { | |
455 *strchr(&Buf, 10) = 0; | |
703 | 456 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); |
701 | 457 if ( v19.uPropCount && *v19.pProperties[0] != 47 ) |
0 | 458 { |
764 | 459 sprintf(v2->pSounds[v2->sNumSounds].pSoundName, "%s", v19.pProperties[0]); |
0 | 460 v9 = atoi(v19.pProperties[1]); |
461 v10 = v19.pProperties[2]; | |
764 | 462 v2->pSounds[v2->sNumSounds].uSoundID = v9; |
1104 | 463 if ( _stricmp(v10, "system") ) |
0 | 464 { |
1104 | 465 if ( _stricmp(v19.pProperties[2], "swap") ) |
0 | 466 { |
1104 | 467 v11 = _stricmp(v19.pProperties[2], "lock"); |
0 | 468 v12 = v2->pSounds; |
469 v13 = v11 == 0; | |
764 | 470 v14 = v2->sNumSounds; |
0 | 471 if ( v13 ) |
472 v12[v14].eType = SOUND_DESC_LOCK; | |
473 else | |
474 v12[v14].eType = SOUND_DESC_LEVEL; | |
475 } | |
476 else | |
477 { | |
764 | 478 v2->pSounds[v2->sNumSounds].eType = SOUND_DESC_SWAP; |
0 | 479 } |
480 } | |
481 else | |
482 { | |
764 | 483 v2->pSounds[v2->sNumSounds].eType = SOUND_DESC_SYSTEM; |
0 | 484 } |
1104 | 485 if ( v19.uPropCount >= 4 && !_stricmp(v19.pProperties[3], "3D") ) |
0 | 486 { |
764 | 487 v15 = (int)&v2->pSounds[v2->sNumSounds].uFlags; |
592 | 488 *(int *)v15 |= SOUND_DESC_SWAP; |
0 | 489 } |
764 | 490 ++v2->sNumSounds; |
0 | 491 } |
492 } | |
493 fclose(File); | |
494 return 1; | |
495 } | |
496 | |
497 //----- (004AA13F) -------------------------------------------------------- | |
498 void AudioPlayer::PlayMusicTrack(MusicID eTrack) | |
499 { | |
500 if (!bNoSound && bPlayerReady && hAILRedbook && uMusicVolimeMultiplier) | |
501 { | |
502 AIL_redbook_stop(hAILRedbook); | |
328 | 503 AIL_redbook_set_volume(hAILRedbook, (signed)pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); |
0 | 504 AIL_redbook_track_info(hAILRedbook, eTrack, &uCurrentMusicTrackStartMS, &uCurrentMusicTrackEndMS); |
505 AIL_redbook_play(hAILRedbook, uCurrentMusicTrackStartMS + 1, uCurrentMusicTrackEndMS); | |
506 uCurrentMusicTrackLength = ((uCurrentMusicTrackEndMS - uCurrentMusicTrackStartMS) * 128) / 1000; | |
507 } | |
508 } | |
509 | |
510 | |
511 //----- (004AA1F3) -------------------------------------------------------- | |
512 void AudioPlayer::SetMusicVolume(int vol) | |
513 { | |
514 if (bPlayerReady) | |
515 { | |
516 if (hAILRedbook) | |
517 AIL_redbook_set_volume(hAILRedbook, vol); | |
518 } | |
519 } | |
520 | |
521 //----- (004AA214) -------------------------------------------------------- | |
328 | 522 void AudioPlayer::SetMasterVolume(float fVolume) |
0 | 523 { |
328 | 524 if ( bPlayerReady ) |
0 | 525 { |
328 | 526 uMasterVolume = fVolume; |
527 if ( hDigDriver ) | |
528 AIL_set_digital_master_volume(hDigDriver, fVolume); | |
529 if ( b3DSoundInitialized ) | |
530 s3DSoundVolume = fVolume * 0.5f; | |
0 | 531 } |
532 } | |
533 // 4D8304: using guessed type int __stdcall AIL_set_digital_master_volume(int, int); | |
534 | |
535 //----- (004AA258) -------------------------------------------------------- | |
536 void AudioPlayer::_4AA258(int a2) | |
537 { | |
1422 | 538 __debugbreak(); |
0 | 539 if ( this->bPlayerReady ) |
540 { | |
1422 | 541 if ( this->b3DSoundInitialized && a2 && this->uNum3DSamples > 0 ) |
0 | 542 { |
1422 | 543 for ( uint i = 0; i < this->uNum3DSamples; ++i ) |
0 | 544 { |
1422 | 545 if ( this->p3DSamples[i].field_4 == a2 && AIL_3D_sample_status(this->p3DSamples[i].hSample) == 4 ) |
546 AIL_end_3D_sample(this->p3DSamples[i].hSample); | |
0 | 547 } |
1422 | 548 goto LABEL_9; |
0 | 549 } |
550 else | |
551 { | |
552 LABEL_9: | |
1422 | 553 if ( this->hDigDriver ) |
0 | 554 { |
1422 | 555 if ( a2 && this->uMixerChannels > 0 ) |
0 | 556 { |
1422 | 557 for ( uint i = 0; i < this->uMixerChannels; ++i ) |
0 | 558 { |
1422 | 559 if ( this->pMixerChannels[i].source_pid == a2 ) |
0 | 560 { |
1422 | 561 if ( AIL_sample_status(this->pMixerChannels[i].hSample) == AIL::Sample::Playing) |
0 | 562 { |
1422 | 563 AIL_end_sample(this->pMixerChannels[i].hSample); |
564 FreeChannel(&this->pMixerChannels[i]); | |
0 | 565 } |
566 } | |
567 } | |
568 } | |
569 } | |
570 } | |
571 } | |
572 } | |
573 | |
574 //----- (004AA306) -------------------------------------------------------- | |
575 void AudioPlayer::PlaySound(SoundID eSoundID, signed int a3, unsigned int uNumRepeats, signed int PartyX, signed int PartyY, int a7, unsigned int uVolume, int sPlaybackRate) | |
576 { | |
577 //AudioPlayer *pAudioPlayer1; // esi@1 | |
388 | 578 //signed int pNum; // edx@5 |
579 //int *pSoundID; // ecx@6 | |
0 | 580 int v12; // edi@13 |
581 signed int v13; // ecx@17 | |
582 signed int v14; // eax@20 | |
583 int v15; // eax@24 | |
584 signed int v16; // eax@25 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
585 SpriteObject *pLayingItem; // eax@28 |
0 | 586 signed int v18; // eax@29 |
587 Actor *pActor1; // eax@32 | |
588 signed int v20; // ecx@32 | |
589 double v21; // st7@32 | |
590 signed int v22; // ecx@33 | |
591 AudioPlayer_3DSample *pAudioPlayer_3DSample; // esi@53 | |
592 AudioPlayer_3DSample *pAudioPlayer_3DSample1; // esi@61 | |
593 int v25; // esi@67 | |
594 double v26; // st7@68 | |
595 int v27; // ST18_4@68 | |
596 int v28; // ebx@68 | |
597 int v29; // eax@68 | |
598 AudioPlayer_3DSample *pAudioPlayer_3DSample2; // esi@69 | |
599 int v31; // ST18_4@70 | |
600 int v32; // ebx@70 | |
601 int v33; // eax@70 | |
602 int v34; // eax@70 | |
603 char v35; // zf@70 | |
604 signed int v36; // ebx@74 | |
605 //AudioPlayer *pAudioPlayer2; // edi@79 | |
606 AudioPlayer_3DSample *pAudioPlayer_3DSample3; // esi@79 | |
388 | 607 //unsigned int v39; // ebx@80 |
0 | 608 int v40; // eax@81 |
609 char *v41; // edi@82 | |
610 int v42; // esi@82 | |
611 double v43; // st7@91 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
612 SpriteObject *pLayingItem2; // eax@92 |
0 | 613 Actor *pActor; // eax@93 |
614 signed int v46; // ecx@93 | |
615 double v47; // st7@93 | |
616 BLVDoor *pBLVDoor; // eax@97 | |
617 double v49; // st7@104 | |
618 int v50; // ST18_4@104 | |
619 int v51; // ebx@104 | |
620 int v52; // eax@104 | |
621 float v53; // ST0C_4@106 | |
622 float v54; // ST04_4@106 | |
623 //AudioPlayer *pAudioPlayer3; // edx@106 | |
624 SoundDesc *pSoundDesc; // edx@107 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
625 SpriteObject *pLayingItem3; // eax@114 |
388 | 626 //int v58; // edx@115 |
627 //int v59; // ecx@115 | |
628 //Actor *pActor2; // eax@118 | |
629 //MixerChannel *pMixerChannel; // esi@126 | |
0 | 630 signed int v62; // esi@133 |
631 //AudioPlayer *pAudioPlayer4; // ebx@133 | |
388 | 632 //MixerChannel *pMixerChannel2; // edi@134 |
633 //int v65; // ebx@141 | |
0 | 634 //AudioPlayer *pAudioPlayer5; // ecx@142 |
388 | 635 //MixerChannel *pMixerChannel3; // edi@142 |
0 | 636 int v68; // eax@143 |
388 | 637 //MixerChannel *pMixerChannel4; // edi@149 |
638 //int v70; // ecx@152 | |
639 //SoundDesc *pSoundDesc2; // eax@153 | |
640 //int v72; // edi@156 | |
641 //MixerChannel *pMixerChannel5; // esi@157 | |
642 //unsigned int pVolume; // eax@157 | |
643 //int pPartyX; // ebx@159 | |
644 //int v76; // ebx@160 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
645 //SpriteObject *pLayingItem4; // edi@164 |
388 | 646 //unsigned int pPosY; // edx@166 |
647 //unsigned int pPosX; // ecx@166 | |
648 //int v80; // eax@167 | |
649 //Actor *pActor3; // edi@168 | |
650 //BLVDoor *pBLVDoor2; // edi@173 | |
651 //int v83; // eax@183 | |
652 //int v84; // eax@183 | |
653 //_SAMPLE *v85; // ST18_4@186 | |
0 | 654 unsigned int v86; // [sp+14h] [bp-60h]@84 |
388 | 655 //int v87; // [sp+14h] [bp-60h]@115 |
0 | 656 RenderVertexSoft pRenderVertexSoft; // [sp+24h] [bp-50h]@1 |
388 | 657 //unsigned int v89; // [sp+54h] [bp-20h]@12 |
0 | 658 int v90; // [sp+58h] [bp-1Ch]@68 |
659 float v91; // [sp+5Ch] [bp-18h]@68 | |
660 //unsigned int v92; // [sp+60h] [bp-14h]@10 | |
661 float v93; // [sp+64h] [bp-10h]@1 | |
662 signed int varC; // [sp+68h] [bp-Ch]@68 | |
388 | 663 //AudioPlayer *pAudioPlayer; // [sp+6Ch] [bp-8h]@1 |
0 | 664 int v96; // [sp+70h] [bp-4h]@19 |
665 signed int uNumRepeatsb; // [sp+84h] [bp+10h]@93 | |
666 float uNumRepeatsa; // [sp+84h] [bp+10h]@104 | |
667 float v99; // [sp+8Ch] [bp+18h]@104 | |
668 signed int v100; // [sp+90h] [bp+1Ch]@32 | |
669 int v101; // [sp+90h] [bp+1Ch]@52 | |
670 int v102; // [sp+90h] [bp+1Ch]@60 | |
671 int v103; // [sp+90h] [bp+1Ch]@68 | |
672 | |
388 | 673 if (!bPlayerReady) |
674 return; | |
675 if (!uSoundVolumeMultiplier) | |
676 return; | |
677 if (!hDigDriver) | |
678 return; | |
679 if (eSoundID == SOUND_Invalid) | |
0 | 680 return; |
388 | 681 |
682 //pAudioPlayer = this; | |
683 //v35 = this->bPlayerReady == 0; | |
684 //pAudioPlayer = this; | |
685 //LODWORD(v93) = 10000; | |
686 int sample_volume = 10000; | |
687 | |
688 | |
689 int sound_id = 0; | |
764 | 690 for (uint i = 0; i < pSoundList->sNumSounds; ++i) |
388 | 691 if (pSoundList->pSounds[i].uSoundID == eSoundID) |
692 { | |
693 sound_id = i; | |
694 break; | |
695 } | |
696 | |
697 if (!sound_id) | |
0 | 698 { |
388 | 699 Log::Warning(L"SoundID = %u not found", eSoundID); |
700 return; | |
0 | 701 } |
388 | 702 |
703 int start_channel = 0, | |
704 end_channel = 0; | |
705 | |
764 | 706 assert(sound_id < pSoundList->sNumSounds); |
388 | 707 auto sound_desc = pSoundList->pSounds + sound_id; |
708 if (!b3DSoundInitialized || sound_desc->Is3D()) | |
0 | 709 { |
388 | 710 if (!a3) // generic sound like from UI |
711 { | |
712 start_channel = 10; | |
713 end_channel = 12; | |
714 goto LABEL_133; | |
715 } | |
716 else if (a3 == -1) // exclusive sounds - can override | |
0 | 717 { |
388 | 718 start_channel = 13; |
719 end_channel = 13; | |
720 goto LABEL_133; | |
721 } | |
722 else | |
723 { | |
724 if (a3 < 0) // exclusive sounds - no override | |
0 | 725 { |
388 | 726 start_channel = 14; |
727 end_channel = 14; | |
728 goto LABEL_123; | |
0 | 729 } |
388 | 730 else |
0 | 731 { |
848 | 732 int object_type = PID_TYPE(a3), |
733 object_id = PID_ID(a3); | |
388 | 734 switch (object_type) |
0 | 735 { |
388 | 736 case OBJECT_BLVDoor: |
737 case OBJECT_Player: | |
738 { | |
739 start_channel = 10; | |
740 end_channel = 12; | |
741 goto LABEL_133; | |
742 } | |
743 break; | |
744 | |
745 case OBJECT_Actor: | |
746 { | |
747 start_channel = 0; | |
748 end_channel = 3; | |
749 | |
750 assert(object_id < uNumActors); | |
751 auto actor = &pActors[object_id]; | |
752 | |
753 sample_volume = GetSoundStrengthByDistanceFromParty(actor->vPosition.x, actor->vPosition.y, actor->vPosition.z); | |
754 if (!sample_volume) | |
755 return; | |
756 goto LABEL_123; | |
757 } | |
758 | |
759 case OBJECT_Decoration: | |
0 | 760 { |
388 | 761 start_channel = 4; |
762 end_channel = 4; | |
763 | |
764 assert(object_id < uNumLevelDecorations); | |
765 auto decor = &pLevelDecorations[object_id]; | |
766 | |
767 sample_volume = GetSoundStrengthByDistanceFromParty(decor->vPosition.x, decor->vPosition.y, decor->vPosition.z); | |
768 if (!sample_volume) | |
769 return; | |
770 goto LABEL_123; | |
0 | 771 } |
388 | 772 break; |
773 | |
774 case OBJECT_Item: | |
775 { | |
776 start_channel = 5; | |
777 end_channel = 7; | |
778 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
779 assert(object_id < uNumSpriteObjects); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
780 auto object = &pSpriteObjects[object_id]; |
388 | 781 |
782 sample_volume = GetSoundStrengthByDistanceFromParty(object->vPosition.x, object->vPosition.y, object->vPosition.z); | |
783 if (!sample_volume) | |
784 return; | |
785 goto LABEL_123; | |
786 } | |
787 break; | |
788 | |
789 case OBJECT_BModel: | |
790 { | |
791 start_channel = 8; | |
792 end_channel = 9; | |
793 goto LABEL_123; | |
794 } | |
795 break; | |
796 | |
797 default: | |
798 assert(false); | |
0 | 799 } |
800 } | |
388 | 801 } |
802 LABEL_123: | |
803 for (uint i = 0; i < uMixerChannels; ++i) | |
804 { | |
805 auto channel = pMixerChannels + i; | |
806 if (channel->source_pid == a3 && | |
807 AIL_sample_status(channel->hSample) == AIL::Sample::Playing) | |
808 { | |
809 if (channel->uSourceTrackIdx == sound_id) | |
810 return; // already playing the same sound from the same source - return | |
811 AIL_end_sample(channel->hSample); // requested new sound from the same source - end & switch | |
764 | 812 FreeChannel(channel); |
388 | 813 } |
814 } | |
0 | 815 LABEL_133: |
388 | 816 v62 = start_channel; |
0 | 817 //pAudioPlayer4 = pAudioPlayer; |
388 | 818 for (v62 = start_channel; v62 <= end_channel; ++v62) |
0 | 819 { |
388 | 820 auto channel = pMixerChannels + v62; |
821 if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) | |
822 { | |
823 AIL_end_sample(channel->hSample); | |
824 if (channel->uSourceTrackIdx) | |
764 | 825 FreeChannel(channel); |
388 | 826 break; |
827 } | |
828 } | |
829 /*if ( start_channel <= end_channel) | |
830 { | |
831 pMixerChannel2 = &pAudioPlayer->pMixerChannels[start_channel]; | |
379 | 832 while ( AIL_sample_status(pMixerChannel2->hSample) != AIL::Sample::Done) |
0 | 833 { |
834 ++v62; | |
835 ++pMixerChannel2; | |
388 | 836 if ( v62 > end_channel ) |
0 | 837 goto LABEL_140; |
838 } | |
839 AIL_end_sample(pMixerChannel2->hSample); | |
840 if ( pMixerChannel2->uSourceTrackIdx ) | |
841 _4ABE55(pMixerChannel2); | |
842 } | |
388 | 843 LABEL_140:*/ |
844 | |
845 if (v62 > end_channel) // no free channel - occupy the quitest one | |
0 | 846 { |
388 | 847 v62 = -1; |
848 | |
849 int min_volume = sample_volume; | |
850 for (uint i = start_channel; i <= end_channel; ++i) | |
0 | 851 { |
388 | 852 auto channel = pMixerChannels + i; |
853 | |
854 int volume = AIL_sample_volume(channel->hSample); | |
855 if (volume < min_volume) | |
0 | 856 { |
388 | 857 min_volume = volume; |
858 v62 = i; | |
0 | 859 } |
860 } | |
388 | 861 /*v65 = start_channel; |
862 v91 = v93; | |
863 if (start_channel <= end_channel) | |
0 | 864 { |
865 //pAudioPlayer5 = pAudioPlayer; | |
388 | 866 pMixerChannel3 = &pAudioPlayer->pMixerChannels[start_channel]; |
0 | 867 do |
868 { | |
869 v68 = AIL_sample_volume(pMixerChannel3->hSample); | |
870 if ( v68 < SLODWORD(v91) ) | |
871 { | |
872 LODWORD(v91) = v68; | |
873 v62 = v65; | |
874 } | |
875 ++v65; | |
876 ++pMixerChannel3; | |
877 } | |
388 | 878 while ( v65 <= end_channel );*/ |
879 | |
880 if (v62 == -1) // no free channels at all - only channel 13 allows override (a3 == -1) | |
0 | 881 { |
388 | 882 if (start_channel != 13) |
883 return; | |
884 v62 = 13; | |
0 | 885 } |
388 | 886 |
887 auto channel = &pMixerChannels[v62]; | |
888 AIL_end_sample(channel->hSample); | |
764 | 889 FreeChannel(channel); |
0 | 890 } |
388 | 891 |
892 if (v62 > end_channel)//10!=13 | |
0 | 893 return; |
388 | 894 |
895 //LABEL_150: | |
896 if (sample_volume == 10000) | |
897 sample_volume = uMasterVolume; | |
898 | |
899 //v70 = 0; | |
900 if ( !a7 ) | |
901 { | |
902 //pSoundDesc = pSoundList->pSounds; | |
903 //pSoundDesc2 = &pSoundList->pSounds[sound_id]; | |
904 if (!sound_desc->pSoundData[0]) | |
905 { | |
906 if (sound_desc->eType == SOUND_DESC_SWAP) | |
907 pSoundList->LoadSound(eSoundID, 0); | |
908 } | |
909 } | |
910 //v72 = 4 * (a7 + 30 * sound_id) + 44; | |
911 if (!pSoundList->pSounds[sound_id].pSoundData[a7]) | |
912 return; | |
913 | |
914 //pMixerChannel5 = &pAudioPlayer->pMixerChannels[v62]; | |
915 auto channel = &pMixerChannels[v62]; | |
916 AIL_init_sample(channel->hSample); | |
917 AIL_set_sample_file(channel->hSample, (char *)pSoundList->pSounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); | |
918 if (uVolume) | |
919 sample_volume = uVolume; | |
920 AIL_set_sample_volume(channel->hSample, sample_volume); | |
921 | |
848 | 922 int object_type = PID_TYPE(a3), |
923 object_id = PID_ID(a3); | |
388 | 924 if (PartyX != -1) |
925 { | |
926 if (!PartyX) PartyX = pParty->vPosition.x; | |
927 if (!PartyY) PartyY = pParty->vPosition.y; | |
928 AIL_set_sample_pan(channel->hSample, sub_4AB66C(PartyX, PartyY)); | |
929 AIL_set_sample_volume(channel->hSample, GetSoundStrengthByDistanceFromParty(PartyX, PartyY, pParty->vPosition.z)); | |
930 } | |
931 else if (object_type == OBJECT_BLVDoor) | |
0 | 932 { |
388 | 933 assert(uCurrentlyLoadedLevelType == LEVEL_Indoor); |
934 | |
935 assert(object_id < pIndoor->uNumDoors); | |
936 auto door = &pIndoor->pDoors[object_id]; | |
937 if (!door->uDoorID) | |
0 | 938 return; |
388 | 939 |
940 if (!GetSoundStrengthByDistanceFromParty(door->pXOffsets[0], door->pYOffsets[0], door->pZOffsets[0])) | |
0 | 941 { |
388 | 942 AIL_end_sample(channel->hSample); |
764 | 943 FreeChannel(channel); |
388 | 944 return; |
0 | 945 } |
388 | 946 AIL_set_sample_pan(channel->hSample, sub_4AB66C(door->pXOffsets[0], door->pYOffsets[0])); |
947 } | |
948 else if (object_type == OBJECT_Item) | |
949 { | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
950 assert(object_id < uNumSpriteObjects); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
951 auto object = &pSpriteObjects[object_id]; |
388 | 952 if (!GetSoundStrengthByDistanceFromParty(object->vPosition.x, object->vPosition.y, object->vPosition.z) ) |
953 return; | |
954 AIL_set_sample_pan(channel->hSample, sub_4AB66C(object->vPosition.x, object->vPosition.y)); | |
955 } | |
956 else if (object_type == OBJECT_Actor) | |
957 { | |
958 assert(object_id < uNumActors); | |
959 auto actor = &pActors[object_id]; | |
960 if (!GetSoundStrengthByDistanceFromParty(actor->vPosition.x, actor->vPosition.y, actor->vPosition.z)) | |
961 return; | |
962 AIL_set_sample_pan(channel->hSample, sub_4AB66C(actor->vPosition.x, actor->vPosition.y)); | |
0 | 963 } |
388 | 964 else if (object_type == OBJECT_Decoration) |
965 { | |
966 assert(object_id < uNumLevelDecorations); | |
967 auto decor = &pLevelDecorations[object_id]; | |
968 if (!GetSoundStrengthByDistanceFromParty(decor->vPosition.x, decor->vPosition.y, decor->vPosition.z)) | |
969 return; | |
970 AIL_set_sample_pan(channel->hSample, sub_4AB66C(decor->vPosition.x, decor->vPosition.y)); | |
971 } | |
972 | |
973 //LABEL_184: | |
974 if (uNumRepeats) | |
975 AIL_set_sample_loop_count(channel->hSample, uNumRepeats - 1); | |
976 channel->uSourceTrackIdx = sound_id; | |
977 channel->source_pid = a3; | |
978 channel->uSourceTrackID = eSoundID; | |
979 int rval = AIL_start_sample(channel->hSample); | |
980 if ( sPlaybackRate ) | |
981 AIL_set_sample_playback_rate(channel->hSample, sPlaybackRate); | |
982 if (object_type == OBJECT_Player) | |
983 AIL_sample_ms_position(channel->hSample, &sLastTrackLengthMS, 0); | |
984 return; | |
0 | 985 } |
388 | 986 |
987 __debugbreak(); // 3d sound stuff, refactor | |
0 | 988 v12 = 13; |
989 if ( a3 < 0 ) | |
990 { | |
991 v15 = pAudioPlayer->uNum3DSamples; | |
992 if ( a3 == -1 ) | |
993 { | |
994 if ( v15 < 16 ) | |
995 v12 = v15 - 1; | |
996 v96 = v12; | |
997 //goto LABEL_46; | |
998 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; | |
999 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y; | |
1000 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; | |
1001 goto LABEL_47; | |
1002 } | |
1003 if ( v15 >= 16 ) | |
1004 v15 = 14; | |
1005 v12 = v15; | |
1006 //goto LABEL_45; | |
1007 v96 = v15; | |
1008 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; | |
1009 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y; | |
1010 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; | |
1011 goto LABEL_47; | |
1012 } | |
848 | 1013 if ( PID_TYPE(a3) == 2 ) |
0 | 1014 { |
1015 v22 = pAudioPlayer->uNum3DSamples; | |
1016 if ( v22 < 16 ) | |
1017 { | |
1018 v12 = 5 * v22 / 16; | |
1019 v96 = 7 * v22 / 16; | |
1020 } | |
1021 else | |
1022 { | |
1023 v96 = 7; | |
1024 v12 = 5; | |
1025 } | |
848 | 1026 pLayingItem = &pSpriteObjects[PID_ID(a3)]; |
0 | 1027 } |
1028 else | |
1029 { | |
848 | 1030 if ( PID_TYPE(a3) == 3 ) |
0 | 1031 { |
1032 v18 = pAudioPlayer->uNum3DSamples; | |
1033 v12 = 0; | |
1034 if ( v18 < 16 ) | |
1035 v96 = 3 * v18 / 16; | |
1036 else | |
1037 v96 = 3; | |
848 | 1038 pActor1 = &pActors[PID_ID(a3)]; |
0 | 1039 v20 = pActor1->vPosition.y; |
1040 pRenderVertexSoft.vWorldPosition.x = (double)pActor1->vPosition.x; | |
1041 v100 = pActor1->vPosition.z; | |
1042 pRenderVertexSoft.vWorldPosition.y = (double)v20; | |
1043 v21 = (double)v100; | |
1044 goto LABEL_47; | |
1045 } | |
848 | 1046 if ( PID_TYPE(a3) != 5 ) |
0 | 1047 { |
1048 v13 = pAudioPlayer->uNum3DSamples; | |
848 | 1049 if ( PID_TYPE(a3) == 6 ) |
0 | 1050 { |
1051 if ( v13 >= 16 ) | |
1052 { | |
1053 v96 = 9; | |
1054 v12 = 8; | |
1055 //goto LABEL_46; | |
1056 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; | |
1057 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y; | |
1058 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; | |
1059 goto LABEL_47; | |
1060 } | |
1061 v12 = 8 * v13 / 16; | |
1062 v14 = 9 * v13; | |
1063 } | |
1064 else | |
1065 { | |
1066 if ( v13 >= 16 ) | |
1067 { | |
1068 v96 = 12; | |
1069 v12 = 10; | |
1070 //LABEL_46: | |
1071 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; | |
1072 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y; | |
1073 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; | |
1074 goto LABEL_47; | |
1075 } | |
1076 v12 = 10 * v13 / 16; | |
1077 v14 = 12 * v13; | |
1078 } | |
1079 v15 = v14 / 16; | |
1080 //LABEL_45: | |
1081 v96 = v15; | |
1082 //goto LABEL_46; | |
1083 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; | |
1084 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y; | |
1085 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; | |
1086 goto LABEL_47; | |
1087 } | |
1088 v16 = pAudioPlayer->uNum3DSamples; | |
1089 if ( v16 < 16 ) | |
1090 { | |
1091 v12 = v16 / 4; | |
1092 v96 = v16 / 4; | |
1093 } | |
1094 else | |
1095 { | |
1096 v12 = 4; | |
1097 v96 = 4; | |
1098 } | |
848 | 1099 pLayingItem = (SpriteObject *)&pLevelDecorations[PID_ID(a3)]; |
0 | 1100 } |
1101 pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem->vPosition.x; | |
1102 pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem->vPosition.y; | |
1103 v21 = (double)pLayingItem->vPosition.z; | |
1104 LABEL_47: | |
1105 pRenderVertexSoft.vWorldPosition.z = v21; | |
1106 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1107 sub_4AAEA6_transform(&pRenderVertexSoft); | |
1108 else | |
1109 pGame->pIndoorCameraD3D->ViewTransform(&pRenderVertexSoft, 1); | |
1110 if ( a3 ) | |
1111 { | |
1112 if ( a3 != -1 ) | |
1113 { | |
1114 v101 = 0; | |
1115 if ( pAudioPlayer->uNum3DSamples > 0 ) | |
1116 { | |
1117 pAudioPlayer_3DSample = pAudioPlayer->p3DSamples; | |
1118 do | |
1119 { | |
1120 if ( AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4 | |
1121 && pAudioPlayer_3DSample->field_4 == a3 && AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4 ) | |
1122 { | |
388 | 1123 if ( pAudioPlayer_3DSample->field_8 == sound_id ) |
0 | 1124 return; |
1125 AIL_end_3D_sample(pAudioPlayer_3DSample->hSample); | |
1126 pAudioPlayer->_4ABF23(pAudioPlayer_3DSample); | |
1127 } | |
1128 ++v101; | |
1129 ++pAudioPlayer_3DSample; | |
1130 } | |
1131 while ( v101 < pAudioPlayer->uNum3DSamples ); | |
1132 } | |
1133 } | |
1134 } | |
1135 v102 = v12; | |
1136 if ( v12 <= v96 ) | |
1137 { | |
1138 pAudioPlayer_3DSample1 = &pAudioPlayer->p3DSamples[v12]; | |
1139 while ( AIL_3D_sample_status(pAudioPlayer_3DSample1->hSample) != 2 ) | |
1140 { | |
1141 ++v102; | |
1142 ++pAudioPlayer_3DSample1; | |
1143 if ( v102 > v96 ) | |
1144 goto LABEL_67; | |
1145 } | |
1146 AIL_end_3D_sample(pAudioPlayer_3DSample1->hSample); | |
1147 if ( pAudioPlayer_3DSample1->field_8 ) | |
1148 pAudioPlayer->_4ABF23(pAudioPlayer_3DSample1); | |
1149 } | |
1150 LABEL_67: | |
1151 v25 = v96; | |
1152 if ( v102 == v96 + 1 ) | |
1153 { | |
1154 LODWORD(v91) = -1; | |
1155 v103 = 0; | |
1156 *(float *)&varC = pRenderVertexSoft.vWorldViewPosition.y * -0.012207031; | |
1157 v93 = 0.0; | |
1158 v26 = pRenderVertexSoft.vWorldViewPosition.x * 0.012207031; | |
1159 *(float *)&uVolume = v26; | |
1160 v27 = abs((signed __int64)v26); | |
1161 v28 = abs((signed __int64)v93); | |
1162 v29 = abs((signed __int64)*(float *)&varC); | |
322 | 1163 v90 = int_get_vector_length(v29, v28, v27); |
0 | 1164 sPlaybackRate = v12; |
1165 if ( v12 > v25 ) | |
1166 goto LABEL_192; | |
1167 pAudioPlayer_3DSample2 = &pAudioPlayer->p3DSamples[v12]; | |
1168 do | |
1169 { | |
1170 AIL_3D_position(pAudioPlayer_3DSample2->hSample, &varC, &v93, (long *)&uVolume); | |
1171 v31 = abs((signed __int64)*(float *)&uVolume); | |
1172 v32 = abs((signed __int64)v93); | |
1173 v33 = abs((signed __int64)*(float *)&varC); | |
322 | 1174 v34 = int_get_vector_length(v33, v32, v31); |
0 | 1175 v35 = v103 == v34; |
1176 if ( v103 < v34 ) | |
1177 { | |
1178 v103 = v34; | |
1179 v35 = 1; | |
1180 } | |
1181 if ( v35 && v90 < v103 ) | |
1182 { | |
1183 v36 = sPlaybackRate; | |
1184 LODWORD(v91) = sPlaybackRate; | |
1185 } | |
1186 else | |
1187 { | |
1188 v36 = LODWORD(v91); | |
1189 } | |
1190 ++sPlaybackRate; | |
1191 ++pAudioPlayer_3DSample2; | |
1192 } | |
1193 while ( sPlaybackRate <= v96 ); | |
1194 if ( v36 == -1 ) | |
1195 { | |
1196 LABEL_192: | |
1197 v36 = 13; | |
1198 if ( v12 != 13 ) | |
1199 return; | |
1200 } | |
1201 //pAudioPlayer2 = pAudioPlayer; | |
1202 pAudioPlayer_3DSample3 = &pAudioPlayer->p3DSamples[v36]; | |
1203 AIL_end_3D_sample(pAudioPlayer_3DSample3->hSample); | |
1204 pAudioPlayer->_4ABF23(pAudioPlayer_3DSample3); | |
1205 v102 = v36; | |
1206 } | |
388 | 1207 //v39 = v89; |
1208 if ( pSoundList->pSounds[sound_id].p3DSound || (LOWORD(v40) = pSoundList->LoadSound(eSoundID, 0), v40) ) | |
0 | 1209 { |
1210 v41 = (char *)pAudioPlayer + 16 * v102; | |
1211 v42 = (int)(v41 + 20); | |
388 | 1212 if ( AIL_set_3D_sample_file(*((int *)v41 + 5), *(void **)((char *)&pSoundList->pSounds->p3DSound + sound_id * sizeof(SoundDesc))) ) |
0 | 1213 { |
1214 if ( uNumRepeats ) | |
1215 v86 = uNumRepeats - 1; | |
1216 else | |
1217 v86 = 1; | |
1218 AIL_set_3D_sample_loop_count(*(int *)v42, v86); | |
1219 if ( PartyX == -1 ) | |
1220 { | |
848 | 1221 if ( PID_TYPE(a3) == 1 ) |
0 | 1222 { |
1223 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1224 { | |
1225 //goto LABEL_103; | |
848 | 1226 pBLVDoor = &pIndoor->pDoors[PID_ID(a3)]; |
0 | 1227 if ( !pBLVDoor->uDoorID ) |
1228 return; | |
1229 pRenderVertexSoft.vWorldPosition.x = (double)*pBLVDoor->pXOffsets; | |
1230 pRenderVertexSoft.vWorldPosition.y = (double)*pBLVDoor->pYOffsets; | |
1231 v47 = (double)*pBLVDoor->pZOffsets; | |
1232 LABEL_101: | |
1233 pRenderVertexSoft.vWorldPosition.z = v47; | |
1234 //if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1235 //{ | |
1236 sub_4AAEA6_transform(&pRenderVertexSoft); | |
1237 //goto LABEL_104; | |
1238 //} | |
1239 } | |
1240 //LABEL_103: | |
1241 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) | |
1242 pGame->pIndoorCameraD3D->ViewTransform(&pRenderVertexSoft, 1); | |
1243 //LABEL_104: | |
1244 AIL_start_3D_sample(*(int *)v42); | |
1245 AIL_set_3D_sample_float_distances(*(int **)v42, 100.0, 20.0, 100.0, 20.0); | |
1246 AIL_set_3D_sample_volume(*(int **)v42, pAudioPlayer->s3DSoundVolume); | |
1247 v99 = pRenderVertexSoft.vWorldViewPosition.y * -0.012207031; | |
1248 v49 = pRenderVertexSoft.vWorldViewPosition.x * 0.012207031; | |
1249 uNumRepeatsa = v49; | |
1250 v50 = abs((signed __int64)v49); | |
1251 v51 = abs(0); | |
1252 v52 = abs((signed __int64)v99); | |
322 | 1253 if ( int_get_vector_length(v52, v51, v50) <= 100 ) |
0 | 1254 { |
1255 AIL_set_3D_position((void *)*(int *)v42, LODWORD(v99), 0.0, LODWORD(uNumRepeatsa)); | |
1256 v53 = -uNumRepeatsa; | |
1257 v54 = -v99; | |
1258 AIL_set_3D_orientation((void *)*(int *)v42, LODWORD(v54), 0.0, LODWORD(v53), 0.0, 1.0, 0.0); | |
1259 //pAudioPlayer3 = pAudioPlayer; | |
1260 *((int *)v41 + 6) = a3; | |
388 | 1261 *((int *)v41 + 7) = sound_id; |
0 | 1262 *(&pAudioPlayer->bEAXSupported + 4 * (v102 + 2)) = eSoundID; |
1263 } | |
1264 else | |
1265 { | |
1266 AIL_end_3D_sample(*(int **)v42); | |
1267 pAudioPlayer->_4ABF23((AudioPlayer_3DSample *)(v41 + 20)); | |
1268 } | |
1269 return; | |
1270 } | |
848 | 1271 if ( PID_TYPE(a3) == 2 ) |
0 | 1272 { |
848 | 1273 pLayingItem2 = &pSpriteObjects[PID_ID(a3)]; |
0 | 1274 } |
1275 else | |
1276 { | |
848 | 1277 if ( PID_TYPE(a3) == 3 ) |
0 | 1278 { |
848 | 1279 pActor = &pActors[PID_ID(a3)]; |
0 | 1280 v46 = pActor->vPosition.y; |
1281 pRenderVertexSoft.vWorldPosition.x = (double)pActor->vPosition.x; | |
1282 uNumRepeatsb = pActor->vPosition.z; | |
1283 pRenderVertexSoft.vWorldPosition.y = (double)v46; | |
1284 v47 = (double)uNumRepeatsb; | |
1285 goto LABEL_101; | |
1286 } | |
848 | 1287 if ( PID_TYPE(a3) != 5 ) |
0 | 1288 { |
1289 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; | |
1290 v43 = (double)pParty->vPosition.y; | |
1291 pRenderVertexSoft.vWorldPosition.y = v43; | |
1292 v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; | |
1293 goto LABEL_101; | |
1294 } | |
848 | 1295 pLayingItem2 = (SpriteObject *)&pLevelDecorations[PID_ID(a3)]; |
0 | 1296 } |
1297 pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem2->vPosition.x; | |
1298 pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem2->vPosition.y; | |
1299 v47 = (double)pLayingItem2->vPosition.z; | |
1300 goto LABEL_101; | |
1301 } | |
1302 pRenderVertexSoft.vWorldPosition.x = (double)PartyX; | |
1303 v43 = (double)PartyY; | |
1406 | 1304 pRenderVertexSoft.vWorldPosition.y = v43; |
1305 v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; | |
1306 goto LABEL_101; | |
0 | 1307 } |
1308 } | |
1309 } | |
1310 | |
1311 //----- (0040DEA5) -------------------------------------------------------- | |
1312 void __cdecl AudioPlayer::MessWithChannels() | |
1313 { | |
1314 pAudioPlayer->StopChannels(-1, -1); | |
1315 } | |
1316 | |
1317 | |
1318 //----- (004AAFCF) -------------------------------------------------------- | |
378 | 1319 void AudioPlayer::UpdateSounds() |
0 | 1320 { |
378 | 1321 //AudioPlayer *pAudioPlayer; // edi@1 |
0 | 1322 int v2; // ebx@1 |
378 | 1323 //unsigned __int8 v3; // zf@1 |
1324 //int *v4; // eax@2 | |
1325 //unsigned __int8 v5; // sf@4 | |
0 | 1326 AudioPlayer_3DSample *v6; // esi@5 |
1327 int v7; // ebx@6 | |
1328 int v8; // ebx@9 | |
1329 int v9; // ebx@10 | |
1330 int v10; // ebx@11 | |
1331 double v11; // st7@13 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
1332 SpriteObject *v12; // eax@14 |
0 | 1333 Actor *v13; // eax@15 |
1334 signed int v14; // edx@15 | |
1408 | 1335 BLVDoor *pDoor; // eax@19 |
0 | 1336 double v16; // st7@22 |
1337 double v17; // st6@22 | |
1338 double v18; // st5@23 | |
1339 double v19; // st4@24 | |
1340 double v20; // st3@24 | |
1341 double v21; // st6@28 | |
1342 double v22; // st7@32 | |
1343 int v23; // ST1C_4@32 | |
1344 int v24; // ebx@32 | |
1345 int v25; // eax@32 | |
1346 float v26; // ST10_4@34 | |
1347 float v27; // ST08_4@34 | |
378 | 1348 //MixerChannel *v28; // esi@38 |
1349 //unsigned __int8 v29; // of@43 | |
1350 //MixerChannel *v30; // esi@44 | |
1351 //int v31; // eax@45 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
1352 //SpriteObject *v32; // eax@49 |
378 | 1353 //Actor *v33; // edi@50 |
1354 //int v34; // eax@50 | |
1355 //unsigned int v35; // edx@51 | |
1356 //unsigned int v36; // ecx@51 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
1357 //SpriteObject *v37; // edi@53 |
0 | 1358 int v38; // eax@53 |
378 | 1359 //BLVDoor *v39; // edi@56 |
1360 //int v40; // eax@57 | |
1361 //int v41; // eax@60 | |
379 | 1362 //MixerChannel *v42; // edi@65 |
1363 //int v43; // ebx@68 | |
1364 //LevelDecoration *v44; // esi@68 | |
1365 //int v45; // ST1C_4@68 | |
1366 //int v46; // edi@68 | |
1367 //int v47; // eax@68 | |
1368 //DecorationDesc *v48; // edi@69 | |
1369 //__int16 v49; // ax@69 | |
1370 //__int16 v50; // ax@70 | |
0 | 1371 __int16 v51; // ax@71 |
379 | 1372 //__int16 v52; // ax@73 |
0 | 1373 signed int v53; // eax@88 |
1374 RenderVertexSoft a1; // [sp+24h] [bp-48h]@1 | |
1375 float v55; // [sp+54h] [bp-18h]@22 | |
1376 float v56; // [sp+58h] [bp-14h]@22 | |
1377 int uNumRepeats; // [sp+5Ch] [bp-10h]@15 | |
1378 float v58; // [sp+60h] [bp-Ch]@23 | |
1379 int v59; // [sp+64h] [bp-8h]@4 | |
378 | 1380 //AudioPlayer *thisa; // [sp+68h] [bp-4h]@1 |
0 | 1381 |
378 | 1382 //pAudioPlayer = this; |
0 | 1383 v2 = 0; |
378 | 1384 //thisa = this; |
1385 //v3 = this->bPlayerReady == 0; | |
1386 //a1.flt_2C = 0.0; | |
1387 if (!bPlayerReady) | |
1388 return; | |
1389 | |
1390 if (field_2D0_time_left <= pEventTimer->uTimeElapsed) | |
1391 field_2D0_time_left = 32; | |
1392 else | |
0 | 1393 { |
378 | 1394 field_2D0_time_left -= pEventTimer->uTimeElapsed; |
1395 return; | |
1396 } | |
1397 | |
1408 | 1398 //v3 = this->b3DSoundInitialized == 0; |
1399 if ( b3DSoundInitialized ) | |
1400 { | |
1401 __debugbreak(); // refactor refactor | |
1402 //v3 = this->uNum3DSamples == 0; | |
1403 //v5 = this->uNum3DSamples < 0; | |
1404 v59 = 0; | |
1405 if (uNum3DSamples > 0) | |
1406 { | |
1407 v6 = this->p3DSamples; | |
1408 while ( 1 ) | |
0 | 1409 { |
1408 | 1410 v7 = PID_TYPE(v6->field_4); |
1411 if ( AIL_3D_sample_status(v6->hSample) == 2 ) | |
1412 { | |
1413 AIL_end_3D_sample(v6->hSample); | |
1414 pAudioPlayer->_4ABF23(v6); | |
1415 } | |
1416 if ( AIL_3D_sample_status(v6->hSample) != 4 ) | |
1417 goto LABEL_35; | |
1418 v8 = v7 - 1;// | |
1419 if ( v8 )//> 1 | |
1420 break; | |
1421 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )//==1 | |
1422 goto LABEL_31; | |
1423 pDoor = &pIndoor->pDoors[PID_ID(v6->field_4)]; | |
1424 if ( pDoor->uDoorID ) | |
1425 { | |
1426 uNumRepeats = *pDoor->pXOffsets; | |
1427 a1.vWorldPosition.x = (double)uNumRepeats; | |
1428 uNumRepeats = *pDoor->pYOffsets; | |
1429 a1.vWorldPosition.y = (double)uNumRepeats; | |
1430 uNumRepeats = *pDoor->pZOffsets; | |
1431 v11 = (double)uNumRepeats; | |
1432 goto LABEL_21; | |
1433 } | |
1434 LABEL_35: | |
1435 ++v59; | |
1436 ++v6; | |
1437 if ( v59 >= pAudioPlayer->uNum3DSamples ) | |
1438 { | |
1439 v2 = 0; | |
1440 goto LABEL_37; | |
1441 } | |
1442 } | |
1443 | |
1444 v9 = v8 - 1;// | |
1445 if ( v9 )//> 2 | |
1446 { | |
1447 v10 = v9 - 1;// | |
1448 if ( !v10 )//3 | |
0 | 1449 { |
1408 | 1450 v13 = &pActors[PID_ID(v6->field_4)]; |
1451 uNumRepeats = v13->vPosition.x; | |
1452 v14 = v13->vPosition.y; | |
1453 a1.vWorldPosition.x = (double)uNumRepeats; | |
1454 uNumRepeats = v13->vPosition.z; | |
1455 a1.vWorldPosition.y = (double)v14; | |
1456 v11 = (double)uNumRepeats; | |
1457 goto LABEL_21; | |
1458 } | |
1459 if ( v10 != 2 )//4 | |
1460 { | |
1461 a1.vWorldPosition.x = (double)pParty->vPosition.x; | |
1462 a1.vWorldPosition.y = (double)pParty->vPosition.y; | |
1463 v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; | |
1464 goto LABEL_21; | |
1465 }//5 | |
1466 v12 = (SpriteObject *)&pLevelDecorations[PID_ID(v6->field_4)]; | |
1467 } | |
1468 else//2 | |
1469 { | |
1470 v12 = &pSpriteObjects[PID_ID(v6->field_4)]; | |
1471 } | |
1472 a1.vWorldPosition.x = (double)v12->vPosition.x; | |
1473 a1.vWorldPosition.y = (double)v12->vPosition.y; | |
1474 v11 = (double)v12->vPosition.z; | |
1475 LABEL_21: | |
1476 a1.vWorldPosition.z = v11; | |
1477 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1478 { | |
1479 v16 = pBLVRenderParams->fCosineNegX; | |
1480 v17 = pBLVRenderParams->fSineNegX; | |
1481 v55 = pBLVRenderParams->fCosineY; | |
1482 v56 = pBLVRenderParams->fSineY; | |
1483 if ( pBLVRenderParams->sPartyRotX ) | |
1484 { | |
1485 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; | |
1486 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; | |
1487 v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z; | |
1488 if ( pRenderer->pRenderD3D ) | |
0 | 1489 { |
1408 | 1490 v19 = *(float *)&uNumRepeats * v56 + v58 * v55; |
1491 v20 = v58 * v56 - *(float *)&uNumRepeats * v55; | |
0 | 1492 } |
1493 else | |
1494 { | |
1408 | 1495 v19 = v58 * v55 - *(float *)&uNumRepeats * v56; |
1496 v20 = v58 * v56 + *(float *)&uNumRepeats * v55; | |
0 | 1497 } |
1408 | 1498 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17; |
1499 a1.vWorldViewPosition.y = v20; | |
1500 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16; | |
1501 } | |
1502 else | |
1503 { | |
1504 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; | |
1505 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; | |
1506 if ( pRenderer->pRenderD3D ) | |
0 | 1507 { |
1408 | 1508 a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55; |
1509 v21 = v58 * v56 - *(float *)&uNumRepeats * v55; | |
0 | 1510 } |
1511 else | |
1512 { | |
1408 | 1513 a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56; |
1514 v21 = v58 * v56 + *(float *)&uNumRepeats * v55; | |
0 | 1515 } |
1408 | 1516 a1.vWorldViewPosition.y = v21; |
1517 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z; | |
0 | 1518 } |
1519 } | |
1408 | 1520 else |
1521 { | |
1522 LABEL_31: | |
1523 pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u); | |
1524 } | |
1525 v58 = a1.vWorldViewPosition.y * -0.012207031; | |
1526 v22 = a1.vWorldViewPosition.x * 0.012207031; | |
1527 *(float *)&uNumRepeats = v22; | |
1528 v23 = abs((signed __int64)v22); | |
1529 v24 = abs(0); | |
1530 v25 = abs((signed __int64)v58); | |
1531 if ( int_get_vector_length(v25, v24, v23) <= 100 ) | |
1532 { | |
1533 AIL_set_3D_position(v6->hSample, LODWORD(v58), 0.0, uNumRepeats); | |
1534 v26 = -*(float *)&uNumRepeats; | |
1535 v27 = -v58; | |
1536 AIL_set_3D_orientation(v6->hSample, LODWORD(v27), 0.0, LODWORD(v26), 0.0, 1.0, 0.0); | |
1537 } | |
1538 else | |
1539 { | |
1540 AIL_end_3D_sample(v6->hSample); | |
1541 pAudioPlayer->_4ABF23(v6); | |
1542 } | |
1543 goto LABEL_35; | |
1544 } | |
1545 } | |
378 | 1546 |
0 | 1547 LABEL_37: |
378 | 1548 for (uint i = 0; i < uMixerChannels; ++i) |
1549 { | |
1408 | 1550 if (AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Done) |
390 | 1551 { |
1408 | 1552 AIL_end_sample(pMixerChannels[i].hSample); |
1553 FreeChannel(&pMixerChannels[i]); | |
390 | 1554 } |
378 | 1555 } |
1556 | |
1557 for (uint i = 0; i < uMixerChannels; ++i) | |
1558 { | |
1408 | 1559 if (pMixerChannels[i].source_pid <= 0) |
390 | 1560 continue; |
1561 | |
1408 | 1562 int source_type = PID_TYPE(pMixerChannels[i].source_pid), |
1563 source_id = PID_ID(pMixerChannels[i].source_pid); | |
378 | 1564 int source_x, |
1565 source_y, | |
1566 source_z; | |
1567 | |
1568 switch (source_type) | |
1569 { | |
1570 case 0: | |
1571 case OBJECT_Player: | |
411 | 1572 case OBJECT_BModel: |
378 | 1573 continue; |
1574 | |
1575 case OBJECT_BLVDoor: | |
0 | 1576 { |
378 | 1577 assert(uCurrentlyLoadedLevelType == LEVEL_Indoor); |
1578 | |
1579 assert(source_id < pIndoor->uNumDoors); | |
1408 | 1580 if (!pIndoor->pDoors[source_id].uDoorID) |
378 | 1581 continue; |
1582 | |
1408 | 1583 source_x = pIndoor->pDoors[source_id].pXOffsets[0]; |
1584 source_y = pIndoor->pDoors[source_id].pYOffsets[0]; | |
1585 source_z = pIndoor->pDoors[source_id].pZOffsets[0]; | |
0 | 1586 } |
378 | 1587 break; |
1588 | |
1589 case OBJECT_Item: | |
379 | 1590 { |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
412
diff
changeset
|
1591 assert(source_id < uNumSpriteObjects); |
379 | 1592 |
1408 | 1593 source_x = pSpriteObjects[source_id].vPosition.x; |
1594 source_y = pSpriteObjects[source_id].vPosition.y; | |
1595 source_z = pSpriteObjects[source_id].vPosition.z; | |
379 | 1596 } |
1597 break; | |
1598 | |
378 | 1599 case OBJECT_Decoration: |
0 | 1600 { |
379 | 1601 assert(source_id < uNumLevelDecorations); |
378 | 1602 |
1408 | 1603 source_x = pLevelDecorations[source_id].vPosition.x; |
1604 source_y = pLevelDecorations[source_id].vPosition.y; | |
1605 source_z = pLevelDecorations[source_id].vPosition.z; | |
0 | 1606 } |
378 | 1607 break; |
1608 | |
1609 case OBJECT_Actor: | |
1610 { | |
1611 assert(source_id < uNumActors); | |
1612 | |
1408 | 1613 source_x = pActors[source_id].vPosition.x; |
1614 source_y = pActors[source_id].vPosition.y; | |
1615 source_z = pActors[source_id].vPosition.z; | |
378 | 1616 } |
1617 break; | |
1618 | |
1619 default: | |
408 | 1620 assert(false); |
378 | 1621 continue; |
1622 } | |
1623 | |
1624 if (auto sound_strength = GetSoundStrengthByDistanceFromParty(source_x, source_y, source_z)) | |
1625 { | |
1408 | 1626 AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength); |
1627 AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(source_x, source_y)); | |
378 | 1628 } |
1629 else | |
1630 { | |
1408 | 1631 AIL_end_sample(pMixerChannels[i].hSample); |
1632 FreeChannel(&pMixerChannels[i]); | |
378 | 1633 } |
1634 } | |
1635 | |
1636 | |
379 | 1637 |
1638 if (pCurrentScreen != SCREEN_GAME) | |
1639 { | |
1640 auto channel = &pMixerChannels[4]; | |
1641 if (AIL_sample_status(channel->hSample) == AIL::Sample::Playing) | |
1642 AIL_end_sample(channel->hSample); | |
1643 return; | |
1644 } | |
1645 if (!_6807E0_num_decorations_with_sounds_6807B8) | |
1646 return; | |
1647 | |
378 | 1648 v55 = 0; |
379 | 1649 //v59 = 0; |
1650 for (uint i = 0; i < _6807E0_num_decorations_with_sounds_6807B8; ++i) | |
1651 { | |
1652 //while ( 1 ) | |
1653 //{ | |
0 | 1654 LODWORD(v56) = 1; |
379 | 1655 //v43 = _6807B8_level_decorations_ids[v59]; |
1656 //v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]]; | |
1657 //v45 = abs(v44->vPosition.z - pParty->vPosition.z); | |
1658 //v46 = abs(v44->vPosition.y - pParty->vPosition.y); | |
1659 //v47 = abs(v44->vPosition.x - pParty->vPosition.x); | |
1660 auto decor = &pLevelDecorations[_6807B8_level_decorations_ids[i]]; | |
1661 if (int_get_vector_length(decor->vPosition.x - pParty->vPosition.x, | |
1662 decor->vPosition.y - pParty->vPosition.y, | |
1663 decor->vPosition.z - pParty->vPosition.z) > 8192) | |
1664 continue; | |
1665 | |
1666 auto decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
1667 //v48 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
1668 //v49 = v48->uFlags; | |
592 | 1669 uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & DECORATION_SLOW_LOOP) >> 6; |
379 | 1670 |
1671 if (decor_desc->SoundOnDawn() || decor_desc->SoundOnDusk()) | |
1672 { | |
1673 //v50 = decor->field_1A; | |
0 | 1674 v55 = 0.0; |
1675 uNumRepeats = 2; | |
379 | 1676 if (decor->field_1A) |
0 | 1677 { |
379 | 1678 v51 = decor->field_1A - 32; |
1679 decor->field_1A = v51; | |
0 | 1680 if ( v51 < 0 ) |
379 | 1681 decor->field_1A = 0; |
0 | 1682 } |
379 | 1683 } |
1684 | |
1685 //v52 = v48->uFlags; | |
1686 if (!decor_desc->SoundOnDawn()) | |
1687 { | |
1688 if (!decor_desc->SoundOnDusk()) | |
1408 | 1689 { |
1690 if ( v55 == 0.0 ) | |
1691 { | |
1692 if ( v56 != 0.0 ) | |
1693 { | |
1694 v53 = 8 * _6807B8_level_decorations_ids[i]; | |
1695 LOBYTE(v53) = v53 | OBJECT_Decoration; | |
1696 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); | |
1697 } | |
1698 continue; | |
1699 } | |
1700 if ( !decor->field_1A ) | |
1701 decor->field_1A = (rand() % 15 + 1) << 7; | |
1702 if ( v56 != 0.0 ) | |
1703 { | |
1704 v53 = 8 * _6807B8_level_decorations_ids[i]; | |
1705 LOBYTE(v53) = v53 | OBJECT_Decoration; | |
1706 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); | |
1707 } | |
1708 continue; | |
1709 } | |
379 | 1710 if ( v55 != 0.0 ) |
1408 | 1711 { |
1712 if ( !decor->field_1A ) | |
1713 decor->field_1A = (rand() % 15 + 1) << 7; | |
1714 if ( v56 != 0.0 ) | |
1715 { | |
1716 v53 = 8 * _6807B8_level_decorations_ids[i]; | |
1717 LOBYTE(v53) = v53 | OBJECT_Decoration; | |
1718 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); | |
1719 } | |
1720 continue; | |
1721 } | |
379 | 1722 } |
1723 v56 = 0.0; | |
1724 | |
1725 if (pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 6 || | |
1726 pParty->uCurrentHour >= 20 && pParty->uCurrentHour < 21) | |
1727 { | |
1728 if ( !decor->field_1A && rand() % 100 < 100 ) | |
0 | 1729 LODWORD(v56) = 1; |
1730 LODWORD(v55) = 1; | |
379 | 1731 } |
1408 | 1732 if ( v55 == 0.0 ) |
1733 { | |
1734 if ( v56 != 0.0 ) | |
0 | 1735 { |
1408 | 1736 v53 = 8 * _6807B8_level_decorations_ids[i]; |
1737 LOBYTE(v53) = v53 | OBJECT_Decoration; | |
1738 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); | |
0 | 1739 } |
1408 | 1740 continue; |
1741 } | |
1742 if ( !decor->field_1A ) | |
1743 decor->field_1A = (rand() % 15 + 1) << 7; | |
1744 if ( v56 != 0.0 ) | |
1745 { | |
1746 v53 = 8 * _6807B8_level_decorations_ids[i]; | |
1747 LOBYTE(v53) = v53 | OBJECT_Decoration; | |
1748 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); | |
1749 } | |
1750 continue; | |
379 | 1751 } |
0 | 1752 } |
1753 | |
1754 //----- (004AB66C) -------------------------------------------------------- | |
1755 int __fastcall sub_4AB66C(int a1, int a2) | |
1756 { | |
1757 signed int v2; // eax@1 | |
1758 | |
1759 v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.y) | |
147 | 1760 - stru_5C6E00->uIntegerHalfPi - pParty->sRotationY); |
0 | 1761 if ( v2 > (signed int)stru_5C6E00->uIntegerPi ) |
1762 v2 = 2 * stru_5C6E00->uIntegerPi - v2; | |
1763 return (v2 >> 3) - (v2 >> 10); | |
1764 } | |
1765 // 4AB66C: using guessed type int __fastcall sub_4AB66C(int, int); | |
1766 | |
1767 //----- (004AB6B1) -------------------------------------------------------- | |
1408 | 1768 int GetSoundStrengthByDistanceFromParty(int x, int y, int z) |
0 | 1769 { |
1408 | 1770 int dir_x; // ST08_4@1 |
1771 int dir_y; // esi@1 | |
1772 int dir_z; // eax@1 | |
1773 int length; // [sp+10h] [bp+8h]@1 | |
0 | 1774 |
1408 | 1775 dir_z = abs(z - pParty->vPosition.z); |
1776 dir_y = abs(y - pParty->vPosition.y); | |
1777 dir_x = abs(x - pParty->vPosition.x); | |
1778 length = int_get_vector_length(dir_x, dir_y, dir_z); | |
1779 if ( length <= 8192 ) | |
1780 return 114 - (unsigned __int64)(signed __int64)((double)length * 0.0001220703125 * 100.0); | |
0 | 1781 else |
322 | 1782 return 0; |
0 | 1783 } |
1784 | |
1785 //----- (004AB71F) -------------------------------------------------------- | |
1786 void AudioPlayer::StopChannels(int uStartChannel, int uEndChannel) | |
1787 { | |
1788 //AudioPlayer *v3; // esi@1 | |
1789 int v4; // ecx@1 | |
1408 | 1790 //AudioPlayer_3DSample *v5; // edi@4 |
0 | 1791 int v6; // ebx@12 |
1792 MixerChannel *pChannel; // edi@14 | |
1793 //_STREAM *v8; // esi@23 | |
1794 int v9; // [sp+4h] [bp-4h]@3 | |
1795 | |
1796 if ( bPlayerReady ) | |
1797 { | |
1798 if ( b3DSoundInitialized ) | |
1799 { | |
1800 v9 = 0; | |
1801 if ( uNum3DSamples > 0 ) | |
1802 { | |
1408 | 1803 //v5 = p3DSamples;//;(char *)&p3DSamples[0].field_8; |
1804 for ( v4 = 0; v4 < uNum3DSamples; ++v4 ) | |
0 | 1805 { |
1806 if ( (uStartChannel == -1 || v4 < uStartChannel || v4 > uEndChannel) | |
1408 | 1807 && p3DSamples[v4].field_8 |
1808 && pSoundList->pSounds[p3DSamples[v4].field_8].eType != SOUND_DESC_SYSTEM) | |
0 | 1809 { |
1408 | 1810 AIL_end_3D_sample(p3DSamples[v4].hSample); |
1811 _4ABF23(&p3DSamples[v4]); | |
1812 p3DSamples[v4].field_4 = 0; | |
0 | 1813 v4 = v9; |
1814 } | |
1408 | 1815 //v5 += 16; |
0 | 1816 v9 = v4; |
1817 } | |
1818 } | |
1819 } | |
1820 if ( hDigDriver && uMixerChannels > 0 ) | |
1821 { | |
1822 pChannel = pMixerChannels; | |
1408 | 1823 for ( v6 = 0; v6 < uMixerChannels; ++v6 ) |
0 | 1824 { |
1825 if ( (uStartChannel == -1 || v6 < uStartChannel || v6 > uEndChannel) | |
1826 && pSoundList->pSounds[pChannel->uSourceTrackIdx].eType != SOUND_DESC_SYSTEM) | |
1827 { | |
1828 AIL_end_sample(pChannel->hSample); | |
764 | 1829 FreeChannel(pChannel); |
378 | 1830 pChannel->source_pid = 0; |
0 | 1831 } |
1832 ++pChannel; | |
1833 } | |
1834 } | |
1835 if (hSequence) | |
1836 AIL_end_sequence(hSequence); | |
1837 //v8 = hStream; | |
1838 if (hStream) | |
1839 AIL_pause_stream(hStream, 1); | |
1840 } | |
1841 } | |
1842 | |
1843 //----- (004AB818) -------------------------------------------------------- | |
1844 void AudioPlayer::LoadAudioSnd() | |
1845 { | |
1846 DWORD NumberOfBytesRead; // [sp+Ch] [bp-4h]@3 | |
1847 | |
1848 hAudioSnd = CreateFileA("Sounds\\Audio.snd", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0); | |
1849 if (hAudioSnd == INVALID_HANDLE_VALUE) | |
1850 { | |
1851 Log::Warning(L"Can't open file: %s", L"Sounds\\Audio.snd"); | |
1852 return; | |
1853 } | |
1854 | |
1855 ReadFile(hAudioSnd, &uNumSoundHeaders, 4u, &NumberOfBytesRead, 0); | |
1856 pSoundHeaders = nullptr; | |
1857 pSoundHeaders = (SoundHeader *)pAllocator->AllocNamedChunk(0, 52 * uNumSoundHeaders + 2, 0); | |
1858 ReadFile(hAudioSnd, pSoundHeaders, 52 * uNumSoundHeaders, &NumberOfBytesRead, 0); | |
1859 } | |
1860 | |
1861 //----- (004AB8CE) -------------------------------------------------------- | |
1862 void AudioPlayer::Initialize(HWND hWnd) | |
1863 { | |
1864 //AudioPlayer *v2; // esi@1 | |
1865 int v3; // ebx@1 | |
1866 //_DIG_DRIVER *v4; // eax@1 | |
1867 char v5; // dl@5 | |
1868 _PROVIDER *v6; // eax@9 | |
1869 HWND v7; // ST00_4@9 | |
1870 MixerChannel *pChannel; // edi@14 | |
1871 _SAMPLE *v9; // eax@15 | |
1872 //_REDBOOK *v10; // eax@19 | |
1873 //int v11; // ecx@21 | |
1874 int v12; // [sp+Ch] [bp-Ch]@9 | |
1875 char *Str1; // [sp+10h] [bp-8h]@6 | |
1876 int v14; // [sp+14h] [bp-4h]@5 | |
1877 | |
1878 //v2 = this; | |
1879 v3 = 0; | |
1880 this->hWindow = hWnd; | |
1881 this->hAILRedbook = 0; | |
1882 this->hDigDriver = 0; | |
1883 this->dword_0002AC = 0; | |
1884 this->hSequence = 0; | |
1885 this->uMasterVolume = 127; | |
1886 this->dword_0002C8 = 64; | |
1887 this->dword_0002CC = 2; | |
1888 | |
1889 MSS32_DLL_Initialize(); | |
1890 BINKW32_DLL_Initialize(); | |
1891 SMACKW32_DLL_Initialize(); | |
1892 | |
1893 AIL_startup(); | |
1894 if (bCanLoadFromCD) | |
1895 hAILRedbook = AIL_redbook_open_drive(cMM7GameCDDriveLetter/*cGameCDDriveLetter*/); | |
1896 //else | |
1897 // hAILRedbook = AIL_redbook_open(0); | |
1898 //v4 = Audio_GetFirstHardwareDigitalDriver(); | |
1899 | |
1900 hDigDriver = Audio_GetFirstHardwareDigitalDriver(); | |
1901 if ( hDigDriver ) | |
1902 SmackSoundUseMSS(hDigDriver); | |
1903 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 && pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ) | |
1904 { | |
1905 v14 = 0; | |
1906 bEAXSupported = 0; | |
1907 b3DSoundInitialized = 0; | |
1908 ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128u, "NONE"); | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1408
diff
changeset
|
1909 __debugbreak(); // audioplayer.cpp(1926): warning C4700: uninitialized local variable 'v5' used |
0 | 1910 CheckA3DSupport(v5); |
1911 while ( AIL_enumerate_3D_providers(&v14, (HPROVIDER *)&hWnd, &Str1) ) | |
1912 { | |
1913 if ( !strcmp(Str1, p3DSoundProvider) ) | |
1914 { | |
1915 if ( AIL_open_3D_provider((HPROVIDER)hWnd) ) | |
1916 { | |
1917 bEAXSupported = 0; | |
1918 b3DSoundInitialized = 0; | |
1919 h3DSoundProvider = 0; | |
1920 } | |
1921 else | |
1922 { | |
1923 v6 = (_PROVIDER *)hWnd; | |
1924 v7 = hWnd; | |
1925 b3DSoundInitialized = 1; | |
1926 h3DSoundProvider = v6; | |
1927 uNum3DSamples = 4; | |
1928 AIL_3D_provider_attribute((HPROVIDER)v7, "EAX environment selection", &v12); | |
1929 if ( v12 != -1 ) | |
1930 bEAXSupported = 1; | |
1931 } | |
1932 pAudioPlayer->_4AC0A2(); | |
1933 break; | |
1934 } | |
1935 } | |
1936 } | |
1937 if ( uMixerChannels > 0 ) | |
1938 { | |
1939 pChannel = pMixerChannels; | |
1940 do | |
1941 { | |
1942 v9 = AIL_allocate_sample_handle(hDigDriver); | |
1943 pChannel->hSample = v9; | |
1944 if ( !v9 ) | |
1945 break; | |
1946 ++v3; | |
1947 ++pChannel; | |
1948 } | |
1949 while ( v3 < uMixerChannels ); | |
1950 } | |
1951 uMixerChannels = v3; | |
1952 if ( bPlayerReady ) | |
1953 StopChannels(-1, -1); | |
1954 //v10 = hAILRedbook; | |
1955 bPlayerReady = true; | |
1956 if ( hAILRedbook ) | |
1957 { | |
1958 AIL_redbook_stop(hAILRedbook); | |
1959 uNumRedbookTracks = AIL_redbook_tracks(hAILRedbook); | |
1960 } | |
1961 pAudioPlayer->sRedbookVolume = AIL_redbook_volume(hAILRedbook); | |
328 | 1962 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); |
0 | 1963 if ( bPlayerReady && hAILRedbook ) |
328 | 1964 AIL_redbook_set_volume(hAILRedbook, (unsigned __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f) >> 32); |
0 | 1965 LoadAudioSnd(); |
1966 } | |
1967 | |
1968 //----- (004ABAF7) -------------------------------------------------------- | |
1969 _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void) | |
1970 { | |
1971 int v0; // ecx@1 | |
1972 unsigned int v1; // ebp@2 | |
1973 size_t v2; // eax@4 | |
1974 signed int v3; // kr14_4@9 | |
1975 char *v5; // [sp+10h] [bp-Ch]@2 | |
1976 unsigned int v6; // [sp+14h] [bp-8h]@1 | |
1977 _DIG_DRIVER *hDrv; // [sp+18h] [bp-4h]@3 | |
1978 | |
1979 static int dword_4F00DC = 22050; | |
1980 static int dword_4F00E0 = 16; | |
1981 static int dword_4F00E4 = 2; | |
1982 | |
1983 AIL_set_preference(15, 0); | |
1984 AIL_set_preference(33, 1); | |
1985 v0 = dword_4F00DC; | |
1986 pAudioPlayer->pDeviceNames[0][0] = 0; | |
1987 pAudioPlayer->uNumDevices = 0; | |
1988 v6 = 0; | |
1989 | |
1990 if ( dword_4F00DC < 11025 ) | |
1991 return 0; | |
1992 v1 = 0; | |
1993 v5 = (char *)pAudioPlayer->array_000BF0; | |
1994 while ( 1 ) | |
1995 { | |
1996 while ( 1 ) | |
1997 { | |
1998 pcmWaveFormat.wf.wFormatTag = 1; | |
1999 pcmWaveFormat.wf.nChannels = dword_4F00E4; | |
2000 pcmWaveFormat.wf.nSamplesPerSec = v0; | |
2001 pcmWaveFormat.wf.nBlockAlign = dword_4F00E4 * dword_4F00E0 / 8; | |
2002 pcmWaveFormat.wBitsPerSample = dword_4F00E0; | |
2003 pcmWaveFormat.wf.nAvgBytesPerSec = v0 * dword_4F00E4 * dword_4F00E0 / 8; | |
2004 if ( !AIL_waveOutOpen(&hDrv, 0, -1, &pcmWaveFormat.wf) ) | |
2005 break; | |
2006 if ( !AIL_get_preference(15) ) | |
2007 goto LABEL_8; | |
2008 v3 = dword_4F00DC; | |
2009 v0 = dword_4F00DC / 2; | |
2010 dword_4F00DC /= 2; | |
2011 if ( v3 / 2 < 11025 ) | |
2012 { | |
2013 if ( dword_4F00E0 == 8 ) | |
2014 { | |
2015 v0 = 22050; | |
2016 dword_4F00E0 = 8; | |
2017 dword_4F00DC = 22050; | |
2018 } | |
2019 goto LABEL_12; | |
2020 } | |
2021 } | |
2022 strcpy(pAudioPlayer->pDeviceNames[v1 / 8], "Device: "); | |
2023 v2 = strlen(pAudioPlayer->pDeviceNames[v1 / 8]); | |
2024 AIL_digital_configuration(hDrv, (int *)v5, (int *)(v5 + 64), (char *)pAudioPlayer->pDeviceNames + v2 + v1 * 16); | |
2025 ++v6; | |
2026 v1 += 8; | |
2027 v5 += 4; | |
2028 pAudioPlayer->uNumDevices = v6; | |
2029 if ( AIL_get_preference(15) ) | |
2030 return hDrv; | |
2031 if ( !strstr(pAudioPlayer->pDeviceNames[v1 / 8 - 1], "Emulated") ) | |
2032 return hDrv; | |
2033 AIL_waveOutClose(hDrv); | |
2034 AIL_set_preference(15, 1); | |
2035 LABEL_8: | |
2036 AIL_set_preference(15, 1); | |
2037 v0 = dword_4F00DC; | |
2038 LABEL_12: | |
2039 if ( v0 < 11025 ) | |
2040 return 0; | |
2041 } | |
2042 } | |
2043 | |
2044 //----- (004ABC9B) -------------------------------------------------------- | |
2045 LSTATUS AudioPlayer::CheckA3DSupport(char a2) | |
2046 { | |
2047 LSTATUS result; // eax@1 | |
2048 DWORD cbData; // [sp+8h] [bp-Ch]@1 | |
2049 int Data; // [sp+Ch] [bp-8h]@1 | |
2050 HKEY hKey; // [sp+10h] [bp-4h]@1 | |
2051 char v6; // [sp+1Ch] [bp+8h]@0 | |
222 | 2052 v6=0; //to fix |
0 | 2053 hKey = 0; |
2054 cbData = 4; | |
2055 Data = 0; | |
2056 result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Aureal\\A3D", 0, 0x2001Fu, &hKey); | |
2057 if ( !result ) | |
2058 { | |
2059 if ( v6 ) | |
2060 RegQueryValueExA(hKey, "SplashAudio", 0, 0, (LPBYTE)&Aureal3D_SplashAudio, &cbData); | |
2061 else | |
2062 Data = Aureal3D_SplashAudio; | |
2063 RegSetValueExA(hKey, "SplashAudio", 0, 4u, (const BYTE *)&Data, 4u); | |
2064 Data = 0; | |
2065 if ( v6 ) | |
2066 RegQueryValueExA(hKey, "SplashScreen", 0, 0, (LPBYTE)&Aureal3D_SplashScreen, &cbData); | |
2067 else | |
2068 Data = Aureal3D_SplashScreen; | |
2069 RegSetValueExA(hKey, "SplashScreen", 0, 4u, (const BYTE *)&Data, 4u); | |
2070 result = RegCloseKey(hKey); | |
2071 } | |
2072 return result; | |
2073 } | |
2074 // 4ABC9B: inconsistent function type and number of purged bytes | |
2075 | |
2076 //----- (004ABD5B) -------------------------------------------------------- | |
4 | 2077 void AudioPlayer::Release() // |
0 | 2078 { |
4 | 2079 MixerChannel *pMixerChannel; // ebx@3 |
0 | 2080 char v4; // dl@5 |
4 | 2081 AudioPlayer_3DSample *p3DSample; // edi@7 |
0 | 2082 void *v9; // ecx@15 |
2083 | |
2084 if ( this->bPlayerReady ) | |
2085 { | |
2086 CloseHandle(pVideoPlayer->hMagicVid); | |
2087 CloseHandle(pVideoPlayer->hMightVid); | |
4 | 2088 pAudioPlayer->StopChannels(-1, -1); |
2089 if ( pAudioPlayer->uMixerChannels > 0 ) | |
0 | 2090 { |
4 | 2091 pMixerChannel = pAudioPlayer->pMixerChannels; |
1408 | 2092 for ( uint i = 0; i < pAudioPlayer->uMixerChannels; ++i ) |
0 | 2093 { |
4 | 2094 AIL_release_sample_handle(pMixerChannel->hSample); |
2095 ++pMixerChannel; | |
0 | 2096 } |
2097 } | |
2098 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 ) | |
2099 { | |
24 | 2100 pAudioPlayer->CheckA3DSupport(0);// pAudioPlayer->CheckA3DSupport(v4); |
4 | 2101 if ( pAudioPlayer->uNum3DSamples > 0 ) |
0 | 2102 { |
4 | 2103 p3DSample = pAudioPlayer->p3DSamples; |
1408 | 2104 for ( uint i = 0; i < pAudioPlayer->uNum3DSamples; ++i ) |
0 | 2105 { |
4 | 2106 if ( p3DSample->hSample ) |
0 | 2107 { |
4 | 2108 AIL_release_3D_sample_handle(p3DSample->hSample); |
2109 p3DSample->hSample = 0; | |
0 | 2110 } |
4 | 2111 ++p3DSample; |
0 | 2112 } |
2113 } | |
4 | 2114 if ( pAudioPlayer->h3DSoundProvider ) |
0 | 2115 { |
4 | 2116 AIL_close_3D_provider(pAudioPlayer->h3DSoundProvider); |
2117 pAudioPlayer->h3DSoundProvider = 0; | |
0 | 2118 } |
2119 } | |
4 | 2120 if ( pAudioPlayer->hAILRedbook ) |
0 | 2121 { |
4 | 2122 AIL_redbook_stop(pAudioPlayer->hAILRedbook); |
1408 | 2123 AIL_redbook_set_volume((HREDBOOK)&pAudioPlayer->hAILRedbook, pAudioPlayer->sRedbookVolume); |
4 | 2124 AIL_redbook_close(pAudioPlayer->hAILRedbook); |
0 | 2125 } |
2126 AIL_shutdown(); | |
2127 pSoundList->Release(); | |
4 | 2128 v9 = *(void **)&pAudioPlayer->field_C78[0]; |
0 | 2129 if ( v9 ) |
2130 ReleaseSoundData(v9); | |
4 | 2131 CloseHandle(pAudioPlayer->hAudioSnd); |
0 | 2132 } |
2133 } | |
2134 | |
2135 //----- (004ABE55) -------------------------------------------------------- | |
764 | 2136 void AudioPlayer::FreeChannel(MixerChannel *pChannel) |
0 | 2137 { |
1408 | 2138 //int v2; // ebx@1 |
0 | 2139 //AudioPlayer *v3; // esi@1 |
1408 | 2140 //SoundDesc *v4; // eax@2 |
0 | 2141 unsigned __int8 v5; // zf@5 |
1408 | 2142 //unsigned __int8 v6; // sf@5 |
2143 //char *v7; // edi@6 | |
764 | 2144 int num_same_sound_on_channels; // eax@8 |
1408 | 2145 //int v9; // ST04_4@8 |
0 | 2146 int v10; // ecx@12 |
2147 int v11; // edi@13 | |
2148 int v12; // eax@13 | |
1408 | 2149 //unsigned __int8 v13; // of@13 |
0 | 2150 int v14[16]; // [sp+Ch] [bp-48h]@8 |
764 | 2151 int num_playing_channels; // [sp+4Ch] [bp-8h]@5 |
1408 | 2152 //int v16; // [sp+50h] [bp-4h]@5 |
0 | 2153 |
390 | 2154 if (!pSoundList->pSounds) |
2155 return; | |
2156 | |
1408 | 2157 //v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx]; |
764 | 2158 if ( pSoundList->pSounds[pChannel->uSourceTrackIdx].eType == SOUND_DESC_SWAP) |
0 | 2159 { |
764 | 2160 if ( pSoundList->pSounds[pChannel->uSourceTrackIdx].pSoundData[0] && |
2161 !(pSoundList->pSounds[pChannel->uSourceTrackIdx].uFlags & SOUND_DESC_SYSTEM) ) | |
0 | 2162 { |
764 | 2163 num_playing_channels = 0; |
2164 num_same_sound_on_channels = 0; | |
1408 | 2165 if ( this->uMixerChannels <= 0 ) |
0 | 2166 goto LABEL_16; |
1408 | 2167 for ( uint i = 0; i < uMixerChannels; i++ ) |
0 | 2168 { |
1408 | 2169 if ( pChannel->uSourceTrackID == pMixerChannels[i].uSourceTrackID ) |
0 | 2170 { |
1408 | 2171 v14[num_same_sound_on_channels++] = i; |
2172 if ( AIL_sample_status((HSAMPLE)pMixerChannels[i].hSample) == AIL::Sample::Playing) | |
764 | 2173 ++num_playing_channels; |
0 | 2174 } |
2175 } | |
764 | 2176 if ( !num_playing_channels ) |
0 | 2177 { |
2178 LABEL_16: | |
764 | 2179 pSoundList->UnloadSound(pChannel->uSourceTrackIdx, 1); |
0 | 2180 v10 = 0; |
764 | 2181 if ( num_same_sound_on_channels > 0 ) |
0 | 2182 { |
2183 do | |
2184 { | |
2185 v11 = v14[v10]; | |
1265 | 2186 v12 = 16 * (v14[v10++] + 47); |
0 | 2187 pMixerChannels[v11].uSourceTrackID = 0; |
1408 | 2188 //v13 = __OFSUB__(v10, num_same_sound_on_channels); |
2189 //v6 = v10 - num_same_sound_on_channels < 0; | |
1265 | 2190 *(unsigned int *)((char *)&bEAXSupported + v12) = 0; |
0 | 2191 } |
1408 | 2192 while (v10 < num_same_sound_on_channels); |
0 | 2193 } |
2194 } | |
2195 } | |
2196 } | |
2197 } | |
2198 | |
2199 //----- (004ABF23) -------------------------------------------------------- | |
2200 void AudioPlayer::_4ABF23(AudioPlayer_3DSample *a2) | |
2201 { | |
2202 int v2; // ebx@1 | |
2203 //AudioPlayer *v3; // esi@1 | |
2204 SoundDesc *v4; // eax@2 | |
2205 unsigned __int8 v5; // zf@5 | |
2206 unsigned __int8 v6; // sf@5 | |
2207 char *v7; // edi@6 | |
2208 int v8; // eax@8 | |
2209 int v9; // ST04_4@8 | |
2210 int v10; // ecx@12 | |
2211 int v11; // eax@13 | |
2212 unsigned __int8 v12; // of@13 | |
2213 int v13[16]; // [sp+Ch] [bp-48h]@8 | |
2214 int v14; // [sp+4Ch] [bp-8h]@5 | |
2215 int v15; // [sp+50h] [bp-4h]@5 | |
2216 | |
2217 v2 = 0; | |
2218 //v3 = this; | |
2219 if ( pSoundList->pSounds ) | |
2220 { | |
2221 v4 = &pSoundList->pSounds[a2->field_8]; | |
2222 if ( v4->eType == SOUND_DESC_SWAP) | |
2223 { | |
592 | 2224 if ( v4->p3DSound && !(v4->uFlags & SOUND_DESC_SYSTEM) ) |
0 | 2225 { |
2226 v5 = this->uNum3DSamples == 0; | |
2227 v6 = this->uNum3DSamples < 0; | |
2228 v14 = 0; | |
2229 v15 = 0; | |
2230 if ( v6 | v5 ) | |
2231 goto LABEL_16; | |
2232 v7 = (char *)this->p3DSamples; | |
2233 do | |
2234 { | |
2235 if ( a2->field_C == *((int *)v7 + 3) ) | |
2236 { | |
2237 v8 = v15; | |
2238 v9 = *(int *)v7; | |
2239 ++v15; | |
2240 v13[v8] = v2; | |
2241 if ( AIL_3D_sample_status((void *)v9) == 4 ) | |
2242 ++v14; | |
2243 } | |
2244 ++v2; | |
2245 v7 += 16; | |
2246 } | |
2247 while ( v2 < uNum3DSamples ); | |
2248 if ( !v14 ) | |
2249 { | |
2250 LABEL_16: | |
764 | 2251 pSoundList->UnloadSound(a2->field_8, 1); |
0 | 2252 v10 = 0; |
2253 if ( v15 > 0 ) | |
2254 { | |
2255 do | |
2256 { | |
2257 v11 = v13[v10++]; | |
2258 *(&bEAXSupported + 4 * (v11 + 2)) = 0; | |
2259 v12 = __OFSUB__(v10, v15); | |
2260 v6 = v10 - v15 < 0; | |
2261 p3DSamples[v11].field_8 = 0; | |
2262 } | |
2263 while ( v6 ^ v12 ); | |
2264 } | |
2265 } | |
2266 } | |
2267 } | |
2268 } | |
2269 } | |
2270 // 4D82F4: using guessed type int __stdcall AIL_3D_sample_status(int); | |
2271 // 4ABF23: using guessed type int var_48[16]; | |
2272 | |
2273 //----- (004ABFDB) -------------------------------------------------------- | |
2274 void __cdecl PlayLevelMusic() | |
2275 { | |
2276 unsigned int v0; // eax@1 | |
2277 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
2278 v0 = pMapStats->GetMapInfo(pCurrentMapName.data()); |
0 | 2279 if ( v0 ) |
2280 pAudioPlayer->PlayMusicTrack((MusicID)pMapStats->pInfos[v0].uRedbookTrackID); | |
2281 } | |
2282 | |
2283 //----- (004AC004) -------------------------------------------------------- | |
2284 void AudioPlayer::SetEAXPreferences() | |
2285 { | |
2286 float v4; // [sp+4h] [bp-4h]@2 | |
2287 | |
2288 if ( this->bEAXSupported ) | |
2289 { | |
2290 v4 = 0.0; | |
1408 | 2291 AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX effect volume", (int *)&v4); |
0 | 2292 v4 = 1.0; |
1408 | 2293 AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX damping", (int *)&v4); |
0 | 2294 } |
2295 } | |
2296 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int); | |
2297 | |
2298 //----- (004AC041) -------------------------------------------------------- | |
2299 void AudioPlayer::SetMapEAX() | |
2300 { | |
1408 | 2301 unsigned int pMapID; // eax@1 |
0 | 2302 int v3; // [sp+4h] [bp-4h]@3 |
2303 | |
1408 | 2304 pMapID = pMapStats->GetMapInfo(pCurrentMapName.data()); |
2305 if ( this->b3DSoundInitialized && this->bEAXSupported ) | |
0 | 2306 { |
1408 | 2307 v3 = pMapStats->pInfos[pMapID].uEAXEnv; |
0 | 2308 if ( (unsigned int)v3 >= 0x1A ) |
2309 { | |
2310 SetEAXPreferences(); | |
1408 | 2311 this->field_214 = -1; |
0 | 2312 } |
2313 else | |
2314 { | |
1408 | 2315 AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX environment selection", &v3); |
2316 this->field_214 = v3; | |
0 | 2317 } |
2318 } | |
2319 } | |
2320 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int); | |
2321 | |
2322 //----- (004AC0A2) -------------------------------------------------------- | |
2323 int AudioPlayer::_4AC0A2() | |
2324 { | |
2325 AudioPlayer *v1; // esi@1 | |
2326 unsigned int v2; // eax@1 | |
2327 char v3; // zf@1 | |
2328 int v4; // ebx@1 | |
2329 int *v5; // edi@2 | |
2330 int v6; // eax@4 | |
2331 AudioPlayer_3DSample *v8; // ebx@7 | |
2332 void *v9; // eax@8 | |
2333 int v10; // ebx@14 | |
2334 unsigned int v11; // eax@14 | |
2335 int v12; // [sp+1Ch] [bp-8h]@1 | |
2336 int v13; // [sp+20h] [bp-4h]@6 | |
2337 | |
2338 v1 = this; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
2339 v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); |
0 | 2340 v3 = v1->b3DSoundInitialized == 0; |
2341 v4 = v2; | |
2342 v12 = v2; | |
2343 if ( !v3 ) | |
2344 { | |
2345 v5 = &v1->uNum3DSamples; | |
2346 AIL_3D_provider_attribute(v1->h3DSoundProvider, "Maximum supported samples", &v1->uNum3DSamples); | |
2347 if ( v1->uNum3DSamples > 32 ) | |
2348 *v5 = 32; | |
2349 v6 = *v5; | |
2350 if ( !*v5 ) | |
2351 { | |
2352 v1->b3DSoundInitialized = 0; | |
2353 return -1; | |
2354 } | |
2355 v13 = 0; | |
2356 if ( v6 > 0 ) | |
2357 { | |
2358 v8 = v1->p3DSamples; | |
2359 while ( 1 ) | |
2360 { | |
2361 v9 = (void *)AIL_allocate_3D_sample_handle(v1->h3DSoundProvider); | |
2362 v8->hSample = v9; | |
2363 if ( !v9 ) | |
2364 break; | |
2365 AIL_set_3D_sample_float_distances(v9, 4096.0, 256.0, 4096.0, 256.0); | |
2366 AIL_set_3D_sample_volume(v8->hSample, v1->s3DSoundVolume); | |
2367 ++v13; | |
2368 ++v8; | |
2369 if ( v13 >= *v5 ) | |
2370 goto LABEL_12; | |
2371 } | |
2372 *v5 = v13; | |
2373 LABEL_12: | |
2374 v4 = v12; | |
2375 } | |
2376 if ( v1->bEAXSupported ) | |
2377 { | |
2378 v10 = v4; | |
2379 v11 = pMapStats->pInfos[v10].uEAXEnv; | |
2380 v12 = pMapStats->pInfos[v10].uEAXEnv; | |
2381 if ( v11 >= 0x1A ) | |
2382 { | |
2383 pAudioPlayer->SetEAXPreferences(); | |
2384 v1->field_214 = -1; | |
2385 } | |
2386 else | |
2387 { | |
2388 AIL_set_3D_provider_preference(v1->h3DSoundProvider, "EAX environment selection", &v12); | |
2389 v1->field_214 = v12; | |
2390 } | |
2391 } | |
2392 } | |
2393 return 1; | |
2394 } | |
2395 | |
2396 //----- (004A96BE) -------------------------------------------------------- | |
2397 void ReleaseSoundData(void *_this) | |
2398 { | |
1408 | 2399 for ( uint i = 0; (void *)&pSounds[i].pSoundData < (void *)&pSounds[2999].pSoundData; i++ ) |
0 | 2400 { |
1408 | 2401 if ( pSounds[i].pSoundData == _this ) |
2402 { | |
2403 pAllocator->FreeChunk(_this); | |
2404 memset(&pSounds[i], 0, 0x80u); | |
2405 } | |
0 | 2406 } |
1408 | 2407 |
0 | 2408 } |
2409 | |
2410 //----- (004A96FF) -------------------------------------------------------- | |
1408 | 2411 struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName) |
0 | 2412 { |
1408 | 2413 /* SoundHeader *result; // eax@2 |
2414 SoundHeader *pSound; | |
0 | 2415 signed int v6; // ebx@11 |
2416 | |
2417 while ( 1 ) | |
2418 { | |
1408 | 2419 v6 = uEnd - uStart; |
2420 pSound = &pAudioPlayer->pSoundHeaders[v6 / 2 + uStart]; | |
2421 if ( !pSound ) | |
2422 return false; | |
2423 result = (SoundHeader *)_stricmp(pName, pSound->pSoundName); | |
2424 if ( !_stricmp(pName, pSound->pSoundName) ) | |
2425 uFindSound_BinSearch_ResultID = v6 / 2 + uStart; | |
2426 if ( uStart == uEnd ) | |
0 | 2427 { |
2428 uFindSound_BinSearch_ResultID = -1; | |
2429 return result; | |
2430 } | |
1408 | 2431 if ( (signed int)result < 0 ) |
2432 break; | |
2433 | |
2434 if ( v6 <= 4 ) | |
2435 { | |
2436 if ( (signed int)uStart < (signed int)uEnd ) | |
2437 { | |
2438 for ( uint i = uStart; i < (signed int)uEnd; ++i ) | |
2439 { | |
2440 if ( !_stricmp(pName, pAudioPlayer->pSoundHeaders[i].pSoundName) ) | |
2441 { | |
2442 uFindSound_BinSearch_ResultID = i; | |
2443 return &pAudioPlayer->pSoundHeaders[i]; | |
2444 } | |
2445 } | |
2446 } | |
2447 uFindSound_BinSearch_ResultID = -1; | |
2448 return false; | |
2449 } | |
2450 | |
2451 uStart += v6 / 2; | |
0 | 2452 LABEL_10: |
1408 | 2453 ; |
0 | 2454 } |
2455 if ( v6 > 4 ) | |
2456 { | |
1408 | 2457 uEnd = v6 / 2 + uStart; |
0 | 2458 goto LABEL_10; |
2459 } | |
1408 | 2460 if ( (signed int)uStart >= (signed int)uEnd ) |
2461 { | |
2462 uFindSound_BinSearch_ResultID = -1; | |
2463 return false; | |
2464 }*/ | |
2465 for ( uint i = uStart; i < (signed int)uEnd; ++i ) | |
0 | 2466 { |
1408 | 2467 if ( !_stricmp(pName, pAudioPlayer->pSoundHeaders[i].pSoundName) ) |
2468 { | |
2469 uFindSound_BinSearch_ResultID = i; | |
2470 return &pAudioPlayer->pSoundHeaders[i]; | |
2471 } | |
0 | 2472 } |
1408 | 2473 uFindSound_BinSearch_ResultID = -1; |
2474 return false; | |
0 | 2475 } |
2476 // F1B4C8: using guessed type int uFindSound_BinSearch_ResultID; | |
2477 | |
2478 //----- (004A97C6) -------------------------------------------------------- | |
2479 SoundData *LoadSound(const char *pSoundName, SoundData *pOutBuff, unsigned int uID) | |
2480 { | |
2481 DWORD NumberOfBytesRead; // [sp+14h] [bp-8h]@8 | |
2482 | |
2483 for (uint i = 0; i < 3000; ++i) | |
24 | 2484 { |
1408 | 2485 if (pSounds[i].uID == uID) |
2486 return pSounds[i].pSoundData; | |
24 | 2487 } |
1408 | 2488 FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName); |
2489 if ( uFindSound_BinSearch_ResultID == -1 ) | |
2490 return 0; | |
2491 if ( pOutBuff == (SoundData *)-1 ) | |
2492 pOutBuff = (SoundData *)pAllocator->AllocNamedChunk(0, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize + 4, pSoundName); | |
2493 SetFilePointer(pAudioPlayer->hAudioSnd, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uFileOffset, 0, 0); | |
2494 if ( (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize >= (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize ) | |
0 | 2495 { |
1408 | 2496 pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize = pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize; |
2497 if ( pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize ) | |
0 | 2498 { |
1408 | 2499 ReadFile(pAudioPlayer->hAudioSnd, (char *)pOutBuff + 4, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize, &NumberOfBytesRead, 0); |
0 | 2500 } |
2501 else | |
2502 { | |
2503 MessageBoxW(nullptr, L"Can't load sound file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Sound.cpp:448", 0); | |
2504 } | |
2505 } | |
2506 else | |
2507 { | |
1408 | 2508 uID = (unsigned int)malloc(pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize); |
2509 ReadFile(pAudioPlayer->hAudioSnd, (LPVOID)uID, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize, &NumberOfBytesRead, 0); | |
2510 zlib::MemUnzip((char *)pOutBuff + 4, &pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize, (const void *)uID, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize); | |
0 | 2511 free((void *)uID); |
2512 } | |
1408 | 2513 if ( pOutBuff ) |
0 | 2514 { |
1408 | 2515 *(int *)pOutBuff = pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize; |
0 | 2516 uLastLoadedSoundID = 0; |
2517 if ( pSounds[0].pSoundData ) | |
2518 { | |
1408 | 2519 for ( uint i = 0; pSounds[i].pSoundData; i++ ) |
2520 ++uLastLoadedSoundID; | |
0 | 2521 } |
1408 | 2522 strcpy((char *)pSounds[uLastLoadedSoundID].SoundName, pSoundName); |
2523 pSoundList->uTotalLoadedSoundSize += pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize; | |
2524 pSounds[uLastLoadedSoundID].pSoundData = pOutBuff; | |
2525 return pOutBuff; | |
0 | 2526 } |
2527 else | |
1408 | 2528 return 0; |
0 | 2529 } |