NES PPU - Palette Viewer - show details on mouse over. Note: value is currently messed up, due to an implementation flaw in the Palette object

This commit is contained in:
andres.delikat 2011-03-09 03:22:38 +00:00
parent def79375dd
commit ea21d73ed8
3 changed files with 95 additions and 5 deletions

View File

@ -31,14 +31,19 @@
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.PalettesGroup = new System.Windows.Forms.GroupBox();
this.PaletteView = new BizHawk.MultiClient.PaletteViewer();
this.DetailsBox = new System.Windows.Forms.GroupBox();
this.SectionLabel = new System.Windows.Forms.Label();
this.AddressLabel = new System.Windows.Forms.Label();
this.ValueLabel = new System.Windows.Forms.Label();
this.PalettesGroup.SuspendLayout();
this.DetailsBox.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(12, 26);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(415, 199);
this.groupBox1.Size = new System.Drawing.Size(281, 199);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Pattern Tables";
@ -48,7 +53,7 @@
this.PalettesGroup.Controls.Add(this.PaletteView);
this.PalettesGroup.Location = new System.Drawing.Point(12, 262);
this.PalettesGroup.Name = "PalettesGroup";
this.PalettesGroup.Size = new System.Drawing.Size(415, 84);
this.PalettesGroup.Size = new System.Drawing.Size(281, 66);
this.PalettesGroup.TabIndex = 1;
this.PalettesGroup.TabStop = false;
this.PalettesGroup.Text = "Palettes";
@ -56,16 +61,59 @@
// PaletteView
//
this.PaletteView.BackColor = System.Drawing.Color.White;
this.PaletteView.Location = new System.Drawing.Point(69, 35);
this.PaletteView.Location = new System.Drawing.Point(6, 19);
this.PaletteView.Name = "PaletteView";
this.PaletteView.Size = new System.Drawing.Size(257, 34);
this.PaletteView.TabIndex = 0;
this.PaletteView.MouseLeave += new System.EventHandler(this.PaletteView_MouseLeave);
this.PaletteView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.PaletteView_MouseMove);
this.PaletteView.MouseEnter += new System.EventHandler(this.PaletteView_MouseEnter);
//
// DetailsBox
//
this.DetailsBox.Controls.Add(this.ValueLabel);
this.DetailsBox.Controls.Add(this.AddressLabel);
this.DetailsBox.Controls.Add(this.SectionLabel);
this.DetailsBox.Location = new System.Drawing.Point(300, 26);
this.DetailsBox.Name = "DetailsBox";
this.DetailsBox.Size = new System.Drawing.Size(177, 129);
this.DetailsBox.TabIndex = 2;
this.DetailsBox.TabStop = false;
this.DetailsBox.Text = "Details";
//
// SectionLabel
//
this.SectionLabel.AutoSize = true;
this.SectionLabel.Location = new System.Drawing.Point(6, 26);
this.SectionLabel.Name = "SectionLabel";
this.SectionLabel.Size = new System.Drawing.Size(35, 13);
this.SectionLabel.TabIndex = 0;
this.SectionLabel.Text = "label1";
//
// AddressLabel
//
this.AddressLabel.AutoSize = true;
this.AddressLabel.Location = new System.Drawing.Point(6, 49);
this.AddressLabel.Name = "AddressLabel";
this.AddressLabel.Size = new System.Drawing.Size(35, 13);
this.AddressLabel.TabIndex = 1;
this.AddressLabel.Text = "label1";
//
// ValueLabel
//
this.ValueLabel.AutoSize = true;
this.ValueLabel.Location = new System.Drawing.Point(6, 73);
this.ValueLabel.Name = "ValueLabel";
this.ValueLabel.Size = new System.Drawing.Size(35, 13);
this.ValueLabel.TabIndex = 2;
this.ValueLabel.Text = "label1";
//
// NESPPU
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(443, 359);
this.ClientSize = new System.Drawing.Size(504, 359);
this.Controls.Add(this.DetailsBox);
this.Controls.Add(this.PalettesGroup);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
@ -73,6 +121,8 @@
this.Text = "PPU Viewer";
this.Load += new System.EventHandler(this.NESPPU_Load);
this.PalettesGroup.ResumeLayout(false);
this.DetailsBox.ResumeLayout(false);
this.DetailsBox.PerformLayout();
this.ResumeLayout(false);
}
@ -82,5 +132,9 @@
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox PalettesGroup;
private PaletteViewer PaletteView;
private System.Windows.Forms.GroupBox DetailsBox;
private System.Windows.Forms.Label ValueLabel;
private System.Windows.Forms.Label AddressLabel;
private System.Windows.Forms.Label SectionLabel;
}
}

View File

@ -6,6 +6,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using BizHawk.Emulation.Consoles.Nintendo;
namespace BizHawk.MultiClient
@ -59,6 +60,41 @@ namespace BizHawk.MultiClient
{
LoadConfigSettings();
Nes = Global.Emulator as NES;
ClearDetails();
}
private void ClearDetails()
{
SectionLabel.Text = "";
AddressLabel.Text = "";
ValueLabel.Text = "";
//TODO: more info labels
}
private void PaletteView_MouseLeave(object sender, EventArgs e)
{
ClearDetails();
}
private void PaletteView_MouseEnter(object sender, EventArgs e)
{
SectionLabel.Text = "Section: Palette";
}
private void PaletteView_MouseMove(object sender, MouseEventArgs e)
{
int baseAddr = 0x3F00;
if (e.Y > 16)
baseAddr += 16;
int column = (e.X - PaletteView.Location.X) / 16;
int addr = column + baseAddr;
AddressLabel.Text = "Address: 0x" + String.Format("{0:X4}", addr, NumberStyles.HexNumber);
int val;
if (baseAddr == 0x3F00)
val = PaletteView.bgPalettes[column].GetValue();
else
val = PaletteView.spritePalettes[column].GetValue();
ValueLabel.Text = "Color: 0x" + String.Format("{0:X2}", val, NumberStyles.HexNumber);
}
}
}

View File

@ -33,7 +33,7 @@ namespace BizHawk.MultiClient
{
value = val | (int)0xFF000000;
}
color = Color.FromArgb(value);
color = Color.FromArgb(value); //TODO: value should be unprocessed! then do all calculations on this line
}
public Color GetColor()