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