From 10b18cf862be4d184b96d77275d0b989549a4759 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Tue, 8 Mar 2011 19:41:49 +0000 Subject: [PATCH] NES PPU - hook up ppu bus values to the palette tool. --- BizHawk.MultiClient/NEStools/NESPPU.cs | 5 +++ BizHawk.MultiClient/NEStools/PaletteViewer.cs | 37 +++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/BizHawk.MultiClient/NEStools/NESPPU.cs b/BizHawk.MultiClient/NEStools/NESPPU.cs index 820667b6eb..07e1743d58 100644 --- a/BizHawk.MultiClient/NEStools/NESPPU.cs +++ b/BizHawk.MultiClient/NEStools/NESPPU.cs @@ -47,6 +47,11 @@ namespace BizHawk.MultiClient { if (!(Global.Emulator is NES)) return; if (!this.IsHandleCreated || this.IsDisposed) return; + for (int x = 0; x < 16; x++) + { + PaletteView.bgPalettes[x].SetValue(Nes.ppu.ppubus_read(PaletteView.bgPalettes[x].address)); + PaletteView.spritePalettes[x].SetValue(Nes.ppu.ppubus_read(PaletteView.spritePalettes[x].address)); + } PaletteView.Refresh(); } diff --git a/BizHawk.MultiClient/NEStools/PaletteViewer.cs b/BizHawk.MultiClient/NEStools/PaletteViewer.cs index 27de356dc7..c5fd286746 100644 --- a/BizHawk.MultiClient/NEStools/PaletteViewer.cs +++ b/BizHawk.MultiClient/NEStools/PaletteViewer.cs @@ -10,20 +10,37 @@ namespace BizHawk.MultiClient { public class PaletteViewer : Control { - private class Palette + public class Palette { public int address { get; set; } - public int value { get; set; } + private int value { get; set; } + private Color color; public Palette(int Address) { address = Address; value = -1; } + + public int GetValue() + { + return value; + } + + public void SetValue(int val) + { + value = val; + color = Color.FromArgb(val); + } + + public Color GetColor() + { + return color; + } } - private Palette[] bgPalettes = new Palette[16]; - private Palette[] spritePalettes = new Palette[16]; + public Palette[] bgPalettes = new Palette[16]; + public Palette[] spritePalettes = new Palette[16]; public PaletteViewer() { @@ -40,10 +57,7 @@ namespace BizHawk.MultiClient for (int x = 0; x < 16; x++) { bgPalettes[x] = new Palette(0x3F00 + x); - bgPalettes[x].value = x; - spritePalettes[x] = new Palette(0x3F10 + x); - spritePalettes[x].value = x; } } @@ -58,12 +72,12 @@ namespace BizHawk.MultiClient for (int x = 0; x < 16; x++) { rect = new Rectangle(new Point(x * 16, 1), new Size(16, 16)); - g.FillRectangle(new SolidBrush(GetColorByValue(bgPalettes[x].value)), rect); + 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(GetColorByValue(spritePalettes[x].value)), rect); + g.FillRectangle(new SolidBrush(spritePalettes[x].GetColor()), rect); } } } @@ -82,7 +96,7 @@ namespace BizHawk.MultiClient { } - + /* //adelikat: Using my own approximation of the NES color palette until we have a decent palette system private Color GetColorByValue(int value) { @@ -123,6 +137,7 @@ namespace BizHawk.MultiClient default: return Color.Black; } - } + } + */ } }