From 02edb4558f52c0fce43a39bbcd335645c069565e Mon Sep 17 00:00:00 2001 From: Souryo Date: Mon, 14 Aug 2017 20:50:13 -0400 Subject: [PATCH] Debugger: Palette ram editor (in PPU viewer) --- .../Controls/ctrlPaletteViewer.Designer.cs | 59 +++++++-- .../Debugger/Controls/ctrlPaletteViewer.cs | 27 ++++ .../Debugger/ctrlPaletteDisplay.Designer.cs | 63 +++++++++ GUI.NET/Debugger/ctrlPaletteDisplay.cs | 111 ++++++++++++++++ GUI.NET/Debugger/ctrlPaletteDisplay.resx | 120 +++++++++++++++++ GUI.NET/Debugger/frmSelectColor.Designer.cs | 92 +++++++++++++ GUI.NET/Debugger/frmSelectColor.cs | 46 +++++++ GUI.NET/Debugger/frmSelectColor.resx | 123 ++++++++++++++++++ .../Forms/Config/frmVideoConfig.Designer.cs | 58 ++++----- GUI.NET/Forms/Config/frmVideoConfig.cs | 88 ++++--------- GUI.NET/Forms/GraphicsExtensions.cs | 20 +++ GUI.NET/GUI.NET.csproj | 22 +++- 12 files changed, 720 insertions(+), 109 deletions(-) create mode 100644 GUI.NET/Debugger/ctrlPaletteDisplay.Designer.cs create mode 100644 GUI.NET/Debugger/ctrlPaletteDisplay.cs create mode 100644 GUI.NET/Debugger/ctrlPaletteDisplay.resx create mode 100644 GUI.NET/Debugger/frmSelectColor.Designer.cs create mode 100644 GUI.NET/Debugger/frmSelectColor.cs create mode 100644 GUI.NET/Debugger/frmSelectColor.resx create mode 100644 GUI.NET/Forms/GraphicsExtensions.cs diff --git a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.Designer.cs b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.Designer.cs index 2dda9dbc..df53adef 100644 --- a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.Designer.cs @@ -37,20 +37,26 @@ this.picColor = new System.Windows.Forms.PictureBox(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.picPalette = new System.Windows.Forms.PictureBox(); + this.lblClickColorHint = new System.Windows.Forms.Label(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.picHelp = new System.Windows.Forms.PictureBox(); this.grpColorInfo.SuspendLayout(); this.tableLayoutPanel4.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picColor)).BeginInit(); this.tableLayoutPanel3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picPalette)).BeginInit(); + this.flowLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picHelp)).BeginInit(); this.SuspendLayout(); // // grpColorInfo // this.grpColorInfo.Controls.Add(this.tableLayoutPanel4); this.grpColorInfo.Dock = System.Windows.Forms.DockStyle.Fill; - this.grpColorInfo.Location = new System.Drawing.Point(135, 3); + this.grpColorInfo.Location = new System.Drawing.Point(137, 3); this.grpColorInfo.Name = "grpColorInfo"; - this.grpColorInfo.Size = new System.Drawing.Size(544, 254); + this.tableLayoutPanel3.SetRowSpan(this.grpColorInfo, 2); + this.grpColorInfo.Size = new System.Drawing.Size(542, 305); this.grpColorInfo.TabIndex = 4; this.grpColorInfo.TabStop = false; this.grpColorInfo.Text = "Color Info"; @@ -77,7 +83,7 @@ this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel4.Size = new System.Drawing.Size(538, 235); + this.tableLayoutPanel4.Size = new System.Drawing.Size(536, 286); this.tableLayoutPanel4.TabIndex = 0; // // txtPaletteAddress @@ -141,42 +147,73 @@ 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.grpColorInfo, 2, 1); - this.tableLayoutPanel3.Controls.Add(this.picPalette, 0, 1); + 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.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.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.Absolute, 20F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(682, 260); + 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 // this.picPalette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picPalette.Cursor = System.Windows.Forms.Cursors.Hand; this.picPalette.Location = new System.Drawing.Point(1, 1); this.picPalette.Margin = new System.Windows.Forms.Padding(1); this.picPalette.Name = "picPalette"; this.picPalette.Size = new System.Drawing.Size(130, 258); 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); // + // lblClickColorHint + // + this.lblClickColorHint.Location = new System.Drawing.Point(27, 0); + this.lblClickColorHint.Name = "lblClickColorHint"; + this.lblClickColorHint.Size = new System.Drawing.Size(92, 32); + this.lblClickColorHint.TabIndex = 5; + this.lblClickColorHint.Text = "Click on a color to change it"; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Controls.Add(this.picHelp); + this.flowLayoutPanel1.Controls.Add(this.lblClickColorHint); + this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 263); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(128, 31); + 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; + // // ctrlPaletteViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.tableLayoutPanel3); this.Name = "ctrlPaletteViewer"; - this.Size = new System.Drawing.Size(682, 260); + this.Size = new System.Drawing.Size(682, 311); this.grpColorInfo.ResumeLayout(false); this.tableLayoutPanel4.ResumeLayout(false); this.tableLayoutPanel4.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.picColor)).EndInit(); this.tableLayoutPanel3.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.picPalette)).EndInit(); + this.flowLayoutPanel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.picHelp)).EndInit(); this.ResumeLayout(false); } @@ -193,6 +230,8 @@ private System.Windows.Forms.TextBox txtColor; private System.Windows.Forms.PictureBox picColor; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; - + private System.Windows.Forms.Label lblClickColorHint; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.PictureBox picHelp; } } diff --git a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs index 36c120ed..1fdf262a 100644 --- a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices; using Mesen.GUI.Controls; +using Mesen.GUI.Forms; namespace Mesen.GUI.Debugger.Controls { @@ -49,6 +50,16 @@ namespace Mesen.GUI.Debugger.Controls g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; g.ScaleTransform(32, 32); g.DrawImageUnscaled(source, 0, 0); + + g.ScaleTransform(1f/32, 1f/32); + Font font = new Font(BaseControl.MonospaceFontFamily, BaseControl.DefaultFontSize - 2); + 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); + } + } + } } this.picPalette.Image = target; } finally { @@ -79,5 +90,21 @@ namespace Mesen.GUI.Debugger.Controls this.picColor.Image = tile; } } + + private void picPalette_MouseDown(object sender, MouseEventArgs e) + { + using(frmSelectColor frm = new frmSelectColor()) { + if(frm.ShowDialog(this) == DialogResult.OK) { + int x = Math.Min(e.X / 32, 31); + int y = Math.Min(e.Y / 32, 31); + + int colorAddress = y * 4 + x; + + InteropEmu.DebugSetMemoryValue(DebugMemoryType.PaletteMemory, (uint)colorAddress, (byte)frm.ColorIndex); + this.GetData(); + this.RefreshViewer(); + } + } + } } } diff --git a/GUI.NET/Debugger/ctrlPaletteDisplay.Designer.cs b/GUI.NET/Debugger/ctrlPaletteDisplay.Designer.cs new file mode 100644 index 00000000..2ad12066 --- /dev/null +++ b/GUI.NET/Debugger/ctrlPaletteDisplay.Designer.cs @@ -0,0 +1,63 @@ +namespace Mesen.GUI.Debugger +{ + partial class ctrlPaletteDisplay + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.picPalette = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.picPalette)).BeginInit(); + this.SuspendLayout(); + // + // picPalette + // + this.picPalette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picPalette.Cursor = System.Windows.Forms.Cursors.Hand; + this.picPalette.Dock = System.Windows.Forms.DockStyle.Fill; + this.picPalette.Location = new System.Drawing.Point(0, 0); + this.picPalette.Margin = new System.Windows.Forms.Padding(1); + this.picPalette.Name = "picPalette"; + this.picPalette.Size = new System.Drawing.Size(338, 338); + this.picPalette.TabIndex = 1; + this.picPalette.TabStop = false; + this.picPalette.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picPalette_MouseDown); + // + // ctrlPaletteDisplay + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.picPalette); + this.Name = "ctrlPaletteDisplay"; + this.Size = new System.Drawing.Size(338, 338); + ((System.ComponentModel.ISupportInitialize)(this.picPalette)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.PictureBox picPalette; + } +} diff --git a/GUI.NET/Debugger/ctrlPaletteDisplay.cs b/GUI.NET/Debugger/ctrlPaletteDisplay.cs new file mode 100644 index 00000000..e2bc1e0b --- /dev/null +++ b/GUI.NET/Debugger/ctrlPaletteDisplay.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Mesen.GUI.Forms; +using System.Runtime.InteropServices; +using Mesen.GUI.Controls; + +namespace Mesen.GUI.Debugger +{ + public partial class ctrlPaletteDisplay : UserControl + { + private int[] _paletteData; + private bool _showColorIndexes; + + public delegate void PaletteClickHandler(int colorIndex); + public event PaletteClickHandler ColorClick; + + public ctrlPaletteDisplay() + { + InitializeComponent(); + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public bool ShowColorIndexes + { + get + { + return _showColorIndexes; + } + set + { + _showColorIndexes = value; + this.RefreshPalette(); + } + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public int[] PaletteData + { + get + { + return _paletteData; + } + set + { + _paletteData = new int[value.Length]; + Array.Copy(value, _paletteData, value.Length); + this.RefreshPalette(); + } + } + + private void RefreshPalette() + { + if(this._paletteData == null) { + return; + } + + GCHandle handle = GCHandle.Alloc(this.PaletteData, GCHandleType.Pinned); + try { + Bitmap source = new Bitmap(16, 4, 16*4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject()); + Bitmap target = new Bitmap(336, 336); + + Font font = new Font(BaseControl.MonospaceFontFamily, BaseControl.DefaultFontSize - 2); + 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(42, 42); + g.DrawImageUnscaled(source, 0, 0); + g.DrawImageUnscaled(source, -8, 4); + + if(this.ShowColorIndexes) { + g.ScaleTransform(1f/42, 1f/42); + using(Brush bg = new SolidBrush(Color.FromArgb(150, Color.LightGray))) { + for(int y = 0; y < 8; y++) { + for(int x = 0; x < 8; x++) { + int index = y * 16 + x; + if(y >= 4) { + index = (y - 4) * 16 + x + 8; + } + g.DrawOutlinedString(index.ToString("X2"), font, Brushes.Black, bg, 42*x + 22, 42*y + 26); + } + } + } + } + } + picPalette.Image = target; + } finally { + handle.Free(); + } + } + + private void picPalette_MouseDown(object sender, MouseEventArgs e) + { + int y = e.Y / 42 < 4 ? e.Y : (e.Y - 168); + int x = e.Y / 42 < 4 ? e.X : (e.X + 336); + + int offset = (x / 42) + (y / 42 * 16); + + ColorClick?.Invoke(offset); + } + } +} diff --git a/GUI.NET/Debugger/ctrlPaletteDisplay.resx b/GUI.NET/Debugger/ctrlPaletteDisplay.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/GUI.NET/Debugger/ctrlPaletteDisplay.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GUI.NET/Debugger/frmSelectColor.Designer.cs b/GUI.NET/Debugger/frmSelectColor.Designer.cs new file mode 100644 index 00000000..80f1c0d2 --- /dev/null +++ b/GUI.NET/Debugger/frmSelectColor.Designer.cs @@ -0,0 +1,92 @@ +namespace Mesen.GUI.Debugger +{ + partial class frmSelectColor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.ctrlPaletteDisplay = new Mesen.GUI.Debugger.ctrlPaletteDisplay(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.lblSelectColor = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // ctrlPaletteDisplay + // + this.ctrlPaletteDisplay.Location = new System.Drawing.Point(6, 19); + this.ctrlPaletteDisplay.Name = "ctrlPaletteDisplay"; + this.ctrlPaletteDisplay.Size = new System.Drawing.Size(338, 338); + this.ctrlPaletteDisplay.TabIndex = 2; + this.ctrlPaletteDisplay.ColorClick += new Mesen.GUI.Debugger.ctrlPaletteDisplay.PaletteClickHandler(this.ctrlPaletteDisplay_ColorClick); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.ctrlPaletteDisplay, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.lblSelectColor, 0, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3); + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.Size = new System.Drawing.Size(350, 363); + this.tableLayoutPanel1.TabIndex = 3; + // + // lblSelectColor + // + this.lblSelectColor.AutoSize = true; + this.lblSelectColor.Location = new System.Drawing.Point(6, 3); + this.lblSelectColor.Name = "lblSelectColor"; + this.lblSelectColor.Size = new System.Drawing.Size(134, 13); + this.lblSelectColor.TabIndex = 3; + this.lblSelectColor.Text = "Click to select a new color:"; + // + // frmSelectColor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(350, 363); + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "frmSelectColor"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Select Color..."; + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private ctrlPaletteDisplay ctrlPaletteDisplay; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label lblSelectColor; + } +} \ No newline at end of file diff --git a/GUI.NET/Debugger/frmSelectColor.cs b/GUI.NET/Debugger/frmSelectColor.cs new file mode 100644 index 00000000..9a7193eb --- /dev/null +++ b/GUI.NET/Debugger/frmSelectColor.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Mesen.GUI.Forms; + +namespace Mesen.GUI.Debugger +{ + public partial class frmSelectColor : BaseForm + { + public int ColorIndex { get; private set; } + + public frmSelectColor() + { + InitializeComponent(); + } + + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + { + if(keyData == Keys.Escape) { + this.Close(); + } + return base.ProcessCmdKey(ref msg, keyData); + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + ctrlPaletteDisplay.ShowColorIndexes = true; + ctrlPaletteDisplay.PaletteData = InteropEmu.GetRgbPalette(); + } + + private void ctrlPaletteDisplay_ColorClick(int colorIndex) + { + this.ColorIndex = colorIndex; + this.DialogResult = DialogResult.OK; + this.Close(); + } + } +} diff --git a/GUI.NET/Debugger/frmSelectColor.resx b/GUI.NET/Debugger/frmSelectColor.resx new file mode 100644 index 00000000..8766f298 --- /dev/null +++ b/GUI.NET/Debugger/frmSelectColor.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/GUI.NET/Forms/Config/frmVideoConfig.Designer.cs b/GUI.NET/Forms/Config/frmVideoConfig.Designer.cs index b8627e03..3142dcda 100644 --- a/GUI.NET/Forms/Config/frmVideoConfig.Designer.cs +++ b/GUI.NET/Forms/Config/frmVideoConfig.Designer.cs @@ -95,12 +95,13 @@ namespace Mesen.GUI.Forms.Config this.nudOverscanRight = new System.Windows.Forms.NumericUpDown(); this.tpgPalette = new System.Windows.Forms.TabPage(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); - this.picPalette = new System.Windows.Forms.PictureBox(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.btnExportPalette = new System.Windows.Forms.Button(); this.btnSelectPalette = new System.Windows.Forms.Button(); this.btnLoadPalFile = new System.Windows.Forms.Button(); + this.chkShowColorIndexes = new System.Windows.Forms.CheckBox(); this.chkUseCustomVsPalette = new System.Windows.Forms.CheckBox(); + this.ctrlPaletteDisplay = new Mesen.GUI.Debugger.ctrlPaletteDisplay(); this.tpgAdvanced = new System.Windows.Forms.TabPage(); this.tableLayoutPanel9 = new System.Windows.Forms.TableLayoutPanel(); this.chkDisableBackground = new Mesen.GUI.Controls.ctrlRiskyOption(); @@ -124,7 +125,6 @@ namespace Mesen.GUI.Forms.Config this.mnuPaletteSonyCxa2025As = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPaletteUnsaturated = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPaletteYuv = new System.Windows.Forms.ToolStripMenuItem(); - this.chkShowColorIndexes = new System.Windows.Forms.CheckBox(); this.tlpMain.SuspendLayout(); this.flowLayoutPanel7.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picHdNesTooltip)).BeginInit(); @@ -157,7 +157,6 @@ namespace Mesen.GUI.Forms.Config ((System.ComponentModel.ISupportInitialize)(this.nudOverscanRight)).BeginInit(); this.tpgPalette.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.picPalette)).BeginInit(); this.tableLayoutPanel2.SuspendLayout(); this.tpgAdvanced.SuspendLayout(); this.tableLayoutPanel9.SuspendLayout(); @@ -1047,9 +1046,9 @@ namespace Mesen.GUI.Forms.Config this.tableLayoutPanel3.ColumnCount = 2; this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel3.Controls.Add(this.picPalette, 0, 0); this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel2, 1, 0); this.tableLayoutPanel3.Controls.Add(this.chkUseCustomVsPalette, 0, 1); + this.tableLayoutPanel3.Controls.Add(this.ctrlPaletteDisplay, 0, 0); this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 3); this.tableLayoutPanel3.Name = "tableLayoutPanel3"; @@ -1059,18 +1058,6 @@ namespace Mesen.GUI.Forms.Config this.tableLayoutPanel3.Size = new System.Drawing.Size(521, 370); this.tableLayoutPanel3.TabIndex = 4; // - // picPalette - // - this.picPalette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.picPalette.Cursor = System.Windows.Forms.Cursors.Hand; - this.picPalette.Location = new System.Drawing.Point(1, 1); - this.picPalette.Margin = new System.Windows.Forms.Padding(1); - this.picPalette.Name = "picPalette"; - this.picPalette.Size = new System.Drawing.Size(338, 338); - this.picPalette.TabIndex = 0; - this.picPalette.TabStop = false; - this.picPalette.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picPalette_MouseDown); - // // tableLayoutPanel2 // this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -1082,7 +1069,7 @@ namespace Mesen.GUI.Forms.Config this.tableLayoutPanel2.Controls.Add(this.btnSelectPalette, 0, 0); this.tableLayoutPanel2.Controls.Add(this.btnLoadPalFile, 0, 1); this.tableLayoutPanel2.Controls.Add(this.chkShowColorIndexes, 0, 3); - this.tableLayoutPanel2.Location = new System.Drawing.Point(340, 0); + this.tableLayoutPanel2.Location = new System.Drawing.Point(344, 0); this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel2.Name = "tableLayoutPanel2"; this.tableLayoutPanel2.RowCount = 4; @@ -1090,7 +1077,7 @@ namespace Mesen.GUI.Forms.Config this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(181, 340); + this.tableLayoutPanel2.Size = new System.Drawing.Size(181, 344); this.tableLayoutPanel2.TabIndex = 1; // // btnExportPalette @@ -1131,17 +1118,36 @@ namespace Mesen.GUI.Forms.Config this.btnLoadPalFile.UseVisualStyleBackColor = true; this.btnLoadPalFile.Click += new System.EventHandler(this.btnLoadPalFile_Click); // + // chkShowColorIndexes + // + this.chkShowColorIndexes.AutoSize = true; + this.chkShowColorIndexes.Location = new System.Drawing.Point(3, 90); + this.chkShowColorIndexes.Name = "chkShowColorIndexes"; + this.chkShowColorIndexes.Size = new System.Drawing.Size(118, 17); + this.chkShowColorIndexes.TabIndex = 4; + this.chkShowColorIndexes.Text = "Show color indexes"; + this.chkShowColorIndexes.UseVisualStyleBackColor = true; + this.chkShowColorIndexes.CheckedChanged += new System.EventHandler(this.chkShowColorIndexes_CheckedChanged); + // // chkUseCustomVsPalette // this.chkUseCustomVsPalette.AutoSize = true; this.tableLayoutPanel3.SetColumnSpan(this.chkUseCustomVsPalette, 2); - this.chkUseCustomVsPalette.Location = new System.Drawing.Point(3, 343); + this.chkUseCustomVsPalette.Location = new System.Drawing.Point(3, 347); this.chkUseCustomVsPalette.Name = "chkUseCustomVsPalette"; this.chkUseCustomVsPalette.Size = new System.Drawing.Size(202, 17); this.chkUseCustomVsPalette.TabIndex = 2; this.chkUseCustomVsPalette.Text = "Use this palette for VS System games"; this.chkUseCustomVsPalette.UseVisualStyleBackColor = true; // + // ctrlPaletteDisplay + // + this.ctrlPaletteDisplay.Location = new System.Drawing.Point(3, 3); + this.ctrlPaletteDisplay.Name = "ctrlPaletteDisplay"; + this.ctrlPaletteDisplay.Size = new System.Drawing.Size(338, 338); + this.ctrlPaletteDisplay.TabIndex = 3; + this.ctrlPaletteDisplay.ColorClick += new Mesen.GUI.Debugger.ctrlPaletteDisplay.PaletteClickHandler(this.ctrlPaletteDisplay_ColorClick); + // // tpgAdvanced // this.tpgAdvanced.Controls.Add(this.tableLayoutPanel9); @@ -1336,17 +1342,6 @@ namespace Mesen.GUI.Forms.Config this.mnuPaletteYuv.Text = "YUV v3 (by FirebrandX)"; this.mnuPaletteYuv.Click += new System.EventHandler(this.mnuPaletteYuv_Click); // - // chkShowColorIndexes - // - this.chkShowColorIndexes.AutoSize = true; - this.chkShowColorIndexes.Location = new System.Drawing.Point(3, 90); - this.chkShowColorIndexes.Name = "chkShowColorIndexes"; - this.chkShowColorIndexes.Size = new System.Drawing.Size(118, 17); - this.chkShowColorIndexes.TabIndex = 4; - this.chkShowColorIndexes.Text = "Show color indexes"; - this.chkShowColorIndexes.UseVisualStyleBackColor = true; - this.chkShowColorIndexes.CheckedChanged += new System.EventHandler(this.chkShowColorIndexes_CheckedChanged); - // // frmVideoConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1406,7 +1401,6 @@ namespace Mesen.GUI.Forms.Config this.tpgPalette.ResumeLayout(false); this.tableLayoutPanel3.ResumeLayout(false); this.tableLayoutPanel3.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.picPalette)).EndInit(); this.tableLayoutPanel2.ResumeLayout(false); this.tableLayoutPanel2.PerformLayout(); this.tpgAdvanced.ResumeLayout(false); @@ -1449,7 +1443,6 @@ namespace Mesen.GUI.Forms.Config private System.Windows.Forms.CheckBox chkUseHdPacks; private System.Windows.Forms.PictureBox picHdNesTooltip; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; - private System.Windows.Forms.PictureBox picPalette; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; private System.Windows.Forms.Button btnLoadPalFile; private System.Windows.Forms.ColorDialog colorDialog; @@ -1514,5 +1507,6 @@ namespace Mesen.GUI.Forms.Config private System.Windows.Forms.CheckBox chkUseCustomVsPalette; private System.Windows.Forms.CheckBox chkFullscreenForceIntegerScale; private System.Windows.Forms.CheckBox chkShowColorIndexes; + private Debugger.ctrlPaletteDisplay ctrlPaletteDisplay; } } \ No newline at end of file diff --git a/GUI.NET/Forms/Config/frmVideoConfig.cs b/GUI.NET/Forms/Config/frmVideoConfig.cs index 46829054..cd37315a 100644 --- a/GUI.NET/Forms/Config/frmVideoConfig.cs +++ b/GUI.NET/Forms/Config/frmVideoConfig.cs @@ -120,59 +120,18 @@ namespace Mesen.GUI.Forms.Config private void RefreshPalette() { - GCHandle handle = GCHandle.Alloc(_paletteData, GCHandleType.Pinned); - try { - Bitmap source = new Bitmap(16, 4, 16*4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject()); - Bitmap target = new Bitmap(336, 336); - - Font font = new Font(BaseControl.MonospaceFontFamily, BaseControl.DefaultFontSize - 2); - 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(42, 42); - g.DrawImageUnscaled(source, 0, 0); - g.DrawImageUnscaled(source, -8, 4); - - if(chkShowColorIndexes.Checked) { - g.ScaleTransform(1f/42, 1f/42); - using(Brush bg = new SolidBrush(Color.FromArgb(150, Color.LightGray))) { - for(int y = 0; y < 8; y++) { - for(int x = 0; x < 8; x++) { - int index = y * 16 + x; - if(y >= 4) { - index = (y - 4) * 16 + x + 8; - } - for(int i = -1; i <= 1; i++) { - for(int j = -1; j <= 1; j++) { - g.DrawString(index.ToString("X2"), font, bg, 42*x + 22+j, 42*y + 26+i); - } - } - g.DrawString(index.ToString("X2"), font, Brushes.Black, 42*x + 22, 42*y + 26); - } - } - } - } - } - this.picPalette.Image = target; - } finally { - handle.Free(); - } + this.ctrlPaletteDisplay.ShowColorIndexes = chkShowColorIndexes.Checked; + this.ctrlPaletteDisplay.PaletteData = _paletteData; } - private void picPalette_MouseDown(object sender, MouseEventArgs e) + private void ctrlPaletteDisplay_ColorClick(int colorIndex) { - int y = e.Y / 42 < 4 ? e.Y : (e.Y - 168); - int x = e.Y / 42 < 4 ? e.X : (e.X + 336); - - int offset = (x / 42) + (y / 42 * 16); - colorDialog.SolidColorOnly = true; colorDialog.AllowFullOpen = true; colorDialog.FullOpen = true; - colorDialog.Color = Color.FromArgb(_paletteData[offset]); - if(colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - _paletteData[offset] = colorDialog.Color.ToArgb(); + colorDialog.Color = Color.FromArgb(_paletteData[colorIndex]); + if(colorDialog.ShowDialog() == DialogResult.OK) { + _paletteData[colorIndex] = colorDialog.Color.ToArgb(); } RefreshPalette(); @@ -325,58 +284,57 @@ namespace Mesen.GUI.Forms.Config contextPaletteList.Show(btnSelectPalette.PointToScreen(new Point(0, btnSelectPalette.Height-1))); } + private void UpdatePalette(UInt32[] newPalette) + { + for(int i = 0; i < 64; i++) { + _paletteData[i] = (Int32)newPalette[i]; + } + RefreshPalette(); + } + private void mnuDefaultPalette_Click(object sender, EventArgs e) { - _paletteData = (Int32[])((object)(new UInt32[] { 0xFF666666, 0xFF002A88, 0xFF1412A7, 0xFF3B00A4, 0xFF5C007E, 0xFF6E0040, 0xFF6C0600, 0xFF561D00, 0xFF333500, 0xFF0B4800, 0xFF005200, 0xFF004F08, 0xFF00404D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFADADAD, 0xFF155FD9, 0xFF4240FF, 0xFF7527FE, 0xFFA01ACC, 0xFFB71E7B, 0xFFB53120, 0xFF994E00, 0xFF6B6D00, 0xFF388700, 0xFF0C9300, 0xFF008F32, 0xFF007C8D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFF64B0FF, 0xFF9290FF, 0xFFC676FF, 0xFFF36AFF, 0xFFFE6ECC, 0xFFFE8170, 0xFFEA9E22, 0xFFBCBE00, 0xFF88D800, 0xFF5CE430, 0xFF45E082, 0xFF48CDDE, 0xFF4F4F4F, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFFC0DFFF, 0xFFD3D2FF, 0xFFE8C8FF, 0xFFFBC2FF, 0xFFFEC4EA, 0xFFFECCC5, 0xFFF7D8A5, 0xFFE4E594, 0xFFCFEF96, 0xFFBDF4AB, 0xFFB3F3CC, 0xFFB5EBF2, 0xFFB8B8B8, 0xFF000000, 0xFF000000 })); - RefreshPalette(); + UpdatePalette(new UInt32[] { 0xFF666666, 0xFF002A88, 0xFF1412A7, 0xFF3B00A4, 0xFF5C007E, 0xFF6E0040, 0xFF6C0600, 0xFF561D00, 0xFF333500, 0xFF0B4800, 0xFF005200, 0xFF004F08, 0xFF00404D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFADADAD, 0xFF155FD9, 0xFF4240FF, 0xFF7527FE, 0xFFA01ACC, 0xFFB71E7B, 0xFFB53120, 0xFF994E00, 0xFF6B6D00, 0xFF388700, 0xFF0C9300, 0xFF008F32, 0xFF007C8D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFF64B0FF, 0xFF9290FF, 0xFFC676FF, 0xFFF36AFF, 0xFFFE6ECC, 0xFFFE8170, 0xFFEA9E22, 0xFFBCBE00, 0xFF88D800, 0xFF5CE430, 0xFF45E082, 0xFF48CDDE, 0xFF4F4F4F, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFFC0DFFF, 0xFFD3D2FF, 0xFFE8C8FF, 0xFFFBC2FF, 0xFFFEC4EA, 0xFFFECCC5, 0xFFF7D8A5, 0xFFE4E594, 0xFFCFEF96, 0xFFBDF4AB, 0xFFB3F3CC, 0xFFB5EBF2, 0xFFB8B8B8, 0xFF000000, 0xFF000000 }); } private void mnuPaletteUnsaturated_Click(object sender, EventArgs e) { - _paletteData = (Int32[])((object)(new UInt32[] { 0xFF6B6B6B, 0xFF001E87, 0xFF1F0B96, 0xFF3B0C87, 0xFF590D61, 0xFF5E0528, 0xFF551100, 0xFF461B00, 0xFF303200, 0xFF0A4800, 0xFF004E00, 0xFF004619, 0xFF003A58, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB2B2B2, 0xFF1A53D1, 0xFF4835EE, 0xFF7123EC, 0xFF9A1EB7, 0xFFA51E62, 0xFFA52D19, 0xFF874B00, 0xFF676900, 0xFF298400, 0xFF038B00, 0xFF008240, 0xFF007891, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF63ADFD, 0xFF908AFE, 0xFFB977FC, 0xFFE771FE, 0xFFF76FC9, 0xFFF5836A, 0xFFDD9C29, 0xFFBDB807, 0xFF84D107, 0xFF5BDC3B, 0xFF48D77D, 0xFF48CCCE, 0xFF555555, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFC4E3FE, 0xFFD7D5FE, 0xFFE6CDFE, 0xFFF9CAFE, 0xFFFEC9F0, 0xFFFED1C7, 0xFFF7DCAC, 0xFFE8E89C, 0xFFD1F29D, 0xFFBFF4B1, 0xFFB7F5CD, 0xFFB7F0EE, 0xFFBEBEBE, 0xFF000000, 0xFF000000 })); - RefreshPalette(); + UpdatePalette(new UInt32[] { 0xFF6B6B6B, 0xFF001E87, 0xFF1F0B96, 0xFF3B0C87, 0xFF590D61, 0xFF5E0528, 0xFF551100, 0xFF461B00, 0xFF303200, 0xFF0A4800, 0xFF004E00, 0xFF004619, 0xFF003A58, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB2B2B2, 0xFF1A53D1, 0xFF4835EE, 0xFF7123EC, 0xFF9A1EB7, 0xFFA51E62, 0xFFA52D19, 0xFF874B00, 0xFF676900, 0xFF298400, 0xFF038B00, 0xFF008240, 0xFF007891, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF63ADFD, 0xFF908AFE, 0xFFB977FC, 0xFFE771FE, 0xFFF76FC9, 0xFFF5836A, 0xFFDD9C29, 0xFFBDB807, 0xFF84D107, 0xFF5BDC3B, 0xFF48D77D, 0xFF48CCCE, 0xFF555555, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFC4E3FE, 0xFFD7D5FE, 0xFFE6CDFE, 0xFFF9CAFE, 0xFFFEC9F0, 0xFFFED1C7, 0xFFF7DCAC, 0xFFE8E89C, 0xFFD1F29D, 0xFFBFF4B1, 0xFFB7F5CD, 0xFFB7F0EE, 0xFFBEBEBE, 0xFF000000, 0xFF000000 }); } private void mnuPaletteYuv_Click(object sender, EventArgs e) { - _paletteData = (Int32[])((object)(new UInt32[] { 0xFF666666, 0xFF002A88, 0xFF1412A7, 0xFF3B00A4, 0xFF5C007E, 0xFF6E0040, 0xFF6C0700, 0xFF561D00, 0xFF333500, 0xFF0C4800, 0xFF005200, 0xFF004C18, 0xFF003E5B, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFADADAD, 0xFF155FD9, 0xFF4240FF, 0xFF7527FE, 0xFFA01ACC, 0xFFB71E7B, 0xFFB53120, 0xFF994E00, 0xFF6B6D00, 0xFF388700, 0xFF0D9300, 0xFF008C47, 0xFF007AA0, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF64B0FF, 0xFF9290FF, 0xFFC676FF, 0xFFF26AFF, 0xFFFF6ECC, 0xFFFF8170, 0xFFEA9E22, 0xFFBCBE00, 0xFF88D800, 0xFF5CE430, 0xFF45E082, 0xFF48CDDE, 0xFF4F4F4F, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFC0DFFF, 0xFFD3D2FF, 0xFFE8C8FF, 0xFFFAC2FF, 0xFFFFC4EA, 0xFFFFCCC5, 0xFFF7D8A5, 0xFFE4E594, 0xFFCFEF96, 0xFFBDF4AB, 0xFFB3F3CC, 0xFFB5EBF2, 0xFFB8B8B8, 0xFF000000, 0xFF000000 })); - RefreshPalette(); + UpdatePalette(new UInt32[] { 0xFF666666, 0xFF002A88, 0xFF1412A7, 0xFF3B00A4, 0xFF5C007E, 0xFF6E0040, 0xFF6C0700, 0xFF561D00, 0xFF333500, 0xFF0C4800, 0xFF005200, 0xFF004C18, 0xFF003E5B, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFADADAD, 0xFF155FD9, 0xFF4240FF, 0xFF7527FE, 0xFFA01ACC, 0xFFB71E7B, 0xFFB53120, 0xFF994E00, 0xFF6B6D00, 0xFF388700, 0xFF0D9300, 0xFF008C47, 0xFF007AA0, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF64B0FF, 0xFF9290FF, 0xFFC676FF, 0xFFF26AFF, 0xFFFF6ECC, 0xFFFF8170, 0xFFEA9E22, 0xFFBCBE00, 0xFF88D800, 0xFF5CE430, 0xFF45E082, 0xFF48CDDE, 0xFF4F4F4F, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFC0DFFF, 0xFFD3D2FF, 0xFFE8C8FF, 0xFFFAC2FF, 0xFFFFC4EA, 0xFFFFCCC5, 0xFFF7D8A5, 0xFFE4E594, 0xFFCFEF96, 0xFFBDF4AB, 0xFFB3F3CC, 0xFFB5EBF2, 0xFFB8B8B8, 0xFF000000, 0xFF000000 }); } private void mnuPaletteNestopiaRgb_Click(object sender, EventArgs e) { - _paletteData = (Int32[])((object)(new UInt32[] { 0xFF6D6D6D, 0xFF002492, 0xFF0000DB, 0xFF6D49DB, 0xFF92006D, 0xFFB6006D, 0xFFB62400, 0xFF924900, 0xFF6D4900, 0xFF244900, 0xFF006D24, 0xFF009200, 0xFF004949, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB6B6B6, 0xFF006DDB, 0xFF0049FF, 0xFF9200FF, 0xFFB600FF, 0xFFFF0092, 0xFFFF0000, 0xFFDB6D00, 0xFF926D00, 0xFF249200, 0xFF009200, 0xFF00B66D, 0xFF009292, 0xFF242424, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF6DB6FF, 0xFF9292FF, 0xFFDB6DFF, 0xFFFF00FF, 0xFFFF6DFF, 0xFFFF9200, 0xFFFFB600, 0xFFDBDB00, 0xFF6DDB00, 0xFF00FF00, 0xFF49FFDB, 0xFF00FFFF, 0xFF494949, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFB6DBFF, 0xFFDBB6FF, 0xFFFFB6FF, 0xFFFF92FF, 0xFFFFB6B6, 0xFFFFDB92, 0xFFFFFF49, 0xFFFFFF6D, 0xFFB6FF49, 0xFF92FF6D, 0xFF49FFDB, 0xFF92DBFF, 0xFF929292, 0xFF000000, 0xFF000000 })); - RefreshPalette(); + UpdatePalette(new UInt32[] { 0xFF6D6D6D, 0xFF002492, 0xFF0000DB, 0xFF6D49DB, 0xFF92006D, 0xFFB6006D, 0xFFB62400, 0xFF924900, 0xFF6D4900, 0xFF244900, 0xFF006D24, 0xFF009200, 0xFF004949, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB6B6B6, 0xFF006DDB, 0xFF0049FF, 0xFF9200FF, 0xFFB600FF, 0xFFFF0092, 0xFFFF0000, 0xFFDB6D00, 0xFF926D00, 0xFF249200, 0xFF009200, 0xFF00B66D, 0xFF009292, 0xFF242424, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF6DB6FF, 0xFF9292FF, 0xFFDB6DFF, 0xFFFF00FF, 0xFFFF6DFF, 0xFFFF9200, 0xFFFFB600, 0xFFDBDB00, 0xFF6DDB00, 0xFF00FF00, 0xFF49FFDB, 0xFF00FFFF, 0xFF494949, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFB6DBFF, 0xFFDBB6FF, 0xFFFFB6FF, 0xFFFF92FF, 0xFFFFB6B6, 0xFFFFDB92, 0xFFFFFF49, 0xFFFFFF6D, 0xFFB6FF49, 0xFF92FF6D, 0xFF49FFDB, 0xFF92DBFF, 0xFF929292, 0xFF000000, 0xFF000000 }); } private void mnuPaletteCompositeDirect_Click(object sender, EventArgs e) { - _paletteData = (Int32[])((object)(new UInt32[] { 0xFF656565, 0xFF00127D, 0xFF18008E, 0xFF360082, 0xFF56005D, 0xFF5A0018, 0xFF4F0500, 0xFF381900, 0xFF1D3100, 0xFF003D00, 0xFF004100, 0xFF003B17, 0xFF002E55, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFAFAFAF, 0xFF194EC8, 0xFF472FE3, 0xFF6B1FD7, 0xFF931BAE, 0xFF9E1A5E, 0xFF993200, 0xFF7B4B00, 0xFF5B6700, 0xFF267A00, 0xFF008200, 0xFF007A3E, 0xFF006E8A, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF64A9FF, 0xFF8E89FF, 0xFFB676FF, 0xFFE06FFF, 0xFFEF6CC4, 0xFFF0806A, 0xFFD8982C, 0xFFB9B40A, 0xFF83CB0C, 0xFF5BD63F, 0xFF4AD17E, 0xFF4DC7CB, 0xFF4C4C4C, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFC7E5FF, 0xFFD9D9FF, 0xFFE9D1FF, 0xFFF9CEFF, 0xFFFFCCF1, 0xFFFFD4CB, 0xFFF8DFB1, 0xFFEDEAA4, 0xFFD6F4A4, 0xFFC5F8B8, 0xFFBEF6D3, 0xFFBFF1F1, 0xFFB9B9B9, 0xFF000000, 0xFF000000 })); - RefreshPalette(); + UpdatePalette(new UInt32[] { 0xFF656565, 0xFF00127D, 0xFF18008E, 0xFF360082, 0xFF56005D, 0xFF5A0018, 0xFF4F0500, 0xFF381900, 0xFF1D3100, 0xFF003D00, 0xFF004100, 0xFF003B17, 0xFF002E55, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFAFAFAF, 0xFF194EC8, 0xFF472FE3, 0xFF6B1FD7, 0xFF931BAE, 0xFF9E1A5E, 0xFF993200, 0xFF7B4B00, 0xFF5B6700, 0xFF267A00, 0xFF008200, 0xFF007A3E, 0xFF006E8A, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF64A9FF, 0xFF8E89FF, 0xFFB676FF, 0xFFE06FFF, 0xFFEF6CC4, 0xFFF0806A, 0xFFD8982C, 0xFFB9B40A, 0xFF83CB0C, 0xFF5BD63F, 0xFF4AD17E, 0xFF4DC7CB, 0xFF4C4C4C, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFC7E5FF, 0xFFD9D9FF, 0xFFE9D1FF, 0xFFF9CEFF, 0xFFFFCCF1, 0xFFFFD4CB, 0xFFF8DFB1, 0xFFEDEAA4, 0xFFD6F4A4, 0xFFC5F8B8, 0xFFBEF6D3, 0xFFBFF1F1, 0xFFB9B9B9, 0xFF000000, 0xFF000000 }); } private void mnuPaletteNesClassic_Click(object sender, EventArgs e) { - _paletteData = (Int32[])((object)(new UInt32[] { 0xFF60615F, 0xFF000083, 0xFF1D0195, 0xFF340875, 0xFF51055E, 0xFF56000F, 0xFF4C0700, 0xFF372308, 0xFF203A0B, 0xFF0F4B0E, 0xFF194C16, 0xFF02421E, 0xFF023154, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFA9AAA8, 0xFF104BBF, 0xFF4712D8, 0xFF6300CA, 0xFF8800A9, 0xFF930B46, 0xFF8A2D04, 0xFF6F5206, 0xFF5C7114, 0xFF1B8D12, 0xFF199509, 0xFF178448, 0xFF206B8E, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFBFBFB, 0xFF6699F8, 0xFF8974F9, 0xFFAB58F8, 0xFFD557EF, 0xFFDE5FA9, 0xFFDC7F59, 0xFFC7A224, 0xFFA7BE03, 0xFF75D703, 0xFF60E34F, 0xFF3CD68D, 0xFF56C9CC, 0xFF414240, 0xFF000000, 0xFF000000, 0xFFFBFBFB, 0xFFBED4FA, 0xFFC9C7F9, 0xFFD7BEFA, 0xFFE8B8F9, 0xFFF5BAE5, 0xFFF3CAC2, 0xFFDFCDA7, 0xFFD9E09C, 0xFFC9EB9E, 0xFFC0EDB8, 0xFFB5F4C7, 0xFFB9EAE9, 0xFFABABAB, 0xFF000000, 0xFF000000 })); - RefreshPalette(); + UpdatePalette(new UInt32[] { 0xFF60615F, 0xFF000083, 0xFF1D0195, 0xFF340875, 0xFF51055E, 0xFF56000F, 0xFF4C0700, 0xFF372308, 0xFF203A0B, 0xFF0F4B0E, 0xFF194C16, 0xFF02421E, 0xFF023154, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFA9AAA8, 0xFF104BBF, 0xFF4712D8, 0xFF6300CA, 0xFF8800A9, 0xFF930B46, 0xFF8A2D04, 0xFF6F5206, 0xFF5C7114, 0xFF1B8D12, 0xFF199509, 0xFF178448, 0xFF206B8E, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFBFBFB, 0xFF6699F8, 0xFF8974F9, 0xFFAB58F8, 0xFFD557EF, 0xFFDE5FA9, 0xFFDC7F59, 0xFFC7A224, 0xFFA7BE03, 0xFF75D703, 0xFF60E34F, 0xFF3CD68D, 0xFF56C9CC, 0xFF414240, 0xFF000000, 0xFF000000, 0xFFFBFBFB, 0xFFBED4FA, 0xFFC9C7F9, 0xFFD7BEFA, 0xFFE8B8F9, 0xFFF5BAE5, 0xFFF3CAC2, 0xFFDFCDA7, 0xFFD9E09C, 0xFFC9EB9E, 0xFFC0EDB8, 0xFFB5F4C7, 0xFFB9EAE9, 0xFFABABAB, 0xFF000000, 0xFF000000 }); } private void mnuPaletteOriginalHardware_Click(object sender, EventArgs e) { - _paletteData = (Int32[])((object)(new UInt32[] { 0xFF6A6D6A, 0xFF00127D, 0xFF1E008A, 0xFF3B007D, 0xFF56005D, 0xFF5A0018, 0xFF4F0D00, 0xFF381E00, 0xFF203100, 0xFF003D00, 0xFF004000, 0xFF003B1E, 0xFF002E55, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB9BCB9, 0xFF194EC8, 0xFF472FE3, 0xFF751FD7, 0xFF931EAD, 0xFF9E245E, 0xFF963800, 0xFF7B5000, 0xFF5B6700, 0xFF267A00, 0xFF007F00, 0xFF007842, 0xFF006E8A, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF69AEFF, 0xFF9798FF, 0xFFB687FF, 0xFFE278FF, 0xFFF279C7, 0xFFF58F6F, 0xFFDDA932, 0xFFBCB70D, 0xFF88D015, 0xFF60DB49, 0xFF4FD687, 0xFF50CACE, 0xFF515451, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFCCEAFF, 0xFFDEE2FF, 0xFFEEDAFF, 0xFFFAD7FD, 0xFFFDD7F6, 0xFFFDDCD0, 0xFFFAE8B6, 0xFFF2F1A9, 0xFFDBFBA9, 0xFFCAFFBD, 0xFFC3FBD8, 0xFFC4F6F6, 0xFFBEC1BE, 0xFF000000, 0xFF000000 })); - RefreshPalette(); + UpdatePalette(new UInt32[] { 0xFF6A6D6A, 0xFF00127D, 0xFF1E008A, 0xFF3B007D, 0xFF56005D, 0xFF5A0018, 0xFF4F0D00, 0xFF381E00, 0xFF203100, 0xFF003D00, 0xFF004000, 0xFF003B1E, 0xFF002E55, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB9BCB9, 0xFF194EC8, 0xFF472FE3, 0xFF751FD7, 0xFF931EAD, 0xFF9E245E, 0xFF963800, 0xFF7B5000, 0xFF5B6700, 0xFF267A00, 0xFF007F00, 0xFF007842, 0xFF006E8A, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF69AEFF, 0xFF9798FF, 0xFFB687FF, 0xFFE278FF, 0xFFF279C7, 0xFFF58F6F, 0xFFDDA932, 0xFFBCB70D, 0xFF88D015, 0xFF60DB49, 0xFF4FD687, 0xFF50CACE, 0xFF515451, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFCCEAFF, 0xFFDEE2FF, 0xFFEEDAFF, 0xFFFAD7FD, 0xFFFDD7F6, 0xFFFDDCD0, 0xFFFAE8B6, 0xFFF2F1A9, 0xFFDBFBA9, 0xFFCAFFBD, 0xFFC3FBD8, 0xFFC4F6F6, 0xFFBEC1BE, 0xFF000000, 0xFF000000 }); } private void mnuPalettePvmStyle_Click(object sender, EventArgs e) { - _paletteData = (Int32[])((object)(new UInt32[] { 0xFF696964, 0xFF001774, 0xFF28007D, 0xFF3E006D, 0xFF560057, 0xFF5E0013, 0xFF531A00, 0xFF3B2400, 0xFF2A3000, 0xFF143A00, 0xFF003F00, 0xFF003B1E, 0xFF003050, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB9B9B4, 0xFF1453B9, 0xFF4D2CDA, 0xFF7A1EC8, 0xFF98189C, 0xFF9D2344, 0xFFA03E00, 0xFF8D5500, 0xFF656D00, 0xFF2C7900, 0xFF008100, 0xFF007D42, 0xFF00788A, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF69A8FF, 0xFF9A96FF, 0xFFC28AFA, 0xFFEA7DFA, 0xFFF387B4, 0xFFF1986C, 0xFFE6B327, 0xFFD7C805, 0xFF90DF07, 0xFF64E53C, 0xFF45E27D, 0xFF48D5D9, 0xFF4B4B46, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFD2EAFF, 0xFFE2E2FF, 0xFFF2D8FF, 0xFFF8D2FF, 0xFFF8D9EA, 0xFFFADEB9, 0xFFF9E89B, 0xFFF3F28C, 0xFFD3FA91, 0xFFB8FCA8, 0xFFAEFACA, 0xFFCAF3F3, 0xFFBEBEB9, 0xFF000000, 0xFF000000 })); - RefreshPalette(); + UpdatePalette(new UInt32[] { 0xFF696964, 0xFF001774, 0xFF28007D, 0xFF3E006D, 0xFF560057, 0xFF5E0013, 0xFF531A00, 0xFF3B2400, 0xFF2A3000, 0xFF143A00, 0xFF003F00, 0xFF003B1E, 0xFF003050, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB9B9B4, 0xFF1453B9, 0xFF4D2CDA, 0xFF7A1EC8, 0xFF98189C, 0xFF9D2344, 0xFFA03E00, 0xFF8D5500, 0xFF656D00, 0xFF2C7900, 0xFF008100, 0xFF007D42, 0xFF00788A, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF69A8FF, 0xFF9A96FF, 0xFFC28AFA, 0xFFEA7DFA, 0xFFF387B4, 0xFFF1986C, 0xFFE6B327, 0xFFD7C805, 0xFF90DF07, 0xFF64E53C, 0xFF45E27D, 0xFF48D5D9, 0xFF4B4B46, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFD2EAFF, 0xFFE2E2FF, 0xFFF2D8FF, 0xFFF8D2FF, 0xFFF8D9EA, 0xFFFADEB9, 0xFFF9E89B, 0xFFF3F28C, 0xFFD3FA91, 0xFFB8FCA8, 0xFFAEFACA, 0xFFCAF3F3, 0xFFBEBEB9, 0xFF000000, 0xFF000000 }); } private void mnuPaletteSonyCxa2025As_Click(object sender, EventArgs e) { - _paletteData = (Int32[])((object)(new UInt32[] { 0xFF585858, 0xFF00238C, 0xFF00139B, 0xFF2D0585, 0xFF5D0052, 0xFF7A0017, 0xFF7A0800, 0xFF5F1800, 0xFF352A00, 0xFF093900, 0xFF003F00, 0xFF003C22, 0xFF00325D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFA1A1A1, 0xFF0053EE, 0xFF153CFE, 0xFF6028E4, 0xFFA91D98, 0xFFD41E41, 0xFFD22C00, 0xFFAA4400, 0xFF6C5E00, 0xFF2D7300, 0xFF007D06, 0xFF007852, 0xFF0069A9, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF1FA5FE, 0xFF5E89FE, 0xFFB572FE, 0xFFFE65F6, 0xFFFE6790, 0xFFFE773C, 0xFFFE9308, 0xFFC4B200, 0xFF79CA10, 0xFF3AD54A, 0xFF11D1A4, 0xFF06BFFE, 0xFF424242, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFA0D9FE, 0xFFBDCCFE, 0xFFE1C2FE, 0xFFFEBCFB, 0xFFFEBDD0, 0xFFFEC5A9, 0xFFFED18E, 0xFFE9DE86, 0xFFC7E992, 0xFFA8EEB0, 0xFF95ECD9, 0xFF91E4FE, 0xFFACACAC, 0xFF000000, 0xFF000000 })); - RefreshPalette(); + UpdatePalette(new UInt32[] { 0xFF585858, 0xFF00238C, 0xFF00139B, 0xFF2D0585, 0xFF5D0052, 0xFF7A0017, 0xFF7A0800, 0xFF5F1800, 0xFF352A00, 0xFF093900, 0xFF003F00, 0xFF003C22, 0xFF00325D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFA1A1A1, 0xFF0053EE, 0xFF153CFE, 0xFF6028E4, 0xFFA91D98, 0xFFD41E41, 0xFFD22C00, 0xFFAA4400, 0xFF6C5E00, 0xFF2D7300, 0xFF007D06, 0xFF007852, 0xFF0069A9, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF1FA5FE, 0xFF5E89FE, 0xFFB572FE, 0xFFFE65F6, 0xFFFE6790, 0xFFFE773C, 0xFFFE9308, 0xFFC4B200, 0xFF79CA10, 0xFF3AD54A, 0xFF11D1A4, 0xFF06BFFE, 0xFF424242, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFA0D9FE, 0xFFBDCCFE, 0xFFE1C2FE, 0xFFFEBCFB, 0xFFFEBDD0, 0xFFFEC5A9, 0xFFFED18E, 0xFFE9DE86, 0xFFC7E992, 0xFFA8EEB0, 0xFF95ECD9, 0xFF91E4FE, 0xFFACACAC, 0xFF000000, 0xFF000000 }); } private void contextPaletteList_Opening(object sender, CancelEventArgs e) diff --git a/GUI.NET/Forms/GraphicsExtensions.cs b/GUI.NET/Forms/GraphicsExtensions.cs new file mode 100644 index 00000000..234da6f6 --- /dev/null +++ b/GUI.NET/Forms/GraphicsExtensions.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace Mesen.GUI.Forms +{ + public static class GraphicsExtensions + { + public static void DrawOutlinedString(this Graphics g, string text, Font font, Brush foreColor, Brush backColor, int x, int y) + { + for(int i = -1; i <= 1; i++) { + for(int j = -1; j <= 1; j++) { + g.DrawString(text, font, backColor, x+j, y+i); + } + } + g.DrawString(text, font, foreColor, x, y); + } + } + +} \ No newline at end of file diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj index 4d9de867..d98d21ec 100644 --- a/GUI.NET/GUI.NET.csproj +++ b/GUI.NET/GUI.NET.csproj @@ -388,6 +388,12 @@ ctrlWatch.cs + + UserControl + + + ctrlPaletteDisplay.cs + Form @@ -461,6 +467,12 @@ frmPpuViewer.cs + + Form + + + frmSelectColor.cs + Form @@ -694,6 +706,7 @@ frmUpdatePrompt.cs + Form @@ -740,7 +753,6 @@ - @@ -820,6 +832,9 @@ ctrlWatch.cs + + ctrlPaletteDisplay.cs + frmAssembler.cs @@ -856,6 +871,9 @@ frmPpuViewer.cs + + frmSelectColor.cs + frmTraceLogger.cs @@ -1158,4 +1176,4 @@ call DependencyPacker.exe --> - + \ No newline at end of file