# HG changeset patch # User Matti Hamalainen # Date 1528484940 -10800 # Node ID 07111a60cd4e9c031c8e69f3cd934eff112d38af # Parent 474055f25ab00eab0502d7a45abd646dbd03cef2 Add dmSetMixedColorC64Palette() for setting a 256 entry "mixed color" palette, which consists of averaged 16 x 16 matrix of C64 palette. This can be used for rendering images that use color interlace. diff -r 474055f25ab0 -r 07111a60cd4e tools/lib64gfx.c --- a/tools/lib64gfx.c Fri Jun 08 22:07:05 2018 +0300 +++ b/tools/lib64gfx.c Fri Jun 08 22:09:00 2018 +0300 @@ -115,6 +115,29 @@ } +BOOL dmSetMixedColorC64Palette(DMImage *img) +{ + if (!dmImagePaletteAlloc(dst, C64_NCOLORS * C64_NCOLORS, -1)) + return FALSE; + + int n = 0; + for (int n1 = 0; n1 < C64_NCOLORS; n1++) + { + const DMColor *col1 = &dmDefaultC64Palette[n1]; + for (int n2 = 0; n2 < C64_NCOLORS; n2++) + { + const DMColor *col2 = &dmDefaultC64Palette[n2]; + dst->pal[n].r = (col1->r + col2->r) / 2; + dst->pal[n].g = (col1->g + col2->g) / 2; + dst->pal[n].b = (col1->b + col2->b) / 2; + n++; + } + } + + return TRUE; +} + + BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr) { return buf[offs ] == DM_GET_ADDR_LO(addr) && diff -r 474055f25ab0 -r 07111a60cd4e tools/lib64gfx.h --- a/tools/lib64gfx.h Fri Jun 08 22:07:05 2018 +0300 +++ b/tools/lib64gfx.h Fri Jun 08 22:09:00 2018 +0300 @@ -284,6 +284,8 @@ void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt); void dmSetDefaultC64Palette(DMImage *img); +BOOL dmSetMixedColorC64Palette(DMImage *img); + BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr); int dmC64ImageGetNumBanks(const DMC64ImageFormat *fmt);