rem: SetSemaphore (&GraphicsSem);
add: SetSemaphore (GraphicsSem);
context: DoManipulateDevices (INPUT_STATE InputState, PMENU_STATE pMS){	BYTE NewState;	if (GLOBAL (CurrentActivity) & CHECK_ABORT)		return (FALSE);	if (!(pMS->Initialized & 1))	{		DrawDevices (pMS, (BYTE)~0, (BYTE)~0);		pMS->InputFunc = DoManipulateDevices;		++pMS->Initialized;		NewState = pMS->CurState;		goto SelectDevice;	}	else if (InputState & DEVICE_BUTTON2)	{		return (FALSE);	}	else if (InputState & DEVICE_BUTTON1)	{		UWORD status;		SetSemaphore (&GraphicsSem);		status = DeviceFailed (				((PBYTE)pMS->CurFrame)[pMS->CurState - 1]				);		NewState = LOBYTE (status);		if (NewState)			PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 2),					0, GAME_SOUND_PRIORITY);		else if (HIBYTE (status) == 0)			PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 3),					0, GAME_SOUND_PRIORITY);		ClearSemaphore (&GraphicsSem);		return ((BOOLEAN)NewState);	}	else	{		SIZE NewTop;		NewTop = pMS->first_item.y;		NewState = pMS->CurState - 1;		if (GetInputXComponent (InputState) < 0				|| GetInputYComponent (InputState) < 0)		{			if (NewState-- == 0)				NewState = 0;			if ((SIZE)NewState < NewTop && (NewTop -= MAX_VIS_DEVICES) < 0)				NewTop = 0;		}		else if (GetInputXComponent (InputState) > 0				|| GetInputYComponent (InputState) > 0)		{			if (++NewState == (BYTE)pMS->first_item.x)				NewState = (BYTE)(pMS->first_item.x - 1);			if (NewState >= NewTop + MAX_VIS_DEVICES)				NewTop = NewState;		}		if (++NewState != pMS->CurState)		{			if (NewTop != pMS->first_item.y)			{				pMS->first_item.y = NewTop;				pMS->CurState = (BYTE)~0;			}SelectDevice:			DrawDevices (pMS, (BYTE)(pMS->CurState - 1), (BYTE)(NewState - 1));			pMS->CurState = NewState;		}	}	return (TRUE);}