equal
deleted
inserted
replaced
28 procedure PlayMusic; |
28 procedure PlayMusic; |
29 procedure StopSound(snd: TSound); |
29 procedure StopSound(snd: TSound); |
30 function ChangeVolume(voldelta: LongInt): LongInt; |
30 function ChangeVolume(voldelta: LongInt): LongInt; |
31 procedure InitPlaylistChunk(seed: LongWord); |
31 procedure InitPlaylistChunk(seed: LongWord); |
32 |
32 |
|
33 var MusicFN: shortstring = ''; |
|
34 |
33 implementation |
35 implementation |
34 uses uMisc, uConsole; |
36 uses uMisc, uConsole; |
35 |
|
36 {$INCLUDE playlist.inc} |
|
37 |
37 |
38 const chanTPU = 12; |
38 const chanTPU = 12; |
39 var Mus: PMixMusic = nil; |
39 var Mus: PMixMusic = nil; |
40 Volume: LongInt; |
40 Volume: LongInt; |
41 {$IFDEF HAVE_MUSIC} |
|
42 CurrMusic: Longword = 0; |
|
43 {$ENDIF} |
|
44 |
41 |
45 procedure InitSound; |
42 procedure InitSound; |
46 begin |
43 begin |
47 if not isSoundEnabled then exit; |
44 if not isSoundEnabled then exit; |
48 WriteToConsole('Init sound...'); |
45 WriteToConsole('Init sound...'); |
50 if isSoundEnabled then |
47 if isSoundEnabled then |
51 isSoundEnabled:= Mix_OpenAudio(22050, $8010, 2, 512) = 0; |
48 isSoundEnabled:= Mix_OpenAudio(22050, $8010, 2, 512) = 0; |
52 if isSoundEnabled then WriteLnToConsole(msgOK) |
49 if isSoundEnabled then WriteLnToConsole(msgOK) |
53 else WriteLnToConsole(msgFailed); |
50 else WriteLnToConsole(msgFailed); |
54 Mix_AllocateChannels(Succ(chanTPU)); |
51 Mix_AllocateChannels(Succ(chanTPU)); |
55 Mix_VolumeMusic(48); |
52 Mix_VolumeMusic(64); |
56 |
53 |
57 Volume:= cInitVolume; |
54 Volume:= cInitVolume; |
58 if Volume < 0 then Volume:= 0; |
55 if Volume < 0 then Volume:= 0; |
59 Volume:= Mix_Volume(-1, Volume) |
56 Volume:= Mix_Volume(-1, Volume) |
60 end; |
57 end; |
97 if Mix_Playing(Soundz[snd].lastChan) <> 0 then |
94 if Mix_Playing(Soundz[snd].lastChan) <> 0 then |
98 Mix_HaltChannel(Soundz[snd].lastChan) |
95 Mix_HaltChannel(Soundz[snd].lastChan) |
99 end; |
96 end; |
100 |
97 |
101 procedure PlayMusic; |
98 procedure PlayMusic; |
102 {$IFDEF HAVE_MUSIC} |
|
103 var s: string; |
99 var s: string; |
104 {$ENDIF} |
|
105 begin |
100 begin |
106 {$IFDEF HAVE_MUSIC} |
101 if (not isSoundEnabled) |
107 if not isSoundEnabled then exit; |
102 or (MusicFN = '') then exit; |
108 if Mix_PlayingMusic() <> 0 then exit; |
|
109 |
103 |
110 Mix_FreeMusic(Mus); |
104 s:= PathPrefix + '/Music/' + MusicFN; |
111 |
|
112 CurrMusic:= playlistchain[CurrMusic]; |
|
113 |
|
114 s:= PathPrefix + '/Music/' + playlist[CurrMusic]; |
|
115 WriteToConsole(msgLoading + s + ' '); |
105 WriteToConsole(msgLoading + s + ' '); |
116 |
106 |
117 Mus:= Mix_LoadMUS(Str2PChar(s)); |
107 Mus:= Mix_LoadMUS(Str2PChar(s)); |
118 TryDo(Mus <> nil, msgFailed, false); |
108 TryDo(Mus <> nil, msgFailed, false); |
119 WriteLnToConsole(msgOK); |
109 WriteLnToConsole(msgOK); |
120 |
110 |
121 Mix_PlayMusic(Mus, 1) |
111 Mix_PlayMusic(Mus, -1) |
122 {$ENDIF} |
|
123 end; |
112 end; |
124 |
113 |
125 function ChangeVolume(voldelta: LongInt): LongInt; |
114 function ChangeVolume(voldelta: LongInt): LongInt; |
126 begin |
115 begin |
127 if not isSoundEnabled then |
116 if not isSoundEnabled then |