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