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