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