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