using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using BizHawk.Emulation.CPUs.M6502;
namespace BizHawk.Emulation.Consoles.Nintendo
{
partial class NES
{
public static class Palettes
{
static float[] rtmul = { 1.239f, 0.794f, 1.019f, 0.905f, 1.023f, 0.741f, 0.75f };
static float[] gtmul = { 0.915f, 1.086f, 0.98f, 1.026f, 0.908f, 0.987f, 0.75f };
static float[] btmul = { 0.743f, 0.882f, 0.653f, 1.277f, 0.979f, 0.101f, 0.75f };
public static void ApplyDeemphasis(ref int r, ref int g, ref int b, int deemph_bits)
{
//DEEMPH BITS MAY BE ORDERED WRONG. PLEASE CHECK
if (deemph_bits == 0) return;
int d = deemph_bits-1;
r = (int)(r * rtmul[d]);
g = (int)(g * gtmul[d]);
b = (int)(b * btmul[d]);
if (r > 0xFF) r = 0xFF;
if (g > 0xFF) g = 0xFF;
if (b > 0xFF) b = 0xFF;
}
///
/// Loads a simple 192 byte (64 entry RGB888) palette which is FCEUX format (and probably other emulators as well)
///
/// 192 bytes, the contents of the palette file
public static int[,] Load_FCEUX_Palette(byte[] fileContents)
{
if (fileContents.Length != 192) return null;
int[,] ret = new int[64, 3];
int i=0;
for (int c = 0; c < 64; c++)
{
for(int z=0;z<3;z++)
ret[c,z] = fileContents[i++];
}
return ret;
}
const int SHIFT = 2;
public static int[,] FCEUX_Standard = new int[,]
{
{ 0x1D<