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