Browse Source

Remove direct calls to SDL_SetPaletteSurface & remove SDL_HWSURFACE

LouYihua 7 years ago
parent
commit
11b1d86215
5 changed files with 41 additions and 29 deletions
  1. 0 2
      common.h
  2. 3 12
      ending.c
  3. 4 14
      main.c
  4. 28 1
      video.c
  5. 6 0
      video.h

+ 0 - 2
common.h

@@ -60,8 +60,6 @@ extern "C"
 # define SDLK_KP9     SDLK_KP_9
 # define SDLK_KP0     SDLK_KP_0
 
-# define SDL_HWSURFACE     0
-
 #else
 
 # ifndef PAL_FATAL_OUTPUT

+ 3 - 12
ending.c

@@ -267,11 +267,7 @@ PAL_ScrollFBP(
       {
          PAL_FadeIn(gpGlobals->wNumPalette, gpGlobals->fNightPalette, 1);
          gpGlobals->fNeedToFadeIn = FALSE;
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-         SDL_SetSurfacePalette(p, gpScreen->format->palette);
-#else
-         SDL_SetPalette(p, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-#endif
+         VIDEO_UpdateSurfacePalette(p, gpScreen);
       }
 
       UTIL_Delay(800 / wScrollSpeed);
@@ -380,13 +376,8 @@ PAL_EndingAnimation(
       {
          PAL_FadeIn(gpGlobals->wNumPalette, gpGlobals->fNightPalette, 1);
          gpGlobals->fNeedToFadeIn = FALSE;
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-         SDL_SetSurfacePalette(pUpper, gpScreen->format->palette);
-         SDL_SetSurfacePalette(pLower, gpScreen->format->palette);
-#else
-         SDL_SetPalette(pUpper, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-         SDL_SetPalette(pLower, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-#endif
+         VIDEO_UpdateSurfacePalette(pUpper, gpScreen);
+         VIDEO_UpdateSurfacePalette(pLower, gpScreen);
       }
 
       UTIL_Delay(50);

+ 4 - 14
main.c

@@ -331,13 +331,8 @@ PAL_SplashScreen(
       }
 
       VIDEO_SetPalette(rgCurrentPalette);
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-	  SDL_SetSurfacePalette(lpBitmapDown, gpScreen->format->palette);
-	  SDL_SetSurfacePalette(lpBitmapUp, gpScreen->format->palette);
-#else
-      SDL_SetPalette(lpBitmapDown, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-      SDL_SetPalette(lpBitmapUp, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-#endif
+      VIDEO_UpdateSurfacePalette(lpBitmapDown, gpScreen);
+      VIDEO_UpdateSurfacePalette(lpBitmapUp, gpScreen);
 
       //
       // Draw the screen
@@ -429,13 +424,8 @@ PAL_SplashScreen(
                   rgCurrentPalette[i].b = (BYTE)(palette[i].b * ((float)dwTime / 15000));
                }
                VIDEO_SetPalette(rgCurrentPalette);
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-			   SDL_SetSurfacePalette(lpBitmapDown, gpScreen->format->palette);
-			   SDL_SetSurfacePalette(lpBitmapUp, gpScreen->format->palette);
-#else
-			   SDL_SetPalette(lpBitmapDown, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-			   SDL_SetPalette(lpBitmapUp, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-#endif
+               VIDEO_UpdateSurfacePalette(lpBitmapDown, gpScreen);
+               VIDEO_UpdateSurfacePalette(lpBitmapUp, gpScreen);
                UTIL_Delay(8);
                dwTime += 250;
             }

+ 28 - 1
video.c

@@ -1124,7 +1124,6 @@ VIDEO_DuplicateSurface(
   Parameters:
 
     [IN]  pSource - the source surface.
-	[IN]  flagsMask - flags that should be taken away from the new surface.
 	[IN]  pRect   - the area to be duplicated, NULL for entire surface.
 
   Return value:
@@ -1142,3 +1141,31 @@ VIDEO_DuplicateSurface(
 
 	return dest;
 }
+
+void
+VIDEO_UpdateSurfacePalette(
+	SDL_Surface    *pSurface,
+	SDL_Surface    *pSource
+)
+/*++
+  Purpose:
+
+    Use the palette from pSource to update the palette of pSurface.
+
+  Parameters:
+
+    [IN]  pSurface - the surface whose palette should be updated.
+	[IN]  pSource  - the surface whose palette is used as source.
+
+  Return value:
+
+    None.
+
+--*/
+{
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+	SDL_SetSurfacePalette(pSurface, pSource->format->palette);
+#else
+	SDL_SetPalette(pSurface, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
+#endif
+}

+ 6 - 0
video.h

@@ -112,6 +112,12 @@ VIDEO_CreateCompatibleSurface(
 	SDL_Surface    *pSource
 );
 
+void
+VIDEO_UpdateSurfacePalette(
+	SDL_Surface    *pSurface,
+	SDL_Surface    *pSource
+);
+
 #ifdef __cplusplus
 }
 #endif