changeset 2175:58fab91830d5

Change default C64 palette system a bit, add two more palettes. These are not yet selectable. TBD.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 12 Jun 2019 16:38:39 +0300
parents 5b22533cb07d
children 8e6713705786
files tools/lib64gfx.c tools/lib64gfx.h
diffstat 2 files changed, 81 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Tue Jun 11 22:23:36 2019 +0300
+++ b/tools/lib64gfx.c	Wed Jun 12 16:38:39 2019 +0300
@@ -12,27 +12,78 @@
 #define BUF_SIZE_GROW      (4*1024)
 
 
-// Based on Pepto's palette, stolen from VICE
-DMColor dmDefaultC64Palette[D64_NCOLORS] =
+//
+// Some "default" C64 palettes
+//
+DMC64Palette dmC64DefaultPalettes[] =
 {
-    { 0x00, 0x00, 0x00, 0xff },
-    { 0xFF, 0xFF, 0xFF, 0xff },
-    { 0x68, 0x37, 0x2B, 0xff },
-    { 0x70, 0xA4, 0xB2, 0xff },
-    { 0x6F, 0x3D, 0x86, 0xff },
-    { 0x58, 0x8D, 0x43, 0xff },
-    { 0x35, 0x28, 0x79, 0xff },
-    { 0xB8, 0xC7, 0x6F, 0xff },
-    { 0x6F, 0x4F, 0x25, 0xff },
-    { 0x43, 0x39, 0x00, 0xff },
-    { 0x9A, 0x67, 0x59, 0xff },
-    { 0x44, 0x44, 0x44, 0xff },
-    { 0x6C, 0x6C, 0x6C, 0xff },
-    { 0x9A, 0xD2, 0x84, 0xff },
-    { 0x6C, 0x5E, 0xB5, 0xff },
-    { 0x95, 0x95, 0x95, 0xff },
+    {
+        "Pepto",
+        {
+            { 0x00, 0x00, 0x00, 0xff },
+            { 0xFF, 0xFF, 0xFF, 0xff },
+            { 0x68, 0x37, 0x2B, 0xff },
+            { 0x70, 0xA4, 0xB2, 0xff },
+            { 0x6F, 0x3D, 0x86, 0xff },
+            { 0x58, 0x8D, 0x43, 0xff },
+            { 0x35, 0x28, 0x79, 0xff },
+            { 0xB8, 0xC7, 0x6F, 0xff },
+            { 0x6F, 0x4F, 0x25, 0xff },
+            { 0x43, 0x39, 0x00, 0xff },
+            { 0x9A, 0x67, 0x59, 0xff },
+            { 0x44, 0x44, 0x44, 0xff },
+            { 0x6C, 0x6C, 0x6C, 0xff },
+            { 0x9A, 0xD2, 0x84, 0xff },
+            { 0x6C, 0x5E, 0xB5, 0xff },
+            { 0x95, 0x95, 0x95, 0xff },
+        },
+    },
+    {
+        "Colodore",
+        {
+            { 0x00, 0x00, 0x00, 0xff },
+            { 0xff, 0xff, 0xff, 0xff },
+            { 0x96, 0x28, 0x2e, 0xff },
+            { 0x5b, 0xd6, 0xce, 0xff },
+            { 0x9f, 0x2d, 0xad, 0xff },
+            { 0x41, 0xb9, 0x36, 0xff },
+            { 0x27, 0x24, 0xc4, 0xff },
+            { 0xef, 0xf3, 0x47, 0xff },
+            { 0x9f, 0x48, 0x15, 0xff },
+            { 0x5e, 0x35, 0x00, 0xff },
+            { 0xda, 0x5f, 0x66, 0xff },
+            { 0x47, 0x47, 0x47, 0xff },
+            { 0x78, 0x78, 0x78, 0xff },
+            { 0x91, 0xff, 0x84, 0xff },
+            { 0x68, 0x64, 0xff, 0xff },
+            { 0xae, 0xae, 0xae, 0xff },
+        },
+    },
+    {
+        "VICE 3.3",
+        {
+            { 0x00, 0x00, 0x00, 0xff },
+            { 0xfd, 0xfe, 0xfc, 0xff },
+            { 0xbe, 0x1a, 0x24, 0xff },
+            { 0x30, 0xe6, 0xc6, 0xff },
+            { 0xb4, 0x1a, 0xe2, 0xff },
+            { 0x1f, 0xd2, 0x1e, 0xff },
+            { 0x21, 0x1b, 0xae, 0xff },
+            { 0xdf, 0xf6, 0x0a, 0xff },
+            { 0xb8, 0x41, 0x04, 0xff },
+            { 0x6a, 0x33, 0x04, 0xff },
+            { 0xfe, 0x4a, 0x57, 0xff },
+            { 0x42, 0x45, 0x40, 0xff },
+            { 0x70, 0x74, 0x6f, 0xff },
+            { 0x59, 0xfe, 0x59, 0xff },
+            { 0x5f, 0x53, 0xfe, 0xff },
+            { 0xa4, 0xa7, 0xa2, 0xff },
+        },
+    },
 };
 
+const int ndmC64DefaultPalettes = sizeof(dmC64DefaultPalettes) / sizeof(dmC64DefaultPalettes[0]);
+
 
 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng)
 {
@@ -132,7 +183,7 @@
     if ((res = dmPaletteAlloc(&(img->pal), D64_NCOLORS, 255)) != DMERR_OK)
         return res;
 
-    memcpy(img->pal->colors, dmDefaultC64Palette, img->pal->ncolors * sizeof(DMColor));
+    memcpy(img->pal->colors, dmC64DefaultPalettes[0].colors, img->pal->ncolors * sizeof(DMColor));
 
     return DMERR_OK;
 }
@@ -154,10 +205,10 @@
 
     for (int n1 = 0, n = 0; n1 < D64_NCOLORS; n1++)
     {
-        const DMColor *col1 = &dmDefaultC64Palette[n1];
+        const DMColor *col1 = &dmC64DefaultPalettes[0].colors[n1];
         for (int n2 = 0; n2 < D64_NCOLORS; n2++)
         {
-            const DMColor *col2 = &dmDefaultC64Palette[n2];
+            const DMColor *col2 = &dmC64DefaultPalettes[0].colors[n2];
             img->pal->colors[n].r = (col1->r + col2->r) / 2;
             img->pal->colors[n].g = (col1->g + col2->g) / 2;
             img->pal->colors[n].b = (col1->b + col2->b) / 2;
--- a/tools/lib64gfx.h	Tue Jun 11 22:23:36 2019 +0300
+++ b/tools/lib64gfx.h	Wed Jun 12 16:38:39 2019 +0300
@@ -158,6 +158,13 @@
 
 typedef struct
 {
+    char *name;
+    DMColor colors[D64_NCOLORS];
+} DMC64Palette;
+
+
+typedef struct
+{
     BOOL multicolor, xexpand, yexpand;
     int color, xc, yc;
     Uint8 data[D64_SPR_HEIGHT_UT][D64_SPR_WIDTH_UT];
@@ -316,7 +323,8 @@
 //
 // Global variables
 //
-extern DMColor           dmDefaultC64Palette[D64_NCOLORS];
+extern DMC64Palette      dmC64DefaultPalettes[];
+extern const int         ndmC64DefaultPalettes;
 extern DMC64ImageFormat  dmC64ImageFormats[];
 extern const int         ndmC64ImageFormats;