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