rem: ClearSemaphore (&GraphicsSem);
add: ClearSemaphore (GraphicsSem);
context: ship_preprocess (register PELEMENT ElementPtr){	register ELEMENT_FLAGS cur_status_flags;	STARSHIPPTR StarShipPtr;	RACE_DESCPTR RDPtr;	GetElementStarShip (ElementPtr, &StarShipPtr);	RDPtr = StarShipPtr->RaceDescPtr;	cur_status_flags =			StarShipPtr->cur_status_flags			& ~(LEFT | RIGHT | THRUST | WEAPON | SPECIAL);	if (!(ElementPtr->state_flags & APPEARING))		cur_status_flags |= StarShipPtr->ship_input_state				& (LEFT | RIGHT | THRUST | WEAPON | SPECIAL);	else	{		ElementPtr->crew_level =				(BYTE)RDPtr->ship_info.crew_level;		if ((ElementPtr->state_flags & BAD_GUY)				&& LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)		{			STAMP s;			CONTEXT OldContext;			OldContext = SetContext (StatusContext);			s.origin.x = s.origin.y = 0;			s.frame = RDPtr->ship_data.captain_control.background;			DrawStamp (&s);			DestroyDrawable (ReleaseDrawable (s.frame));			RDPtr->ship_data.captain_control.background = 0;			SetContext (OldContext);		}		else if (LOBYTE (GLOBAL (CurrentActivity)) <= IN_ENCOUNTER)		{			InitShipStatus (StarShipPtr, NULL_PTR);			DrawCaptainsWindow (StarShipPtr);			if (RDPtr->preprocess_func)				(*RDPtr->preprocess_func) (ElementPtr);			if (ElementPtr->hTarget == 0)			{				extern void ship_transition (PELEMENT ElementPtr);				ship_transition (ElementPtr);			}			else			{				extern BOOLEAN OpponentAlive (STARSHIPPTR						TestStarShipPtr);				ElementPtr->hTarget = 0;				if (!PLRPlaying ((MUSIC_REF)~0) && OpponentAlive (StarShipPtr))					BattleSong (TRUE);			}			return;		}		else		{			ElementPtr->current.location.x = LOG_SPACE_WIDTH >> 1;			ElementPtr->current.location.y = LOG_SPACE_HEIGHT >> 1;			ElementPtr->next.location = ElementPtr->current.location;			InitIntersectStartPoint (ElementPtr);			InitIntersectEndPoint (ElementPtr);			ClearSemaphore (&GraphicsSem);			ResumeGameClock ();			SetGameClockRate (HYPERSPACE_CLOCK_RATE);			SetSemaphore (&GraphicsSem);			if (hyper_transition (ElementPtr))				return;		}	}	StarShipPtr->cur_status_flags = cur_status_flags;	if (StarShipPtr->energy_counter)		--StarShipPtr->energy_counter;	else if (RDPtr->ship_info.energy_level < (BYTE)RDPtr->ship_info.max_energy			|| (SBYTE)RDPtr->characteristics.energy_regeneration < 0)		DeltaEnergy ((ELEMENTPTR)ElementPtr,				(SBYTE)RDPtr->characteristics.energy_regeneration);	if (RDPtr->preprocess_func)	{		(*RDPtr->preprocess_func) (ElementPtr);		cur_status_flags = StarShipPtr->cur_status_flags;	}	if (ElementPtr->turn_wait)		--ElementPtr->turn_wait;	else if (cur_status_flags & (LEFT | RIGHT))	{		if (cur_status_flags & LEFT)			StarShipPtr->ShipFacing =					NORMALIZE_FACING (StarShipPtr->ShipFacing - 1);		else			StarShipPtr->ShipFacing =					NORMALIZE_FACING (StarShipPtr->ShipFacing + 1);		ElementPtr->next.image.frame =				SetAbsFrameIndex (ElementPtr->next.image.frame,				StarShipPtr->ShipFacing);		ElementPtr->state_flags |= CHANGING;		ElementPtr->turn_wait = RDPtr->characteristics.turn_wait;	}	if (ElementPtr->thrust_wait)		--ElementPtr->thrust_wait;	else if (cur_status_flags & THRUST)	{		UWORD thrust_status;		thrust_status = inertial_thrust ((ELEMENTPTR)ElementPtr);		StarShipPtr->cur_status_flags &=				~(SHIP_AT_MAX_SPEED				| SHIP_BEYOND_MAX_SPEED				| SHIP_IN_GRAVITY_WELL);		StarShipPtr->cur_status_flags |= thrust_status;		ElementPtr->thrust_wait = RDPtr->characteristics.thrust_wait;		if (!OBJECT_CLOAKED (ElementPtr)				&& LOBYTE (GLOBAL (CurrentActivity)) <= IN_ENCOUNTER)		{			extern void spawn_ion_trail					(PELEMENT					ElementPtr);			spawn_ion_trail (ElementPtr);		}	}	if (LOBYTE (GLOBAL (CurrentActivity)) <= IN_ENCOUNTER)		PreProcessStatus (ElementPtr);}