sound looping
This commit is contained in:
parent
14d36f312c
commit
9adc1222ac
|
@ -1105,6 +1105,7 @@ void game_sound_player(void)
|
||||||
wav_t w;
|
wav_t w;
|
||||||
char *snd;
|
char *snd;
|
||||||
int chan = -1;
|
int chan = -1;
|
||||||
|
int loop = 1;
|
||||||
|
|
||||||
if (!snd_volume_mus(-1))
|
if (!snd_volume_mus(-1))
|
||||||
return;
|
return;
|
||||||
|
@ -1113,6 +1114,12 @@ void game_sound_player(void)
|
||||||
chan = atoi(snd);
|
chan = atoi(snd);
|
||||||
free(snd);
|
free(snd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snd = instead_eval("return get_sound_loop()");
|
||||||
|
if (snd) {
|
||||||
|
loop = atoi(snd);
|
||||||
|
free(snd);
|
||||||
|
}
|
||||||
|
|
||||||
snd = instead_eval("return get_sound()");
|
snd = instead_eval("return get_sound()");
|
||||||
if (!snd) {
|
if (!snd) {
|
||||||
|
@ -1135,7 +1142,7 @@ void game_sound_player(void)
|
||||||
free(snd);
|
free(snd);
|
||||||
if (!w)
|
if (!w)
|
||||||
return;
|
return;
|
||||||
snd_play(w, chan);
|
snd_play(w, chan, loop - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *horiz_inv(char *invstr)
|
char *horiz_inv(char *invstr)
|
||||||
|
@ -1658,7 +1665,7 @@ int game_click(int x, int y, int action, int filter)
|
||||||
if (mouse_filter(filter))
|
if (mouse_filter(filter))
|
||||||
return 0;
|
return 0;
|
||||||
if (opt_click)
|
if (opt_click)
|
||||||
snd_play(game_theme.click, -1);
|
snd_play(game_theme.click, -1, 0);
|
||||||
game_cmd(buf);
|
game_cmd(buf);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -1681,7 +1688,7 @@ int game_click(int x, int y, int action, int filter)
|
||||||
disable_use();
|
disable_use();
|
||||||
|
|
||||||
if (opt_click)
|
if (opt_click)
|
||||||
snd_play(game_theme.click, -1);
|
snd_play(game_theme.click, -1, 0);
|
||||||
|
|
||||||
game_cmd(buf);
|
game_cmd(buf);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -188,7 +188,7 @@ void snd_free_mus(mus_t mus)
|
||||||
Mix_FreeMusic((Mix_Music*) mus);
|
Mix_FreeMusic((Mix_Music*) mus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void snd_play(void *chunk, int channel)
|
void snd_play(void *chunk, int channel, int loop)
|
||||||
{
|
{
|
||||||
if (!sound_on)
|
if (!sound_on)
|
||||||
return;
|
return;
|
||||||
|
@ -198,7 +198,7 @@ void snd_play(void *chunk, int channel)
|
||||||
channel %= MIX_CHANNELS;
|
channel %= MIX_CHANNELS;
|
||||||
if (channel < 0)
|
if (channel < 0)
|
||||||
channel = -1;
|
channel = -1;
|
||||||
Mix_PlayChannel(channel, (Mix_Chunk*)chunk, 0);
|
Mix_PlayChannel(channel, (Mix_Chunk*)chunk, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void snd_done(void)
|
void snd_done(void)
|
||||||
|
|
|
@ -16,7 +16,7 @@ typedef void* mus_t;
|
||||||
extern void snd_free_mus(mus_t mus);
|
extern void snd_free_mus(mus_t mus);
|
||||||
extern int snd_init(int hz);
|
extern int snd_init(int hz);
|
||||||
extern int snd_hz(void);
|
extern int snd_hz(void);
|
||||||
extern void snd_play(wav_t chunk, int channel);
|
extern void snd_play(wav_t chunk, int channel, int loop);
|
||||||
extern void snd_halt_chan(int han);
|
extern void snd_halt_chan(int han);
|
||||||
|
|
||||||
extern void snd_free_wav(wav_t chunk);
|
extern void snd_free_wav(wav_t chunk);
|
||||||
|
|
|
@ -2067,8 +2067,18 @@ function get_sound_chan()
|
||||||
return game._sound_channel
|
return game._sound_channel
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_sound(s, chan)
|
function get_sound_loop()
|
||||||
game._sound = s;
|
return game._sound_loop
|
||||||
|
end
|
||||||
|
|
||||||
|
function set_sound(s, chan, loop)
|
||||||
|
game._sound = s;
|
||||||
|
if not tonumber(loop) then
|
||||||
|
game._sound_loop = 1;
|
||||||
|
else
|
||||||
|
game._sound_loop = tonumber(loop);
|
||||||
|
end
|
||||||
|
|
||||||
if not tonumber(chan) then
|
if not tonumber(chan) then
|
||||||
game._sound_channel = -1;
|
game._sound_channel = -1;
|
||||||
else
|
else
|
||||||
|
|
Reference in a new issue