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