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
|
|
1741 //----- (004AB66C) --------------------------------------------------------
|
|
1742 int __fastcall sub_4AB66C(int a1, int a2)
|
|
1743 {
|
|
1744 signed int v2; // eax@1
|
|
1745
|
|
1746 v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.y)
|
147
|
1747 - stru_5C6E00->uIntegerHalfPi - pParty->sRotationY);
|
0
|
1748 if ( v2 > (signed int)stru_5C6E00->uIntegerPi )
|
|
1749 v2 = 2 * stru_5C6E00->uIntegerPi - v2;
|
|
1750 return (v2 >> 3) - (v2 >> 10);
|
|
1751 }
|
|
1752 // 4AB66C: using guessed type int __fastcall sub_4AB66C(int, int);
|
|
1753
|
|
1754 //----- (004AB6B1) --------------------------------------------------------
|
|
1755 int __fastcall GetSoundStrengthByDistanceFromParty(int a1, int a2, int a3)
|
|
1756 {
|
|
1757 int v3; // esi@1
|
|
1758 int v4; // edi@1
|
|
1759 int v5; // ST08_4@1
|
|
1760 int v6; // esi@1
|
|
1761 int v7; // eax@1
|
|
1762 int v9; // [sp+10h] [bp+8h]@1
|
|
1763
|
|
1764 v3 = a2;
|
|
1765 v4 = a1;
|
|
1766 v5 = abs(a3 - pParty->vPosition.z);
|
|
1767 v6 = abs(v3 - pParty->vPosition.y);
|
|
1768 v7 = abs(v4 - pParty->vPosition.x);
|
322
|
1769 v9 = int_get_vector_length(v7, v6, v5);
|
0
|
1770 if ( v9 <= 8192 )
|
322
|
1771 return 114 - (unsigned __int64)(signed __int64)((double)v9 * 0.0001220703125 * 100.0);
|
0
|
1772 else
|
322
|
1773 return 0;
|
0
|
1774 }
|
|
1775
|
|
1776
|
|
1777
|
|
1778 //----- (004AB71F) --------------------------------------------------------
|
|
1779 void AudioPlayer::StopChannels(int uStartChannel, int uEndChannel)
|
|
1780 {
|
|
1781 //AudioPlayer *v3; // esi@1
|
|
1782 int v4; // ecx@1
|
82
|
1783 AudioPlayer_3DSample *v5; // edi@4
|
0
|
1784 int v6; // ebx@12
|
|
1785 MixerChannel *pChannel; // edi@14
|
|
1786 //_STREAM *v8; // esi@23
|
|
1787 int v9; // [sp+4h] [bp-4h]@3
|
|
1788
|
|
1789 //v3 = this;
|
|
1790 v4 = 0;
|
|
1791 if ( bPlayerReady )
|
|
1792 {
|
|
1793 if ( b3DSoundInitialized )
|
|
1794 {
|
|
1795 v9 = 0;
|
|
1796 if ( uNum3DSamples > 0 )
|
|
1797 {
|
82
|
1798 v5 = p3DSamples;//;(char *)&p3DSamples[0].field_8;
|
0
|
1799 do
|
|
1800 {
|
|
1801 if ( (uStartChannel == -1 || v4 < uStartChannel || v4 > uEndChannel)
|
82
|
1802 && v5->field_8
|
|
1803 && pSoundList->pSounds[v5->field_8].eType != SOUND_DESC_SYSTEM)
|
0
|
1804 {
|
82
|
1805 AIL_end_3D_sample(v5->hSample);
|
|
1806 _4ABF23(v5);
|
|
1807 v5->field_4 = 0;
|
0
|
1808 v4 = v9;
|
|
1809 }
|
|
1810 ++v4;
|
|
1811 v5 += 16;
|
|
1812 v9 = v4;
|
|
1813 }
|
|
1814 while ( v4 < uNum3DSamples );
|
|
1815 }
|
|
1816 }
|
|
1817 v6 = 0;
|
|
1818 if ( hDigDriver && uMixerChannels > 0 )
|
|
1819 {
|
|
1820 pChannel = pMixerChannels;
|
|
1821 do
|
|
1822 {
|
|
1823 if ( (uStartChannel == -1 || v6 < uStartChannel || v6 > uEndChannel)
|
|
1824 && pSoundList->pSounds[pChannel->uSourceTrackIdx].eType != SOUND_DESC_SYSTEM)
|
|
1825 {
|
|
1826 AIL_end_sample(pChannel->hSample);
|
|
1827 _4ABE55(pChannel);
|
|
1828 pChannel->dword_000004 = 0;
|
|
1829 }
|
|
1830 ++v6;
|
|
1831 ++pChannel;
|
|
1832 }
|
|
1833 while (v6 < uMixerChannels);
|
|
1834 }
|
|
1835 if (hSequence)
|
|
1836 AIL_end_sequence(hSequence);
|
|
1837 //v8 = hStream;
|
|
1838 if (hStream)
|
|
1839 AIL_pause_stream(hStream, 1);
|
|
1840 }
|
|
1841 }
|
|
1842
|
|
1843
|
|
1844 //----- (004AB818) --------------------------------------------------------
|
|
1845 void AudioPlayer::LoadAudioSnd()
|
|
1846 {
|
|
1847 DWORD NumberOfBytesRead; // [sp+Ch] [bp-4h]@3
|
|
1848
|
|
1849 hAudioSnd = CreateFileA("Sounds\\Audio.snd", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
|
|
1850 if (hAudioSnd == INVALID_HANDLE_VALUE)
|
|
1851 {
|
|
1852 Log::Warning(L"Can't open file: %s", L"Sounds\\Audio.snd");
|
|
1853 return;
|
|
1854 }
|
|
1855
|
|
1856 ReadFile(hAudioSnd, &uNumSoundHeaders, 4u, &NumberOfBytesRead, 0);
|
|
1857 pSoundHeaders = nullptr;
|
|
1858 pSoundHeaders = (SoundHeader *)pAllocator->AllocNamedChunk(0, 52 * uNumSoundHeaders + 2, 0);
|
|
1859 ReadFile(hAudioSnd, pSoundHeaders, 52 * uNumSoundHeaders, &NumberOfBytesRead, 0);
|
|
1860 }
|
|
1861
|
|
1862 //----- (004AB8CE) --------------------------------------------------------
|
|
1863 void AudioPlayer::Initialize(HWND hWnd)
|
|
1864 {
|
|
1865 //AudioPlayer *v2; // esi@1
|
|
1866 int v3; // ebx@1
|
|
1867 //_DIG_DRIVER *v4; // eax@1
|
|
1868 char v5; // dl@5
|
|
1869 _PROVIDER *v6; // eax@9
|
|
1870 HWND v7; // ST00_4@9
|
|
1871 MixerChannel *pChannel; // edi@14
|
|
1872 _SAMPLE *v9; // eax@15
|
|
1873 //_REDBOOK *v10; // eax@19
|
|
1874 //int v11; // ecx@21
|
|
1875 int v12; // [sp+Ch] [bp-Ch]@9
|
|
1876 char *Str1; // [sp+10h] [bp-8h]@6
|
|
1877 int v14; // [sp+14h] [bp-4h]@5
|
|
1878
|
|
1879 //v2 = this;
|
|
1880 v3 = 0;
|
|
1881 this->hWindow = hWnd;
|
|
1882 this->hAILRedbook = 0;
|
|
1883 this->hDigDriver = 0;
|
|
1884 this->dword_0002AC = 0;
|
|
1885 this->hSequence = 0;
|
|
1886 this->uMasterVolume = 127;
|
|
1887 this->dword_0002C8 = 64;
|
|
1888 this->dword_0002CC = 2;
|
|
1889
|
|
1890 MSS32_DLL_Initialize();
|
|
1891 BINKW32_DLL_Initialize();
|
|
1892 SMACKW32_DLL_Initialize();
|
|
1893
|
|
1894 AIL_startup();
|
|
1895 if (bCanLoadFromCD)
|
|
1896 hAILRedbook = AIL_redbook_open_drive(cMM7GameCDDriveLetter/*cGameCDDriveLetter*/);
|
|
1897 //else
|
|
1898 // hAILRedbook = AIL_redbook_open(0);
|
|
1899 //v4 = Audio_GetFirstHardwareDigitalDriver();
|
|
1900
|
|
1901 hDigDriver = Audio_GetFirstHardwareDigitalDriver();
|
|
1902 if ( hDigDriver )
|
|
1903 SmackSoundUseMSS(hDigDriver);
|
|
1904 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 && pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT )
|
|
1905 {
|
|
1906 v14 = 0;
|
|
1907 bEAXSupported = 0;
|
|
1908 b3DSoundInitialized = 0;
|
|
1909 ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128u, "NONE");
|
|
1910 CheckA3DSupport(v5);
|
|
1911 while ( AIL_enumerate_3D_providers(&v14, (HPROVIDER *)&hWnd, &Str1) )
|
|
1912 {
|
|
1913 if ( !strcmp(Str1, p3DSoundProvider) )
|
|
1914 {
|
|
1915 if ( AIL_open_3D_provider((HPROVIDER)hWnd) )
|
|
1916 {
|
|
1917 bEAXSupported = 0;
|
|
1918 b3DSoundInitialized = 0;
|
|
1919 h3DSoundProvider = 0;
|
|
1920 }
|
|
1921 else
|
|
1922 {
|
|
1923 v6 = (_PROVIDER *)hWnd;
|
|
1924 v7 = hWnd;
|
|
1925 b3DSoundInitialized = 1;
|
|
1926 h3DSoundProvider = v6;
|
|
1927 uNum3DSamples = 4;
|
|
1928 AIL_3D_provider_attribute((HPROVIDER)v7, "EAX environment selection", &v12);
|
|
1929 if ( v12 != -1 )
|
|
1930 bEAXSupported = 1;
|
|
1931 }
|
|
1932 pAudioPlayer->_4AC0A2();
|
|
1933 break;
|
|
1934 }
|
|
1935 }
|
|
1936 }
|
|
1937 if ( uMixerChannels > 0 )
|
|
1938 {
|
|
1939 pChannel = pMixerChannels;
|
|
1940 do
|
|
1941 {
|
|
1942 v9 = AIL_allocate_sample_handle(hDigDriver);
|
|
1943 pChannel->hSample = v9;
|
|
1944 if ( !v9 )
|
|
1945 break;
|
|
1946 ++v3;
|
|
1947 ++pChannel;
|
|
1948 }
|
|
1949 while ( v3 < uMixerChannels );
|
|
1950 }
|
|
1951 uMixerChannels = v3;
|
|
1952 if ( bPlayerReady )
|
|
1953 StopChannels(-1, -1);
|
|
1954 //v10 = hAILRedbook;
|
|
1955 bPlayerReady = true;
|
|
1956 if ( hAILRedbook )
|
|
1957 {
|
|
1958 AIL_redbook_stop(hAILRedbook);
|
|
1959 uNumRedbookTracks = AIL_redbook_tracks(hAILRedbook);
|
|
1960 }
|
|
1961 pAudioPlayer->sRedbookVolume = AIL_redbook_volume(hAILRedbook);
|
328
|
1962 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
|
0
|
1963 if ( bPlayerReady && hAILRedbook )
|
328
|
1964 AIL_redbook_set_volume(hAILRedbook, (unsigned __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f) >> 32);
|
0
|
1965 LoadAudioSnd();
|
|
1966 }
|
|
1967
|
|
1968 //----- (004ABAF7) --------------------------------------------------------
|
|
1969 _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void)
|
|
1970 {
|
|
1971 int v0; // ecx@1
|
|
1972 unsigned int v1; // ebp@2
|
|
1973 size_t v2; // eax@4
|
|
1974 signed int v3; // kr14_4@9
|
|
1975 char *v5; // [sp+10h] [bp-Ch]@2
|
|
1976 unsigned int v6; // [sp+14h] [bp-8h]@1
|
|
1977 _DIG_DRIVER *hDrv; // [sp+18h] [bp-4h]@3
|
|
1978
|
|
1979 static int dword_4F00DC = 22050;
|
|
1980 static int dword_4F00E0 = 16;
|
|
1981 static int dword_4F00E4 = 2;
|
|
1982
|
|
1983 AIL_set_preference(15, 0);
|
|
1984 AIL_set_preference(33, 1);
|
|
1985 v0 = dword_4F00DC;
|
|
1986 pAudioPlayer->pDeviceNames[0][0] = 0;
|
|
1987 pAudioPlayer->uNumDevices = 0;
|
|
1988 v6 = 0;
|
|
1989
|
|
1990 if ( dword_4F00DC < 11025 )
|
|
1991 return 0;
|
|
1992 v1 = 0;
|
|
1993 v5 = (char *)pAudioPlayer->array_000BF0;
|
|
1994 while ( 1 )
|
|
1995 {
|
|
1996 while ( 1 )
|
|
1997 {
|
|
1998 pcmWaveFormat.wf.wFormatTag = 1;
|
|
1999 pcmWaveFormat.wf.nChannels = dword_4F00E4;
|
|
2000 pcmWaveFormat.wf.nSamplesPerSec = v0;
|
|
2001 pcmWaveFormat.wf.nBlockAlign = dword_4F00E4 * dword_4F00E0 / 8;
|
|
2002 pcmWaveFormat.wBitsPerSample = dword_4F00E0;
|
|
2003 pcmWaveFormat.wf.nAvgBytesPerSec = v0 * dword_4F00E4 * dword_4F00E0 / 8;
|
|
2004 if ( !AIL_waveOutOpen(&hDrv, 0, -1, &pcmWaveFormat.wf) )
|
|
2005 break;
|
|
2006 if ( !AIL_get_preference(15) )
|
|
2007 goto LABEL_8;
|
|
2008 v3 = dword_4F00DC;
|
|
2009 v0 = dword_4F00DC / 2;
|
|
2010 dword_4F00DC /= 2;
|
|
2011 if ( v3 / 2 < 11025 )
|
|
2012 {
|
|
2013 if ( dword_4F00E0 == 8 )
|
|
2014 {
|
|
2015 v0 = 22050;
|
|
2016 dword_4F00E0 = 8;
|
|
2017 dword_4F00DC = 22050;
|
|
2018 }
|
|
2019 goto LABEL_12;
|
|
2020 }
|
|
2021 }
|
|
2022 strcpy(pAudioPlayer->pDeviceNames[v1 / 8], "Device: ");
|
|
2023 v2 = strlen(pAudioPlayer->pDeviceNames[v1 / 8]);
|
|
2024 AIL_digital_configuration(hDrv, (int *)v5, (int *)(v5 + 64), (char *)pAudioPlayer->pDeviceNames + v2 + v1 * 16);
|
|
2025 ++v6;
|
|
2026 v1 += 8;
|
|
2027 v5 += 4;
|
|
2028 pAudioPlayer->uNumDevices = v6;
|
|
2029 if ( AIL_get_preference(15) )
|
|
2030 return hDrv;
|
|
2031 if ( !strstr(pAudioPlayer->pDeviceNames[v1 / 8 - 1], "Emulated") )
|
|
2032 return hDrv;
|
|
2033 AIL_waveOutClose(hDrv);
|
|
2034 AIL_set_preference(15, 1);
|
|
2035 LABEL_8:
|
|
2036 AIL_set_preference(15, 1);
|
|
2037 v0 = dword_4F00DC;
|
|
2038 LABEL_12:
|
|
2039 if ( v0 < 11025 )
|
|
2040 return 0;
|
|
2041 }
|
|
2042 }
|
|
2043
|
|
2044
|
|
2045 //----- (004ABC9B) --------------------------------------------------------
|
|
2046 LSTATUS AudioPlayer::CheckA3DSupport(char a2)
|
|
2047 {
|
|
2048 LSTATUS result; // eax@1
|
|
2049 DWORD cbData; // [sp+8h] [bp-Ch]@1
|
|
2050 int Data; // [sp+Ch] [bp-8h]@1
|
|
2051 HKEY hKey; // [sp+10h] [bp-4h]@1
|
|
2052 char v6; // [sp+1Ch] [bp+8h]@0
|
222
|
2053 v6=0; //to fix
|
0
|
2054 hKey = 0;
|
|
2055 cbData = 4;
|
|
2056 Data = 0;
|
|
2057 result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Aureal\\A3D", 0, 0x2001Fu, &hKey);
|
|
2058 if ( !result )
|
|
2059 {
|
|
2060 if ( v6 )
|
|
2061 RegQueryValueExA(hKey, "SplashAudio", 0, 0, (LPBYTE)&Aureal3D_SplashAudio, &cbData);
|
|
2062 else
|
|
2063 Data = Aureal3D_SplashAudio;
|
|
2064 RegSetValueExA(hKey, "SplashAudio", 0, 4u, (const BYTE *)&Data, 4u);
|
|
2065 Data = 0;
|
|
2066 if ( v6 )
|
|
2067 RegQueryValueExA(hKey, "SplashScreen", 0, 0, (LPBYTE)&Aureal3D_SplashScreen, &cbData);
|
|
2068 else
|
|
2069 Data = Aureal3D_SplashScreen;
|
|
2070 RegSetValueExA(hKey, "SplashScreen", 0, 4u, (const BYTE *)&Data, 4u);
|
|
2071 result = RegCloseKey(hKey);
|
|
2072 }
|
|
2073 return result;
|
|
2074 }
|
|
2075 // 4ABC9B: inconsistent function type and number of purged bytes
|
|
2076
|
|
2077 //----- (004ABD5B) --------------------------------------------------------
|
4
|
2078 void AudioPlayer::Release() //Освободить
|
0
|
2079 {
|
4
|
2080 AudioPlayer *pAudioPlayer; // esi@1
|
0
|
2081 int v2; // edi@1
|
4
|
2082 MixerChannel *pMixerChannel; // ebx@3
|
0
|
2083 char v4; // dl@5
|
|
2084 int v5; // ebx@6
|
4
|
2085 AudioPlayer_3DSample *p3DSample; // edi@7
|
24
|
2086 //int v7; // edx@14
|
0
|
2087 int v8; // ecx@14
|
|
2088 void *v9; // ecx@15
|
|
2089
|
4
|
2090 pAudioPlayer = this;
|
0
|
2091 v2 = 0;
|
|
2092 if ( this->bPlayerReady )
|
|
2093 {
|
|
2094 CloseHandle(pVideoPlayer->hMagicVid);
|
|
2095 CloseHandle(pVideoPlayer->hMightVid);
|
4
|
2096 pAudioPlayer->StopChannels(-1, -1);
|
|
2097 if ( pAudioPlayer->uMixerChannels > 0 )
|
0
|
2098 {
|
4
|
2099 pMixerChannel = pAudioPlayer->pMixerChannels;
|
0
|
2100 do
|
|
2101 {
|
4
|
2102 AIL_release_sample_handle(pMixerChannel->hSample);
|
0
|
2103 ++v2;
|
4
|
2104 ++pMixerChannel;
|
0
|
2105 }
|
4
|
2106 while ( v2 < pAudioPlayer->uMixerChannels );
|
0
|
2107 }
|
|
2108 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 )
|
|
2109 {
|
|
2110 v5 = 0;
|
24
|
2111 pAudioPlayer->CheckA3DSupport(0);// pAudioPlayer->CheckA3DSupport(v4);
|
4
|
2112 if ( pAudioPlayer->uNum3DSamples > 0 )
|
0
|
2113 {
|
4
|
2114 p3DSample = pAudioPlayer->p3DSamples;
|
0
|
2115 do
|
|
2116 {
|
4
|
2117 if ( p3DSample->hSample )
|
0
|
2118 {
|
4
|
2119 AIL_release_3D_sample_handle(p3DSample->hSample);
|
|
2120 p3DSample->hSample = 0;
|
0
|
2121 }
|
|
2122 ++v5;
|
4
|
2123 ++p3DSample;
|
0
|
2124 }
|
4
|
2125 while ( v5 < pAudioPlayer->uNum3DSamples );
|
0
|
2126 }
|
4
|
2127 if ( pAudioPlayer->h3DSoundProvider )
|
0
|
2128 {
|
4
|
2129 AIL_close_3D_provider(pAudioPlayer->h3DSoundProvider);
|
|
2130 pAudioPlayer->h3DSoundProvider = 0;
|
0
|
2131 }
|
|
2132 }
|
24
|
2133 v8 = (int)&pAudioPlayer->hAILRedbook;
|
4
|
2134 if ( pAudioPlayer->hAILRedbook )
|
0
|
2135 {
|
4
|
2136 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
|
24
|
2137 AIL_redbook_set_volume((HREDBOOK)v8, pAudioPlayer->sRedbookVolume);
|
4
|
2138 AIL_redbook_close(pAudioPlayer->hAILRedbook);
|
0
|
2139 }
|
|
2140 AIL_shutdown();
|
|
2141 pSoundList->Release();
|
4
|
2142 v9 = *(void **)&pAudioPlayer->field_C78[0];
|
0
|
2143 if ( v9 )
|
|
2144 ReleaseSoundData(v9);
|
4
|
2145 CloseHandle(pAudioPlayer->hAudioSnd);
|
0
|
2146 }
|
|
2147 }
|
|
2148
|
|
2149 //----- (004ABE55) --------------------------------------------------------
|
|
2150 void AudioPlayer::_4ABE55(MixerChannel *pChannel)
|
|
2151 {
|
|
2152 int v2; // ebx@1
|
|
2153 //AudioPlayer *v3; // esi@1
|
|
2154 SoundDesc *v4; // eax@2
|
|
2155 unsigned __int8 v5; // zf@5
|
|
2156 unsigned __int8 v6; // sf@5
|
|
2157 char *v7; // edi@6
|
|
2158 int v8; // eax@8
|
|
2159 int v9; // ST04_4@8
|
|
2160 int v10; // ecx@12
|
|
2161 int v11; // edi@13
|
|
2162 int v12; // eax@13
|
|
2163 unsigned __int8 v13; // of@13
|
|
2164 int v14[16]; // [sp+Ch] [bp-48h]@8
|
|
2165 int v15; // [sp+4Ch] [bp-8h]@5
|
|
2166 int v16; // [sp+50h] [bp-4h]@5
|
|
2167
|
|
2168 v2 = 0;
|
|
2169 //v3 = this;
|
|
2170 if ( pSoundList->pSounds )
|
|
2171 {
|
|
2172 v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx];
|
|
2173 if ( v4->eType == SOUND_DESC_SWAP)
|
|
2174 {
|
|
2175 if ( v4->pSoundData[0] && !(v4->uFlags & 1) )
|
|
2176 {
|
|
2177 v5 = this->uMixerChannels == 0;
|
|
2178 v6 = this->uMixerChannels < 0;
|
|
2179 v15 = 0;
|
|
2180 v16 = 0;
|
|
2181 if ( v6 | v5 )
|
|
2182 goto LABEL_16;
|
|
2183 v7 = (char *)this->pMixerChannels;
|
|
2184 do
|
|
2185 {
|
|
2186 if ( pChannel->uSourceTrackID == *((int *)v7 + 3) )
|
|
2187 {
|
|
2188 v8 = v16;
|
|
2189 v9 = *(int *)v7;
|
|
2190 ++v16;
|
|
2191 v14[v8] = v2;
|
|
2192 if ( AIL_sample_status((HSAMPLE)v9) == 4 )
|
|
2193 ++v15;
|
|
2194 }
|
|
2195 ++v2;
|
|
2196 v7 += 16;
|
|
2197 }
|
|
2198 while ( v2 < uMixerChannels );
|
|
2199 if ( !v15 )
|
|
2200 {
|
|
2201 LABEL_16:
|
|
2202 pSoundList->_4A9DCD(pChannel->uSourceTrackIdx, 1);
|
|
2203 v10 = 0;
|
|
2204 if ( v16 > 0 )
|
|
2205 {
|
|
2206 do
|
|
2207 {
|
|
2208 v11 = v14[v10];
|
|
2209 v12 = 16 * (v14[v10++] + 47);
|
|
2210 pMixerChannels[v11].uSourceTrackID = 0;
|
|
2211 v13 = __OFSUB__(v10, v16);
|
|
2212 v6 = v10 - v16 < 0;
|
|
2213 *(unsigned int *)((char *)&bEAXSupported + v12) = 0;
|
|
2214 }
|
|
2215 while ( v6 ^ v13 );
|
|
2216 }
|
|
2217 }
|
|
2218 }
|
|
2219 }
|
|
2220 }
|
|
2221 }
|
|
2222 // 4D82F8: using guessed type int __stdcall AIL_sample_status(int);
|
|
2223 // 4ABE55: using guessed type int var_48[16];
|
|
2224
|
|
2225
|
|
2226
|
|
2227 //----- (004AAEA6) --------------------------------------------------------
|
|
2228 int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1)
|
|
2229 {
|
|
2230 double v1; // st7@1
|
|
2231 double v2; // st6@1
|
|
2232 int result; // eax@1
|
|
2233 double v4; // st5@2
|
|
2234 double v5; // st4@3
|
|
2235 double v6; // st3@3
|
|
2236 double v7; // st7@6
|
|
2237 double v8; // st6@7
|
|
2238 float v9; // [sp+0h] [bp-10h]@1
|
|
2239 float v10; // [sp+4h] [bp-Ch]@1
|
|
2240 float v11; // [sp+8h] [bp-8h]@2
|
|
2241 float v12; // [sp+8h] [bp-8h]@6
|
|
2242 float v13; // [sp+Ch] [bp-4h]@2
|
|
2243 float v14; // [sp+Ch] [bp-4h]@6
|
|
2244
|
|
2245 v1 = pBLVRenderParams->fCosineNegX;
|
|
2246 v2 = pBLVRenderParams->fSineNegX;
|
|
2247 v9 = pBLVRenderParams->fCosineY;
|
|
2248 v10 = pBLVRenderParams->fSineY;
|
|
2249 result = 0;
|
|
2250 if ( pBLVRenderParams->sPartyRotX )
|
|
2251 {
|
|
2252 v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
|
|
2253 v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
|
|
2254 v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
|
|
2255 if ( pRenderer->pRenderD3D )
|
|
2256 {
|
|
2257 v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY;
|
|
2258 v6 = v13 * pBLVRenderParams->fSineY - v11 * pBLVRenderParams->fCosineY;
|
|
2259 }
|
|
2260 else
|
|
2261 {
|
|
2262 v5 = v13 * pBLVRenderParams->fCosineY - v11 * pBLVRenderParams->fSineY;
|
|
2263 v6 = v13 * pBLVRenderParams->fSineY + v11 * pBLVRenderParams->fCosineY;
|
|
2264 }
|
|
2265 a1->vWorldViewPosition.x = v5 * v1 - v4 * v2;
|
|
2266 a1->vWorldViewPosition.y = v6;
|
|
2267 a1->vWorldViewPosition.z = v5 * v2 + v4 * v1;
|
|
2268 }
|
|
2269 else
|
|
2270 {
|
|
2271 v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
|
|
2272 v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
|
|
2273 v7 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
|
|
2274 if ( pRenderer->pRenderD3D )
|
|
2275 {
|
|
2276 a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY;
|
|
2277 v8 = v14 * v10 - v12 * v9;
|
|
2278 }
|
|
2279 else
|
|
2280 {
|
|
2281 a1->vWorldViewPosition.x = v14 * pBLVRenderParams->fCosineY - v12 * pBLVRenderParams->fSineY;
|
|
2282 v8 = v14 * v10 + v12 * v9;
|
|
2283 }
|
|
2284 a1->vWorldViewPosition.y = v8;
|
|
2285 a1->vWorldViewPosition.z = v7;
|
|
2286 }
|
|
2287 return result;
|
|
2288 }
|
|
2289
|
|
2290
|
|
2291
|
|
2292
|
|
2293 //----- (004ABF23) --------------------------------------------------------
|
|
2294 void AudioPlayer::_4ABF23(AudioPlayer_3DSample *a2)
|
|
2295 {
|
|
2296 int v2; // ebx@1
|
|
2297 //AudioPlayer *v3; // esi@1
|
|
2298 SoundDesc *v4; // eax@2
|
|
2299 unsigned __int8 v5; // zf@5
|
|
2300 unsigned __int8 v6; // sf@5
|
|
2301 char *v7; // edi@6
|
|
2302 int v8; // eax@8
|
|
2303 int v9; // ST04_4@8
|
|
2304 int v10; // ecx@12
|
|
2305 int v11; // eax@13
|
|
2306 unsigned __int8 v12; // of@13
|
|
2307 int v13[16]; // [sp+Ch] [bp-48h]@8
|
|
2308 int v14; // [sp+4Ch] [bp-8h]@5
|
|
2309 int v15; // [sp+50h] [bp-4h]@5
|
|
2310
|
|
2311 v2 = 0;
|
|
2312 //v3 = this;
|
|
2313 if ( pSoundList->pSounds )
|
|
2314 {
|
|
2315 v4 = &pSoundList->pSounds[a2->field_8];
|
|
2316 if ( v4->eType == SOUND_DESC_SWAP)
|
|
2317 {
|
|
2318 if ( v4->p3DSound && !(v4->uFlags & 1) )
|
|
2319 {
|
|
2320 v5 = this->uNum3DSamples == 0;
|
|
2321 v6 = this->uNum3DSamples < 0;
|
|
2322 v14 = 0;
|
|
2323 v15 = 0;
|
|
2324 if ( v6 | v5 )
|
|
2325 goto LABEL_16;
|
|
2326 v7 = (char *)this->p3DSamples;
|
|
2327 do
|
|
2328 {
|
|
2329 if ( a2->field_C == *((int *)v7 + 3) )
|
|
2330 {
|
|
2331 v8 = v15;
|
|
2332 v9 = *(int *)v7;
|
|
2333 ++v15;
|
|
2334 v13[v8] = v2;
|
|
2335 if ( AIL_3D_sample_status((void *)v9) == 4 )
|
|
2336 ++v14;
|
|
2337 }
|
|
2338 ++v2;
|
|
2339 v7 += 16;
|
|
2340 }
|
|
2341 while ( v2 < uNum3DSamples );
|
|
2342 if ( !v14 )
|
|
2343 {
|
|
2344 LABEL_16:
|
|
2345 pSoundList->_4A9DCD(a2->field_8, 1);
|
|
2346 v10 = 0;
|
|
2347 if ( v15 > 0 )
|
|
2348 {
|
|
2349 do
|
|
2350 {
|
|
2351 v11 = v13[v10++];
|
|
2352 *(&bEAXSupported + 4 * (v11 + 2)) = 0;
|
|
2353 v12 = __OFSUB__(v10, v15);
|
|
2354 v6 = v10 - v15 < 0;
|
|
2355 p3DSamples[v11].field_8 = 0;
|
|
2356 }
|
|
2357 while ( v6 ^ v12 );
|
|
2358 }
|
|
2359 }
|
|
2360 }
|
|
2361 }
|
|
2362 }
|
|
2363 }
|
|
2364 // 4D82F4: using guessed type int __stdcall AIL_3D_sample_status(int);
|
|
2365 // 4ABF23: using guessed type int var_48[16];
|
|
2366
|
|
2367 //----- (004ABFDB) --------------------------------------------------------
|
|
2368 void __cdecl PlayLevelMusic()
|
|
2369 {
|
|
2370 unsigned int v0; // eax@1
|
|
2371
|
|
2372 v0 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2373 if ( v0 )
|
|
2374 pAudioPlayer->PlayMusicTrack((MusicID)pMapStats->pInfos[v0].uRedbookTrackID);
|
|
2375 }
|
|
2376
|
|
2377 //----- (004AC004) --------------------------------------------------------
|
|
2378 void AudioPlayer::SetEAXPreferences()
|
|
2379 {
|
|
2380 AudioPlayer *v1; // edi@1
|
|
2381 _PROVIDER *v2; // ST00_4@2
|
|
2382 _PROVIDER *v3; // ST00_4@2
|
|
2383 float v4; // [sp+4h] [bp-4h]@2
|
|
2384
|
|
2385 v1 = this;
|
|
2386 if ( this->bEAXSupported )
|
|
2387 {
|
|
2388 v2 = this->h3DSoundProvider;
|
|
2389 v4 = 0.0;
|
|
2390 AIL_set_3D_provider_preference(v2, "EAX effect volume", (int *)&v4);
|
|
2391 v3 = v1->h3DSoundProvider;
|
|
2392 v4 = 1.0;
|
|
2393 AIL_set_3D_provider_preference(v3, "EAX damping", (int *)&v4);
|
|
2394 }
|
|
2395 }
|
|
2396 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int);
|
|
2397
|
|
2398 //----- (004AC041) --------------------------------------------------------
|
|
2399 void AudioPlayer::SetMapEAX()
|
|
2400 {
|
|
2401 AudioPlayer *v1; // esi@1
|
|
2402 unsigned int v2; // eax@1
|
|
2403 int v3; // [sp+4h] [bp-4h]@3
|
|
2404
|
|
2405 v1 = this;
|
|
2406 v2 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2407 if ( v1->b3DSoundInitialized && v1->bEAXSupported )
|
|
2408 {
|
|
2409 v3 = pMapStats->pInfos[v2].uEAXEnv;
|
|
2410 if ( (unsigned int)v3 >= 0x1A )
|
|
2411 {
|
|
2412 SetEAXPreferences();
|
|
2413 v1->field_214 = -1;
|
|
2414 }
|
|
2415 else
|
|
2416 {
|
|
2417 AIL_set_3D_provider_preference(v1->h3DSoundProvider, "EAX environment selection", &v3);
|
|
2418 v1->field_214 = v3;
|
|
2419 }
|
|
2420 }
|
|
2421 }
|
|
2422 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int);
|
|
2423
|
|
2424 //----- (004AC0A2) --------------------------------------------------------
|
|
2425 int AudioPlayer::_4AC0A2()
|
|
2426 {
|
|
2427 AudioPlayer *v1; // esi@1
|
|
2428 unsigned int v2; // eax@1
|
|
2429 char v3; // zf@1
|
|
2430 int v4; // ebx@1
|
|
2431 int *v5; // edi@2
|
|
2432 int v6; // eax@4
|
|
2433 AudioPlayer_3DSample *v8; // ebx@7
|
|
2434 void *v9; // eax@8
|
|
2435 int v10; // ebx@14
|
|
2436 unsigned int v11; // eax@14
|
|
2437 int v12; // [sp+1Ch] [bp-8h]@1
|
|
2438 int v13; // [sp+20h] [bp-4h]@6
|
|
2439
|
|
2440 v1 = this;
|
|
2441 v2 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2442 v3 = v1->b3DSoundInitialized == 0;
|
|
2443 v4 = v2;
|
|
2444 v12 = v2;
|
|
2445 if ( !v3 )
|
|
2446 {
|
|
2447 v5 = &v1->uNum3DSamples;
|
|
2448 AIL_3D_provider_attribute(v1->h3DSoundProvider, "Maximum supported samples", &v1->uNum3DSamples);
|
|
2449 if ( v1->uNum3DSamples > 32 )
|
|
2450 *v5 = 32;
|
|
2451 v6 = *v5;
|
|
2452 if ( !*v5 )
|
|
2453 {
|
|
2454 v1->b3DSoundInitialized = 0;
|
|
2455 return -1;
|
|
2456 }
|
|
2457 v13 = 0;
|
|
2458 if ( v6 > 0 )
|
|
2459 {
|
|
2460 v8 = v1->p3DSamples;
|
|
2461 while ( 1 )
|
|
2462 {
|
|
2463 v9 = (void *)AIL_allocate_3D_sample_handle(v1->h3DSoundProvider);
|
|
2464 v8->hSample = v9;
|
|
2465 if ( !v9 )
|
|
2466 break;
|
|
2467 AIL_set_3D_sample_float_distances(v9, 4096.0, 256.0, 4096.0, 256.0);
|
|
2468 AIL_set_3D_sample_volume(v8->hSample, v1->s3DSoundVolume);
|
|
2469 ++v13;
|
|
2470 ++v8;
|
|
2471 if ( v13 >= *v5 )
|
|
2472 goto LABEL_12;
|
|
2473 }
|
|
2474 *v5 = v13;
|
|
2475 LABEL_12:
|
|
2476 v4 = v12;
|
|
2477 }
|
|
2478 if ( v1->bEAXSupported )
|
|
2479 {
|
|
2480 v10 = v4;
|
|
2481 v11 = pMapStats->pInfos[v10].uEAXEnv;
|
|
2482 v12 = pMapStats->pInfos[v10].uEAXEnv;
|
|
2483 if ( v11 >= 0x1A )
|
|
2484 {
|
|
2485 pAudioPlayer->SetEAXPreferences();
|
|
2486 v1->field_214 = -1;
|
|
2487 }
|
|
2488 else
|
|
2489 {
|
|
2490 AIL_set_3D_provider_preference(v1->h3DSoundProvider, "EAX environment selection", &v12);
|
|
2491 v1->field_214 = v12;
|
|
2492 }
|
|
2493 }
|
|
2494 }
|
|
2495 return 1;
|
|
2496 }
|
|
2497
|
|
2498
|
|
2499 //----- (004A96BE) --------------------------------------------------------
|
|
2500 void ReleaseSoundData(void *_this)
|
|
2501 {
|
24
|
2502 int pID; // esi@1
|
0
|
2503 char *v2; // eax@1
|
|
2504
|
24
|
2505 pID = 0;
|
0
|
2506 v2 = (char *)&pSounds[0].pSoundData;
|
|
2507 while ( *(void **)v2 != _this )
|
|
2508 {
|
|
2509 v2 += 128;
|
24
|
2510 ++pID;
|
28
|
2511 if ( v2 > (void *)&pSounds[2999].pSoundData)//(signed int)&pAudioPlayer->p3DSamples[6].field_8 )
|
0
|
2512 return;
|
|
2513 }
|
|
2514 pAllocator->FreeChunk(_this);
|
24
|
2515 memset(&pSounds[pID], 0, 0x80u);
|
0
|
2516 }
|
|
2517
|
|
2518 //----- (004A96FF) --------------------------------------------------------
|
|
2519 SoundHeader *__fastcall FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName)
|
|
2520 {
|
|
2521 unsigned int v3; // ebx@1
|
|
2522 unsigned int v4; // esi@1
|
|
2523 SoundHeader *result; // eax@2
|
|
2524 signed int v6; // ebx@11
|
|
2525 int v7; // edi@13
|
|
2526 unsigned int v8; // esi@14
|
|
2527 unsigned int v9; // esi@20
|
|
2528 unsigned int v10; // [sp+Ch] [bp-4h]@1
|
|
2529
|
|
2530 v3 = uEnd;
|
|
2531 v10 = uEnd;
|
|
2532 v4 = uStart;
|
|
2533 while ( 1 )
|
|
2534 {
|
|
2535 v6 = v3 - v4;
|
|
2536 result = &pAudioPlayer->pSoundHeaders[v6 / 2 + v4];
|
|
2537 if ( !result )
|
|
2538 return result;
|
|
2539 result = (SoundHeader *)_strcmpi(pName, result->pSoundName);
|
|
2540 if ( !result )
|
|
2541 uFindSound_BinSearch_ResultID = v6 / 2 + v4;
|
|
2542 if ( v4 == v10 )
|
|
2543 goto LABEL_17;
|
|
2544 if ( (signed int)result < 0 )
|
|
2545 break;
|
|
2546 if ( v6 <= 4 )
|
|
2547 {
|
|
2548 v7 = v4;
|
|
2549 if ( (signed int)v4 < (signed int)v10 )
|
|
2550 {
|
|
2551 v9 = v4;
|
|
2552 do
|
|
2553 {
|
|
2554 result = (SoundHeader *)_strcmpi(pName, pAudioPlayer->pSoundHeaders[v9].pSoundName);
|
|
2555 if ( !result )
|
|
2556 goto LABEL_24;
|
|
2557 ++v7;
|
|
2558 ++v9;
|
|
2559 }
|
|
2560 while ( v7 < (signed int)v10 );
|
|
2561 }
|
|
2562 LABEL_17:
|
|
2563 uFindSound_BinSearch_ResultID = -1;
|
|
2564 return result;
|
|
2565 }
|
|
2566 v4 += v6 / 2;
|
|
2567 LABEL_10:
|
|
2568 v3 = v10;
|
|
2569 }
|
|
2570 if ( v6 > 4 )
|
|
2571 {
|
|
2572 v10 = v6 / 2 + v4;
|
|
2573 goto LABEL_10;
|
|
2574 }
|
|
2575 v7 = v4;
|
|
2576 if ( (signed int)v4 >= (signed int)v10 )
|
|
2577 goto LABEL_17;
|
|
2578 v8 = v4;
|
|
2579 while ( 1 )
|
|
2580 {
|
|
2581 result = (SoundHeader *)_strcmpi(pName, pAudioPlayer->pSoundHeaders[v8].pSoundName);
|
|
2582 if ( !result )
|
|
2583 break;
|
|
2584 ++v7;
|
|
2585 ++v8;
|
|
2586 if ( v7 >= (signed int)v10 )
|
|
2587 goto LABEL_17;
|
|
2588 }
|
|
2589 LABEL_24:
|
|
2590 uFindSound_BinSearch_ResultID = v7;
|
|
2591 return result;
|
|
2592 }
|
|
2593 // F1B4C8: using guessed type int uFindSound_BinSearch_ResultID;
|
|
2594
|
|
2595 //----- (004A97C6) --------------------------------------------------------
|
|
2596 SoundData *LoadSound(const char *pSoundName, SoundData *pOutBuff, unsigned int uID)
|
|
2597 {
|
|
2598 SoundData *v3; // edi@1
|
|
2599 int v4; // ecx@1
|
|
2600 //Sound *v5; // eax@1
|
|
2601 SoundHeader *v6; // esi@5
|
|
2602 unsigned int *pDecompressedSize; // ebx@5
|
|
2603 unsigned int v8; // eax@5
|
|
2604 unsigned int v9; // eax@7
|
|
2605 SoundData *result; // eax@9
|
|
2606 int v11; // esi@15
|
|
2607 int v12; // eax@15
|
|
2608 char *v13; // ecx@16
|
|
2609 int v14; // eax@19
|
|
2610 std::string v15; // [sp-18h] [bp-34h]@12
|
|
2611 const char *v16; // [sp-8h] [bp-24h]@12
|
|
2612 int v17; // [sp-4h] [bp-20h]@12
|
|
2613 char v18; // [sp+Ch] [bp-10h]@12
|
|
2614 int v19; // [sp+10h] [bp-Ch]@5
|
|
2615 DWORD NumberOfBytesRead; // [sp+14h] [bp-8h]@8
|
|
2616 const char *pSoundName_; // [sp+18h] [bp-4h]@1
|
|
2617
|
|
2618 pSoundName_ = pSoundName;
|
|
2619 v3 = pOutBuff;
|
|
2620 v4 = 0;
|
|
2621 for (uint i = 0; i < 3000; ++i)
|
|
2622 if (pSounds[i].uID == uID)
|
|
2623 return pSounds[i].pSoundData;
|
|
2624
|
|
2625 FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName_);
|
|
2626 if ( uFindSound_BinSearch_ResultID == -1 )
|
24
|
2627 {
|
|
2628 result = 0;
|
|
2629 return result;
|
|
2630 }
|
0
|
2631 v6 = &pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID];
|
|
2632 pDecompressedSize = &v6->uDecompressedSize;
|
|
2633 v8 = v6->uDecompressedSize;
|
|
2634 v19 = v6->uDecompressedSize;
|
|
2635 if ( v3 == (SoundData *)-1 )
|
|
2636 v3 = (SoundData *)pAllocator->AllocNamedChunk(0, v8 + 4, pSoundName_);
|
|
2637 SetFilePointer(pAudioPlayer->hAudioSnd, v6->uFileOffset, 0, 0);
|
|
2638 v9 = *pDecompressedSize;
|
|
2639 if ( (signed int)v6->uCompressedSize >= (signed int)*pDecompressedSize )
|
|
2640 {
|
|
2641 v6->uCompressedSize = v9;
|
|
2642 if ( v9 )
|
|
2643 {
|
|
2644 ReadFile(pAudioPlayer->hAudioSnd, (char *)v3 + 4, v9, &NumberOfBytesRead, 0);
|
|
2645 }
|
|
2646 else
|
|
2647 {
|
|
2648 MessageBoxW(nullptr, L"Can't load sound file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Sound.cpp:448", 0);
|
|
2649 }
|
|
2650 }
|
|
2651 else
|
|
2652 {
|
|
2653 uID = (unsigned int)malloc(v6->uCompressedSize);
|
|
2654 ReadFile(pAudioPlayer->hAudioSnd, (LPVOID)uID, v6->uCompressedSize, &NumberOfBytesRead, 0);
|
|
2655 zlib::MemUnzip((char *)v3 + 4, &v6->uDecompressedSize, (const void *)uID, v6->uCompressedSize);
|
|
2656 free((void *)uID);
|
|
2657 }
|
|
2658 if ( v3 )
|
|
2659 {
|
|
2660 v11 = v19;
|
|
2661 v12 = 0;
|
|
2662 *(int *)v3 = v19;
|
|
2663 uLastLoadedSoundID = 0;
|
|
2664 if ( pSounds[0].pSoundData )
|
|
2665 {
|
|
2666 v13 = (char *)&pSounds[0].pSoundData;
|
|
2667 do
|
|
2668 {
|
|
2669 v13 += 128;
|
|
2670 ++v12;
|
|
2671 }
|
|
2672 while ( *(int *)v13 );
|
|
2673 uLastLoadedSoundID = v12;
|
|
2674 }
|
24
|
2675 v16 = pSounds[v12].SoundName;
|
0
|
2676 strcpy((char *)v16, pSoundName_);
|
|
2677 v14 = uLastLoadedSoundID++ << 7;
|
|
2678 pSoundList->uTotalLoadedSoundSize += v11;
|
|
2679 pSounds[uLastLoadedSoundID].pSoundData = v3;
|
|
2680 result = v3;
|
|
2681 }
|
|
2682 else
|
|
2683 {
|
|
2684 result = 0;
|
|
2685 }
|
|
2686 return result;
|
|
2687 }
|