NESPPU - speedups to palette viewer
This commit is contained in:
parent
e75052923a
commit
278a9486b6
|
@ -70,10 +70,13 @@ namespace BizHawk.MultiClient
|
||||||
//Pattern Viewer
|
//Pattern Viewer
|
||||||
for (int x = 0; x < 16; x++)
|
for (int x = 0; x < 16; x++)
|
||||||
{
|
{
|
||||||
|
PaletteView.bgPalettesPrev[x] = new PaletteViewer.Palette(PaletteView.bgPalettes[x]);
|
||||||
|
PaletteView.spritePalettesPrev[x] = new PaletteViewer.Palette(PaletteView.spritePalettes[x]);
|
||||||
PaletteView.bgPalettes[x].SetValue(Nes.LookupColor(Nes.ppu.PALRAM[PaletteView.bgPalettes[x].address]));
|
PaletteView.bgPalettes[x].SetValue(Nes.LookupColor(Nes.ppu.PALRAM[PaletteView.bgPalettes[x].address]));
|
||||||
PaletteView.spritePalettes[x].SetValue(Nes.LookupColor(Nes.ppu.PALRAM[PaletteView.spritePalettes[x].address]));
|
PaletteView.spritePalettes[x].SetValue(Nes.LookupColor(Nes.ppu.PALRAM[PaletteView.spritePalettes[x].address]));
|
||||||
}
|
}
|
||||||
PaletteView.Refresh();
|
if (PaletteView.HasChanged())
|
||||||
|
PaletteView.Refresh();
|
||||||
|
|
||||||
//Pattern Viewer
|
//Pattern Viewer
|
||||||
int b0 = 0;
|
int b0 = 0;
|
||||||
|
@ -116,7 +119,7 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PatternView.pattern.UnlockBits(bmpdata);
|
PatternView.pattern.UnlockBits(bmpdata);
|
||||||
PatternView.Refresh();
|
//PatternView.Refresh();
|
||||||
/*
|
/*
|
||||||
int SpriteNum, TileNum, Attr, MemAddr;
|
int SpriteNum, TileNum, Attr, MemAddr;
|
||||||
|
|
||||||
|
|
|
@ -8,84 +8,104 @@ using System.Globalization;
|
||||||
|
|
||||||
namespace BizHawk.MultiClient
|
namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
public class PaletteViewer : Control
|
public class PaletteViewer : Control
|
||||||
{
|
{
|
||||||
public class Palette
|
public class Palette
|
||||||
{
|
{
|
||||||
public int address { get; set; }
|
public int address { get; set; }
|
||||||
private int value { get; set; }
|
private int value { get; set; }
|
||||||
private Color color;
|
private Color color;
|
||||||
|
|
||||||
public Palette(int Address)
|
public Palette(int Address)
|
||||||
{
|
{
|
||||||
address = Address;
|
address = Address;
|
||||||
value = -1;
|
value = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetValue()
|
public Palette(Palette p)
|
||||||
{
|
{
|
||||||
return value;
|
address = p.address;
|
||||||
}
|
value = p.value;
|
||||||
|
color = p.color;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetValue(int val)
|
public int GetValue()
|
||||||
{
|
{
|
||||||
unchecked
|
return value;
|
||||||
{
|
}
|
||||||
|
|
||||||
|
public void SetValue(int val)
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
value = val;
|
value = val;
|
||||||
}
|
}
|
||||||
color = Color.FromArgb(value); //TODO: value should be unprocessed! then do all calculations on this line
|
color = Color.FromArgb(value); //TODO: value should be unprocessed! then do all calculations on this line
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetColor()
|
public Color GetColor()
|
||||||
{
|
{
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Palette[] bgPalettes = new Palette[16];
|
public Palette[] bgPalettes = new Palette[16];
|
||||||
public Palette[] spritePalettes = new Palette[16];
|
public Palette[] spritePalettes = new Palette[16];
|
||||||
|
|
||||||
public PaletteViewer()
|
|
||||||
{
|
|
||||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
||||||
SetStyle(ControlStyles.UserPaint, true);
|
|
||||||
SetStyle(ControlStyles.DoubleBuffer, true);
|
|
||||||
this.Size = new Size(128, 32);
|
|
||||||
this.BackColor = Color.White;
|
|
||||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.PaletteViewer_Paint);
|
|
||||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PaletteViewer_KeyDown);
|
|
||||||
|
|
||||||
for (int x = 0; x < 16; x++)
|
public Palette[] bgPalettesPrev = new Palette[16];
|
||||||
{
|
public Palette[] spritePalettesPrev = new Palette[16];
|
||||||
bgPalettes[x] = new Palette(x);
|
|
||||||
spritePalettes[x] = new Palette(x+16);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
public PaletteViewer()
|
||||||
|
{
|
||||||
|
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||||
|
SetStyle(ControlStyles.UserPaint, true);
|
||||||
|
SetStyle(ControlStyles.DoubleBuffer, true);
|
||||||
|
this.Size = new Size(128, 32);
|
||||||
|
this.BackColor = Color.White;
|
||||||
|
this.Paint += new System.Windows.Forms.PaintEventHandler(this.PaletteViewer_Paint);
|
||||||
|
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PaletteViewer_KeyDown);
|
||||||
|
|
||||||
private void PaletteViewer_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { }
|
for (int x = 0; x < 16; x++)
|
||||||
|
{
|
||||||
private void Display(Graphics g)
|
bgPalettes[x] = new Palette(x);
|
||||||
{
|
spritePalettes[x] = new Palette(x + 16);
|
||||||
unchecked
|
}
|
||||||
{
|
|
||||||
Rectangle rect;
|
|
||||||
for (int x = 0; x < 16; x++)
|
|
||||||
{
|
|
||||||
rect = new Rectangle(new Point(x * 16, 1), new Size(16, 16));
|
|
||||||
g.FillRectangle(new SolidBrush(bgPalettes[x].GetColor()), rect);
|
|
||||||
}
|
|
||||||
for (int x = 0; x < 16; x++)
|
|
||||||
{
|
|
||||||
rect = new Rectangle(new Point(x * 16, 17), new Size(16, 16));
|
|
||||||
g.FillRectangle(new SolidBrush(spritePalettes[x].GetColor()), rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PaletteViewer_Paint(object sender, PaintEventArgs e)
|
}
|
||||||
{
|
|
||||||
Display(e.Graphics);
|
private void PaletteViewer_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { }
|
||||||
}
|
|
||||||
}
|
private void PaletteViewer_Paint(object sender, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
Rectangle rect;
|
||||||
|
for (int x = 0; x < 16; x++)
|
||||||
|
{
|
||||||
|
if (bgPalettes[x] != bgPalettesPrev[x])
|
||||||
|
{
|
||||||
|
rect = new Rectangle(new Point(x * 16, 1), new Size(16, 16));
|
||||||
|
e.Graphics.FillRectangle(new SolidBrush(bgPalettes[x].GetColor()), rect);
|
||||||
|
}
|
||||||
|
if (spritePalettes != spritePalettesPrev)
|
||||||
|
{
|
||||||
|
rect = new Rectangle(new Point(x * 16, 17), new Size(16, 16));
|
||||||
|
e.Graphics.FillRectangle(new SolidBrush(spritePalettes[x].GetColor()), rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasChanged()
|
||||||
|
{
|
||||||
|
for (int x = 0; x < 16; x++)
|
||||||
|
{
|
||||||
|
if (bgPalettes[x] != bgPalettesPrev[x])
|
||||||
|
return true;
|
||||||
|
if (spritePalettes[x] != spritePalettesPrev[x])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue