annotate Media/Audio/AudioPlayer.cpp @ 2572:d87bfbd3bb3b

Step towards unification of Texture and RGBTexture (class Image)
author a.parshin
date Sat, 05 Mar 2016 01:51:54 +0200
parents d569340b05ff
children a76d408c5132
rev   line source
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1 #define _CRTDBG_MAP_ALLOC
2567
d569340b05ff Few constants changed into enum values
a.parshin
parents: 2557
diff changeset
2 #define _CRT_SECURE_NO_WARNINGS
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
3 #include <stdlib.h>
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
4 #include <crtdbg.h>
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
5 #include <sstream>
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2534
diff changeset
6 #include <string>
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
7
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2534
diff changeset
8 #include "Engine/Engine.h"
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2534
diff changeset
9
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
10 #include "Engine/ZlibWrapper.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
11
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
12 #include "../MediaPlayer.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
13 #include "AudioPlayer.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
14 #include "Engine/Tables/FrameTableInc.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
15 #include "Engine/Graphics/Indoor.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
16 #include "Engine/Objects/SpriteObject.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
17 #include "Engine/Party.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
18 #include "Engine/Objects/Actor.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
19 #include "Engine/Graphics/DecorationList.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
20 #include "Engine/Timer.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
21 #include "Engine/OurMath.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
22 #include "Engine/MapInfo.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
23 #include "GUI/GUIWindow.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
24 #include "Engine/Graphics/Level/Decoration.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
25 #include "Engine/Registry.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
26
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
27 #include "Media/Video/Bink_Smacker.h"
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
28
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
29 #include "Engine/MMT.h"
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
30
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
31
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
32 PCMWAVEFORMAT pcmWaveFormat;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
33
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
34 int uFindSound_BinSearch_ResultID; // weak
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
35 int uLastLoadedSoundID; // weak
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
36 int sLastTrackLengthMS;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
37 std::array<Sound, 3000> pSounds;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
38 AudioPlayer *pAudioPlayer;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
39 SoundList *pSoundList;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
40
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
41
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
42 std::array<stru339_spell_sound, 4> stru_A750F8;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
43 std::array<stru339_spell_sound, 4> AA1058_PartyQuickSpellSound;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
44
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
45
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
46
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
47 unsigned __int8 uSoundVolumeMultiplier;// = 4;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
48 unsigned __int8 uVoicesVolumeMultiplier;// = 4;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
49 unsigned __int8 uMusicVolimeMultiplier;// = 4;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
50 int bWalkSound; // idb
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
51
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
52 std::array<float, 10> pSoundVolumeLevels =
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
53 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
54 0.0000000f, 0.1099999f, 0.2199999f, 0.3300000f, 0.4399999f,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
55 0.5500000f, 0.6600000f, 0.7699999f, 0.8799999f, 0.9700000f
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
56 // 0.0000000f, 0.4900000f, 0.5500000f, 0.6100000f, 0.6700000f, //for 128.0f
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
57 // 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
58 };
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 void ReleaseSoundData(void *_this);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
64 _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
65
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 //----- (004A9953) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
70 void SoundList::Initialize()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
71 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
72 SoundDesc *pSoundDesc; // eax@5
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
73 void *pSoundData; // ebx@7
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
74 unsigned int uSoundSize; // eax@7
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
75 char *pSoundBytes; // ebx@7
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
76 AILFILETYPE pType; // eax@7
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
77 int v8; // eax@8
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
78 char pSoundName[120]; // [sp+4h] [bp-A4h]@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
79 AILSOUNDINFO pInfo; // [sp+7Ch] [bp-2Ch]@10
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
80 int v12; // [sp+A0h] [bp-8h]@12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
81
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
82 if ( sNumSounds > 1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
83 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
84 for ( uint i = 1; i < pSoundList->sNumSounds; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
85 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
86 sprintf(pSoundName, "%s", pSL_Sounds[i].pSoundName);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
87 pSoundDesc = &pSoundList->pSL_Sounds[i];
2506
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
88 //if ( pSL_Sounds[i].uSoundID == 75 )
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
89 //__debugbreak();
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
90 if ( pSoundList->pSL_Sounds[i].eType != SOUND_DESC_SYSTEM )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
91 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
92 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
93 if ( !pAudioPlayer->b3DSoundInitialized )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
94 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
95 pSoundDesc = &pSoundList->pSL_Sounds[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
96 if ( !(pSoundDesc->uFlags & SOUND_DESC_SWAP) || !pSoundDesc->pSoundData[0] )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
97 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
98 pSoundData = pSoundDesc->pSoundData[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
99 uSoundSize = *(int *)pSoundData;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
100 pSoundBytes = (char *)pSoundData + 4;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
101 pType = AIL_file_type(pSoundBytes, uSoundSize);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
102 if ( !pType )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
103 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
104 pSoundList->pSL_Sounds[i].bDecompressed = false;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
105 pSoundList->UnloadSound(i, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
106 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
107 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
108 v8 = pType - 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
109 if ( v8 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
110 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
111 if ( v8 == 1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
112 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
113 if ( AIL_WAV_info(pSoundBytes, &pInfo) && pInfo.uChannels != 2 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
114 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
115 if ( !AIL_decompress_ADPCM(&pInfo, &pSoundList->pSL_Sounds[i].p3DSound, &v12) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
116 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
117 pSoundList->pSL_Sounds[i].p3DSound = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
118 pSoundList->pSL_Sounds[i].bDecompressed = true;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
119 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
120 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
121 pSoundList->UnloadSound(i, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
122 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
123 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
124 pSoundList->pSL_Sounds[i].bDecompressed = false;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
125 pSoundList->UnloadSound(i, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
126 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
127 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
128 pSoundList->pSL_Sounds[i].p3DSound = pSoundList->pSL_Sounds[i].pSoundData[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
129 pSoundList->UnloadSound(i, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
130 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
131 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
132 //_CrtDumpMemoryLeaks();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
133 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
134
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
135 //----- (004A9A67) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
136 __int16 SoundList::LoadSound(int a1, unsigned int a3)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
137 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
138 AILSOUNDINFO v24; // [sp+84h] [bp-28h]@23
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
139
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
140 if (bNoSound || !sNumSounds)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
141 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
142
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
143 uint uSoundIdx = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
144 SoundDesc *pSound = nullptr;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
145 for (uint i = 1; i < sNumSounds; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
146 if (pSL_Sounds[i].uSoundID == a1)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
147 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
148 uSoundIdx = i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
149 pSound = &pSL_Sounds[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
150 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
151 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
152 if (!pSound)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
153 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
154
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
155 if (pSound->uFlags & SOUND_DESC_SWAP && pSound->p3DSound ||
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
156 ~pSound->uFlags & SOUND_DESC_SWAP && pSound->pSoundData[0])
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
157 return uSoundIdx;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
158
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
159 if (!pSound->pSoundData[0])
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
160 pSound->pSoundData[0] = ::LoadSound(pSound->pSoundName, (SoundData *)-1, pSound->uSoundID);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
161
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
162 if (!pSound->pSoundData[0])
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
163 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
164
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
165 if (a3)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
166 pSound->uFlags |= SOUND_DESC_SYSTEM;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
167
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
168 if (!pAudioPlayer->b3DSoundInitialized)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
169 return uSoundIdx;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
170
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
171 if (~pSound->uFlags & SOUND_DESC_SWAP || !pSound->pSoundData[0])
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
172 return uSoundIdx;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
173
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
174
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
175 SoundData* pSoundData = pSound->pSoundData[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
176 switch (AIL_file_type((void *)pSoundData->pData, pSoundData->uDataSize))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
177 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
178 default:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
179 case AILFILETYPE_UNKNOWN:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
180 pSound->bDecompressed = false;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
181 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
182
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
183 case AILFILETYPE_PCM_WAV:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
184 pSound->p3DSound = pSound->pSoundData[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
185 return uSoundIdx;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
186
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
187 case AILFILETYPE_ADPCM_WAV:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
188 if (AIL_WAV_info((void *)pSoundData->pData, &v24) && v24.uChannels != 2)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
189 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
190 if (!AIL_decompress_ADPCM(&v24, &pSound->p3DSound, &a1) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
191 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
192 pSound->p3DSound = nullptr;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
193 pSound->bDecompressed = true;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
194 UnloadSound(uSoundIdx, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
195 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
196 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
197 return uSoundIdx;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
198 };
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
199 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
200
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
201 //----- (004A9BBD) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
202 int SoundList::LoadSound(unsigned int a2, LPVOID lpBuffer, int uBufferSizeLeft, int *pOutSoundSize, int a6)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
203 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
204 void *v18; // ebx@19
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
205 DWORD NumberOfBytesRead;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
206
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
207 if (!sNumSounds)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
208 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
209
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
210 for ( uint i = 0; i < sNumSounds; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
211 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
212 if ( a2 == pSL_Sounds[i].uSoundID )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
213 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
214 if ( !a6 && pSL_Sounds[i].pSoundData )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
215 return i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
216 for ( uint j = 0; j < (signed int)pAudioPlayer->uNumSoundHeaders; ++j )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
217 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
218 if ( !_stricmp(pAudioPlayer->pSoundHeaders[j].pSoundName, pSL_Sounds[i].pSoundName) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
219 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
220 if ( (signed int)pAudioPlayer->pSoundHeaders[j].uDecompressedSize > uBufferSizeLeft )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
221 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
222 SetFilePointer(pAudioPlayer->hAudioSnd, pAudioPlayer->pSoundHeaders[j].uFileOffset, 0, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
223 if ( (signed int)pAudioPlayer->pSoundHeaders[j].uCompressedSize >= (signed int)pAudioPlayer->pSoundHeaders[j].uDecompressedSize )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
224 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
225 if ( pAudioPlayer->pSoundHeaders[j].uCompressedSize == pAudioPlayer->pSoundHeaders[j].uDecompressedSize )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
226 ReadFile(pAudioPlayer->hAudioSnd, lpBuffer, pAudioPlayer->pSoundHeaders[j].uDecompressedSize, &NumberOfBytesRead, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
227 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
228 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
229 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
230 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
231 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
232 v18 = malloc(pAudioPlayer->pSoundHeaders[j].uCompressedSize);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
233 ReadFile(pAudioPlayer->hAudioSnd, v18, pAudioPlayer->pSoundHeaders[j].uCompressedSize, &NumberOfBytesRead, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
234 zlib::MemUnzip(lpBuffer, &pAudioPlayer->pSoundHeaders[j].uDecompressedSize, v18, pAudioPlayer->pSoundHeaders[j].uCompressedSize);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
235 free(v18);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
236 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
237 pSL_Sounds[i].pSoundData[a6] = (SoundData *)lpBuffer;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
238 *pOutSoundSize = a2;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
239 return i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
240 }
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 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
245 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
246
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
247 //----- (004A9D3E) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
248 SoundDesc *SoundList::Release()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
249 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
250 SoundDesc *result; // eax@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
251 //void *v5; // ecx@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
252
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
253 if ( (signed int)this->sNumSounds > 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
254 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
255 for ( uint i = 0; i < (signed int)this->sNumSounds; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
256 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
257 result = this->pSL_Sounds;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
258 //v5 = this->pSL_Sounds[i].pSoundData[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
259 if ( this->pSL_Sounds[i].pSoundData[0] )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
260 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
261 ReleaseSoundData(this->pSL_Sounds[i].pSoundData[0]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
262 this->pSL_Sounds[i].pSoundData[0] = nullptr;
2505
e3a619609dae for sounds of decoration
Ritor1
parents: 2502
diff changeset
263 this->pSL_Sounds[i].uFlags &= 0xFFFFFFFE;//~0x00000001
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
264 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
265 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
266 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
267 return result;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
268 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
269
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
270 //----- (004A9D79) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
271 void SoundList::_4A9D79(int a2)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
272 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
273 for ( int i = 0; i < (signed int)this->sNumSounds; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
274 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
275 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
276 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
277 if ( this->pSL_Sounds[i].pSoundData[0] )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
278 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
279 ReleaseSoundData(this->pSL_Sounds[i].pSoundData[0]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
280 this->pSL_Sounds[i].pSoundData[0] = nullptr;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
281 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
282 this->pSL_Sounds[i].uFlags &= ~SOUND_DESC_SYSTEM;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
283 }
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 //----- (004A9DCD) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
288 void SoundList::UnloadSound(unsigned int uSoundID, char a3)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
289 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
290 if ( pSL_Sounds[uSoundID].eType != SOUND_DESC_SYSTEM )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
291 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
292 if ( (pSL_Sounds[uSoundID].uFlags & SOUND_DESC_SWAP) && pSL_Sounds[uSoundID].p3DSound && a3 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
293 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
294 if ( pSL_Sounds[uSoundID].bDecompressed)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
295 AIL_mem_free_lock(pSL_Sounds[uSoundID].p3DSound);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
296 pSL_Sounds[uSoundID].p3DSound = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
297 pSL_Sounds[uSoundID].uFlags &= ~SOUND_DESC_SYSTEM;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
298 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
299 if ( pSL_Sounds[uSoundID].pSoundData[0] )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
300 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
301 ReleaseSoundData(pSL_Sounds[uSoundID].pSoundData[0]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
302 pSL_Sounds[uSoundID].pSoundData[0] = nullptr;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
303 pSL_Sounds[uSoundID].uFlags &= ~SOUND_DESC_SYSTEM;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
304 }
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 //----- (004A9E3D) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
310 void SoundList::ToFile()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
311 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
312 FILE *v2; // eax@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
313
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
314 v2 = fopen("data\\dsounds.bin", "wb");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
315 if ( !v2 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
316 Error("Unable to save dsounds.bin!");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
317
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
318 fwrite(this, 4, 1, v2);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
319 fwrite(this->pSL_Sounds, 0x78u, this->sNumSounds, v2);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
320 fclose(v2);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
321 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
322
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
323 //----- (004A9E89) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
324 void SoundList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
325 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
326 uint num_mm6_sounds = data_mm6 ? *(int *)data_mm6 : 0,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
327 num_mm7_sounds = data_mm7 ? *(int *)data_mm7 : 0,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
328 num_mm8_sounds = data_mm8 ? *(int *)data_mm8 : 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
329
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
330 sNumSounds = num_mm6_sounds + num_mm7_sounds + num_mm8_sounds;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
331 assert(sNumSounds);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
332 assert(!num_mm8_sounds);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
333
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
334 pSL_Sounds = (SoundDesc *)malloc(sNumSounds * sizeof(SoundDesc));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
335 memcpy(pSL_Sounds, (char *)data_mm7 + 4, num_mm7_sounds * sizeof(SoundDesc));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
336 for (uint i = 0; i < num_mm6_sounds; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
337 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
338 auto src = (SoundDesc_mm6 *)((char *)data_mm6 + 4) + i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
339 SoundDesc* dst = &pSL_Sounds[num_mm7_sounds + i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
340
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
341 memcpy(dst, src, sizeof(SoundDesc_mm6));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
342 dst->p3DSound = nullptr;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
343 dst->bDecompressed = false;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
344 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
345 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
346
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
347 //----- (004A9ED0) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
348 int SoundList::FromFileTxt(const char *Args)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
349 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
350 __int32 v3; // edi@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
351 FILE *v4; // eax@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
352 unsigned int v5; // esi@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
353 void *v6; // eax@9
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
354 FILE *v7; // ST0C_4@11
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
355 char *i; // eax@11
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
356 char Buf; // [sp+Ch] [bp-2F0h]@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
357 FrameTableTxtLine v18; // [sp+200h] [bp-FCh]@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
358 FrameTableTxtLine v19; // [sp+27Ch] [bp-80h]@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
359 FILE *File; // [sp+2F8h] [bp-4h]@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
360 unsigned int Argsa; // [sp+304h] [bp+8h]@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
361
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
362 free(this->pSL_Sounds);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
363 v3 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
364 this->pSL_Sounds = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
365 this->sNumSounds = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
366 v4 = fopen(Args, "r");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
367 File = v4;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
368 if ( !v4 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
369 Error("SoundListClass::load - Unable to open file: %s.");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
370
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
371 v5 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
372 Argsa = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
373 if ( fgets(&Buf, 490, v4) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
374 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
375 do
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
376 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
377 *strchr(&Buf, 10) = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
378 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
379 if ( v19.uPropCount && *v19.pProperties[0] != 47 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
380 ++Argsa;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
381 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
382 while ( fgets(&Buf, 490, File) );
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
383 v5 = Argsa;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
384 v3 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
385 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
386 this->sNumSounds = v5;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
387 v6 = malloc(120 * v5);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
388 this->pSL_Sounds = (SoundDesc *)v6;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
389 if ( v6 == (void *)v3 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
390 Error("SoundListClass::load - Out of Memory!");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
391
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
392 memset(v6, v3, 120 * this->sNumSounds);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
393 v7 = File;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
394 this->sNumSounds = v3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
395 fseek(v7, v3, v3);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
396 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
397 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
398 *strchr(&Buf, 10) = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
399 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
400 if ( v19.uPropCount && *v19.pProperties[0] != 47 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
401 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
402 sprintf(this->pSL_Sounds[this->sNumSounds].pSoundName, "%s", v19.pProperties[0]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
403 this->pSL_Sounds[this->sNumSounds].uSoundID = atoi(v19.pProperties[1]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
404 if ( _stricmp(v19.pProperties[2], "system") )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
405 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
406 if ( _stricmp(v19.pProperties[2], "swap") )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
407 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
408 if ( !_stricmp(v19.pProperties[2], "lock") )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
409 this->pSL_Sounds[this->sNumSounds].eType = SOUND_DESC_LOCK;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
410 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
411 this->pSL_Sounds[this->sNumSounds].eType = SOUND_DESC_LEVEL;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
412 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
413 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
414 this->pSL_Sounds[this->sNumSounds].eType = SOUND_DESC_SWAP;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
415 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
416 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
417 this->pSL_Sounds[this->sNumSounds].eType = SOUND_DESC_SYSTEM;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
418 if ( v19.uPropCount >= 4 && !_stricmp(v19.pProperties[3], "3D") )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
419 this->pSL_Sounds[this->sNumSounds].uFlags |= SOUND_DESC_SWAP;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
420 ++this->sNumSounds;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
421 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
422 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
423 fclose(File);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
424 return 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
425 }
2516
Ritor1
parents: 2515
diff changeset
426 //char to wchar_t
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
427 bool char2wchar_t(char *str1, wchar_t *str2)
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
428 {
2516
Ritor1
parents: 2515
diff changeset
429 std::wstringstream st;
Ritor1
parents: 2515
diff changeset
430 st << str1;
Ritor1
parents: 2515
diff changeset
431 return !(st >> str2).fail();
Ritor1
parents: 2515
diff changeset
432 }
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
433 //----- (004AA13F) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
434 void AudioPlayer::PlayMusicTrack(MusicID eTrack)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
435 {
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
436 if (!bNoSound && bPlayerReady && uMusicVolimeMultiplier)
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
437 {
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
438 if ( use_music_folder )
2516
Ritor1
parents: 2515
diff changeset
439 {
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
440 alSourceStop(mSourceID);
2534
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2516
diff changeset
441
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2567
diff changeset
442 char string[256];
2516
Ritor1
parents: 2515
diff changeset
443 sprintf(string, "Music\\%d.mp3", eTrack);
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2567
diff changeset
444
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);
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2567
diff changeset
453 delete [] wStr;
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2567
diff changeset
454 alSourcef(mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
2516
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);
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2567
diff changeset
459 AIL_redbook_set_volume(hAILRedbook, 64.0f * pSoundVolumeLevels[uMusicVolimeMultiplier]);
2508
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
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1207 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 )
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1340 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 BLVDoor *pDoor; // eax@19
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1429 double v16; // st7@22
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1430 double v17; // st6@22
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1431 double v18; // st5@23
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1432 double v19; // st4@24
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1433 double v20; // st3@24
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1434 double v21; // st6@28
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1435 double v22; // st7@32
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1436 int v23; // ST1C_4@32
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1437 int v24; // ebx@32
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1438 int v25; // eax@32
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1439 float v26; // ST10_4@34
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1440 float v27; // ST08_4@34
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1441 signed int v53; // eax@88
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1442 RenderVertexSoft a1; // [sp+24h] [bp-48h]@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1443 float v55; // [sp+54h] [bp-18h]@22
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1444 float v56; // [sp+58h] [bp-14h]@22
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1445 int uNumRepeats; // [sp+5Ch] [bp-10h]@15
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1446 float v58; // [sp+60h] [bp-Ch]@23
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1447 int v59; // [sp+64h] [bp-8h]@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1448
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1449 v2 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1450 if (!bPlayerReady)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1451 return;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1452
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1453 //if (field_2D0_time_left <= pEventTimer->uTimeElapsed)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1454 //field_2D0_time_left = 32;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1455 //else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1456 //{
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1457 //field_2D0_time_left -= pEventTimer->uTimeElapsed;
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 field_2D0_time_left -= pEventTimer->uTimeElapsed;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1461 if ( field_2D0_time_left <= 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1462 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1463 field_2D0_time_left = 32;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1464 if ( b3DSoundInitialized )//for 3D sound
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1465 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1466 __debugbreak(); // refactor refactor
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1467 v2 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1468 for ( v59 = 0; v59 < pAudioPlayer->uNum3DSamples; ++v59 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1469 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1470 v7 = PID_TYPE(this->p3DSamples[v59].field_4);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1471 if ( AIL_3D_sample_status(this->p3DSamples[v59].hSample) == AIL::Sample::Done )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1472 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1473 AIL_end_3D_sample(this->p3DSamples[v59].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1474 pAudioPlayer->_4ABF23(&this->p3DSamples[v59]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1475 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1476 if ( AIL_3D_sample_status(this->p3DSamples[v59].hSample) != AIL::Sample::Playing )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1477 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1478 v8 = v7 - 1;//
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1479 if ( v8 )//> 1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1480 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1481 v9 = v8 - 1;//
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1482 if ( v9 )//> 2
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1483 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1484 v10 = v9 - 1;//
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1485 if ( !v10 )//3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1486 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1487 v13 = &pActors[PID_ID(this->p3DSamples[v59].field_4)];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1488 //uNumRepeats = v13->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1489 //v14 = v13->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1490 a1.vWorldPosition.x = (double)v13->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1491 //uNumRepeats = v13->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1492 a1.vWorldPosition.y = (double)v13->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1493 //v11 = (double)uNumRepeats;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1494 a1.vWorldPosition.z = v13->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1495 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1496 {
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1497 v16 = pIndoorCameraD3D->fRotationXCosine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1498 v17 = pIndoorCameraD3D->fRotationXSine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1499 v55 = pIndoorCameraD3D->fRotationYCosine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1500 v56 = pIndoorCameraD3D->fRotationYSine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1501 if (pIndoorCameraD3D->sRotationX)
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1502 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1503 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1504 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1505 v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1506 //if ( pRenderer->pRenderD3D )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1507 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1508 v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1509 v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1510 }
2557
Ritor1
parents: 2543
diff changeset
1511 //else
Ritor1
parents: 2543
diff changeset
1512 // {
Ritor1
parents: 2543
diff changeset
1513 // v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
Ritor1
parents: 2543
diff changeset
1514 // v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
Ritor1
parents: 2543
diff changeset
1515 //}
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1516 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1517 a1.vWorldViewPosition.y = v20;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1518 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1519 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1520 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1521 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1522 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1523 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1524 //if ( pRenderer->pRenderD3D )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1525 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1526 a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1527 v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1528 }
2557
Ritor1
parents: 2543
diff changeset
1529 //else
Ritor1
parents: 2543
diff changeset
1530 //{
Ritor1
parents: 2543
diff changeset
1531 // a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
Ritor1
parents: 2543
diff changeset
1532 // v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
Ritor1
parents: 2543
diff changeset
1533 //}
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1534 a1.vWorldViewPosition.y = v21;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1535 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1536 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1537 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1538 else
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1539 pIndoorCameraD3D->ViewTransform(&a1, 1);
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1540 v58 = a1.vWorldViewPosition.y * -0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1541 v22 = a1.vWorldViewPosition.x * 0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1542 *(float *)&uNumRepeats = v22;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1543 v23 = abs((signed __int64)v22);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1544 v24 = abs(0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1545 v25 = abs((signed __int64)v58);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1546 if ( int_get_vector_length(v25, v24, v23) <= 100 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1547 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1548 AIL_set_3D_position(this->p3DSamples[v59].hSample, LODWORD(v58), 0.0, uNumRepeats);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1549 v26 = -*(float *)&uNumRepeats;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1550 v27 = -v58;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1551 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
1552 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1553 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1554 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1555 AIL_end_3D_sample(this->p3DSamples[v59].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1556 pAudioPlayer->_4ABF23(&this->p3DSamples[v59]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1557 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1558 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1559 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1560 if ( v10 != 2 )//4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1561 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1562 a1.vWorldPosition.x = (double)pParty->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1563 a1.vWorldPosition.y = (double)pParty->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1564 v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1565 a1.vWorldPosition.z = v11;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1566 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1567 {
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1568 v16 = pIndoorCameraD3D->fRotationXCosine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1569 v17 = pIndoorCameraD3D->fRotationXSine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1570 v55 = pIndoorCameraD3D->fRotationYCosine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1571 v56 = pIndoorCameraD3D->fRotationYSine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1572 if (pIndoorCameraD3D->sRotationX)
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1573 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1574 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1575 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1576 v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1577 //if ( pRenderer->pRenderD3D )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1578 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1579 v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1580 v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1581 }
2557
Ritor1
parents: 2543
diff changeset
1582 //else
Ritor1
parents: 2543
diff changeset
1583 //{
Ritor1
parents: 2543
diff changeset
1584 // v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
Ritor1
parents: 2543
diff changeset
1585 // v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
Ritor1
parents: 2543
diff changeset
1586 //}
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1587 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1588 a1.vWorldViewPosition.y = v20;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1589 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1590 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1591 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1592 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1593 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1594 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1595 //if ( pRenderer->pRenderD3D )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1596 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1597 a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1598 v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1599 }
2557
Ritor1
parents: 2543
diff changeset
1600 //else
Ritor1
parents: 2543
diff changeset
1601 //{
Ritor1
parents: 2543
diff changeset
1602 // a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
Ritor1
parents: 2543
diff changeset
1603 // v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
Ritor1
parents: 2543
diff changeset
1604 //}
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1605 a1.vWorldViewPosition.y = v21;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1606 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1607 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1608 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1609 else
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1610 pIndoorCameraD3D->ViewTransform(&a1, 1);
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1611 v58 = a1.vWorldViewPosition.y * -0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1612 v22 = a1.vWorldViewPosition.x * 0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1613 *(float *)&uNumRepeats = v22;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1614 v23 = abs((signed __int64)v22);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1615 v24 = abs(0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1616 v25 = abs((signed __int64)v58);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1617 if ( int_get_vector_length(v25, v24, v23) <= 100 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1618 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1619 AIL_set_3D_position(this->p3DSamples[v59].hSample, LODWORD(v58), 0.0, uNumRepeats);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1620 v26 = -*(float *)&uNumRepeats;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1621 v27 = -v58;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1622 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
1623 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1624 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1625 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1626 AIL_end_3D_sample(this->p3DSamples[v59].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1627 pAudioPlayer->_4ABF23(&this->p3DSamples[v59]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1628 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1629 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1630 }//5
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1631 v12 = (SpriteObject *)&pLevelDecorations[PID_ID(this->p3DSamples[v59].field_4)];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1632 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1633 else//2
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1634 v12 = &pSpriteObjects[PID_ID(this->p3DSamples[v59].field_4)];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1635 a1.vWorldPosition.x = (double)v12->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1636 a1.vWorldPosition.y = (double)v12->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1637 v11 = (double)v12->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1638 //LABEL_21:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1639 a1.vWorldPosition.z = v11;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1640 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1641 {
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1642 v16 = pIndoorCameraD3D->fRotationXCosine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1643 v17 = pIndoorCameraD3D->fRotationXSine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1644 v55 = pIndoorCameraD3D->fRotationYCosine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1645 v56 = pIndoorCameraD3D->fRotationYSine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1646 if (pIndoorCameraD3D->sRotationX)
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1647 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1648 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1649 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1650 v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1651 //if ( pRenderer->pRenderD3D )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1652 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1653 v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1654 v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1655 }
2557
Ritor1
parents: 2543
diff changeset
1656 //else
Ritor1
parents: 2543
diff changeset
1657 // {
Ritor1
parents: 2543
diff changeset
1658 // v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
Ritor1
parents: 2543
diff changeset
1659 // v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
Ritor1
parents: 2543
diff changeset
1660 //}
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1661 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1662 a1.vWorldViewPosition.y = v20;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1663 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1664 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1665 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1666 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1667 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1668 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1669 //if ( pRenderer->pRenderD3D )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1670 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1671 a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1672 v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1673 }
2557
Ritor1
parents: 2543
diff changeset
1674 //else
Ritor1
parents: 2543
diff changeset
1675 //{
Ritor1
parents: 2543
diff changeset
1676 //a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
Ritor1
parents: 2543
diff changeset
1677 //v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
Ritor1
parents: 2543
diff changeset
1678 //}
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1679 a1.vWorldViewPosition.y = v21;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1680 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1681 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1682 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1683 else
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1684 pIndoorCameraD3D->ViewTransform(&a1, 1);
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1685 v58 = a1.vWorldViewPosition.y * -0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1686 v22 = a1.vWorldViewPosition.x * 0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1687 *(float *)&uNumRepeats = v22;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1688 v23 = abs((signed __int64)v22);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1689 v24 = abs(0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1690 v25 = abs((signed __int64)v58);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1691 if ( int_get_vector_length(v25, v24, v23) <= 100 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1692 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1693 AIL_set_3D_position(this->p3DSamples[v59].hSample, LODWORD(v58), 0.0, uNumRepeats);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1694 v26 = -*(float *)&uNumRepeats;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1695 v27 = -v58;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1696 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
1697 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1698 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1699 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1700 AIL_end_3D_sample(this->p3DSamples[v59].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1701 pAudioPlayer->_4ABF23(&this->p3DSamples[v59]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1702 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1703 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1704 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1705 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )//==1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1706 {
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1707 pIndoorCameraD3D->ViewTransform(&a1, 1);
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1708 v58 = a1.vWorldViewPosition.y * -0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1709 v22 = a1.vWorldViewPosition.x * 0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1710 *(float *)&uNumRepeats = v22;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1711 v23 = abs((signed __int64)v22);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1712 v24 = abs(0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1713 v25 = abs((signed __int64)v58);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1714 if ( int_get_vector_length(v25, v24, v23) <= 100 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1715 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1716 AIL_set_3D_position(this->p3DSamples[v59].hSample, LODWORD(v58), 0.0, uNumRepeats);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1717 v26 = -*(float *)&uNumRepeats;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1718 v27 = -v58;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1719 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
1720 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1721 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1722 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1723 AIL_end_3D_sample(this->p3DSamples[v59].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1724 pAudioPlayer->_4ABF23(&this->p3DSamples[v59]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1725 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1726 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1727 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1728 pDoor = &pIndoor->pDoors[PID_ID(this->p3DSamples[v59].field_4)];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1729 if ( pDoor->uDoorID )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1730 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1731 uNumRepeats = *pDoor->pXOffsets;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1732 a1.vWorldPosition.x = (double)uNumRepeats;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1733 uNumRepeats = *pDoor->pYOffsets;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1734 a1.vWorldPosition.y = (double)uNumRepeats;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1735 uNumRepeats = *pDoor->pZOffsets;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1736 v11 = (double)uNumRepeats;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1737 a1.vWorldPosition.z = v11;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1738 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1739 {
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1740 v16 = pIndoorCameraD3D->fRotationXCosine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1741 v17 = pIndoorCameraD3D->fRotationXSine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1742 v55 = pIndoorCameraD3D->fRotationYCosine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1743 v56 = pIndoorCameraD3D->fRotationYSine;
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1744 if (pIndoorCameraD3D->sRotationX)
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1745 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1746 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1747 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1748 v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1749 //if ( pRenderer->pRenderD3D )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1750 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1751 v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1752 v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1753 }
2557
Ritor1
parents: 2543
diff changeset
1754 //else
Ritor1
parents: 2543
diff changeset
1755 //{
Ritor1
parents: 2543
diff changeset
1756 // v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
Ritor1
parents: 2543
diff changeset
1757 // v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
Ritor1
parents: 2543
diff changeset
1758 //}
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1759 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1760 a1.vWorldViewPosition.y = v20;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1761 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1762 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1763 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1764 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1765 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1766 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1767 //if ( pRenderer->pRenderD3D )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1768 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1769 a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1770 v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1771 }
2557
Ritor1
parents: 2543
diff changeset
1772 //else
Ritor1
parents: 2543
diff changeset
1773 //{
Ritor1
parents: 2543
diff changeset
1774 // a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
Ritor1
parents: 2543
diff changeset
1775 // v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
Ritor1
parents: 2543
diff changeset
1776 //}
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1777 a1.vWorldViewPosition.y = v21;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1778 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1779 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1780 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1781 else
2543
b6140dfeac27 GameOver h/cpp
a.parshin
parents: 2541
diff changeset
1782 pIndoorCameraD3D->ViewTransform(&a1, 1);
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1783 v58 = a1.vWorldViewPosition.y * -0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1784 v22 = a1.vWorldViewPosition.x * 0.012207031;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1785 *(float *)&uNumRepeats = v22;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1786 v23 = abs((signed __int64)v22);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1787 v24 = abs(0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1788 v25 = abs((signed __int64)v58);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1789 if ( int_get_vector_length(v25, v24, v23) <= 100 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1790 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1791 AIL_set_3D_position(this->p3DSamples[v59].hSample, LODWORD(v58), 0.0, uNumRepeats);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1792 v26 = -*(float *)&uNumRepeats;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1793 v27 = -v58;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1794 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
1795 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1796 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1797 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1798 AIL_end_3D_sample(this->p3DSamples[v59].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1799 pAudioPlayer->_4ABF23(&this->p3DSamples[v59]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1800 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1801 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1802 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1803 //}
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1804 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1805
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1806 //LABEL_37:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1807 for (int i = 0; i < uMixerChannels; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1808 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1809 if (AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Done)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1810 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1811 AIL_end_sample(pMixerChannels[i].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1812 FreeChannel(&pMixerChannels[i]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1813 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1814 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1815
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1816 for (int i = 0; i < uMixerChannels; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1817 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1818 if (pMixerChannels[i].source_pid <= 0)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1819 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1820
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1821 int source_type = PID_TYPE(pMixerChannels[i].source_pid),
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1822 source_id = PID_ID(pMixerChannels[i].source_pid);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1823 // int source_x,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1824 // int source_y,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1825 // source_z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1826
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1827 switch (source_type)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1828 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1829 case 0:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1830 case OBJECT_Player:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1831 case OBJECT_BModel:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1832 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1833
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1834 case OBJECT_BLVDoor:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1835 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1836 assert(uCurrentlyLoadedLevelType == LEVEL_Indoor);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1837
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1838 assert(source_id < pIndoor->uNumDoors);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1839 if (!pIndoor->pDoors[source_id].uDoorID)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1840 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1841
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1842 //source_x = pIndoor->pDoors[source_id].pXOffsets[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1843 //source_y = pIndoor->pDoors[source_id].pYOffsets[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1844 //source_z = pIndoor->pDoors[source_id].pZOffsets[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1845 int sound_strength = GetSoundStrengthByDistanceFromParty(pIndoor->pDoors[source_id].pXOffsets[0],
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1846 pIndoor->pDoors[source_id].pYOffsets[0],
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1847 pIndoor->pDoors[source_id].pZOffsets[0]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1848 if ( sound_strength )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1849 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1850 AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1851 AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(pIndoor->pDoors[source_id].pXOffsets[0],
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1852 pIndoor->pDoors[source_id].pYOffsets[0]));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1853 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1854 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1855 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1856 AIL_end_sample(pMixerChannels[i].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1857 FreeChannel(&pMixerChannels[i]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1858 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1859 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1860 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1861
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1862 case OBJECT_Item:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1863 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1864 //assert(source_id < uNumSpriteObjects); // Ritor1:â èäà äî è ïîñëå ïåðåõîäà îäèíàêîâî
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1865
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1866 //source_x = pSpriteObjects[source_id].vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1867 //source_y = pSpriteObjects[source_id].vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1868 //source_z = pSpriteObjects[source_id].vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1869 int sound_strength = GetSoundStrengthByDistanceFromParty(pSpriteObjects[source_id].vPosition.x,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1870 pSpriteObjects[source_id].vPosition.y,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1871 pSpriteObjects[source_id].vPosition.z);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1872 if ( sound_strength )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1873 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1874 AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1875 AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(pSpriteObjects[source_id].vPosition.x,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1876 pSpriteObjects[source_id].vPosition.y));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1877 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1878 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1879 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1880 AIL_end_sample(pMixerChannels[i].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1881 FreeChannel(&pMixerChannels[i]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1882 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1883 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1884 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1885
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1886 case OBJECT_Decoration:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1887 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1888 assert(source_id < uNumLevelDecorations);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1889
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1890 //source_x = pLevelDecorations[source_id].vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1891 //source_y = pLevelDecorations[source_id].vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1892 //source_z = pLevelDecorations[source_id].vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1893 int sound_strength = GetSoundStrengthByDistanceFromParty(pLevelDecorations[source_id].vPosition.x,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1894 pLevelDecorations[source_id].vPosition.y,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1895 pLevelDecorations[source_id].vPosition.z);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1896 if ( sound_strength )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1897 {
2505
e3a619609dae for sounds of decoration
Ritor1
parents: 2502
diff changeset
1898 //AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1899 AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(pLevelDecorations[source_id].vPosition.x,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1900 pLevelDecorations[source_id].vPosition.y));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1901 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1902 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1903 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1904 AIL_end_sample(pMixerChannels[i].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1905 FreeChannel(&pMixerChannels[i]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1906 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1907 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1908 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1909
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1910 case OBJECT_Actor:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1911 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1912 assert(source_id < uNumActors);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1913
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1914 //source_x = pActors[source_id].vPosition.x;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1915 //source_y = pActors[source_id].vPosition.y;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1916 //source_z = pActors[source_id].vPosition.z;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1917 int sound_strength = GetSoundStrengthByDistanceFromParty(pActors[source_id].vPosition.x,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1918 pActors[source_id].vPosition.y,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1919 pActors[source_id].vPosition.z);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1920 if ( sound_strength )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1921 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1922 AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1923 AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(pActors[source_id].vPosition.x,
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1924 pActors[source_id].vPosition.y));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1925 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1926 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1927 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1928 AIL_end_sample(pMixerChannels[i].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1929 FreeChannel(&pMixerChannels[i]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1930 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1931 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1932 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1933
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1934 default:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1935 assert(false);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1936 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1937 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1938
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1939 /*if (int sound_strength = GetSoundStrengthByDistanceFromParty(source_x, source_y, source_z))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1940 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1941 AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1942 AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(source_x, source_y));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1943 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1944 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1945 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1946 AIL_end_sample(pMixerChannels[i].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1947 FreeChannel(&pMixerChannels[i]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1948 } */
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1949 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1950
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2534
diff changeset
1951 if (current_screen_type != SCREEN_GAME) //îòêëþ÷åíèå çâóêà äåêîðàöèé ïðè ïåðåêëþ÷åíèè îêíà èãðû
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1952 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1953 if (AIL_sample_status(pMixerChannels[4].hSample) == AIL::Sample::Playing)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1954 AIL_end_sample(pMixerChannels[4].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1955 return;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1956 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1957 if (!_6807E0_num_decorations_with_sounds_6807B8)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1958 return;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1959
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1960 v55 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1961 //v59 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1962 for (uint i = 0; i < _6807E0_num_decorations_with_sounds_6807B8; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1963 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1964 LODWORD(v56) = 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1965 //v43 = _6807B8_level_decorations_ids[v59];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1966 //v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1967 //v45 = abs(v44->vPosition.z - pParty->vPosition.z);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1968 //v46 = abs(v44->vPosition.y - pParty->vPosition.y);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1969 //v47 = abs(v44->vPosition.x - pParty->vPosition.x);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1970 LevelDecoration* decor = &pLevelDecorations[_6807B8_level_decorations_ids[i]];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1971 if (int_get_vector_length(abs(decor->vPosition.x - pParty->vPosition.x),
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1972 abs(decor->vPosition.y - pParty->vPosition.y),
2505
e3a619609dae for sounds of decoration
Ritor1
parents: 2502
diff changeset
1973 abs(decor->vPosition.z - pParty->vPosition.z)) > 8192)
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1974 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1975
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1976 DecorationDesc* decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1977 //v48 = &pDecorationList->pDecorations[decor->uDecorationDescID];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1978 //v49 = v48->uFlags;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1979 uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & DECORATION_DESC_SLOW_LOOP) >> 6;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1980
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1981 if (decor_desc->SoundOnDawn() || decor_desc->SoundOnDusk())
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1982 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1983 //v50 = decor->field_1A;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1984 v55 = 0.0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1985 uNumRepeats = 2;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1986 if (decor->field_1A)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1987 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1988 //v51 = decor->field_1A - 32;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1989 decor->field_1A = decor->field_1A - 32;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1990 if ( decor->field_1A < 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1991 decor->field_1A = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1992 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1993 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1994
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1995 //v52 = v48->uFlags;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1996 if (!decor_desc->SoundOnDawn())
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1997 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1998 if (!decor_desc->SoundOnDusk())
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
1999 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2000 if ( v55 == 0.0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2001 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2002 if ( v56 != 0.0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2003 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2004 v53 = 8 * _6807B8_level_decorations_ids[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2005 LOBYTE(v53) = v53 | OBJECT_Decoration;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2006 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0);//sound of Boat and water(çâóêè êîðàáëÿ, ïëåñêàíèÿ âîäû)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2007 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2008 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2009 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2010 if ( !decor->field_1A )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2011 decor->field_1A = (rand() % 15 + 1) << 7;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2012 if ( v56 != 0.0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2013 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2014 v53 = 8 * _6807B8_level_decorations_ids[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2015 LOBYTE(v53) = v53 | OBJECT_Decoration;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2016 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2017 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2018 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2019 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2020 if ( v55 != 0.0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2021 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2022 if ( !decor->field_1A )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2023 decor->field_1A = (rand() % 15 + 1) << 7;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2024 if ( v56 != 0.0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2025 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2026 v53 = 8 * _6807B8_level_decorations_ids[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2027 LOBYTE(v53) = v53 | OBJECT_Decoration;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2028 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2029 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2030 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2031 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2032 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2033 v56 = 0.0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2034
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2035 if (pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 6 ||
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2036 pParty->uCurrentHour >= 20 && pParty->uCurrentHour < 21)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2037 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2038 if ( !decor->field_1A && rand() % 100 < 100 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2039 LODWORD(v56) = 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2040 LODWORD(v55) = 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2041 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2042 if ( v55 == 0.0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2043 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2044 if ( v56 != 0.0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2045 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2046 v53 = 8 * _6807B8_level_decorations_ids[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2047 LOBYTE(v53) = v53 | OBJECT_Decoration;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2048 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2049 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2050 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2051 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2052 if ( !decor->field_1A )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2053 decor->field_1A = (rand() % 15 + 1) << 7;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2054 if ( v56 != 0.0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2055 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2056 v53 = 8 * _6807B8_level_decorations_ids[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2057 LOBYTE(v53) = v53 | OBJECT_Decoration;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2058 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2059 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2060 continue;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2061 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2062 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2063 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2064
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2065 //----- (004AB66C) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2066 int __fastcall sub_4AB66C(int a1, int a2)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2067 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2068 signed int v2; // eax@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2069
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2070 v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.y)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2071 - stru_5C6E00->uIntegerHalfPi - pParty->sRotationY);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2072 if ( v2 > (signed int)stru_5C6E00->uIntegerPi )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2073 v2 = 2 * stru_5C6E00->uIntegerPi - v2;
2505
e3a619609dae for sounds of decoration
Ritor1
parents: 2502
diff changeset
2074 v2 =(v2 >> 3) - (v2 >> 10) ;
e3a619609dae for sounds of decoration
Ritor1
parents: 2502
diff changeset
2075 return v2;
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2076 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2077 // 4AB66C: using guessed type int __fastcall sub_4AB66C(int, int);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2078
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2079 //----- (004AB6B1) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2080 int GetSoundStrengthByDistanceFromParty(int x, int y, int z)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2081 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2082 int dir_x; // ST08_4@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2083 int dir_y; // esi@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2084 int dir_z; // eax@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2085 int length; // [sp+10h] [bp+8h]@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2086
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2087 dir_z = abs(z - pParty->vPosition.z);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2088 dir_y = abs(y - pParty->vPosition.y);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2089 dir_x = abs(x - pParty->vPosition.x);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2090 length = int_get_vector_length(dir_x, dir_y, dir_z);
2534
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2516
diff changeset
2091 if ( length <= 0x2000 )
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2092 return 114 - (unsigned __int64)(signed __int64)((double)length * 0.0001220703125 * 100.0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2093 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2094 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2095 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2096
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2097 //----- (004AB71F) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2098 void AudioPlayer::StopChannels(int uStartChannel, int uEndChannel)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2099 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2100 if ( bPlayerReady )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2101 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2102 if ( b3DSoundInitialized )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2103 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2104 for ( uint i = 0; i < uNum3DSamples; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2105 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2106 if ( (uStartChannel == -1 || i < uStartChannel || i > uEndChannel)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2107 && p3DSamples[i].field_8 && pSoundList->pSL_Sounds[p3DSamples[i].field_8].eType != SOUND_DESC_SYSTEM)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2108 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2109 AIL_end_3D_sample(p3DSamples[i].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2110 _4ABF23(&p3DSamples[i]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2111 p3DSamples[i].field_4 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2112 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2113 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2114 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2115 if ( hDigDriver )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2116 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2117 for ( int i = 0; i < uMixerChannels; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2118 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2119 if ( (uStartChannel == -1 || i < uStartChannel || i > uEndChannel)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2120 && pSoundList->pSL_Sounds[pMixerChannels[i].uSourceTrackIdx].eType != SOUND_DESC_SYSTEM)//âñå, êðîìå ñèñòåìíûõ çâóêîâ, îòêëþ÷àþòñÿ
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2121 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2122 AIL_end_sample(pMixerChannels[i].hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2123 FreeChannel(&pMixerChannels[i]);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2124 pMixerChannels[i].source_pid = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2125 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2126 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2127 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2128 if (hSequence)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2129 AIL_end_sequence(hSequence);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2130 if (hStream)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2131 AIL_pause_stream(hStream, 1);
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 //----- (004AB818) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2136 void AudioPlayer::LoadAudioSnd()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2137 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2138 DWORD NumberOfBytesRead; // [sp+Ch] [bp-4h]@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2139
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2140 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
2141 if (hAudioSnd == INVALID_HANDLE_VALUE)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2142 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2143 Log::Warning(L"Can't open file: %s", L"Sounds\\Audio.snd");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2144 return;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2145 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2146
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2147 ReadFile(hAudioSnd, &uNumSoundHeaders, 4, &NumberOfBytesRead, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2148 pSoundHeaders = nullptr;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2149 pSoundHeaders = (SoundHeader *)malloc(52 * uNumSoundHeaders + 2);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2150 ReadFile(hAudioSnd, pSoundHeaders, 52 * uNumSoundHeaders, &NumberOfBytesRead, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2151 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2152
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2153 //----- (004AB8CE) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2154 void AudioPlayer::Initialize()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2155 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2156 int v3; // ebx@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2157 _PROVIDER *v6; // eax@9
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2158 int v12; // [sp+Ch] [bp-Ch]@9
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2159 char *Str1; // [sp+10h] [bp-8h]@6
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2160 int v14; // [sp+14h] [bp-4h]@5
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2161
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2162 //WriteWindowsRegistryString( "3DSoundProvider", "Aureal A3D Interactive(TM)");//çàïèñü â ðååñòð äëÿ 3D çâóêà(Microsoft DirectSound3D with Creative Labs EAX(TM))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2163
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2164 v3 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2165 //this->hWindow = hWnd;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2166 this->hAILRedbook = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2167 this->hDigDriver = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2168 this->dword_0002AC = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2169 this->hSequence = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2170 this->uMasterVolume = 127;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2171 this->dword_0002C8 = 64;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2172 this->dword_0002CC = 2;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2173
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2174 MSS32_DLL_Initialize();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2175 BINKW32_DLL_Initialize();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2176 SMACKW32_DLL_Initialize();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2177
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2178 AIL_startup();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2179 if (bCanLoadFromCD)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2180 hAILRedbook = AIL_redbook_open_drive(cMM7GameCDDriveLetter/*cGameCDDriveLetter*/);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2181 //else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2182 // hAILRedbook = AIL_redbook_open(0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2183 //v4 = Audio_GetFirstHardwareDigitalDriver();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2184
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2185 hDigDriver = Audio_GetFirstHardwareDigitalDriver();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2186 if ( hDigDriver )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2187 SmackSoundUseMSS(hDigDriver);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2188 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 && true)//pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2189 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2190 v14 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2191 bEAXSupported = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2192 b3DSoundInitialized = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2193 ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128, "NONE");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2194 CheckA3DSupport(true);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2195 HPROVIDER prov;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2196 while ( AIL_enumerate_3D_providers(&v14, &prov, &Str1) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2197 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2198 if ( !strcmp(Str1, p3DSoundProvider) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2199 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2200 if ( AIL_open_3D_provider(prov) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2201 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2202 bEAXSupported = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2203 b3DSoundInitialized = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2204 h3DSoundProvider = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2205 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2206 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2207 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2208 v6 = prov;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2209 //v7 = prov;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2210 b3DSoundInitialized = 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2211 h3DSoundProvider = v6;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2212 uNum3DSamples = 4;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2213 AIL_3D_provider_attribute(prov, "EAX environment selection", &v12);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2214 if ( v12 != -1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2215 bEAXSupported = 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2216 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2217 pAudioPlayer->_4AC0A2();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2218 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2219 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2220 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2221 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2222 for ( v3; v3 < uMixerChannels; ++v3 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2223 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2224 pMixerChannels[v3].hSample = AIL_allocate_sample_handle(hDigDriver);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2225 if ( !pMixerChannels[v3].hSample )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2226 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2227 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2228 uMixerChannels = v3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2229 if ( bPlayerReady )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2230 StopChannels(-1, -1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2231 //v10 = hAILRedbook;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2232 bPlayerReady = true;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2233 if ( hAILRedbook )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2234 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2235 AIL_redbook_stop(hAILRedbook);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2236 uNumRedbookTracks = AIL_redbook_tracks(hAILRedbook);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2237 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2238 pAudioPlayer->sRedbookVolume = AIL_redbook_volume(hAILRedbook);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2239 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
2240 if ( bPlayerReady )
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
2241 {
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
2242 if ( use_music_folder )
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
2243 alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
2244 else if ( hAILRedbook )
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
2245 AIL_redbook_set_volume(hAILRedbook, (unsigned __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f) >> 32);
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
2246 }
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2247 LoadAudioSnd();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2248 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2249
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2250 //----- (004ABAF7) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2251 _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2252 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2253 int v0; // ecx@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2254 size_t v2; // eax@4
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2255 signed int v3; // kr14_4@9
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2256 int v5; // [sp+10h] [bp-Ch]@2
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2257 unsigned int pNum_devices; // [sp+14h] [bp-8h]@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2258 _DIG_DRIVER *hDrv; // [sp+18h] [bp-4h]@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2259
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2260 static int sample_Rate = 22050;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2261 static int bitsPerSample = 16;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2262 static int channels = 2;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2263
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2264 AIL_set_preference(15, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2265 AIL_set_preference(33, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2266 v0 = sample_Rate;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2267 pAudioPlayer->pDeviceNames[0][0] = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2268 pAudioPlayer->uNumDevices = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2269 pNum_devices = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2270
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2271 if ( sample_Rate < 11025 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2272 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2273 v5 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2274 while ( 1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2275 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2276 while ( 1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2277 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2278 pcmWaveFormat.wf.wFormatTag = WAVE_FORMAT_PCM;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2279 pcmWaveFormat.wf.nChannels = channels; // Channels: 1 = mono, 2 = stereo
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2280 pcmWaveFormat.wf.nSamplesPerSec = v0; //÷àñòîòà îöèôðîâêè
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2281 pcmWaveFormat.wf.nBlockAlign = channels * bitsPerSample / 8; //êîëè÷åñòâî äàííûõ â áëîêå
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2282 pcmWaveFormat.wBitsPerSample = bitsPerSample;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2283 pcmWaveFormat.wf.nAvgBytesPerSec = pcmWaveFormat.wf.nSamplesPerSec * pcmWaveFormat.wf.nBlockAlign;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2284 if ( !AIL_waveOutOpen(&hDrv, 0, -1, &pcmWaveFormat.wf) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2285 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2286 strcpy(pAudioPlayer->pDeviceNames[v5], "Device: ");
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2287 v2 = strlen(pAudioPlayer->pDeviceNames[v5]);
2534
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2516
diff changeset
2288 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
2289 ++pNum_devices;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2290 v5++;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2291 pAudioPlayer->uNumDevices = pNum_devices;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2292 if ( AIL_get_preference(15) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2293 return hDrv;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2294 if ( !strstr(pAudioPlayer->pDeviceNames[v5 - 1], "Emulated") )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2295 return hDrv;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2296 AIL_waveOutClose(hDrv);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2297 AIL_set_preference(15, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2298 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2299 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2300 if ( !AIL_get_preference(15) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2301 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2302 AIL_set_preference(15, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2303 if ( sample_Rate < 11025 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2304 return 0;
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 //v3 = sample_Rate;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2308 v0 = sample_Rate / 2;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2309 sample_Rate /= 2;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2310 if ( sample_Rate / 2 < 11025 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2311 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2312 if ( bitsPerSample == 8 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2313 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2314 v0 = 22050;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2315 bitsPerSample = 8;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2316 sample_Rate = 22050;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2317 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2318 if ( v0 < 11025 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2319 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2320 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2321 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2322 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2323 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2324 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2325
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2326 //----- (004ABC9B) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2327 void AudioPlayer::CheckA3DSupport(bool query)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2328 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2329 DWORD cbData; // [sp+8h] [bp-Ch]@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2330 HKEY hKey; // [sp+10h] [bp-4h]@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2331 hKey = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2332 cbData = 4;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2333 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Aureal\\A3D", 0, KEY_READ|KEY_WOW64_32KEY, &hKey))
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2334 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2335 int Aureal3D_SplashAudio = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2336 if (query)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2337 RegQueryValueExA(hKey, "SplashAudio", 0, 0, (LPBYTE)&Aureal3D_SplashAudio, &cbData);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2338 RegSetValueExA(hKey, "SplashAudio", 0, 4, (const BYTE *)&Aureal3D_SplashAudio, 4);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2339
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2340 int Aureal3D_SplashScreen = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2341 if (query)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2342 RegQueryValueExA(hKey, "SplashScreen", 0, 0, (LPBYTE)&Aureal3D_SplashScreen, &cbData);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2343 RegSetValueExA(hKey, "SplashScreen", 0, 4, (const BYTE *)&Aureal3D_SplashScreen, 4);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2344 RegCloseKey(hKey);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2345 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2346 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2347
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2348
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2349 //----- (004ABD5B) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2350 void AudioPlayer::Release() //Îñâîáîäèòü
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2351 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2352 MixerChannel *pMixerChannel; // ebx@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2353 // char v4; // dl@5
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2354 AudioPlayer_3DSample *p3DSample; // edi@7
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2355 void *v9; // ecx@15
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2356
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2357 if ( this->bPlayerReady )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2358 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2359 free(pSoundHeaders);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2360 CloseHandle(pMediaPlayer->hMagicVid);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2361 CloseHandle(pMediaPlayer->hMightVid);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2362 pAudioPlayer->StopChannels(-1, -1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2363 if ( pAudioPlayer->uMixerChannels > 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2364 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2365 pMixerChannel = pAudioPlayer->pMixerChannels;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2366 for ( uint i = 0; i < pAudioPlayer->uMixerChannels; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2367 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2368 AIL_release_sample_handle(pMixerChannel->hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2369 ++pMixerChannel;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2370 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2371 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2372 if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2373 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2374 CheckA3DSupport(false);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2375 if ( pAudioPlayer->uNum3DSamples > 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2376 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2377 p3DSample = pAudioPlayer->p3DSamples;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2378 for ( uint i = 0; i < pAudioPlayer->uNum3DSamples; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2379 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2380 if ( p3DSample->hSample )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2381 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2382 AIL_release_3D_sample_handle(p3DSample->hSample);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2383 p3DSample->hSample = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2384 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2385 ++p3DSample;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2386 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2387 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2388 if ( pAudioPlayer->h3DSoundProvider )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2389 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2390 AIL_close_3D_provider(pAudioPlayer->h3DSoundProvider);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2391 pAudioPlayer->h3DSoundProvider = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2392 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2393 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2394 if ( pAudioPlayer->hAILRedbook )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2395 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2396 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2397 AIL_redbook_set_volume((HREDBOOK)&pAudioPlayer->hAILRedbook, pAudioPlayer->sRedbookVolume);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2398 AIL_redbook_close(pAudioPlayer->hAILRedbook);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2399 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2400 AIL_shutdown();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2401 pSoundList->Release();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2402 v9 = *(void **)&pAudioPlayer->field_C78[0];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2403 if ( v9 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2404 ReleaseSoundData(v9);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2405 CloseHandle(pAudioPlayer->hAudioSnd);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2406 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2407 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2408
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2409 //----- (004ABE55) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2410 void AudioPlayer::FreeChannel(MixerChannel *pChannel)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2411 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2412 int num_same_sound_on_channels; // eax@8
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2413 int v10; // ecx@12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2414 int v12; // eax@13
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2415 int v14[16]; // [sp+Ch] [bp-48h]@8
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2416 int num_playing_channels; // [sp+4Ch] [bp-8h]@5
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2417
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2418 if (!pSoundList->pSL_Sounds)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2419 return;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2420
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2421 //v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2422 if ( pSoundList->pSL_Sounds[pChannel->uSourceTrackIdx].eType == SOUND_DESC_SWAP)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2423 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2424 if ( pSoundList->pSL_Sounds[pChannel->uSourceTrackIdx].pSoundData[0] &&
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2425 !(pSoundList->pSL_Sounds[pChannel->uSourceTrackIdx].uFlags & SOUND_DESC_SYSTEM) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2426 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2427 num_playing_channels = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2428 num_same_sound_on_channels = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2429 if ( this->uMixerChannels <= 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2430 goto LABEL_16;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2431 for ( uint i = 0; i < uMixerChannels; i++ )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2432 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2433 if ( pChannel->uSourceTrackID == pMixerChannels[i].uSourceTrackID )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2434 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2435 v14[num_same_sound_on_channels++] = i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2436 if ( AIL_sample_status((HSAMPLE)pMixerChannels[i].hSample) == AIL::Sample::Playing)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2437 ++num_playing_channels;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2438 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2439 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2440 if ( !num_playing_channels )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2441 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2442 LABEL_16:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2443 pSoundList->UnloadSound(pChannel->uSourceTrackIdx, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2444 for ( v10 = 0; v10 < num_same_sound_on_channels; v10++ )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2445 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2446 v12 = 16 * (v14[v10] + 47);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2447 pMixerChannels[v14[v10]].uSourceTrackID = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2448 *(unsigned int *)((char *)&bEAXSupported + v12) = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2449 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2450 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2451 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2452 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2453 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2454
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2455 //----- (004ABF23) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2456 void AudioPlayer::_4ABF23(AudioPlayer_3DSample *a2)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2457 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2458 int v2; // ebx@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2459 unsigned __int8 v5; // zf@5
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2460 unsigned __int8 v6; // sf@5
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2461 char *v7; // edi@6
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2462 int v8; // eax@8
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2463 int v10; // ecx@12
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2464 int v11; // eax@13
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2465 int v13[16]; // [sp+Ch] [bp-48h]@8
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2466 int v14; // [sp+4Ch] [bp-8h]@5
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2467 int v15; // [sp+50h] [bp-4h]@5
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2468
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2469 if ( pSoundList->pSL_Sounds )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2470 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2471 //v4 = &pSoundList->pSounds[a2->field_8];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2472 if ( pSoundList->pSL_Sounds[a2->field_8].eType == SOUND_DESC_SWAP)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2473 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2474 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
2475 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2476 v5 = this->uNum3DSamples == 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2477 v6 = this->uNum3DSamples < 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2478 v14 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2479 v15 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2480 if ( v6 | v5 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2481 goto LABEL_16;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2482 v7 = (char *)this->p3DSamples;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2483 __debugbreak();//Ritor1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2484 for ( v2 = 0; v2 < uNum3DSamples; ++v2 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2485 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2486 if ( a2->field_C == *((int *)v7 + 3) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2487 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2488 v8 = v15;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2489 //v9 = this->p3DSamples[v2];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2490 ++v15;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2491 v13[v8] = v2;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2492 if ( AIL_3D_sample_status(&this->p3DSamples[v2]) == 4 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2493 ++v14;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2494 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2495 v7 += 16;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2496 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2497 if ( !v14 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2498 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2499 LABEL_16:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2500 pSoundList->UnloadSound(a2->field_8, 1);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2501 for ( v10 = 0; v10 < v15; v10++ )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2502 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2503 v11 = v13[v10];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2504 *(&bEAXSupported + 4 * (v11 + 2)) = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2505 p3DSamples[v11].field_8 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2506 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2507 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2508 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2509 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2510 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2511 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2512
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2513 //----- (004ABFDB) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2514 void PlayLevelMusic()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2515 {
2534
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2516
diff changeset
2516 unsigned int map_id; // eax@1
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2517
2534
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2516
diff changeset
2518 map_id = pMapStats->GetMapInfo(pCurrentMapName);
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2516
diff changeset
2519 if ( map_id )
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2516
diff changeset
2520 pAudioPlayer->PlayMusicTrack((MusicID)pMapStats->pInfos[map_id].uRedbookTrackID);
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2521 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2522
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2523 //----- (004AC004) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2524 void AudioPlayer::SetEAXPreferences()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2525 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2526 float v4; // [sp+4h] [bp-4h]@2
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2527
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2528 if ( this->bEAXSupported )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2529 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2530 v4 = 0.0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2531 AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX effect volume", (int *)&v4);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2532 v4 = 1.0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2533 AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX damping", (int *)&v4);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2534 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2535 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2536 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2537
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2538 //----- (004AC041) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2539 void AudioPlayer::SetMapEAX()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2540 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2541 unsigned int pMapID; // eax@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2542 int v3; // [sp+4h] [bp-4h]@3
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2543
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2544 pMapID = pMapStats->GetMapInfo(pCurrentMapName);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2545 if ( this->b3DSoundInitialized && this->bEAXSupported )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2546 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2547 v3 = pMapStats->pInfos[pMapID].uEAXEnv;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2548 if ( (unsigned int)v3 >= 0x1A )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2549 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2550 SetEAXPreferences();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2551 this->field_214 = -1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2552 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2553 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2554 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2555 AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX environment selection", &v3);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2556 this->field_214 = v3;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2557 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2558 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2559 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2560 // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2561
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2562 //----- (004AC0A2) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2563 int AudioPlayer::_4AC0A2()
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2564 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2565 unsigned int map_id; // eax@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2566 void *v9; // eax@8
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2567 int v12; // [sp+1Ch] [bp-8h]@1
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2568
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2569 if ( this->b3DSoundInitialized )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2570 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2571 //v5 = &this->uNum3DSamples;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2572 AIL_3D_provider_attribute(this->h3DSoundProvider, "Maximum supported samples", &this->uNum3DSamples);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2573 if ( this->uNum3DSamples > 32 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2574 this->uNum3DSamples = 32;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2575 //v6 = this->uNum3DSamples;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2576 if ( !this->uNum3DSamples )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2577 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2578 this->b3DSoundInitialized = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2579 return -1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2580 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2581 //v13 = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2582 //if ( this->uNum3DSamples > 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2583 //{
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2584 //v8 = this->p3DSamples;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2585 //while ( 1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2586 for ( int i = 0; i < this->uNum3DSamples; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2587 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2588 v9 = (void *)AIL_allocate_3D_sample_handle(this->h3DSoundProvider);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2589 this->p3DSamples[i].hSample = v9;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2590 if ( !v9 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2591 this->uNum3DSamples = i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2592 AIL_set_3D_sample_float_distances(v9, 4096.0, 256.0, 4096.0, 256.0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2593 AIL_set_3D_sample_volume(this->p3DSamples[i].hSample, this->s3DSoundVolume);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2594 //++v8;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2595 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2596 //}
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2597 if ( this->bEAXSupported )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2598 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2599 //v10 = v4;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2600 //v11 = pMapStats->pInfos[map_id].uEAXEnv;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2601 map_id = pMapStats->GetMapInfo(pCurrentMapName);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2602 v12 = pMapStats->pInfos[map_id].uEAXEnv;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2603 if ( pMapStats->pInfos[map_id].uEAXEnv >= 0x1A )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2604 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2605 pAudioPlayer->SetEAXPreferences();
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2606 this->field_214 = -1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2607 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2608 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2609 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2610 AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX environment selection", &v12);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2611 this->field_214 = v12;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2612 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2613 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2614 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2615 return 1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2616 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2617
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2618 //----- (004A96BE) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2619 void ReleaseSoundData(void *_this)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2620 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2621 //for ( uint i = 0; (void *)&pSounds[i].pSoundData < (void *)&pSounds[2999].pSoundData; i++ )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2622 for ( uint i = 0; i < 2999; i++ )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2623 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2624 if ( pSounds[i].pSoundData == _this )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2625 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2626 free(_this);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2627 memset(&pSounds[i], 0, sizeof(pSounds[i]));
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2628 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2629 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2630
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2631 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2632
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2633 //----- (004A96FF) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2634 struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2635 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2636 /* SoundHeader *result; // eax@2
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2637 SoundHeader *pSound;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2638 signed int v6; // ebx@11
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2639
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2640 while ( 1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2641 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2642 v6 = uEnd - uStart;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2643 pSound = &pAudioPlayer->pSoundHeaders[v6 / 2 + uStart];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2644 if ( !pSound )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2645 return false;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2646 result = (SoundHeader *)_stricmp(pName, pSound->pSoundName);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2647 if ( !_stricmp(pName, pSound->pSoundName) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2648 uFindSound_BinSearch_ResultID = v6 / 2 + uStart;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2649 if ( uStart == uEnd )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2650 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2651 uFindSound_BinSearch_ResultID = -1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2652 return result;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2653 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2654 if ( (signed int)result < 0 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2655 break;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2656
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2657 if ( v6 <= 4 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2658 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2659 if ( (signed int)uStart < (signed int)uEnd )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2660 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2661 for ( uint i = uStart; i < (signed int)uEnd; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2662 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2663 if ( !_stricmp(pName, pAudioPlayer->pSoundHeaders[i].pSoundName) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2664 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2665 uFindSound_BinSearch_ResultID = i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2666 return &pAudioPlayer->pSoundHeaders[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2667 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2668 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2669 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2670 uFindSound_BinSearch_ResultID = -1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2671 return false;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2672 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2673
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2674 uStart += v6 / 2;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2675 LABEL_10:
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2676 ;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2677 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2678 if ( v6 > 4 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2679 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2680 uEnd = v6 / 2 + uStart;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2681 goto LABEL_10;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2682 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2683 if ( (signed int)uStart >= (signed int)uEnd )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2684 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2685 uFindSound_BinSearch_ResultID = -1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2686 return false;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2687 }*/
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2688 for ( uint i = uStart; i < (signed int)uEnd; ++i )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2689 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2690 if ( !_stricmp(pName, pAudioPlayer->pSoundHeaders[i].pSoundName) )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2691 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2692 uFindSound_BinSearch_ResultID = i;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2693 return &pAudioPlayer->pSoundHeaders[i];
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2694 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2695 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2696 uFindSound_BinSearch_ResultID = -1;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2697 return false;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2698 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2699 // F1B4C8: using guessed type int uFindSound_BinSearch_ResultID;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2700
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2701 //----- (004A97C6) --------------------------------------------------------
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2702 SoundData *LoadSound(const char *pSoundName, SoundData *pOutBuff, unsigned int uID)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2703 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2704 DWORD NumberOfBytesRead; // [sp+14h] [bp-8h]@8
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2705
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2706 for (uint i = 0; i < 3000; ++i)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2707 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2708 if (pSounds[i].uID == uID)
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2709 return pSounds[i].pSoundData;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2710 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2711 FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2712 if ( uFindSound_BinSearch_ResultID == -1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2713 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2714 if ( pOutBuff == (SoundData *)-1 )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2715 pOutBuff = (SoundData *)malloc(pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize + 4);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2716 SetFilePointer(pAudioPlayer->hAudioSnd, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uFileOffset, 0, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2717 if ( (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize >= (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2718 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2719 pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize = pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2720 if ( pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2721 ReadFile(pAudioPlayer->hAudioSnd, pOutBuff->pData, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize, &NumberOfBytesRead, 0);// Ritor1: pSounds[20]
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2722 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2723 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
2724 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2725 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2726 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2727 uID = (unsigned int)malloc(pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2728 ReadFile(pAudioPlayer->hAudioSnd, (LPVOID)uID, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize, &NumberOfBytesRead, 0);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2729 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
2730 free((void *)uID);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2731 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2732 if ( pOutBuff )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2733 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2734 pOutBuff->uDataSize = pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize;
2506
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
2735
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
2736 if ( uID == SOUND_StartMainChoice02 )//Ritor1: code included (BUG)
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
2737 {
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
2738 char *p = (char *)pOutBuff->pData;
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
2739 p = p+7;
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
2740 memcpy(&pOutBuff->pData, p, NumberOfBytesRead - 7);
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
2741 pOutBuff->uDataSize = NumberOfBytesRead - 7;
9b96a51011fb for sound
Ritor1
parents: 2505
diff changeset
2742 }
2502
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2743 uLastLoadedSoundID = 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2744 if ( pSounds[0].pSoundData )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2745 {
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2746 for ( uint i = 0; pSounds[i].pSoundData; i++ )
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2747 ++uLastLoadedSoundID;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2748 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2749 strcpy((char *)pSounds[uLastLoadedSoundID].SoundName, pSoundName);
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2750 pSoundList->uTotalLoadedSoundSize += pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2751 pSounds[uLastLoadedSoundID].pSoundData = pOutBuff;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2752 return pOutBuff;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2753 }
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2754 else
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2755 return 0;
a77c34acdbc9 Media folder
Ritor1
parents:
diff changeset
2756 }