rem: SetSemaphore (&GraphicsSem);
add: SetSemaphore (GraphicsSem);
context: DrawDevices (PMENU_STATE pMS, BYTE OldDevice, BYTE NewDevice){#define MAX_VIS_DEVICES 5	COORD y, cy;	TEXT t;	RECT r;	PBYTE pDeviceMap;	SetSemaphore (&GraphicsSem);	SetContext (StatusContext);	SetContextFont (TinyFont);	y = 41;	t.baseline.x = 40;	t.align = ALIGN_CENTER;	t.CharCount = 3;	pDeviceMap = (PBYTE)pMS->CurFrame;	if (OldDevice > NUM_DEVICES			|| (NewDevice < NUM_DEVICES			&& (NewDevice < (BYTE)pMS->first_item.y			|| NewDevice >= (BYTE)(pMS->first_item.y + MAX_VIS_DEVICES))))	{		STAMP s;		extern FRAME misc_data;		r.corner.x = 2;		r.extent.width = FIELD_WIDTH + 1;		if (!(pMS->Initialized & 1))		{			++r.corner.x;			r.extent.width -= 2;			r.corner.y = 33;			r.extent.height = 89;			SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01));			DrawFilledRectangle (&r);		}		else		{			TEXT ct;			r.corner.y = 20;			r.extent.height = 109;			DrawStarConBox (&r, 1,					BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19),					BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), 0x1F),					TRUE,					BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01));			SetContextFont (StarConFont);			ct.baseline.x = (STATUS_WIDTH >> 1) - 1;			ct.baseline.y = 27;			ct.align = ALIGN_CENTER;			ct.pStr = GAME_STRING (DEVICE_STRING_BASE);			ct.CharCount = (COUNT)~0;			SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0x1F, 0x1F), 0x0B));			DrawText (&ct);			SetContextFont (TinyFont);		}		if (NewDevice < (BYTE)pMS->first_item.y)			pMS->first_item.y = NewDevice;		else if (NewDevice >= (BYTE)(pMS->first_item.y + MAX_VIS_DEVICES))			pMS->first_item.y = NewDevice - (MAX_VIS_DEVICES - 1);		s.origin.x = 4;		s.origin.y = 34;		cy = y;		SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03));		for (OldDevice = (BYTE)pMS->first_item.y;				OldDevice < (BYTE)(pMS->first_item.y + MAX_VIS_DEVICES)				&& OldDevice < (BYTE)pMS->first_item.x;				++OldDevice)		{			s.frame = SetAbsFrameIndex (					misc_data, 77 + pDeviceMap[OldDevice]					);			DrawStamp (&s);			if (OldDevice != NewDevice)			{				t.baseline.y = cy;				t.pStr = GAME_STRING (pDeviceMap[OldDevice] + DEVICE_STRING_BASE + 1);				t.CharCount = lpstrchr (t.pStr, ' ');				DrawText (&t);				t.baseline.y += 7;				t.pStr += t.CharCount + 1;				t.CharCount = (COUNT)~0;				DrawText (&t);			}			cy += 18;			s.origin.y += 18;		}		OldDevice = NewDevice;	}	r.extent.width = 41;	r.extent.height = 14;	r.corner.x = t.baseline.x - (r.extent.width >> 1);	if (OldDevice != NewDevice)	{		cy = y + ((OldDevice - pMS->first_item.y) * 18);		r.corner.y = cy - 6;		SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01));		DrawFilledRectangle (&r);		SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03));		t.baseline.y = cy;		t.pStr = GAME_STRING (pDeviceMap[OldDevice] + DEVICE_STRING_BASE + 1);		t.CharCount = lpstrchr (t.pStr, ' ');		DrawText (&t);		t.baseline.y += 7;		t.pStr += t.CharCount + 1;		t.CharCount = (COUNT)~0;		DrawText (&t);	}	if (NewDevice < NUM_DEVICES)	{		cy = y + ((NewDevice - pMS->first_item.y) * 18);		r.corner.y = cy - 6;		SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0x1F), 0x09));		DrawFilledRectangle (&r);		SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0x1F, 0x1F), 0x0B));		t.baseline.y = cy;		t.pStr = GAME_STRING (pDeviceMap[NewDevice] + DEVICE_STRING_BASE + 1);		t.CharCount = lpstrchr (t.pStr, ' ');		DrawText (&t);		t.baseline.y += 7;		t.pStr += t.CharCount + 1;		t.CharCount = (COUNT)~0;		DrawText (&t);	}	ClearSemaphore (&GraphicsSem);}