1 //Copyright Paul Reiche, Fred Ford. 1992-2002
2
3 /*
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include "settings.h"
20
21 #include "globdata.h"
22 #include "libs/compiler.h"
23
24
25 static MUSIC_REF LastMusicRef;
26 static BOOLEAN LastContinuous;
27 static BYTE LastPriority;
28
29 void
ToggleMusic(void)30 ToggleMusic (void)
31 {
32 GLOBAL (glob_flags) ^= MUSIC_DISABLED;
33 if (LastPriority <= 1)
34 {
35 if (GLOBAL (glob_flags) & MUSIC_DISABLED)
36 PLRStop (LastMusicRef);
37 else if (LastMusicRef)
38 PLRPlaySong (LastMusicRef, LastContinuous, LastPriority);
39 }
40 }
41
42 void
PlayMusic(MUSIC_REF MusicRef,BOOLEAN Continuous,BYTE Priority)43 PlayMusic (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE Priority)
44 {
45 LastMusicRef = MusicRef;
46 LastContinuous = Continuous;
47 LastPriority = Priority;
48
49 if (
50 #ifdef NEVER
51 Priority > 1
52 ||
53 #endif /* NEVER */
54 !(GLOBAL (glob_flags) & MUSIC_DISABLED)
55 )
56 {
57 PLRPlaySong (MusicRef, Continuous, Priority);
58 }
59 }
60
61 void
StopMusic(void)62 StopMusic (void)
63 {
64 PLRStop (LastMusicRef);
65 LastMusicRef = 0;
66 }
67
68 void
ResumeMusic(void)69 ResumeMusic (void)
70 {
71 PLRResume (LastMusicRef);
72 }
73
74 void
PauseMusic(void)75 PauseMusic (void)
76 {
77 PLRPause (LastMusicRef);
78 }
79
80 void
ToggleSoundEffect(void)81 ToggleSoundEffect (void)
82 {
83 GLOBAL (glob_flags) ^= SOUND_DISABLED;
84 }
85
86 void
PlaySoundEffect(SOUND S,COUNT Channel,SoundPosition Pos,void * PositionalObject,BYTE Priority)87 PlaySoundEffect (SOUND S, COUNT Channel, SoundPosition Pos,
88 void *PositionalObject, BYTE Priority)
89 {
90 if (!(GLOBAL (glob_flags) & SOUND_DISABLED))
91 {
92 SetChannelVolume (Channel, MAX_VOLUME >> 1, Priority);
93 //SetChannelRate (Channel, GetSampleRate (S), Priority);
94 PlayChannel (Channel, S, Pos, PositionalObject, Priority);
95 }
96 }
97
98