2 Cantaveria - action adventure platform game
3 Copyright (C) 2009 2010 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
22 evanrinehart@gmail.com
34 mus_id current_id
= MUS_NOTHING
;
37 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
38 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
39 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
40 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
48 static char* mus_name(mus_id id
){
50 case MUS_NOTHING
: return "MUS_NOTHING";
51 case MUS_COOL
: return "MUS_COOL";
52 case MUS_TEST1
: return "MUS_TEST1";
53 default: return "(?)";
57 static int is_id_invalid(mus_id id
){
58 if(id
>= 32) return 1;
63 int music_load(char* filename
, mus_id id
){
66 if(id
== MUS_NOTHING
){
67 error_msg("music_load: you can't load a song into MUS_NOTHING\n");
71 if(is_id_invalid(id
)){
72 error_msg("music_load: music id out of range (%d)\n", id
);
76 if(songs
[id
] != NULL
){
77 error_msg("music_load: slot %s not empty\n", mus_name(id
));
81 events
= midi_load(filename
);
83 error_msg("music_load: unable to load \"%s\"\n", filename
);
88 positions
[id
] = events
->next
;
92 void music_unload(mus_id id
){
93 if(is_id_invalid(id
)) return;
94 if(songs
[id
] == NULL
) return;
96 if(music_current() == id
) music_stop(id
);
98 list
* ptr
= songs
[id
]->next
;
104 recycle(songs
[id
]->next
);
108 mus_id
music_current(){
112 void music_play(mus_id id
){
113 if(is_id_invalid(id
)) return;
114 if(songs
[id
] == NULL
) return;
115 if(music_current() == id
&& playing
) return;
117 if(playing
) music_pause();
119 seq_seek(positions
[id
]);
127 void music_stop(mus_id id
){
128 if(is_id_invalid(id
)) return;
129 if(songs
[id
] == NULL
) return;
130 if(music_current() == id
){
141 positions
[music_current()] = seq_tell();
144 void music_volume(int percent
){
145 seq_instant(EVX_MUSICVOLUME
, 0, percent
, 0);
148 void music_fadeout(int seconds
){
149 seq_instant(EVX_FADEOUT
, 0, seconds
, 0);
152 void music_print(mus_id id
){