rem: 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++)
context: RotatePlanet (int x, int da, int dx, int dy, int zoom){	STAMP s;	FRAME pFrame[2];	COUNT i, num_frames;	static COUNT scale_amt = PLANET_INIT_ZOOM_SIZE;	static UBYTE zoom_from = 0;	RECT r,  *rp = NULL;	CONTEXT OldContext;	// If thiis frame hasn' been generted, generate it	if (! pSolarSysState->isPFADefined[x]) {		RenderLevelMasks (x);		pSolarSysState->isPFADefined[x] = 1;	}	num_frames = (pSolarSysState->ShieldFrame == 0) ? 1 : 2;	pFrame[0] = SetAbsFrameIndex (pSolarSysState->PlanetFrameArray, (COUNT)(x + 1));	if (num_frames == 2)		pFrame[1] = pSolarSysState->ShieldFrame;	if (zoom)	{			r.corner.x = 0;		r.corner.y = 0;		r.extent.width = SIS_SCREEN_WIDTH;		r.extent.height = SIS_SCREEN_HEIGHT - MAP_HEIGHT;		rp = &r;		if (scale_amt == PLANET_INIT_ZOOM_SIZE)			zoom_from |= Random () & 0x03;		//  we're zooming in, take care of scaling the frames		for (i=0; i < num_frames; i++)		{			COUNT frameh, this_scale;			if (pSolarSysState->ScaleFrame[i])			{				DestroyDrawable (ReleaseDrawable (pSolarSysState->ScaleFrame[i]));				pSolarSysState->ScaleFrame[i] = 0;			}			frameh = GetFrameHeight (pFrame[i]);			this_scale = frameh * scale_amt / MAP_HEIGHT;			if (! (this_scale & 0x01))				this_scale++;			pSolarSysState->ScaleFrame[i] = stretch_frame (					pFrame[i], this_scale, this_scale, 0					);			SetFrameHot (					pSolarSysState->ScaleFrame[i], 					MAKE_HOT_SPOT ((this_scale >> 1) + 1, (this_scale >> 1) + 1)					);			pFrame[i] = pSolarSysState->ScaleFrame[i];		}		scale_amt += PLANET_ZOOM_SPEED;		//Translate the planet so it comes from the bottom right corner		if (scale_amt > MAP_HEIGHT) 			scale_amt=MAP_HEIGHT;		dx += ((zoom_from & 0x01) ? 1 : -1) * dx * (MAP_HEIGHT - scale_amt) / MAP_HEIGHT;		dy += ((zoom_from & 0x02) ? 1 : -1) * dy * (MAP_HEIGHT - scale_amt) / MAP_HEIGHT;		if (scale_amt == MAP_HEIGHT)		{			scale_amt = PLANET_INIT_ZOOM_SIZE;			zoom = 0;			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++)	{		s.frame = pFrame[i];		DrawStamp (&s);	}	UnbatchGraphics ();	SetContext (OldContext);	ClearSemaphore (GraphicsSem);	return (zoom);}