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