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