Some minor (and not entirely correct) palette fixes. default tip
authorRyan C. Gordon <icculus@icculus.org>
Wed, 03 Apr 2019 23:37:14 -0400
changeset 120dc55edfe5d2f
parent 119 8d4f708adba1
Some minor (and not entirely correct) palette fixes.

Restores the missing 3D Realms logo on Duke Nukem 3D, etc.

Fixes Bugzilla #4556.
src/SDL12_compat.c
     1.1 --- a/src/SDL12_compat.c	Tue Apr 02 15:05:00 2019 -0400
     1.2 +++ b/src/SDL12_compat.c	Wed Apr 03 23:37:14 2019 -0400
     1.3 @@ -3491,6 +3491,10 @@
     1.4          return 0;  // not an error, a no-op.
     1.5      }
     1.6  
     1.7 +    if ((flags & (SDL12_LOGPAL | SDL12_PHYSPAL)) == 0) {
     1.8 +        return 0;  // nothing to do.
     1.9 +    }
    1.10 +
    1.11      SDL12_Palette *palette12 = surface12->format->palette;
    1.12      if (!palette12) {
    1.13          return 0;  // not an error, a no-op.
    1.14 @@ -3514,12 +3518,24 @@
    1.15          opaquecolors[i].a = 255;
    1.16      }
    1.17  
    1.18 -    const int retval = SDL20_SetPaletteColors(palette20, opaquecolors, firstcolor, ncolors);
    1.19 +    int retval = 0;
    1.20 +
    1.21 +    if (flags & SDL12_LOGPAL) {
    1.22 +        if (SDL20_SetPaletteColors(palette20, opaquecolors, firstcolor, ncolors) < 0) {
    1.23 +            retval = -1;
    1.24 +        }
    1.25 +    }
    1.26 +
    1.27      SDL20_free(opaquecolors);
    1.28  
    1.29      // in case this pointer changed...
    1.30      palette12->colors = palette20->colors;
    1.31  
    1.32 +    FIXME("We need to store the physical palette somewhere");  // it might be different that logical palette and it will be needed for future blits.
    1.33 +    if ((surface12 == VideoSurface12) && (flags & SDL12_PHYSPAL)) {
    1.34 +        SDL_UpdateRect(surface12, 0, 0, 0, 0);   // force screen to reblit with new palette.
    1.35 +    }
    1.36 +
    1.37      return retval;
    1.38  }
    1.39