Debugger: Sprite Viewer - Added an option to display an outline around all sprites in the screen preview

This commit is contained in:
Sour 2019-01-19 20:53:15 -05:00
parent 8293382024
commit db370dda97
3 changed files with 100 additions and 64 deletions

View file

@ -204,6 +204,7 @@ namespace Mesen.GUI.Config
public bool NtViewerHighlightTileUpdates = false;
public bool NtViewerHighlightAttributeUpdates = false;
public bool NtViewerIgnoreRedundantWrites = false;
public bool SpriteViewerDisplaySpriteOutlines = false;
public int ChrViewerSelectedPalette = 0;
public CdlHighlightType ChrViewerHighlightType = CdlHighlightType.None;

View file

@ -47,10 +47,6 @@ namespace Mesen.GUI.Debugger.Controls
this.mnuCopyToClipboard = new System.Windows.Forms.ToolStripMenuItem();
this.mnuExportToPng = new System.Windows.Forms.ToolStripMenuItem();
this.lblScreenPreview = new System.Windows.Forms.Label();
this.lblTile = new System.Windows.Forms.Label();
this.picTile = new System.Windows.Forms.PictureBox();
this.lblPosition = new System.Windows.Forms.Label();
this.txtPosition = new System.Windows.Forms.TextBox();
this.lblTileIndex = new System.Windows.Forms.Label();
this.txtTileIndex = new System.Windows.Forms.TextBox();
this.lblPaletteAddr = new System.Windows.Forms.Label();
@ -62,14 +58,19 @@ namespace Mesen.GUI.Debugger.Controls
this.chkVerticalMirroring = new System.Windows.Forms.CheckBox();
this.chkBackgroundPriority = new System.Windows.Forms.CheckBox();
this.ctrlTilePalette = new Mesen.GUI.Debugger.Controls.ctrlTilePalette();
this.lblPosition = new System.Windows.Forms.Label();
this.txtPosition = new System.Windows.Forms.TextBox();
this.lblTile = new System.Windows.Forms.Label();
this.picTile = new System.Windows.Forms.PictureBox();
this.chkDisplaySpriteOutlines = new System.Windows.Forms.CheckBox();
this.picSprites = new System.Windows.Forms.PictureBox();
this.tlpMain.SuspendLayout();
this.grpSpriteInfo.SuspendLayout();
this.tlpInfo.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picPreview)).BeginInit();
this.ctxMenu.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picTile)).BeginInit();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picTile)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picSprites)).BeginInit();
this.SuspendLayout();
//
@ -115,22 +116,24 @@ namespace Mesen.GUI.Debugger.Controls
this.tlpInfo.Controls.Add(this.lblSpriteIndex, 0, 0);
this.tlpInfo.Controls.Add(this.picPreview, 1, 5);
this.tlpInfo.Controls.Add(this.lblScreenPreview, 0, 5);
this.tlpInfo.Controls.Add(this.lblTile, 0, 3);
this.tlpInfo.Controls.Add(this.picTile, 1, 3);
this.tlpInfo.Controls.Add(this.lblPosition, 0, 2);
this.tlpInfo.Controls.Add(this.txtPosition, 1, 2);
this.tlpInfo.Controls.Add(this.lblTileIndex, 0, 1);
this.tlpInfo.Controls.Add(this.txtTileIndex, 1, 1);
this.tlpInfo.Controls.Add(this.lblPaletteAddr, 2, 0);
this.tlpInfo.Controls.Add(this.lblTileAddress, 2, 1);
this.tlpInfo.Controls.Add(this.txtPaletteAddress, 3, 0);
this.tlpInfo.Controls.Add(this.txtTileAddress, 3, 1);
this.tlpInfo.Controls.Add(this.tableLayoutPanel1, 2, 2);
this.tlpInfo.Controls.Add(this.tableLayoutPanel1, 2, 3);
this.tlpInfo.Controls.Add(this.ctrlTilePalette, 1, 4);
this.tlpInfo.Controls.Add(this.lblPosition, 2, 2);
this.tlpInfo.Controls.Add(this.txtPosition, 3, 2);
this.tlpInfo.Controls.Add(this.lblTile, 0, 2);
this.tlpInfo.Controls.Add(this.picTile, 1, 2);
this.tlpInfo.Controls.Add(this.chkDisplaySpriteOutlines, 0, 6);
this.tlpInfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.tlpInfo.Location = new System.Drawing.Point(3, 16);
this.tlpInfo.Name = "tlpInfo";
this.tlpInfo.RowCount = 6;
this.tlpInfo.RowCount = 7;
this.tlpInfo.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpInfo.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpInfo.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpInfo.RowStyles.Add(new System.Windows.Forms.RowStyle());
@ -144,7 +147,7 @@ namespace Mesen.GUI.Debugger.Controls
//
this.lblPalette.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblPalette.AutoSize = true;
this.lblPalette.Location = new System.Drawing.Point(3, 230);
this.lblPalette.Location = new System.Drawing.Point(3, 204);
this.lblPalette.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
this.lblPalette.Name = "lblPalette";
this.lblPalette.Size = new System.Drawing.Size(43, 13);
@ -154,7 +157,7 @@ namespace Mesen.GUI.Debugger.Controls
// txtSpriteIndex
//
this.txtSpriteIndex.BackColor = System.Drawing.SystemColors.Window;
this.txtSpriteIndex.Location = new System.Drawing.Point(82, 3);
this.txtSpriteIndex.Location = new System.Drawing.Point(75, 3);
this.txtSpriteIndex.Name = "txtSpriteIndex";
this.txtSpriteIndex.ReadOnly = true;
this.txtSpriteIndex.Size = new System.Drawing.Size(26, 20);
@ -176,7 +179,7 @@ namespace Mesen.GUI.Debugger.Controls
this.picPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tlpInfo.SetColumnSpan(this.picPreview, 4);
this.picPreview.ContextMenuStrip = this.ctxMenu;
this.picPreview.Location = new System.Drawing.Point(82, 257);
this.picPreview.Location = new System.Drawing.Point(75, 231);
this.picPreview.Name = "picPreview";
this.picPreview.Size = new System.Drawing.Size(258, 242);
this.picPreview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@ -262,53 +265,13 @@ namespace Mesen.GUI.Debugger.Controls
// lblScreenPreview
//
this.lblScreenPreview.AutoSize = true;
this.lblScreenPreview.Location = new System.Drawing.Point(3, 259);
this.lblScreenPreview.Location = new System.Drawing.Point(3, 233);
this.lblScreenPreview.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
this.lblScreenPreview.Name = "lblScreenPreview";
this.lblScreenPreview.Size = new System.Drawing.Size(48, 13);
this.lblScreenPreview.TabIndex = 20;
this.lblScreenPreview.Text = "Preview:";
//
// lblTile
//
this.lblTile.AutoSize = true;
this.lblTile.Location = new System.Drawing.Point(3, 83);
this.lblTile.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
this.lblTile.Name = "lblTile";
this.lblTile.Size = new System.Drawing.Size(27, 13);
this.lblTile.TabIndex = 6;
this.lblTile.Text = "Tile:";
//
// picTile
//
this.picTile.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.picTile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picTile.Location = new System.Drawing.Point(82, 81);
this.picTile.Name = "picTile";
this.picTile.Size = new System.Drawing.Size(66, 130);
this.picTile.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picTile.TabIndex = 12;
this.picTile.TabStop = false;
//
// lblPosition
//
this.lblPosition.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblPosition.AutoSize = true;
this.lblPosition.Location = new System.Drawing.Point(3, 58);
this.lblPosition.Name = "lblPosition";
this.lblPosition.Size = new System.Drawing.Size(73, 13);
this.lblPosition.TabIndex = 16;
this.lblPosition.Text = "Position (X,Y):";
//
// txtPosition
//
this.txtPosition.BackColor = System.Drawing.SystemColors.Window;
this.txtPosition.Location = new System.Drawing.Point(82, 55);
this.txtPosition.Name = "txtPosition";
this.txtPosition.ReadOnly = true;
this.txtPosition.Size = new System.Drawing.Size(66, 20);
this.txtPosition.TabIndex = 18;
//
// lblTileIndex
//
this.lblTileIndex.Anchor = System.Windows.Forms.AnchorStyles.Left;
@ -322,7 +285,7 @@ namespace Mesen.GUI.Debugger.Controls
// txtTileIndex
//
this.txtTileIndex.BackColor = System.Drawing.SystemColors.Window;
this.txtTileIndex.Location = new System.Drawing.Point(82, 29);
this.txtTileIndex.Location = new System.Drawing.Point(75, 29);
this.txtTileIndex.Name = "txtTileIndex";
this.txtTileIndex.ReadOnly = true;
this.txtTileIndex.Size = new System.Drawing.Size(26, 20);
@ -332,7 +295,7 @@ namespace Mesen.GUI.Debugger.Controls
//
this.lblPaletteAddr.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblPaletteAddr.AutoSize = true;
this.lblPaletteAddr.Location = new System.Drawing.Point(154, 6);
this.lblPaletteAddr.Location = new System.Drawing.Point(147, 6);
this.lblPaletteAddr.Name = "lblPaletteAddr";
this.lblPaletteAddr.Size = new System.Drawing.Size(84, 13);
this.lblPaletteAddr.TabIndex = 15;
@ -342,7 +305,7 @@ namespace Mesen.GUI.Debugger.Controls
//
this.lblTileAddress.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblTileAddress.AutoSize = true;
this.lblTileAddress.Location = new System.Drawing.Point(154, 32);
this.lblTileAddress.Location = new System.Drawing.Point(147, 32);
this.lblTileAddress.Name = "lblTileAddress";
this.lblTileAddress.Size = new System.Drawing.Size(68, 13);
this.lblTileAddress.TabIndex = 1;
@ -351,7 +314,7 @@ namespace Mesen.GUI.Debugger.Controls
// txtPaletteAddress
//
this.txtPaletteAddress.BackColor = System.Drawing.SystemColors.Window;
this.txtPaletteAddress.Location = new System.Drawing.Point(244, 3);
this.txtPaletteAddress.Location = new System.Drawing.Point(237, 3);
this.txtPaletteAddress.Name = "txtPaletteAddress";
this.txtPaletteAddress.ReadOnly = true;
this.txtPaletteAddress.Size = new System.Drawing.Size(42, 20);
@ -360,7 +323,7 @@ namespace Mesen.GUI.Debugger.Controls
// txtTileAddress
//
this.txtTileAddress.BackColor = System.Drawing.SystemColors.Window;
this.txtTileAddress.Location = new System.Drawing.Point(244, 29);
this.txtTileAddress.Location = new System.Drawing.Point(237, 29);
this.txtTileAddress.Name = "txtTileAddress";
this.txtTileAddress.ReadOnly = true;
this.txtTileAddress.Size = new System.Drawing.Size(42, 20);
@ -376,12 +339,11 @@ namespace Mesen.GUI.Debugger.Controls
this.tableLayoutPanel1.Controls.Add(this.chkHorizontalMirroring, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.chkVerticalMirroring, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.chkBackgroundPriority, 0, 2);
this.tableLayoutPanel1.Location = new System.Drawing.Point(151, 52);
this.tableLayoutPanel1.Location = new System.Drawing.Point(144, 78);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3);
this.tableLayoutPanel1.RowCount = 3;
this.tlpInfo.SetRowSpan(this.tableLayoutPanel1, 2);
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
@ -427,11 +389,64 @@ namespace Mesen.GUI.Debugger.Controls
this.tlpInfo.SetColumnSpan(this.ctrlTilePalette, 2);
this.ctrlTilePalette.DisplayIndexes = false;
this.ctrlTilePalette.HighlightMouseOver = false;
this.ctrlTilePalette.Location = new System.Drawing.Point(82, 217);
this.ctrlTilePalette.Location = new System.Drawing.Point(75, 191);
this.ctrlTilePalette.Name = "ctrlTilePalette";
this.ctrlTilePalette.Size = new System.Drawing.Size(130, 34);
this.ctrlTilePalette.TabIndex = 25;
//
// lblPosition
//
this.lblPosition.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblPosition.AutoSize = true;
this.lblPosition.Location = new System.Drawing.Point(147, 58);
this.lblPosition.Name = "lblPosition";
this.lblPosition.Size = new System.Drawing.Size(73, 13);
this.lblPosition.TabIndex = 16;
this.lblPosition.Text = "Position (X,Y):";
//
// txtPosition
//
this.txtPosition.BackColor = System.Drawing.SystemColors.Window;
this.txtPosition.Location = new System.Drawing.Point(237, 55);
this.txtPosition.Name = "txtPosition";
this.txtPosition.ReadOnly = true;
this.txtPosition.Size = new System.Drawing.Size(66, 20);
this.txtPosition.TabIndex = 18;
//
// lblTile
//
this.lblTile.AutoSize = true;
this.lblTile.Location = new System.Drawing.Point(3, 57);
this.lblTile.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
this.lblTile.Name = "lblTile";
this.lblTile.Size = new System.Drawing.Size(27, 13);
this.lblTile.TabIndex = 6;
this.lblTile.Text = "Tile:";
//
// picTile
//
this.picTile.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.picTile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picTile.Location = new System.Drawing.Point(75, 55);
this.picTile.Name = "picTile";
this.tlpInfo.SetRowSpan(this.picTile, 2);
this.picTile.Size = new System.Drawing.Size(66, 130);
this.picTile.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picTile.TabIndex = 12;
this.picTile.TabStop = false;
//
// chkDisplaySpriteOutlines
//
this.chkDisplaySpriteOutlines.AutoSize = true;
this.tlpInfo.SetColumnSpan(this.chkDisplaySpriteOutlines, 4);
this.chkDisplaySpriteOutlines.Location = new System.Drawing.Point(3, 479);
this.chkDisplaySpriteOutlines.Name = "chkDisplaySpriteOutlines";
this.chkDisplaySpriteOutlines.Size = new System.Drawing.Size(227, 17);
this.chkDisplaySpriteOutlines.TabIndex = 27;
this.chkDisplaySpriteOutlines.Text = "Display outline around all sprites in preview";
this.chkDisplaySpriteOutlines.UseVisualStyleBackColor = true;
this.chkDisplaySpriteOutlines.Click += new System.EventHandler(this.chkDisplaySpriteOutlines_Click);
//
// picSprites
//
this.picSprites.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@ -462,9 +477,9 @@ namespace Mesen.GUI.Debugger.Controls
this.tlpInfo.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picPreview)).EndInit();
this.ctxMenu.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picTile)).EndInit();
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picTile)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picSprites)).EndInit();
this.ResumeLayout(false);
@ -505,5 +520,6 @@ namespace Mesen.GUI.Debugger.Controls
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
private System.Windows.Forms.ToolStripMenuItem mnuExportToPng;
private System.Windows.Forms.ToolStripMenuItem mnuEditInMemoryViewer;
private System.Windows.Forms.CheckBox chkDisplaySpriteOutlines;
}
}

