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