annotate Media/Audio/AudioPlayer.cpp @ 2542:bacf9809126a

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