diff --git a/BizHawk.MultiClient/NEStools/NESPPU.cs b/BizHawk.MultiClient/NEStools/NESPPU.cs index 4c125c6805..08bff89d21 100644 --- a/BizHawk.MultiClient/NEStools/NESPPU.cs +++ b/BizHawk.MultiClient/NEStools/NESPPU.cs @@ -72,10 +72,10 @@ namespace BizHawk.MultiClient //Pattern Viewer 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.spritePalettes[x].SetValue(Nes.LookupColor(Nes.ppu.PALRAM[PaletteView.spritePalettes[x].address])); + PaletteView.bgPalettesPrev[x].Value = PaletteView.bgPalettes[x].Value; + PaletteView.spritePalettesPrev[x].Value = PaletteView.spritePalettes[x].Value; + PaletteView.bgPalettes[x].Value = Nes.LookupColor(Nes.ppu.PALRAM[PaletteView.bgPalettes[x].Address]); + PaletteView.spritePalettes[x].Value = Nes.LookupColor(Nes.ppu.PALRAM[PaletteView.spritePalettes[x].Address]); } if (PaletteView.HasChanged()) PaletteView.Refresh(); @@ -247,15 +247,15 @@ namespace BizHawk.MultiClient 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(); - 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 { - val = Nes.ppu.PALRAM[PaletteView.spritePalettes[column].address]; + val = Nes.ppu.PALRAM[PaletteView.spritePalettes[column].Address]; 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(); diff --git a/BizHawk.MultiClient/NEStools/PaletteViewer.cs b/BizHawk.MultiClient/NEStools/PaletteViewer.cs index 8fefbb2710..f566d47fab 100644 --- a/BizHawk.MultiClient/NEStools/PaletteViewer.cs +++ b/BizHawk.MultiClient/NEStools/PaletteViewer.cs @@ -12,40 +12,20 @@ namespace BizHawk.MultiClient { public class Palette { - public int address { get; set; } - private int value { get; set; } - private Color color; + public int Address { get; private set; } + public int Value { get; set; } + public Color Color { get { return Color.FromArgb(Value); } private set { Value = value.ToArgb(); } } - public Palette(int Address) + public Palette(int address) { - address = Address; - value = -1; + Address = address; + Value = -1; } public Palette(Palette p) { - address = p.address; - 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; + Address = p.Address; + Value = p.Value; } } @@ -70,6 +50,8 @@ namespace BizHawk.MultiClient { bgPalettes[x] = new Palette(x); spritePalettes[x] = new Palette(x + 16); + bgPalettesPrev[x] = new Palette(x); + spritePalettesPrev[x] = new Palette(x + 16); } } @@ -78,21 +60,18 @@ namespace BizHawk.MultiClient private void PaletteViewer_Paint(object sender, PaintEventArgs e) { - unchecked + Rectangle rect; + for (int x = 0; x < 16; x++) { - Rectangle rect; - for (int x = 0; x < 16; x++) + if (bgPalettes[x] != bgPalettesPrev[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); - } + rect = new Rectangle(new Point(x * 16, 1), new Size(16, 16)); + e.Graphics.FillRectangle(new SolidBrush(bgPalettes[x].Color), rect); + } + if (spritePalettes != spritePalettesPrev) + { + rect = new Rectangle(new Point(x * 16, 17), new Size(16, 16)); + e.Graphics.FillRectangle(new SolidBrush(spritePalettes[x].Color), rect); } } }