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