Debugger: PPU Viewer - Added compact display mode

This commit is contained in:
Sour 2019-01-17 00:12:33 -05:00
parent 6fd02bdba5
commit 9b68473863
15 changed files with 307 additions and 112 deletions

View file

@ -54,6 +54,9 @@ namespace Mesen.GUI.Config
[ShortcutName("Go to All")]
public XmlKeys GoToAll = Keys.Control | Keys.Oemcomma;
[ShortcutName("PPU Viewer: Toggle View")]
public XmlKeys PpuViewer_ToggleView = Keys.Control | Keys.Q;
[ShortcutName("Edit in Memory Viewer")]
public XmlKeys CodeWindow_EditInMemoryViewer = Keys.F1;
[ShortcutName("View in disassembly")]

View file

@ -60,15 +60,15 @@ namespace Mesen.GUI.Debugger.Controls
this.ctrlTilePalette = new Mesen.GUI.Debugger.Controls.ctrlTilePalette();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.picChrBank1 = new System.Windows.Forms.PictureBox();
this.ctxMenu = new ctrlMesenContextMenuStrip(this.components);
this.ctxMenu = new Mesen.GUI.Controls.ctrlMesenContextMenuStrip(this.components);
this.mnuEditInMemoryViewer = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
this.mnuCopyHdPack = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.mnuCopyToClipboard = new System.Windows.Forms.ToolStripMenuItem();
this.mnuExportToPng = new System.Windows.Forms.ToolStripMenuItem();
this.picChrBank2 = new System.Windows.Forms.PictureBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.mnuEditInMemoryViewer = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
this.tableLayoutPanel3.SuspendLayout();
this.grpDisplayOptions.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
@ -477,9 +477,22 @@ namespace Mesen.GUI.Debugger.Controls
this.mnuCopyToClipboard,
this.mnuExportToPng});
this.ctxMenu.Name = "ctxMenu";
this.ctxMenu.Size = new System.Drawing.Size(222, 126);
this.ctxMenu.Size = new System.Drawing.Size(222, 104);
this.ctxMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ctxMenu_Opening);
//
// mnuEditInMemoryViewer
//
this.mnuEditInMemoryViewer.Image = global::Mesen.GUI.Properties.Resources.CheatCode;
this.mnuEditInMemoryViewer.Name = "mnuEditInMemoryViewer";
this.mnuEditInMemoryViewer.Size = new System.Drawing.Size(221, 22);
this.mnuEditInMemoryViewer.Text = "Edit in Memory Viewer";
this.mnuEditInMemoryViewer.Click += new System.EventHandler(this.mnuEditInMemoryViewer_Click);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(218, 6);
//
// mnuCopyHdPack
//
this.mnuCopyHdPack.Name = "mnuCopyHdPack";
@ -531,19 +544,6 @@ namespace Mesen.GUI.Debugger.Controls
this.toolTip.InitialDelay = 10;
this.toolTip.ReshowDelay = 10;
//
// mnuEditInMemoryViewer
//
this.mnuEditInMemoryViewer.Image = global::Mesen.GUI.Properties.Resources.CheatCode;
this.mnuEditInMemoryViewer.Name = "mnuEditInMemoryViewer";
this.mnuEditInMemoryViewer.Size = new System.Drawing.Size(221, 22);
this.mnuEditInMemoryViewer.Text = "Edit in Memory Viewer";
this.mnuEditInMemoryViewer.Click += new System.EventHandler(this.mnuEditInMemoryViewer_Click);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(218, 6);
//
// ctrlChrViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View file

