From 2854c68a18b0f7da48f1136839da575c1e726c3a Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 8 Oct 2003 03:37:33 +0000 Subject: [PATCH] Remember if a surface fits in 4 bits. --- stepmania/src/SDL_utils.cpp | 3 +++ stepmania/src/SDL_utils.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/stepmania/src/SDL_utils.cpp b/stepmania/src/SDL_utils.cpp index e3e87d190b..d15a6df7eb 100644 --- a/stepmania/src/SDL_utils.cpp +++ b/stepmania/src/SDL_utils.cpp @@ -1022,6 +1022,9 @@ SDL_Surface *mySDL_Palettize( SDL_Surface *src_surf, int GrayBits, int AlphaBits const int Amask = ((1 << AlphaBits) - 1) << Ashift; // alpha mask const int Aloss = 8-AlphaBits; + if( TotalColors <= 16 ) + dst_surf->unused1 |= FOUR_BIT_PALETTE; + for( int index = 0; index < TotalColors; ++index ) { const int I = (index & Imask) >> Ishift; diff --git a/stepmania/src/SDL_utils.h b/stepmania/src/SDL_utils.h index 9c17aae527..473c529274 100644 --- a/stepmania/src/SDL_utils.h +++ b/stepmania/src/SDL_utils.h @@ -64,6 +64,11 @@ void mySDL_BlitTransform( const SDL_Surface *src, SDL_Surface *dst, const float fCoords[8] /* TL, BR, BL, TR */ ); void mySDL_BlitSurface( SDL_Surface *src, SDL_Surface *dst, int width, int height, bool ckey); + +/* Use the "unused1" field in surfaces to mark paletted surfaces that only use + * 16 palette values. */ +enum { FOUR_BIT_PALETTE = 0x1 }; + SDL_Surface *mySDL_Palettize( SDL_Surface *src_surf, int GrayBits, int AlphaBits ); #endif