Rev 342 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 342 | Rev 374 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | 45 | ||
Line 46... | Line 46... | ||
46 | //#include "qmus2mid.h" |
46 | //#include "qmus2mid.h" |
- | 47 | ||
Line 47... | Line 48... | ||
47 | 48 | ||
Line 48... | Line 49... | ||
48 | 49 | #include "kolibri.h" |
|
49 | #include "kolibri.h" |
50 | #include "sound.h" |
Line 163... | Line 164... | ||
163 | // Initializes sound stuff, including volume |
164 | // Initializes sound stuff, including volume |
164 | // Sets channels, SFX and music volume, |
165 | // Sets channels, SFX and music volume, |
165 | // allocates channel buffer, sets S_sfx lookup. |
166 | // allocates channel buffer, sets S_sfx lookup. |
166 | // |
167 | // |
Line -... | Line 168... | ||
- | 168 | ||
167 | 169 | ||
168 | DWORD hMixBuff[4]; |
170 | SNDBUF hMixBuff; |
- | 171 | volatile int sound_state; |
|
- | 172 | void sound_proc(void); |
|
Line 169... | Line 173... | ||
169 | int mix_ptr; |
173 | void I_UpdateSound( void ); |
170 | 174 | ||
171 | void S_Init |
175 | void S_Init |
172 | ( int sfxVolume, |
176 | ( int sfxVolume, |
173 | int musicVolume ) |
177 | int musicVolume ) |
174 | { |
- | |
175 | int i; |
178 | { |
176 | - | ||
177 | printf("S_Init: default sfx volume %d\n", sfxVolume); |
179 | int i; |
178 | - | ||
179 | InitSound(); |
- | |
180 | - | ||
181 | hMixBuff[0]= CreateBuffer(15); |
- | |
182 | hMixBuff[1]= CreateBuffer(15); |
- | |
Line 183... | Line 180... | ||
183 | hMixBuff[2]= CreateBuffer(15); |
180 | char *thread_stack; |
Line 184... | Line 181... | ||
184 | hMixBuff[3]= CreateBuffer(15); |
181 | int ver; |
185 | 182 | ||
Line 206... | Line 203... | ||
206 | mus_paused = 0; |
203 | mus_paused = 0; |
Line 207... | Line 204... | ||
207 | 204 | ||
208 | // Note that sounds have not been cached (yet). |
205 | // Note that sounds have not been cached (yet). |
209 | for (i=1 ; i |
206 | for (i=1 ; i |
- | 207 | S_sfx[i].lumpnum = S_sfx[i].usefulness = -1; |
|
- | 208 | ||
- | 209 | ||
- | 210 | /******** |
|
- | 211 | if((ver = InitSound())< SOUND_VERSION ) |
|
- | 212 | { |
|
- | 213 | printf("Sound service version mismatch\n\r"); |
|
- | 214 | printf("Installed version: %d, required version %d\n\r", |
|
- | 215 | ver, SOUND_VERSION); |
|
- | 216 | }; |
|
- | 217 | ||
- | 218 | hMixBuff = CreateBuffer(PCM_2_16_11,0); |
|
- | 219 | ||
- | 220 | *********/ |
|
- | 221 | ||
- | 222 | thread_stack = UserAlloc(4096); |
|
- | 223 | thread_stack+=4092; |
|
- | 224 | ||
- | 225 | sound_state=1; |
|
210 | S_sfx[i].lumpnum = S_sfx[i].usefulness = -1; |
226 | CreateThread(sound_proc, thread_stack); |
Line -... | Line 227... | ||
- | 227 | } |
|
- | 228 | ||
- | 229 | typedef struct |
|
- | 230 | { |
|
- | 231 | unsigned int code; |
|
- | 232 | unsigned int sender; |
|
- | 233 | unsigned int stream; |
|
- | 234 | unsigned int offset; |
|
- | 235 | unsigned int size; |
|
- | 236 | unsigned int unused; |
|
- | 237 | }SND_EVENT; |
|
- | 238 | ||
- | 239 | unsigned int mix_offset; |
|
- | 240 | int mix_size; |
|
- | 241 | extern signed short *mixbuffer; |
|
- | 242 | ||
- | 243 | void sound_proc(void) |
|
- | 244 | { |
|
- | 245 | int ver; |
|
- | 246 | SND_EVENT evnt; |
|
- | 247 | int i; |
|
- | 248 | ||
- | 249 | if((ver = InitSound())< SOUND_VERSION ) |
|
- | 250 | { |
|
- | 251 | printf("Sound service version mismatch\n\r"); |
|
- | 252 | printf("Installed version: %d, required version %d\n\r", |
|
- | 253 | ver, SOUND_VERSION); |
|
- | 254 | }; |
|
- | 255 | ||
- | 256 | hMixBuff=CreateBuffer(PCM_2_16_11|PCM_RING,0); |
|
- | 257 | ||
- | 258 | if(!hMixBuff) |
|
- | 259 | { |
|
- | 260 | printf("sound not available\n\r"); |
|
- | 261 | _asm |
|
- | 262 | { |
|
- | 263 | mov eax, -1 |
|
- | 264 | int 0x40 |
|
- | 265 | }; |
|
- | 266 | }; |
|
- | 267 | ||
- | 268 | mix_size=GetBufferSize(hMixBuff)/2; |
|
- | 269 | printf("mixer size %d\n\r", mix_size); |
|
- | 270 | ||
- | 271 | mixbuffer = malloc(mix_size); |
|
- | 272 | ||
- | 273 | PlayBuffer(hMixBuff, 0); |
|
- | 274 | while(sound_state) |
|
- | 275 | { |
|
- | 276 | GetNotify(&evnt); |
|
- | 277 | ||
- | 278 | if(evnt.code != 0xFF000001) |
|
- | 279 | { |
|
- | 280 | printf("invalid code %d\n\r", evnt.code); |
|
- | 281 | continue; |
|
- | 282 | } |
|
- | 283 | ||
- | 284 | if(evnt.stream != hMixBuff) |
|
- | 285 | { |
|
- | 286 | printf("invalid stream %d hMixBuff= %d\n\r", evnt.stream, hMixBuff); |
|
- | 287 | continue; |
|
- | 288 | }; |
|
- | 289 | mix_offset= evnt.offset; |
|
- | 290 | I_UpdateSound(); |
|
- | 291 | }; |
|
- | 292 | ||
- | 293 | //flush sound buffers |
|
- | 294 | ||
- | 295 | for(i=0; i<32; i++) |
|
- | 296 | { |
|
- | 297 | GetNotify(&evnt); |
|
- | 298 | ||
- | 299 | if(evnt.code != 0xFF000001) |
|
- | 300 | { |
|
- | 301 | printf("invalid code %d\n\r", evnt.code); |
|
- | 302 | continue; |
|
- | 303 | } |
|
- | 304 | ||
- | 305 | if(evnt.stream != hMixBuff) |
|
- | 306 | { |
|
- | 307 | printf("invalid stream %d hMixBuff= %d\n\r", evnt.stream, hMixBuff); |
|
- | 308 | continue; |
|
- | 309 | }; |
|
- | 310 | mix_offset= evnt.offset; |
|
- | 311 | I_UpdateSound(); |
|
- | 312 | }; |
|
- | 313 | ||
- | 314 | _asm |
|
- | 315 | { |
|
- | 316 | mov eax, -1 |
|
- | 317 | int 0x40 |
|
- | 318 | }; |
|
- | 319 | ||
211 | } |
320 | }; |
212 | 321 | ||
213 | // |
322 | // |
214 | // Per level startup code. |
323 | // Per level startup code. |
215 | // Kills playing sounds at start of level, |
324 | // Kills playing sounds at start of level, |