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