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