diff --git a/src/sdl-instead/game.c b/src/sdl-instead/game.c index 14da608..79e7d6b 100644 --- a/src/sdl-instead/game.c +++ b/src/sdl-instead/game.c @@ -1105,6 +1105,7 @@ void game_sound_player(void) wav_t w; char *snd; int chan = -1; + int loop = 1; if (!snd_volume_mus(-1)) return; @@ -1113,6 +1114,12 @@ void game_sound_player(void) chan = atoi(snd); free(snd); } + + snd = instead_eval("return get_sound_loop()"); + if (snd) { + loop = atoi(snd); + free(snd); + } snd = instead_eval("return get_sound()"); if (!snd) { @@ -1135,7 +1142,7 @@ void game_sound_player(void) free(snd); if (!w) return; - snd_play(w, chan); + snd_play(w, chan, loop - 1); } char *horiz_inv(char *invstr) @@ -1658,7 +1665,7 @@ int game_click(int x, int y, int action, int filter) if (mouse_filter(filter)) return 0; if (opt_click) - snd_play(game_theme.click, -1); + snd_play(game_theme.click, -1, 0); game_cmd(buf); return 1; @@ -1681,7 +1688,7 @@ int game_click(int x, int y, int action, int filter) disable_use(); if (opt_click) - snd_play(game_theme.click, -1); + snd_play(game_theme.click, -1, 0); game_cmd(buf); return 1; diff --git a/src/sdl-instead/sound.c b/src/sdl-instead/sound.c index f820ba2..22ef394 100644 --- a/src/sdl-instead/sound.c +++ b/src/sdl-instead/sound.c @@ -188,7 +188,7 @@ void snd_free_mus(mus_t 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) return; @@ -198,7 +198,7 @@ void snd_play(void *chunk, int channel) channel %= MIX_CHANNELS; if (channel < 0) channel = -1; - Mix_PlayChannel(channel, (Mix_Chunk*)chunk, 0); + Mix_PlayChannel(channel, (Mix_Chunk*)chunk, loop); } void snd_done(void) diff --git a/src/sdl-instead/sound.h b/src/sdl-instead/sound.h index f06d89c..5ceb8f2 100644 --- a/src/sdl-instead/sound.h +++ b/src/sdl-instead/sound.h @@ -16,7 +16,7 @@ typedef void* mus_t; extern void snd_free_mus(mus_t mus); extern int snd_init(int hz); 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_free_wav(wav_t chunk); diff --git a/stead/stead.lua b/stead/stead.lua index e34b7ee..88a8f9f 100644 --- a/stead/stead.lua +++ b/stead/stead.lua @@ -2067,8 +2067,18 @@ function get_sound_chan() return game._sound_channel end -function set_sound(s, chan) - game._sound = s; +function get_sound_loop() + 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 game._sound_channel = -1; else