rem: ClearSemaphore (&GraphicsSem);
add: ClearSemaphore (GraphicsSem);
context: DoSettings (INPUT_STATE InputState, PMENU_STATE pMS){	BYTE cur_speed;	if (GLOBAL (CurrentActivity) & CHECK_ABORT)		return (FALSE);	cur_speed = (BYTE)(GLOBAL (glob_flags) & COMBAT_SPEED_MASK) >> COMBAT_SPEED_SHIFT;	if (!pMS->Initialized)	{		DrawMenuStateStrings (PM_SOUND_ON, pMS->CurState);		FeedbackSetting (pMS->CurState);		pMS->Initialized = TRUE;		pMS->InputFunc = DoSettings;	}	else if ((InputState & DEVICE_BUTTON2)			|| ((InputState & DEVICE_BUTTON1)			&& pMS->CurState == EXIT_MENU_SETTING))	{		SetSemaphore (&GraphicsSem);		DrawStatusMessage (NULL_PTR);		ClearSemaphore (&GraphicsSem);		pMS->CurState = SETTINGS;		pMS->InputFunc = DoGameOptions;		pMS->Initialized = 0;	}	else if (InputState & DEVICE_BUTTON1)	{		switch (pMS->CurState)		{			case SOUND_ON_SETTING:			case SOUND_OFF_SETTING:				ToggleSoundEffect ();				pMS->CurState ^= 1;				DrawMenuStateStrings (PM_SOUND_ON, pMS->CurState);				break;			case MUSIC_ON_SETTING:			case MUSIC_OFF_SETTING:				ToggleMusic ();				pMS->CurState ^= 1;				DrawMenuStateStrings (PM_SOUND_ON, pMS->CurState);				break;			case CHANGE_CAPTAIN_SETTING:			case CHANGE_SHIP_SETTING:				pMS->Initialized = FALSE;				pMS->InputFunc = DoNaming;				return (TRUE);			default:				if (cur_speed++ < NUM_COMBAT_SPEEDS - 1)					GLOBAL (glob_flags) |= CYBORG_ENABLED;				else				{					cur_speed = 0;					GLOBAL (glob_flags) &= ~CYBORG_ENABLED;				}				GLOBAL (glob_flags) =						(BYTE)((GLOBAL (glob_flags) & ~COMBAT_SPEED_MASK)						| (cur_speed << COMBAT_SPEED_SHIFT));				pMS->CurState = CYBORG_OFF_SETTING + cur_speed;				DrawMenuStateStrings (PM_SOUND_ON, pMS->CurState);		}		FeedbackSetting (pMS->CurState);	}	else	{		BYTE NewState;		NewState = pMS->CurState;		if (GetInputXComponent (InputState) < 0				|| GetInputYComponent (InputState) < 0)		{			do			{				if (NewState-- == SOUND_ON_SETTING)					NewState = EXIT_MENU_SETTING;			} while ((NewState == SOUND_ON_SETTING					&& (GLOBAL (glob_flags) & SOUND_DISABLED))					|| (NewState == SOUND_OFF_SETTING					&& !(GLOBAL (glob_flags) & SOUND_DISABLED))					|| (NewState == MUSIC_ON_SETTING					&& (GLOBAL (glob_flags) & MUSIC_DISABLED))					|| (NewState == MUSIC_OFF_SETTING					&& !(GLOBAL (glob_flags) & MUSIC_DISABLED))					|| (NewState >= CYBORG_OFF_SETTING					&& NewState <= CYBORG_SUPER_SETTING					&& NewState != cur_speed + CYBORG_OFF_SETTING)					);		}		else if (GetInputXComponent (InputState) > 0				|| GetInputYComponent (InputState) > 0)		{			do			{				if (NewState++ == EXIT_MENU_SETTING)					NewState = SOUND_ON_SETTING;			} while ((NewState == SOUND_ON_SETTING					&& (GLOBAL (glob_flags) & SOUND_DISABLED))					|| (NewState == SOUND_OFF_SETTING					&& !(GLOBAL (glob_flags) & SOUND_DISABLED))					|| (NewState == MUSIC_ON_SETTING					&& (GLOBAL (glob_flags) & MUSIC_DISABLED))					|| (NewState == MUSIC_OFF_SETTING					&& !(GLOBAL (glob_flags) & MUSIC_DISABLED))					|| (NewState >= CYBORG_OFF_SETTING					&& NewState <= CYBORG_SUPER_SETTING					&& NewState != cur_speed + CYBORG_OFF_SETTING)					);		}		if (NewState != pMS->CurState)		{			DrawMenuStateStrings (PM_SOUND_ON, NewState);			pMS->CurState = NewState;			FeedbackSetting (pMS->CurState);		}	}	return (TRUE);}