rem: SetSemaphore (&GraphicsSem);
add: SetSemaphore (GraphicsSem);
context: ScanSystem (void){	RECT r;	MENU_STATE MenuState;	MenuState.InputFunc = DoScan;	MenuState.Initialized = FALSE;	MenuState.flash_task = 0;{#define REPAIR_SCAN (1 << 6)	extern BYTE draw_sys_flags;		if (draw_sys_flags & REPAIR_SCAN)	{		RECT r;		r.corner.x = SIS_ORG_X;		r.corner.y = SIS_ORG_Y;		r.extent.width = SIS_SCREEN_WIDTH;		r.extent.height = SIS_SCREEN_HEIGHT;		LoadIntoExtraScreen (&r);		draw_sys_flags &= ~REPAIR_SCAN;	}}	if ((pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED)			|| pSolarSysState->SysInfo.PlanetInfo.AtmoDensity ==			GAS_GIANT_ATMOSPHERE)	{		MenuState.CurState = EXIT_SCAN;		ScanContext = 0;	}	else	{		MenuState.CurState = AUTO_SCAN;		pSolarSysState->MenuState.first_item.x = (MAP_WIDTH >> 1) << MAG_SHIFT;		pSolarSysState->MenuState.first_item.y = (MAP_HEIGHT >> 1) << MAG_SHIFT;		SetSemaphore (&GraphicsSem);		ScanContext = CaptureContext (CreateContext ());		SetContext (ScanContext);		MenuState.flash_rect0.extent.width = FLASH_WIDTH;		MenuState.flash_rect0.extent.height = FLASH_HEIGHT;		MenuState.flash_frame0 = CaptureDrawable (				CreateDrawable (WANT_PIXMAP | MAPPED_TO_DISPLAY,				FLASH_WIDTH, FLASH_HEIGHT, 1)				);		SetContextFGFrame (Screen);		r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;		r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT;		r.extent.width = MAP_WIDTH;		r.extent.height = MAP_HEIGHT;		SetContextClipRect (&r);		DrawScannedObjects (FALSE);		ClearSemaphore (&GraphicsSem);	}	DrawMenuStateStrings (PM_MIN_SCAN, MenuState.CurState);	PrintCoarseScan ();	pMenuState = &MenuState;	DoInput ((PVOID)&MenuState);	pMenuState = 0;	if (ScanContext)	{		SetSemaphore (&GraphicsSem);		SetContext (SpaceContext);		DestroyDrawable (ReleaseDrawable (MenuState.flash_frame0));		DestroyContext (ReleaseContext (ScanContext));		ScanContext = 0;		ClearSemaphore (&GraphicsSem);	}}