annotate AudioPlayer.cpp @ 1392:e3e9c0467529

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