NES PPU - some ground work for Pattern Viewer

This commit is contained in:
andres.delikat 2011-03-10 14:51:21 +00:00
parent 33a9ccf1f5
commit e8b8ab533d
3 changed files with 58 additions and 27 deletions

View File

@ -35,12 +35,12 @@
this.ValueLabel = new System.Windows.Forms.Label();
this.AddressLabel = new System.Windows.Forms.Label();
this.SectionLabel = new System.Windows.Forms.Label();
this.PaletteView = new BizHawk.MultiClient.PaletteViewer();
this.PatternView = new BizHawk.MultiClient.PatternViewer();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton();
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.PaletteView = new BizHawk.MultiClient.PaletteViewer();
this.PatternView = new BizHawk.MultiClient.PatternViewer();
this.groupBox1.SuspendLayout();
this.PalettesGroup.SuspendLayout();
this.DetailsBox.SuspendLayout();
@ -52,7 +52,7 @@
this.groupBox1.Controls.Add(this.PatternView);
this.groupBox1.Location = new System.Drawing.Point(12, 26);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(281, 199);
this.groupBox1.Size = new System.Drawing.Size(272, 165);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Pattern Tables";
@ -60,9 +60,9 @@
// PalettesGroup
//
this.PalettesGroup.Controls.Add(this.PaletteView);
this.PalettesGroup.Location = new System.Drawing.Point(12, 262);
this.PalettesGroup.Location = new System.Drawing.Point(12, 214);
this.PalettesGroup.Name = "PalettesGroup";
this.PalettesGroup.Size = new System.Drawing.Size(281, 66);
this.PalettesGroup.Size = new System.Drawing.Size(272, 65);
this.PalettesGroup.TabIndex = 1;
this.PalettesGroup.TabStop = false;
this.PalettesGroup.Text = "Palettes";
@ -72,7 +72,7 @@
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.Location = new System.Drawing.Point(299, 28);
this.DetailsBox.Name = "DetailsBox";
this.DetailsBox.Size = new System.Drawing.Size(177, 129);
this.DetailsBox.TabIndex = 2;
@ -106,25 +106,6 @@
this.SectionLabel.TabIndex = 0;
this.SectionLabel.Text = "label1";
//
// PaletteView
//
this.PaletteView.BackColor = System.Drawing.Color.White;
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);
//
// PatternView
//
this.PatternView.BackColor = System.Drawing.Color.White;
this.PatternView.Location = new System.Drawing.Point(17, 26);
this.PatternView.Name = "PatternView";
this.PatternView.Size = new System.Drawing.Size(35, 13);
this.PatternView.TabIndex = 0;
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -162,6 +143,25 @@
this.saveWindowPositionToolStripMenuItem.Text = "Save window position";
this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
//
// PaletteView
//
this.PaletteView.BackColor = System.Drawing.Color.White;
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);
//
// PatternView
//
this.PatternView.BackColor = System.Drawing.Color.White;
this.PatternView.Location = new System.Drawing.Point(6, 19);
this.PatternView.Name = "PatternView";
this.PatternView.Size = new System.Drawing.Size(256, 128);
this.PatternView.TabIndex = 0;
//
// NESPPU
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@ -48,12 +48,30 @@ namespace BizHawk.MultiClient
{
if (!(Global.Emulator is NES)) return;
if (!this.IsHandleCreated || this.IsDisposed) return;
//Pattern Viewer
for (int x = 0; x < 16; x++)
{
PaletteView.bgPalettes[x].SetValue(Nes.ConvertColor(Nes.ppu.PALRAM[PaletteView.bgPalettes[x].address]));
PaletteView.spritePalettes[x].SetValue(Nes.ppu.PALRAM[PaletteView.spritePalettes[x].address]);
}
PaletteView.Refresh();
//Pattern Viewer
for (int i = 0; i < 16; i++)
{
for (int j = 0; j < 16; j++)
{
for (int x = 0; x < 8; x++)
{
for (int y = 0; y < 8; y++)
{
PatternView.pattern.SetPixel(x + (i*8), y + (j*8), Color.White);
}
}
}
}
PatternView.Refresh();
}
private void NESPPU_Load(object sender, EventArgs e)

View File

@ -10,15 +10,28 @@ namespace BizHawk.MultiClient
{
public class PatternViewer : Control
{
Size pSize;
public Bitmap pattern;
public PatternViewer()
{
pSize = new Size(256, 128);
pattern = new Bitmap(pSize.Width, pSize.Height);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.Size = new Size(128, 32);
this.Size = pSize;
this.BackColor = Color.White;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.PatternViewer_Paint);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PatternViewer_KeyDown);
for (int x = 0; x < pattern.Size.Width; x++)
{
for (int y = 0; y < pattern.Size.Height; y++)
{
pattern.SetPixel(x, y, Color.Black);
}
}
}
private void PatternViewer_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { }
@ -27,7 +40,7 @@ namespace BizHawk.MultiClient
{
unchecked
{
g.DrawImage(pattern, 1, 1);
}
}