rem: SetSemaphore (&GraphicsSem); DrawStamp (&s); ClearSemaphore (&GraphicsSem);
add: SetSemaphore (GraphicsSem); DrawStamp (&s); ClearSemaphore (GraphicsSem);
context: DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int resunit_delta){	STAMP s;	RECT r;	TEXT t;	UNICODE buf[12];	CONTEXT OldContext;	if (crew_delta == 0 && fuel_delta == 0 && resunit_delta == 0)		return;	OldContext = SetContext (StatusContext);	BatchGraphics ();	if (crew_delta == UNDEFINED_DELTA)	{		COUNT i;		extern FRAME flagship_status;		s.origin.x = s.origin.y = 0;		s.frame = flagship_status;		DrawStamp (&s);		s.origin.x = s.origin.y = 0;		for (i = 0; i < NUM_DRIVE_SLOTS; ++i)		{			BYTE which_piece;			if ((which_piece =					GLOBAL_SIS (DriveSlots[i])) < EMPTY_SLOT)			{				s.frame = SetAbsFrameIndex (						flagship_status, which_piece + 1 + 0						);				DrawStamp (&s);				s.frame = IncFrameIndex (s.frame);				DrawStamp (&s);			}			s.origin.y -= 3;		}		s.origin.y = 0;		for (i = 0; i < NUM_JET_SLOTS; ++i)		{			BYTE which_piece;			if ((which_piece =					GLOBAL_SIS (JetSlots[i])) < EMPTY_SLOT)			{				s.frame = SetAbsFrameIndex (						flagship_status, which_piece + 1 + 1						);				DrawStamp (&s);				s.frame = IncFrameIndex (s.frame);				DrawStamp (&s);			}			s.origin.y -= 3;		}		s.origin.y = 0;		for (i = 0; i < NUM_MODULE_SLOTS; ++i)		{			BYTE which_piece;			if ((which_piece =					GLOBAL_SIS (ModuleSlots[i])) < EMPTY_SLOT)			{				s.frame = SetAbsFrameIndex (						flagship_status, which_piece + 1 + 2						);				DrawStamp (&s);			}			s.origin.y -= 3;		}		{			HSTARSHIP hStarShip, hNextShip;			PPOINT pship_pos;			POINT ship_pos[MAX_COMBAT_SHIPS] =			{				SUPPORT_SHIP_PTS			};			ClearSemaphore (&GraphicsSem);			for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)),					pship_pos = ship_pos;					hStarShip; hStarShip = hNextShip, ++pship_pos)			{				SHIP_FRAGMENTPTR StarShipPtr;				StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip (						&GLOBAL (built_ship_q),						hStarShip						);				hNextShip = _GetSuccLink (StarShipPtr);				s.origin.x = pship_pos->x;				s.origin.y = pship_pos->y;				s.frame = StarShipPtr->ShipInfo.icons;				SetSemaphore (&GraphicsSem);				DrawStamp (&s);				ClearSemaphore (&GraphicsSem);				UnlockStarShip (						&GLOBAL (built_ship_q),						hStarShip						);			}			SetSemaphore (&GraphicsSem);		}	}	t.baseline.x = STATUS_WIDTH >> 1;	t.align = ALIGN_CENTER;	t.pStr = buf;	SetContextFont (TinyFont);	if (crew_delta != 0)	{		if (crew_delta != UNDEFINED_DELTA)		{			COUNT CrewCapacity;			if (crew_delta < 0					&& GLOBAL_SIS (CrewEnlisted) <= (COUNT)-crew_delta)				GLOBAL_SIS (CrewEnlisted) = 0;			else if ((GLOBAL_SIS (CrewEnlisted) += crew_delta) >					(CrewCapacity = GetCPodCapacity (NULL_PTR)))				GLOBAL_SIS (CrewEnlisted) = CrewCapacity;		}		wsprintf (buf, "%u", GLOBAL_SIS (CrewEnlisted));		GetGaugeRect (&r, TRUE);		t.baseline.y = r.corner.y + r.extent.height;		t.CharCount = (COUNT)~0;		SetContextForeGroundColor (BLACK_COLOR);		DrawFilledRectangle (&r);		SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0xE, 0x00), 0x6C));		DrawText (&t);	}	if (fuel_delta != 0)	{		COUNT old_coarse_fuel, new_coarse_fuel;		if (fuel_delta == UNDEFINED_DELTA)			old_coarse_fuel = (COUNT)~0;		else		{			DWORD FuelCapacity;			old_coarse_fuel = (COUNT)(					GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE					);			if (fuel_delta < 0					&& GLOBAL_SIS (FuelOnBoard) <= (DWORD)-fuel_delta)				GLOBAL_SIS (FuelOnBoard) = 0;			else if ((GLOBAL_SIS (FuelOnBoard) += fuel_delta) >					(FuelCapacity = GetFTankCapacity (NULL_PTR)))				GLOBAL_SIS (FuelOnBoard) = FuelCapacity;		}		new_coarse_fuel = (COUNT)(				GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE				);		if (new_coarse_fuel != old_coarse_fuel)		{			wsprintf (buf, "%u", new_coarse_fuel);			GetGaugeRect (&r, FALSE);			t.baseline.y = r.corner.y + r.extent.height;			t.CharCount = (COUNT)~0;			SetContextForeGroundColor (BLACK_COLOR);			DrawFilledRectangle (&r);			SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C));			DrawText (&t);		}	}	if (crew_delta == UNDEFINED_DELTA)	{		DrawFlagshipName (TRUE);		DrawCaptainsName ();		DrawLanders ();		DrawStorageBays (FALSE);	}	if (resunit_delta != 0)	{		if (resunit_delta != UNDEFINED_DELTA)		{			if (resunit_delta < 0					&& GLOBAL_SIS (ResUnits) <= (DWORD)-resunit_delta)				GLOBAL_SIS (ResUnits) = 0;			else				GLOBAL_SIS (ResUnits) += resunit_delta;			DrawStatusMessage ((UNICODE *)~0);		}		else		{			r.corner.x = 1;			r.corner.y = 129;			r.extent.width = 62;			r.extent.height = 9;			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, 0x8, 0x00), 0x6E));			if ((pMenuState == 0					&& CommData.ConversationPhrases /* Melnorme shenanigans */					&& cur_comm == MELNORME_CONVERSATION)					|| (pMenuState					&& (pMenuState->InputFunc == DoStarBase					|| pMenuState->InputFunc == DoOutfit					|| pMenuState->InputFunc == DoShipyard)))				DrawStatusMessage ((UNICODE *)~0);			else				DrawStatusMessage (NULL_PTR);		}	}	UnbatchGraphics ();	SetContext (OldContext);}