public MesenControl() { InitializeComponent(); _renderer.ScaleChanged = scale => { if (Emulator == null) { return(false); } Emulator.SetScale(scale); return(true); }; _speedSlider.GotFocus += (s, a) => { _renderer.Focus(); }; _speedSlider.ValueChanged += () => { if (Emulator != null) { Emulator.SetSpeed(EmulationSpeed[_speedSlider.Value]); } if (_isSpeedTolTipVisible) { _toolTip.Show(EmulationSpeed[_speedSlider.Value] + "%", _speedSlider, Point.Add(_speedSlider.Location, new Size(45, -25))); } }; _speedSlider.MouseUp += (sender, args) => { if (args.Button != MouseButtons.Left) { return; } _renderer.Focus(); _isSpeedTolTipVisible = false; _toolTip.Hide(_speedSlider); }; _speedSlider.MouseDown += (sender, args) => { if (args.Button != MouseButtons.Left) { return; } _isSpeedTolTipVisible = true; _toolTip.Show(EmulationSpeed[_speedSlider.Value] + "%", _speedSlider, Point.Add(_speedSlider.Location, new Size(45, -25))); }; // Loading files synchronously in constructor is bad practice, but the file is small, and this should only happen when program starts anyway // In the future, maybe get settings-object from a thread that loads all settings async on startup EmulatorSettings = new EmulatorSettings(); if (Program.WorkingDirectory != null) { EmulatorSettings.NesPalette.Load(Path.Combine(Program.WorkingDirectory, "nes.pal")); // TODO: custom palettes } EmulatorSettings.SnesPalette.LoadSnesPalette(); }
public void UpdateSettings(EmulatorSettings settings) { EmulationConfig.RamPowerOnState = settings.RandomPowerOnState ? RamState.Random : RamState.AllZeros; EmulationConfig.EnableRandomPowerOnState = settings.RandomPowerOnState; VideoConfig.HideBgLayer0 = !settings.ShowBgLayer1; VideoConfig.HideBgLayer1 = !settings.ShowBgLayer2; VideoConfig.HideBgLayer2 = !settings.ShowBgLayer3; VideoConfig.HideBgLayer3 = !settings.ShowBgLayer4; VideoConfig.HideSprites = !settings.ShowSpriteLayer; SnesConfigApi.SetAudioConfig(new AudioConfig { EnableAudio = settings.PlayAudio }); ApplyEmulationConfig(); ApplyVideoConfig(); }
public void UpdateSettings(EmulatorSettings settings) { InteropEmu.SetRamPowerOnState(settings.RandomPowerOnState ? RamPowerOnState.Random : RamPowerOnState.AllZeros); InteropEmu.SetFlag(EmulationFlags.RandomizeMapperPowerOnState, settings.RandomPowerOnState); InteropEmu.SetMasterVolume(settings.PlayAudio ? 25 / 10d : 0, 75 / 100d); InteropEmu.SetChannelVolume(AudioChannel.Square1, ConvertVolume(settings.PlaySquare1 ? 100 : 0)); InteropEmu.SetChannelVolume(AudioChannel.Square2, ConvertVolume(settings.PlaySquare2 ? 100 : 0)); InteropEmu.SetChannelVolume(AudioChannel.Triangle, ConvertVolume(settings.PlayTriangle ? 100 : 0)); InteropEmu.SetChannelVolume(AudioChannel.Noise, ConvertVolume(settings.PlayNoise ? 100 : 0)); InteropEmu.SetChannelVolume(AudioChannel.DMC, ConvertVolume(settings.PlayPcm ? 100 : 0)); InteropEmu.SetFlag(EmulationFlags.DisableBackground, !settings.ShowBgLayer); InteropEmu.SetFlag(EmulationFlags.DisableSprites, !settings.ShowSpriteLayer); InteropEmu.SetRgbPalette(settings.NesPalette.GetBinary(), 4 * 16); }