Fixed bug #33; Crossfades are consistent and don't glitch anymore

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@891 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2003-03-16 18:38:48 +00:00
parent 441ef5c97f
commit acc4111de8
15 changed files with 117 additions and 90 deletions
+3
View File
@@ -1,4 +1,7 @@
Changes towards version 0.3:
- Crossfade code now explicitly caches the screen to transition from, and
thus no longer glitches. The code needed a slight rewrite, but this
does fix bug #33 -McMartin
- Melee scaling is now trilinear by default, but it's still possible to
choose nearest neighbour with --meleescale; fixes #34 -Mika
- Minimum scaling extent is now 1,1; fixes mostly small-objects-disappearing
+18 -15
View File
@@ -188,7 +188,7 @@ Battle (void)
if (num_ships)
{
DWORD NextTime;
BOOLEAN first_time;
BOOLEAN first_time;
GLOBAL (CurrentActivity) |= IN_BATTLE;
battle_counter = MAKE_WORD (
@@ -204,27 +204,30 @@ BOOLEAN first_time;
BattleSong (TRUE);
NextTime = 0;
first_time = (BOOLEAN)(LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE);
first_time = (BOOLEAN)(LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE);
do
{
extern UWORD nth_frame;
RECT r;
BatchGraphics ();
if (first_time)
{
r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT;
SetTransitionSource (&r);
}
BatchGraphics ();
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
SeedUniverse ();
RedrawQueue (TRUE);
if (first_time)
{
RECT r;
first_time = FALSE;
r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT;
ScreenTransition (3, &r);
}
UnbatchGraphics ();
if (first_time)
{
first_time = FALSE;
ScreenTransition (3, &r);
}
UnbatchGraphics ();
ClearSemaphore (GraphicsSem);
if (nth_frame)
TaskSwitch ();
+4 -1
View File
@@ -1492,7 +1492,9 @@ static BOOLEAN
DoCommunication (INPUT_STATE InputState, PENCOUNTER_STATE pES)
{
if (!(CommData.AlienTransitionDesc.AnimFlags & (TALK_INTRO | TALK_DONE)))
{
AlienTalkSegue ((COUNT)~0);
}
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
;
@@ -1719,7 +1721,8 @@ HailAlien (void)
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
BatchGraphics ();
SetTransitionSource (NULL);
BatchGraphics ();
if (LOBYTE (GLOBAL (CurrentActivity)) == WON_LAST_BATTLE)
{
r.corner.x = (SCREEN_WIDTH - SIS_SCREEN_WIDTH) >> 1;
+1
View File
@@ -84,6 +84,7 @@ FreeHyperData ();
TimeIn = GetTimeCounter ();
for (i = 1; i < NUM_CREDITS; ++i)
{
SetTransitionSource (&r);
BatchGraphics ();
s.frame = f[0];
DrawStamp (&s);
+11 -9
View File
@@ -169,7 +169,7 @@ InitEncounter (void)
STAMP s;
TEXT t;
extern FRAME planet[];
MUSIC_REF MR;
MUSIC_REF MR;
SetSemaphore (GraphicsSem);
@@ -178,17 +178,18 @@ MUSIC_REF MR;
SetContext (SpaceContext);
SetContextFont (TinyFont);
MR = LoadMusicInstance (REDALERT_MUSIC);
PlayMusic (MR, FALSE, 1);
MR = LoadMusicInstance (REDALERT_MUSIC);
PlayMusic (MR, FALSE, 1);
SegueFrame = CaptureDrawable (LoadGraphic (SEGUE_PMAP_ANIM));
ClearSemaphore (GraphicsSem);
while (PLRPlaying (MR))
TaskSwitch ();
StopMusic ();
DestroyMusic (MR);
SetSemaphore (GraphicsSem);
ClearSemaphore (GraphicsSem);
while (PLRPlaying (MR))
TaskSwitch ();
StopMusic ();
DestroyMusic (MR);
SetSemaphore (GraphicsSem);
s.origin.x = s.origin.y = 0;
SetTransitionSource (NULL);
BatchGraphics ();
SetContextBackGroundColor (BLACK_COLOR);
@@ -293,6 +294,7 @@ SetSemaphore (GraphicsSem);
UnbatchGraphics ();
DestroyDrawable (ReleaseDrawable (SegueFrame));
ScreenTransition (3, NULL);
SetResourceIndex (hOldIndex);
+30 -35
View File
@@ -909,6 +909,7 @@ DoPickGame (INPUT_STATE InputState, PMENU_STATE pMS)
}
SetSemaphore (GraphicsSem);
SetTransitionSource (NULL);
BatchGraphics ();
Restart:
SetContext (SpaceContext);
@@ -927,20 +928,20 @@ Restart:
SetFlashRect ((PRECT)~0L, (FRAME)0);
ClearSemaphore (GraphicsSem);
pMS->ModuleFrame = 0;
pMS->ModuleFrame = 0;
pMS->CurState = (BYTE)pMS->delta_item;
ResumeMusic ();
if (pSolarSysState)
{
ResumeMusic ();
if (pSolarSysState)
{
#define DRAW_REFRESH (1 << 5)
#define REPAIR_SCAN (1 << 6)
extern BYTE draw_sys_flags;
extern BYTE draw_sys_flags;
if (pSolarSysState->MenuState.Initialized < 3)
draw_sys_flags |= DRAW_REFRESH;
else if (pSolarSysState->MenuState.Initialized == 4)
draw_sys_flags |= REPAIR_SCAN;
}
if (pSolarSysState->MenuState.Initialized < 3)
draw_sys_flags |= DRAW_REFRESH;
else if (pSolarSysState->MenuState.Initialized == 4)
draw_sys_flags |= REPAIR_SCAN;
}
return (FALSE);
}
else if (InputState & DEVICE_BUTTON1)
@@ -980,26 +981,21 @@ RetrySave:
goto Restart;
}
ResumeMusic ();
if (pSolarSysState)
{
if (pSolarSysState)
{
#define DRAW_REFRESH (1 << 5)
#define REPAIR_SCAN (1 << 6)
extern BYTE draw_sys_flags;
extern BYTE draw_sys_flags;
if (pSolarSysState->MenuState.Initialized < 3)
draw_sys_flags |= DRAW_REFRESH;
else if (pSolarSysState->MenuState.Initialized == 4)
draw_sys_flags |= REPAIR_SCAN;
}
if (pSolarSysState->MenuState.Initialized < 3)
draw_sys_flags |= DRAW_REFRESH;
else if (pSolarSysState->MenuState.Initialized == 4)
draw_sys_flags |= REPAIR_SCAN;
}
}
else
{
extern BOOLEAN
LoadGame
(COUNT
which_game,
SUMMARY_DESC
*summary_desc);
extern BOOLEAN LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc);
ConfirmSaveLoad (0);
if (LoadGame ((COUNT)pMS->CurState, NULL_PTR))
@@ -1008,7 +1004,7 @@ if (pSolarSysState)
SetFlashRect (NULL_PTR, (FRAME)0);
ClearSemaphore (GraphicsSem);
pMS->ModuleFrame = 0;
pMS->ModuleFrame = 0;
pMS->CurState = (BYTE)pMS->delta_item;
return (FALSE);
}
@@ -1029,7 +1025,9 @@ pMS->ModuleFrame = 0;
if (NewState != pMS->CurState)
{
RECT r;
SetSemaphore (GraphicsSem);
BatchGraphics ();
if (((SUMMARY_DESC *)pMS->CurString)[NewState].year_index != 0)
{
@@ -1070,26 +1068,22 @@ ChangeGameSelection:
{
if (first_time)
{
RECT r;
r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT;
ScreenTransition (3, &r);
}
UnbatchGraphics ();
}
{
RECT r;
r.corner.x = 3 + (NewState * 21);
r.corner.y = 176;
r.extent.width = 18;
r.extent.height = 18;
SetFlashRect (&r, (FRAME)0);
r.corner.x = 3 + (NewState * 21);
r.corner.y = 176;
r.extent.width = 18;
r.extent.height = 18;
SetFlashRect (&r, (FRAME)0);
}
ClearSemaphore (GraphicsSem);
}
}
@@ -1153,6 +1147,7 @@ PickGame (PMENU_STATE
|| !(pSolarSysState
&& pSolarSysState->MenuState.Initialized < 3))
{
SetTransitionSource (&DlgRect);
BatchGraphics ();
DrawStamp(&DlgStamp);
ScreenTransition (3, &DlgRect);
@@ -56,6 +56,7 @@ void SetGraphicGrabOther (int grab_other);
void SetGraphicScale (int scale);
int GetGraphicScale (void);
void SetGraphicUseOtherExtra (int other);
void SetTransitionSource (PRECT pRect);
void ScreenTransition (int transition, PRECT pRect);
extern float FrameRate;
@@ -114,6 +114,12 @@ transition_task_func (void *data)
return 0;
}
void
SetTransitionSource (PRECT pRect)
{
TFB_DrawScreen_Copy(pRect, TFB_SCREEN_MAIN, TFB_SCREEN_TRANSITION);
}
// Status: Implemented
void
ScreenTransition (int TransType, PRECT pRect)
@@ -140,8 +146,6 @@ ScreenTransition (int TransType, PRECT pRect)
TransitionClipRect.h = ScreenHeight;
}
SDL_BlitSurface (SDL_Screen, &TransitionClipRect, TransitionScreen, &TransitionClipRect);
#ifdef HAVE_OPENGL
if (GraphicsDriver == TFB_GFXDRIVER_SDL_OPENGL)
{
+1
View File
@@ -600,6 +600,7 @@ DoOutfit (INPUT_STATE InputState, PMENU_STATE pMS)
LoadGraphic (OUTFIT_PMAP_ANIM)
);
SetTransitionSource (NULL);
BatchGraphics ();
DrawSISFrame ();
SetSemaphore(GraphicsSem);
+2
View File
@@ -1515,6 +1515,7 @@ InitPlanetSide (void)
SetContextClipRect (&r);
SetContextClipping (TRUE);
SetTransitionSource (&r);
BatchGraphics ();
{
@@ -1856,6 +1857,7 @@ ReturnToOrbit (PRECT pRect)
OldContext = SetContext (SpaceContext);
SetContextClipRect (pRect);
SetTransitionSource (pRect);
BatchGraphics ();
DrawStarBackGround (TRUE);
SetContext (ScanContext);
+2 -1
View File
@@ -64,6 +64,7 @@ LoadPlanet (BOOLEAN IsDefined)
SetSemaphore (GraphicsSem);
BatchGraphics ();
SetTransitionSource (NULL);
if (!(LastActivity & CHECK_LOAD))
DrawStarBackGround (TRUE);
@@ -176,7 +177,7 @@ LoadPlanet (BOOLEAN IsDefined)
BatchGraphics();
DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0);
UnbatchGraphics();
ScreenTransition (3, &r);
ScreenTransition (3, &r); // How does this work?
UnbatchGraphics ();
LoadIntoExtraScreen (&r);
ClearSemaphore (GraphicsSem);
+5
View File
@@ -268,6 +268,11 @@ DrawStarMap (COUNT race_update, PRECT pClipRect)
SetFrameHot (Screen,
MAKE_HOT_SPOT (pClipRect->corner.x, pClipRect->corner.y));
}
if (transition_pending)
{
SetTransitionSource (NULL);
}
BatchGraphics ();
which_space = GET_GAME_STATE (ARILOU_SPACE_SIDE);
+10 -6
View File
@@ -490,6 +490,7 @@ ShowPlanet:
GenerateMoons ();
NewWaitPlanet = 0;
SetTransitionSource (NULL);
BatchGraphics ();
SetGraphicGrabOther (1);
DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE);
@@ -673,7 +674,12 @@ void
ZoomSystem (void)
{
RECT r;
r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT;
SetTransitionSource (&r);
BatchGraphics ();
if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc)
DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE);
@@ -684,10 +690,6 @@ ZoomSystem (void)
DrawSystem (pSolarSysState->SunDesc[0].radius, FALSE);
}
r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT;
ScreenTransition (3, &r);
UnbatchGraphics ();
LoadIntoExtraScreen (&r);
@@ -974,9 +976,10 @@ ScaleSystem (void)
CONTEXT OldContext;
OldContext = SetContext (SpaceContext);
GetContextClipRect (&r);
SetTransitionSource (&r);
BatchGraphics ();
DrawSystem (pSolarSysState->SunDesc[0].radius, FALSE);
GetContextClipRect (&r);
ScreenTransition (3, &r);
UnbatchGraphics ();
LoadIntoExtraScreen (&r);
@@ -1085,8 +1088,8 @@ TheMess:
if (old_radius)
ScaleSystem ();
SetTransitionSource (NULL);
BatchGraphics ();
if (!(draw_sys_flags & DRAW_REFRESH)) // don't repair from Extra or draw ship if forcing repair
{
CONTEXT OldContext;
@@ -1405,6 +1408,7 @@ LoadLanderData ();
if (pSolarSysState->MenuState.Initialized == 0)
{
SetTransitionSource (NULL);
BatchGraphics ();
draw_sys_flags |= UNBATCH_SYS;
+9 -8
View File
@@ -1205,6 +1205,7 @@ DoShipyard (INPUT_STATE InputState, PMENU_STATE pMS)
pMS->hMusic = LoadMusicInstance (SHIPYARD_MUSIC);
SetTransitionSource (NULL);
BatchGraphics ();
DrawSISFrame ();
@@ -1237,15 +1238,15 @@ DoShipyard (INPUT_STATE InputState, PMENU_STATE pMS)
SetContextFont (TinyFont);
{
RECT r;
{
RECT r;
r.corner.x = 0;
r.corner.y = 0;
r.extent.width = SCREEN_WIDTH;
r.extent.height = SCREEN_HEIGHT;
ScreenTransition (3, &r);
}
r.corner.x = 0;
r.corner.y = 0;
r.extent.width = SCREEN_WIDTH;
r.extent.height = SCREEN_HEIGHT;
ScreenTransition (3, &r);
}
PlayMusic (pMS->hMusic, TRUE, 1);
UnbatchGraphics ();
BeginHangarAnim (pMS);
+9 -8
View File
@@ -314,20 +314,21 @@ s.origin.x = SAFE_X, s.origin.y = SAFE_Y + 4;
pMS->hMusic = LoadMusicInstance (STARBASE_MUSIC);
SetSemaphore (GraphicsSem);
SetTransitionSource (NULL);
BatchGraphics ();
SetContextBackGroundColor (BLACK_COLOR);
ClearDrawable ();
DrawStamp (&s);
DrawBaseStateStrings ((STARBASE_STATE)~0, pMS->CurState);
{
RECT r;
{
RECT r;
r.corner.x = 0;
r.corner.y = 0;
r.extent.width = SCREEN_WIDTH;
r.extent.height = SCREEN_HEIGHT;
ScreenTransition (3, &r);
}
r.corner.x = 0;
r.corner.y = 0;
r.extent.width = SCREEN_WIDTH;
r.extent.height = SCREEN_HEIGHT;
ScreenTransition (3, &r);
}
PlayMusic (pMS->hMusic, TRUE, 1);
UnbatchGraphics ();
pMS->flash_task = AssignTask (rotate_starbase, 4096,