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);
|
|
93 // pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID); Ritor1: it's error - result: no sound
|
|
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
|
24
|
740 uVolume = 120; //Ritor1:It's temporary
|
0
|
741 pAudioPlayer = this;
|
|
742 v35 = this->bPlayerReady == 0;
|
|
743 //pAudioPlayer = this;
|
|
744 pRenderVertexSoft.flt_2C = 0.0;
|
|
745 LODWORD(v93) = 10000;
|
|
746 if ( v35 || !uSoundVolumeMultiplier || !this->hDigDriver || !eSoundID )
|
|
747 return;
|
|
748 pNum = 0;
|
|
749 if ( (signed int)pSoundList->uNumSounds <= 0 )
|
|
750 {
|
|
751 LABEL_9:
|
|
752 pNum = 0;
|
|
753 }
|
|
754 else
|
|
755 {
|
|
756 pSoundID = (int *)&pSoundList->pSounds->uSoundID;
|
|
757 while ( *pSoundID != eSoundID )
|
|
758 {
|
|
759 ++pNum;
|
|
760 pSoundID += 30;
|
|
761 if ( pNum >= (signed int)pSoundList->uNumSounds )
|
|
762 goto LABEL_9;
|
|
763 }
|
|
764 }
|
|
765 /* v92 = pNum;//38
|
|
766 pNum = 0;
|
|
767 for ( pSoundID = (int *)&pSoundList->pSounds->uSoundID; *pSoundID != eSoundID; pSoundID += 30)
|
|
768 {
|
|
769 ++pNum;
|
|
770 }*/
|
|
771 if ( !pNum )
|
|
772 return;
|
|
773 if ( !pAudioPlayer->b3DSoundInitialized || (v89 = 120 * pNum, !(pSoundList->pSounds[pNum].uFlags & 2)) )
|
|
774 {
|
|
775 //pSoundDesc = (SoundDesc *)7;
|
|
776 if ( a3 < 0 )
|
|
777 {
|
|
778 if ( a3 == -1 )
|
|
779 {
|
|
780 varC = 13;
|
|
781 v96 = 13;
|
|
782 goto LABEL_133;
|
|
783 }
|
|
784 varC = 14;
|
|
785 v96 = 14;
|
|
786 LABEL_123:
|
|
787 if ( a3 )
|
|
788 {
|
|
789 if ( a3 != -1 )
|
|
790 {
|
|
791 LODWORD(v91) = 0;
|
|
792 if ( pAudioPlayer->uMixerChannels > 0 )
|
|
793 {
|
|
794 pMixerChannel = pAudioPlayer->pMixerChannels;
|
|
795 do
|
|
796 {
|
|
797 if ( AIL_sample_status(pMixerChannel->hSample) == 4 && pMixerChannel->dword_000004 == a3
|
|
798 && AIL_sample_status(pMixerChannel->hSample) == 4 )
|
|
799 {
|
|
800 if ( pMixerChannel->uSourceTrackIdx == pNum )
|
|
801 return;
|
|
802 AIL_end_sample(pMixerChannel->hSample);
|
|
803 _4ABE55(pMixerChannel);
|
|
804 }
|
|
805 ++LODWORD(v91);
|
|
806 ++pMixerChannel;
|
|
807 }
|
|
808 while ( SLODWORD(v91) < pAudioPlayer->uMixerChannels );
|
|
809 }
|
|
810 }
|
|
811 }
|
|
812 LABEL_133:
|
|
813 v62 = varC;
|
|
814 //pAudioPlayer4 = pAudioPlayer;
|
|
815 if ( varC <= v96 )
|
|
816 {
|
|
817 pMixerChannel2 = &pAudioPlayer->pMixerChannels[varC];
|
|
818 while ( AIL_sample_status(pMixerChannel2->hSample) != 2 )
|
|
819 {
|
|
820 ++v62;
|
|
821 ++pMixerChannel2;
|
|
822 if ( v62 > v96 )
|
|
823 goto LABEL_140;
|
|
824 }
|
|
825 AIL_end_sample(pMixerChannel2->hSample);
|
|
826 if ( pMixerChannel2->uSourceTrackIdx )
|
|
827 _4ABE55(pMixerChannel2);
|
|
828 }
|
|
829 LABEL_140:
|
|
830 if ( v62 != v96 + 1 )//10!=13
|
|
831 {
|
|
832 LABEL_150:
|
|
833 if ( LODWORD(v93) == 10000 )
|
|
834 LODWORD(v93) = pAudioPlayer->uMasterVolume;
|
|
835 v70 = 0;
|
|
836 if ( !a7 )
|
|
837 {
|
|
838 //pSoundDesc = pSoundList->pSounds;
|
|
839 pSoundDesc2 = &pSoundList->pSounds[pNum];
|
|
840 if ( !pSoundDesc2->pSoundData[0] )
|
|
841 {
|
|
842 if (pSoundDesc2->eType == SOUND_DESC_SWAP)
|
|
843 pSoundList->LoadSound(eSoundID, 0);
|
|
844 }
|
|
845 }
|
|
846 v72 = 4 * (a7 + 30 * pNum) + 44;
|
|
847 if ( !*(int *)&pSoundList->pSounds->pSoundName[v72] )
|
|
848 return;
|
|
849 pMixerChannel5 = &pAudioPlayer->pMixerChannels[v62];
|
|
850 AIL_init_sample(pMixerChannel5->hSample);
|
|
851 AIL_set_sample_file(pMixerChannel5->hSample, (void *)(*(int *)&pSoundList->pSounds->pSoundName[v72] + 4 * (a7 == 0)), -1);
|
|
852 pVolume = uVolume;
|
|
853 if ( !uVolume )
|
|
854 pVolume = LODWORD(v93);
|
|
855 AIL_set_sample_volume(pMixerChannel5->hSample, pVolume);
|
|
856 pPartyX = PartyX;
|
|
857 if ( PartyX != -1 )
|
|
858 {
|
|
859 if ( !PartyX )
|
|
860 pPartyX = pParty->vPosition.x;
|
|
861 if ( !PartyY )
|
|
862 PartyY = pParty->vPosition.y;
|
|
863 if ( uNumRepeats )
|
|
864 AIL_set_sample_loop_count(pMixerChannel5->hSample, uNumRepeats - 1);
|
|
865 v83 = sub_4AB66C(pPartyX, PartyY);
|
|
866 AIL_set_sample_pan(pMixerChannel5->hSample, v83);
|
|
867 v84 = GetSoundStrengthByDistanceFromParty(pPartyX, PartyY, pParty->vPosition.z);
|
|
868 AIL_set_sample_volume(pMixerChannel5->hSample, v84);
|
|
869 v76 = a3;
|
|
870 goto LABEL_184;
|
|
871 }
|
|
872 v76 = a3;
|
|
873 if ( (a3 & 7) == 1 )
|
|
874 {
|
|
875 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
|
|
876 goto LABEL_184;
|
|
877 pBLVDoor2 = &pIndoor->pDoors[a3 >> 3];
|
|
878 if ( !pBLVDoor2->uDoorID )
|
|
879 return;
|
|
880 if ( !GetSoundStrengthByDistanceFromParty(*pBLVDoor2->pXOffsets, *pBLVDoor2->pYOffsets, *pBLVDoor2->pZOffsets) )
|
|
881 {
|
|
882 AIL_end_sample(pMixerChannel5->hSample);
|
|
883 pAudioPlayer->AudioPlayer::_4ABE55(pMixerChannel5);
|
|
884 return;
|
|
885 }
|
|
886 pPosY = *pBLVDoor2->pYOffsets;
|
|
887 pPosX = *pBLVDoor2->pXOffsets;
|
|
888 //goto LABEL_167;
|
|
889 v80 = sub_4AB66C(pPosX, pPosY);
|
|
890 AIL_set_sample_pan(pMixerChannel5->hSample, v80);
|
|
891 goto LABEL_184;
|
|
892 }
|
|
893 if ( (a3 & 7) == 2 )
|
|
894 {
|
|
895 pLayingItem4 = &pLayingItems[a3 >> 3];
|
|
896 if ( !GetSoundStrengthByDistanceFromParty(pLayingItem4->vPosition.x, pLayingItem4->vPosition.y, pLayingItem4->vPosition.z) )
|
|
897 return;
|
|
898 }
|
|
899 else
|
|
900 {
|
|
901 if ( (a3 & 7) == 3 )
|
|
902 {
|
|
903 pActor3 = &pActors[a3 >> 3];
|
|
904 if ( !GetSoundStrengthByDistanceFromParty(pActor3->vPosition.x, pActor3->vPosition.y, pActor3->vPosition.z) )
|
|
905 return;
|
|
906 pPosY = pActor3->vPosition.y;
|
|
907 pPosX = pActor3->vPosition.x;
|
|
908 //goto LABEL_167;
|
|
909 v80 = sub_4AB66C(pPosX, pPosY);
|
|
910 AIL_set_sample_pan(pMixerChannel5->hSample, v80);
|
|
911 goto LABEL_184;
|
|
912 }
|
|
913 if ( (a3 & 7) != 5 )
|
|
914 {
|
|
915 LABEL_184:
|
|
916 if ( uNumRepeats )
|
|
917 AIL_set_sample_loop_count(pMixerChannel5->hSample, uNumRepeats - 1);
|
|
918 v85 = pMixerChannel5->hSample;
|
|
919 pMixerChannel5->uSourceTrackIdx = pNum;
|
|
920 pMixerChannel5->dword_000004 = v76;
|
|
921 pMixerChannel5->uSourceTrackID = eSoundID;
|
|
922 AIL_start_sample(v85);
|
|
923 if ( sPlaybackRate )
|
|
924 AIL_set_sample_playback_rate(pMixerChannel5->hSample, sPlaybackRate);
|
|
925 if ( (v76 & 7) == 4 )
|
|
926 AIL_sample_ms_position(pMixerChannel5->hSample, &sLastTrackLengthMS, 0);
|
|
927 return;
|
|
928 }
|
|
929 pLayingItem4 = (LayingItem *)&pLevelDecorations[a3 >> 3];
|
|
930 if ( !GetSoundStrengthByDistanceFromParty(pLayingItem4->vPosition.x, pLayingItem4->vPosition.y, pLayingItem4->vPosition.z) )
|
|
931 return;
|
|
932 AIL_set_sample_loop_count(pMixerChannel5->hSample, uNumRepeats - 1);
|
|
933 }
|
|
934 pPosY = pLayingItem4->vPosition.y;
|
|
935 pPosX = pLayingItem4->vPosition.x;
|
|
936 //LABEL_167:
|
|
937 v80 = sub_4AB66C(pPosX, pPosY);
|
|
938 AIL_set_sample_pan(pMixerChannel5->hSample, v80);
|
|
939 goto LABEL_184;
|
|
940 }
|
|
941 v65 = varC;
|
|
942 v62 = -1;
|
|
943 v91 = v93;
|
|
944 if ( varC <= v96 )
|
|
945 {
|
|
946 //pAudioPlayer5 = pAudioPlayer;
|
|
947 pMixerChannel3 = &pAudioPlayer->pMixerChannels[varC];
|
|
948 do
|
|
949 {
|
|
950 v68 = AIL_sample_volume(pMixerChannel3->hSample);
|
|
951 if ( v68 < SLODWORD(v91) )
|
|
952 {
|
|
953 LODWORD(v91) = v68;
|
|
954 v62 = v65;
|
|
955 }
|
|
956 ++v65;
|
|
957 ++pMixerChannel3;
|
|
958 }
|
|
959 while ( v65 <= v96 );
|
|
960 if ( v62 != -1 )
|
|
961 {
|
|
962 //LABEL_149:
|
|
963 //pAudioPlayer4 = pAudioPlayer;
|
|
964 pMixerChannel4 = &pAudioPlayer->pMixerChannels[v62];
|
|
965 AIL_end_sample(pMixerChannel4->hSample);
|
|
966 _4ABE55(pMixerChannel4);
|
|
967 goto LABEL_150;
|
|
968 }
|
|
969 v65 = varC;
|
|
970 }
|
|
971 v62 = 13;
|
|
972 if ( v65 != 13 )
|
|
973 return;
|
|
974 //goto LABEL_149;
|
|
975 //pAudioPlayer4 = pAudioPlayer;
|
|
976 pMixerChannel4 = &pAudioPlayer->pMixerChannels[v62];
|
|
977 AIL_end_sample(pMixerChannel4->hSample);
|
|
978 _4ABE55(pMixerChannel4);
|
|
979 goto LABEL_150;
|
|
980 }
|
|
981 if ( (a3 & 7) == 2 )
|
|
982 {
|
|
983 varC = 5;
|
|
984 v96 = 7;
|
|
985 pLayingItem3 = &pLayingItems[a3 >> 3];
|
|
986 }
|
|
987 else
|
|
988 {
|
|
989 if ( (a3 & 7) == 3 )
|
|
990 {
|
|
991 *(float *)&varC = 0.0;
|
|
992 pActor2 = &pActors[a3 >> 3];
|
|
993 v96 = 3;
|
|
994 v58 = pActor2->vPosition.y;
|
|
995 v87 = pActor2->vPosition.z;
|
|
996 v59 = pActor2->vPosition.x;
|
|
997 LABEL_116:
|
|
998 LODWORD(v93) = GetSoundStrengthByDistanceFromParty(v59, /*(int)pSoundDesc*/ v58, v87);
|
|
999 if ( v93 == 0.0 )
|
|
1000 return;
|
|
1001 goto LABEL_123;
|
|
1002 }
|
|
1003 if ( (a3 & 7) != 5 )
|
|
1004 {
|
|
1005 if ( (a3 & 7) == 6 )
|
|
1006 {
|
|
1007 varC = 8;
|
|
1008 v96 = 9;
|
|
1009 }
|
|
1010 else
|
|
1011 {
|
|
1012 varC = 10;
|
|
1013 v96 = 12;
|
|
1014 }
|
|
1015 goto LABEL_123;
|
|
1016 }
|
|
1017 varC = 4;
|
|
1018 v96 = 4;
|
|
1019 pLayingItem3 = (LayingItem *)&pLevelDecorations[a3 >> 3];
|
|
1020 }
|
|
1021 v87 = pLayingItem3->vPosition.z;
|
|
1022 v58 = pLayingItem3->vPosition.y;
|
|
1023 v59 = pLayingItem3->vPosition.x;
|
|
1024 goto LABEL_116;
|
|
1025 }
|
|
1026 v12 = 13;
|
|
1027 if ( a3 < 0 )
|
|
1028 {
|
|
1029 v15 = pAudioPlayer->uNum3DSamples;
|
|
1030 if ( a3 == -1 )
|
|
1031 {
|
|
1032 if ( v15 < 16 )
|
|
1033 v12 = v15 - 1;
|
|
1034 v96 = v12;
|
|
1035 //goto LABEL_46;
|
|
1036 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x;
|
|
1037 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y;
|
|
1038 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
|
|
1039 goto LABEL_47;
|
|
1040 }
|
|
1041 if ( v15 >= 16 )
|
|
1042 v15 = 14;
|
|
1043 v12 = v15;
|
|
1044 //goto LABEL_45;
|
|
1045 v96 = v15;
|
|
1046 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x;
|
|
1047 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y;
|
|
1048 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
|
|
1049 goto LABEL_47;
|
|
1050 }
|
|
1051 if ( (a3 & 7) == 2 )
|
|
1052 {
|
|
1053 v22 = pAudioPlayer->uNum3DSamples;
|
|
1054 if ( v22 < 16 )
|
|
1055 {
|
|
1056 v12 = 5 * v22 / 16;
|
|
1057 v96 = 7 * v22 / 16;
|
|
1058 }
|
|
1059 else
|
|
1060 {
|
|
1061 v96 = 7;
|
|
1062 v12 = 5;
|
|
1063 }
|
|
1064 pLayingItem = &pLayingItems[a3 >> 3];
|
|
1065 }
|
|
1066 else
|
|
1067 {
|
|
1068 if ( (a3 & 7) == 3 )
|
|
1069 {
|
|
1070 v18 = pAudioPlayer->uNum3DSamples;
|
|
1071 v12 = 0;
|
|
1072 if ( v18 < 16 )
|
|
1073 v96 = 3 * v18 / 16;
|
|
1074 else
|
|
1075 v96 = 3;
|
|
1076 pActor1 = &pActors[a3 >> 3];
|
|
1077 v20 = pActor1->vPosition.y;
|
|
1078 pRenderVertexSoft.vWorldPosition.x = (double)pActor1->vPosition.x;
|
|
1079 v100 = pActor1->vPosition.z;
|
|
1080 pRenderVertexSoft.vWorldPosition.y = (double)v20;
|
|
1081 v21 = (double)v100;
|
|
1082 goto LABEL_47;
|
|
1083 }
|
|
1084 if ( (a3 & 7) != 5 )
|
|
1085 {
|
|
1086 v13 = pAudioPlayer->uNum3DSamples;
|
|
1087 if ( (a3 & 7) == 6 )
|
|
1088 {
|
|
1089 if ( v13 >= 16 )
|
|
1090 {
|
|
1091 v96 = 9;
|
|
1092 v12 = 8;
|
|
1093 //goto 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 = 8 * v13 / 16;
|
|
1100 v14 = 9 * v13;
|
|
1101 }
|
|
1102 else
|
|
1103 {
|
|
1104 if ( v13 >= 16 )
|
|
1105 {
|
|
1106 v96 = 12;
|
|
1107 v12 = 10;
|
|
1108 //LABEL_46:
|
|
1109 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x;
|
|
1110 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y;
|
|
1111 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
|
|
1112 goto LABEL_47;
|
|
1113 }
|
|
1114 v12 = 10 * v13 / 16;
|
|
1115 v14 = 12 * v13;
|
|
1116 }
|
|
1117 v15 = v14 / 16;
|
|
1118 //LABEL_45:
|
|
1119 v96 = v15;
|
|
1120 //goto LABEL_46;
|
|
1121 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x;
|
|
1122 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y;
|
|
1123 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
|
|
1124 goto LABEL_47;
|
|
1125 }
|
|
1126 v16 = pAudioPlayer->uNum3DSamples;
|
|
1127 if ( v16 < 16 )
|
|
1128 {
|
|
1129 v12 = v16 / 4;
|
|
1130 v96 = v16 / 4;
|
|
1131 }
|
|
1132 else
|
|
1133 {
|
|
1134 v12 = 4;
|
|
1135 v96 = 4;
|
|
1136 }
|
|
1137 pLayingItem = (LayingItem *)&pLevelDecorations[a3 >> 3];
|
|
1138 }
|
|
1139 pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem->vPosition.x;
|
|
1140 pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem->vPosition.y;
|
|
1141 v21 = (double)pLayingItem->vPosition.z;
|
|
1142 LABEL_47:
|
|
1143 pRenderVertexSoft.vWorldPosition.z = v21;
|
|
1144 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1145 sub_4AAEA6_transform(&pRenderVertexSoft);
|
|
1146 else
|
|
1147 pGame->pIndoorCameraD3D->ViewTransform(&pRenderVertexSoft, 1);
|
|
1148 if ( a3 )
|
|
1149 {
|
|
1150 if ( a3 != -1 )
|
|
1151 {
|
|
1152 v101 = 0;
|
|
1153 if ( pAudioPlayer->uNum3DSamples > 0 )
|
|
1154 {
|
|
1155 pAudioPlayer_3DSample = pAudioPlayer->p3DSamples;
|
|
1156 do
|
|
1157 {
|
|
1158 if ( AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4
|
|
1159 && pAudioPlayer_3DSample->field_4 == a3 && AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4 )
|
|
1160 {
|
|
1161 if ( pAudioPlayer_3DSample->field_8 == pNum )
|
|
1162 return;
|
|
1163 AIL_end_3D_sample(pAudioPlayer_3DSample->hSample);
|
|
1164 pAudioPlayer->_4ABF23(pAudioPlayer_3DSample);
|
|
1165 }
|
|
1166 ++v101;
|
|
1167 ++pAudioPlayer_3DSample;
|
|
1168 }
|
|
1169 while ( v101 < pAudioPlayer->uNum3DSamples );
|
|
1170 }
|
|
1171 }
|
|
1172 }
|
|
1173 v102 = v12;
|
|
1174 if ( v12 <= v96 )
|
|
1175 {
|
|
1176 pAudioPlayer_3DSample1 = &pAudioPlayer->p3DSamples[v12];
|
|
1177 while ( AIL_3D_sample_status(pAudioPlayer_3DSample1->hSample) != 2 )
|
|
1178 {
|
|
1179 ++v102;
|
|
1180 ++pAudioPlayer_3DSample1;
|
|
1181 if ( v102 > v96 )
|
|
1182 goto LABEL_67;
|
|
1183 }
|
|
1184 AIL_end_3D_sample(pAudioPlayer_3DSample1->hSample);
|
|
1185 if ( pAudioPlayer_3DSample1->field_8 )
|
|
1186 pAudioPlayer->_4ABF23(pAudioPlayer_3DSample1);
|
|
1187 }
|
|
1188 LABEL_67:
|
|
1189 v25 = v96;
|
|
1190 if ( v102 == v96 + 1 )
|
|
1191 {
|
|
1192 LODWORD(v91) = -1;
|
|
1193 v103 = 0;
|
|
1194 *(float *)&varC = pRenderVertexSoft.vWorldViewPosition.y * -0.012207031;
|
|
1195 v93 = 0.0;
|
|
1196 v26 = pRenderVertexSoft.vWorldViewPosition.x * 0.012207031;
|
|
1197 *(float *)&uVolume = v26;
|
|
1198 v27 = abs((signed __int64)v26);
|
|
1199 v28 = abs((signed __int64)v93);
|
|
1200 v29 = abs((signed __int64)*(float *)&varC);
|
|
1201 v90 = sub_4621DA(v29, v28, v27);
|
|
1202 sPlaybackRate = v12;
|
|
1203 if ( v12 > v25 )
|
|
1204 goto LABEL_192;
|
|
1205 pAudioPlayer_3DSample2 = &pAudioPlayer->p3DSamples[v12];
|
|
1206 do
|
|
1207 {
|
|
1208 AIL_3D_position(pAudioPlayer_3DSample2->hSample, &varC, &v93, (long *)&uVolume);
|
|
1209 v31 = abs((signed __int64)*(float *)&uVolume);
|
|
1210 v32 = abs((signed __int64)v93);
|
|
1211 v33 = abs((signed __int64)*(float *)&varC);
|
|
1212 v34 = sub_4621DA(v33, v32, v31);
|
|
1213 v35 = v103 == v34;
|
|
1214 if ( v103 < v34 )
|
|
1215 {
|
|
1216 v103 = v34;
|
|
1217 v35 = 1;
|
|
1218 }
|
|
1219 if ( v35 && v90 < v103 )
|
|
1220 {
|
|
1221 v36 = sPlaybackRate;
|
|
1222 LODWORD(v91) = sPlaybackRate;
|
|
1223 }
|
|
1224 else
|
|
1225 {
|
|
1226 v36 = LODWORD(v91);
|
|
1227 }
|
|
1228 ++sPlaybackRate;
|
|
1229 ++pAudioPlayer_3DSample2;
|
|
1230 }
|
|
1231 while ( sPlaybackRate <= v96 );
|
|
1232 if ( v36 == -1 )
|
|
1233 {
|
|
1234 LABEL_192:
|
|
1235 v36 = 13;
|
|
1236 if ( v12 != 13 )
|
|
1237 return;
|
|
1238 }
|
|
1239 //pAudioPlayer2 = pAudioPlayer;
|
|
1240 pAudioPlayer_3DSample3 = &pAudioPlayer->p3DSamples[v36];
|
|
1241 AIL_end_3D_sample(pAudioPlayer_3DSample3->hSample);
|
|
1242 pAudioPlayer->_4ABF23(pAudioPlayer_3DSample3);
|
|
1243 v102 = v36;
|
|
1244 }
|
|
1245 v39 = v89;
|
|
1246 if ( pSoundList->pSounds[v89 / 0x78].p3DSound || (LOWORD(v40) = pSoundList->LoadSound(eSoundID, 0), v40) )
|
|
1247 {
|
|
1248 v41 = (char *)pAudioPlayer + 16 * v102;
|
|
1249 v42 = (int)(v41 + 20);
|
|
1250 if ( AIL_set_3D_sample_file(*((int *)v41 + 5), *(void **)((char *)&pSoundList->pSounds->p3DSound + v39)) )
|
|
1251 {
|
|
1252 if ( uNumRepeats )
|
|
1253 v86 = uNumRepeats - 1;
|
|
1254 else
|
|
1255 v86 = 1;
|
|
1256 AIL_set_3D_sample_loop_count(*(int *)v42, v86);
|
|
1257 if ( PartyX == -1 )
|
|
1258 {
|
|
1259 if ( (a3 & 7) == 1 )
|
|
1260 {
|
|
1261 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1262 {
|
|
1263 //goto LABEL_103;
|
|
1264 pBLVDoor = &pIndoor->pDoors[a3 >> 3];
|
|
1265 if ( !pBLVDoor->uDoorID )
|
|
1266 return;
|
|
1267 pRenderVertexSoft.vWorldPosition.x = (double)*pBLVDoor->pXOffsets;
|
|
1268 pRenderVertexSoft.vWorldPosition.y = (double)*pBLVDoor->pYOffsets;
|
|
1269 v47 = (double)*pBLVDoor->pZOffsets;
|
|
1270 LABEL_101:
|
|
1271 pRenderVertexSoft.vWorldPosition.z = v47;
|
|
1272 //if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1273 //{
|
|
1274 sub_4AAEA6_transform(&pRenderVertexSoft);
|
|
1275 //goto LABEL_104;
|
|
1276 //}
|
|
1277 }
|
|
1278 //LABEL_103:
|
|
1279 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
|
|
1280 pGame->pIndoorCameraD3D->ViewTransform(&pRenderVertexSoft, 1);
|
|
1281 //LABEL_104:
|
|
1282 AIL_start_3D_sample(*(int *)v42);
|
|
1283 AIL_set_3D_sample_float_distances(*(int **)v42, 100.0, 20.0, 100.0, 20.0);
|
|
1284 AIL_set_3D_sample_volume(*(int **)v42, pAudioPlayer->s3DSoundVolume);
|
|
1285 v99 = pRenderVertexSoft.vWorldViewPosition.y * -0.012207031;
|
|
1286 v49 = pRenderVertexSoft.vWorldViewPosition.x * 0.012207031;
|
|
1287 uNumRepeatsa = v49;
|
|
1288 v50 = abs((signed __int64)v49);
|
|
1289 v51 = abs(0);
|
|
1290 v52 = abs((signed __int64)v99);
|
|
1291 if ( sub_4621DA(v52, v51, v50) <= 100 )
|
|
1292 {
|
|
1293 AIL_set_3D_position((void *)*(int *)v42, LODWORD(v99), 0.0, LODWORD(uNumRepeatsa));
|
|
1294 v53 = -uNumRepeatsa;
|
|
1295 v54 = -v99;
|
|
1296 AIL_set_3D_orientation((void *)*(int *)v42, LODWORD(v54), 0.0, LODWORD(v53), 0.0, 1.0, 0.0);
|
|
1297 //pAudioPlayer3 = pAudioPlayer;
|
|
1298 *((int *)v41 + 6) = a3;
|
|
1299 *((int *)v41 + 7) = pNum;
|
|
1300 *(&pAudioPlayer->bEAXSupported + 4 * (v102 + 2)) = eSoundID;
|
|
1301 }
|
|
1302 else
|
|
1303 {
|
|
1304 AIL_end_3D_sample(*(int **)v42);
|
|
1305 pAudioPlayer->_4ABF23((AudioPlayer_3DSample *)(v41 + 20));
|
|
1306 }
|
|
1307 return;
|
|
1308 }
|
|
1309 if ( (a3 & 7) == 2 )
|
|
1310 {
|
|
1311 pLayingItem2 = &pLayingItems[a3 >> 3];
|
|
1312 }
|
|
1313 else
|
|
1314 {
|
|
1315 if ( (a3 & 7) == 3 )
|
|
1316 {
|
|
1317 pActor = &pActors[a3 >> 3];
|
|
1318 v46 = pActor->vPosition.y;
|
|
1319 pRenderVertexSoft.vWorldPosition.x = (double)pActor->vPosition.x;
|
|
1320 uNumRepeatsb = pActor->vPosition.z;
|
|
1321 pRenderVertexSoft.vWorldPosition.y = (double)v46;
|
|
1322 v47 = (double)uNumRepeatsb;
|
|
1323 goto LABEL_101;
|
|
1324 }
|
|
1325 if ( (a3 & 7) != 5 )
|
|
1326 {
|
|
1327 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x;
|
|
1328 v43 = (double)pParty->vPosition.y;
|
|
1329 LABEL_100:
|
|
1330 pRenderVertexSoft.vWorldPosition.y = v43;
|
|
1331 v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
|
|
1332 goto LABEL_101;
|
|
1333 }
|
|
1334 pLayingItem2 = (LayingItem *)&pLevelDecorations[a3 >> 3];
|
|
1335 }
|
|
1336 pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem2->vPosition.x;
|
|
1337 pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem2->vPosition.y;
|
|
1338 v47 = (double)pLayingItem2->vPosition.z;
|
|
1339 goto LABEL_101;
|
|
1340 }
|
|
1341 pRenderVertexSoft.vWorldPosition.x = (double)PartyX;
|
|
1342 v43 = (double)PartyY;
|
|
1343 goto LABEL_100;
|
|
1344 }
|
|
1345 }
|
|
1346 }
|
|
1347
|
|
1348 //----- (0040DEA5) --------------------------------------------------------
|
|
1349 void __cdecl AudioPlayer::MessWithChannels()
|
|
1350 {
|
|
1351 pAudioPlayer->StopChannels(-1, -1);
|
|
1352 }
|
|
1353
|
|
1354
|
|
1355
|
|
1356 //----- (004AAFCF) --------------------------------------------------------
|
|
1357 void AudioPlayer::_4AAFCF()
|
|
1358 {
|
11
|
1359 AudioPlayer *pAudioPlayer; // edi@1
|
0
|
1360 int v2; // ebx@1
|
|
1361 unsigned __int8 v3; // zf@1
|
|
1362 int *v4; // eax@2
|
|
1363 unsigned __int8 v5; // sf@4
|
|
1364 AudioPlayer_3DSample *v6; // esi@5
|
|
1365 int v7; // ebx@6
|
|
1366 int v8; // ebx@9
|
|
1367 int v9; // ebx@10
|
|
1368 int v10; // ebx@11
|
|
1369 double v11; // st7@13
|
|
1370 LayingItem *v12; // eax@14
|
|
1371 Actor *v13; // eax@15
|
|
1372 signed int v14; // edx@15
|
|
1373 BLVDoor *v15; // eax@19
|
|
1374 double v16; // st7@22
|
|
1375 double v17; // st6@22
|
|
1376 double v18; // st5@23
|
|
1377 double v19; // st4@24
|
|
1378 double v20; // st3@24
|
|
1379 double v21; // st6@28
|
|
1380 double v22; // st7@32
|
|
1381 int v23; // ST1C_4@32
|
|
1382 int v24; // ebx@32
|
|
1383 int v25; // eax@32
|
|
1384 float v26; // ST10_4@34
|
|
1385 float v27; // ST08_4@34
|
|
1386 MixerChannel *v28; // esi@38
|
|
1387 unsigned __int8 v29; // of@43
|
|
1388 MixerChannel *v30; // esi@44
|
|
1389 int v31; // eax@45
|
|
1390 LayingItem *v32; // eax@49
|
|
1391 Actor *v33; // edi@50
|
|
1392 int v34; // eax@50
|
|
1393 unsigned int v35; // edx@51
|
|
1394 unsigned int v36; // ecx@51
|
|
1395 LayingItem *v37; // edi@53
|
|
1396 int v38; // eax@53
|
|
1397 BLVDoor *v39; // edi@56
|
|
1398 int v40; // eax@57
|
|
1399 int v41; // eax@60
|
|
1400 MixerChannel *v42; // edi@65
|
|
1401 int v43; // ebx@68
|
|
1402 LevelDecoration *v44; // esi@68
|
|
1403 int v45; // ST1C_4@68
|
|
1404 int v46; // edi@68
|
|
1405 int v47; // eax@68
|
|
1406 DecorationDesc *v48; // edi@69
|
|
1407 __int16 v49; // ax@69
|
|
1408 __int16 v50; // ax@70
|
|
1409 __int16 v51; // ax@71
|
|
1410 __int16 v52; // ax@73
|
|
1411 signed int v53; // eax@88
|
|
1412 RenderVertexSoft a1; // [sp+24h] [bp-48h]@1
|
|
1413 float v55; // [sp+54h] [bp-18h]@22
|
|
1414 float v56; // [sp+58h] [bp-14h]@22
|
|
1415 int uNumRepeats; // [sp+5Ch] [bp-10h]@15
|
|
1416 float v58; // [sp+60h] [bp-Ch]@23
|
|
1417 int v59; // [sp+64h] [bp-8h]@4
|
|
1418 AudioPlayer *thisa; // [sp+68h] [bp-4h]@1
|
|
1419
|
11
|
1420 pAudioPlayer = this;
|
0
|
1421 v2 = 0;
|
|
1422 thisa = this;
|
|
1423 v3 = this->bPlayerReady == 0;
|
|
1424 a1.flt_2C = 0.0;
|
|
1425 if ( !v3 )
|
|
1426 {
|
|
1427 v4 = &this->field_2D0_time_left;
|
|
1428 *v4 -= pEventTimer->uTimeElapsed;
|
|
1429 if ( this->field_2D0_time_left <= 0 )
|
|
1430 {
|
|
1431 v3 = this->b3DSoundInitialized == 0;
|
|
1432 *v4 = 32;
|
|
1433 if ( !v3 )
|
|
1434 {
|
|
1435 v3 = this->uNum3DSamples == 0;
|
|
1436 v5 = this->uNum3DSamples < 0;
|
|
1437 v59 = 0;
|
|
1438 if ( !(v5 | v3) )
|
|
1439 {
|
|
1440 v6 = this->p3DSamples;
|
|
1441 while ( 1 )
|
|
1442 {
|
|
1443 v7 = v6->field_4 & 7;
|
|
1444 if ( AIL_3D_sample_status(v6->hSample) == 2 )
|
|
1445 {
|
|
1446 AIL_end_3D_sample(v6->hSample);
|
11
|
1447 pAudioPlayer->_4ABF23(v6);
|
0
|
1448 }
|
|
1449 if ( AIL_3D_sample_status(v6->hSample) != 4 )
|
|
1450 goto LABEL_35;
|
|
1451 v8 = v7 - 1;
|
|
1452 if ( v8 )
|
|
1453 break;
|
|
1454 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
|
|
1455 goto LABEL_31;
|
|
1456 v15 = &pIndoor->pDoors[v6->field_4 >> 3];
|
|
1457 if ( v15->uDoorID )
|
|
1458 {
|
|
1459 uNumRepeats = *v15->pXOffsets;
|
|
1460 a1.vWorldPosition.x = (double)uNumRepeats;
|
|
1461 uNumRepeats = *v15->pYOffsets;
|
|
1462 a1.vWorldPosition.y = (double)uNumRepeats;
|
|
1463 uNumRepeats = *v15->pZOffsets;
|
|
1464 v11 = (double)uNumRepeats;
|
|
1465 goto LABEL_21;
|
|
1466 }
|
|
1467 LABEL_35:
|
|
1468 ++v59;
|
|
1469 ++v6;
|
11
|
1470 if ( v59 >= pAudioPlayer->uNum3DSamples )
|
0
|
1471 {
|
|
1472 v2 = 0;
|
|
1473 goto LABEL_37;
|
|
1474 }
|
|
1475 }
|
|
1476 v9 = v8 - 1;
|
|
1477 if ( v9 )
|
|
1478 {
|
|
1479 v10 = v9 - 1;
|
|
1480 if ( !v10 )
|
|
1481 {
|
|
1482 v13 = &pActors[v6->field_4 >> 3];
|
|
1483 uNumRepeats = v13->vPosition.x;
|
|
1484 v14 = v13->vPosition.y;
|
|
1485 a1.vWorldPosition.x = (double)uNumRepeats;
|
|
1486 uNumRepeats = v13->vPosition.z;
|
|
1487 a1.vWorldPosition.y = (double)v14;
|
|
1488 v11 = (double)uNumRepeats;
|
|
1489 goto LABEL_21;
|
|
1490 }
|
|
1491 if ( v10 != 2 )
|
|
1492 {
|
|
1493 a1.vWorldPosition.x = (double)pParty->vPosition.x;
|
|
1494 a1.vWorldPosition.y = (double)pParty->vPosition.y;
|
|
1495 v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
|
|
1496 goto LABEL_21;
|
|
1497 }
|
|
1498 v12 = (LayingItem *)&pLevelDecorations[v6->field_4 >> 3];
|
|
1499 }
|
|
1500 else
|
|
1501 {
|
|
1502 v12 = &pLayingItems[v6->field_4 >> 3];
|
|
1503 }
|
|
1504 a1.vWorldPosition.x = (double)v12->vPosition.x;
|
|
1505 a1.vWorldPosition.y = (double)v12->vPosition.y;
|
|
1506 v11 = (double)v12->vPosition.z;
|
|
1507 LABEL_21:
|
|
1508 a1.vWorldPosition.z = v11;
|
|
1509 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1510 {
|
|
1511 v16 = pBLVRenderParams->fCosineNegX;
|
|
1512 v17 = pBLVRenderParams->fSineNegX;
|
|
1513 v55 = pBLVRenderParams->fCosineY;
|
|
1514 v56 = pBLVRenderParams->fSineY;
|
|
1515 if ( pBLVRenderParams->sPartyRotX )
|
|
1516 {
|
|
1517 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
|
|
1518 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
|
|
1519 v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
|
|
1520 if ( pRenderer->pRenderD3D )
|
|
1521 {
|
|
1522 v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
|
|
1523 v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
|
|
1524 }
|
|
1525 else
|
|
1526 {
|
|
1527 v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
|
|
1528 v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
|
|
1529 }
|
|
1530 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
|
|
1531 a1.vWorldViewPosition.y = v20;
|
|
1532 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
|
|
1533 }
|
|
1534 else
|
|
1535 {
|
|
1536 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
|
|
1537 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
|
|
1538 if ( pRenderer->pRenderD3D )
|
|
1539 {
|
|
1540 a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
|
|
1541 v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
|
|
1542 }
|
|
1543 else
|
|
1544 {
|
|
1545 a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
|
|
1546 v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
|
|
1547 }
|
|
1548 a1.vWorldViewPosition.y = v21;
|
|
1549 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
|
|
1550 }
|
|
1551 }
|
|
1552 else
|
|
1553 {
|
|
1554 LABEL_31:
|
|
1555 pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u);
|
|
1556 }
|
|
1557 v58 = a1.vWorldViewPosition.y * -0.012207031;
|
|
1558 v22 = a1.vWorldViewPosition.x * 0.012207031;
|
|
1559 *(float *)&uNumRepeats = v22;
|
|
1560 v23 = abs((signed __int64)v22);
|
|
1561 v24 = abs(0);
|
|
1562 v25 = abs((signed __int64)v58);
|
|
1563 if ( sub_4621DA(v25, v24, v23) <= 100 )
|
|
1564 {
|
|
1565 AIL_set_3D_position(v6->hSample, LODWORD(v58), 0.0, uNumRepeats);
|
|
1566 v26 = -*(float *)&uNumRepeats;
|
|
1567 v27 = -v58;
|
|
1568 AIL_set_3D_orientation(v6->hSample, LODWORD(v27), 0.0, LODWORD(v26), 0.0, 1.0, 0.0);
|
|
1569 }
|
|
1570 else
|
|
1571 {
|
|
1572 AIL_end_3D_sample(v6->hSample);
|
11
|
1573 pAudioPlayer->_4ABF23(v6);
|
0
|
1574 }
|
|
1575 goto LABEL_35;
|
|
1576 }
|
|
1577 }
|
|
1578 LABEL_37:
|
11
|
1579 if ( pAudioPlayer->uMixerChannels > v2 )
|
0
|
1580 {
|
11
|
1581 v28 = pAudioPlayer->pMixerChannels;
|
0
|
1582 do
|
|
1583 {
|
|
1584 if ( AIL_sample_status(v28->hSample) == 2 )
|
|
1585 {
|
|
1586 AIL_end_sample(v28->hSample);
|
11
|
1587 pAudioPlayer->_4ABE55(v28);
|
0
|
1588 }
|
|
1589 ++v2;
|
|
1590 ++v28;
|
|
1591 }
|
11
|
1592 while ( v2 < pAudioPlayer->uMixerChannels );
|
0
|
1593 v2 = 0;
|
|
1594 }
|
|
1595 //v29 = __OFSUB__(v1->uMixerChannels, v2);
|
11
|
1596 v29 = pAudioPlayer->uMixerChannels > v2;
|
|
1597 v3 = pAudioPlayer->uMixerChannels == v2;
|
|
1598 v5 = pAudioPlayer->uMixerChannels - v2 < 0;
|
0
|
1599 v59 = v2;
|
|
1600 if ( !((unsigned __int8)(v5 ^ v29) | v3) )
|
|
1601 {
|
11
|
1602 v30 = pAudioPlayer->pMixerChannels;
|
0
|
1603 while ( 1 )
|
|
1604 {
|
|
1605 v31 = v30->dword_000004;
|
|
1606 if ( (v30->dword_000004 & 7) == 1 )
|
|
1607 {
|
|
1608 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1609 {
|
|
1610 v39 = &pIndoor->pDoors[v31 >> 3];
|
|
1611 if ( !v39->uDoorID )
|
|
1612 {
|
|
1613 LABEL_61:
|
11
|
1614 pAudioPlayer = thisa;
|
0
|
1615 goto LABEL_62;
|
|
1616 }
|
|
1617 v40 = GetSoundStrengthByDistanceFromParty(*v39->pXOffsets, *v39->pYOffsets, *v39->pZOffsets);
|
|
1618 if ( !v40 )
|
|
1619 {
|
|
1620 LABEL_58:
|
|
1621 AIL_end_sample(v30->hSample);
|
|
1622 thisa->_4ABE55(v30);
|
|
1623 goto LABEL_61;
|
|
1624 }
|
|
1625 AIL_set_sample_volume(v30->hSample, v40);
|
|
1626 v35 = *v39->pYOffsets;
|
|
1627 v36 = *v39->pXOffsets;
|
|
1628 LABEL_60:
|
|
1629 v41 = sub_4AB66C(v36, v35);
|
|
1630 AIL_set_sample_pan(v30->hSample, v41);
|
|
1631 goto LABEL_61;
|
|
1632 }
|
|
1633 }
|
|
1634 else
|
|
1635 {
|
|
1636 if ( (v30->dword_000004 & 7) == 2 )
|
|
1637 {
|
|
1638 v32 = &pLayingItems[v31 >> 3];
|
|
1639 goto LABEL_53;
|
|
1640 }
|
|
1641 if ( (v30->dword_000004 & 7) == 3 )
|
|
1642 {
|
|
1643 v33 = &pActors[v31 >> 3];
|
|
1644 v34 = GetSoundStrengthByDistanceFromParty(v33->vPosition.x, v33->vPosition.y, v33->vPosition.z);
|
|
1645 if ( !v34 )
|
|
1646 goto LABEL_58;
|
|
1647 AIL_set_sample_volume(v30->hSample, v34);
|
|
1648 v35 = v33->vPosition.y;
|
|
1649 v36 = v33->vPosition.x;
|
|
1650 goto LABEL_60;
|
|
1651 }
|
|
1652 if ( (v30->dword_000004 & 7) == 5 )
|
|
1653 {
|
|
1654 v32 = (LayingItem *)&pLevelDecorations[v31 >> 3];
|
|
1655 LABEL_53:
|
|
1656 v37 = v32;
|
|
1657 v38 = GetSoundStrengthByDistanceFromParty(v32->vPosition.x, v32->vPosition.y, v32->vPosition.z);
|
|
1658 if ( !v38 )
|
|
1659 goto LABEL_58;
|
|
1660 AIL_set_sample_volume(v30->hSample, v38);
|
|
1661 v35 = v37->vPosition.y;
|
|
1662 v36 = v37->vPosition.x;
|
|
1663 goto LABEL_60;
|
|
1664 }
|
|
1665 }
|
|
1666 LABEL_62:
|
|
1667 ++v59;
|
|
1668 ++v30;
|
11
|
1669 if ( v59 >= pAudioPlayer->uMixerChannels )
|
0
|
1670 {
|
|
1671 v2 = 0;
|
|
1672 break;
|
|
1673 }
|
|
1674 }
|
|
1675 }
|
|
1676 if ( pCurrentScreen != v2 )
|
|
1677 {
|
11
|
1678 v42 = &pAudioPlayer->pMixerChannels[4];
|
0
|
1679 if ( AIL_sample_status(v42->hSample) == 4 )
|
|
1680 AIL_end_sample(v42->hSample);
|
|
1681 return;
|
|
1682 }
|
|
1683 v59 = v2;
|
|
1684 if ( _6807E0_num_decorations_with_sounds_6807B8 <= v2 )
|
|
1685 return;
|
|
1686 while ( 1 )
|
|
1687 {
|
|
1688 LODWORD(v56) = 1;
|
|
1689 v43 = 4 * v59 + 6817720;
|
|
1690 v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]];
|
|
1691 v45 = abs(v44->vPosition.z - pParty->vPosition.z);
|
|
1692 v46 = abs(v44->vPosition.y - pParty->vPosition.y);
|
|
1693 v47 = abs(v44->vPosition.x - pParty->vPosition.x);
|
|
1694 if ( sub_4621DA(v47, v46, v45) <= 8192 )
|
|
1695 break;
|
|
1696 LABEL_89:
|
|
1697 ++v59;
|
|
1698 if ( v59 >= _6807E0_num_decorations_with_sounds_6807B8 )
|
|
1699 return;
|
|
1700 }
|
|
1701 v48 = &pDecorationList->pDecorations[v44->uDecorationDescID];
|
|
1702 v49 = v48->uFlags;
|
|
1703 uNumRepeats = (~(unsigned __int8)v48->uFlags & 0x40) >> 6;
|
|
1704 if ( HIBYTE(v49) & 3 )
|
|
1705 {
|
|
1706 v50 = v44->field_1A;
|
|
1707 v55 = 0.0;
|
|
1708 uNumRepeats = 2;
|
|
1709 if ( v50 )
|
|
1710 {
|
|
1711 v51 = v50 - 32;
|
|
1712 v44->field_1A = v51;
|
|
1713 if ( v51 < 0 )
|
|
1714 v44->field_1A = 0;
|
|
1715 }
|
|
1716 }
|
|
1717 v52 = v48->uFlags;
|
|
1718 if ( !(HIBYTE(v52) & 1) )
|
|
1719 {
|
|
1720 if ( !(HIBYTE(v52) & 2) )
|
|
1721 goto LABEL_84;
|
|
1722 if ( v55 != 0.0 )
|
|
1723 goto LABEL_85;
|
|
1724 }
|
|
1725 v56 = 0.0;
|
|
1726 if ( pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 6
|
|
1727 || pParty->uCurrentHour >= 0x14 && pParty->uCurrentHour < 0x15 )
|
|
1728 {
|
|
1729 if ( !v44->field_1A && rand() % 100 < 100 )
|
|
1730 LODWORD(v56) = 1;
|
|
1731 LODWORD(v55) = 1;
|
|
1732 }
|
|
1733 LABEL_84:
|
|
1734 if ( v55 == 0.0 )
|
|
1735 {
|
|
1736 LABEL_87:
|
|
1737 if ( v56 != 0.0 )
|
|
1738 {
|
|
1739 v53 = 8 * *(int *)v43;
|
|
1740 LOBYTE(v53) = v53 | 5;
|
|
1741 thisa->PlaySound((SoundID)v48->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0);
|
|
1742 }
|
|
1743 goto LABEL_89;
|
|
1744 }
|
|
1745 LABEL_85:
|
|
1746 if ( !v44->field_1A )
|
|
1747 v44->field_1A = (rand() % 15 + 1) << 7;
|
|
1748 goto LABEL_87;
|
|
1749 }
|
|
1750 }
|
|
1751 }
|
|
1752
|
|
1753
|
|
1754
|
|
1755 //----- (004AB66C) --------------------------------------------------------
|
|
1756 int __fastcall sub_4AB66C(int a1, int a2)
|
|
1757 {
|
|
1758 signed int v2; // eax@1
|
|
1759
|
|
1760 v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.y)
|
|
1761 - stru_5C6E00->uIntegerHalfPi
|
|
1762 - pParty->sRotationY);
|
|
1763 if ( v2 > (signed int)stru_5C6E00->uIntegerPi )
|
|
1764 v2 = 2 * stru_5C6E00->uIntegerPi - v2;
|
|
1765 return (v2 >> 3) - (v2 >> 10);
|
|
1766 }
|
|
1767 // 4AB66C: using guessed type int __fastcall sub_4AB66C(int, int);
|
|
1768
|
|
1769 //----- (004AB6B1) --------------------------------------------------------
|
|
1770 int __fastcall GetSoundStrengthByDistanceFromParty(int a1, int a2, int a3)
|
|
1771 {
|
|
1772 int v3; // esi@1
|
|
1773 int v4; // edi@1
|
|
1774 int v5; // ST08_4@1
|
|
1775 int v6; // esi@1
|
|
1776 int v7; // eax@1
|
|
1777 int result; // eax@2
|
|
1778 int v9; // [sp+10h] [bp+8h]@1
|
|
1779
|
|
1780 v3 = a2;
|
|
1781 v4 = a1;
|
|
1782 v5 = abs(a3 - pParty->vPosition.z);
|
|
1783 v6 = abs(v3 - pParty->vPosition.y);
|
|
1784 v7 = abs(v4 - pParty->vPosition.x);
|
|
1785 v9 = sub_4621DA(v7, v6, v5);
|
|
1786 if ( v9 <= 8192 )
|
|
1787 result = 114 - (unsigned __int64)(signed __int64)((double)v9 * 0.0001220703125 * 100.0);
|
|
1788 else
|
|
1789 result = 0;
|
|
1790 return result;
|
|
1791 }
|
|
1792
|
|
1793
|
|
1794
|
|
1795 //----- (004AB71F) --------------------------------------------------------
|
|
1796 void AudioPlayer::StopChannels(int uStartChannel, int uEndChannel)
|
|
1797 {
|
|
1798 //AudioPlayer *v3; // esi@1
|
|
1799 int v4; // ecx@1
|
|
1800 char *v5; // edi@4
|
|
1801 int v6; // ebx@12
|
|
1802 MixerChannel *pChannel; // edi@14
|
|
1803 //_STREAM *v8; // esi@23
|
|
1804 int v9; // [sp+4h] [bp-4h]@3
|
|
1805
|
|
1806 //v3 = this;
|
|
1807 v4 = 0;
|
|
1808 if ( bPlayerReady )
|
|
1809 {
|
|
1810 if ( b3DSoundInitialized )
|
|
1811 {
|
|
1812 v9 = 0;
|
|
1813 if ( uNum3DSamples > 0 )
|
|
1814 {
|
|
1815 v5 = (char *)&p3DSamples[0].field_8;
|
|
1816 do
|
|
1817 {
|
|
1818 if ( (uStartChannel == -1 || v4 < uStartChannel || v4 > uEndChannel)
|
|
1819 && *(int *)v5
|
|
1820 && pSoundList->pSounds[*(int *)v5].eType != SOUND_DESC_SYSTEM)
|
|
1821 {
|
|
1822 AIL_end_3D_sample(*((int **)v5 - 2));
|
|
1823 _4ABF23((AudioPlayer_3DSample *)(v5 - 8));
|
|
1824 *((int *)v5 - 1) = 0;
|
|
1825 v4 = v9;
|
|
1826 }
|
|
1827 ++v4;
|
|
1828 v5 += 16;
|
|
1829 v9 = v4;
|
|
1830 }
|
|
1831 while ( v4 < uNum3DSamples );
|
|
1832 }
|
|
1833 }
|
|
1834 v6 = 0;
|
|
1835 if ( hDigDriver && uMixerChannels > 0 )
|
|
1836 {
|
|
1837 pChannel = pMixerChannels;
|
|
1838 do
|
|
1839 {
|
|
1840 if ( (uStartChannel == -1 || v6 < uStartChannel || v6 > uEndChannel)
|
|
1841 && pSoundList->pSounds[pChannel->uSourceTrackIdx].eType != SOUND_DESC_SYSTEM)
|
|
1842 {
|
|
1843 AIL_end_sample(pChannel->hSample);
|
|
1844 _4ABE55(pChannel);
|
|
1845 pChannel->dword_000004 = 0;
|
|
1846 }
|
|
1847 ++v6;
|
|
1848 ++pChannel;
|
|
1849 }
|
|
1850 while (v6 < uMixerChannels);
|
|
1851 }
|
|
1852 if (hSequence)
|
|
1853 AIL_end_sequence(hSequence);
|
|
1854 //v8 = hStream;
|
|
1855 if (hStream)
|
|
1856 AIL_pause_stream(hStream, 1);
|
|
1857 }
|
|
1858 }
|
|
1859
|
|
1860
|
|
1861 //----- (004AB818) --------------------------------------------------------
|
|
1862 void AudioPlayer::LoadAudioSnd()
|
|
1863 {
|
|
1864 DWORD NumberOfBytesRead; // [sp+Ch] [bp-4h]@3
|
|
1865
|
|
1866 hAudioSnd = CreateFileA("Sounds\\Audio.snd", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
|
|
1867 if (hAudioSnd == INVALID_HANDLE_VALUE)
|
|
1868 {
|
|
1869 Log::Warning(L"Can't open file: %s", L"Sounds\\Audio.snd");
|
|
1870 return;
|
|
1871 }
|
|
1872
|
|
1873 ReadFile(hAudioSnd, &uNumSoundHeaders, 4u, &NumberOfBytesRead, 0);
|
|
1874 pSoundHeaders = nullptr;
|
|
1875 pSoundHeaders = (SoundHeader *)pAllocator->AllocNamedChunk(0, 52 * uNumSoundHeaders + 2, 0);
|
|
1876 ReadFile(hAudioSnd, pSoundHeaders, 52 * uNumSoundHeaders, &NumberOfBytesRead, 0);
|
|
1877 }
|
|
1878
|
|
1879 //----- (004AB8CE) --------------------------------------------------------
|
|
1880 void AudioPlayer::Initialize(HWND hWnd)
|
|
1881 {
|
|
1882 //AudioPlayer *v2; // esi@1
|
|
1883 int v3; // ebx@1
|
|
1884 //_DIG_DRIVER *v4; // eax@1
|
|
1885 char v5; // dl@5
|
|
1886 _PROVIDER *v6; // eax@9
|
|
1887 HWND v7; // ST00_4@9
|
|
1888 MixerChannel *pChannel; // edi@14
|
|
1889 _SAMPLE *v9; // eax@15
|
|
1890 //_REDBOOK *v10; // eax@19
|
|
1891 //int v11; // ecx@21
|
|
1892 int v12; // [sp+Ch] [bp-Ch]@9
|
|
1893 char *Str1; // [sp+10h] [bp-8h]@6
|
|
1894 int v14; // [sp+14h] [bp-4h]@5
|
|
1895
|
|
1896 //v2 = this;
|
|
1897 v3 = 0;
|
|
1898 this->hWindow = hWnd;
|
|
1899 this->hAILRedbook = 0;
|
|
1900 this->hDigDriver = 0;
|
|
1901 this->dword_0002AC = 0;
|
|
1902 this->hSequence = 0;
|
|
1903 this->uMasterVolume = 127;
|
|
1904 this->dword_0002C8 = 64;
|
|
1905 this->dword_0002CC = 2;
|
|
1906
|
|
1907 MSS32_DLL_Initialize();
|
|
1908 BINKW32_DLL_Initialize();
|
|
1909 SMACKW32_DLL_Initialize();
|
|
1910
|
|
1911 AIL_startup();
|
|
1912 if (bCanLoadFromCD)
|
|
1913 hAILRedbook = AIL_redbook_open_drive(cMM7GameCDDriveLetter/*cGameCDDriveLetter*/);
|
|
1914 //else
|
|
1915 // hAILRedbook = AIL_redbook_open(0);
|
|
1916 //v4 = Audio_GetFirstHardwareDigitalDriver();
|
|
1917
|
|
1918 hDigDriver = Audio_GetFirstHardwareDigitalDriver();
|
|
1919 if ( hDigDriver )
|
|
1920 SmackSoundUseMSS(hDigDriver);
|
|
1921 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 && pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT )
|
|
1922 {
|
|
1923 v14 = 0;
|
|
1924 bEAXSupported = 0;
|
|
1925 b3DSoundInitialized = 0;
|
|
1926 ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128u, "NONE");
|
|
1927 CheckA3DSupport(v5);
|
|
1928 while ( AIL_enumerate_3D_providers(&v14, (HPROVIDER *)&hWnd, &Str1) )
|
|
1929 {
|
|
1930 if ( !strcmp(Str1, p3DSoundProvider) )
|
|
1931 {
|
|
1932 if ( AIL_open_3D_provider((HPROVIDER)hWnd) )
|
|
1933 {
|
|
1934 bEAXSupported = 0;
|
|
1935 b3DSoundInitialized = 0;
|
|
1936 h3DSoundProvider = 0;
|
|
1937 }
|
|
1938 else
|
|
1939 {
|
|
1940 v6 = (_PROVIDER *)hWnd;
|
|
1941 v7 = hWnd;
|
|
1942 b3DSoundInitialized = 1;
|
|
1943 h3DSoundProvider = v6;
|
|
1944 uNum3DSamples = 4;
|
|
1945 AIL_3D_provider_attribute((HPROVIDER)v7, "EAX environment selection", &v12);
|
|
1946 if ( v12 != -1 )
|
|
1947 bEAXSupported = 1;
|
|
1948 }
|
|
1949 pAudioPlayer->_4AC0A2();
|
|
1950 break;
|
|
1951 }
|
|
1952 }
|
|
1953 }
|
|
1954 if ( uMixerChannels > 0 )
|
|
1955 {
|
|
1956 pChannel = pMixerChannels;
|
|
1957 do
|
|
1958 {
|
|
1959 v9 = AIL_allocate_sample_handle(hDigDriver);
|
|
1960 pChannel->hSample = v9;
|
|
1961 if ( !v9 )
|
|
1962 break;
|
|
1963 ++v3;
|
|
1964 ++pChannel;
|
|
1965 }
|
|
1966 while ( v3 < uMixerChannels );
|
|
1967 }
|
|
1968 uMixerChannels = v3;
|
|
1969 if ( bPlayerReady )
|
|
1970 StopChannels(-1, -1);
|
|
1971 //v10 = hAILRedbook;
|
|
1972 bPlayerReady = true;
|
|
1973 if ( hAILRedbook )
|
|
1974 {
|
|
1975 AIL_redbook_stop(hAILRedbook);
|
|
1976 uNumRedbookTracks = AIL_redbook_tracks(hAILRedbook);
|
|
1977 }
|
|
1978 pAudioPlayer->sRedbookVolume = AIL_redbook_volume(hAILRedbook);
|
|
1979 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0);
|
|
1980 if ( bPlayerReady && hAILRedbook )
|
|
1981 AIL_redbook_set_volume(hAILRedbook, (unsigned __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0) >> 32);
|
|
1982 LoadAudioSnd();
|
|
1983 }
|
|
1984
|
|
1985 //----- (004ABAF7) --------------------------------------------------------
|
|
1986 _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void)
|
|
1987 {
|
|
1988 int v0; // ecx@1
|
|
1989 unsigned int v1; // ebp@2
|
|
1990 size_t v2; // eax@4
|
|
1991 signed int v3; // kr14_4@9
|
|
1992 char *v5; // [sp+10h] [bp-Ch]@2
|
|
1993 unsigned int v6; // [sp+14h] [bp-8h]@1
|
|
1994 _DIG_DRIVER *hDrv; // [sp+18h] [bp-4h]@3
|
|
1995
|
|
1996 static int dword_4F00DC = 22050;
|
|
1997 static int dword_4F00E0 = 16;
|
|
1998 static int dword_4F00E4 = 2;
|
|
1999
|
|
2000 AIL_set_preference(15, 0);
|
|
2001 AIL_set_preference(33, 1);
|
|
2002 v0 = dword_4F00DC;
|
|
2003 pAudioPlayer->pDeviceNames[0][0] = 0;
|
|
2004 pAudioPlayer->uNumDevices = 0;
|
|
2005 v6 = 0;
|
|
2006
|
|
2007 if ( dword_4F00DC < 11025 )
|
|
2008 return 0;
|
|
2009 v1 = 0;
|
|
2010 v5 = (char *)pAudioPlayer->array_000BF0;
|
|
2011 while ( 1 )
|
|
2012 {
|
|
2013 while ( 1 )
|
|
2014 {
|
|
2015 pcmWaveFormat.wf.wFormatTag = 1;
|
|
2016 pcmWaveFormat.wf.nChannels = dword_4F00E4;
|
|
2017 pcmWaveFormat.wf.nSamplesPerSec = v0;
|
|
2018 pcmWaveFormat.wf.nBlockAlign = dword_4F00E4 * dword_4F00E0 / 8;
|
|
2019 pcmWaveFormat.wBitsPerSample = dword_4F00E0;
|
|
2020 pcmWaveFormat.wf.nAvgBytesPerSec = v0 * dword_4F00E4 * dword_4F00E0 / 8;
|
|
2021 if ( !AIL_waveOutOpen(&hDrv, 0, -1, &pcmWaveFormat.wf) )
|
|
2022 break;
|
|
2023 if ( !AIL_get_preference(15) )
|
|
2024 goto LABEL_8;
|
|
2025 v3 = dword_4F00DC;
|
|
2026 v0 = dword_4F00DC / 2;
|
|
2027 dword_4F00DC /= 2;
|
|
2028 if ( v3 / 2 < 11025 )
|
|
2029 {
|
|
2030 if ( dword_4F00E0 == 8 )
|
|
2031 {
|
|
2032 v0 = 22050;
|
|
2033 dword_4F00E0 = 8;
|
|
2034 dword_4F00DC = 22050;
|
|
2035 }
|
|
2036 goto LABEL_12;
|
|
2037 }
|
|
2038 }
|
|
2039 strcpy(pAudioPlayer->pDeviceNames[v1 / 8], "Device: ");
|
|
2040 v2 = strlen(pAudioPlayer->pDeviceNames[v1 / 8]);
|
|
2041 AIL_digital_configuration(hDrv, (int *)v5, (int *)(v5 + 64), (char *)pAudioPlayer->pDeviceNames + v2 + v1 * 16);
|
|
2042 ++v6;
|
|
2043 v1 += 8;
|
|
2044 v5 += 4;
|
|
2045 pAudioPlayer->uNumDevices = v6;
|
|
2046 if ( AIL_get_preference(15) )
|
|
2047 return hDrv;
|
|
2048 if ( !strstr(pAudioPlayer->pDeviceNames[v1 / 8 - 1], "Emulated") )
|
|
2049 return hDrv;
|
|
2050 AIL_waveOutClose(hDrv);
|
|
2051 AIL_set_preference(15, 1);
|
|
2052 LABEL_8:
|
|
2053 AIL_set_preference(15, 1);
|
|
2054 v0 = dword_4F00DC;
|
|
2055 LABEL_12:
|
|
2056 if ( v0 < 11025 )
|
|
2057 return 0;
|
|
2058 }
|
|
2059 }
|
|
2060
|
|
2061
|
|
2062 //----- (004ABC9B) --------------------------------------------------------
|
|
2063 LSTATUS AudioPlayer::CheckA3DSupport(char a2)
|
|
2064 {
|
|
2065 LSTATUS result; // eax@1
|
|
2066 DWORD cbData; // [sp+8h] [bp-Ch]@1
|
|
2067 int Data; // [sp+Ch] [bp-8h]@1
|
|
2068 HKEY hKey; // [sp+10h] [bp-4h]@1
|
|
2069 char v6; // [sp+1Ch] [bp+8h]@0
|
|
2070
|
|
2071 hKey = 0;
|
|
2072 cbData = 4;
|
|
2073 Data = 0;
|
|
2074 result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Aureal\\A3D", 0, 0x2001Fu, &hKey);
|
|
2075 if ( !result )
|
|
2076 {
|
|
2077 if ( v6 )
|
|
2078 RegQueryValueExA(hKey, "SplashAudio", 0, 0, (LPBYTE)&Aureal3D_SplashAudio, &cbData);
|
|
2079 else
|
|
2080 Data = Aureal3D_SplashAudio;
|
|
2081 RegSetValueExA(hKey, "SplashAudio", 0, 4u, (const BYTE *)&Data, 4u);
|
|
2082 Data = 0;
|
|
2083 if ( v6 )
|
|
2084 RegQueryValueExA(hKey, "SplashScreen", 0, 0, (LPBYTE)&Aureal3D_SplashScreen, &cbData);
|
|
2085 else
|
|
2086 Data = Aureal3D_SplashScreen;
|
|
2087 RegSetValueExA(hKey, "SplashScreen", 0, 4u, (const BYTE *)&Data, 4u);
|
|
2088 result = RegCloseKey(hKey);
|
|
2089 }
|
|
2090 return result;
|
|
2091 }
|
|
2092 // 4ABC9B: inconsistent function type and number of purged bytes
|
|
2093
|
|
2094 //----- (004ABD5B) --------------------------------------------------------
|
4
|
2095 void AudioPlayer::Release() //
|
0
|
2096 {
|
4
|
2097 AudioPlayer *pAudioPlayer; // esi@1
|
0
|
2098 int v2; // edi@1
|
4
|
2099 MixerChannel *pMixerChannel; // ebx@3
|
0
|
2100 char v4; // dl@5
|
|
2101 int v5; // ebx@6
|
4
|
2102 AudioPlayer_3DSample *p3DSample; // edi@7
|
24
|
2103 //int v7; // edx@14
|
0
|
2104 int v8; // ecx@14
|
|
2105 void *v9; // ecx@15
|
|
2106
|
4
|
2107 pAudioPlayer = this;
|
0
|
2108 v2 = 0;
|
|
2109 if ( this->bPlayerReady )
|
|
2110 {
|
|
2111 CloseHandle(pVideoPlayer->hMagicVid);
|
|
2112 CloseHandle(pVideoPlayer->hMightVid);
|
4
|
2113 pAudioPlayer->StopChannels(-1, -1);
|
|
2114 if ( pAudioPlayer->uMixerChannels > 0 )
|
0
|
2115 {
|
4
|
2116 pMixerChannel = pAudioPlayer->pMixerChannels;
|
0
|
2117 do
|
|
2118 {
|
4
|
2119 AIL_release_sample_handle(pMixerChannel->hSample);
|
0
|
2120 ++v2;
|
4
|
2121 ++pMixerChannel;
|
0
|
2122 }
|
4
|
2123 while ( v2 < pAudioPlayer->uMixerChannels );
|
0
|
2124 }
|
|
2125 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 )
|
|
2126 {
|
|
2127 v5 = 0;
|
24
|
2128 pAudioPlayer->CheckA3DSupport(0);// pAudioPlayer->CheckA3DSupport(v4);
|
4
|
2129 if ( pAudioPlayer->uNum3DSamples > 0 )
|
0
|
2130 {
|
4
|
2131 p3DSample = pAudioPlayer->p3DSamples;
|
0
|
2132 do
|
|
2133 {
|
4
|
2134 if ( p3DSample->hSample )
|
0
|
2135 {
|
4
|
2136 AIL_release_3D_sample_handle(p3DSample->hSample);
|
|
2137 p3DSample->hSample = 0;
|
0
|
2138 }
|
|
2139 ++v5;
|
4
|
2140 ++p3DSample;
|
0
|
2141 }
|
4
|
2142 while ( v5 < pAudioPlayer->uNum3DSamples );
|
0
|
2143 }
|
4
|
2144 if ( pAudioPlayer->h3DSoundProvider )
|
0
|
2145 {
|
4
|
2146 AIL_close_3D_provider(pAudioPlayer->h3DSoundProvider);
|
|
2147 pAudioPlayer->h3DSoundProvider = 0;
|
0
|
2148 }
|
|
2149 }
|
24
|
2150 v8 = (int)&pAudioPlayer->hAILRedbook;
|
4
|
2151 if ( pAudioPlayer->hAILRedbook )
|
0
|
2152 {
|
4
|
2153 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
|
24
|
2154 AIL_redbook_set_volume((HREDBOOK)v8, pAudioPlayer->sRedbookVolume);
|
4
|
2155 AIL_redbook_close(pAudioPlayer->hAILRedbook);
|
0
|
2156 }
|
|
2157 AIL_shutdown();
|
|
2158 pSoundList->Release();
|
4
|
2159 v9 = *(void **)&pAudioPlayer->field_C78[0];
|
0
|
2160 if ( v9 )
|
|
2161 ReleaseSoundData(v9);
|
4
|
2162 CloseHandle(pAudioPlayer->hAudioSnd);
|
0
|
2163 }
|
|
2164 }
|
|
2165
|
|
2166 //----- (004ABE55) --------------------------------------------------------
|
|
2167 void AudioPlayer::_4ABE55(MixerChannel *pChannel)
|
|
2168 {
|
|
2169 int v2; // ebx@1
|
|
2170 //AudioPlayer *v3; // esi@1
|
|
2171 SoundDesc *v4; // eax@2
|
|
2172 unsigned __int8 v5; // zf@5
|
|
2173 unsigned __int8 v6; // sf@5
|
|
2174 char *v7; // edi@6
|
|
2175 int v8; // eax@8
|
|
2176 int v9; // ST04_4@8
|
|
2177 int v10; // ecx@12
|
|
2178 int v11; // edi@13
|
|
2179 int v12; // eax@13
|
|
2180 unsigned __int8 v13; // of@13
|
|
2181 int v14[16]; // [sp+Ch] [bp-48h]@8
|
|
2182 int v15; // [sp+4Ch] [bp-8h]@5
|
|
2183 int v16; // [sp+50h] [bp-4h]@5
|
|
2184
|
|
2185 v2 = 0;
|
|
2186 //v3 = this;
|
|
2187 if ( pSoundList->pSounds )
|
|
2188 {
|
|
2189 v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx];
|
|
2190 if ( v4->eType == SOUND_DESC_SWAP)
|
|
2191 {
|
|
2192 if ( v4->pSoundData[0] && !(v4->uFlags & 1) )
|
|
2193 {
|
|
2194 v5 = this->uMixerChannels == 0;
|
|
2195 v6 = this->uMixerChannels < 0;
|
|
2196 v15 = 0;
|
|
2197 v16 = 0;
|
|
2198 if ( v6 | v5 )
|
|
2199 goto LABEL_16;
|
|
2200 v7 = (char *)this->pMixerChannels;
|
|
2201 do
|
|
2202 {
|
|
2203 if ( pChannel->uSourceTrackID == *((int *)v7 + 3) )
|
|
2204 {
|
|
2205 v8 = v16;
|
|
2206 v9 = *(int *)v7;
|
|
2207 ++v16;
|
|
2208 v14[v8] = v2;
|
|
2209 if ( AIL_sample_status((HSAMPLE)v9) == 4 )
|
|
2210 ++v15;
|
|
2211 }
|
|
2212 ++v2;
|
|
2213 v7 += 16;
|
|
2214 }
|
|
2215 while ( v2 < uMixerChannels );
|
|
2216 if ( !v15 )
|
|
2217 {
|
|
2218 LABEL_16:
|
|
2219 pSoundList->_4A9DCD(pChannel->uSourceTrackIdx, 1);
|
|
2220 v10 = 0;
|
|
2221 if ( v16 > 0 )
|
|
2222 {
|
|
2223 do
|
|
2224 {
|
|
2225 v11 = v14[v10];
|
|
2226 v12 = 16 * (v14[v10++] + 47);
|
|
2227 pMixerChannels[v11].uSourceTrackID = 0;
|
|
2228 v13 = __OFSUB__(v10, v16);
|
|
2229 v6 = v10 - v16 < 0;
|
|
2230 *(unsigned int *)((char *)&bEAXSupported + v12) = 0;
|
|
2231 }
|
|
2232 while ( v6 ^ v13 );
|
|
2233 }
|
|
2234 }
|
|
2235 }
|
|
2236 }
|
|
2237 }
|
|
2238 }
|
|
2239 // 4D82F8: using guessed type int __stdcall AIL_sample_status(int);
|
|
2240 // 4ABE55: using guessed type int var_48[16];
|
|
2241
|
|
2242
|
|
2243
|
|
2244 //----- (004AAEA6) --------------------------------------------------------
|
|
2245 int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1)
|
|
2246 {
|
|
2247 double v1; // st7@1
|
|
2248 double v2; // st6@1
|
|
2249 int result; // eax@1
|
|
2250 double v4; // st5@2
|
|
2251 double v5; // st4@3
|
|
2252 double v6; // st3@3
|
|
2253 double v7; // st7@6
|
|
2254 double v8; // st6@7
|
|
2255 float v9; // [sp+0h] [bp-10h]@1
|
|
2256 float v10; // [sp+4h] [bp-Ch]@1
|
|
2257 float v11; // [sp+8h] [bp-8h]@2
|
|
2258 float v12; // [sp+8h] [bp-8h]@6
|
|
2259 float v13; // [sp+Ch] [bp-4h]@2
|
|
2260 float v14; // [sp+Ch] [bp-4h]@6
|
|
2261
|
|
2262 v1 = pBLVRenderParams->fCosineNegX;
|
|
2263 v2 = pBLVRenderParams->fSineNegX;
|
|
2264 v9 = pBLVRenderParams->fCosineY;
|
|
2265 v10 = pBLVRenderParams->fSineY;
|
|
2266 result = 0;
|
|
2267 if ( pBLVRenderParams->sPartyRotX )
|
|
2268 {
|
|
2269 v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
|
|
2270 v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
|
|
2271 v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
|
|
2272 if ( pRenderer->pRenderD3D )
|
|
2273 {
|
|
2274 v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY;
|
|
2275 v6 = v13 * pBLVRenderParams->fSineY - v11 * pBLVRenderParams->fCosineY;
|
|
2276 }
|
|
2277 else
|
|
2278 {
|
|
2279 v5 = v13 * pBLVRenderParams->fCosineY - v11 * pBLVRenderParams->fSineY;
|
|
2280 v6 = v13 * pBLVRenderParams->fSineY + v11 * pBLVRenderParams->fCosineY;
|
|
2281 }
|
|
2282 a1->vWorldViewPosition.x = v5 * v1 - v4 * v2;
|
|
2283 a1->vWorldViewPosition.y = v6;
|
|
2284 a1->vWorldViewPosition.z = v5 * v2 + v4 * v1;
|
|
2285 }
|
|
2286 else
|
|
2287 {
|
|
2288 v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
|
|
2289 v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
|
|
2290 v7 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
|
|
2291 if ( pRenderer->pRenderD3D )
|
|
2292 {
|
|
2293 a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY;
|
|
2294 v8 = v14 * v10 - v12 * v9;
|
|
2295 }
|
|
2296 else
|
|
2297 {
|
|
2298 a1->vWorldViewPosition.x = v14 * pBLVRenderParams->fCosineY - v12 * pBLVRenderParams->fSineY;
|
|
2299 v8 = v14 * v10 + v12 * v9;
|
|
2300 }
|
|
2301 a1->vWorldViewPosition.y = v8;
|
|
2302 a1->vWorldViewPosition.z = v7;
|
|
2303 }
|
|
2304 return result;
|
|
2305 }
|
|
2306
|
|
2307
|
|
2308
|
|
2309
|
|
2310 //----- (004ABF23) --------------------------------------------------------
|
|
2311 void AudioPlayer::_4ABF23(AudioPlayer_3DSample *a2)
|
|
2312 {
|
|
2313 int v2; // ebx@1
|
|
2314 //AudioPlayer *v3; // esi@1
|
|
2315 SoundDesc *v4; // eax@2
|
|
2316 unsigned __int8 v5; // zf@5
|
|
2317 unsigned __int8 v6; // sf@5
|
|
2318 char *v7; // edi@6
|
|
2319 int v8; // eax@8
|
|
2320 int v9; // ST04_4@8
|
|
2321 int v10; // ecx@12
|
|
2322 int v11; // eax@13
|
|
2323 unsigned __int8 v12; // of@13
|
|
2324 int v13[16]; // [sp+Ch] [bp-48h]@8
|
|
2325 int v14; // [sp+4Ch] [bp-8h]@5
|
|
2326 int v15; // [sp+50h] [bp-4h]@5
|
|
2327
|
|
2328 v2 = 0;
|
|
2329 //v3 = this;
|
|
2330 if ( pSoundList->pSounds )
|
|
2331 {
|
|
2332 v4 = &pSoundList->pSounds[a2->field_8];
|
|
2333 if ( v4->eType == SOUND_DESC_SWAP)
|
|
2334 {
|
|
2335 if ( v4->p3DSound && !(v4->uFlags & 1) )
|
|
2336 {
|
|
2337 v5 = this->uNum3DSamples == 0;
|
|
2338 v6 = this->uNum3DSamples < 0;
|
|
2339 v14 = 0;
|
|
2340 v15 = 0;
|
|
2341 if ( v6 | v5 )
|
|
2342 goto LABEL_16;
|
|
2343 v7 = (char *)this->p3DSamples;
|
|
2344 do
|
|
2345 {
|
|
2346 if ( a2->field_C == *((int *)v7 + 3) )
|
|
2347 {
|
|
2348 v8 = v15;
|
|
2349 v9 = *(int *)v7;
|
|
2350 ++v15;
|
|
2351 v13[v8] = v2;
|
|
2352 if ( AIL_3D_sample_status((void *)v9) == 4 )
|
|
2353 ++v14;
|
|
2354 }
|
|
2355 ++v2;
|
|
2356 v7 += 16;
|
|
2357 }
|
|
2358 while ( v2 < uNum3DSamples );
|
|
2359 if ( !v14 )
|
|
2360 {
|
|
2361 LABEL_16:
|
|
2362 pSoundList->_4A9DCD(a2->field_8, 1);
|
|
2363 v10 = 0;
|
|
2364 if ( v15 > 0 )
|
|
2365 {
|
|
2366 do
|
|
2367 {
|
|
2368 v11 = v13[v10++];
|
|
2369 *(&bEAXSupported + 4 * (v11 + 2)) = 0;
|
|
2370 v12 = __OFSUB__(v10, v15);
|
|
2371 v6 = v10 - v15 < 0;
|
|
2372 p3DSamples[v11].field_8 = 0;
|
|
2373 }
|
|
2374 while ( v6 ^ v12 );
|
|
2375 }
|
|
2376 }
|
|
2377 }
|
|
2378 }
|
|
2379 }
|
|
2380 }
|
|
2381 // 4D82F4: using guessed type int __stdcall AIL_3D_sample_status(int);
|
|
2382 // 4ABF23: using guessed type int var_48[16];
|
|
2383
|
|
2384 //----- (004ABFDB) --------------------------------------------------------
|
|
2385 void __cdecl PlayLevelMusic()
|
|
2386 {
|
|
2387 unsigned int v0; // eax@1
|
|
2388
|
|
2389 v0 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2390 if ( v0 )
|
|
2391 pAudioPlayer->PlayMusicTrack((MusicID)pMapStats->pInfos[v0].uRedbookTrackID);
|
|
2392 }
|
|
2393
|
|
2394 //----- (004AC004) --------------------------------------------------------
|
|
2395 void AudioPlayer::SetEAXPreferences()
|
|
2396 {
|
|
2397 AudioPlayer *v1; // edi@1
|
|
2398 _PROVIDER *v2; // ST00_4@2
|
|
2399 _PROVIDER *v3; // ST00_4@2
|
|
2400 float v4; // [sp+4h] [bp-4h]@2
|
|
2401
|
|
2402 v1 = this;
|
|
2403 if ( this->bEAXSupported )
|
|
2404 {
|
|
2405 v2 = this->h3DSoundProvider;
|
|
2406 v4 = 0.0;
|
|
2407 AIL_set_3D_provider_preference(v2, "EAX effect volume", (int *)&v4);
|
|
2408 v3 = v1->h3DSoundProvider;
|
|
2409 v4 = 1.0;
|
|
2410 AIL_set_3D_provider_preference(v3, "EAX damping", (int *)&v4);
|
|
2411 }
|
|
2412 }
|
|
2413 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int);
|
|
2414
|
|
2415 //----- (004AC041) --------------------------------------------------------
|
|
2416 void AudioPlayer::SetMapEAX()
|
|
2417 {
|
|
2418 AudioPlayer *v1; // esi@1
|
|
2419 unsigned int v2; // eax@1
|
|
2420 int v3; // [sp+4h] [bp-4h]@3
|
|
2421
|
|
2422 v1 = this;
|
|
2423 v2 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2424 if ( v1->b3DSoundInitialized && v1->bEAXSupported )
|
|
2425 {
|
|
2426 v3 = pMapStats->pInfos[v2].uEAXEnv;
|
|
2427 if ( (unsigned int)v3 >= 0x1A )
|
|
2428 {
|
|
2429 SetEAXPreferences();
|
|
2430 v1->field_214 = -1;
|
|
2431 }
|
|
2432 else
|
|
2433 {
|
|
2434 AIL_set_3D_provider_preference(v1->h3DSoundProvider, "EAX environment selection", &v3);
|
|
2435 v1->field_214 = v3;
|
|
2436 }
|
|
2437 }
|
|
2438 }
|
|
2439 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int);
|
|
2440
|
|
2441 //----- (004AC0A2) --------------------------------------------------------
|
|
2442 int AudioPlayer::_4AC0A2()
|
|
2443 {
|
|
2444 AudioPlayer *v1; // esi@1
|
|
2445 unsigned int v2; // eax@1
|
|
2446 char v3; // zf@1
|
|
2447 int v4; // ebx@1
|
|
2448 int *v5; // edi@2
|
|
2449 int v6; // eax@4
|
|
2450 AudioPlayer_3DSample *v8; // ebx@7
|
|
2451 void *v9; // eax@8
|
|
2452 int v10; // ebx@14
|
|
2453 unsigned int v11; // eax@14
|
|
2454 int v12; // [sp+1Ch] [bp-8h]@1
|
|
2455 int v13; // [sp+20h] [bp-4h]@6
|
|
2456
|
|
2457 v1 = this;
|
|
2458 v2 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2459 v3 = v1->b3DSoundInitialized == 0;
|
|
2460 v4 = v2;
|
|
2461 v12 = v2;
|
|
2462 if ( !v3 )
|
|
2463 {
|
|
2464 v5 = &v1->uNum3DSamples;
|
|
2465 AIL_3D_provider_attribute(v1->h3DSoundProvider, "Maximum supported samples", &v1->uNum3DSamples);
|
|
2466 if ( v1->uNum3DSamples > 32 )
|
|
2467 *v5 = 32;
|
|
2468 v6 = *v5;
|
|
2469 if ( !*v5 )
|
|
2470 {
|
|
2471 v1->b3DSoundInitialized = 0;
|
|
2472 return -1;
|
|
2473 }
|
|
2474 v13 = 0;
|
|
2475 if ( v6 > 0 )
|
|
2476 {
|
|
2477 v8 = v1->p3DSamples;
|
|
2478 while ( 1 )
|
|
2479 {
|
|
2480 v9 = (void *)AIL_allocate_3D_sample_handle(v1->h3DSoundProvider);
|
|
2481 v8->hSample = v9;
|
|
2482 if ( !v9 )
|
|
2483 break;
|
|
2484 AIL_set_3D_sample_float_distances(v9, 4096.0, 256.0, 4096.0, 256.0);
|
|
2485 AIL_set_3D_sample_volume(v8->hSample, v1->s3DSoundVolume);
|
|
2486 ++v13;
|
|
2487 ++v8;
|
|
2488 if ( v13 >= *v5 )
|
|
2489 goto LABEL_12;
|
|
2490 }
|
|
2491 *v5 = v13;
|
|
2492 LABEL_12:
|
|
2493 v4 = v12;
|
|
2494 }
|
|
2495 if ( v1->bEAXSupported )
|
|
2496 {
|
|
2497 v10 = v4;
|
|
2498 v11 = pMapStats->pInfos[v10].uEAXEnv;
|
|
2499 v12 = pMapStats->pInfos[v10].uEAXEnv;
|
|
2500 if ( v11 >= 0x1A )
|
|
2501 {
|
|
2502 pAudioPlayer->SetEAXPreferences();
|
|
2503 v1->field_214 = -1;
|
|
2504 }
|
|
2505 else
|
|
2506 {
|
|
2507 AIL_set_3D_provider_preference(v1->h3DSoundProvider, "EAX environment selection", &v12);
|
|
2508 v1->field_214 = v12;
|
|
2509 }
|
|
2510 }
|
|
2511 }
|
|
2512 return 1;
|
|
2513 }
|
|
2514
|
|
2515
|
|
2516 //----- (004A96BE) --------------------------------------------------------
|
|
2517 void ReleaseSoundData(void *_this)
|
|
2518 {
|
24
|
2519 int pID; // esi@1
|
0
|
2520 char *v2; // eax@1
|
|
2521
|
24
|
2522 pID = 0;
|
0
|
2523 v2 = (char *)&pSounds[0].pSoundData;
|
|
2524 while ( *(void **)v2 != _this )
|
|
2525 {
|
|
2526 v2 += 128;
|
24
|
2527 ++pID;
|
0
|
2528 if ( (signed int)v2 >= (signed int)&pAudioPlayer->p3DSamples[6].field_8 )
|
|
2529 return;
|
|
2530 }
|
|
2531 pAllocator->FreeChunk(_this);
|
24
|
2532 memset(&pSounds[pID], 0, 0x80u);
|
0
|
2533 }
|
|
2534
|
|
2535 //----- (004A96FF) --------------------------------------------------------
|
|
2536 SoundHeader *__fastcall FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName)
|
|
2537 {
|
|
2538 unsigned int v3; // ebx@1
|
|
2539 unsigned int v4; // esi@1
|
|
2540 SoundHeader *result; // eax@2
|
|
2541 signed int v6; // ebx@11
|
|
2542 int v7; // edi@13
|
|
2543 unsigned int v8; // esi@14
|
|
2544 unsigned int v9; // esi@20
|
|
2545 unsigned int v10; // [sp+Ch] [bp-4h]@1
|
|
2546
|
|
2547 v3 = uEnd;
|
|
2548 v10 = uEnd;
|
|
2549 v4 = uStart;
|
|
2550 while ( 1 )
|
|
2551 {
|
|
2552 v6 = v3 - v4;
|
|
2553 result = &pAudioPlayer->pSoundHeaders[v6 / 2 + v4];
|
|
2554 if ( !result )
|
|
2555 return result;
|
|
2556 result = (SoundHeader *)_strcmpi(pName, result->pSoundName);
|
|
2557 if ( !result )
|
|
2558 uFindSound_BinSearch_ResultID = v6 / 2 + v4;
|
|
2559 if ( v4 == v10 )
|
|
2560 goto LABEL_17;
|
|
2561 if ( (signed int)result < 0 )
|
|
2562 break;
|
|
2563 if ( v6 <= 4 )
|
|
2564 {
|
|
2565 v7 = v4;
|
|
2566 if ( (signed int)v4 < (signed int)v10 )
|
|
2567 {
|
|
2568 v9 = v4;
|
|
2569 do
|
|
2570 {
|
|
2571 result = (SoundHeader *)_strcmpi(pName, pAudioPlayer->pSoundHeaders[v9].pSoundName);
|
|
2572 if ( !result )
|
|
2573 goto LABEL_24;
|
|
2574 ++v7;
|
|
2575 ++v9;
|
|
2576 }
|
|
2577 while ( v7 < (signed int)v10 );
|
|
2578 }
|
|
2579 LABEL_17:
|
|
2580 uFindSound_BinSearch_ResultID = -1;
|
|
2581 return result;
|
|
2582 }
|
|
2583 v4 += v6 / 2;
|
|
2584 LABEL_10:
|
|
2585 v3 = v10;
|
|
2586 }
|
|
2587 if ( v6 > 4 )
|
|
2588 {
|
|
2589 v10 = v6 / 2 + v4;
|
|
2590 goto LABEL_10;
|
|
2591 }
|
|
2592 v7 = v4;
|
|
2593 if ( (signed int)v4 >= (signed int)v10 )
|
|
2594 goto LABEL_17;
|
|
2595 v8 = v4;
|
|
2596 while ( 1 )
|
|
2597 {
|
|
2598 result = (SoundHeader *)_strcmpi(pName, pAudioPlayer->pSoundHeaders[v8].pSoundName);
|
|
2599 if ( !result )
|
|
2600 break;
|
|
2601 ++v7;
|
|
2602 ++v8;
|
|
2603 if ( v7 >= (signed int)v10 )
|
|
2604 goto LABEL_17;
|
|
2605 }
|
|
2606 LABEL_24:
|
|
2607 uFindSound_BinSearch_ResultID = v7;
|
|
2608 return result;
|
|
2609 }
|
|
2610 // F1B4C8: using guessed type int uFindSound_BinSearch_ResultID;
|
|
2611
|
|
2612 //----- (004A97C6) --------------------------------------------------------
|
|
2613 SoundData *LoadSound(const char *pSoundName, SoundData *pOutBuff, unsigned int uID)
|
|
2614 {
|
|
2615 SoundData *v3; // edi@1
|
|
2616 int v4; // ecx@1
|
|
2617 //Sound *v5; // eax@1
|
|
2618 SoundHeader *v6; // esi@5
|
|
2619 unsigned int *pDecompressedSize; // ebx@5
|
|
2620 unsigned int v8; // eax@5
|
|
2621 unsigned int v9; // eax@7
|
|
2622 SoundData *result; // eax@9
|
|
2623 int v11; // esi@15
|
|
2624 int v12; // eax@15
|
|
2625 char *v13; // ecx@16
|
|
2626 int v14; // eax@19
|
|
2627 std::string v15; // [sp-18h] [bp-34h]@12
|
|
2628 const char *v16; // [sp-8h] [bp-24h]@12
|
|
2629 int v17; // [sp-4h] [bp-20h]@12
|
|
2630 char v18; // [sp+Ch] [bp-10h]@12
|
|
2631 int v19; // [sp+10h] [bp-Ch]@5
|
|
2632 DWORD NumberOfBytesRead; // [sp+14h] [bp-8h]@8
|
|
2633 const char *pSoundName_; // [sp+18h] [bp-4h]@1
|
|
2634
|
|
2635 pSoundName_ = pSoundName;
|
|
2636 v3 = pOutBuff;
|
|
2637 v4 = 0;
|
|
2638 for (uint i = 0; i < 3000; ++i)
|
|
2639 if (pSounds[i].uID == uID)
|
|
2640 return pSounds[i].pSoundData;
|
|
2641
|
|
2642 FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName_);
|
|
2643 if ( uFindSound_BinSearch_ResultID == -1 )
|
24
|
2644 {
|
|
2645 result = 0;
|
|
2646 return result;
|
|
2647 }
|
0
|
2648 v6 = &pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID];
|
|
2649 pDecompressedSize = &v6->uDecompressedSize;
|
|
2650 v8 = v6->uDecompressedSize;
|
|
2651 v19 = v6->uDecompressedSize;
|
|
2652 if ( v3 == (SoundData *)-1 )
|
|
2653 v3 = (SoundData *)pAllocator->AllocNamedChunk(0, v8 + 4, pSoundName_);
|
|
2654 SetFilePointer(pAudioPlayer->hAudioSnd, v6->uFileOffset, 0, 0);
|
|
2655 v9 = *pDecompressedSize;
|
|
2656 if ( (signed int)v6->uCompressedSize >= (signed int)*pDecompressedSize )
|
|
2657 {
|
|
2658 v6->uCompressedSize = v9;
|
|
2659 if ( v9 )
|
|
2660 {
|
|
2661 ReadFile(pAudioPlayer->hAudioSnd, (char *)v3 + 4, v9, &NumberOfBytesRead, 0);
|
|
2662 }
|
|
2663 else
|
|
2664 {
|
|
2665 MessageBoxW(nullptr, L"Can't load sound file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Sound.cpp:448", 0);
|
|
2666 }
|
|
2667 }
|
|
2668 else
|
|
2669 {
|
|
2670 uID = (unsigned int)malloc(v6->uCompressedSize);
|
|
2671 ReadFile(pAudioPlayer->hAudioSnd, (LPVOID)uID, v6->uCompressedSize, &NumberOfBytesRead, 0);
|
|
2672 zlib::MemUnzip((char *)v3 + 4, &v6->uDecompressedSize, (const void *)uID, v6->uCompressedSize);
|
|
2673 free((void *)uID);
|
|
2674 }
|
|
2675 if ( v3 )
|
|
2676 {
|
|
2677 v11 = v19;
|
|
2678 v12 = 0;
|
|
2679 *(int *)v3 = v19;
|
|
2680 uLastLoadedSoundID = 0;
|
|
2681 if ( pSounds[0].pSoundData )
|
|
2682 {
|
|
2683 v13 = (char *)&pSounds[0].pSoundData;
|
|
2684 do
|
|
2685 {
|
|
2686 v13 += 128;
|
|
2687 ++v12;
|
|
2688 }
|
|
2689 while ( *(int *)v13 );
|
|
2690 uLastLoadedSoundID = v12;
|
|
2691 }
|
24
|
2692 v16 = pSounds[v12].SoundName;
|
0
|
2693 strcpy((char *)v16, pSoundName_);
|
|
2694 v14 = uLastLoadedSoundID++ << 7;
|
|
2695 pSoundList->uTotalLoadedSoundSize += v11;
|
|
2696 pSounds[uLastLoadedSoundID].pSoundData = v3;
|
|
2697 result = v3;
|
|
2698 }
|
|
2699 else
|
|
2700 {
|
|
2701 result = 0;
|
|
2702 }
|
|
2703 return result;
|
|
2704 }
|