equal
deleted
inserted
replaced
168 end; |
168 end; |
169 |
169 |
170 procedure InitSound; |
170 procedure InitSound; |
171 const channels: LongInt = {$IFDEF MOBILE}1{$ELSE}2{$ENDIF}; |
171 const channels: LongInt = {$IFDEF MOBILE}1{$ELSE}2{$ENDIF}; |
172 begin |
172 begin |
173 if (not isSoundEnabled) then |
173 if not isSoundEnabled then |
174 exit; |
174 exit; |
175 WriteToConsole('Init sound...'); |
175 WriteToConsole('Init sound...'); |
176 isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; |
176 isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; |
177 |
177 |
178 if isSoundEnabled then |
178 if isSoundEnabled then |
266 if (voicepack <> nil) then |
266 if (voicepack <> nil) then |
267 begin |
267 begin |
268 if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
268 if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
269 begin |
269 begin |
270 s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
270 s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
271 if (not FileExists(s)) then |
271 if not FileExists(s) then |
272 s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
272 s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
273 if (not FileExists(s)) and (snd in [sndFirePunch2, sndFirePunch3, sndFirePunch4, sndFirePunch5, sndFirePunch6]) then |
273 if (not FileExists(s)) and (snd in [sndFirePunch2, sndFirePunch3, sndFirePunch4, sndFirePunch5, sndFirePunch6]) then |
274 s:= Pathz[Soundz[sndFirePunch1].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
274 s:= Pathz[Soundz[sndFirePunch1].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
275 WriteToConsole(msgLoading + s + ' '); |
275 WriteToConsole(msgLoading + s + ' '); |
276 voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); |
276 voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); |
284 else |
284 else |
285 begin |
285 begin |
286 if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
286 if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
287 begin |
287 begin |
288 s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
288 s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
289 if (not FileExists(s)) then |
289 if not FileExists(s) then |
290 s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
290 s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
291 WriteToConsole(msgLoading + s + ' '); |
291 WriteToConsole(msgLoading + s + ' '); |
292 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); |
292 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); |
293 SDLTry(defVoicepack^.chunks[snd] <> nil, true); |
293 SDLTry(defVoicepack^.chunks[snd] <> nil, true); |
294 WriteLnToConsole(msgOK); |
294 WriteLnToConsole(msgOK); |
368 if (voicepack <> nil) then |
368 if (voicepack <> nil) then |
369 begin |
369 begin |
370 if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
370 if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
371 begin |
371 begin |
372 s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
372 s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
373 if (not FileExists(s)) then |
373 if not FileExists(s) then |
374 s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
374 s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
375 WriteToConsole(msgLoading + s + ' '); |
375 WriteToConsole(msgLoading + s + ' '); |
376 voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); |
376 voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); |
377 if voicepack^.chunks[snd] = nil then |
377 if voicepack^.chunks[snd] = nil then |
378 WriteLnToConsole(msgFailed) |
378 WriteLnToConsole(msgFailed) |
384 else |
384 else |
385 begin |
385 begin |
386 if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
386 if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
387 begin |
387 begin |
388 s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
388 s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
389 if (not FileExists(s)) then |
389 if not FileExists(s) then |
390 s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
390 s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
391 WriteToConsole(msgLoading + s + ' '); |
391 WriteToConsole(msgLoading + s + ' '); |
392 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); |
392 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); |
393 SDLTry(defVoicepack^.chunks[snd] <> nil, true); |
393 SDLTry(defVoicepack^.chunks[snd] <> nil, true); |
394 WriteLnToConsole(msgOK); |
394 WriteLnToConsole(msgOK); |
400 end; |
400 end; |
401 end; |
401 end; |
402 |
402 |
403 procedure StopSound(snd: TSound); |
403 procedure StopSound(snd: TSound); |
404 begin |
404 begin |
405 if (not isSoundEnabled) then |
405 if not isSoundEnabled then |
406 exit; |
406 exit; |
407 |
407 |
408 if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then |
408 if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then |
409 begin |
409 begin |
410 Mix_HaltChannel(lastChan[snd]); |
410 Mix_HaltChannel(lastChan[snd]); |
412 end; |
412 end; |
413 end; |
413 end; |
414 |
414 |
415 procedure StopSoundChan(chn: LongInt); |
415 procedure StopSoundChan(chn: LongInt); |
416 begin |
416 begin |
417 if (not isSoundEnabled) then |
417 if not isSoundEnabled then |
418 exit; |
418 exit; |
419 |
419 |
420 if (chn <> -1) and (Mix_Playing(chn) <> 0) then |
420 if (chn <> -1) and (Mix_Playing(chn) <> 0) then |
421 Mix_HaltChannel(chn); |
421 Mix_HaltChannel(chn); |
422 end; |
422 end; |
423 |
423 |
424 procedure StopSoundChan(chn, fadems: LongInt); |
424 procedure StopSoundChan(chn, fadems: LongInt); |
425 begin |
425 begin |
426 if (not isSoundEnabled) then |
426 if not isSoundEnabled then |
427 exit; |
427 exit; |
428 |
428 |
429 if (chn <> -1) and (Mix_Playing(chn) <> 0) then |
429 if (chn <> -1) and (Mix_Playing(chn) <> 0) then |
430 Mix_FadeOutChannel(chn, fadems); |
430 Mix_FadeOutChannel(chn, fadems); |
431 end; |
431 end; |
435 begin |
435 begin |
436 if (not isSoundEnabled) or (MusicFN = '') or (not isMusicEnabled) then |
436 if (not isSoundEnabled) or (MusicFN = '') or (not isMusicEnabled) then |
437 exit; |
437 exit; |
438 |
438 |
439 s:= UserPathPrefix + '/Data/Music/' + MusicFN; |
439 s:= UserPathPrefix + '/Data/Music/' + MusicFN; |
440 if (not FileExists(s)) then |
440 if not FileExists(s) then |
441 s:= PathPrefix + '/Music/' + MusicFN; |
441 s:= PathPrefix + '/Music/' + MusicFN; |
442 WriteToConsole(msgLoading + s + ' '); |
442 WriteToConsole(msgLoading + s + ' '); |
443 |
443 |
444 Mus:= Mix_LoadMUS(Str2PChar(s)); |
444 Mus:= Mix_LoadMUS(Str2PChar(s)); |
445 SDLTry(Mus <> nil, false); |
445 SDLTry(Mus <> nil, false); |