diff --git a/sc2/src/libs/gfxlib.h b/sc2/src/libs/gfxlib.h index 3f1161d70..989d6b421 100644 --- a/sc2/src/libs/gfxlib.h +++ b/sc2/src/libs/gfxlib.h @@ -258,7 +258,7 @@ extern HOT_SPOT MAKE_HOT_SPOT (COORD, COORD); extern INTERSECT_CODE BoxIntersect (RECT *pr1, RECT *pr2, RECT *printer); extern void BoxUnion (RECT *pr1, RECT *pr2, RECT *punion); -enum +typedef enum { FadeAllToWhite = 250, FadeSomeToWhite, @@ -266,7 +266,7 @@ enum FadeAllToColor, FadeSomeToBlack, FadeSomeToColor -}; +} ScreenFadeType; extern BOOLEAN InitGraphics (int argc, char *argv[], COUNT KbytesRequired); @@ -356,6 +356,7 @@ extern DRAWABLE GetFrameParentDrawable (FRAME Frame); extern BOOLEAN SetColorMap (COLORMAPPTR ColorMapPtr); extern DWORD XFormColorMap (COLORMAPPTR ColorMapPtr, SIZE TimeInterval); +extern DWORD FadeScreen (ScreenFadeType fadeType, SIZE TimeInterval); extern void FlushColorXForms (void); #define InitColorMapResources InitStringTableResources #define LoadColorMapFile LoadStringTableFile diff --git a/sc2/src/libs/graphics/cmap.c b/sc2/src/libs/graphics/cmap.c index 1074c3f26..306891299 100644 --- a/sc2/src/libs/graphics/cmap.c +++ b/sc2/src/libs/graphics/cmap.c @@ -17,23 +17,12 @@ */ #include "gfx_common.h" -#include "libs/tasklib.h" +#include "libs/timelib.h" #include "libs/inplib.h" #include "libs/log.h" #include -static struct -{ - COLORMAPPTR CMapPtr; - SIZE Ticks; - union - { - COUNT NumCycles; - Task XFormTask; - } tc; -} FadeControl; - typedef struct xform_control { int CMapIndex; // -1 means unused @@ -53,8 +42,10 @@ static struct Mutex Lock; } XFormControl; -volatile int FadeAmount = FADE_NORMAL_INTENSITY; -static volatile int FadeEnd, XForming; +static int fadeAmount = FADE_NORMAL_INTENSITY; +static int fadeDelta; +static TimeCount fadeStartTime; +static sint32 fadeInterval; #define SPARE_COLORMAPS 20 #define MAP_POOL_SIZE (MAX_COLORMAPS + SPARE_COLORMAPS) @@ -313,63 +304,59 @@ SetColorMap (COLORMAPPTR map) /* Fade Transforms */ -static int -fade_xform_task (void *data) +int +GetFadeAmount (void) { - SIZE TDelta, TTotal; - DWORD CurTime; - Task task = (Task)data; + int newAmount; - XForming = TRUE; - while (FadeControl.tc.XFormTask == 0 - && (!Task_ReadState (task, TASK_EXIT))) - TaskSwitch (); - TTotal = FadeControl.Ticks; - FadeControl.tc.XFormTask = 0; + LockMutex (XFormControl.Lock); - { - CurTime = GetTimeCounter (); - do - { - DWORD StartTime; + if (fadeInterval) + { // have a pending fade + TimeCount Now = GetTimeCounter (); + sint32 elapsed; + + elapsed = Now - fadeStartTime; + if (elapsed > fadeInterval) + elapsed = fadeInterval; - StartTime = CurTime; - SleepThreadUntil (CurTime + ONE_SECOND / 60); - CurTime = GetTimeCounter (); - if (!XForming || (TDelta = (SIZE)(CurTime - StartTime)) > TTotal) - TDelta = TTotal; + newAmount = fadeAmount + (long)fadeDelta * elapsed / fadeInterval; - FadeAmount += (FadeEnd - FadeAmount) * TDelta / TTotal; - //log_add (log_Debug, "fade_xform_task FadeAmount %d\n", FadeAmount); - } while ((TTotal -= TDelta) && (!Task_ReadState (task, TASK_EXIT))); + if (elapsed >= fadeInterval) + { // fade is over + fadeAmount = newAmount; + fadeInterval = 0; + } + } + else + { // no fade pending, return the current + newAmount = fadeAmount; } - XForming = FALSE; + UnlockMutex (XFormControl.Lock); - FinishTask (task); - return 0; + return newAmount; } static void FlushFadeXForms (void) { - if (XForming) - { - XForming = FALSE; - TaskSwitch (); + LockMutex (XFormControl.Lock); + if (fadeInterval) + { // end the fade immediately + fadeAmount += fadeDelta; + fadeInterval = 0; } + UnlockMutex (XFormControl.Lock); } -static DWORD -XFormFade (COLORMAPPTR ColorMapPtr, SIZE TimeInterval) +DWORD +FadeScreen (ScreenFadeType fadeType, SIZE TimeInterval) { - BYTE what; - DWORD TimeOut; + TimeCount TimeOut; + int FadeEnd; - FlushFadeXForms (); - - what = *ColorMapPtr; - switch (what) + switch (fadeType) { case FadeAllToBlack: case FadeSomeToBlack: @@ -387,24 +374,26 @@ XFormFade (COLORMAPPTR ColorMapPtr, SIZE TimeInterval) return (GetTimeCounter ()); } - FadeControl.Ticks = TimeInterval; - if (FadeControl.Ticks <= 0 || - (FadeControl.tc.XFormTask = AssignTask (fade_xform_task, - 1024, "fade transform")) == 0) - { - FadeAmount = FadeEnd; + LockMutex (XFormControl.Lock); + + if (TimeInterval <= 0) + { // end the fade immediately + fadeAmount = FadeEnd; + // cancel any pending fades + fadeInterval = 0; TimeOut = GetTimeCounter (); } else { - do - TaskSwitch (); - while (FadeControl.tc.XFormTask); - - TimeOut = GetTimeCounter () + TimeInterval + 1; + fadeInterval = TimeInterval; + fadeDelta = FadeEnd - fadeAmount; + fadeStartTime = GetTimeCounter (); + TimeOut = fadeStartTime + TimeInterval + 1; } - return (TimeOut); + UnlockMutex (XFormControl.Lock); + + return TimeOut; } /* Colormap Transforms */ @@ -598,23 +587,16 @@ XFormPLUT (COLORMAPPTR ColorMapPtr, SIZE TimeInterval) return (EndTime); } - DWORD XFormColorMap (COLORMAPPTR ColorMapPtr, SIZE TimeInterval) { - int what; - if (!ColorMapPtr) return (0); if (QuitPosted) // Don't make users wait for fades TimeInterval = 0; - what = *ColorMapPtr; - if (what >= (int)FadeAllToWhite && what <= (int)FadeSomeToColor) - return XFormFade (ColorMapPtr, TimeInterval); - else - return XFormPLUT (ColorMapPtr, TimeInterval); + return XFormPLUT (ColorMapPtr, TimeInterval); } void diff --git a/sc2/src/libs/graphics/cmap.h b/sc2/src/libs/graphics/cmap.h index 93c1f77bb..fb21d8008 100644 --- a/sc2/src/libs/graphics/cmap.h +++ b/sc2/src/libs/graphics/cmap.h @@ -47,7 +47,7 @@ typedef struct tfb_colormap struct tfb_colormap *next; } TFB_ColorMap; -extern volatile int FadeAmount; +extern int GetFadeAmount (void); extern void InitColorMaps (void); extern void UninitColorMaps (void); diff --git a/sc2/src/libs/graphics/sdl/sdl_common.c b/sc2/src/libs/graphics/sdl/sdl_common.c index f88960992..8b02c11aa 100644 --- a/sc2/src/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/libs/graphics/sdl/sdl_common.c @@ -253,7 +253,7 @@ TFB_SwapBuffers (int force_full_redraw) static int last_fade_amount = 255, last_transition_amount = 255; static int fade_amount = 255, transition_amount = 255; - fade_amount = FadeAmount; + fade_amount = GetFadeAmount (); transition_amount = TransitionAmount; if (force_full_redraw == TFB_REDRAW_NO && !TFB_BBox.valid && @@ -618,7 +618,7 @@ TFB_FlushGraphics (void) // Only call from main thread!! { static int last_fade = 255; static int last_transition = 255; - int current_fade = FadeAmount; + int current_fade = GetFadeAmount (); int current_transition = TransitionAmount; if ((current_fade != 255 && current_fade != last_fade) || diff --git a/sc2/src/uqm/comm.c b/sc2/src/uqm/comm.c index 79ecb29b8..5b4ba622c 100644 --- a/sc2/src/uqm/comm.c +++ b/sc2/src/uqm/comm.c @@ -750,9 +750,8 @@ CommIntroTransition (void) } else if (curIntroMode == CIM_FADE_IN_SCREEN) { - BYTE clut_buf[] = {FadeAllToColor}; UnbatchGraphics (); - XFormColorMap ((COLORMAPPTR)clut_buf, fadeTime); + FadeScreen (FadeAllToColor, fadeTime); } else { // Uknown transition diff --git a/sc2/src/uqm/credits.c b/sc2/src/uqm/credits.c index 97f5b0824..72b128da4 100644 --- a/sc2/src/uqm/credits.c +++ b/sc2/src/uqm/credits.c @@ -776,7 +776,6 @@ on_input_frame (void) void Credits (BOOLEAN WithOuttakes) { - BYTE fade_buf[1]; MUSIC_REF hMusic; CREDITS_INPUT_STATE cis; RECT screenRect; @@ -801,8 +800,7 @@ Credits (BOOLEAN WithOuttakes) s.frame = CreditsBack; LockMutex (GraphicsLock); DrawStamp (&s); - fade_buf[0] = FadeAllToColor; - XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND / 2); + FadeScreen (FadeAllToColor, ONE_SECOND / 2); UnlockMutex (GraphicsLock); // set the position of outtakes comm @@ -842,8 +840,7 @@ Credits (BOOLEAN WithOuttakes) LockMutex (GraphicsLock); SetContext (ScreenContext); - fade_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND / 2)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); FlushColorXForms (); UnlockMutex (GraphicsLock); diff --git a/sc2/src/uqm/fmv.c b/sc2/src/uqm/fmv.c index 6d982de78..96176471a 100644 --- a/sc2/src/uqm/fmv.c +++ b/sc2/src/uqm/fmv.c @@ -35,14 +35,12 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic) { #ifdef WANT_SHIP_SPINS char vnbuf[32]; - BYTE clut_buf[1]; RECT old_r; LoadIntoExtraScreen (NULL); #if 0 /* This is cut out right now but should be part of the 3DO side */ - clut_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 4)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 4)); FlushColorXForms (); #endif @@ -55,8 +53,7 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic) sprintf (vnbuf, "slides.spins.%02u", (unsigned)index); ShowPresentation (vnbuf); - clut_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 4)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 4)); FlushColorXForms (); GetContextClipRect (&old_r); @@ -67,8 +64,7 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic) if (hMusic) PlayMusic (hMusic, TRUE, 1); - clut_buf[0] = FadeAllToColor; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 4)); + SleepThreadUntil (FadeScreen (FadeAllToColor, ONE_SECOND / 4)); FlushColorXForms (); #else (void) index; /* Satisfy compiler */ @@ -79,13 +75,10 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic) void SplashScreen (void (* DoProcessing)(DWORD TimeOut)) { - BYTE xform_buf[1]; STAMP s; DWORD TimeOut; - xform_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ( - (COLORMAPPTR) xform_buf, ONE_SECOND / 120)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 120)); LockMutex (GraphicsLock); SetContext (ScreenContext); s.origin.x = s.origin.y = 0; @@ -94,8 +87,7 @@ SplashScreen (void (* DoProcessing)(DWORD TimeOut)) DestroyDrawable (ReleaseDrawable (s.frame)); UnlockMutex (GraphicsLock); - xform_buf[0] = FadeAllToColor; - TimeOut = XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2); + TimeOut = FadeScreen (FadeAllToColor, ONE_SECOND / 2); if (DoProcessing) DoProcessing (TimeOut); @@ -118,35 +110,26 @@ SplashScreen (void (* DoProcessing)(DWORD TimeOut)) } GLOBAL (CurrentActivity) &= ~CHECK_ABORT; - xform_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); } void Introduction (void) { - BYTE xform_buf[1]; - ShowPresentation (INTROPRES_STRTAB); - - xform_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); } void Victory (void) { - BYTE xform_buf[1]; - - xform_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); /* by default we do 3DO cinematics; or PC slides when 3DO files are * not present */ ShowPresentation (FINALPRES_STRTAB); - xform_buf[0] = FadeAllToBlack; - XFormColorMap ((COLORMAPPTR)xform_buf, 0); + FadeScreen (FadeAllToBlack, 0); } void diff --git a/sc2/src/uqm/gameopt.c b/sc2/src/uqm/gameopt.c index 3b4ff895b..40bbe025c 100644 --- a/sc2/src/uqm/gameopt.c +++ b/sc2/src/uqm/gameopt.c @@ -1052,10 +1052,8 @@ ChangeGameSelection: } if (LastActivity == CHECK_LOAD && first_time) { - BYTE clut_buf[] = {FadeAllToColor}; - UnbatchGraphics (); - XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 2); + FadeScreen (FadeAllToColor, ONE_SECOND / 2); } else { diff --git a/sc2/src/uqm/intro.c b/sc2/src/uqm/intro.c index e44b3c4fe..4608805b3 100644 --- a/sc2/src/uqm/intro.c +++ b/sc2/src/uqm/intro.c @@ -114,12 +114,11 @@ ParseColorString (const char *Src, Color* pColor) static BOOLEAN DoFadeScreen (PRESENTATION_INPUT_STATE* pPIS, const char *Src, BYTE FadeType) { - BYTE xform_buf[1] = {FadeType}; int msecs; if (1 == sscanf (Src, "%d", &msecs)) { - pPIS->TimeOut = XFormColorMap ((COLORMAPPTR) xform_buf, - (SIZE)(msecs * ONE_SECOND / 1000)) + ONE_SECOND / 10; + pPIS->TimeOut = FadeScreen (FadeType, msecs * ONE_SECOND / 1000) + + ONE_SECOND / 10; pPIS->TimeOutOnSkip = FALSE; } return TRUE; @@ -851,11 +850,7 @@ DoVideoInput (void *pIS) static void FadeClearScreen (void) { - BYTE xform_buf[1]; - - xform_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ( - (COLORMAPPTR) xform_buf, ONE_SECOND / 2)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); // clear the screen with black LockMutex (GraphicsLock); @@ -864,9 +859,7 @@ FadeClearScreen (void) ClearDrawable (); UnlockMutex (GraphicsLock); - // fade in black rect instantly - xform_buf[0] = FadeAllToColor; - XFormColorMap ((COLORMAPPTR) xform_buf, 0); + FadeScreen (FadeAllToColor, 0); } static BOOLEAN diff --git a/sc2/src/uqm/melee.c b/sc2/src/uqm/melee.c index 50bc8c3a9..d894c08ed 100644 --- a/sc2/src/uqm/melee.c +++ b/sc2/src/uqm/melee.c @@ -1678,11 +1678,9 @@ static void StartMelee (MELEE_STATE *pMS) { { - BYTE black_buf[] = {FadeAllToBlack}; - FadeMusic (0, ONE_SECOND / 2); - SleepThreadUntil (XFormColorMap ( - (COLORMAPPTR)black_buf, ONE_SECOND / 2) + ONE_SECOND / 60); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2) + + ONE_SECOND / 60); FlushColorXForms (); StopMusic (); } @@ -1712,14 +1710,10 @@ StartMelee (MELEE_STATE *pMS) if (GLOBAL (CurrentActivity) & CHECK_ABORT) return; - { - BYTE black_buf[] = { FadeAllToBlack }; - - SleepThreadUntil (XFormColorMap ( - (COLORMAPPTR)black_buf, ONE_SECOND / 2) - + ONE_SECOND / 60); - FlushColorXForms (); - } + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2) + + ONE_SECOND / 60); + FlushColorXForms (); + } while (0 /* !(GLOBAL (CurrentActivity) & CHECK_ABORT) */); GLOBAL (CurrentActivity) = SUPER_MELEE; @@ -2099,11 +2093,8 @@ DoMelee (MELEE_STATE *pMS) LockMutex (GraphicsLock); InitMelee (pMS); UnlockMutex (GraphicsLock); - { - BYTE clut_buf[] = {FadeAllToColor}; - - XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 2); - } + + FadeScreen (FadeAllToColor, ONE_SECOND / 2); pMS->LastInputTime = GetTimeCounter (); return TRUE; } diff --git a/sc2/src/uqm/pickmele.c b/sc2/src/uqm/pickmele.c index 02de2864e..b29053cf6 100644 --- a/sc2/src/uqm/pickmele.c +++ b/sc2/src/uqm/pickmele.c @@ -696,12 +696,9 @@ GetInitialMeleeStarShips (HSTARSHIP *result) } // Fade in - { - BYTE fade_buf[] = {FadeAllToColor}; - SleepThreadUntil (XFormColorMap - ((COLORMAPPTR) fade_buf, ONE_SECOND / 2) + ONE_SECOND / 60); - FlushColorXForms (); - } + SleepThreadUntil (FadeScreen (FadeAllToColor, ONE_SECOND / 2) + + ONE_SECOND / 60); + FlushColorXForms (); playerMask = 0; for (playerI = 0; playerI < NUM_PLAYERS; playerI++) diff --git a/sc2/src/uqm/planets/devices.c b/sc2/src/uqm/planets/devices.c index 022eb3b4f..9cb13bdad 100644 --- a/sc2/src/uqm/planets/devices.c +++ b/sc2/src/uqm/planets/devices.c @@ -306,19 +306,14 @@ DeviceFailed (BYTE which_device) if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY && playerInPlanetOrbit ()) { - BYTE fade_buf[1]; - PlayMenuSound (MENU_SOUND_INVOKED); - fade_buf[0] = FadeAllToWhite; - SleepThreadUntil ( - XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND * 1) + SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND * 1) + (ONE_SECOND * 2)); if (CurStarDescPtr->Index != CHMMR_DEFINED || pSolarSysState->pOrbitalDesc != &pSolarSysState->PlanetDesc[1]) { - fade_buf[0] = FadeAllToColor; - XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND * 2); + FadeScreen (FadeAllToColor, ONE_SECOND * 2); } else { diff --git a/sc2/src/uqm/planets/generate/genpet.c b/sc2/src/uqm/planets/generate/genpet.c index db1f64502..32ea1c673 100644 --- a/sc2/src/uqm/planets/generate/genpet.c +++ b/sc2/src/uqm/planets/generate/genpet.c @@ -239,9 +239,7 @@ ZapToUrquanEncounter (void) { #define LOST_DAYS 15 - BYTE black_buf[] = {FadeAllToBlack}; - - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND * 2)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND * 2)); LockMutex (GraphicsLock); MoveGameClockDays (LOST_DAYS); UnlockMutex (GraphicsLock); diff --git a/sc2/src/uqm/planets/solarsys.c b/sc2/src/uqm/planets/solarsys.c index de8c756c7..ae41615d1 100644 --- a/sc2/src/uqm/planets/solarsys.c +++ b/sc2/src/uqm/planets/solarsys.c @@ -1379,12 +1379,10 @@ InitSolarSys (void) if (LastActivity == (CHECK_LOAD | CHECK_RESTART)) { // Starting a new game, NOT from load! // We have to fade the screen in from intro or menu - BYTE clut_buf[] = {FadeAllToColor}; - DrawOuterSystem (); RedrawQueue (FALSE); UnbatchGraphics (); - XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 2); + FadeScreen (FadeAllToColor, ONE_SECOND / 2); LastActivity = 0; } diff --git a/sc2/src/uqm/restart.c b/sc2/src/uqm/restart.c index 8dc507e0c..1a2d530b6 100644 --- a/sc2/src/uqm/restart.c +++ b/sc2/src/uqm/restart.c @@ -141,11 +141,7 @@ DoRestart (MENU_STATE *pMS) LastInputTime = GetTimeCounter (); pMS->Initialized = TRUE; - { - BYTE clut_buf[] = {FadeAllToColor}; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, - ONE_SECOND / 2)); - } + SleepThreadUntil (FadeScreen (FadeAllToColor, ONE_SECOND / 2)); } else if (GLOBAL (CurrentActivity) & CHECK_ABORT) { @@ -153,8 +149,6 @@ DoRestart (MENU_STATE *pMS) } else if (PulsedInputState.menu[KEY_MENU_SELECT]) { - BYTE fade_buf[1]; - switch (pMS->CurState) { case LOAD_SAVED_GAME: @@ -185,10 +179,7 @@ DoRestart (MENU_STATE *pMS) UnbatchGraphics (); return TRUE; case QUIT_GAME: - fade_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ( - (COLORMAPPTR)fade_buf, ONE_SECOND / 2)); - + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); GLOBAL (CurrentActivity) = CHECK_ABORT; break; } @@ -270,13 +261,10 @@ static BOOLEAN RestartMenu (MENU_STATE *pMS) { TimeCount TimeOut; - BYTE black_buf[1]; ReinitQueue (&race_q[0]); ReinitQueue (&race_q[1]); - black_buf[0] = FadeAllToBlack; - SetContext (ScreenContext); GLOBAL (CurrentActivity) |= CHECK_ABORT; @@ -284,12 +272,10 @@ RestartMenu (MENU_STATE *pMS) && GET_GAME_STATE (UTWIG_BOMB_ON_SHIP) && !GET_GAME_STATE (UTWIG_BOMB)) { // player blew himself up with Utwig bomb - BYTE white_buf[] = {FadeAllToWhite}; - SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0); - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)white_buf, - ONE_SECOND / 8) + ONE_SECOND / 60); + SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND / 8) + + ONE_SECOND / 60); SetContextBackGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); ClearDrawable (); @@ -316,7 +302,7 @@ RestartMenu (MENU_STATE *pMS) LastActivity = 0; NextActivity = 0; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, TimeOut)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, TimeOut)); if (TimeOut == ONE_SECOND / 8) SleepThread (ONE_SECOND * 3); DrawRestartMenuGraphic (pMS); @@ -341,7 +327,7 @@ RestartMenu (MENU_STATE *pMS) if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); // quit - TimeOut = XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND / 2); + TimeOut = FadeScreen (FadeAllToBlack, ONE_SECOND / 2); SleepThreadUntil (TimeOut); FlushColorXForms (); @@ -373,9 +359,7 @@ TryStartGame (void) } else if (GLOBAL (CurrentActivity) == (ACTIVITY)~0) { // timed out - BYTE black_buf[] = {FadeAllToBlack}; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, - ONE_SECOND / 2)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); return (FALSE); } else if (GLOBAL (CurrentActivity) & CHECK_ABORT) diff --git a/sc2/src/uqm/starbase.c b/sc2/src/uqm/starbase.c index 05af8e150..2aaf8ed5f 100644 --- a/sc2/src/uqm/starbase.c +++ b/sc2/src/uqm/starbase.c @@ -443,10 +443,7 @@ static void DoTimePassage (void) { #define LOST_DAYS 14 - BYTE clut_buf[1]; - - clut_buf[0] = FadeAllToBlack; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND * 2)); + SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND * 2)); LockMutex (GraphicsLock); MoveGameClockDays (LOST_DAYS); UnlockMutex (GraphicsLock); @@ -556,8 +553,6 @@ CleanupAfterStarBase (void) void InstallBombAtEarth (void) { - BYTE clut_buf[1]; - DoTimePassage (); LockMutex (GraphicsLock); @@ -567,8 +562,7 @@ InstallBombAtEarth (void) ClearDrawable (); UnlockMutex (GraphicsLock); - clut_buf[0] = FadeAllToColor; - SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, 0)); + SleepThreadUntil (FadeScreen (FadeAllToColor, 0)); SET_GAME_STATE (CHMMR_BOMB_STATE, 3); /* bomb processed */ GLOBAL (CurrentActivity) = CHECK_LOAD; /* fake a load game */