rem: while (AnyButtonPress (FALSE)) TaskSwitch();
context: ShowCombatShip (COUNT which_window, SHIP_FRAGMENTPTR YankedStarShipPtr){	COUNT i, num_ships;	HSTARSHIP hStarShip, hNextShip;	SHIP_FRAGMENTPTR StarShipPtr;	struct	{		SHIP_FRAGMENTPTR StarShipPtr;		POINT finished_s;		STAMP ship_s, lfdoor_s, rtdoor_s;	} ship_win_info[MAX_COMBAT_SHIPS], *pship_win_info;	num_ships = 1;	pship_win_info = &ship_win_info[0];	if (YankedStarShipPtr)	{		pship_win_info->StarShipPtr = YankedStarShipPtr;		pship_win_info->lfdoor_s.origin.x = -(SHIP_WIN_WIDTH >> 1);		pship_win_info->rtdoor_s.origin.x = (SHIP_WIN_WIDTH >> 1);		pship_win_info->lfdoor_s.origin.y =				pship_win_info->rtdoor_s.origin.y = 0;		pship_win_info->lfdoor_s.frame =				IncFrameIndex (pMenuState->ModuleFrame);		pship_win_info->rtdoor_s.frame =				IncFrameIndex (pship_win_info->lfdoor_s.frame);		pship_win_info->ship_s.origin.x = (SHIP_WIN_WIDTH >> 1) + 1;		pship_win_info->ship_s.origin.y = (SHIP_WIN_WIDTH >> 1);		pship_win_info->ship_s.frame =				YankedStarShipPtr->ShipInfo.melee_icon;		pship_win_info->finished_s.x = hangar_x_coords[				which_window % HANGAR_SHIPS_ROW];		pship_win_info->finished_s.y = HANGAR_Y + (HANGAR_DY *				(which_window / HANGAR_SHIPS_ROW));	}	else	{		if (which_window == (COUNT)~0)		{			hStarShip = GetHeadLink (&GLOBAL (built_ship_q));			num_ships = CountLinks (&GLOBAL (built_ship_q));		}		else		{			HSTARSHIP hTailShip;			hTailShip = GetTailLink (&GLOBAL (built_ship_q));			RemoveQueue (&GLOBAL (built_ship_q), hTailShip);			hStarShip = GetHeadLink (&GLOBAL (built_ship_q));			while (hStarShip)			{				StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip (						&GLOBAL (built_ship_q),						hStarShip						);				if (GET_GROUP_LOC (StarShipPtr) > which_window)				{					UnlockStarShip (							&GLOBAL (built_ship_q),							hStarShip							);					break;				}				hNextShip = _GetSuccLink (StarShipPtr);				UnlockStarShip (						&GLOBAL (built_ship_q),						hStarShip						);				hStarShip = hNextShip;			}			InsertQueue (&GLOBAL (built_ship_q),					hTailShip, hStarShip);			hStarShip = hTailShip;			StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip (					&GLOBAL (built_ship_q),					hStarShip					);			SET_GROUP_LOC (StarShipPtr, which_window);			UnlockStarShip (					&GLOBAL (built_ship_q),					hStarShip					);		}		for (i = 0; i < num_ships; ++i)		{			StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip (					&GLOBAL (built_ship_q),					hStarShip					);			hNextShip = _GetSuccLink (StarShipPtr);			pship_win_info->StarShipPtr = StarShipPtr;			pship_win_info->lfdoor_s.origin.x = -1;			pship_win_info->rtdoor_s.origin.x = 1;			pship_win_info->lfdoor_s.origin.y =					pship_win_info->rtdoor_s.origin.y = 0;			pship_win_info->lfdoor_s.frame =					IncFrameIndex (pMenuState->ModuleFrame);			pship_win_info->rtdoor_s.frame =					IncFrameIndex (pship_win_info->lfdoor_s.frame);			pship_win_info->ship_s.origin.x = (SHIP_WIN_WIDTH >> 1) + 1;			pship_win_info->ship_s.origin.y = (SHIP_WIN_WIDTH >> 1);			pship_win_info->ship_s.frame =					StarShipPtr->ShipInfo.melee_icon;			which_window = GET_GROUP_LOC (StarShipPtr);			pship_win_info->finished_s.x = hangar_x_coords[					which_window % HANGAR_SHIPS_ROW];			pship_win_info->finished_s.y = HANGAR_Y + (HANGAR_DY *					(which_window / HANGAR_SHIPS_ROW));			++pship_win_info;			UnlockStarShip (					&GLOBAL (built_ship_q),					hStarShip					);			hStarShip = hNextShip;		}	}	if (num_ships)	{		BYTE ButtonState;		BOOLEAN AllDoorsFinished;		DWORD TimeIn;		RECT r;		CONTEXT OldContext;		int j;		AllDoorsFinished = FALSE;		r.corner.x = r.corner.y = 0;		r.extent.width = SHIP_WIN_WIDTH;		r.extent.height = SHIP_WIN_HEIGHT;		ButtonState = AnyButtonPress (FALSE) ? 1 : 0;		if (ButtonState)		{			while (ButtonState)				if (!AnyButtonPress (FALSE))					ButtonState = 0;				else					TaskSwitch();		}		TimeIn = GetTimeCounter ();		for (j = 0; (j < SHIP_WIN_FRAMES) && !AllDoorsFinished; j++)		{			SleepThreadUntil (TimeIn + ONE_SECOND / 24);			TimeIn = GetTimeCounter ();			if (AnyButtonPress (FALSE))			{				if (YankedStarShipPtr != 0)				{					ship_win_info[0].lfdoor_s.origin.x = 0;					ship_win_info[0].rtdoor_s.origin.x = 0;				}				AllDoorsFinished = TRUE;				while (AnyButtonPress (FALSE))					TaskSwitch();			}			LockMutex (GraphicsLock);			OldContext = SetContext (OffScreenContext);			SetContextFGFrame (Screen);			SetContextBackGroundColor (BLACK_COLOR);			BatchGraphics ();			pship_win_info = &ship_win_info[0];			for (i = 0; i < num_ships; ++i)			{				{					RECT ClipRect;					ClipRect.corner.x = SIS_ORG_X + pship_win_info->finished_s.x;					ClipRect.corner.y = SIS_ORG_Y + pship_win_info->finished_s.y;					ClipRect.extent.width = SHIP_WIN_WIDTH;					ClipRect.extent.height = SHIP_WIN_HEIGHT;					SetContextClipRect (&ClipRect);										ClearDrawable ();					DrawStamp (&pship_win_info->ship_s);					ShowShipCrew (pship_win_info->StarShipPtr, &r);					if (!AllDoorsFinished || YankedStarShipPtr)					{						DrawStamp (&pship_win_info->lfdoor_s);						DrawStamp (&pship_win_info->rtdoor_s);						if (YankedStarShipPtr)						{							++pship_win_info->lfdoor_s.origin.x;							--pship_win_info->rtdoor_s.origin.x;						}						else						{							--pship_win_info->lfdoor_s.origin.x;							++pship_win_info->rtdoor_s.origin.x;						}					}				}				++pship_win_info;			}			UnbatchGraphics ();			SetContextClipRect (NULL_PTR);			SetContext (OldContext);			UnlockMutex (GraphicsLock);		}	}}