PaletteViewer - code clean up
This commit is contained in:
parent
620437c10d
commit
daa406f356
|
@ -72,10 +72,10 @@ 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.bgPalettesPrev[x].Value = PaletteView.bgPalettes[x].Value;
|
||||||
PaletteView.spritePalettesPrev[x] = new PaletteViewer.Palette(PaletteView.spritePalettes[x]);
|
PaletteView.spritePalettesPrev[x].Value = PaletteView.spritePalettes[x].Value;
|
||||||
PaletteView.bgPalettes[x].SetValue(Nes.LookupColor(Nes.ppu.PALRAM[PaletteView.bgPalettes[x].address]));
|
PaletteView.bgPalettes[x].Value = 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].Value = Nes.LookupColor(Nes.ppu.PALRAM[PaletteView.spritePalettes[x].Address]);
|
||||||
}
|
}
|
||||||
if (PaletteView.HasChanged())
|
if (PaletteView.HasChanged())
|
||||||
PaletteView.Refresh();
|
PaletteView.Refresh();
|
||||||
|
@ -247,15 +247,15 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
if (baseAddr == 0x3F00)
|
if (baseAddr == 0x3F00)
|
||||||
{
|
{
|
||||||
val = Nes.ppu.PALRAM[PaletteView.bgPalettes[column].address];
|
val = Nes.ppu.PALRAM[PaletteView.bgPalettes[column].Address];
|
||||||
ValueLabel.Text = "ID: BG" + (column / 4).ToString();
|
ValueLabel.Text = "ID: BG" + (column / 4).ToString();
|
||||||
g.FillRectangle(new SolidBrush(PaletteView.bgPalettes[column].GetColor()), 0, 0, 64, 64);
|
g.FillRectangle(new SolidBrush(PaletteView.bgPalettes[column].Color), 0, 0, 64, 64);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
val = Nes.ppu.PALRAM[PaletteView.spritePalettes[column].address];
|
val = Nes.ppu.PALRAM[PaletteView.spritePalettes[column].Address];
|
||||||
ValueLabel.Text = "ID: SPR" + (column / 4).ToString();
|
ValueLabel.Text = "ID: SPR" + (column / 4).ToString();
|
||||||
g.FillRectangle(new SolidBrush(PaletteView.spritePalettes[column].GetColor()), 0, 0, 64, 64);
|
g.FillRectangle(new SolidBrush(PaletteView.spritePalettes[column].Color), 0, 0, 64, 64);
|
||||||
}
|
}
|
||||||
g.Dispose();
|
g.Dispose();
|
||||||
|
|
||||||
|
|
|
@ -12,40 +12,20 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
public class Palette
|
public class Palette
|
||||||
{
|
{
|
||||||
public int address { get; set; }
|
public int Address { get; private set; }
|
||||||
private int value { get; set; }
|
public int Value { get; set; }
|
||||||
private Color color;
|
public Color Color { get { return Color.FromArgb(Value); } private set { Value = value.ToArgb(); } }
|
||||||
|
|
||||||
public Palette(int Address)
|
public Palette(int address)
|
||||||
{
|
{
|
||||||
address = Address;
|
Address = address;
|
||||||
value = -1;
|
Value = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Palette(Palette p)
|
public Palette(Palette p)
|
||||||
{
|
{
|
||||||
address = p.address;
|
Address = p.Address;
|
||||||
value = p.value;
|
Value = p.Value;
|
||||||
color = p.color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetValue()
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetValue(int val)
|
|
||||||
{
|
|
||||||
unchecked
|
|
||||||
{
|
|
||||||
value = val;
|
|
||||||
}
|
|
||||||
color = Color.FromArgb(value); //TODO: value should be unprocessed! then do all calculations on this line
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color GetColor()
|
|
||||||
{
|
|
||||||
return color;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +50,8 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
bgPalettes[x] = new Palette(x);
|
bgPalettes[x] = new Palette(x);
|
||||||
spritePalettes[x] = new Palette(x + 16);
|
spritePalettes[x] = new Palette(x + 16);
|
||||||
|
bgPalettesPrev[x] = new Palette(x);
|
||||||
|
spritePalettesPrev[x] = new Palette(x + 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,8 +59,6 @@ namespace BizHawk.MultiClient
|
||||||
private void PaletteViewer_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { }
|
private void PaletteViewer_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { }
|
||||||
|
|
||||||
private void PaletteViewer_Paint(object sender, PaintEventArgs e)
|
private void PaletteViewer_Paint(object sender, PaintEventArgs e)
|
||||||
{
|
|
||||||
unchecked
|
|
||||||
{
|
{
|
||||||
Rectangle rect;
|
Rectangle rect;
|
||||||
for (int x = 0; x < 16; x++)
|
for (int x = 0; x < 16; x++)
|
||||||
|
@ -86,13 +66,12 @@ namespace BizHawk.MultiClient
|
||||||
if (bgPalettes[x] != bgPalettesPrev[x])
|
if (bgPalettes[x] != bgPalettesPrev[x])
|
||||||
{
|
{
|
||||||
rect = new Rectangle(new Point(x * 16, 1), new Size(16, 16));
|
rect = new Rectangle(new Point(x * 16, 1), new Size(16, 16));
|
||||||
e.Graphics.FillRectangle(new SolidBrush(bgPalettes[x].GetColor()), rect);
|
e.Graphics.FillRectangle(new SolidBrush(bgPalettes[x].Color), rect);
|
||||||
}
|
}
|
||||||
if (spritePalettes != spritePalettesPrev)
|
if (spritePalettes != spritePalettesPrev)
|
||||||
{
|
{
|
||||||
rect = new Rectangle(new Point(x * 16, 17), new Size(16, 16));
|
rect = new Rectangle(new Point(x * 16, 17), new Size(16, 16));
|
||||||
e.Graphics.FillRectangle(new SolidBrush(spritePalettes[x].GetColor()), rect);
|
e.Graphics.FillRectangle(new SolidBrush(spritePalettes[x].Color), rect);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue