diff --git a/src/game/bondeyespy.c b/src/game/bondeyespy.c index 4724ba046..7c2e6943e 100644 --- a/src/game/bondeyespy.c +++ b/src/game/bondeyespy.c @@ -1058,16 +1058,16 @@ void eyespy_process_input(bool allowbuttons) switch (g_EyespyHit) { case EYESPYHIT_BG: - snd00010718(NULL, 0, 16000, AL_PAN_CENTER, SFXMAP_808C_EYESPYHIT, 1, 1, -1, 1); + snd_start_extra(NULL, false, 16000, AL_PAN_CENTER, SFXMAP_808C_EYESPYHIT, 1, 1, -1, true); break; case EYESPYHIT_OBJ: - snd00010718(NULL, 0, 16000, AL_PAN_CENTER, SFXMAP_808C_EYESPYHIT, 1, 1, -1, 1); + snd_start_extra(NULL, false, 16000, AL_PAN_CENTER, SFXMAP_808C_EYESPYHIT, 1, 1, -1, true); break; case EYESPYHIT_DOOR: - snd00010718(NULL, 0, 16000, AL_PAN_CENTER, SFXMAP_808C_EYESPYHIT, 1, 1, -1, 1); + snd_start_extra(NULL, false, 16000, AL_PAN_CENTER, SFXMAP_808C_EYESPYHIT, 1, 1, -1, true); break; case EYESPYHIT_CHR: - snd00010718(NULL, 0, 16000, AL_PAN_CENTER, SFXMAP_808C_EYESPYHIT, 1, 1, -1, 1); + snd_start_extra(NULL, false, 16000, AL_PAN_CENTER, SFXMAP_808C_EYESPYHIT, 1, 1, -1, true); break; case EYESPYHIT_DAMAGE: snd_start(var80095200, SFXNUM_00F2_PICKUP_LASER, NULL, -1, -1, -1, -1, -1); diff --git a/src/game/bondgun.c b/src/game/bondgun.c index bd4cf9758..7158a7ed3 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -674,10 +674,10 @@ void bgun_tick_anim(struct hand *hand, struct modeldef *modeldef) case GUNCMD_PLAYSOUND: #if VERSION >= VERSION_NTSC_1_0 if (hasspeed) { - snd00010718(0, 0, AL_VOL_FULL, AL_PAN_CENTER, cmd->soundnum, speed, 1, -1, 1); + snd_start_extra(NULL, false, AL_VOL_FULL, AL_PAN_CENTER, cmd->soundnum, speed, 1, -1, true); hasspeed = false; } else { - snd00010718(0, 0, AL_VOL_FULL, AL_PAN_CENTER, cmd->soundnum, 1.0f, 1, -1, 1); + snd_start_extra(NULL, false, AL_VOL_FULL, AL_PAN_CENTER, cmd->soundnum, 1.0f, 1, -1, true); } #else audiohandle = snd_start(var80095200, cmd->soundnum, NULL, -1, -1, -1, -1, -1); diff --git a/src/game/bondmove.c b/src/game/bondmove.c index d5b799be3..9f15711d4 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1966,7 +1966,7 @@ void bmove_tick(bool allowc1x, bool allowc1y, bool allowc1buttons, bool ignorec2 sound = footstep_choose_sound(chr, distance > 10); if (sound != -1) { - snd00010718(0, 0, AL_VOL_FULL, AL_PAN_CENTER, sound, 1, 1, -1, true); + snd_start_extra(NULL, false, AL_VOL_FULL, AL_PAN_CENTER, sound, 1, 1, -1, true); } } } diff --git a/src/game/lv.c b/src/game/lv.c index 792e4d84a..0e8254aed 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -2209,7 +2209,7 @@ void lv_tick(void) && g_MiscAudioHandle == NULL && !lv_is_paused() && nexttime < TICKS(g_MpTimeLimit60)) { - snd00010718(&g_MiscAudioHandle, 0, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_00A3_ALARM_DEFAULT, 1, 1, -1, true); + snd_start_extra(&g_MiscAudioHandle, false, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_00A3_ALARM_DEFAULT, 1, 1, -1, true); } } diff --git a/src/game/mplayer/scenarios/hackthatmac.inc b/src/game/mplayer/scenarios/hackthatmac.inc index 4c0b767ec..91aaa5f2c 100644 --- a/src/game/mplayer/scenarios/hackthatmac.inc +++ b/src/game/mplayer/scenarios/hackthatmac.inc @@ -455,7 +455,7 @@ void htm_tick_chr(struct chrdata *chr) #else hudmsg_create_with_flags(lang_get(L_MPWEAPONS_019), HUDMSGTYPE_MPSCENARIO, HUDMSGFLAG_ONLYIFALIVE); // "You need to use the Data Uplink." #endif - snd00010718(NULL, 0, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_01CC, 1, 1, -1, 1); + snd_start_extra(NULL, false, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_01CC, 1, 1, -1, true); } } } @@ -529,7 +529,7 @@ void htm_tick_chr(struct chrdata *chr) hudmsg_create_with_flags(lang_get(L_MPWEAPONS_017), HUDMSGTYPE_MPSCENARIO, HUDMSGFLAG_ONLYIFALIVE); #endif ps_stop_sound(data->terminals[data->dlterminalnum].prop, PSTYPE_GENERAL, 0xffff); - snd00010718(NULL, 0, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_01CC, 1, 1, -1, 1); + snd_start_extra(NULL, false, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_01CC, 1, 1, -1, true); } data->dlterminalnum = -1; @@ -550,7 +550,7 @@ void htm_tick_chr(struct chrdata *chr) hudmsg_create_with_flags(lang_get(L_MPWEAPONS_016), HUDMSGTYPE_MPSCENARIO, HUDMSGFLAG_ONLYIFALIVE); #endif ps_stop_sound(data->terminals[data->dlterminalnum].prop, PSTYPE_GENERAL, 0xffff); - snd00010718(NULL, 0, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_01C1, 1, 1, -1, 1); + snd_start_extra(NULL, false, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_01C1, 1, 1, -1, true); } data->dlterminalnum = -1; diff --git a/src/game/propsnd.c b/src/game/propsnd.c index d64c9e6eb..1e199eabe 100644 --- a/src/game/propsnd.c +++ b/src/game/propsnd.c @@ -438,18 +438,18 @@ void ps_tick_channel(s32 channelnum) #if VERSION >= VERSION_NTSC_1_0 if (channel->flags & PSFLAG_AMBIENT) { if (newvol) { - snd00010718(&channel->audiohandle, channel->flags & PSFLAG_ISMP3, newvol, newpan, - channel->requestedsoundnum, newpitch, channel->fxbus, newfx, 1); + snd_start_extra(&channel->audiohandle, channel->flags & PSFLAG_ISMP3, newvol, newpan, + channel->requestedsoundnum, newpitch, channel->fxbus, newfx, true); } } else { if (newvol) { - snd00010718(&channel->audiohandle, channel->flags & PSFLAG_ISMP3, newvol, newpan, - channel->requestedsoundnum, newpitch, channel->fxbus, newfx, 1); + snd_start_extra(&channel->audiohandle, channel->flags & PSFLAG_ISMP3, newvol, newpan, + channel->requestedsoundnum, newpitch, channel->fxbus, newfx, true); } } #else - snd00010718(&channel->audiohandle, channel->flags & PSFLAG_ISMP3, newvol, newpan, - channel->requestedsoundnum, newpitch, channel->fxbus, newfx, 1); + snd_start_extra(&channel->audiohandle, channel->flags & PSFLAG_ISMP3, newvol, newpan, + channel->requestedsoundnum, newpitch, channel->fxbus, newfx, true); #endif } diff --git a/src/game/sight.c b/src/game/sight.c index 7cfb6f69b..3c165e8fa 100644 --- a/src/game/sight.c +++ b/src/game/sight.c @@ -240,7 +240,7 @@ void sight_tick(bool sighton) if (g_Vars.currentplayer->lookingatprop.prop != g_Vars.currentplayer->trackedprops[0].prop) { struct sndstate *handle; - handle = snd00010718(&handle, 0, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_0007, 1, 1, -1, true); + handle = snd_start_extra(&handle, false, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_0007, 1, 1, -1, true); trackedprop = &g_Vars.currentplayer->trackedprops[0]; @@ -266,7 +266,7 @@ void sight_tick(bool sighton) if (index >= 0) { struct sndstate *handle; - handle = snd00010718(&handle, 0, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_0007, 1, 1, -1, 1); + handle = snd_start_extra(&handle, false, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_0007, 1, 1, -1, true); trackedprop = &g_Vars.currentplayer->trackedprops[index]; @@ -289,7 +289,7 @@ void sight_tick(bool sighton) if (index >= 0) { struct sndstate *handle; - handle = snd00010718(&handle, 0, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_0007, 1, 1, -1, 1); + handle = snd_start_extra(&handle, false, AL_VOL_FULL, AL_PAN_CENTER, SFXNUM_0007, 1, 1, -1, true); trackedprop = &g_Vars.currentplayer->trackedprops[index]; diff --git a/src/include/lib/snd.h b/src/include/lib/snd.h index 6626b876c..078fdf3a6 100644 --- a/src/include/lib/snd.h +++ b/src/include/lib/snd.h @@ -22,7 +22,7 @@ void snd_tick(void); bool snd_is_disabled(void); void snd_start_mp3_by_filenum(u32 filenum); void snd_adjust(struct sndstate **handle, bool ismp3, s32 vol, s32 pan, s32 soundnum, f32 pitch, s32 fxbus, s32 fxmix, bool forcefxmix); -struct sndstate *snd00010718(struct sndstate **handle, bool ismp3, s32 volume, s32 pan, s32 soundnum, f32 pitch, s32 fxbus, s32 fxmix, bool forcefxmix); +struct sndstate *snd_start_extra(struct sndstate **handle, bool ismp3, s32 volume, s32 pan, s32 soundnum, f32 pitch, s32 fxbus, s32 fxmix, bool forcefxmix); struct sndstate *snd_start(s32 arg0, s16 sound, struct sndstate **handle, s32 volume, s32 pan, f32 pitch, s32 fxbus, s32 fxmix); void snd_start_mp3(s16 soundnum, s32 volume, s32 pan, s32 responseflags); void snd_play_nosedive(s32 seconds); diff --git a/src/lib/snd.c b/src/lib/snd.c index 4b70521cd..59546f663 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -1605,7 +1605,7 @@ bool snd_stop_mp3(s16 soundnum) return true; } -void snd0000fc40(s32 arg0) +void snd_stub_1arg(s32 arg0) { // empty } @@ -1724,7 +1724,7 @@ void snd_unpause_mp3(void) } } -void snd0000fe80(void) +void snd_stub_0args(void) { // empty } @@ -1890,14 +1890,14 @@ void snd_tick(void) } } -s16 snd0001034c(s16 sfxnum) +s16 snd_sfxref_to_sndnum(s16 sfxnum) { - union soundnumhack sfxref; + union soundnumhack tmp; - sfxref.packed = sfxnum; - sfxnum = sfxref.id; + tmp.packed = sfxnum; + sfxnum = tmp.id; - if (sfxref.id); + if (tmp.id); return sfxnum; } @@ -1963,11 +1963,7 @@ void snd_adjust(struct sndstate **handle, bool ismp3, s32 vol, s32 pan, s32 soun struct audioconfig *config; if (forcefxmix || fxmixarg != -1) { - if (fxmixarg != -1) { - fxmix = fxmixarg; - } else { - fxmix = 0; - } + fxmix = fxmixarg != -1 ? fxmixarg : 0; #if VERSION >= VERSION_NTSC_1_0 if (pan != -1 && g_SoundMode == SOUNDMODE_SURROUND && (pan & 0x80)) { @@ -2037,7 +2033,23 @@ void snd_adjust(struct sndstate **handle, bool ismp3, s32 vol, s32 pan, s32 soun } } -struct sndstate *snd00010718(struct sndstate **handle, bool ismp3, s32 volume, s32 pan, s32 soundnum, f32 pitch, s32 fxbus, s32 fxmixarg, bool forcefxmix) +/** + * Wrapper around snd_start, but using the same arguments as snd_adjust. + * + * Unlike snd_start, this function does the follow "extra" things: + * - Allows increasing the fxmix by 128 (likely to do with surround sound data) + * - Applies volpercentage from config + * - Applies pan from config + * - Applies language filter if flagged as offensive in config + * + * The function starts the sound by ensuring the current thread is higher + * priority than the audio thread. This doesn't matter so this is pointless. + * + * It is likely that snd_adjust was written first, then copied to create + * snd_start_extra, and because snd_adjust has to be threadsafe they made this + * one threadsafe as well. + */ +struct sndstate *snd_start_extra(struct sndstate **handle, bool ismp3, s32 volume, s32 pan, s32 soundnum, f32 pitch, s32 fxbus, s32 fxmixarg, bool forcefxmix) { OSPri prevpri = osGetThreadPri(NULL); s32 fxmix = -1; @@ -2049,11 +2061,7 @@ struct sndstate *snd00010718(struct sndstate **handle, bool ismp3, s32 volume, s osSetThreadPri(0, osGetThreadPri(&g_AudioManager.thread) + 1); if (forcefxmix || fxmixarg != -1) { - if (fxmixarg != -1) { - fxmix = fxmixarg; - } else { - fxmix = 0; - } + fxmix = fxmixarg != -1 ? fxmixarg : 0; #if VERSION >= VERSION_NTSC_1_0 if (pan != -1 && g_SoundMode == SOUNDMODE_SURROUND && (pan & 0x80)) {