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