@ -14,7 +14,7 @@ using Mesen.GUI.Forms;
namespace Mesen.GUI.Debugger.Controls
{
public partial class ctrlChrViewer : BaseControl
public partial class ctrlChrViewer : BaseControl, ICompactControl
{
private byte[][] _chrPixelData = new byte[2][];
private UInt32[][] _paletteData = new UInt32[2][];
@ -64,6 +64,11 @@ namespace Mesen.GUI.Debugger.Controls
}
}
public Size GetCompactSize()
{
return new Size(picChrBank1.Width, picChrBank1.Height * 2 + picChrBank1.Margin.Bottom * 2);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
@ -239,7 +244,6 @@ namespace Mesen.GUI.Debugger.Controls
this.RefreshViewer();
}
private void chkShowSingleColorTilesInGrayscale_CheckedChanged(object sender, EventArgs e)
{
ConfigManager.Config.DebugInfo.ChrViewerShowSingleColorTilesInGrayscale = this.chkShowSingleColorTilesInGrayscale.Checked;
@ -290,8 +294,8 @@ namespace Mesen.GUI.Debugger.Controls
private void picChrBank_MouseMove(object sender, MouseEventArgs e)
{
int tileX = Math.Min(e.X * 256 / (picChrBank1.Width - 2) / 16, 15);
int tileY = Math.Min(e.Y * 256 / (picChrBank1.Height - 2) / 16, 15);
int tileX = Math.Max(0, Math.Min(e.X * 256 / (picChrBank1.Width - 2) / 16, 15));
int tileY = Math.Max(0, Math.Min(e.Y * 256 / (picChrBank1.Height - 2) / 16, 15));
bool bottomBank = sender == this.picChrBank2;
int tileIndex = tileY * 16 + tileX;

View file

@ -14,7 +14,7 @@ using Mesen.GUI.Forms;
namespace Mesen.GUI.Debugger.Controls
{
public partial class ctrlNametableViewer : BaseControl
public partial class ctrlNametableViewer : BaseControl, ICompactControl
{
public event EventHandler OnSelectChrTile;
@ -58,6 +58,11 @@ namespace Mesen.GUI.Debugger.Controls
}
}
public Size GetCompactSize()
{
return new Size(picNametable.Width, picNametable.Height);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(ctxMenu.ProcessCommandKey(ref msg, keyData)) {
@ -278,8 +283,8 @@ namespace Mesen.GUI.Debugger.Controls
private void picNametable_MouseMove(object sender, MouseEventArgs e)
{
int xPos = e.X * 512 / (picNametable.Width - 2);
int yPos = e.Y * 480 / (picNametable.Height - 2);
int xPos = Math.Max(0, e.X * 512 / (picNametable.Width - 2));
int yPos = Math.Max(0, e.Y * 480 / (picNametable.Height - 2));
_nametableIndex = 0;
if(xPos >= 256) {

View file

@ -41,31 +41,35 @@
this.txtColorCodeHex = new System.Windows.Forms.TextBox();
this.txtColorCodeRgb = new System.Windows.Forms.TextBox();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.picPalette = new System.Windows.Forms.PictureBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.picHelp = new System.Windows.Forms.PictureBox();
this.lblClickColorHint = new System.Windows.Forms.Label();
this.lblPaletteSprites = new System.Windows.Forms.Label();
this.picPaletteSprites = new System.Windows.Forms.PictureBox();
this.ctxMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.mnuCopyHexColor = new System.Windows.Forms.ToolStripMenuItem();
this.mnuCopyRgbColor = new System.Windows.Forms.ToolStripMenuItem();
this.picPaletteBg = new System.Windows.Forms.PictureBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.picHelp = new System.Windows.Forms.PictureBox();
this.lblClickColorHint = new System.Windows.Forms.Label();
this.lblBgPalette = new System.Windows.Forms.Label();
this.grpColorInfo.SuspendLayout();
this.tableLayoutPanel4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picColor)).BeginInit();
this.tableLayoutPanel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picPalette)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picPaletteSprites)).BeginInit();
this.ctxMenu.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picPaletteBg)).BeginInit();
this.flowLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picHelp)).BeginInit();
this.ctxMenu.SuspendLayout();
this.SuspendLayout();
//
// grpColorInfo
//
this.grpColorInfo.Controls.Add(this.tableLayoutPanel4);
this.grpColorInfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpColorInfo.Location = new System.Drawing.Point(141, 3);
this.grpColorInfo.Location = new System.Drawing.Point(273, 3);
this.grpColorInfo.Name = "grpColorInfo";
this.tableLayoutPanel3.SetRowSpan(this.grpColorInfo, 2);
this.grpColorInfo.Size = new System.Drawing.Size(538, 305);
this.tableLayoutPanel3.SetRowSpan(this.grpColorInfo, 3);
this.grpColorInfo.Size = new System.Drawing.Size(406, 305);
this.grpColorInfo.TabIndex = 4;
this.grpColorInfo.TabStop = false;
this.grpColorInfo.Text = "Color Info";
@ -95,7 +99,7 @@
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.Size = new System.Drawing.Size(532, 286);
this.tableLayoutPanel4.Size = new System.Drawing.Size(400, 286);
this.tableLayoutPanel4.TabIndex = 0;
//
// txtPaletteAddress
@ -200,61 +204,47 @@
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Controls.Add(this.lblPaletteSprites, 1, 1);
this.tableLayoutPanel3.Controls.Add(this.picPaletteSprites, 1, 0);
this.tableLayoutPanel3.Controls.Add(this.grpColorInfo, 2, 0);
this.tableLayoutPanel3.Controls.Add(this.picPalette, 0, 0);
this.tableLayoutPanel3.Controls.Add(this.flowLayoutPanel1, 0, 1);
this.tableLayoutPanel3.Controls.Add(this.picPaletteBg, 0, 0);
this.tableLayoutPanel3.Controls.Add(this.flowLayoutPanel1, 0, 2);
this.tableLayoutPanel3.Controls.Add(this.lblBgPalette, 0, 1);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 2;
this.tableLayoutPanel3.RowCount = 3;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(682, 311);
this.tableLayoutPanel3.TabIndex = 3;
//
// picPalette
// lblPaletteSprites
//
this.picPalette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picPalette.ContextMenuStrip = this.ctxMenu;
this.picPalette.Cursor = System.Windows.Forms.Cursors.Hand;
this.picPalette.Location = new System.Drawing.Point(4, 4);
this.picPalette.Margin = new System.Windows.Forms.Padding(4);
this.picPalette.Name = "picPalette";
this.picPalette.Size = new System.Drawing.Size(130, 258);
this.picPalette.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picPalette.TabIndex = 0;
this.picPalette.TabStop = false;
this.picPalette.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picPalette_MouseDown);
this.picPalette.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picPalette_MouseMove);
this.lblPaletteSprites.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.lblPaletteSprites.AutoSize = true;
this.lblPaletteSprites.Location = new System.Drawing.Point(183, 138);
this.lblPaletteSprites.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblPaletteSprites.Name = "lblPaletteSprites";
this.lblPaletteSprites.Size = new System.Drawing.Size(39, 13);
this.lblPaletteSprites.TabIndex = 8;
this.lblPaletteSprites.Text = "Sprites";
//
// flowLayoutPanel1
// picPaletteSprites
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanel1.Controls.Add(this.picHelp);
this.flowLayoutPanel1.Controls.Add(this.lblClickColorHint);
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 269);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(122, 39);
this.flowLayoutPanel1.TabIndex = 5;
//
// picHelp
//
this.picHelp.Image = global::Mesen.GUI.Properties.Resources.Help;
this.picHelp.Location = new System.Drawing.Point(3, 5);
this.picHelp.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
this.picHelp.Name = "picHelp";
this.picHelp.Size = new System.Drawing.Size(18, 18);
this.picHelp.TabIndex = 9;
this.picHelp.TabStop = false;
//
// lblClickColorHint
//
this.lblClickColorHint.Location = new System.Drawing.Point(27, 0);
this.lblClickColorHint.Name = "lblClickColorHint";
this.lblClickColorHint.Size = new System.Drawing.Size(92, 42);
this.lblClickColorHint.TabIndex = 5;
this.lblClickColorHint.Text = "Click on a color to change it";
this.picPaletteSprites.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picPaletteSprites.ContextMenuStrip = this.ctxMenu;
this.picPaletteSprites.Cursor = System.Windows.Forms.Cursors.Hand;
this.picPaletteSprites.Location = new System.Drawing.Point(138, 4);
this.picPaletteSprites.Margin = new System.Windows.Forms.Padding(2, 4, 2, 4);
this.picPaletteSprites.Name = "picPaletteSprites";
this.picPaletteSprites.Size = new System.Drawing.Size(130, 130);
this.picPaletteSprites.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picPaletteSprites.TabIndex = 6;
this.picPaletteSprites.TabStop = false;
this.picPaletteSprites.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picPalette_MouseDown);
this.picPaletteSprites.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picPalette_MouseMove);
//
// ctxMenu
//
@ -262,7 +252,7 @@
this.mnuCopyHexColor,
this.mnuCopyRgbColor});
this.ctxMenu.Name = "ctxMenu";
this.ctxMenu.Size = new System.Drawing.Size(160, 70);
this.ctxMenu.Size = new System.Drawing.Size(160, 48);
this.ctxMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ctxMenu_Opening);
//
// mnuCopyHexColor
@ -277,6 +267,65 @@
this.mnuCopyRgbColor.Size = new System.Drawing.Size(159, 22);
this.mnuCopyRgbColor.Text = "Copy RGB Color";
//
// picPaletteBg
//
this.picPaletteBg.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picPaletteBg.ContextMenuStrip = this.ctxMenu;
this.picPaletteBg.Cursor = System.Windows.Forms.Cursors.Hand;
this.picPaletteBg.Location = new System.Drawing.Point(4, 4);
this.picPaletteBg.Margin = new System.Windows.Forms.Padding(4, 4, 2, 4);
this.picPaletteBg.Name = "picPaletteBg";
this.picPaletteBg.Size = new System.Drawing.Size(130, 130);
this.picPaletteBg.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picPaletteBg.TabIndex = 0;
this.picPaletteBg.TabStop = false;
this.picPaletteBg.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picPalette_MouseDown);
this.picPaletteBg.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picPalette_MouseMove);
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tableLayoutPanel3.SetColumnSpan(this.flowLayoutPanel1, 2);
this.flowLayoutPanel1.Controls.Add(this.picHelp);
this.flowLayoutPanel1.Controls.Add(this.lblClickColorHint);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top;
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 154);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(264, 26);
this.flowLayoutPanel1.TabIndex = 5;
//
// picHelp
//
this.picHelp.Image = global::Mesen.GUI.Properties.Resources.Help;
this.picHelp.Location = new System.Drawing.Point(3, 5);
this.picHelp.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
this.picHelp.Name = "picHelp";
this.picHelp.Size = new System.Drawing.Size(18, 18);
this.picHelp.TabIndex = 9;
this.picHelp.TabStop = false;
//
// lblClickColorHint
//
this.lblClickColorHint.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblClickColorHint.AutoSize = true;
this.lblClickColorHint.Location = new System.Drawing.Point(27, 6);
this.lblClickColorHint.Name = "lblClickColorHint";
this.lblClickColorHint.Size = new System.Drawing.Size(139, 13);
this.lblClickColorHint.TabIndex = 5;
this.lblClickColorHint.Text = "Click on a color to change it";
//
// lblBgPalette
//
this.lblBgPalette.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.lblBgPalette.AutoSize = true;
this.lblBgPalette.Location = new System.Drawing.Point(36, 138);
this.lblBgPalette.Margin = new System.Windows.Forms.Padding(4, 0, 2, 0);
this.lblBgPalette.Name = "lblBgPalette";
this.lblBgPalette.Size = new System.Drawing.Size(65, 13);
this.lblBgPalette.TabIndex = 7;
this.lblBgPalette.Text = "Background";
//
// ctrlPaletteViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -290,17 +339,19 @@
((System.ComponentModel.ISupportInitialize)(this.picColor)).EndInit();
this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picPalette)).EndInit();
this.flowLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picHelp)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picPaletteSprites)).EndInit();
this.ctxMenu.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picPaletteBg)).EndInit();
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picHelp)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox picPalette;
private System.Windows.Forms.PictureBox picPaletteBg;
private System.Windows.Forms.GroupBox grpColorInfo;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.TextBox txtPaletteAddress;
@ -320,5 +371,8 @@
private System.Windows.Forms.ContextMenuStrip ctxMenu;
private System.Windows.Forms.ToolStripMenuItem mnuCopyHexColor;
private System.Windows.Forms.ToolStripMenuItem mnuCopyRgbColor;
private System.Windows.Forms.PictureBox picPaletteSprites;
private System.Windows.Forms.Label lblBgPalette;
private System.Windows.Forms.Label lblPaletteSprites;
}
}

