annotate AudioPlayer.cpp @ 365:0f35f908547f

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