add: ClearSemaphore(GraphicsSem);
context: DoShipyard (INPUT_STATE InputState, PMENU_STATE pMS){	if (GLOBAL (CurrentActivity) & CHECK_ABORT)		goto ExitShipyard;	if (!pMS->Initialized)	{		pMS->InputFunc = DoShipyard;		{			STAMP s;			s.frame = CaptureDrawable (					LoadGraphic (SHIPYARD_PMAP_ANIM)					);			pMS->hMusic = LoadMusicInstance (SHIPYARD_MUSIC);			BatchGraphics ();			DrawSISFrame ();			DrawSISMessage (GAME_STRING (STARBASE_STRING_BASE + 3));			DrawSISTitle (GAME_STRING (STARBASE_STRING_BASE));			DrawBluePrint (pMS);			pMS->ModuleFrame = s.frame;			DrawMenuStateStrings (PM_CREW, pMS->CurState = SHIPYARD_CREW);			SetSemaphore (GraphicsSem);			SetContext (SpaceContext);			SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);			s.origin.x = s.origin.y = 0;			DrawStamp (&s);			SetContextFont (TinyFont);{	RECT 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 ();			ClearSemaphore (GraphicsSem);			ShowCombatShip ((COUNT)~0, (SHIP_FRAGMENTPTR)0);			SetSemaphore (GraphicsSem);			SetFlashRect ((PRECT)~0L, (FRAME)0);			ClearSemaphore (GraphicsSem);		}		pMS->Initialized = TRUE;	}	else if ((InputState & DEVICE_BUTTON2)			|| ((InputState & DEVICE_BUTTON1)			&& pMS->CurState == SHIPYARD_EXIT))	{ExitShipyard:		SetSemaphore (GraphicsSem);		DestroyDrawable (ReleaseDrawable (pMS->ModuleFrame));		pMS->ModuleFrame = 0;		ClearSemaphore (GraphicsSem);		return (FALSE);	}	else if (InputState & DEVICE_BUTTON1)	{		if (pMS->CurState != SHIPYARD_SAVELOAD)		{			pMS->Initialized = FALSE;			DoModifyShips (InputState, pMS);		}		else		{			if (GameOptions () == 0)				goto ExitShipyard;			DrawMenuStateStrings (PM_CREW, pMS->CurState);			SetSemaphore (GraphicsSem);			SetFlashRect ((PRECT)~0L, (FRAME)0);			ClearSemaphore (GraphicsSem);		}	}	else	{		BYTE NewState;		NewState = pMS->CurState;		if (GetInputXComponent (InputState) < 0				|| GetInputYComponent (InputState) < 0)		{			if (NewState-- == SHIPYARD_CREW)				NewState = SHIPYARD_EXIT;		}		else if (GetInputXComponent (InputState) > 0				|| GetInputYComponent (InputState) > 0)		{			if (NewState++ == SHIPYARD_EXIT)				NewState = SHIPYARD_CREW;		}		if (NewState != pMS->CurState)		{			DrawMenuStateStrings (PM_CREW, NewState);			pMS->CurState = NewState;		}	}	return (TRUE);}