Added fading support for pure mode also.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@62 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2002-09-22 14:38:39 +00:00
parent 5cc745b316
commit 5bde3a9be6
3 changed files with 42 additions and 29 deletions
-5
View File
@@ -41,11 +41,6 @@ static TFB_Palette cmap_rgb[256];
static int cmap_type = 0; static int cmap_type = 0;
int TFB_GetFadeStatus ()
{
return XForming;
}
int TFB_GetFadeAmount () int TFB_GetFadeAmount ()
{ {
return cur; return cur;
-1
View File
@@ -52,7 +52,6 @@ enum
extern DWORD* _varPLUTs; extern DWORD* _varPLUTs;
int TFB_GetFadeStatus ();
int TFB_GetFadeAmount (); int TFB_GetFadeAmount ();
BOOLEAN TFB_HasColorMap (); BOOLEAN TFB_HasColorMap ();
int TFB_GetColorMapType (); int TFB_GetColorMapType ();
+42 -23
View File
@@ -20,6 +20,10 @@
#include "libs/graphics/sdl/pure.h" #include "libs/graphics/sdl/pure.h"
static SDL_Surface *fade_black;
static SDL_Surface *fade_white;
static SDL_Surface *fade_temp;
int int
TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp) TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
@@ -53,15 +57,16 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
ScreenWidth = 320; ScreenWidth = 320;
ScreenHeight = 240; ScreenHeight = 240;
// must use SDL_SWSURFACE, HWSURFACE doesn't work properly with fades/scaling
if (width == 320 && height == 240) if (width == 320 && height == 240)
{ {
videomode_flags = SDL_HWSURFACE; videomode_flags = SDL_SWSURFACE;
ScreenWidthActual = 320; ScreenWidthActual = 320;
ScreenHeightActual = 240; ScreenHeightActual = 240;
} }
else else
{ {
videomode_flags = SDL_SWSURFACE; // cannot be HWSURFACE because of our scaling routine videomode_flags = SDL_SWSURFACE;
ScreenWidthActual = 640; ScreenWidthActual = 640;
ScreenHeightActual = 480; ScreenHeightActual = 480;
@@ -96,26 +101,20 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
if (test_extra == NULL) if (test_extra == NULL)
{ {
printf("Couldn't create back buffer: %s\n", printf("Couldn't create back buffer: %s\n", SDL_GetError());
SDL_GetError());
exit(-1); exit(-1);
} }
SDL_Screen = SDL_DisplayFormat(test_extra); SDL_Screen = SDL_DisplayFormat (test_extra);
SDL_FreeSurface(test_extra); ExtraScreen = SDL_DisplayFormat (test_extra);
test_extra = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32, fade_white = SDL_DisplayFormat (test_extra);
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000); SDL_FillRect (fade_white, NULL, SDL_MapRGB (fade_white->format, 255, 255, 255));
fade_black = SDL_DisplayFormat (test_extra);
SDL_FillRect (fade_black, NULL, SDL_MapRGB (fade_black->format, 0, 0, 0));
fade_temp = SDL_DisplayFormat (test_extra);
if (test_extra == NULL) SDL_FreeSurface (test_extra);
{
printf("Couldn't create workspace buffer: %s\n",
SDL_GetError());
exit(-1);
}
ExtraScreen = SDL_DisplayFormat(test_extra);
SDL_FreeSurface(test_extra);
if (SDL_Video->format->BytesPerPixel != SDL_Screen->format->BytesPerPixel) if (SDL_Video->format->BytesPerPixel != SDL_Screen->format->BytesPerPixel)
{ {
@@ -130,21 +129,41 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
void void
TFB_Pure_SwapBuffers () TFB_Pure_SwapBuffers ()
{ {
SDL_Surface *backbuffer = SDL_Screen;
int fade_amount = TFB_GetFadeAmount ();
if (fade_amount != 255)
{
backbuffer = fade_temp;
SDL_BlitSurface (SDL_Screen, NULL, backbuffer, NULL);
if (fade_amount < 255)
{
SDL_SetAlpha (fade_black, SDL_SRCALPHA, 255 - fade_amount);
SDL_BlitSurface (fade_black, NULL, backbuffer, NULL);
}
else
{
SDL_SetAlpha (fade_white, SDL_SRCALPHA, 255 - (255 - fade_amount));
SDL_BlitSurface (fade_white, NULL, backbuffer, NULL);
}
}
if (ScreenWidth == 320 && ScreenHeight == 240 && if (ScreenWidth == 320 && ScreenHeight == 240 &&
ScreenWidthActual == 640 && ScreenHeightActual == 480) ScreenWidthActual == 640 && ScreenHeightActual == 480)
{ {
// scales SDL_Screen to SDL_Video (640x480) // scales 320x240 backbuffer to 640x480
int x, y; int x, y;
Uint8 *src_p, *src_p2, *dst_p; Uint8 *src_p, *src_p2, *dst_p;
SDL_LockSurface (SDL_Video); SDL_LockSurface (SDL_Video);
SDL_LockSurface (SDL_Screen); SDL_LockSurface (backbuffer);
src_p = SDL_Screen->pixels; src_p = backbuffer->pixels;
dst_p = SDL_Video->pixels; dst_p = SDL_Video->pixels;
switch (SDL_Screen->format->BytesPerPixel) switch (backbuffer->format->BytesPerPixel)
{ {
case 1: case 1:
{ {
@@ -262,13 +281,13 @@ TFB_Pure_SwapBuffers ()
} }
} }
SDL_UnlockSurface (SDL_Screen); SDL_UnlockSurface (backbuffer);
SDL_UnlockSurface (SDL_Video); SDL_UnlockSurface (SDL_Video);
} }
else else
{ {
// resolution is 320x240 so we can blit directly // resolution is 320x240 so we can blit directly
SDL_BlitSurface (SDL_Screen, NULL, SDL_Video, NULL); SDL_BlitSurface (backbuffer, NULL, SDL_Video, NULL);
} }
SDL_UpdateRect (SDL_Video, 0, 0, 0, 0); SDL_UpdateRect (SDL_Video, 0, 0, 0, 0);