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