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