diff --git a/sc2/src/sc2code/planets/planets.c b/sc2/src/sc2code/planets/planets.c index 462cbf66f..fe5c421a9 100644 --- a/sc2/src/sc2code/planets/planets.c +++ b/sc2/src/sc2code/planets/planets.c @@ -24,16 +24,14 @@ #include "libs/graphics/gfx_common.h" -//Added by Chris - -void -DrawPlanet(int x, int y, int dy, unsigned int rgb); - -//End Added by Chris - +extern void DrawPlanet (int x, int y, int dy, unsigned int rgb); +extern void GeneratePlanetSide (void); +extern void GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth); extern void SetPlanetMusic (BYTE planet_type); extern int rotate_planet_task (PVOID Blah); +extern MUSIC_REF LanderMusic; + void DrawScannedObjects (BOOLEAN Reversed) { @@ -62,28 +60,90 @@ DrawScannedObjects (BOOLEAN Reversed) } } +typedef enum +{ + DRAW_ORBITAL_FULL, + DRAW_ORBITAL_WAIT, + DRAW_ORBITAL_UPDATE, + +} DRAW_ORBITAL_MODE; + +static void +DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode) +{ + RECT r = { SIS_ORG_X, SIS_ORG_Y, + SIS_SCREEN_WIDTH, SIS_SCREEN_HEIGHT }; + + BatchGraphics (); + + if (Mode != DRAW_ORBITAL_UPDATE) + { + SetTransitionSource (NULL); + + DrawSISFrame (); + DrawSISMessage (NULL_PTR); + DrawSISTitle (GLOBAL_SIS (PlanetName)); + DrawStarBackGround (TRUE); + } + + SetContext (SpaceContext); + + if (Mode == DRAW_ORBITAL_WAIT) + { + STAMP s; + + s.frame = CaptureDrawable ( + LoadCelFile ("ipanims/orbenter.ani")); + s.origin.x = -SAFE_X; + s.origin.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT; + DrawStamp (&s); + DestroyDrawable (ReleaseDrawable (s.frame)); + } + else + { + DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, + SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0); + } + + if (Mode != DRAW_ORBITAL_UPDATE) + { + ScreenTransition (3, &r); + } + + UnbatchGraphics (); + + if (Mode != DRAW_ORBITAL_WAIT) + { + LoadIntoExtraScreen (&r); + } +} + // Initialise the surface graphics, and start the planet music. // Called from the GENERATE_ORBITAL case of an IP generation function // (when orbit is entered; either from IP, or from loading a saved game) -// and when "starmap" is selected from orbit and then cancelled. +// and when "starmap" is selected from orbit and then cancelled; +// also after in-orbit comm and after defeating planet guards in combat. // IsDefined is true only when the planet comes with its own bitmap, // namely for Earth. void LoadPlanet (BOOLEAN IsDefined) { - STAMP s; + BOOLEAN WaitMode; #ifdef DEBUG if (disableInteractivity) return; #endif - - LockMutex (GraphicsLock); - BatchGraphics (); - SetTransitionSource (NULL); - if (!(LastActivity & CHECK_LOAD)) - DrawStarBackGround (TRUE); + WaitMode = !(LastActivity & CHECK_LOAD) && + (pSolarSysState->MenuState.Initialized <= 2); + + if (WaitMode) + { + LockMutex (GraphicsLock); + DrawOrbitalDisplay (DRAW_ORBITAL_WAIT); + UnlockMutex (GraphicsLock); + } if (pSolarSysState->MenuState.flash_task == 0) { @@ -91,7 +151,6 @@ LoadPlanet (BOOLEAN IsDefined) // This means the call to LoadPlanet is made from a // GENERATE_ORBITAL case of an IP generation function. PPLANET_DESC pPlanetDesc; - extern void GeneratePlanetSide (void); StopMusic (); @@ -109,12 +168,7 @@ LoadPlanet (BOOLEAN IsDefined) LoadLanderData (); */ - { - extern void GeneratePlanetMask (PPLANET_DESC - pPlanetDesc, BOOLEAN IsEarth); - - GeneratePlanetMask (pPlanetDesc, IsDefined); - } + GeneratePlanetMask (pPlanetDesc, IsDefined); SetPlanetMusic ((UBYTE)(pPlanetDesc->data_index & ~PLANET_SHIELDED)); if (pPlanetDesc->pPrevDesc != &pSolarSysState->SunDesc[0]) @@ -123,23 +177,11 @@ LoadPlanet (BOOLEAN IsDefined) GeneratePlanetSide (); } - if (LastActivity & CHECK_LOAD) - { - if (LOBYTE (LastActivity) == 0) - { - DrawSISFrame (); - } - else - { - ClearSISRect (DRAW_SIS_DISPLAY); - RepairSISBorder (); - } - DrawSISMessage (NULL_PTR); - DrawSISTitle (GLOBAL_SIS (PlanetName)); - } - + LockMutex (GraphicsLock); + DrawOrbitalDisplay (WaitMode ? DRAW_ORBITAL_UPDATE : DRAW_ORBITAL_FULL); +#if 0 + // this used to draw the static slave shield graphic SetContext (SpaceContext); - s.frame = pSolarSysState->PlanetSideFrame[2]; if (s.frame) { @@ -147,62 +189,20 @@ LoadPlanet (BOOLEAN IsDefined) s.origin.y = ((116 - SIS_ORG_Y) >> 1) + 2; DrawStamp (&s); } - - if (!(LastActivity & CHECK_LOAD)) - { - RECT r; - - BatchGraphics (); - DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0); - UnbatchGraphics (); - - 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); - } - +#endif UnlockMutex (GraphicsLock); if (!PLRPlaying ((MUSIC_REF)~0)) - { - extern MUSIC_REF LanderMusic; - PlayMusic (LanderMusic, TRUE, 1); - if (pSolarSysState->MenuState.flash_task == 0) - { - pSolarSysState->MenuState.flash_task = - AssignTask (rotate_planet_task, 4096, - "rotate planets"); - while (pSolarSysState->MenuState.Initialized == 2) - TaskSwitch (); - } - } - - if (LastActivity & CHECK_LOAD) + if (pSolarSysState->MenuState.flash_task == 0) { - RECT r; - CONTEXT oldContext; + pSolarSysState->MenuState.flash_task = + AssignTask (rotate_planet_task, 4096, + "rotate planets"); - r.corner.x = SIS_ORG_X; - r.corner.y = SIS_ORG_Y; - r.extent.width = SIS_SCREEN_WIDTH; - r.extent.height = SIS_SCREEN_HEIGHT; - LockMutex (GraphicsLock); - oldContext = SetContext (SpaceContext); - DrawStarBackGround (TRUE); - SetContext (oldContext); - BatchGraphics(); - DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0); - UnbatchGraphics(); - ScreenTransition (3, &r); // How does this work? - UnbatchGraphics (); - LoadIntoExtraScreen (&r); - UnlockMutex (GraphicsLock); + while (pSolarSysState->MenuState.Initialized == 2) + TaskSwitch (); } } @@ -268,7 +268,7 @@ FreePlanet (void) pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0; DestroyFont (ReleaseFont ( pSolarSysState->SysInfo.PlanetInfo.LanderFont - )); + )); pSolarSysState->SysInfo.PlanetInfo.LanderFont = 0; pSolarSysState->PauseRotate = 0;