diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 419b6611a..44655fb91 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -194,23 +194,19 @@ bool SoundSDL2::mute(bool state) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool SoundSDL2::toggleMute() { - bool oldstate = SDL_GetAudioDeviceStatus(myDevice) == SDL_AUDIO_PAUSED; - if(myIsInitializedFlag) - { - string message; + bool enabled = myAudioSettings.enabled(); - SDL_PauseAudioDevice(myDevice, oldstate ? 0 : 1); + setEnabled(!enabled); + myOSystem.console().initializeAudio(); - message = "Sound "; - message += oldstate ? "unmuted" : "muted"; + string message = "Sound "; + message += !enabled ? "unmuted" : "muted"; - myOSystem.frameBuffer().showMessage(message); - } - - return oldstate; + myOSystem.frameBuffer().showMessage(message); + + return enabled; } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SoundSDL2::setVolume(uInt32 percent) { @@ -243,6 +239,15 @@ void SoundSDL2::adjustVolume(Int8 direction) setVolume(percent); + // enabled audio if it is currently disabled + bool enabled = myAudioSettings.enabled(); + + if (percent > 0 && !enabled) + { + setEnabled(!enabled); + myOSystem.console().initializeAudio(); + } + // Now show an onscreen message strval << percent; message = "Volume set to "; diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index a325db706..48f70bb23 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -562,39 +562,37 @@ void Console::changePhosphor(int direction) { int blend = atoi(myProperties.get(Display_PPBlend).c_str()); - if(myOSystem.frameBuffer().tiaSurface().phosphorEnabled()) + + if(direction == +1) // increase blend { - if(direction == +1) // increase blend + if(blend >= 100) { - if(blend >= 100) - { - myOSystem.frameBuffer().showMessage("Phosphor blend at maximum"); - return; - } - else - blend = std::min(blend+2, 100); - } - else if(direction == -1) // decrease blend - { - if(blend <= 2) - { - myOSystem.frameBuffer().showMessage("Phosphor blend at minimum"); - return; - } - else - blend = std::max(blend-2, 0); + myOSystem.frameBuffer().showMessage("Phosphor blend at maximum"); + myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, 100); + return; } else + blend = std::min(blend+2, 100); + } + else if(direction == -1) // decrease blend + { + if(blend <= 2) + { + myOSystem.frameBuffer().showMessage("Phosphor blend at minimum"); + myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, 0); return; - - ostringstream val; - val << blend; - myProperties.set(Display_PPBlend, val.str()); - myOSystem.frameBuffer().showMessage("Phosphor blend " + val.str()); - myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, blend); + } + else + blend = std::max(blend-2, 0); } else - myOSystem.frameBuffer().showMessage("Phosphor effect disabled"); + return; + + ostringstream val; + val << blend; + myProperties.set(Display_PPBlend, val.str()); + myOSystem.frameBuffer().showMessage("Phosphor blend " + val.str()); + myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, blend); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -