equal
deleted
inserted
replaced
28 end; |
28 end; |
29 |
29 |
30 procedure InitSound; |
30 procedure InitSound; |
31 procedure ReleaseSound; |
31 procedure ReleaseSound; |
32 procedure SoundLoad; |
32 procedure SoundLoad; |
33 procedure PlaySound(snd: TSound; infinite: boolean); |
33 procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack); |
34 procedure PlayMusic; |
34 procedure PlayMusic; |
35 procedure StopSound(snd: TSound); |
35 procedure StopSound(snd: TSound); |
36 function ChangeVolume(voldelta: LongInt): LongInt; |
36 function ChangeVolume(voldelta: LongInt): LongInt; |
37 |
37 |
38 function AskForVoicepack(name: shortstring): Pointer; |
38 function AskForVoicepack(name: shortstring): Pointer; |
39 procedure SetVoicePack(vp: PVoicePack); |
|
40 |
39 |
41 var MusicFN: shortstring = ''; |
40 var MusicFN: shortstring = ''; |
42 |
41 |
43 implementation |
42 implementation |
44 uses uMisc, uConsole; |
43 uses uMisc, uConsole; |
47 var Mus: PMixMusic = nil; |
46 var Mus: PMixMusic = nil; |
48 Volume: LongInt; |
47 Volume: LongInt; |
49 lastChan: array [TSound] of LongInt; |
48 lastChan: array [TSound] of LongInt; |
50 voicepacks: array[0..cMaxTeams] of TVoicepack; |
49 voicepacks: array[0..cMaxTeams] of TVoicepack; |
51 defVoicepack: PVoicepack; |
50 defVoicepack: PVoicepack; |
52 currentVP: PVoicepack; |
|
53 |
51 |
54 function AskForVoicepack(name: shortstring): Pointer; |
52 function AskForVoicepack(name: shortstring): Pointer; |
55 var i: Longword; |
53 var i: Longword; |
56 begin |
54 begin |
57 i:= 0; |
55 i:= 0; |
61 TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) |
59 TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) |
62 end; |
60 end; |
63 |
61 |
64 voicepacks[i].name:= name; |
62 voicepacks[i].name:= name; |
65 AskForVoicepack:= @voicepacks[i] |
63 AskForVoicepack:= @voicepacks[i] |
66 end; |
|
67 |
|
68 procedure SetVoicePack(vp: PVoicePack); |
|
69 begin |
|
70 currentVP:= vp |
|
71 end; |
64 end; |
72 |
65 |
73 procedure InitSound; |
66 procedure InitSound; |
74 begin |
67 begin |
75 if not isSoundEnabled then exit; |
68 if not isSoundEnabled then exit; |
107 t: Longword; |
100 t: Longword; |
108 begin |
101 begin |
109 if not isSoundEnabled then exit; |
102 if not isSoundEnabled then exit; |
110 |
103 |
111 defVoicepack:= AskForVoicepack('Default'); |
104 defVoicepack:= AskForVoicepack('Default'); |
112 SetVoicePack(defVoicepack); |
|
113 |
105 |
114 for i:= Low(TSound) to High(TSound) do |
106 for i:= Low(TSound) to High(TSound) do |
115 if Soundz[i].Path <> ptVoices then |
107 if Soundz[i].Path <> ptVoices then |
116 begin |
108 begin |
117 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
109 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
134 else |
126 else |
135 WriteLnToConsole(msgOK) |
127 WriteLnToConsole(msgOK) |
136 end; |
128 end; |
137 end; |
129 end; |
138 |
130 |
139 procedure PlaySound(snd: TSound; infinite: boolean); |
131 procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack); |
140 var loops: LongInt; |
132 var loops: LongInt; |
141 begin |
133 begin |
142 if (not isSoundEnabled) or fastUntilLag then exit; |
134 if (not isSoundEnabled) or fastUntilLag then exit; |
143 if infinite then loops:= -1 else loops:= 0; |
135 if infinite then loops:= -1 else loops:= 0; |
144 |
136 |
145 if currentVP^.chunks[snd] <> nil then |
137 if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then |
146 lastChan[snd]:= Mix_PlayChannelTimed(-1, currentVP^.chunks[snd], loops, -1) |
138 lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], loops, -1) |
147 else |
139 else |
148 lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], loops, -1) |
140 lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], loops, -1) |
149 end; |
141 end; |
150 |
142 |
151 procedure StopSound(snd: TSound); |
143 procedure StopSound(snd: TSound); |