annotate Media/Audio/AudioPlayer.cpp @ 2509:fc5e83bbafd1

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