diff --git a/sc2/src/sc2code/confirm.c b/sc2/src/sc2code/confirm.c index 404abb398..ea32829cb 100644 --- a/sc2/src/sc2code/confirm.c +++ b/sc2/src/sc2code/confirm.c @@ -61,9 +61,12 @@ ConfirmExit (void) F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); DrawStamp (&s); - ClearSemaphore (GraphicsSem); + // Releasing the Semaphore lets the rotate_planet_task + // draw a frame. PauseRotate can still allow one more frame + // to be drawn, so it is safer to just not release the Semaphore + //ClearSemaphore (GraphicsSem); FlushGraphics (); - SetSemaphore (GraphicsSem); + //SetSemaphore (GraphicsSem); { INPUT_STATE PressState; diff --git a/sc2/src/sc2code/planets/pl_stuff.c b/sc2/src/sc2code/planets/pl_stuff.c index aedf9d383..28781a4a0 100644 --- a/sc2/src/sc2code/planets/pl_stuff.c +++ b/sc2/src/sc2code/planets/pl_stuff.c @@ -115,21 +115,34 @@ RotatePlanet (int x, int da, int dx, int dy, int zoom) zoom_from = 0; } } - SetSemaphore (GraphicsSem); - OldContext = SetContext (SpaceContext); - BatchGraphics (); - if (rp) - RepairBackRect (rp); - s.origin.x = dx; - s.origin.y = dy; - for (i = 0; i < num_frames; i++) + + //SetSemaphore (GraphicsSem); + + // PauseRotate needs to be checked twice. It is first + // checked at the rotate_planet_task function to bypass + // rendering the planet (and thus slowinng down other + // parts of te code. It is checked here because it is possile + // that PauseRotate was set between then and now, and we don't + // want too push anything onto the DrawQueue in that case. + // If the setSemaphore is moved before the RenderLevelMasks call, + // one of the two PauseRotate checks can be removed. + //if (((PSOLARSYS_STATE volatile)pSolarSysState)->PauseRotate !=1) { - s.frame = pFrame[i]; - DrawStamp (&s); + OldContext = SetContext (SpaceContext); + BatchGraphics (); + if (rp) + RepairBackRect (rp); + s.origin.x = dx; + s.origin.y = dy; + for (i = 0; i < num_frames; i++) + { + s.frame = pFrame[i]; + DrawStamp (&s); + } + UnbatchGraphics (); + SetContext (OldContext); } - UnbatchGraphics (); - SetContext (OldContext); - ClearSemaphore (GraphicsSem); + //ClearSemaphore (GraphicsSem); return (zoom); } diff --git a/sc2/src/sc2code/planets/plangen.c b/sc2/src/sc2code/planets/plangen.c index 37404c459..384983556 100644 --- a/sc2/src/sc2code/planets/plangen.c +++ b/sc2/src/sc2code/planets/plangen.c @@ -1300,6 +1300,14 @@ rotate_planet_task (void *data) view_index = MAP_WIDTH; do { + // This SetSemaphore was placed before the RotatePlanet call + // To prevent the thread from being interrupted by the flash + // task while computing the Planet Frame. This should help + // to smooth out the planet rotation animation. + // The PauseRotate needs to be placed after the SetSemaphore, + // to gaurantee that PauseRotate doesn't change while waiting + // to aquire the GraphicsSem + SetSemaphore (GraphicsSem); if (((PSOLARSYS_STATE volatile)pSS)->PauseRotate !=1 // if (((PSOLARSYS_STATE volatile)pSS)->MenuState.Initialized <= 3 && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) @@ -1319,7 +1327,7 @@ rotate_planet_task (void *data) } x += i; } - + ClearSemaphore (GraphicsSem); SleepThreadUntil (TimeIn + (ONE_SECOND * ROTATION_TIME) / (MAP_WIDTH)); // SleepThreadUntil (TimeIn + (ONE_SECOND * 5 / (MAP_WIDTH-32))); TimeIn = GetTimeCounter (); diff --git a/sc2/src/sc2code/utils.c b/sc2/src/sc2code/utils.c index 111d5eede..712d73432 100644 --- a/sc2/src/sc2code/utils.c +++ b/sc2/src/sc2code/utils.c @@ -174,9 +174,12 @@ PauseGame (void) F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); DrawStamp (&s); - ClearSemaphore (GraphicsSem); + // Releasing the Semaphore lets the rotate_planet_task + // draw a frame. PauseRotate can still allow one more frame + // to be drawn, so it is safer to just not release the Semaphore + //ClearSemaphore (GraphicsSem); FlushGraphics (); - SetSemaphore (GraphicsSem); + //SetSemaphore (GraphicsSem); { BYTE scan;