DirectX palette bugfix

Here you go, a fix for the DirectX palette bug…

It will go into CVS when I get back from my cousin’s wedding (Monday).

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software
-------------- next part --------------
diff -ruN SDL-1.1/src/video/SDL_video.c SDL-1.1.new/src/video/SDL_video.c
— SDL-1.1/src/video/SDL_video.c Sat Sep 23 20:00:51 2000
+++ SDL-1.1.new/src/video/SDL_video.c Sat Oct 14 11:02:09 2000
@@ -935,9 +935,18 @@
memcpy(pal->colors + firstcolor, colors,
ncolors * sizeof(*colors));
SDL_FormatChanged(screen);+

  •   /* If we're changing the shadow surface, match with video */
    
  •   if ((screen == SDL_ShadowSurface) &&
    
  •       (SDL_VideoSurface->format->palette != NULL) ) {
    
  •   	SDL_Palette *pp = SDL_VideoSurface->format->palette;
    
  •           memcpy(pp->colors + firstcolor, colors,
    
  •   	       ncolors * sizeof(*colors));
    
  •   	SDL_FormatChanged(SDL_VideoSurface);
    
  •   }
    
    }
    if(which & SDL_PHYSPAL) {
  •   SDL_Palette *pp;
      SDL_VideoDevice *video = current_video;
          /*
       * Physical palette change: This doesn't affect the
    

@@ -947,22 +956,24 @@
if(!video)
return gotall; /* video not yet initialized */

  •   pp = video->physpal;
    
  •   if(!pp) {
    
  •   	if ((which&SDL_LOGPAL) && !video->gamma)
    
  •   	        pp = pal;
    
  •   	else {
    
  •   		/* Lazy physical palette allocation */
    
  •   		int size;
    
  •   		pp = malloc(sizeof(*pp));
    
  •   		video->physpal = pp;
    
  •   		pp->ncolors = pal->ncolors;
    
  •   		size = pp->ncolors * sizeof(SDL_Color);
    
  •   		pp->colors = malloc(size);
    
  •   		memcpy(pp->colors, pal->colors, size);
    
  •   if ((screen == SDL_ShadowSurface) &&
    
  •       (SDL_VideoSurface->format->palette == NULL) ) {
    
  •   	SDL_Palette *pp = video->physpal;
    
  •   	if(!pp) {
    
  •   		if ( (which&SDL_LOGPAL) && !video->gamma ) {
    
  •   	        	pp = pal;
    
  •   		} else {
    
  •   			/* Lazy physical palette allocation */
    
  •   			int size;
    
  •   			pp = malloc(sizeof(*pp));
    
  •   			video->physpal = pp;
    
  •   			pp->ncolors = pal->ncolors;
    
  •   			size = pp->ncolors * sizeof(SDL_Color);
    
  •   			pp->colors = malloc(size);
    
  •   			memcpy(pp->colors, pal->colors, size);
    
  •   		}
      	}
    
  •   }
    
  •   if(screen == SDL_ShadowSurface) {
      	if(pp != pal) {
      		if ( video->gamma ) {
      	        	SDL_ApplyGamma(video->gamma, colors,

Sam Lantinga wrote:

Here you go, a fix for the DirectX palette bug…

It will go into CVS when I get back from my cousin’s wedding (Monday).

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

It works!

Thanks

Proff–
Florian ‘Proff’ Schulze - florian.proff.schulze at gmx.net
Homepage: - http://proff.fly.to
PGP-Key available from - http://www.keyserver.net/en/