diff --git a/src/audio/audio.c b/src/audio/audio.c index 2e69cbff2d..9459019066 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -39,6 +39,7 @@ rct_ride_music_params gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC]; rct_ride_music_params *gRideMusicParamsListEnd; void *gCrowdSoundChannel = 0; void *gTitleMusicChannel = 0; +bool gGameSoundsOff = false; void audio_init(int i) { @@ -1423,7 +1424,7 @@ int get_dsound_devices() int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) { int result = 0; - if (RCT2_GLOBAL(0x009AF59D, uint8) & 1) { + if (gConfigSound.sound) { RCT2_GLOBAL(0x00F438AD, uint8) = 0; int volume = 0; if (ebx == 0x8001) { @@ -1557,7 +1558,7 @@ void start_title_music() break; } - if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) && RCT2_GLOBAL(0x009AF59D, uint8) & 1 + if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) && gConfigSound.sound && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) { if (!RCT2_GLOBAL(0x009AF600, uint8)) { #ifdef USE_MIXER @@ -1809,13 +1810,11 @@ void audio_close() /* rct2: 0x006BAB8A */ void toggle_all_sounds(){ - // When all sound code is reversed replace with gConfigSound.sound - RCT2_GLOBAL(0x009AF59D, uint8) ^= 1; - if (RCT2_GLOBAL(0x009AF59D, uint8) == 0) { + gConfigSound.sound = !gConfigSound.sound; + if (!gConfigSound.sound) { stop_title_music(); pause_sounds(); - } - else{ + } else { unpause_sounds(); } } @@ -1826,15 +1825,11 @@ void toggle_all_sounds(){ */ void pause_sounds() { - // When all sound code is reversed replace with gConfigSound.sound - RCT2_GLOBAL(0x009AF59C, uint8) = 1; - if (RCT2_GLOBAL(0x009AF59C, uint8) == 1) { - stop_other_sounds(); - stop_vehicle_sounds(); - stop_ride_music(); - stop_crowd_sound(); - } - gConfigSound.sound = 0; + gGameSoundsOff = 1; + stop_other_sounds(); + stop_vehicle_sounds(); + stop_ride_music(); + stop_crowd_sound(); } /** @@ -1843,9 +1838,7 @@ void pause_sounds() */ void unpause_sounds() { - // When all sound code is reversed replace with gConfigSound.sound - RCT2_GLOBAL(0x009AF59C, uint8) = 0; - gConfigSound.sound = 1; + gGameSoundsOff = 0; } /** diff --git a/src/audio/audio.h b/src/audio/audio.h index 037206227a..ef41f56601 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -156,6 +156,7 @@ extern rct_ride_music_params gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC]; extern rct_ride_music_params *gRideMusicParamsListEnd; extern void *gCrowdSoundChannel; extern void *gTitleMusicChannel; +extern bool gGameSoundsOff; void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2, int channel); int CALLBACK audio_timer_callback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2); diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index 0d6844b616..17dc692d4f 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -568,7 +568,7 @@ void SDLCALL Mixer::Callback(void* arg, uint8* stream, int length) void Mixer::MixChannel(Channel& channel, uint8* data, int length) { - if (channel.source && channel.source->Length() > 0 && !channel.done) { + if (channel.source && channel.source->Length() > 0 && !channel.done && gConfigSound.sound) { AudioFormat streamformat = channel.source->Format(); int loaded = 0; SDL_AudioCVT cvt; diff --git a/src/peep/peep.c b/src/peep/peep.c index 6fa22c1c9a..31877ee159 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -25,6 +25,7 @@ #include "../localisation/localisation.h" #include "../management/finance.h" #include "../management/news_item.h" +#include "../config.h" #include "../openrct2.h" #include "../ride/ride.h" #include "../scenario.h" @@ -4494,10 +4495,10 @@ void peep_update_crowd_noise() if (!(RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) return; - if (RCT2_GLOBAL(0x009AF59C, uint8) != 0) + if (gGameSoundsOff) return; - if (!(RCT2_GLOBAL(0x009AF59D, uint8) & (1 << 0))) + if (!gConfigSound.sound) return; if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) diff --git a/src/ride/ride.c b/src/ride/ride.c index 6362cd4e7f..d6823183ee 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -3143,7 +3143,7 @@ void ride_set_map_tooltip(rct_map_element *mapElement) */ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint16 sampleRate, uint32 position, uint8 *tuneId) { - if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !RCT2_GLOBAL(0x009AF59C, uint8) && RCT2_GLOBAL(0x00F438A4, rct_viewport*) != (rct_viewport*)-1) { + if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gGameSoundsOff && RCT2_GLOBAL(0x00F438A4, rct_viewport*) != (rct_viewport*)-1) { RCT2_GLOBAL(0x009AF47C, uint16) = sampleRate; sint16 v11; sint16 v12; @@ -3373,7 +3373,7 @@ void ride_music_update_final() int ebx; if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)) { if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) { - if (!RCT2_GLOBAL(0x009AF59C, uint8) && RCT2_GLOBAL(0x009AF59D, uint8) & 1 && RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) && !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 1)) { + if (!gGameSoundsOff && gConfigSound.sound && RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) && !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 1)) { // set to stop music if volume <= 1 ? while (1) { int v8 = 0; diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 3536ea1985..6b8dcfa672 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -21,6 +21,7 @@ #include "../addresses.h" #include "../audio/audio.h" #include "../audio/mixer.h" +#include "../config.h" #include "../interface/viewport.h" #include "../world/sprite.h" #include "ride.h" @@ -166,7 +167,7 @@ int sub_6BC2F3(rct_vehicle* vehicle) */ void vehicle_sounds_update() { - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1 && !RCT2_GLOBAL(0x009AF59C, uint8) && RCT2_GLOBAL(0x009AF59D, uint8) & 1) { + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1 && !gGameSoundsOff && gConfigSound.sound) { RCT2_GLOBAL(0x00F438A4, rct_viewport*) = (rct_viewport*)-1; rct_viewport* viewport = (rct_viewport*)-1; rct_window* window = RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); diff --git a/src/world/climate.c b/src/world/climate.c index 51ac92409a..60347f3d10 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -21,6 +21,7 @@ #include "../addresses.h" #include "../audio/audio.h" #include "../audio/mixer.h" +#include "../config.h" #include "../drawing/drawing.h" #include "../localisation/date.h" #include "../scenario.h" @@ -242,9 +243,9 @@ void climate_update_sound() { if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) == 0xFFFFFFFF) return; - if (RCT2_GLOBAL(0x009AF59C, uint8) != 0) + if (gGameSoundsOff) return; - if (!(RCT2_GLOBAL(0x009AF59D, uint8) & 1)) + if (!gConfigSound.sound) return; if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) return;