From 69bc8a0087e3c9cae8837809353d7798945ee247 Mon Sep 17 00:00:00 2001 From: Sour Date: Mon, 16 Jul 2018 20:39:18 -0400 Subject: [PATCH] Debugger: PPU Viewer - Don't update CHR viewer palette when paused & not set to refresh on pause/break --- GUI.NET/Debugger/Controls/ctrlNametableViewer.cs | 6 +++++- GUI.NET/Debugger/frmPpuViewer.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs index a6d1450b..d6218314 100644 --- a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs @@ -409,7 +409,11 @@ namespace Mesen.GUI.Debugger.Controls InteropEmu.DebugGetState(ref state); int tileIndexOffset = state.PPU.ControlFlags.BackgroundPatternAddr == 0x1000 ? 256 : 0; - _chrViewer.SelectedPaletteIndex = paletteIndex; + if(!InteropEmu.DebugIsExecutionStopped() || ConfigManager.Config.DebugInfo.PpuRefreshOnBreak) { + //Only change the palette if execution is not stopped (or if we're configured to refresh the viewer on break/pause) + //Otherwise, the CHR viewer will refresh its data (and it might not match the data we loaded at the specified scanline/cycle anymore) + _chrViewer.SelectedPaletteIndex = paletteIndex; + } _chrViewer.SelectedTileIndex = tileIndex + tileIndexOffset; OnSelectChrTile?.Invoke(null, EventArgs.Empty); } diff --git a/GUI.NET/Debugger/frmPpuViewer.cs b/GUI.NET/Debugger/frmPpuViewer.cs index 07b555df..bfc29fb8 100644 --- a/GUI.NET/Debugger/frmPpuViewer.cs +++ b/GUI.NET/Debugger/frmPpuViewer.cs @@ -211,7 +211,11 @@ namespace Mesen.GUI.Debugger private void ctrlSpriteViewer_OnSelectTilePalette(int tileIndex, int paletteIndex) { ctrlChrViewer.SelectedTileIndex = tileIndex; - ctrlChrViewer.SelectedPaletteIndex = paletteIndex; + if(!InteropEmu.DebugIsExecutionStopped() || ConfigManager.Config.DebugInfo.PpuRefreshOnBreak) { + //Only change the palette if execution is not stopped (or if we're configured to refresh the viewer on break/pause) + //Otherwise, the CHR viewer will refresh its data (and it might not match the data we loaded at the specified scanline/cycle anymore) + ctrlChrViewer.SelectedPaletteIndex = paletteIndex; + } tabMain.SelectTab(tpgChrViewer); } }