View file

@ -13,7 +13,7 @@ using Mesen.GUI.Forms;
namespace Mesen.GUI.Debugger.Controls
{
public partial class ctrlPaletteViewer : BaseControl
public partial class ctrlPaletteViewer : BaseControl, ICompactControl
{
private byte[] _paletteRam;
private int[] _palettePixelData;
@ -23,7 +23,12 @@ namespace Mesen.GUI.Debugger.Controls
{
InitializeComponent();
}
public Size GetCompactSize()
{
return new Size(picPaletteBg.Width * 2 + picPaletteBg.Margin.Right * 2, picPaletteBg.Height);
}
public void GetData()
{
this._paletteRam = InteropEmu.DebugGetMemoryState(DebugMemoryType.PaletteMemory);
@ -34,32 +39,39 @@ namespace Mesen.GUI.Debugger.Controls
{
GCHandle handle = GCHandle.Alloc(this._palettePixelData, GCHandleType.Pinned);
try {
Bitmap source = new Bitmap(4, 8, 4*4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject());
Bitmap target = new Bitmap(128, 256);
for(int i = 0; i < 2; i++) {
Bitmap source = new Bitmap(4, 4, 4 * 4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject()+i*16);
Bitmap target = new Bitmap(128, 128);
using(Graphics g = Graphics.FromImage(target)) {
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
g.ScaleTransform(32, 32);
g.DrawImageUnscaled(source, 0, 0);
using(Graphics g = Graphics.FromImage(target)) {
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
g.ScaleTransform(32, 32);
g.DrawImageUnscaled(source, 0, 0);
g.ResetTransform();
Font font = new Font(BaseControl.MonospaceFontFamily, BaseControl.DefaultFontSize - 2, GraphicsUnit.Pixel);
using(Brush bg = new SolidBrush(Color.FromArgb(150, Color.LightGray))) {
for(int y = 0; y < 8; y++) {
for(int x = 0; x < 4; x++) {
g.DrawOutlinedString(_paletteRam[y*4+x].ToString("X2"), font, Brushes.Black, bg, 32*x+14, 32*y+18);
g.ResetTransform();
Font font = new Font(BaseControl.MonospaceFontFamily, BaseControl.DefaultFontSize - 2, GraphicsUnit.Pixel);
using(Brush bg = new SolidBrush(Color.FromArgb(150, Color.LightGray))) {
for(int y = 0; y < 4; y++) {
for(int x = 0; x < 4; x++) {
g.DrawOutlinedString(_paletteRam[y * 4 + x + i * 16].ToString("X2"), font, Brushes.Black, bg, 32 * x + 14, 32 * y + 18);
}
}
}
}
if(i == 0) {
this.picPaletteBg.Image = target;
} else {
this.picPaletteSprites.Image = target;
}
}
this.picPalette.Image = target;
} finally {
handle.Free();
}
this.picPalette.Refresh();
this.picPaletteBg.Refresh();
this.picPaletteSprites.Refresh();
if(_paletteIndex == -1) {
UpdateColorInformation(0);
@ -68,10 +80,10 @@ namespace Mesen.GUI.Debugger.Controls
private void picPalette_MouseMove(object sender, MouseEventArgs e)
{
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 tileX = Math.Max(0, Math.Min(e.X * 128 / (picPaletteBg.Width - 2) / 32, 31));
int tileY = Math.Max(0, Math.Min(e.Y * 128 / (picPaletteBg.Height - 2) / 32, 31));
int paletteIndex = tileY * 4 + tileX;
int paletteIndex = tileY * 4 + tileX + (sender == picPaletteSprites ? 16 : 0);
if(paletteIndex != _paletteIndex) {
UpdateColorInformation(paletteIndex);
@ -95,7 +107,7 @@ namespace Mesen.GUI.Debugger.Controls
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
g.DrawImage(picPalette.Image, new Rectangle(0, 0, 64, 64), new Rectangle(tileX * 32, tileY * 32, 32, 32), GraphicsUnit.Pixel);
g.DrawImage(picPaletteBg.Image, new Rectangle(0, 0, 64, 64), new Rectangle(tileX * 32, tileY * 32, 32, 32), GraphicsUnit.Pixel);
}
this.picColor.Image = tile;
}
@ -105,9 +117,9 @@ namespace Mesen.GUI.Debugger.Controls
if(e.Button == MouseButtons.Left) {
using(frmSelectColor frm = new frmSelectColor()) {
if(frm.ShowDialog(this) == DialogResult.OK) {
int x = Math.Min(e.X * 128 / picPalette.Width / 32, 31);
int y = Math.Min(e.Y * 256 / picPalette.Height / 32, 31);
int colorAddress = y * 4 + x;
int x = Math.Min(e.X * 128 / picPaletteBg.Width / 32, 31);
int y = Math.Min(e.Y * 128 / picPaletteBg.Height / 32, 31);
int colorAddress = y * 4 + x + (sender == picPaletteSprites ? 16 : 0);
InteropEmu.DebugSetMemoryValue(DebugMemoryType.PaletteMemory, (uint)colorAddress, (byte)frm.ColorIndex);
this.GetData();

View file

@ -15,7 +15,7 @@ using Mesen.GUI.Forms;
namespace Mesen.GUI.Debugger.Controls
{
public partial class ctrlSpriteViewer : BaseControl
public partial class ctrlSpriteViewer : BaseControl, ICompactControl
{
public delegate void SelectTilePaletteHandler(int tileIndex, int paletteIndex);
public event SelectTilePaletteHandler OnSelectTilePalette;
@ -40,6 +40,11 @@ namespace Mesen.GUI.Debugger.Controls
picPreview.Image = new Bitmap(256, 240, PixelFormat.Format32bppArgb);
picSprites.Image = new Bitmap(256, 512, PixelFormat.Format32bppArgb);
}
public Size GetCompactSize()
{
return new Size(picSprites.Width, picSprites.Height);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
@ -167,8 +172,8 @@ namespace Mesen.GUI.Debugger.Controls
{
_previewMousePosition = null;
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 tileX = Math.Max(0, Math.Min(e.X * 256 / (picSprites.Width - 2) / 32, 31));
int tileY = Math.Max(0, Math.Min(e.Y * 512 / (picSprites.Height - 2) / 64, 63));
int ramAddr = ((tileY << 3) + tileX) << 2;
if(ramAddr / 4 == _selectedSprite && !_forceRefresh) {

View file

@ -39,6 +39,7 @@ namespace Mesen.GUI.Debugger
GetMember(nameof(DebuggerShortcutsConfig.GoToAll)),
GetMember(nameof(DebuggerShortcutsConfig.CodeWindow_EditInMemoryViewer)),
GetMember(nameof(DebuggerShortcutsConfig.MemoryViewer_ViewInDisassembly)),
GetMember(nameof(DebuggerShortcutsConfig.PpuViewer_ToggleView)),
GetMember(nameof(DebuggerShortcutsConfig.OpenApuViewer)),
GetMember(nameof(DebuggerShortcutsConfig.OpenAssembler)),

View file

@ -55,6 +55,7 @@ namespace Mesen.GUI.Debugger
this.tpgPaletteViewer = new System.Windows.Forms.TabPage();
this.ctrlPaletteViewer = new Mesen.GUI.Debugger.Controls.ctrlPaletteViewer();
this.ctrlScanlineCycle = new Mesen.GUI.Debugger.Controls.ctrlScanlineCycleSelect();
this.btnToggleView = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
this.tabMain.SuspendLayout();
this.tpgNametableViewer.SuspendLayout();
@ -212,7 +213,6 @@ namespace Mesen.GUI.Debugger
//
this.ctrlChrViewer.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlChrViewer.Location = new System.Drawing.Point(0, 0);
this.ctrlChrViewer.Margin = new System.Windows.Forms.Padding(0);
this.ctrlChrViewer.Name = "ctrlChrViewer";
this.ctrlChrViewer.Size = new System.Drawing.Size(701, 527);
this.ctrlChrViewer.TabIndex = 2;
@ -262,18 +262,29 @@ namespace Mesen.GUI.Debugger
this.ctrlScanlineCycle.Size = new System.Drawing.Size(709, 28);
this.ctrlScanlineCycle.TabIndex = 4;
//
// btnToggleView
//
this.btnToggleView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnToggleView.Image = global::Mesen.GUI.Properties.Resources.Collapse;
this.btnToggleView.Location = new System.Drawing.Point(680, 1);
this.btnToggleView.Name = "btnToggleView";
this.btnToggleView.Size = new System.Drawing.Size(27, 22);
this.btnToggleView.TabIndex = 1;
this.btnToggleView.UseVisualStyleBackColor = true;
this.btnToggleView.Click += new System.EventHandler(this.btnToggleView_Click);
//
// frmPpuViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(709, 605);
this.Controls.Add(this.btnToggleView);
this.Controls.Add(this.tabMain);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.ctrlScanlineCycle);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MainMenuStrip = this.menuStrip1;
this.MaximizeBox = false;
this.MinimumSize = new System.Drawing.Size(725, 644);
this.Name = "frmPpuViewer";
this.Text = "PPU Viewer";
this.menuStrip1.ResumeLayout(false);
@ -312,5 +323,6 @@ namespace Mesen.GUI.Debugger
private System.Windows.Forms.ToolStripMenuItem mnuAutoRefreshLow;
private System.Windows.Forms.ToolStripMenuItem mnuAutoRefreshNormal;
private System.Windows.Forms.ToolStripMenuItem mnuAutoRefreshHigh;
private System.Windows.Forms.Button btnToggleView;
}
}

View file

@ -1,4 +1,5 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using Mesen.GUI.Config;
using Mesen.GUI.Forms;
@ -11,6 +12,8 @@ namespace Mesen.GUI.Debugger
private InteropEmu.NotificationListener _notifListener;
private TabPage _selectedTab;
private bool _refreshing = false;
private Size _originalSize;
private bool _isCompact;
private static int _nextPpuViewerId = 0;
private int _ppuViewerId = 0;
@ -61,6 +64,12 @@ namespace Mesen.GUI.Debugger
this.InitShortcuts();
this.UpdateRefreshSpeedMenu();
string toggleViewTooltip = "Toggle Compact/Normal View";
if(ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView != Keys.None) {
toggleViewTooltip += " (" + DebuggerShortcutsConfig.GetShortcutDisplay(ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView) + ")";
}
this.toolTip.SetToolTip(this.btnToggleView, toggleViewTooltip);
}
}
@ -166,6 +175,11 @@ namespace Mesen.GUI.Debugger
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView) {
ToggleView();
return true;
}
if(!this.ctrlScanlineCycle.ContainsFocus) {
if(this.tabMain.SelectedTab == tpgChrViewer) {
bool shift = keyData.HasFlag(Keys.Shift);
@ -228,5 +242,62 @@ namespace Mesen.GUI.Debugger
UpdateRefreshSpeedMenu();
}
private void ToggleCompactMode(ICompactControl control, TabPage tab, string title)
{
if(!_isCompact) {
Point tabTopLeft = tabMain.PointToScreen(Point.Empty);
Point tabContentTopLeft = ctrlNametableViewer.PointToScreen(Point.Empty);
int heightGap = tabContentTopLeft.Y - tabTopLeft.Y + ctrlScanlineCycle.Height;
_isCompact = true;
_originalSize = this.Size;
Size size = control.GetCompactSize();
int widthDiff = ((Control)control).Width - size.Width;
int heightDiff = ((Control)control).Height - size.Height;
this.Controls.Add((Control)control);
((Control)control).BringToFront();
tabMain.Visible = false;
ctrlScanlineCycle.Visible = false;
this.Text = title;
this.Size = new Size(this.Width - widthDiff, this.Height - heightDiff - heightGap + 3);
} else {
_isCompact = false;
this.Size = _originalSize;
tabMain.Visible = true;
tab.Controls.Add((Control)control);
ctrlScanlineCycle.Visible = true;
this.Text = "PPU Viewer";
}
btnToggleView.Image = _isCompact ? Properties.Resources.Expand : Properties.Resources.Collapse;
}
private void ToggleView()
{
if(_selectedTab == tpgChrViewer) {
ToggleCompactMode(ctrlChrViewer, tpgChrViewer, "CHR Viewer");
} else if(_selectedTab == tpgPaletteViewer) {
ToggleCompactMode(ctrlPaletteViewer, tpgPaletteViewer, "Palette Viewer");
} else if(_selectedTab == tpgSpriteViewer) {
ToggleCompactMode(ctrlSpriteViewer, tpgSpriteViewer, "Sprite Viewer");
} else if(_selectedTab == tpgNametableViewer) {
ToggleCompactMode(ctrlNametableViewer, tpgNametableViewer, "Nametable Viewer");
}
}
private void btnToggleView_Click(object sender, EventArgs e)
{
ToggleView();
}
}
public interface ICompactControl
{
Size GetCompactSize();
}
}

View file

@ -1250,6 +1250,8 @@
<Compile Include="RuntimeChecker.cs" />
<Compile Include="SingleInstance.cs" />
<Compile Include="TestRunner.cs" />
<None Include="Resources\Expand.png" />
<None Include="Resources\Collapse.png" />
<None Include="Resources\RegisterIcon.png" />
<None Include="Resources\JumpTarget.png" />
<None Include="Resources\Cut.png" />

View file

@ -210,6 +210,16 @@ namespace Mesen.GUI.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Collapse {
get {
object obj = ResourceManager.GetObject("Collapse", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@ -370,6 +380,16 @@ namespace Mesen.GUI.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Expand {
get {
object obj = ResourceManager.GetObject("Expand", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View file

@ -433,4 +433,10 @@
<data name="RegisterIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\RegisterIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Collapse" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Collapse.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Expand" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Expand.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B