From 81595172a1de9d8a3b07aacffc537da32e82eb78 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 25 May 2020 22:00:22 +0200 Subject: [PATCH] ST formats : only save ST palette when RGB scale is 8 --- src/stformats.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/stformats.c b/src/stformats.c index 93704d31..c1611fc2 100644 --- a/src/stformats.c +++ b/src/stformats.c @@ -33,6 +33,7 @@ #include "loadsavefuncs.h" #include "io.h" #include "misc.h" +#include "palette.h" #include "gfx2log.h" #include "gfx2mem.h" #include "packbits.h" @@ -187,7 +188,10 @@ void PI1_code_palette(const T_Components * palette, byte * dest) { int i; // Numéro de la couleur traitée word w; // Word contenant le code + int plain_ST_colors = Get_palette_RGB_scale() == 8; + GFX2_Log(GFX2_DEBUG, "encoding ST%s palette (%d bits per component)\n", + plain_ST_colors ? "" : "e", plain_ST_colors ? 3 : 4); // Schéma d'un word = // // Low High @@ -196,10 +200,16 @@ void PI1_code_palette(const T_Components * palette, byte * dest) for (i=0;i<16;i++) { - w = ((word)(palette[i].R & 0xe0) << 3) | ((word)(palette[i].R & 0x10) << 7); - w |= ((word)(palette[i].G & 0xe0) >> 1) | ((word)(palette[i].G & 0x10) << 3); - w |= ((word)(palette[i].B & 0xe0) >> 5) | ((word)(palette[i].B & 0x10) >> 1); - + w = ((word)(palette[i].R & 0xe0) << 3); + w |= ((word)(palette[i].G & 0xe0) >> 1); + w |= ((word)(palette[i].B & 0xe0) >> 5); + if (!plain_ST_colors) + { + // add the STe specific bit + w |= ((word)(palette[i].R & 0x10) << 7); + w |= ((word)(palette[i].G & 0x10) << 3); + w |= ((word)(palette[i].B & 0x10) >> 1); + } *dest++ = (w >> 8); *dest++ = (w & 0xff); }