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