annotate Media/Audio/AudioPlayer.cpp @ 2575:a76d408c5132 tip

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