From fe51441596a00d9569bc05fc509ad12662c5eeea Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 8 Mar 2011 19:05:52 +0000 Subject: [PATCH] [NES] separate color conversion logic for use in tools --- BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs | 11 +++++++++++ BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs | 8 +------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs index 60c8a1f0e4..5279dfc593 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs @@ -132,6 +132,17 @@ namespace BizHawk.Emulation.Consoles.Nintendo cpu.PendingCycles -= 512; } + public int ConvertColor(int pixel) + { + int deemph = pixel >> 8; + int palentry = pixel & 0xFF; + int r = palette[palentry, 0]; + int g = palette[palentry, 1]; + int b = palette[palentry, 2]; + Palettes.ApplyDeemphasis(ref r, ref g, ref b, deemph); + return (r << 16) | (g << 8) | b; + } + public byte ReadMemory(ushort addr) { if (addr < 0x0800) return ram[addr]; diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs index 8f147877ca..9fc9d4f7bb 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs @@ -56,13 +56,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo for (int x = 0; x < 256; x++) { int pixel = emu.ppu.xbuf[i]; - int deemph = pixel >> 8; - int palentry = pixel & 0xFF; - int r = emu.palette[palentry, 0]; - int g = emu.palette[palentry, 1]; - int b = emu.palette[palentry, 2]; - Palettes.ApplyDeemphasis(ref r, ref g, ref b, deemph); - pixels[i] = (r<<16)|(g<<8)|b; + pixels[i] = emu.ConvertColor(pixel); i++; } return pixels;