From c3c2abf2721ab3bfff1bcc89561317c4fa91461f Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 6 Mar 2024 09:07:25 +0100 Subject: [PATCH] added color functions and definitions for BD engine (not used yet) --- src/game_bd/bd_colors.c | 597 ++++++++++++++++++++++++++++++++++++++-- src/game_bd/bd_colors.h | 6 + 2 files changed, 587 insertions(+), 16 deletions(-) diff --git a/src/game_bd/bd_colors.c b/src/game_bd/bd_colors.c index 5a04dde6..57f02ab0 100644 --- a/src/game_bd/bd_colors.c +++ b/src/game_bd/bd_colors.c @@ -17,24 +17,530 @@ #include "main_bd.h" +static int gd_c64_palette = 0; +static int gd_c64dtv_palette = 0; +static int gd_atari_palette = 0; + static char *c64_color_names[] = { - "Black", - "White", - "Red", - "Cyan", - "Purple", - "Green", - "Blue", - "Yellow", - "Orange", - "Brown", - "LightRed", - "Gray1", - "Gray2", - "LightGreen", - "LightBlue", - "Gray3", + "Black", "White", "Red", "Cyan", "Purple", "Green", "Blue", "Yellow", + "Orange", "Brown", "LightRed", "Gray1", "Gray2", "LightGreen", "LightBlue", "Gray3", +}; + +static unsigned int c64_colors_vice_old[] = +{ + 0x000000, 0xFFFFFF, 0x68372b, 0x70a4b2, 0x6f3d86, 0x588d43, 0x352879, 0xb8c76f, + 0x6f4f25, 0x433900, 0x9a6759, 0x444444, 0x6c6c6c, 0x9ad284, 0x6c5eb5, 0x959595, +}; + +static unsigned int c64_colors_vice_new[] = +{ + 0x000000, 0xffffff, 0x894036, 0x7abfc7, 0x8a46ae, 0x68a941, 0x3e31a2, 0xd0dc71, + 0x905f25, 0x5c4700, 0xbb776d, 0x555555, 0x808080, 0xacea88, 0x7c70da, 0xababab, +}; + +static unsigned int c64_colors_c64_hq[] = +{ + 0x0A0A0A, 0xFFF8FF, 0x851F02, 0x65CDA8, 0xA73B9F, 0x4DAB19, 0x1A0C92, 0xEBE353, + 0xA94B02, 0x441E00, 0xD28074, 0x464646, 0x8B8B8B, 0x8EF68E, 0x4D91D1, 0xBABABA, +}; + +static unsigned int c64_colors_c64s[] = +{ + 0x000000, 0xFCFCFC, 0xA80000, 0x54FCFC, 0xA800A8, 0x00A800, 0x0000A8, 0xFCFC00, + 0xA85400, 0x802C00, 0xFC5454, 0x545454, 0x808080, 0x54FC54, 0x5454FC, 0xA8A8A8, +}; + +static unsigned int c64_colors_ccs64[] = +{ + 0x101010, 0xFFFFFF, 0xE04040, 0x60FFFF, 0xE060E0, 0x40E040, 0x4040E0, 0xFFFF40, + 0xE0A040, 0x9C7448, 0xFFA0A0, 0x545454, 0x888888, 0xA0FFA0, 0xA0A0FF, 0xC0C0C0, +}; + +static unsigned int c64_colors_vice_default[] = +{ + 0x000000, 0xFDFEFC, 0xBE1A24, 0x30E6C6, 0xB41AE2, 0x1FD21E, 0x211BAE, 0xDFF60A, + 0xB84104, 0x6A3304, 0xFE4A57, 0x424540, 0x70746F, 0x59FE59, 0x5F53FE, 0xA4A7A2, +}; + +static unsigned int c64_colors_frodo[] = +{ + 0x000000, 0xFFFFFF, 0xCC0000, 0x00FFCC, 0xFF00FF, 0x00CC00, 0x0000CC, 0xFFFF00, + 0xFF8800, 0x884400, 0xFF8888, 0x444444, 0x888888, 0x88FF88, 0x8888FF, 0xCCCCCC, +}; + +static unsigned int c64_colors_godot[] = +{ + 0x000000, 0xFFFFFF, 0x880000, 0xAAFFEE, 0xCC44CC, 0x00CC55, 0x0000AA, 0xEEEE77, + 0xDD8855, 0x664400, 0xFE7777, 0x333333, 0x777777, 0xAAFF66, 0x0088FF, 0xBBBBBB, +}; + +static unsigned int c64_colors_pc64[] = +{ + 0x212121, 0xFFFFFF, 0xB52121, 0x73FFFF, 0xB521B5, 0x21B521, 0x2121B5, 0xFFFF21, + 0xB57321, 0x944221, 0xFF7373, 0x737373, 0x949494, 0x73FF73, 0x7373FF, 0xB5B5B5, +}; + +static unsigned int c64_colors_rtadash[]={ + 0x000000, 0xffffff, 0xea3418, 0x58ffff, 0xd82cff, 0x55fb00, 0x4925ff, 0xffff09, + 0xe66c00, 0x935f00, 0xff7c64, 0x6c6c6c, 0xa1a1a1, 0xafff4d, 0x9778ff, 0xd8d8d8, +}; + +/* make sure that pointeres and names match! */ +static unsigned int *c64_palette_pointers[] = +{ + c64_colors_vice_new, + c64_colors_vice_old, + c64_colors_vice_default, + c64_colors_c64_hq, + c64_colors_c64s, + c64_colors_ccs64, + c64_colors_frodo, + c64_colors_godot, + c64_colors_pc64, + c64_colors_rtadash, + + NULL +}; + +static byte BuiltIn[] = +{ + 0,0,0,16,16,16,32,32,32,48,48,48,64,64,64,80,80,80,96,96,96,112,112,112, + 128,128,128,144,144,144,160,160,160,176,176,176,192,192,192,208,208,208, + 224,224,224,240,240,240,56,0,0,72,16,0,88,32,0,104,48,0,120,64,0,136,80, + 0,152,96,0,168,112,0,184,128,0,200,144,0,216,160,12,232,176,28,248,192, + 44,255,208,60,255,224,76,255,240,92,63,0,0,79,2,0,95,18,0,111,34,0,127, + 50,0,143,66,0,159,82,3,175,98,19,191,114,35,207,130,51,223,146,67,239,162, + 83,255,178,99,255,194,115,255,210,131,255,226,147,58,0,0,74,0,0,90,6,12, + 106,22,28,122,38,44,138,54,60,154,70,76,170,86,92,186,102,108,202,118,124, + 218,134,140,234,150,156,250,166,172,255,182,188,255,198,204,255,214,220, + 42,0,56,58,0,72,74,1,88,90,17,104,106,33,120,122,49,136,138,65,152,154, + 81,168,170,97,184,186,113,200,202,129,216,218,145,232,234,161,248,250,177, + 255,255,193,255,255,209,255,17,0,122,33,0,138,49,1,154,65,17,170,81,33, + 186,97,49,202,113,65,218,129,81,234,145,97,250,161,113,255,177,129,255, + 193,145,255,209,161,255,225,177,255,241,193,255,255,209,255,0,0,164,5,0, + 180,21,8,196,37,24,212,53,40,228,69,56,244,85,72,255,101,88,255,117,104, + 255,133,120,255,149,136,255,165,152,255,181,168,255,197,184,255,213,200, + 255,229,216,255,0,0,173,0,3,189,0,19,205,11,35,221,27,51,237,43,67,253, + 59,83,255,75,99,255,91,115,255,107,131,255,123,147,255,139,163,255,155, + 179,255,171,195,255,187,211,255,203,227,255,0,0,148,0,16,164,0,32,180,0, + 48,196,8,64,212,24,80,228,40,96,244,56,112,255,72,128,255,88,144,255,104, + 160,255,120,176,255,136,192,255,152,208,255,168,224,255,184,240,255,0,14, + 93,0,30,109,0,46,125,0,62,141,1,78,157,17,94,173,33,110,189,49,126,205, + 65,142,221,81,158,237,97,174,253,113,190,255,129,206,255,145,222,255,161, + 238,255,177,254,255,0,26,20,0,42,36,0,58,52,0,74,68,6,90,84,22,106,100, + 38,122,116,54,138,132,70,154,148,86,170,164,102,186,180,118,202,196,134, + 218,212,150,234,228,166,250,244,182,255,255,0,31,0,0,47,0,0,63,0,6,79,0, + 22,95,8,38,111,24,54,127,40,70,143,56,86,159,72,102,175,88,118,191,104, + 134,207,120,150,223,136,166,239,152,182,255,168,198,255,184,0,31,0,0,47, + 0,15,63,0,31,79,0,47,95,0,63,111,0,79,127,0,95,143,0,111,159,6,127,175, + 22,143,191,38,159,207,54,175,223,70,191,239,86,207,255,102,223,255,118, + 11,24,0,27,40,0,43,56,0,59,72,0,75,88,0,91,104,0,107,120,0,123,136,0,139, + 152,0,155,168,0,171,184,0,187,200,12,203,216,28,219,232,44,235,248,60,251, + 255,76,37,13,0,53,29,0,69,45,0,85,61,0,101,77,0,117,93,0,133,109,0,149, + 125,0,165,141,0,181,157,0,197,173,0,213,189,3,229,205,19,245,221,35,255, + 237,51,255,253,67,56,0,0,72,16,0,88,32,0,104,48,0,120,64,0,136,80,0,152, + 96,0,168,112,0,184,128,0,200,144,0,216,160,12,232,176,28,248,192,44,255, + 208,60,255,224,76,255,240,92 +}; + +static byte BuiltIn_contrast[] = +{ + 0,0,0,17,17,17,34,34,34,51,51,51,68,68,68,85,85,85,102,102,102,119,119, + 119,136,136,136,153,153,153,170,170,170,187,187,187,204,204,204,221,221, + 221,238,238,238,255,255,255,59,0,0,76,16,0,93,33,0,110,50,0,127,67,0,144, + 84,0,161,101,0,178,118,0,195,135,0,212,152,0,229,169,13,246,186,30,255, + 203,47,255,220,64,255,237,81,255,254,98,67,0,0,84,2,0,101,19,0,118,36,0, + 135,53,0,152,70,0,169,87,3,186,104,20,203,121,37,220,138,54,237,155,71, + 254,172,88,255,189,105,255,206,122,255,223,139,255,240,156,62,0,0,79,0, + 0,96,7,12,113,24,29,130,41,46,147,58,63,164,75,80,181,92,97,198,109,114, + 215,126,131,232,143,148,249,160,165,255,177,182,255,194,199,255,211,216, + 255,228,233,44,0,59,61,0,76,78,1,93,95,18,110,112,35,127,129,52,144,146, + 69,161,163,86,178,180,103,195,197,120,212,214,137,229,231,154,246,248,171, + 255,255,188,255,255,205,255,255,222,255,18,0,130,35,0,147,52,1,164,69,18, + 181,86,35,198,103,52,215,120,69,232,137,86,249,154,103,255,171,120,255, + 188,137,255,205,154,255,222,171,255,239,188,255,255,205,255,255,222,255, + 0,0,174,5,0,191,22,8,208,39,25,225,56,42,242,73,59,255,90,76,255,107,93, + 255,124,110,255,141,127,255,158,144,255,175,161,255,192,178,255,209,195, + 255,226,212,255,243,229,255,0,0,184,0,3,201,0,20,218,12,37,235,29,54,252, + 46,71,255,63,88,255,80,105,255,97,122,255,114,139,255,131,156,255,148,173, + 255,165,190,255,182,207,255,199,224,255,216,241,255,0,1,157,0,18,174,0, + 35,191,0,52,208,9,69,225,26,86,242,43,103,255,60,120,255,77,137,255,94, + 154,255,111,171,255,128,188,255,145,205,255,162,222,255,179,239,255,196, + 255,255,0,15,99,0,32,116,0,49,133,0,66,150,1,83,167,18,100,184,35,117,201, + 52,134,218,69,151,235,86,168,252,103,185,255,120,202,255,137,219,255,154, + 236,255,171,253,255,188,255,255,0,27,22,0,44,39,0,61,56,0,78,73,6,95,90, + 23,112,107,40,129,124,57,146,141,74,163,158,91,180,175,108,197,192,125, + 214,209,142,231,226,159,248,243,176,255,255,193,255,255,0,33,0,0,50,0,0, + 67,0,7,84,0,24,101,9,41,118,26,58,135,43,75,152,60,92,169,77,109,186,94, + 126,203,111,143,220,128,160,237,145,177,254,162,194,255,179,211,255,196, + 0,33,0,0,50,0,16,67,0,33,84,0,50,101,0,67,118,0,84,135,0,101,152,0,118, + 169,6,135,186,23,152,203,40,169,220,57,186,237,74,203,254,91,220,255,108, + 237,255,125,12,26,0,29,43,0,46,60,0,63,77,0,80,94,0,97,111,0,114,128,0, + 131,145,0,148,162,0,165,179,0,182,196,0,199,213,13,216,230,30,233,247,47, + 250,255,64,255,255,81,39,14,0,56,31,0,73,48,0,90,65,0,107,82,0,124,99,0, + 141,116,0,158,133,0,175,150,0,192,167,0,209,184,0,226,201,3,243,218,20, + 255,235,37,255,252,54,255,255,71,59,0,0,76,16,0,93,33,0,110,50,0,127,67, + 0,144,84,0,161,101,0,178,118,0,195,135,0,212,152,0,229,169,13,246,186,30, + 255,203,47,255,220,64,255,237,81,255,254,98 +}; + +static byte Default[] = +{ + 0,0,0,28,28,28,57,57,57,89,89,89,121,121,121,146,146,146,171,171,171,188, + 188,188,205,205,205,217,217,217,230,230,230,236,236,236,242,242,242,248, + 248,248,255,255,255,255,255,255,57,23,1,94,35,4,131,48,8,165,71,22,200, + 95,36,227,120,32,255,145,29,255,171,29,255,197,29,255,206,52,255,216,76, + 255,230,81,255,244,86,255,249,119,255,255,152,255,255,152,69,25,4,114,30, + 17,159,36,30,179,58,32,200,81,34,227,105,32,255,129,30,255,140,37,255,152, + 44,255,174,56,255,197,69,255,197,89,255,198,109,255,213,135,255,228,161, + 255,228,161,74,23,4,126,26,13,178,29,23,200,33,25,223,37,28,236,59,56,250, + 82,85,252,97,97,255,112,110,255,127,126,255,143,143,255,157,158,255,171, + 173,255,185,189,255,199,206,255,199,206,5,5,104,59,19,109,113,34,114,139, + 42,140,165,50,166,185,56,186,205,62,207,219,71,221,234,81,235,244,95,245, + 254,109,255,254,122,253,255,135,251,255,149,253,255,164,255,255,164,255, + 40,4,121,64,9,132,89,15,144,112,36,157,136,57,170,164,65,195,192,74,220, + 208,84,237,224,94,255,233,109,255,242,124,255,248,138,255,255,152,255,254, + 161,255,254,171,255,254,171,255,53,8,138,66,10,173,80,12,208,100,40,208, + 121,69,208,141,75,212,162,81,217,176,88,236,190,96,255,197,107,255,204, + 119,255,209,131,255,215,144,255,219,157,255,223,170,255,223,170,255,5,30, + 129,6,38,165,8,47,202,38,61,212,68,76,222,79,90,238,90,104,255,101,117, + 255,113,131,255,128,145,255,144,160,255,151,169,255,159,178,255,175,190, + 255,192,203,255,192,203,255,12,4,139,34,24,160,56,45,181,72,62,199,88,79, + 218,97,89,236,107,100,255,122,116,255,138,132,255,145,142,255,153,152,255, + 165,163,255,177,174,255,184,184,255,192,194,255,192,194,255,29,41,90,29, + 56,118,29,72,146,28,92,172,28,113,198,50,134,207,72,155,217,78,168,236, + 85,182,255,112,199,255,140,216,255,147,219,255,155,223,255,175,228,255, + 195,233,255,195,233,255,47,67,2,57,82,2,68,97,3,65,122,18,62,148,33,74, + 159,46,87,171,59,92,189,85,97,208,112,105,226,122,114,245,132,124,250,141, + 135,255,151,154,255,166,173,255,182,173,255,182,10,65,8,13,84,10,16,104, + 13,19,125,15,22,146,18,25,165,20,28,185,23,30,201,25,33,217,27,71,228,45, + 110,240,64,120,247,77,131,255,91,154,255,122,178,255,154,178,255,154,4, + 65,11,5,83,14,6,102,17,7,119,20,8,136,23,9,155,26,11,175,29,72,196,31,134, + 217,34,143,233,36,153,249,39,168,252,65,183,255,91,201,255,110,220,255, + 129,220,255,129,2,53,15,7,63,21,12,74,28,45,95,30,79,116,32,89,131,36,100, + 146,40,130,161,46,161,176,52,169,193,58,178,210,65,196,217,69,214,225,73, + 228,240,78,242,255,83,242,255,83,38,48,1,36,56,3,35,64,5,81,84,27,128,105, + 49,151,129,53,175,153,58,194,167,62,213,181,67,219,192,61,225,203,56,226, + 216,54,227,229,52,239,242,88,251,255,125,251,255,125,64,26,2,88,31,5,112, + 36,8,141,58,19,171,81,31,181,100,39,191,119,48,208,133,58,225,147,68,237, + 160,78,249,173,88,252,183,92,255,193,96,255,198,113,255,203,131,255,203, + 131 +}; + +static byte Jakub[] = +{ + 45,45,45,59,59,59,73,73,73,87,87,87,101,101,101,115,115,115,129,129,129, + 143,143,143,157,157,157,171,171,171,185,185,185,199,199,199,213,213,213, + 227,227,227,241,241,241,255,255,255,92,35,0,106,49,0,120,63,0,134,77,10, + 148,91,24,162,105,38,176,119,52,190,133,66,204,147,80,218,161,94,232,175, + 108,246,189,122,255,203,136,255,217,150,255,231,164,255,245,178,105,20, + 9,119,34,23,133,48,37,147,62,51,161,76,65,175,90,79,189,104,93,203,118, + 107,217,132,121,231,146,135,245,160,149,255,174,163,255,188,177,255,202, + 191,255,216,205,255,230,219,108,10,56,122,24,70,136,38,84,150,52,98,164, + 66,112,178,80,126,192,94,140,206,108,154,220,122,168,234,136,182,248,150, + 196,255,164,210,255,178,224,255,192,238,255,206,252,255,220,255,100,5,101, + 114,19,115,128,33,129,142,47,143,156,61,157,170,75,171,184,89,185,198,103, + 199,212,117,213,226,131,227,240,145,241,254,159,255,255,173,255,255,187, + 255,255,201,255,255,215,255,82,7,137,96,21,151,110,35,165,124,49,179,138, + 63,193,152,77,207,166,91,221,180,105,235,194,119,249,208,133,255,222,147, + 255,236,161,255,250,175,255,255,189,255,255,203,255,255,217,255,58,16,156, + 72,30,170,86,44,184,100,58,198,114,72,212,128,86,226,142,100,240,156,114, + 254,170,128,255,184,142,255,198,156,255,212,170,255,226,184,255,240,198, + 255,254,212,255,255,226,255,31,30,156,45,44,170,59,58,184,73,72,198,87, + 86,212,101,100,226,115,114,240,129,128,254,143,142,255,157,156,255,171, + 170,255,185,184,255,199,198,255,213,212,255,227,226,255,241,240,255,7,46, + 137,21,60,151,35,74,165,49,88,179,63,102,193,77,116,207,91,130,221,105, + 144,235,119,158,249,133,172,255,147,186,255,161,200,255,175,214,255,189, + 228,255,203,242,255,217,255,255,0,62,101,3,76,115,17,90,129,31,104,143, + 45,118,157,59,132,171,73,146,185,87,160,199,101,174,213,115,188,227,129, + 202,241,143,216,255,157,230,255,171,244,255,185,255,255,199,255,255,0,75, + 56,0,89,70,9,103,84,23,117,98,37,131,112,51,145,126,65,159,140,79,173,154, + 93,187,168,107,201,182,121,215,196,135,229,210,149,243,224,163,255,238, + 177,255,252,191,255,255,0,82,9,0,96,23,12,110,37,26,124,51,40,138,65,54, + 152,79,68,166,93,82,180,107,96,194,121,110,208,135,124,222,149,138,236, + 163,152,250,177,166,255,191,180,255,205,194,255,219,0,83,0,11,97,0,25,111, + 0,39,125,10,53,139,24,67,153,38,81,167,52,95,181,66,109,195,80,123,209, + 94,137,223,108,151,237,122,165,251,136,179,255,150,193,255,164,207,255, + 178,19,78,0,33,92,0,47,106,0,61,120,0,75,134,0,89,148,11,103,162,25,117, + 176,39,131,190,53,145,204,67,159,218,81,173,232,95,187,246,109,201,255, + 123,215,255,137,229,255,151,45,67,0,59,81,0,73,95,0,87,109,0,101,123,0, + 115,137,1,129,151,15,143,165,29,157,179,43,171,193,57,185,207,71,199,221, + 85,213,235,99,227,249,113,241,255,127,255,255,141,70,51,0,84,65,0,98,79, + 0,112,93,0,126,107,0,140,121,11,154,135,25,168,149,39,182,163,53,196,177, + 67,210,191,81,224,205,95,238,219,109,252,233,123,255,247,137,255,255,151 +}; + +static byte Jakub_contrast[] = +{ + 0,0,0,17,17,17,34,34,34,50,50,50,67,67,67,85,85,85,101,101,101,118,118, + 118,136,136,136,153,153,153,170,170,170,186,186,186,203,203,203,220,220, + 220,237,237,237,254,254,254,57,0,0,74,4,0,91,21,0,108,38,0,125,55,0,142, + 72,0,159,89,8,176,106,25,193,123,42,210,140,59,227,157,76,244,174,93,254, + 191,110,255,208,127,255,225,144,254,242,161,72,0,0,89,0,0,106,3,0,123,20, + 7,140,37,24,157,54,41,174,71,58,191,88,75,208,105,92,225,122,109,242,139, + 126,255,156,143,255,173,160,255,190,177,254,207,194,254,224,211,76,0,13, + 93,0,30,110,0,47,127,8,64,144,25,81,161,42,98,178,59,115,195,76,132,212, + 93,149,229,110,166,246,127,183,254,144,200,254,161,217,255,178,234,255, + 195,251,255,212,255,66,0,68,83,0,85,100,0,102,117,2,119,134,19,136,151, + 36,153,168,53,170,185,70,187,202,87,204,219,104,221,236,121,238,253,138, + 255,254,155,254,255,172,255,254,189,254,254,206,254,44,0,111,61,0,128,78, + 0,145,95,4,162,112,21,179,129,38,196,146,55,213,163,72,230,180,89,247,197, + 106,254,214,123,255,231,140,255,248,157,254,255,174,255,254,191,254,254, + 208,254,15,0,134,32,0,151,49,0,168,66,15,185,83,32,202,100,49,219,117,66, + 236,134,83,253,151,100,255,168,117,254,185,134,254,202,151,255,219,168, + 254,236,185,255,253,202,254,255,219,255,0,0,134,0,0,151,16,15,168,33,32, + 185,50,49,202,68,66,219,85,83,236,102,100,253,119,117,255,135,134,254,152, + 151,254,170,168,255,186,185,254,204,202,255,220,219,254,237,236,254,0,1, + 111,0,18,128,0,35,145,4,52,162,21,69,179,38,86,196,55,103,213,72,120,230, + 89,137,247,106,154,255,123,171,255,140,188,254,157,205,255,174,222,254, + 191,239,255,208,255,255,0,20,67,0,37,85,0,54,101,0,71,118,0,88,136,17,105, + 153,34,122,170,50,139,186,67,156,203,84,173,220,101,190,237,118,207,254, + 136,224,255,153,241,254,169,254,254,187,254,254,0,36,13,0,53,30,0,70,47, + 0,87,64,0,104,81,7,121,98,24,138,115,41,155,132,58,172,149,75,189,166,92, + 206,183,109,223,200,126,240,217,143,254,234,160,255,251,177,254,254,0,44, + 0,0,61,0,0,78,0,0,95,7,0,112,24,10,129,41,27,146,58,44,163,75,61,180,92, + 78,197,109,95,214,126,112,231,143,129,248,160,146,254,177,163,254,194,180, + 255,211,0,46,0,0,63,0,0,80,0,0,97,0,9,114,0,26,131,0,43,148,8,60,165,25, + 77,182,42,94,199,59,111,216,76,128,233,93,145,250,110,162,255,127,179,254, + 144,196,254,161,0,40,0,0,57,0,2,74,0,19,91,0,36,108,0,53,125,0,70,142,0, + 87,159,0,104,176,9,121,193,26,138,210,43,155,227,60,172,244,77,189,254, + 94,206,254,111,223,255,128,0,26,0,16,43,0,34,60,0,50,77,0,67,94,0,84,111, + 0,101,128,0,118,145,0,135,162,0,152,179,14,169,196,31,186,213,48,204,230, + 65,220,247,82,237,254,99,255,255,116,30,7,0,47,24,0,64,41,0,81,58,0,98, + 75,0,115,92,0,132,109,0,149,126,0,166,143,9,183,160,26,200,177,43,217,194, + 60,234,211,77,251,228,94,254,245,111,255,255,128 +}; + +static byte Real[] = +{ + 50,49,50,63,62,63,77,76,77,91,91,91,106,105,106,121,120,121,136,135,136, + 151,151,151,161,160,161,175,175,175,190,190,190,206,205,206,219,219,219, + 235,234,235,250,250,250,255,255,255,97,46,0,108,59,0,122,74,0,136,88,0, + 148,103,12,165,118,27,178,132,42,193,148,58,202,157,67,218,173,83,232,187, + 98,248,203,114,255,216,127,255,232,143,255,247,159,255,255,174,108,36,0, + 119,48,0,132,64,3,146,78,17,158,93,34,175,108,49,188,123,65,204,138,80, + 213,147,91,228,163,105,242,177,121,255,194,137,255,207,151,255,223,166, + 255,237,181,255,253,196,117,22,24,129,35,36,143,49,52,157,64,67,170,78, + 80,184,94,96,198,109,111,213,125,127,222,135,135,237,149,150,252,164,165, + 255,180,181,255,194,196,255,209,211,255,224,225,255,239,240,98,14,113,110, + 27,124,123,42,138,138,57,152,150,71,165,165,87,181,179,101,195,195,117, + 209,205,126,218,220,141,233,234,151,247,249,172,255,255,186,255,255,201, + 255,255,217,255,255,232,255,86,15,135,97,29,144,113,44,158,127,58,172,141, + 72,186,155,88,199,169,103,213,184,119,229,194,128,237,208,144,252,223,159, + 255,238,175,255,252,189,255,255,204,255,255,219,255,255,234,255,70,22,149, + 81,34,160,96,50,172,110,65,187,124,79,200,138,94,214,153,109,227,168,124, + 242,177,133,251,192,149,255,207,163,255,223,179,255,238,193,255,252,208, + 255,255,223,255,255,239,255,33,41,148,45,53,159,61,68,173,75,83,186,89, + 97,199,104,111,213,119,126,226,135,142,242,144,151,250,150,166,255,174, + 181,255,191,196,255,205,210,255,218,227,255,234,241,255,250,254,255,15, + 53,132,28,65,141,44,80,155,58,94,170,72,108,183,88,123,197,103,138,210, + 118,153,226,128,162,235,143,178,249,158,192,255,173,208,255,189,221,255, + 203,236,255,219,252,255,234,255,255,4,63,112,17,75,121,33,89,136,47,104, + 150,62,117,164,77,131,178,92,146,193,108,161,210,116,171,217,131,186,231, + 147,201,246,162,216,255,177,230,255,192,245,255,208,255,255,222,255,255, + 0,89,24,0,101,38,15,114,53,29,129,68,44,142,80,59,157,96,74,172,111,89, + 187,126,99,196,135,114,211,150,130,226,165,146,241,181,159,254,195,174, + 255,210,190,255,226,206,255,241,7,92,0,20,104,0,34,117,0,50,131,0,63,145, + 11,79,160,27,94,174,42,110,189,59,119,198,68,135,213,83,150,227,99,167, + 243,115,179,254,128,195,255,143,211,255,160,227,255,176,26,86,0,40,98,0, + 54,112,0,69,126,0,83,140,0,98,155,7,112,169,22,128,185,38,137,194,47,153, + 209,62,168,223,77,183,239,92,197,252,107,213,255,123,227,255,139,243,255, + 153,51,75,0,64,87,0,77,101,0,93,115,0,106,130,0,122,145,0,136,158,15,152, + 174,31,161,183,40,186,198,56,191,213,72,206,228,88,220,242,102,235,255, + 117,250,255,133,255,255,149,75,60,0,88,73,0,101,87,0,116,101,0,129,116, + 0,144,131,7,159,145,22,174,161,38,183,170,46,199,186,62,213,199,77,229, + 215,93,242,229,107,254,244,122,255,255,139,255,255,154,96,46,0,109,58,0, + 122,73,0,137,88,0,149,103,10,164,118,27,178,131,42,194,148,58,203,157,68, + 218,172,83,232,186,98,248,203,115,255,215,127,255,231,145,255,246,159,255, + 255,175 +}; + +static byte Real_contrast[] = +{ + 0,0,0,16,15,16,34,32,34,51,51,51,70,68,70,88,87,88,107,106,107,126,126, + 126,138,137,138,155,155,155,174,174,174,194,192,194,210,210,210,230,228, + 230,248,248,248,255,255,255,59,0,0,72,11,0,90,30,0,107,47,0,122,66,0,143, + 85,0,159,102,0,178,122,10,189,133,21,209,153,41,226,170,60,246,190,80,255, + 206,96,255,226,116,255,245,135,255,255,154,72,0,0,86,0,0,102,18,0,119,35, + 0,134,54,0,155,72,0,171,91,19,191,109,37,202,121,51,221,140,68,238,158, + 88,255,179,108,255,195,126,255,215,144,255,232,163,255,252,181,83,0,0,98, + 0,0,116,0,3,133,18,21,149,35,37,166,55,57,184,73,76,202,93,96,214,106,106, + 232,123,124,251,142,143,255,161,163,255,179,181,255,197,200,255,216,217, + 255,235,236,60,0,78,75,0,92,91,0,109,109,9,127,124,26,143,143,46,163,160, + 63,180,180,83,197,192,94,209,211,113,227,228,126,245,247,152,255,255,169, + 255,255,188,255,255,207,255,255,226,255,45,0,106,59,0,117,78,0,134,96,10, + 152,113,28,169,130,47,185,148,66,202,166,86,222,179,97,232,196,117,251, + 215,135,255,233,155,255,251,173,255,255,191,255,255,210,255,255,228,255, + 25,0,123,39,0,137,57,0,152,75,19,170,92,36,186,109,55,204,128,73,220,147, + 92,238,158,103,250,176,123,255,195,140,255,215,160,255,233,178,255,251, + 196,255,255,215,255,255,235,255,0,0,122,0,4,135,14,23,153,31,41,169,49, + 59,185,67,76,202,86,94,219,106,114,238,117,126,248,124,144,255,154,163, + 255,175,181,255,192,199,255,209,220,255,228,237,255,248,253,255,0,4,102, + 0,19,113,0,37,130,10,55,149,28,72,165,47,91,183,66,109,199,85,128,219,97, + 139,230,116,159,247,134,176,255,153,196,255,173,212,255,190,231,255,210, + 251,255,228,255,255,0,16,77,0,31,88,0,49,107,0,67,124,15,83,142,34,101, + 159,52,119,178,72,138,199,82,150,207,101,169,225,121,188,243,139,206,255, + 158,223,255,176,242,255,196,255,255,214,255,255,0,49,0,0,63,0,0,80,4,0, + 98,23,0,114,37,11,133,57,30,152,76,49,170,94,61,181,106,80,200,124,99,219, + 143,119,237,163,135,253,180,154,255,199,174,255,219,194,255,237,0,52,0, + 0,67,0,0,83,0,0,101,0,16,118,0,36,137,0,55,154,0,75,173,11,86,184,23,106, + 202,41,124,220,61,145,240,81,160,253,97,180,255,116,200,255,137,220,255, + 157,0,45,0,0,60,0,5,77,0,24,94,0,41,112,0,60,130,0,77,148,0,97,168,0,108, + 179,0,128,197,15,147,215,34,165,235,52,183,251,71,202,255,91,220,255,111, + 240,255,128,1,31,0,18,46,0,34,63,0,54,81,0,70,99,0,90,118,0,107,134,0,127, + 154,0,138,165,0,169,184,8,175,202,28,194,221,47,211,238,65,230,255,83,248, + 255,103,255,255,123,31,13,0,47,29,0,63,46,0,82,63,0,98,82,0,117,101,0,135, + 118,0,154,138,0,165,149,0,185,169,15,202,185,34,222,205,54,238,222,71,253, + 241,90,255,255,111,255,255,129,57,0,0,73,10,0,90,29,0,108,47,0,123,66,0, + 142,85,0,159,101,0,179,122,10,190,133,23,209,152,41,226,169,60,246,190, + 81,255,205,96,255,225,118,255,243,135,255,255,155 +}; + +static byte XFormer[] = +{ + 0,0,0,32,32,32,64,64,64,97,97,97,125,125,125,145,145,145,161,161,161,178, + 178,178,190,190,190,202,202,202,214,214,214,226,226,226,234,234,234,242, + 242,242,250,250,250,255,255,255,24,20,0,48,40,0,97,60,4,121,80,8,141,109, + 12,157,133,24,178,170,48,190,178,68,198,194,80,210,206,93,218,214,105,222, + 222,117,226,226,133,230,230,145,234,234,157,238,238,165,36,20,0,56,36,0, + 80,52,0,113,80,0,145,113,4,174,133,4,190,157,40,198,174,68,206,186,97,214, + 190,105,222,198,113,230,202,121,238,206,129,242,214,145,246,222,157,250, + 226,161,44,12,4,72,20,8,109,28,16,145,44,32,178,80,52,186,97,64,198,113, + 85,206,121,101,214,141,121,218,153,137,222,170,149,226,174,153,230,178, + 157,230,186,161,234,194,170,238,198,178,44,4,12,89,24,36,149,40,68,170, + 60,89,182,85,113,194,97,121,202,105,129,210,113,137,214,121,145,218,133, + 153,222,141,161,226,149,170,230,157,178,234,165,182,238,170,186,242,174, + 190,48,0,44,80,8,72,113,16,105,157,32,149,194,72,198,214,97,214,222,117, + 222,226,129,226,230,141,230,234,149,234,238,157,238,238,165,238,238,170, + 238,238,174,238,238,178,238,242,182,242,20,4,64,40,8,129,89,40,186,109, + 60,198,129,85,206,141,101,210,153,113,214,161,129,218,170,141,222,178,149, + 226,186,153,230,190,161,230,194,165,234,198,174,234,202,178,238,206,182, + 238,0,0,52,16,16,105,40,40,186,72,72,198,97,97,214,109,109,218,121,121, + 222,133,133,226,145,145,230,157,157,230,165,165,234,174,174,234,178,178, + 238,186,186,242,194,194,246,198,198,250,4,28,72,8,52,121,12,76,170,16,97, + 170,36,113,182,56,129,194,68,141,206,80,149,214,97,157,222,113,165,226, + 125,178,230,137,186,230,149,190,234,157,194,234,165,198,238,170,202,242, + 4,16,48,8,24,89,12,40,129,20,60,145,32,80,153,60,101,178,85,121,190,97, + 137,198,109,153,210,117,170,218,125,178,222,133,186,226,145,190,230,153, + 198,234,161,202,238,170,206,242,0,36,28,4,72,56,8,105,80,12,141,109,16, + 170,133,24,190,153,56,206,178,72,214,186,89,222,198,101,226,206,113,230, + 210,129,234,214,145,238,222,161,242,226,178,246,230,182,250,234,0,40,4, + 0,64,12,4,89,20,20,133,28,36,178,64,56,194,85,76,206,97,89,210,113,97,214, + 125,121,222,141,145,230,153,157,234,165,165,238,178,174,238,190,186,238, + 198,190,242,202,12,40,0,24,80,0,36,121,4,56,149,16,72,178,28,89,186,48, + 105,194,68,117,202,89,133,210,105,145,218,113,153,222,121,161,226,133,170, + 230,145,182,234,157,194,238,170,198,242,174,20,36,0,44,89,0,68,141,4,93, + 170,8,117,194,32,137,202,48,153,206,68,161,210,85,170,214,97,178,218,109, + 186,222,117,190,226,125,194,230,137,202,234,149,210,238,161,214,242,170, + 32,28,0,76,64,0,113,97,16,133,125,24,194,153,32,210,178,48,222,202,60,230, + 210,76,234,218,89,234,226,97,238,230,105,238,234,117,242,234,133,246,238, + 141,246,238,145,250,242,153,32,20,0,52,36,0,89,56,4,129,85,12,170,117,20, + 182,133,28,194,145,48,202,157,72,214,170,97,218,182,109,222,186,121,226, + 190,133,230,198,145,234,202,153,234,214,157,238,218,161 +}; + +static const byte *atari_palettes_pointers[] = +{ + BuiltIn, + BuiltIn_contrast, + Default, + Jakub, + Jakub_contrast, + Real, + Real_contrast, + XFormer, + + NULL +}; + +static byte Spiff[] = +{ + 2,5,10,12,16,19,29,28,30,36,43,43,54,53,52,63,68,67,82,79,80,91,94,94,103, + 102,104,114,116,114,130,128,131,139,143,143,157,153,154,167,167,169,181, + 180,178,193,196,194,35,2,0,45,13,0,58,27,0,68,43,0,80,54,0,92,68,0,109, + 80,0,120,94,0,130,102,4,141,117,21,157,129,35,167,142,51,182,154,63,194, + 168,77,210,180,91,223,196,104,52,0,0,63,8,0,76,16,0,85,34,0,99,46,0,108, + 61,0,127,72,14,139,85,27,150,93,39,162,107,49,175,120,59,185,134,74,201, + 144,85,212,158,100,229,171,113,243,188,129,62,0,0,75,0,0,86,0,0,96,26,6, + 110,38,21,121,52,36,139,63,47,152,77,62,163,85,70,174,99,79,188,111,95, + 199,126,106,212,136,121,226,151,132,244,163,147,255,178,166,64,0,12,78, + 0,22,89,0,36,101,15,52,112,32,62,126,46,76,143,58,88,155,72,105,167,79, + 109,176,93,124,192,106,139,200,120,151,216,132,161,226,146,176,246,158, + 192,254,173,207,58,0,49,68,0,60,82,0,77,90,19,88,107,30,103,116,46,112, + 135,58,126,146,71,137,158,80,145,170,92,165,181,106,174,193,120,192,209, + 131,198,219,145,215,236,158,227,252,174,241,40,0,77,50,0,90,66,3,102,73, + 24,119,89,35,130,99,49,144,118,61,153,130,74,167,139,83,176,152,96,190, + 165,108,206,175,123,217,191,133,232,203,148,242,220,160,253,232,176,255, + 20,0,97,31,0,104,44,14,119,56,28,133,68,40,146,79,53,158,97,65,170,108, + 80,182,118,87,191,130,101,208,147,113,220,154,128,236,172,138,245,182,153, + 255,199,165,255,217,180,255,0,0,98,5,8,107,23,20,121,32,34,135,48,45,150, + 57,59,163,74,71,174,84,85,187,96,94,197,108,107,212,123,120,225,134,134, + 241,149,145,254,157,160,255,174,172,255,189,187,255,0,6,88,0,15,99,0,27, + 111,0,41,129,20,52,140,31,66,154,47,78,167,59,93,179,69,101,190,84,115, + 204,102,127,220,111,142,233,126,152,246,134,167,254,149,180,255,161,196, + 255,0,13,68,0,23,79,0,35,93,0,48,110,0,60,118,0,73,132,12,86,147,25,102, + 160,43,110,168,57,124,184,78,136,199,89,150,213,102,161,223,111,176,233, + 125,189,249,140,205,254,0,20,36,0,30,46,0,41,62,0,56,72,0,66,87,0,80,97, + 0,93,113,0,108,124,5,118,132,32,131,152,56,144,161,69,158,177,87,169,188, + 95,183,198,109,196,212,121,213,223,0,25,0,0,35,0,0,46,14,0,60,30,0,70,40, + 0,86,55,0,97,68,6,113,82,25,122,93,43,136,105,61,148,119,77,162,131,91, + 174,143,100,188,156,113,201,169,127,217,186,0,26,0,0,36,0,0,48,0,0,61,0, + 0,72,0,0,86,21,19,99,32,34,114,47,46,122,56,57,137,66,78,148,79,88,163, + 89,102,173,106,111,188,120,124,201,132,137,214,145,3,25,0,5,35,0,0,47,0, + 2,61,0,5,71,0,23,86,0,39,98,0,52,112,16,63,121,25,76,134,40,94,147,47,105, + 161,64,119,173,73,126,187,92,140,199,106,155,217,119,0,20,0,0,31,0,7,42, + 0,15,58,0,36,67,0,43,82,0,62,94,0,74,108,0,85,116,0,98,130,11,112,143,32, + 126,156,45,137,168,59,148,182,72,164,194,89,177,210,99 +}; + +static byte Murray[] = +{ + 0,0,0,16,17,20,30,37,32,49,56,47,66,69,64,85,87,83,103,106,99,120,123,119, + 132,135,130,152,155,150,165,168,163,186,189,185,199,201,193,221,223,219, + 236,239,235,255,255,255,50,0,0,67,7,0,82,26,0,102,44,0,117,59,0,135,80, + 0,153,96,11,166,116,36,183,126,42,202,140,67,218,159,79,235,181,92,252, + 196,112,255,213,132,255,232,153,255,251,162,66,0,0,77,0,0,100,9,0,115,30, + 7,130,43,16,150,63,37,169,80,59,173,93,60,199,109,85,213,130,99,235,148, + 120,255,162,142,255,179,155,255,199,170,255,213,192,255,232,208,76,0,3, + 83,0,9,105,0,29,123,19,46,139,33,66,155,50,79,172,66,99,192,86,107,198, + 99,140,223,116,146,236,138,165,255,150,186,255,166,205,255,185,223,255, + 203,238,255,219,252,66,0,49,77,0,62,99,0,83,119,10,102,130,24,112,146,44, + 130,166,63,153,185,79,166,198,92,179,215,107,201,231,125,209,251,142,234, + 255,162,255,255,181,255,255,195,255,255,213,255,49,0,89,62,0,102,83,0,119, + 102,7,136,112,26,149,132,43,182,155,60,186,169,79,209,183,90,222,196,109, + 242,221,129,255,236,146,255,254,165,255,255,179,255,255,196,255,255,212, + 255,26,0,115,40,0,135,63,0,146,77,16,166,93,32,185,106,52,199,129,70,219, + 148,86,239,159,99,254,176,117,255,193,133,255,208,150,255,228,168,255,244, + 188,255,255,205,255,255,225,255,0,0,125,17,0,139,33,10,163,52,30,181,66, + 44,192,86,64,212,103,82,229,120,96,248,130,107,255,152,128,255,166,149, + 255,182,165,255,201,179,255,222,198,255,239,215,255,255,239,255,0,0,115, + 0,7,135,3,26,148,23,43,169,36,62,185,57,76,208,72,93,212,97,112,239,105, + 129,244,122,146,255,138,160,255,153,176,255,173,198,255,186,215,255,209, + 231,255,228,249,255,0,10,89,0,24,99,0,47,123,3,64,143,14,74,158,36,97,176, + 49,113,192,67,133,208,82,143,219,102,158,236,119,181,255,135,196,255,149, + 211,255,168,234,255,186,248,255,201,255,255,0,27,43,0,42,56,0,57,82,0,83, + 102,0,92,115,17,112,135,34,129,149,46,150,160,69,159,183,85,175,196,99, + 192,218,119,215,226,136,231,254,152,249,255,168,255,255,185,255,255,0,36, + 3,0,53,13,0,72,24,0,90,50,0,106,64,11,126,87,29,142,100,46,163,112,63,172, + 132,79,188,145,95,203,163,115,223,183,133,241,198,152,255,218,162,255,236, + 186,255,255,0,46,0,0,59,0,0,80,0,0,100,1,3,110,14,13,132,32,39,149,52,57, + 166,73,64,179,77,80,198,92,97,212,113,120,229,136,132,248,149,159,255,175, + 172,255,182,183,255,203,0,44,0,0,63,0,0,76,0,1,97,0,19,115,0,36,128,0,53, + 149,10,70,163,32,82,178,42,102,201,49,117,211,79,136,226,96,153,248,109, + 168,255,125,186,255,143,206,255,162,0,39,0,0,56,0,6,73,0,24,95,0,36,105, + 0,56,125,0,77,145,0,92,160,0,103,172,16,129,189,34,142,205,46,158,226,66, + 173,239,85,196,255,100,206,255,110,231,255,139,0,26,0,16,42,0,33,59,0,50, + 79,0,66,93,0,87,109,0,103,129,0,115,146,0,132,160,1,149,181,26,170,196, + 39,185,212,57,208,232,80,225,249,89,238,255,107,255,255,126 +}; + +static const byte *c64dtv_palettes_pointers[] = +{ + Spiff, + Murray, + + NULL }; // return c64 color with index. @@ -61,6 +567,65 @@ static GdColor unknown_color(void) return (GD_COLOR_TYPE_UNKNOWN << 24); } +// convert color to rgbcolor; using the current palette. +GdColor gd_color_get_rgb(GdColor color) +{ + int index; + const unsigned char *atari_pal; + const unsigned char *c64dtv_pal; + const GdColor *c64_pal; + + switch (color >> 24) + { + case GD_COLOR_TYPE_RGB: + // is already rgb + return color; + + case GD_COLOR_TYPE_C64: + if (gd_c64_palette < 0 || gd_c64_palette >= ARRAY_SIZE(c64_palette_pointers) - 1) + gd_c64_palette = 0; // silently switch to default, if invalid value + c64_pal = c64_palette_pointers[gd_c64_palette]; + index = color & 0x0f; + return c64_pal[index]; + + case GD_COLOR_TYPE_C64DTV: + if (gd_c64dtv_palette < 0 || gd_c64dtv_palette >= ARRAY_SIZE(c64dtv_palettes_pointers) - 1) + gd_c64dtv_palette = 0; + c64dtv_pal = c64dtv_palettes_pointers[gd_c64dtv_palette]; + index = color & 0xff; + return gd_color_get_from_rgb(c64dtv_pal[index * 3], + c64dtv_pal[index * 3 + 1], + c64dtv_pal[index * 3 + 2]); + + case GD_COLOR_TYPE_ATARI: + if (gd_atari_palette < 0 || gd_atari_palette >= ARRAY_SIZE(atari_palettes_pointers) - 1) + gd_atari_palette = 0; + atari_pal = atari_palettes_pointers[gd_atari_palette]; + index = color & 0xff; + return gd_color_get_from_rgb(atari_pal[index * 3], + atari_pal[index * 3 + 1], + atari_pal[index * 3 + 2]); + + default: + return 0; // (never reached) + } +} + +unsigned int gd_color_get_r(GdColor color) +{ + return ((gd_color_get_rgb(color) >> 16) & 0xff); +} + +unsigned int gd_color_get_g(GdColor color) +{ + return ((gd_color_get_rgb(color) >> 8) & 0xff); +} + +unsigned int gd_color_get_b(GdColor color) +{ + return ((gd_color_get_rgb(color) >> 0) & 0xff); +} + // make up GdColor from r,g,b values. GdColor gd_color_get_from_rgb(int r, int g, int b) { diff --git a/src/game_bd/bd_colors.h b/src/game_bd/bd_colors.h index 26fd2b6d..9738503e 100644 --- a/src/game_bd/bd_colors.h +++ b/src/game_bd/bd_colors.h @@ -82,6 +82,12 @@ typedef enum _color_type GdColor gd_c64_color(int index); GdColor gd_atari_color(int index); GdColor gd_c64dtv_color(int index); + +unsigned int gd_color_get_r(GdColor color); +unsigned int gd_color_get_g(GdColor color); +unsigned int gd_color_get_b(GdColor color); + +GdColor gd_color_get_rgb(GdColor color); GdColor gd_color_get_from_rgb(int r, int g, int b); GdColor gd_color_get_from_string(const char *color); const char *gd_color_get_string(GdColor color); -- 2.34.1