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