43 function LoopSound(snd: TSound): LongInt; |
37 function LoopSound(snd: TSound): LongInt; |
44 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
38 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
45 procedure PlayMusic; |
39 procedure PlayMusic; |
46 procedure PauseMusic; |
40 procedure PauseMusic; |
47 procedure ResumeMusic; |
41 procedure ResumeMusic; |
|
42 procedure ChangeMusic; |
48 procedure StopSound(snd: TSound); |
43 procedure StopSound(snd: TSound); |
49 procedure StopSound(chn: LongInt); |
44 procedure StopSound(chn: LongInt); |
50 function ChangeVolume(voldelta: LongInt): LongInt; |
45 function ChangeVolume(voldelta: LongInt): LongInt; |
51 function AskForVoicepack(name: shortstring): Pointer; |
46 function AskForVoicepack(name: shortstring): Pointer; |
52 |
47 |
53 |
48 |
54 implementation |
49 implementation |
55 uses uMisc, uConsole; |
50 uses uVariables, uConsole, uUtils, uCommands, uDebug, uMobile; |
56 |
51 |
57 const chanTPU = 32; |
52 const chanTPU = 32; |
58 var Volume: LongInt; |
53 var Volume: LongInt; |
59 lastChan: array [TSound] of LongInt; |
54 lastChan: array [TSound] of LongInt; |
60 voicepacks: array[0..cMaxTeams] of TVoicepack; |
55 voicepacks: array[0..cMaxTeams] of TVoicepack; |
151 |
146 |
152 for i:= Low(TSound) to High(TSound) do |
147 for i:= Low(TSound) to High(TSound) do |
153 begin |
148 begin |
154 defVoicepack^.chunks[i]:= nil; |
149 defVoicepack^.chunks[i]:= nil; |
155 // preload all the big sound files (>32k) that would otherwise lockup the game |
150 // preload all the big sound files (>32k) that would otherwise lockup the game |
156 if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
151 if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, |
|
152 sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
157 and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
153 and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
158 begin |
154 begin |
159 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
155 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
160 WriteToConsole(msgLoading + s + ' '); |
156 WriteToConsole(msgLoading + s + ' '); |
161 defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
157 defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
321 exit; |
317 exit; |
322 |
318 |
323 Mix_ResumeMusic(Mus); |
319 Mix_ResumeMusic(Mus); |
324 end; |
320 end; |
325 |
321 |
|
322 procedure ChangeMusic; |
|
323 begin |
|
324 if (MusicFN = '') or (not isMusicEnabled) then |
|
325 exit; |
|
326 |
|
327 if Mus <> nil then |
|
328 Mix_FreeMusic(Mus); |
|
329 |
|
330 PlayMusic; |
|
331 end; |
|
332 |
|
333 procedure chVoicepack(var s: shortstring); |
|
334 begin |
|
335 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/voicepack"', true); |
|
336 if s[1]='"' then Delete(s, 1, 1); |
|
337 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
338 CurrentTeam^.voicepack:= AskForVoicepack(s) |
|
339 end; |
|
340 |
326 procedure initModule; |
341 procedure initModule; |
327 begin |
342 begin |
|
343 RegisterVariable('voicepack', vtCommand, @chVoicepack, false); |
328 MusicFN:=''; |
344 MusicFN:=''; |
329 end; |
345 end; |
330 |
346 |
331 procedure freeModule; |
347 procedure freeModule; |
332 begin |
348 begin |