From cb785c4cdbdec32832b51e084af5bb022a25f704 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Fri, 10 Mar 2023 02:17:35 +0100 Subject: [PATCH] resolve TODO regarding bsnes settings --- .../Nintendo/BSNES/BsnesCore.IEmulator.cs | 19 ----------------- .../Nintendo/BSNES/BsnesCore.ISettable.cs | 21 +++++++++++++++++++ .../Consoles/Nintendo/BSNES/BsnesCore.cs | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.IEmulator.cs index d15479091c..e4f546ddca 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.IEmulator.cs @@ -44,29 +44,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES { _controller = controller; - var enables = new BsnesApi.LayerEnables - { - BG1_Prio0 = _settings.ShowBG1_0, - BG1_Prio1 = _settings.ShowBG1_1, - BG2_Prio0 = _settings.ShowBG2_0, - BG2_Prio1 = _settings.ShowBG2_1, - BG3_Prio0 = _settings.ShowBG3_0, - BG3_Prio1 = _settings.ShowBG3_1, - BG4_Prio0 = _settings.ShowBG4_0, - BG4_Prio1 = _settings.ShowBG4_1, - Obj_Prio0 = _settings.ShowOBJ_0, - Obj_Prio1 = _settings.ShowOBJ_1, - Obj_Prio2 = _settings.ShowOBJ_2, - Obj_Prio3 = _settings.ShowOBJ_3 - }; - // TODO: I really don't think stuff like this should be set every single frame (only on change) - Api.core.snes_set_layer_enables(ref enables); Api.core.snes_set_hooks_enabled(MemoryCallbacks.HasReads, MemoryCallbacks.HasWrites, MemoryCallbacks.HasExecutes); Api.core.snes_set_trace_enabled(_tracer.IsEnabled()); Api.core.snes_set_video_enabled(render); Api.core.snes_set_audio_enabled(renderSound); - Api.core.snes_set_ppu_sprite_limit_enabled(!_settings.NoPPUSpriteLimit); - Api.core.snes_set_overscan_enabled(_settings.ShowOverscan); } internal void FrameAdvancePost() diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.ISettable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.ISettable.cs index d28f244c9b..62ec2a4fa8 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.ISettable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.ISettable.cs @@ -19,6 +19,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES public PutSettingsDirtyBits PutSettings(SnesSettings o) { + if (o != _settings) + { + var enables = new BsnesApi.LayerEnables + { + BG1_Prio0 = o.ShowBG1_0, + BG1_Prio1 = o.ShowBG1_1, + BG2_Prio0 = o.ShowBG2_0, + BG2_Prio1 = o.ShowBG2_1, + BG3_Prio0 = o.ShowBG3_0, + BG3_Prio1 = o.ShowBG3_1, + BG4_Prio0 = o.ShowBG4_0, + BG4_Prio1 = o.ShowBG4_1, + Obj_Prio0 = o.ShowOBJ_0, + Obj_Prio1 = o.ShowOBJ_1, + Obj_Prio2 = o.ShowOBJ_2, + Obj_Prio3 = o.ShowOBJ_3 + }; + Api.core.snes_set_layer_enables(ref enables); + Api.core.snes_set_ppu_sprite_limit_enabled(!o.NoPPUSpriteLimit); + Api.core.snes_set_overscan_enabled(o.ShowOverscan); + } _settings = o; return PutSettingsDirtyBits.None; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs index f8bf8c820d..e001bc7fe1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs @@ -25,7 +25,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES this._romPath = Path.ChangeExtension(loadParameters.Roms[0].RomPath, null); CoreComm = loadParameters.Comm; - _settings = loadParameters.Settings ?? new SnesSettings(); _syncSettings = loadParameters.SyncSettings ?? new SnesSyncSettings(); SystemId = loadParameters.Game.System; _isSGB = SystemId == VSystemID.Raw.SGB; @@ -80,6 +79,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES }; Api.core.snes_init(ref snesInitData); Api.SetCallbacks(callbacks); + PutSettings(loadParameters.Settings ?? new SnesSettings()); // start up audio resampler InitAudio();