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