void Sound::UpdateSettings() { cstring errMsg = NULL; if (dialog->SoundEnabled()) { Nes::Sound nesSound( emulator ); errMsg = directSound.Update ( dialog->GetAdapter(), nesSound.GetSampleRate(), nesSound.GetSampleBits(), nesSound.GetSpeaker() == Nes::Sound::SPEAKER_STEREO ? DirectX::DirectSound::STEREO : DirectX::DirectSound::MONO, emulator.IsNsf() ? 500 : (dialog->GetLatency() + 2) * 21, dialog->GetPool(), CanRunInBackground() ); if (errMsg == NULL) { emuOutput = &output; nesSound.SetSpeed( emulator.GetSpeed() ); recorder->Enable( &directSound.GetWaveFormat() ); return; } } else { directSound.Destroy(); } Disable( errMsg ); }
bool Main::ToggleMenu() const { bool visible = menu.Visible(); if (Fullscreen() || !window.Restored()) { if (Fullscreen() && !visible && !CanRunInBackground()) emulator.Stop(); visible = menu.Toggle(); } else { Point size; if (visible) { size.y = menu.Height(); menu.Hide(); window.Size() -= size; visible = false; } else { menu.Show(); size.y = menu.Height(); window.Size() += size; visible = true; } } return visible; }
bool Main::OnStartEmulation() { if (window.Enabled() && (CanRunInBackground() || (window.Active() && !window.Minimized() && (Windowed() || !menu.Visible())))) { int priority; switch (preferences.GetPriority()) { case Managers::Preferences::PRIORITY_HIGH: if (emulator.IsGame() && !CanRunInBackground()) { priority = THREAD_PRIORITY_HIGHEST; break; } case Managers::Preferences::PRIORITY_ABOVE_NORMAL: priority = THREAD_PRIORITY_ABOVE_NORMAL; break; default: priority = THREAD_PRIORITY_NORMAL; break; } ::SetThreadPriority( ::GetCurrentThread(), priority ); frameClock.StartEmulation(); video.StartEmulation(); input.StartEmulation(); sound.StartEmulation(); return true; } return false; }
ibool Main::OnActivate(Param& param) { if (param.Activator().Entering()) { if (Fullscreen() && param.Activator().Minimized()) emulator.Stop(); } else { if (!CanRunInBackground() || (Fullscreen() && param.Activator().OutsideApplication())) emulator.Stop(); } return false; }