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