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