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 {
|
80
|
471 sprintf(v2->pSounds[v2->uNumSounds].pSoundName, "%s", v19.pProperties[0]);
|
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 )
|
58
|
828 a6 = pParty->vPosition.y;
|
0
|
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);
|
58
|
833 v84 = GetSoundStrengthByDistanceFromParty(v75, a6, pParty->vPosition.z);
|
0
|
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;
|
58
|
1052 a1.vWorldPosition.y = (double)pParty->vPosition.y;
|
|
1053 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
|
0
|
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;
|
58
|
1262 v43 = (double)pParty->vPosition.y;
|
0
|
1263 LABEL_100:
|
|
1264 a1.vWorldPosition.y = v43;
|
58
|
1265 v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
|
0
|
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;
|
58
|
1430 a1.vWorldPosition.y = (double)pParty->vPosition.y;
|
|
1431 v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
|
0
|
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;
|
58
|
1454 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
|
|
1455 v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
|
0
|
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;
|
58
|
1473 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
|
0
|
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;
|
58
|
1485 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
|
0
|
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 }
|
158
|
1531 //v29 = __OFSUB__(v1->uMixerChannels, v2);
|
|
1532 v29 = v1->uMixerChannels > v2;
|
0
|
1533 v3 = v1->uMixerChannels == v2;
|
|
1534 v5 = v1->uMixerChannels - v2 < 0;
|
|
1535 v59 = v2;
|
|
1536 if ( !((unsigned __int8)(v5 ^ v29) | v3) )
|
|
1537 {
|
|
1538 v30 = v1->pMixerChannels;
|
|
1539 while ( 1 )
|
|
1540 {
|
|
1541 v31 = v30->dword_000004;
|
|
1542 if ( (v30->dword_000004 & 7) == 1 )
|
|
1543 {
|
|
1544 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1545 {
|
|
1546 v39 = &pIndoor->pDoors[v31 >> 3];
|
|
1547 if ( !v39->uDoorID )
|
|
1548 {
|
|
1549 LABEL_61:
|
|
1550 v1 = thisa;
|
|
1551 goto LABEL_62;
|
|
1552 }
|
|
1553 v40 = GetSoundStrengthByDistanceFromParty(*v39->pXOffsets, *v39->pYOffsets, *v39->pZOffsets);
|
|
1554 if ( !v40 )
|
|
1555 {
|
|
1556 LABEL_58:
|
|
1557 AIL_end_sample(v30->hSample);
|
|
1558 thisa->_4ABE55(v30);
|
|
1559 goto LABEL_61;
|
|
1560 }
|
|
1561 AIL_set_sample_volume(v30->hSample, v40);
|
|
1562 v35 = *v39->pYOffsets;
|
|
1563 v36 = *v39->pXOffsets;
|
|
1564 LABEL_60:
|
|
1565 v41 = sub_4AB66C(v36, v35);
|
|
1566 AIL_set_sample_pan(v30->hSample, v41);
|
|
1567 goto LABEL_61;
|
|
1568 }
|
|
1569 }
|
|
1570 else
|
|
1571 {
|
|
1572 if ( (v30->dword_000004 & 7) == 2 )
|
|
1573 {
|
|
1574 v32 = &pLayingItems[v31 >> 3];
|
|
1575 goto LABEL_53;
|
|
1576 }
|
|
1577 if ( (v30->dword_000004 & 7) == 3 )
|
|
1578 {
|
|
1579 v33 = &pActors[v31 >> 3];
|
|
1580 v34 = GetSoundStrengthByDistanceFromParty(v33->vPosition.x, v33->vPosition.y, v33->vPosition.z);
|
|
1581 if ( !v34 )
|
|
1582 goto LABEL_58;
|
|
1583 AIL_set_sample_volume(v30->hSample, v34);
|
|
1584 v35 = v33->vPosition.y;
|
|
1585 v36 = v33->vPosition.x;
|
|
1586 goto LABEL_60;
|
|
1587 }
|
|
1588 if ( (v30->dword_000004 & 7) == 5 )
|
|
1589 {
|
|
1590 v32 = (LayingItem *)&pLevelDecorations[v31 >> 3];
|
|
1591 LABEL_53:
|
|
1592 v37 = v32;
|
|
1593 v38 = GetSoundStrengthByDistanceFromParty(v32->vPosition.x, v32->vPosition.y, v32->vPosition.z);
|
|
1594 if ( !v38 )
|
|
1595 goto LABEL_58;
|
|
1596 AIL_set_sample_volume(v30->hSample, v38);
|
|
1597 v35 = v37->vPosition.y;
|
|
1598 v36 = v37->vPosition.x;
|
|
1599 goto LABEL_60;
|
|
1600 }
|
|
1601 }
|
|
1602 LABEL_62:
|
|
1603 ++v59;
|
|
1604 ++v30;
|
|
1605 if ( v59 >= v1->uMixerChannels )
|
|
1606 {
|
|
1607 v2 = 0;
|
|
1608 break;
|
|
1609 }
|
|
1610 }
|
|
1611 }
|
44
|
1612 if ( pCurrentScreen != v2 )
|
0
|
1613 {
|
|
1614 v42 = &v1->pMixerChannels[4];
|
|
1615 if ( AIL_sample_status(v42->hSample) == 4 )
|
|
1616 AIL_end_sample(v42->hSample);
|
|
1617 return;
|
|
1618 }
|
|
1619 v59 = v2;
|
98
|
1620 if ( _6807E0_num_decorations_with_sounds_6807B8 <= v2 )
|
0
|
1621 return;
|
|
1622 while ( 1 )
|
|
1623 {
|
|
1624 LODWORD(v56) = 1;
|
|
1625 v43 = 4 * v59 + 6817720;
|
|
1626 v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]];
|
58
|
1627 v45 = abs(v44->vPosition.z - pParty->vPosition.z);
|
|
1628 v46 = abs(v44->vPosition.y - pParty->vPosition.y);
|
0
|
1629 v47 = abs(v44->vPosition.x - pParty->vPosition.x);
|
|
1630 if ( sub_4621DA(v47, v46, v45) <= 8192 )
|
|
1631 break;
|
|
1632 LABEL_89:
|
|
1633 ++v59;
|
98
|
1634 if ( v59 >= _6807E0_num_decorations_with_sounds_6807B8 )
|
0
|
1635 return;
|
|
1636 }
|
|
1637 v48 = &pDecorationList->pDecorations[v44->uDecorationDescID];
|
|
1638 v49 = v48->uFlags;
|
|
1639 uNumRepeats = (~(unsigned __int8)v48->uFlags & 0x40) >> 6;
|
|
1640 if ( HIBYTE(v49) & 3 )
|
|
1641 {
|
|
1642 v50 = v44->field_1A;
|
|
1643 v55 = 0.0;
|
|
1644 uNumRepeats = 2;
|
|
1645 if ( v50 )
|
|
1646 {
|
|
1647 v51 = v50 - 32;
|
|
1648 v44->field_1A = v51;
|
|
1649 if ( v51 < 0 )
|
|
1650 v44->field_1A = 0;
|
|
1651 }
|
|
1652 }
|
|
1653 v52 = v48->uFlags;
|
|
1654 if ( !(HIBYTE(v52) & 1) )
|
|
1655 {
|
|
1656 if ( !(HIBYTE(v52) & 2) )
|
|
1657 goto LABEL_84;
|
|
1658 if ( v55 != 0.0 )
|
|
1659 goto LABEL_85;
|
|
1660 }
|
|
1661 v56 = 0.0;
|
|
1662 if ( pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 6
|
|
1663 || pParty->uCurrentHour >= 0x14 && pParty->uCurrentHour < 0x15 )
|
|
1664 {
|
|
1665 if ( !v44->field_1A && rand() % 100 < 100 )
|
|
1666 LODWORD(v56) = 1;
|
|
1667 LODWORD(v55) = 1;
|
|
1668 }
|
|
1669 LABEL_84:
|
|
1670 if ( v55 == 0.0 )
|
|
1671 {
|
|
1672 LABEL_87:
|
|
1673 if ( v56 != 0.0 )
|
|
1674 {
|
|
1675 v53 = 8 * *(int *)v43;
|
|
1676 LOBYTE(v53) = v53 | 5;
|
|
1677 thisa->PlaySound((SoundID)v48->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0);
|
|
1678 }
|
|
1679 goto LABEL_89;
|
|
1680 }
|
|
1681 LABEL_85:
|
|
1682 if ( !v44->field_1A )
|
|
1683 v44->field_1A = (rand() % 15 + 1) << 7;
|
|
1684 goto LABEL_87;
|
|
1685 }
|
|
1686 }
|
|
1687 }
|
|
1688
|
|
1689
|
|
1690
|
|
1691 //----- (004AB66C) --------------------------------------------------------
|
|
1692 int __fastcall sub_4AB66C(int a1, int a2)
|
|
1693 {
|
|
1694 signed int v2; // eax@1
|
|
1695
|
58
|
1696 v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.y)
|
0
|
1697 - stru_5C6E00->uIntegerHalfPi
|
|
1698 - pParty->sRotationY);
|
|
1699 if ( v2 > (signed int)stru_5C6E00->uIntegerPi )
|
|
1700 v2 = 2 * stru_5C6E00->uIntegerPi - v2;
|
|
1701 return (v2 >> 3) - (v2 >> 10);
|
|
1702 }
|
|
1703 // 4AB66C: using guessed type int __fastcall sub_4AB66C(int, int);
|
|
1704
|
|
1705 //----- (004AB6B1) --------------------------------------------------------
|
|
1706 int __fastcall GetSoundStrengthByDistanceFromParty(int a1, int a2, int a3)
|
|
1707 {
|
|
1708 int v3; // esi@1
|
|
1709 int v4; // edi@1
|
|
1710 int v5; // ST08_4@1
|
|
1711 int v6; // esi@1
|
|
1712 int v7; // eax@1
|
|
1713 int result; // eax@2
|
|
1714 int v9; // [sp+10h] [bp+8h]@1
|
|
1715
|
|
1716 v3 = a2;
|
|
1717 v4 = a1;
|
58
|
1718 v5 = abs(a3 - pParty->vPosition.z);
|
|
1719 v6 = abs(v3 - pParty->vPosition.y);
|
0
|
1720 v7 = abs(v4 - pParty->vPosition.x);
|
|
1721 v9 = sub_4621DA(v7, v6, v5);
|
|
1722 if ( v9 <= 8192 )
|
|
1723 result = 114 - (unsigned __int64)(signed __int64)((double)v9 * 0.0001220703125 * 100.0);
|
|
1724 else
|
|
1725 result = 0;
|
|
1726 return result;
|
|
1727 }
|
|
1728
|
|
1729
|
|
1730
|
|
1731 //----- (004AB71F) --------------------------------------------------------
|
|
1732 void AudioPlayer::StopChannels(int uStartChannel, int uEndChannel)
|
|
1733 {
|
2
|
1734 //AudioPlayer *v3; // esi@1
|
0
|
1735 int v4; // ecx@1
|
|
1736 char *v5; // edi@4
|
|
1737 int v6; // ebx@12
|
|
1738 MixerChannel *pChannel; // edi@14
|
2
|
1739 //_STREAM *v8; // esi@23
|
0
|
1740 int v9; // [sp+4h] [bp-4h]@3
|
|
1741
|
2
|
1742 //v3 = this;
|
0
|
1743 v4 = 0;
|
2
|
1744 if ( bPlayerReady )
|
0
|
1745 {
|
2
|
1746 if ( b3DSoundInitialized )
|
0
|
1747 {
|
|
1748 v9 = 0;
|
2
|
1749 if ( uNum3DSamples > 0 )
|
0
|
1750 {
|
2
|
1751 v5 = (char *)&p3DSamples[0].field_8;
|
0
|
1752 do
|
|
1753 {
|
|
1754 if ( (uStartChannel == -1 || v4 < uStartChannel || v4 > uEndChannel)
|
|
1755 && *(int *)v5
|
2
|
1756 && pSoundList->pSounds[*(int *)v5].eType != SOUND_DESC_SYSTEM)
|
0
|
1757 {
|
|
1758 AIL_end_3D_sample(*((int **)v5 - 2));
|
2
|
1759 _4ABF23((AudioPlayer_3DSample *)(v5 - 8));
|
0
|
1760 *((int *)v5 - 1) = 0;
|
|
1761 v4 = v9;
|
|
1762 }
|
|
1763 ++v4;
|
|
1764 v5 += 16;
|
|
1765 v9 = v4;
|
|
1766 }
|
2
|
1767 while ( v4 < uNum3DSamples );
|
0
|
1768 }
|
|
1769 }
|
|
1770 v6 = 0;
|
2
|
1771 if ( hDigDriver && uMixerChannels > 0 )
|
0
|
1772 {
|
2
|
1773 pChannel = pMixerChannels;
|
0
|
1774 do
|
|
1775 {
|
|
1776 if ( (uStartChannel == -1 || v6 < uStartChannel || v6 > uEndChannel)
|
2
|
1777 && pSoundList->pSounds[pChannel->uSourceTrackIdx].eType != SOUND_DESC_SYSTEM)
|
0
|
1778 {
|
|
1779 AIL_end_sample(pChannel->hSample);
|
2
|
1780 _4ABE55(pChannel);
|
0
|
1781 pChannel->dword_000004 = 0;
|
|
1782 }
|
|
1783 ++v6;
|
|
1784 ++pChannel;
|
|
1785 }
|
2
|
1786 while (v6 < uMixerChannels);
|
0
|
1787 }
|
2
|
1788 if (hSequence)
|
|
1789 AIL_end_sequence(hSequence);
|
|
1790 //v8 = hStream;
|
|
1791 if (hStream)
|
|
1792 AIL_pause_stream(hStream, 1);
|
0
|
1793 }
|
|
1794 }
|
|
1795
|
|
1796
|
|
1797 //----- (004AB818) --------------------------------------------------------
|
|
1798 void AudioPlayer::LoadAudioSnd()
|
|
1799 {
|
|
1800 DWORD NumberOfBytesRead; // [sp+Ch] [bp-4h]@3
|
|
1801
|
|
1802 hAudioSnd = CreateFileA("Sounds\\Audio.snd", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
|
|
1803 if (hAudioSnd == INVALID_HANDLE_VALUE)
|
|
1804 {
|
|
1805 Log::Warning(L"Can't open file: %s", L"Sounds\\Audio.snd");
|
|
1806 return;
|
|
1807 }
|
|
1808
|
|
1809 ReadFile(hAudioSnd, &uNumSoundHeaders, 4u, &NumberOfBytesRead, 0);
|
|
1810 pSoundHeaders = nullptr;
|
|
1811 pSoundHeaders = (SoundHeader *)pAllocator->AllocNamedChunk(0, 52 * uNumSoundHeaders + 2, 0);
|
|
1812 ReadFile(hAudioSnd, pSoundHeaders, 52 * uNumSoundHeaders, &NumberOfBytesRead, 0);
|
|
1813 }
|
|
1814
|
|
1815 //----- (004AB8CE) --------------------------------------------------------
|
|
1816 void AudioPlayer::Initialize(HWND hWnd)
|
|
1817 {
|
|
1818 //AudioPlayer *v2; // esi@1
|
|
1819 int v3; // ebx@1
|
|
1820 //_DIG_DRIVER *v4; // eax@1
|
|
1821 char v5; // dl@5
|
|
1822 _PROVIDER *v6; // eax@9
|
|
1823 HWND v7; // ST00_4@9
|
|
1824 MixerChannel *pChannel; // edi@14
|
|
1825 _SAMPLE *v9; // eax@15
|
|
1826 //_REDBOOK *v10; // eax@19
|
|
1827 //int v11; // ecx@21
|
|
1828 int v12; // [sp+Ch] [bp-Ch]@9
|
|
1829 char *Str1; // [sp+10h] [bp-8h]@6
|
|
1830 int v14; // [sp+14h] [bp-4h]@5
|
|
1831
|
|
1832 //v2 = this;
|
|
1833 v3 = 0;
|
|
1834 this->hWindow = hWnd;
|
|
1835 this->hAILRedbook = 0;
|
|
1836 this->hDigDriver = 0;
|
|
1837 this->dword_0002AC = 0;
|
|
1838 this->hSequence = 0;
|
|
1839 this->uMasterVolume = 127;
|
|
1840 this->dword_0002C8 = 64;
|
|
1841 this->dword_0002CC = 2;
|
|
1842
|
|
1843 MSS32_DLL_Initialize();
|
|
1844 BINKW32_DLL_Initialize();
|
|
1845 SMACKW32_DLL_Initialize();
|
|
1846
|
|
1847 AIL_startup();
|
3
|
1848 if (bCanLoadFromCD)
|
|
1849 hAILRedbook = AIL_redbook_open_drive(cMM7GameCDDriveLetter/*cGameCDDriveLetter*/);
|
|
1850 //else
|
|
1851 // hAILRedbook = AIL_redbook_open(0);
|
0
|
1852 //v4 = Audio_GetFirstHardwareDigitalDriver();
|
3
|
1853
|
0
|
1854 hDigDriver = Audio_GetFirstHardwareDigitalDriver();
|
|
1855 if ( hDigDriver )
|
|
1856 SmackSoundUseMSS(hDigDriver);
|
|
1857 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 && pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT )
|
|
1858 {
|
|
1859 v14 = 0;
|
|
1860 bEAXSupported = 0;
|
|
1861 b3DSoundInitialized = 0;
|
|
1862 ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128u, "NONE");
|
|
1863 CheckA3DSupport(v5);
|
|
1864 while ( AIL_enumerate_3D_providers(&v14, (HPROVIDER *)&hWnd, &Str1) )
|
|
1865 {
|
|
1866 if ( !strcmp(Str1, p3DSoundProvider) )
|
|
1867 {
|
|
1868 if ( AIL_open_3D_provider((HPROVIDER)hWnd) )
|
|
1869 {
|
|
1870 bEAXSupported = 0;
|
|
1871 b3DSoundInitialized = 0;
|
|
1872 h3DSoundProvider = 0;
|
|
1873 }
|
|
1874 else
|
|
1875 {
|
|
1876 v6 = (_PROVIDER *)hWnd;
|
|
1877 v7 = hWnd;
|
|
1878 b3DSoundInitialized = 1;
|
|
1879 h3DSoundProvider = v6;
|
|
1880 uNum3DSamples = 4;
|
|
1881 AIL_3D_provider_attribute((HPROVIDER)v7, "EAX environment selection", &v12);
|
|
1882 if ( v12 != -1 )
|
|
1883 bEAXSupported = 1;
|
|
1884 }
|
|
1885 pAudioPlayer->_4AC0A2();
|
|
1886 break;
|
|
1887 }
|
|
1888 }
|
|
1889 }
|
|
1890 if ( uMixerChannels > 0 )
|
|
1891 {
|
|
1892 pChannel = pMixerChannels;
|
|
1893 do
|
|
1894 {
|
|
1895 v9 = AIL_allocate_sample_handle(hDigDriver);
|
|
1896 pChannel->hSample = v9;
|
|
1897 if ( !v9 )
|
|
1898 break;
|
|
1899 ++v3;
|
|
1900 ++pChannel;
|
|
1901 }
|
|
1902 while ( v3 < uMixerChannels );
|
|
1903 }
|
|
1904 uMixerChannels = v3;
|
|
1905 if ( bPlayerReady )
|
|
1906 StopChannels(-1, -1);
|
|
1907 //v10 = hAILRedbook;
|
|
1908 bPlayerReady = true;
|
|
1909 if ( hAILRedbook )
|
|
1910 {
|
|
1911 AIL_redbook_stop(hAILRedbook);
|
|
1912 uNumRedbookTracks = AIL_redbook_tracks(hAILRedbook);
|
|
1913 }
|
|
1914 pAudioPlayer->sRedbookVolume = AIL_redbook_volume(hAILRedbook);
|
|
1915 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0);
|
|
1916 if ( bPlayerReady && hAILRedbook )
|
|
1917 AIL_redbook_set_volume(hAILRedbook, (unsigned __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0) >> 32);
|
|
1918 LoadAudioSnd();
|
|
1919 }
|
|
1920
|
|
1921 //----- (004ABAF7) --------------------------------------------------------
|
|
1922 _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void)
|
|
1923 {
|
|
1924 int v0; // ecx@1
|
|
1925 unsigned int v1; // ebp@2
|
|
1926 size_t v2; // eax@4
|
|
1927 signed int v3; // kr14_4@9
|
|
1928 char *v5; // [sp+10h] [bp-Ch]@2
|
|
1929 unsigned int v6; // [sp+14h] [bp-8h]@1
|
|
1930 _DIG_DRIVER *hDrv; // [sp+18h] [bp-4h]@3
|
|
1931
|
|
1932 static int dword_4F00DC = 22050;
|
|
1933 static int dword_4F00E0 = 16;
|
|
1934 static int dword_4F00E4 = 2;
|
|
1935
|
|
1936 AIL_set_preference(15, 0);
|
|
1937 AIL_set_preference(33, 1);
|
|
1938 v0 = dword_4F00DC;
|
|
1939 pAudioPlayer->pDeviceNames[0][0] = 0;
|
|
1940 pAudioPlayer->uNumDevices = 0;
|
|
1941 v6 = 0;
|
|
1942
|
|
1943 if ( dword_4F00DC < 11025 )
|
|
1944 return 0;
|
|
1945 v1 = 0;
|
|
1946 v5 = (char *)pAudioPlayer->array_000BF0;
|
|
1947 while ( 1 )
|
|
1948 {
|
|
1949 while ( 1 )
|
|
1950 {
|
|
1951 pcmWaveFormat.wf.wFormatTag = 1;
|
|
1952 pcmWaveFormat.wf.nChannels = dword_4F00E4;
|
|
1953 pcmWaveFormat.wf.nSamplesPerSec = v0;
|
|
1954 pcmWaveFormat.wf.nBlockAlign = dword_4F00E4 * dword_4F00E0 / 8;
|
|
1955 pcmWaveFormat.wBitsPerSample = dword_4F00E0;
|
|
1956 pcmWaveFormat.wf.nAvgBytesPerSec = v0 * dword_4F00E4 * dword_4F00E0 / 8;
|
|
1957 if ( !AIL_waveOutOpen(&hDrv, 0, -1, &pcmWaveFormat.wf) )
|
|
1958 break;
|
|
1959 if ( !AIL_get_preference(15) )
|
|
1960 goto LABEL_8;
|
|
1961 v3 = dword_4F00DC;
|
|
1962 v0 = dword_4F00DC / 2;
|
|
1963 dword_4F00DC /= 2;
|
|
1964 if ( v3 / 2 < 11025 )
|
|
1965 {
|
|
1966 if ( dword_4F00E0 == 8 )
|
|
1967 {
|
|
1968 v0 = 22050;
|
|
1969 dword_4F00E0 = 8;
|
|
1970 dword_4F00DC = 22050;
|
|
1971 }
|
|
1972 goto LABEL_12;
|
|
1973 }
|
|
1974 }
|
|
1975 strcpy(pAudioPlayer->pDeviceNames[v1 / 8], "Device: ");
|
|
1976 v2 = strlen(pAudioPlayer->pDeviceNames[v1 / 8]);
|
|
1977 AIL_digital_configuration(hDrv, (int *)v5, (int *)(v5 + 64), (char *)pAudioPlayer->pDeviceNames + v2 + v1 * 16);
|
|
1978 ++v6;
|
|
1979 v1 += 8;
|
|
1980 v5 += 4;
|
|
1981 pAudioPlayer->uNumDevices = v6;
|
|
1982 if ( AIL_get_preference(15) )
|
|
1983 return hDrv;
|
|
1984 if ( !strstr(pAudioPlayer->pDeviceNames[v1 / 8 - 1], "Emulated") )
|
|
1985 return hDrv;
|
|
1986 AIL_waveOutClose(hDrv);
|
|
1987 AIL_set_preference(15, 1);
|
|
1988 LABEL_8:
|
|
1989 AIL_set_preference(15, 1);
|
|
1990 v0 = dword_4F00DC;
|
|
1991 LABEL_12:
|
|
1992 if ( v0 < 11025 )
|
|
1993 return 0;
|
|
1994 }
|
|
1995 }
|
|
1996
|
|
1997
|
|
1998 //----- (004ABC9B) --------------------------------------------------------
|
|
1999 LSTATUS AudioPlayer::CheckA3DSupport(char a2)
|
|
2000 {
|
|
2001 LSTATUS result; // eax@1
|
|
2002 DWORD cbData; // [sp+8h] [bp-Ch]@1
|
|
2003 int Data; // [sp+Ch] [bp-8h]@1
|
|
2004 HKEY hKey; // [sp+10h] [bp-4h]@1
|
|
2005 char v6; // [sp+1Ch] [bp+8h]@0
|
|
2006
|
|
2007 hKey = 0;
|
|
2008 cbData = 4;
|
|
2009 Data = 0;
|
|
2010 result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Aureal\\A3D", 0, 0x2001Fu, &hKey);
|
|
2011 if ( !result )
|
|
2012 {
|
|
2013 if ( v6 )
|
|
2014 RegQueryValueExA(hKey, "SplashAudio", 0, 0, (LPBYTE)&Aureal3D_SplashAudio, &cbData);
|
|
2015 else
|
|
2016 Data = Aureal3D_SplashAudio;
|
|
2017 RegSetValueExA(hKey, "SplashAudio", 0, 4u, (const BYTE *)&Data, 4u);
|
|
2018 Data = 0;
|
|
2019 if ( v6 )
|
|
2020 RegQueryValueExA(hKey, "SplashScreen", 0, 0, (LPBYTE)&Aureal3D_SplashScreen, &cbData);
|
|
2021 else
|
|
2022 Data = Aureal3D_SplashScreen;
|
|
2023 RegSetValueExA(hKey, "SplashScreen", 0, 4u, (const BYTE *)&Data, 4u);
|
|
2024 result = RegCloseKey(hKey);
|
|
2025 }
|
|
2026 return result;
|
|
2027 }
|
|
2028 // 4ABC9B: inconsistent function type and number of purged bytes
|
|
2029
|
|
2030 //----- (004ABD5B) --------------------------------------------------------
|
|
2031 void AudioPlayer::Release()
|
|
2032 {
|
|
2033 AudioPlayer *v1; // esi@1
|
|
2034 int v2; // edi@1
|
|
2035 MixerChannel *v3; // ebx@3
|
|
2036 char v4; // dl@5
|
|
2037 int v5; // ebx@6
|
|
2038 AudioPlayer_3DSample *v6; // edi@7
|
|
2039 int v7; // edx@14
|
|
2040 int v8; // ecx@14
|
|
2041 void *v9; // ecx@15
|
|
2042
|
|
2043 v1 = this;
|
|
2044 v2 = 0;
|
|
2045 if ( this->bPlayerReady )
|
|
2046 {
|
|
2047 CloseHandle(pVideoPlayer->hMagicVid);
|
|
2048 CloseHandle(pVideoPlayer->hMightVid);
|
|
2049 v1->StopChannels(-1, -1);
|
|
2050 if ( v1->uMixerChannels > 0 )
|
|
2051 {
|
|
2052 v3 = v1->pMixerChannels;
|
|
2053 do
|
|
2054 {
|
|
2055 AIL_release_sample_handle(v3->hSample);
|
|
2056 ++v2;
|
|
2057 ++v3;
|
|
2058 }
|
|
2059 while ( v2 < v1->uMixerChannels );
|
|
2060 }
|
|
2061 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 )
|
|
2062 {
|
|
2063 v5 = 0;
|
|
2064 v1->CheckA3DSupport(v4);
|
|
2065 if ( v1->uNum3DSamples > 0 )
|
|
2066 {
|
|
2067 v6 = v1->p3DSamples;
|
|
2068 do
|
|
2069 {
|
|
2070 if ( v6->hSample )
|
|
2071 {
|
|
2072 AIL_release_3D_sample_handle(v6->hSample);
|
|
2073 v6->hSample = 0;
|
|
2074 }
|
|
2075 ++v5;
|
|
2076 ++v6;
|
|
2077 }
|
|
2078 while ( v5 < v1->uNum3DSamples );
|
|
2079 }
|
|
2080 if ( v1->h3DSoundProvider )
|
|
2081 {
|
|
2082 AIL_close_3D_provider(v1->h3DSoundProvider);
|
|
2083 v1->h3DSoundProvider = 0;
|
|
2084 }
|
|
2085 }
|
|
2086 if ( v1->hAILRedbook )
|
|
2087 {
|
|
2088 AIL_redbook_stop(v1->hAILRedbook);
|
|
2089 AIL_redbook_set_volume((HREDBOOK)v8, v7);
|
|
2090 AIL_redbook_close(v1->hAILRedbook);
|
|
2091 }
|
|
2092 AIL_shutdown();
|
|
2093 pSoundList->Release();
|
|
2094 v9 = *(void **)&v1->field_C78[0];
|
|
2095 if ( v9 )
|
|
2096 ReleaseSoundData(v9);
|
|
2097 CloseHandle(v1->hAudioSnd);
|
|
2098 }
|
|
2099 }
|
|
2100
|
|
2101 //----- (004ABE55) --------------------------------------------------------
|
|
2102 void AudioPlayer::_4ABE55(MixerChannel *pChannel)
|
|
2103 {
|
|
2104 int v2; // ebx@1
|
2
|
2105 //AudioPlayer *v3; // esi@1
|
0
|
2106 SoundDesc *v4; // eax@2
|
|
2107 unsigned __int8 v5; // zf@5
|
|
2108 unsigned __int8 v6; // sf@5
|
|
2109 char *v7; // edi@6
|
|
2110 int v8; // eax@8
|
|
2111 int v9; // ST04_4@8
|
|
2112 int v10; // ecx@12
|
|
2113 int v11; // edi@13
|
|
2114 int v12; // eax@13
|
|
2115 unsigned __int8 v13; // of@13
|
|
2116 int v14[16]; // [sp+Ch] [bp-48h]@8
|
|
2117 int v15; // [sp+4Ch] [bp-8h]@5
|
|
2118 int v16; // [sp+50h] [bp-4h]@5
|
|
2119
|
|
2120 v2 = 0;
|
2
|
2121 //v3 = this;
|
0
|
2122 if ( pSoundList->pSounds )
|
|
2123 {
|
|
2124 v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx];
|
2
|
2125 if ( v4->eType == SOUND_DESC_SWAP)
|
0
|
2126 {
|
|
2127 if ( v4->pSoundData[0] && !(v4->uFlags & 1) )
|
|
2128 {
|
|
2129 v5 = this->uMixerChannels == 0;
|
|
2130 v6 = this->uMixerChannels < 0;
|
|
2131 v15 = 0;
|
|
2132 v16 = 0;
|
|
2133 if ( v6 | v5 )
|
|
2134 goto LABEL_16;
|
|
2135 v7 = (char *)this->pMixerChannels;
|
|
2136 do
|
|
2137 {
|
|
2138 if ( pChannel->uSourceTrackID == *((int *)v7 + 3) )
|
|
2139 {
|
|
2140 v8 = v16;
|
|
2141 v9 = *(int *)v7;
|
|
2142 ++v16;
|
|
2143 v14[v8] = v2;
|
|
2144 if ( AIL_sample_status((HSAMPLE)v9) == 4 )
|
|
2145 ++v15;
|
|
2146 }
|
|
2147 ++v2;
|
|
2148 v7 += 16;
|
|
2149 }
|
2
|
2150 while ( v2 < uMixerChannels );
|
0
|
2151 if ( !v15 )
|
|
2152 {
|
|
2153 LABEL_16:
|
|
2154 pSoundList->_4A9DCD(pChannel->uSourceTrackIdx, 1);
|
|
2155 v10 = 0;
|
|
2156 if ( v16 > 0 )
|
|
2157 {
|
|
2158 do
|
|
2159 {
|
|
2160 v11 = v14[v10];
|
|
2161 v12 = 16 * (v14[v10++] + 47);
|
2
|
2162 pMixerChannels[v11].uSourceTrackID = 0;
|
0
|
2163 v13 = __OFSUB__(v10, v16);
|
|
2164 v6 = v10 - v16 < 0;
|
2
|
2165 *(unsigned int *)((char *)&bEAXSupported + v12) = 0;
|
0
|
2166 }
|
|
2167 while ( v6 ^ v13 );
|
|
2168 }
|
|
2169 }
|
|
2170 }
|
|
2171 }
|
|
2172 }
|
|
2173 }
|
|
2174 // 4D82F8: using guessed type int __stdcall AIL_sample_status(int);
|
|
2175 // 4ABE55: using guessed type int var_48[16];
|
|
2176
|
|
2177
|
|
2178
|
|
2179 //----- (004AAEA6) --------------------------------------------------------
|
|
2180 int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1)
|
|
2181 {
|
|
2182 double v1; // st7@1
|
|
2183 double v2; // st6@1
|
|
2184 int result; // eax@1
|
|
2185 double v4; // st5@2
|
|
2186 double v5; // st4@3
|
|
2187 double v6; // st3@3
|
|
2188 double v7; // st7@6
|
|
2189 double v8; // st6@7
|
|
2190 float v9; // [sp+0h] [bp-10h]@1
|
|
2191 float v10; // [sp+4h] [bp-Ch]@1
|
|
2192 float v11; // [sp+8h] [bp-8h]@2
|
|
2193 float v12; // [sp+8h] [bp-8h]@6
|
|
2194 float v13; // [sp+Ch] [bp-4h]@2
|
|
2195 float v14; // [sp+Ch] [bp-4h]@6
|
|
2196
|
|
2197 v1 = pBLVRenderParams->fCosineNegX;
|
|
2198 v2 = pBLVRenderParams->fSineNegX;
|
|
2199 v9 = pBLVRenderParams->fCosineY;
|
|
2200 v10 = pBLVRenderParams->fSineY;
|
|
2201 result = 0;
|
|
2202 if ( pBLVRenderParams->sPartyRotX )
|
|
2203 {
|
|
2204 v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
|
58
|
2205 v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
|
|
2206 v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
|
0
|
2207 if ( pRenderer->pRenderD3D )
|
|
2208 {
|
|
2209 v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY;
|
|
2210 v6 = v13 * pBLVRenderParams->fSineY - v11 * pBLVRenderParams->fCosineY;
|
|
2211 }
|
|
2212 else
|
|
2213 {
|
|
2214 v5 = v13 * pBLVRenderParams->fCosineY - v11 * pBLVRenderParams->fSineY;
|
|
2215 v6 = v13 * pBLVRenderParams->fSineY + v11 * pBLVRenderParams->fCosineY;
|
|
2216 }
|
|
2217 a1->vWorldViewPosition.x = v5 * v1 - v4 * v2;
|
|
2218 a1->vWorldViewPosition.y = v6;
|
|
2219 a1->vWorldViewPosition.z = v5 * v2 + v4 * v1;
|
|
2220 }
|
|
2221 else
|
|
2222 {
|
|
2223 v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
|
58
|
2224 v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
|
|
2225 v7 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
|
0
|
2226 if ( pRenderer->pRenderD3D )
|
|
2227 {
|
|
2228 a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY;
|
|
2229 v8 = v14 * v10 - v12 * v9;
|
|
2230 }
|
|
2231 else
|
|
2232 {
|
|
2233 a1->vWorldViewPosition.x = v14 * pBLVRenderParams->fCosineY - v12 * pBLVRenderParams->fSineY;
|
|
2234 v8 = v14 * v10 + v12 * v9;
|
|
2235 }
|
|
2236 a1->vWorldViewPosition.y = v8;
|
|
2237 a1->vWorldViewPosition.z = v7;
|
|
2238 }
|
|
2239 return result;
|
|
2240 }
|
|
2241
|
|
2242
|
|
2243
|
|
2244
|
|
2245 //----- (004ABF23) --------------------------------------------------------
|
|
2246 void AudioPlayer::_4ABF23(AudioPlayer_3DSample *a2)
|
|
2247 {
|
|
2248 int v2; // ebx@1
|
2
|
2249 //AudioPlayer *v3; // esi@1
|
0
|
2250 SoundDesc *v4; // eax@2
|
|
2251 unsigned __int8 v5; // zf@5
|
|
2252 unsigned __int8 v6; // sf@5
|
|
2253 char *v7; // edi@6
|
|
2254 int v8; // eax@8
|
|
2255 int v9; // ST04_4@8
|
|
2256 int v10; // ecx@12
|
|
2257 int v11; // eax@13
|
|
2258 unsigned __int8 v12; // of@13
|
|
2259 int v13[16]; // [sp+Ch] [bp-48h]@8
|
|
2260 int v14; // [sp+4Ch] [bp-8h]@5
|
|
2261 int v15; // [sp+50h] [bp-4h]@5
|
|
2262
|
|
2263 v2 = 0;
|
2
|
2264 //v3 = this;
|
0
|
2265 if ( pSoundList->pSounds )
|
|
2266 {
|
|
2267 v4 = &pSoundList->pSounds[a2->field_8];
|
2
|
2268 if ( v4->eType == SOUND_DESC_SWAP)
|
0
|
2269 {
|
|
2270 if ( v4->p3DSound && !(v4->uFlags & 1) )
|
|
2271 {
|
|
2272 v5 = this->uNum3DSamples == 0;
|
|
2273 v6 = this->uNum3DSamples < 0;
|
|
2274 v14 = 0;
|
|
2275 v15 = 0;
|
|
2276 if ( v6 | v5 )
|
|
2277 goto LABEL_16;
|
|
2278 v7 = (char *)this->p3DSamples;
|
|
2279 do
|
|
2280 {
|
|
2281 if ( a2->field_C == *((int *)v7 + 3) )
|
|
2282 {
|
|
2283 v8 = v15;
|
|
2284 v9 = *(int *)v7;
|
|
2285 ++v15;
|
|
2286 v13[v8] = v2;
|
|
2287 if ( AIL_3D_sample_status((void *)v9) == 4 )
|
|
2288 ++v14;
|
|
2289 }
|
|
2290 ++v2;
|
|
2291 v7 += 16;
|
|
2292 }
|
2
|
2293 while ( v2 < uNum3DSamples );
|
0
|
2294 if ( !v14 )
|
|
2295 {
|
|
2296 LABEL_16:
|
|
2297 pSoundList->_4A9DCD(a2->field_8, 1);
|
|
2298 v10 = 0;
|
|
2299 if ( v15 > 0 )
|
|
2300 {
|
|
2301 do
|
|
2302 {
|
|
2303 v11 = v13[v10++];
|
2
|
2304 *(&bEAXSupported + 4 * (v11 + 2)) = 0;
|
0
|
2305 v12 = __OFSUB__(v10, v15);
|
|
2306 v6 = v10 - v15 < 0;
|
2
|
2307 p3DSamples[v11].field_8 = 0;
|
0
|
2308 }
|
|
2309 while ( v6 ^ v12 );
|
|
2310 }
|
|
2311 }
|
|
2312 }
|
|
2313 }
|
|
2314 }
|
|
2315 }
|
|
2316 // 4D82F4: using guessed type int __stdcall AIL_3D_sample_status(int);
|
|
2317 // 4ABF23: using guessed type int var_48[16];
|
|
2318
|
|
2319 //----- (004ABFDB) --------------------------------------------------------
|
|
2320 void __cdecl PlayLevelMusic()
|
|
2321 {
|
|
2322 unsigned int v0; // eax@1
|
|
2323
|
|
2324 v0 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2325 if ( v0 )
|
3
|
2326 pAudioPlayer->PlayMusicTrack((MusicID)pMapStats->pInfos[v0].uRedbookTrackID);
|
0
|
2327 }
|
|
2328
|
|
2329 //----- (004AC004) --------------------------------------------------------
|
|
2330 void AudioPlayer::SetEAXPreferences()
|
|
2331 {
|
|
2332 AudioPlayer *v1; // edi@1
|
|
2333 _PROVIDER *v2; // ST00_4@2
|
|
2334 _PROVIDER *v3; // ST00_4@2
|
|
2335 float v4; // [sp+4h] [bp-4h]@2
|
|
2336
|
|
2337 v1 = this;
|
|
2338 if ( this->bEAXSupported )
|
|
2339 {
|
|
2340 v2 = this->h3DSoundProvider;
|
|
2341 v4 = 0.0;
|
|
2342 AIL_set_3D_provider_preference(v2, "EAX effect volume", (int *)&v4);
|
|
2343 v3 = v1->h3DSoundProvider;
|
|
2344 v4 = 1.0;
|
|
2345 AIL_set_3D_provider_preference(v3, "EAX damping", (int *)&v4);
|
|
2346 }
|
|
2347 }
|
|
2348 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int);
|
|
2349
|
|
2350 //----- (004AC041) --------------------------------------------------------
|
|
2351 void AudioPlayer::SetMapEAX()
|
|
2352 {
|
|
2353 AudioPlayer *v1; // esi@1
|
|
2354 unsigned int v2; // eax@1
|
|
2355 int v3; // [sp+4h] [bp-4h]@3
|
|
2356
|
|
2357 v1 = this;
|
|
2358 v2 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2359 if ( v1->b3DSoundInitialized && v1->bEAXSupported )
|
|
2360 {
|
|
2361 v3 = pMapStats->pInfos[v2].uEAXEnv;
|
|
2362 if ( (unsigned int)v3 >= 0x1A )
|
|
2363 {
|
|
2364 SetEAXPreferences();
|
|
2365 v1->field_214 = -1;
|
|
2366 }
|
|
2367 else
|
|
2368 {
|
|
2369 AIL_set_3D_provider_preference(v1->h3DSoundProvider, "EAX environment selection", &v3);
|
|
2370 v1->field_214 = v3;
|
|
2371 }
|
|
2372 }
|
|
2373 }
|
|
2374 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int);
|
|
2375
|
|
2376 //----- (004AC0A2) --------------------------------------------------------
|
|
2377 int AudioPlayer::_4AC0A2()
|
|
2378 {
|
|
2379 AudioPlayer *v1; // esi@1
|
|
2380 unsigned int v2; // eax@1
|
|
2381 char v3; // zf@1
|
|
2382 int v4; // ebx@1
|
|
2383 int *v5; // edi@2
|
|
2384 int v6; // eax@4
|
|
2385 AudioPlayer_3DSample *v8; // ebx@7
|
|
2386 void *v9; // eax@8
|
|
2387 int v10; // ebx@14
|
|
2388 unsigned int v11; // eax@14
|
|
2389 int v12; // [sp+1Ch] [bp-8h]@1
|
|
2390 int v13; // [sp+20h] [bp-4h]@6
|
|
2391
|
|
2392 v1 = this;
|
|
2393 v2 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2394 v3 = v1->b3DSoundInitialized == 0;
|
|
2395 v4 = v2;
|
|
2396 v12 = v2;
|
|
2397 if ( !v3 )
|
|
2398 {
|
|
2399 v5 = &v1->uNum3DSamples;
|
|
2400 AIL_3D_provider_attribute(v1->h3DSoundProvider, "Maximum supported samples", &v1->uNum3DSamples);
|
|
2401 if ( v1->uNum3DSamples > 32 )
|
|
2402 *v5 = 32;
|
|
2403 v6 = *v5;
|
|
2404 if ( !*v5 )
|
|
2405 {
|
|
2406 v1->b3DSoundInitialized = 0;
|
|
2407 return -1;
|
|
2408 }
|
|
2409 v13 = 0;
|
|
2410 if ( v6 > 0 )
|
|
2411 {
|
|
2412 v8 = v1->p3DSamples;
|
|
2413 while ( 1 )
|
|
2414 {
|
|
2415 v9 = (void *)AIL_allocate_3D_sample_handle(v1->h3DSoundProvider);
|
|
2416 v8->hSample = v9;
|
|
2417 if ( !v9 )
|
|
2418 break;
|
|
2419 AIL_set_3D_sample_float_distances(v9, 4096.0, 256.0, 4096.0, 256.0);
|
|
2420 AIL_set_3D_sample_volume(v8->hSample, v1->s3DSoundVolume);
|
|
2421 ++v13;
|
|
2422 ++v8;
|
|
2423 if ( v13 >= *v5 )
|
|
2424 goto LABEL_12;
|
|
2425 }
|
|
2426 *v5 = v13;
|
|
2427 LABEL_12:
|
|
2428 v4 = v12;
|
|
2429 }
|
|
2430 if ( v1->bEAXSupported )
|
|
2431 {
|
|
2432 v10 = v4;
|
|
2433 v11 = pMapStats->pInfos[v10].uEAXEnv;
|
|
2434 v12 = pMapStats->pInfos[v10].uEAXEnv;
|
|
2435 if ( v11 >= 0x1A )
|
|
2436 {
|
|
2437 pAudioPlayer->SetEAXPreferences();
|
|
2438 v1->field_214 = -1;
|
|
2439 }
|
|
2440 else
|
|
2441 {
|
|
2442 AIL_set_3D_provider_preference(v1->h3DSoundProvider, "EAX environment selection", &v12);
|
|
2443 v1->field_214 = v12;
|
|
2444 }
|
|
2445 }
|
|
2446 }
|
|
2447 return 1;
|
|
2448 }
|
|
2449
|
|
2450
|
|
2451 //----- (004A96BE) --------------------------------------------------------
|
|
2452 void ReleaseSoundData(void *_this)
|
|
2453 {
|
|
2454 int v1; // esi@1
|
|
2455 char *v2; // eax@1
|
|
2456
|
|
2457 v1 = 0;
|
|
2458 v2 = (char *)&pSounds[0].pSoundData;
|
|
2459 while ( *(void **)v2 != _this )
|
|
2460 {
|
|
2461 v2 += 128;
|
|
2462 ++v1;
|
|
2463 if ( (signed int)v2 >= (signed int)&pAudioPlayer->p3DSamples[6].field_8 )
|
|
2464 return;
|
|
2465 }
|
|
2466 pAllocator->FreeChunk(_this);
|
|
2467 memset(&pSounds[v1], 0, 0x80u);
|
|
2468 }
|
|
2469
|
|
2470 //----- (004A96FF) --------------------------------------------------------
|
|
2471 SoundHeader *__fastcall FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName)
|
|
2472 {
|
|
2473 unsigned int v3; // ebx@1
|
|
2474 unsigned int v4; // esi@1
|
|
2475 SoundHeader *result; // eax@2
|
|
2476 signed int v6; // ebx@11
|
|
2477 int v7; // edi@13
|
|
2478 unsigned int v8; // esi@14
|
|
2479 unsigned int v9; // esi@20
|
|
2480 unsigned int v10; // [sp+Ch] [bp-4h]@1
|
|
2481
|
|
2482 v3 = uEnd;
|
|
2483 v10 = uEnd;
|
|
2484 v4 = uStart;
|
|
2485 while ( 1 )
|
|
2486 {
|
|
2487 v6 = v3 - v4;
|
|
2488 result = &pAudioPlayer->pSoundHeaders[v6 / 2 + v4];
|
|
2489 if ( !result )
|
|
2490 return result;
|
|
2491 result = (SoundHeader *)_strcmpi(pName, result->pSoundName);
|
|
2492 if ( !result )
|
|
2493 uFindSound_BinSearch_ResultID = v6 / 2 + v4;
|
|
2494 if ( v4 == v10 )
|
|
2495 goto LABEL_17;
|
|
2496 if ( (signed int)result < 0 )
|
|
2497 break;
|
|
2498 if ( v6 <= 4 )
|
|
2499 {
|
|
2500 v7 = v4;
|
|
2501 if ( (signed int)v4 < (signed int)v10 )
|
|
2502 {
|
|
2503 v9 = v4;
|
|
2504 do
|
|
2505 {
|
|
2506 result = (SoundHeader *)_strcmpi(pName, pAudioPlayer->pSoundHeaders[v9].pSoundName);
|
|
2507 if ( !result )
|
|
2508 goto LABEL_24;
|
|
2509 ++v7;
|
|
2510 ++v9;
|
|
2511 }
|
|
2512 while ( v7 < (signed int)v10 );
|
|
2513 }
|
|
2514 LABEL_17:
|
|
2515 uFindSound_BinSearch_ResultID = -1;
|
|
2516 return result;
|
|
2517 }
|
|
2518 v4 += v6 / 2;
|
|
2519 LABEL_10:
|
|
2520 v3 = v10;
|
|
2521 }
|
|
2522 if ( v6 > 4 )
|
|
2523 {
|
|
2524 v10 = v6 / 2 + v4;
|
|
2525 goto LABEL_10;
|
|
2526 }
|
|
2527 v7 = v4;
|
|
2528 if ( (signed int)v4 >= (signed int)v10 )
|
|
2529 goto LABEL_17;
|
|
2530 v8 = v4;
|
|
2531 while ( 1 )
|
|
2532 {
|
|
2533 result = (SoundHeader *)_strcmpi(pName, pAudioPlayer->pSoundHeaders[v8].pSoundName);
|
|
2534 if ( !result )
|
|
2535 break;
|
|
2536 ++v7;
|
|
2537 ++v8;
|
|
2538 if ( v7 >= (signed int)v10 )
|
|
2539 goto LABEL_17;
|
|
2540 }
|
|
2541 LABEL_24:
|
|
2542 uFindSound_BinSearch_ResultID = v7;
|
|
2543 return result;
|
|
2544 }
|
|
2545 // F1B4C8: using guessed type int uFindSound_BinSearch_ResultID;
|
|
2546
|
|
2547 //----- (004A97C6) --------------------------------------------------------
|
27
|
2548 SoundData *LoadSound(const char *pSoundName, SoundData *pOutBuff, unsigned int uID)
|
0
|
2549 {
|
27
|
2550 SoundData *v3; // edi@1
|
0
|
2551 int v4; // ecx@1
|
27
|
2552 //Sound *v5; // eax@1
|
0
|
2553 SoundHeader *v6; // esi@5
|
|
2554 unsigned int *pDecompressedSize; // ebx@5
|
|
2555 unsigned int v8; // eax@5
|
|
2556 unsigned int v9; // eax@7
|
27
|
2557 SoundData *result; // eax@9
|
0
|
2558 int v11; // esi@15
|
|
2559 int v12; // eax@15
|
|
2560 char *v13; // ecx@16
|
|
2561 int v14; // eax@19
|
|
2562 std::string v15; // [sp-18h] [bp-34h]@12
|
|
2563 const char *v16; // [sp-8h] [bp-24h]@12
|
|
2564 int v17; // [sp-4h] [bp-20h]@12
|
|
2565 char v18; // [sp+Ch] [bp-10h]@12
|
|
2566 int v19; // [sp+10h] [bp-Ch]@5
|
|
2567 DWORD NumberOfBytesRead; // [sp+14h] [bp-8h]@8
|
|
2568 const char *pSoundName_; // [sp+18h] [bp-4h]@1
|
|
2569
|
|
2570 pSoundName_ = pSoundName;
|
|
2571 v3 = pOutBuff;
|
|
2572 v4 = 0;
|
27
|
2573 for (uint i = 0; i < 3000; ++i)
|
|
2574 if (pSounds[i].uID == uID)
|
|
2575 return pSounds[i].pSoundData;
|
|
2576
|
0
|
2577 FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName_);
|
|
2578 if ( uFindSound_BinSearch_ResultID == -1 )
|
|
2579 goto LABEL_22;
|
|
2580 v6 = &pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID];
|
|
2581 pDecompressedSize = &v6->uDecompressedSize;
|
|
2582 v8 = v6->uDecompressedSize;
|
|
2583 v19 = v6->uDecompressedSize;
|
27
|
2584 if ( v3 == (SoundData *)-1 )
|
|
2585 v3 = (SoundData *)pAllocator->AllocNamedChunk(0, v8 + 4, pSoundName_);
|
0
|
2586 SetFilePointer(pAudioPlayer->hAudioSnd, v6->uFileOffset, 0, 0);
|
|
2587 v9 = *pDecompressedSize;
|
|
2588 if ( (signed int)v6->uCompressedSize >= (signed int)*pDecompressedSize )
|
|
2589 {
|
|
2590 v6->uCompressedSize = v9;
|
|
2591 if ( v9 )
|
|
2592 {
|
|
2593 ReadFile(pAudioPlayer->hAudioSnd, (char *)v3 + 4, v9, &NumberOfBytesRead, 0);
|
|
2594 }
|
|
2595 else
|
|
2596 {
|
|
2597 MessageBoxW(nullptr, L"Can't load sound file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Sound.cpp:448", 0);
|
|
2598 }
|
|
2599 }
|
|
2600 else
|
|
2601 {
|
|
2602 uID = (unsigned int)malloc(v6->uCompressedSize);
|
|
2603 ReadFile(pAudioPlayer->hAudioSnd, (LPVOID)uID, v6->uCompressedSize, &NumberOfBytesRead, 0);
|
|
2604 zlib::MemUnzip((char *)v3 + 4, &v6->uDecompressedSize, (const void *)uID, v6->uCompressedSize);
|
|
2605 free((void *)uID);
|
|
2606 }
|
|
2607 if ( v3 )
|
|
2608 {
|
|
2609 v11 = v19;
|
|
2610 v12 = 0;
|
|
2611 *(int *)v3 = v19;
|
|
2612 uLastLoadedSoundID = 0;
|
|
2613 if ( pSounds[0].pSoundData )
|
|
2614 {
|
|
2615 v13 = (char *)&pSounds[0].pSoundData;
|
|
2616 do
|
|
2617 {
|
|
2618 v13 += 128;
|
|
2619 ++v12;
|
|
2620 }
|
|
2621 while ( *(int *)v13 );
|
|
2622 uLastLoadedSoundID = v12;
|
|
2623 }
|
|
2624 v16 = pSounds[v12].field_4;
|
|
2625 strcpy((char *)v16, pSoundName_);
|
|
2626 v14 = uLastLoadedSoundID++ << 7;
|
|
2627 pSoundList->uTotalLoadedSoundSize += v11;
|
27
|
2628 pSounds[uLastLoadedSoundID].pSoundData = v3;
|
|
2629 result = v3;
|
0
|
2630 }
|
|
2631 else
|
|
2632 {
|
|
2633 LABEL_22:
|
|
2634 result = 0;
|
|
2635 }
|
|
2636 return result;
|
|
2637 }
|