This palette is based on values in an actual Atari 800 emulator available from Sourceforge.
63 | 77 | 91 | 106 | 121 | 135 | 151 | 161 | 175 | 190 | 206 | 219 | 235 | 250 | 255 | |||
0 | Grey | ||||||||||||||||
1 | Gold | ||||||||||||||||
2 | Orange | ||||||||||||||||
3 | Red-Orange | ||||||||||||||||
4 | Pink | ||||||||||||||||
5 | Purple | ||||||||||||||||
6 | Purple-Blue | ||||||||||||||||
7 | Blue | ||||||||||||||||
8 | Blue | ||||||||||||||||
9 | Light Blue | ||||||||||||||||
10 | Turquoise | ||||||||||||||||
11 | Green- Blue | ||||||||||||||||
12 | Green | ||||||||||||||||
13 | Yellow-Green | ||||||||||||||||
14 | Orange-Green | ||||||||||||||||
15 | Light Orange |
static const double redf = 0.30; static const double greenf = 0.59; static const double bluef = 0.11;
static void Palette_Format(int black, int white, int colors) /* format loaded palette */ { double white_in, black_in, brightfix; pal_t rgb; int i, j;
for (i = 0; i <0x100; i++) { int c="basicpal[i];" rgb[i].r="(c">> 16) & 0xff; rgb[i].g = (c >> 8) & 0xff; rgb[i].b = c & 0xff; }
black_in = redf * rgb[ 0].r + greenf * rgb[ 0].g + bluef * rgb[ 0].b; white_in = redf * rgb[15].r + greenf * rgb[15].g + bluef * rgb[15].b; brightfix = (double)(white - black) / (white_in - black_in);
for (i = 0; i < 0x10; i++) { for (j = 0; j < 0x10; j++) { double y, r, g, b; int r1, g1, b1; // y is luminance, easy to calculate y = redf * rgb[i * 16 + j].r + greenf * rgb[i * 16 + j].g + bluef * rgb[i * 16 + j].b; r = (double)rgb[i * 16 + j].r - y; g = (double)rgb[i * 16 + j].g - y; b = (double)rgb[i * 16 + j].b - y; y = ((y - black_in) * brightfix) + black; r *= (double)colors * brightfix / (double)COLINTENS; g *= (double)colors * brightfix / (double)COLINTENS; b *= (double)colors * brightfix / (double)COLINTENS; r1 = y + r; g1 = y + g; b1 = y + b; CLIP_VAR(r1); CLIP_VAR(g1); CLIP_VAR(b1); rgb[i * 16 + j].r = r1; rgb[i * 16 + j].g = g1; rgb[i * 16 + j].b = b1; } }
for (i = 0; i < 0x100; i++) { colortable[i] = (rgb[i].r << 16) + (rgb[i].g << 8) + (rgb[i].b << 0); }
}