From 8e37b81d3afdbed71eca0fd7339ba9967ae4063a Mon Sep 17 00:00:00 2001 From: Souryo Date: Thu, 28 Sep 2017 20:34:14 -0400 Subject: [PATCH] Debugger: Fixed mouse over precision in PPU viewer (cause by recent DPI-related changes) --- GUI.NET/Debugger/Controls/ctrlChrViewer.cs | 8 ++++---- GUI.NET/Debugger/Controls/ctrlNametableViewer.cs | 6 +++--- GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs | 4 ++-- GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs | 8 ++++---- GUI.NET/Debugger/Controls/ctrlTilePalette.cs | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/GUI.NET/Debugger/Controls/ctrlChrViewer.cs b/GUI.NET/Debugger/Controls/ctrlChrViewer.cs index a687f34b..9560a964 100644 --- a/GUI.NET/Debugger/Controls/ctrlChrViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlChrViewer.cs @@ -217,8 +217,8 @@ namespace Mesen.GUI.Debugger.Controls private void picChrBank_MouseMove(object sender, MouseEventArgs e) { - int tileX = Math.Min(e.X * 256 / picChrBank1.Width / 16, 15); - int tileY = Math.Min(e.Y * 256 / picChrBank1.Height / 16, 15); + int tileX = Math.Min(e.X * 256 / (picChrBank1.Width - 2) / 16, 15); + int tileY = Math.Min(e.Y * 256 / (picChrBank1.Height - 2) / 16, 15); bool bottomBank = sender == this.picChrBank2; int tileIndex = tileY * 16 + tileX; @@ -234,8 +234,8 @@ namespace Mesen.GUI.Debugger.Controls private void picChrBank_MouseDown(object sender, MouseEventArgs e) { - int tileX = Math.Min(e.X * 256 / picChrBank1.Width / 16, 15); - int tileY = Math.Min(e.Y * 256 / picChrBank1.Height / 16, 15); + int tileX = Math.Min(e.X * 256 / (picChrBank1.Width - 2) / 16, 15); + int tileY = Math.Min(e.Y * 256 / (picChrBank1.Height - 2)/ 16, 15); _tileIndex = tileY * 16 + tileX; _bottomBank = sender == this.picChrBank2; diff --git a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs index 40cefd9d..a6dd01c0 100644 --- a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs @@ -177,9 +177,9 @@ namespace Mesen.GUI.Debugger.Controls private void picNametable_MouseMove(object sender, MouseEventArgs e) { - int xPos = e.X * 512 / picNametable.Width; - int yPos = e.Y * 480 / picNametable.Height; - + int xPos = e.X * 512 / (picNametable.Width - 2); + int yPos = e.Y * 480 / (picNametable.Height - 2); + _nametableIndex = 0; if(xPos >= 256) { _nametableIndex++; diff --git a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs index 1fedfcad..04b7bf8d 100644 --- a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs @@ -69,8 +69,8 @@ namespace Mesen.GUI.Debugger.Controls private void picPalette_MouseMove(object sender, MouseEventArgs e) { - int tileX = Math.Min(e.X * 128 / picPalette.Width / 32, 31); - int tileY = Math.Min(e.Y * 256 / picPalette.Height / 32, 31); + int tileX = Math.Min(e.X * 128 / (picPalette.Width - 2) / 32, 31); + int tileY = Math.Min(e.Y * 256 / (picPalette.Height - 2) / 32, 31); int tileIndex = tileY * 4 + tileX; diff --git a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs index 71c1709a..373ec7e8 100644 --- a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs @@ -119,8 +119,8 @@ namespace Mesen.GUI.Debugger.Controls { _previewMousePosition = null; - int tileX = Math.Min(e.X * 256 / picSprites.Width / 32, 31); - int tileY = Math.Min(e.Y * 512 / picSprites.Height / 64, 63); + int tileX = Math.Min(e.X * 256 / (picSprites.Width - 2) / 32, 31); + int tileY = Math.Min(e.Y * 512 / (picSprites.Height - 2) / 64, 63); int ramAddr = ((tileY << 3) + tileX) << 2; if(ramAddr / 4 == _selectedSprite && !_forceRefresh) { @@ -244,8 +244,8 @@ namespace Mesen.GUI.Debugger.Controls private void SelectSpriteUnderCursor() { Point p = _previewMousePosition.Value; - int xPos = p.X * 256 / picPreview.Width; - int yPos = p.Y * 240 / picPreview.Height; + int xPos = p.X * 256 / (picPreview.Width - 2); + int yPos = p.Y * 240 / (picPreview.Height - 2); int prevSprite = _selectedSprite; _selectedSprite = -1; for(int i = 0x100 - 4; i >= 0; i-=4) { diff --git a/GUI.NET/Debugger/Controls/ctrlTilePalette.cs b/GUI.NET/Debugger/Controls/ctrlTilePalette.cs index a9b94aa7..34237579 100644 --- a/GUI.NET/Debugger/Controls/ctrlTilePalette.cs +++ b/GUI.NET/Debugger/Controls/ctrlTilePalette.cs @@ -131,13 +131,13 @@ namespace Mesen.GUI.Debugger.Controls private void picPaletteSelection_MouseMove(object sender, MouseEventArgs e) { - _hoverColor = e.X * 128 / this.Width / 32; + _hoverColor = e.X * 128 / (this.Width - 2) / 32; RefreshPalette(); } private void picPaletteSelection_MouseDown(object sender, MouseEventArgs e) { - this.SelectedColor = e.X * 128 / this.Width / 32; + this.SelectedColor = e.X * 128 / (this.Width - 2) / 32; RefreshPalette(); }