View file

@ -47,6 +47,8 @@ namespace Mesen.GUI.Debugger.Controls
picPreview.Image = new Bitmap(256, 240, PixelFormat.Format32bppArgb);
picSprites.Image = new Bitmap(256, 512, PixelFormat.Format32bppArgb);
chkDisplaySpriteOutlines.Checked = ConfigManager.Config.DebugInfo.SpriteViewerDisplaySpriteOutlines;
_originalSpriteHeight = picSprites.Height;
_originalTileHeight = picTile.Height;
}
@ -207,6 +209,16 @@ namespace Mesen.GUI.Debugger.Controls
}
}
if(ConfigManager.Config.DebugInfo.SpriteViewerDisplaySpriteOutlines) {
using(Pen pen = new Pen(Color.White, 1)) {
for(int i = 63; i >= 0; i--) {
int spriteY = _spriteRam[i * 4];
int spriteX = _spriteRam[i * 4 + 3];
g.DrawRectangle(pen, new Rectangle(spriteX, spriteY, 9, _largeSprites ? 17 : 9));
}
}
}
if(_selectedSprite >= 0) {
DrawSprite(source, g, _selectedSprite);
}
@ -525,6 +537,13 @@ namespace Mesen.GUI.Debugger.Controls
DebugWindowManager.OpenMemoryViewer((tileIndex + tileIndexOffset) * 16, DebugMemoryType.PpuMemory);
}
private void chkDisplaySpriteOutlines_Click(object sender, EventArgs e)
{
ConfigManager.Config.DebugInfo.SpriteViewerDisplaySpriteOutlines = chkDisplaySpriteOutlines.Checked;
ConfigManager.ApplyChanges();
RefreshViewer();
}
private class SpriteInfo
{
public int SpriteIndex;