rem: SetSemaphore (&GraphicsSem);
add: SetSemaphore (GraphicsSem);
context: DrawStarMap (COUNT race_update, PRECT pClipRect){#define GRID_DELTA 500	SIZE i;	COUNT which_space;	long diameter;	RECT r, old_r;	STAMP s;	FRAME star_frame;	STAR_DESCPTR SDPtr;	FRAME OldFrame;	BOOLEAN draw_cursor;	if (pClipRect == (PRECT)-1)	{		pClipRect = 0;		draw_cursor = FALSE;	}	else	{		SetSemaphore (&GraphicsSem);		draw_cursor = TRUE;	}	SetContext (SpaceContext);	if (pClipRect)	{		GetContextClipRect (&old_r);		pClipRect->corner.x += old_r.corner.x;		pClipRect->corner.y += old_r.corner.y;		SetContextClipRect (pClipRect);		pClipRect->corner.x -= old_r.corner.x;		pClipRect->corner.y -= old_r.corner.y;		SetFrameHot (Screen,				MAKE_HOT_SPOT (pClipRect->corner.x, pClipRect->corner.y));	}	OldFrame = SetContextBGFrame ((FRAME)0);	BatchGraphics ();		SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);	which_space = GET_GAME_STATE (ARILOU_SPACE_SIDE);	if (which_space <= 1)	{		SDPtr = &star_array[0];		SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x7), 0x57));		SetContextBackGroundColor (BLACK_COLOR);	}	else	{		SDPtr = &star_array[NUM_SOLAR_SYSTEMS + 1];		SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0xB, 0x00), 0x6D));		SetContextBackGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x8, 0x00), 0x6E));	}	ClearDrawable ();	if (race_update == 0			&& which_space < 2			&& (diameter = (long)GLOBAL_SIS (FuelOnBoard) << 1))	{		COLOR OldColor;		if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)			r.corner = CurStarDescPtr->star_pt;		else		{			r.corner.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x));			r.corner.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y));		}		r.extent.width = UNIVERSE_TO_DISPX (diameter)				- UNIVERSE_TO_DISPX (0);		if (r.extent.width < 0)			r.extent.width = -r.extent.width;		r.extent.height = UNIVERSE_TO_DISPY (diameter)				- UNIVERSE_TO_DISPY (0);		if (r.extent.height < 0)			r.extent.height = -r.extent.height;		r.corner.x = UNIVERSE_TO_DISPX (r.corner.x)				- (r.extent.width >> 1);		r.corner.y = UNIVERSE_TO_DISPY (r.corner.y)				- (r.extent.height >> 1);		OldColor = SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x3, 0x3, 0x3), 0x22));		DrawFilledOval (&r);		SetContextForeGroundColor (OldColor);	}	for (i = MAX_Y_UNIVERSE + 1; i >= 0; i -= GRID_DELTA)	{		SIZE j;		r.corner.x = UNIVERSE_TO_DISPX (0);		r.corner.y = UNIVERSE_TO_DISPY (i);		r.extent.width = SIS_SCREEN_WIDTH << LOBYTE (pMenuState->delta_item);		r.extent.height = 1;		DrawFilledRectangle (&r);		r.corner.y = UNIVERSE_TO_DISPY (MAX_Y_UNIVERSE + 1);		r.extent.width = 1;		r.extent.height = SIS_SCREEN_HEIGHT << LOBYTE (pMenuState->delta_item);		for (j = MAX_X_UNIVERSE + 1; j >= 0; j -= GRID_DELTA)		{			r.corner.x = UNIVERSE_TO_DISPX (j);			DrawFilledRectangle (&r);		}	}	star_frame = SetRelFrameIndex (pMenuState->CurFrame, 2);	if (which_space <= 1)	{		COUNT index;		HSTARSHIP hStarShip, hNextShip;		COLOR race_colors[] =		{			RACE_COLORS		};		for (index = 0,				hStarShip = GetHeadLink (&GLOBAL (avail_race_q));				hStarShip != 0; ++index, hStarShip = hNextShip)		{			EXTENDED_SHIP_FRAGMENTPTR StarShipPtr;			StarShipPtr = (EXTENDED_SHIP_FRAGMENTPTR)LockStarShip (					&GLOBAL (avail_race_q),					hStarShip					);			hNextShip = _GetSuccLink (StarShipPtr);			if (StarShipPtr->ShipInfo.known_strength)			{				RECT repair_r;				GetSphereRect (StarShipPtr, &r, &repair_r);				if (r.corner.x < SIS_SCREEN_WIDTH						&& r.corner.y < SIS_SCREEN_HEIGHT						&& r.corner.x + r.extent.width > 0						&& r.corner.y + r.extent.height > 0						&& (pClipRect == 0						|| (repair_r.corner.x < pClipRect->corner.x + pClipRect->extent.width						&& repair_r.corner.y < pClipRect->corner.y + pClipRect->extent.height						&& repair_r.corner.x + repair_r.extent.width > pClipRect->corner.x						&& repair_r.corner.y + repair_r.extent.height > pClipRect->corner.y)))				{					COLOR c;					TEXT t;					STRING locString;					c = race_colors[index];					if (index + 1 == race_update)						SetContextForeGroundColor (WHITE_COLOR);					else						SetContextForeGroundColor (c);					DrawOval (&r, 0);					SetContextFont (TinyFont);					t.baseline.x = r.corner.x + (r.extent.width >> 1);					t.baseline.y = r.corner.y + (r.extent.height >> 1) - 1;					t.align = ALIGN_CENTER;					locString = SetAbsStringTableIndex (							StarShipPtr->ShipInfo.race_strings, 1							);					t.CharCount = GetStringLength (locString);					t.pStr = (UNICODE *)GetStringAddress (locString);					TextRect (&t, &r, NULL_PTR);					if (r.corner.x <= 0)						t.baseline.x -= r.corner.x - 1;					else if (r.corner.x + r.extent.width >= SIS_SCREEN_WIDTH)						t.baseline.x -= (r.corner.x + r.extent.width)								- SIS_SCREEN_WIDTH + 1;					if (r.corner.y <= 0)						t.baseline.y -= r.corner.y - 1;					else if (r.corner.y + r.extent.height >= SIS_SCREEN_HEIGHT)						t.baseline.y -= (r.corner.y + r.extent.height)								- SIS_SCREEN_HEIGHT + 1;					{						BYTE r, g, b;						COLOR c32k;						c32k = COLOR_32k (c);						r = (c32k >> (5 * 2)) & 0x1F;						if ((r += 0x03) > 0x1F) r = 0x1F;						g = (c32k >> (5 * 1)) & 0x1F;						if ((g += 0x03) > 0x1F) g = 0x1F;						b = (c32k >> (5 * 0)) & 0x1F;						if ((b += 0x03) > 0x1F) b = 0x1F;						SetContextForeGroundColor (								BUILD_COLOR (MAKE_RGB15 (r, g, b), COLOR_256 (c) - 1)								);					}					DrawText (&t);				}			}			UnlockStarShip (					&GLOBAL (avail_race_q), hStarShip					);		}	}	do	{		BYTE star_type;		star_type = SDPtr->Type;#ifdef NOTYET{UNICODE buf[40];GetClusterName (SDPtr, buf);wprintf ("%s\n", buf);}#endif /* NOTYET */		s.origin.x = UNIVERSE_TO_DISPX (SDPtr->star_pt.x);		s.origin.y = UNIVERSE_TO_DISPY (SDPtr->star_pt.y);		if (which_space <= 1)			s.frame = SetRelFrameIndex (star_frame,					STAR_TYPE (star_type)					* NUM_STAR_COLORS					+ STAR_COLOR (star_type));		else if (SDPtr->star_pt.x == ARILOU_HOME_X				&& SDPtr->star_pt.y == ARILOU_HOME_Y)			s.frame = SetRelFrameIndex (star_frame,					SUPER_GIANT_STAR * NUM_STAR_COLORS + GREEN_BODY);		else			s.frame = SetRelFrameIndex (star_frame,					GIANT_STAR * NUM_STAR_COLORS + GREEN_BODY);		DrawStamp (&s);		++SDPtr;	} while (SDPtr->star_pt.x <= MAX_X_UNIVERSE			&& SDPtr->star_pt.y <= MAX_Y_UNIVERSE);	if (GET_GAME_STATE (ARILOU_SPACE))	{		if (which_space <= 1)		{			s.origin.x = UNIVERSE_TO_DISPX (ARILOU_SPACE_X);			s.origin.y = UNIVERSE_TO_DISPY (ARILOU_SPACE_Y);		}		else		{			s.origin.x = UNIVERSE_TO_DISPX (QUASI_SPACE_X);			s.origin.y = UNIVERSE_TO_DISPY (QUASI_SPACE_Y);		}		s.frame = SetRelFrameIndex (star_frame,				GIANT_STAR * NUM_STAR_COLORS + GREEN_BODY);		DrawStamp (&s);	}	if (race_update == 0			&& GLOBAL (autopilot.x) != ~0			&& GLOBAL (autopilot.y) != ~0)		DrawAutoPilot (&GLOBAL (autopilot));	if (transition_pending)	{		GetContextClipRect (&r);		ScreenTransition (3, &r);		transition_pending = FALSE;	}		UnbatchGraphics ();	if (pClipRect)	{		SetContextClipRect (&old_r);		SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0));	}	SetContextBGFrame (OldFrame);	if (race_update == 0)	{		if (draw_cursor)		{			GetContextClipRect (&r);			LoadIntoExtraScreen (&r);			DrawCursor (					UNIVERSE_TO_DISPX (pMenuState->first_item.x),					UNIVERSE_TO_DISPY (pMenuState->first_item.y)					);		}	}	if (draw_cursor)		ClearSemaphore (&GraphicsSem);}