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