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