rem: ClearSemaphore (&GraphicsSem);
add: ClearSemaphore (GraphicsSem);
context: PrintCoarseScan (void){#define SCAN_LEADING 19	SIZE temp;	TEXT t;	STAMP s;	UNICODE buf[40];	extern FRAME SpaceJunkFrame;	SetSemaphore (&GraphicsSem);	SetContext (SpaceContext);	if (CurStarDescPtr->Index == SOL_DEFINED)	{		if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0])			wstrcpy (buf, GLOBAL_SIS (PlanetName));		else		{			switch (pSolarSysState->pOrbitalDesc->pPrevDesc					- pSolarSysState->PlanetDesc)			{				case 2: /* EARTH */					wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 9));					break;				case 4: /* JUPITER */					switch (pSolarSysState->pOrbitalDesc							- pSolarSysState->MoonDesc)					{						case 0:							wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 10));							break;						case 1:							wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 11));							break;						case 2:							wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 12));							break;						case 3:							wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 13));							break;					}					break;				case 5:					wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 14));					break;				case 7:					wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 15));					break;			}		}	}	else	{		temp = pSolarSysState->pOrbitalDesc->data_index & ~PLANET_SHIELDED;		if (temp >= FIRST_GAS_GIANT)			wsprintf (buf, "%s", GAME_STRING (SCAN_STRING_BASE + 4 + 51));		else			wsprintf (buf, "%s %s",					GAME_STRING (SCAN_STRING_BASE + 4 + temp),					GAME_STRING (SCAN_STRING_BASE + 4 + 50));	}	t.align = ALIGN_CENTER;	t.baseline.x = SIS_SCREEN_WIDTH >> 1;	t.baseline.y = 13;	t.pStr = buf;	t.CharCount = (COUNT)~0;	SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xF, 0x00, 0x19), 0x3B));	SetContextFont (MicroFont);	DrawText (&t);	s.origin.x = s.origin.y = 0;	s.frame = SetAbsFrameIndex (SpaceJunkFrame, 20);	DrawStamp (&s);	ClearSemaphore (&GraphicsSem);#define LEFT_SIDE_BASELINE_X 27#define RIGHT_SIDE_BASELINE_X (SIS_SCREEN_WIDTH - LEFT_SIDE_BASELINE_X)#define SCAN_BASELINE_Y 25	t.baseline.x = LEFT_SIDE_BASELINE_X;	t.baseline.y = SCAN_BASELINE_Y;	t.align = ALIGN_LEFT;	SetSemaphore (&GraphicsSem);	t.pStr = buf;	temp = (SIZE)((pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist * 100L			+ (EARTH_RADIUS >> 1)) / EARTH_RADIUS);	if (temp >= 10 * 100)		wsprintf (buf, "%u.%u&", temp / 100, (temp / 10) % 10);	else		wsprintf (buf, "%u.%02u&", temp / 100, temp % 100);	t.CharCount = (COUNT)~0;	DrawText (&t);	t.baseline.y += SCAN_LEADING;	ClearSemaphore (&GraphicsSem);	SetSemaphore (&GraphicsSem);	t.pStr = buf;	if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == GAS_GIANT_ATMOSPHERE)		wsprintf (buf, "|");	else	{		temp = (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity * 100				+ (EARTH_ATMOSPHERE >> 1)) / EARTH_ATMOSPHERE;		if (temp >= 10 * 100)			wsprintf (buf, "%u.%u&", temp / 100, (temp / 10) % 10);		else			wsprintf (buf, "%u.%02u&", temp / 100, temp % 100);	}	t.CharCount = (COUNT)~0;	DrawText (&t);	t.baseline.y += SCAN_LEADING;	ClearSemaphore (&GraphicsSem);	SetSemaphore (&GraphicsSem);	t.pStr = buf;	wsprintf (buf, "%d^", pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature);	t.CharCount = (COUNT)~0;	DrawText (&t);	t.baseline.y += SCAN_LEADING;	ClearSemaphore (&GraphicsSem);	SetSemaphore (&GraphicsSem);	t.pStr = buf;	wsprintf (buf, "<%u>", pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == 0			? 0 : (pSolarSysState->SysInfo.PlanetInfo.Weather + 1));	t.CharCount = (COUNT)~0;	DrawText (&t);	t.baseline.y += SCAN_LEADING;	ClearSemaphore (&GraphicsSem);	SetSemaphore (&GraphicsSem);	t.pStr = buf;	wsprintf (buf, "<%u>",			PLANSIZE (			pSolarSysState->SysInfo.PlanetInfo.PlanDataPtr->Type			) == GAS_GIANT			? 0 : (pSolarSysState->SysInfo.PlanetInfo.Tectonics + 1));	t.CharCount = (COUNT)~0;	DrawText (&t);	ClearSemaphore (&GraphicsSem);	t.baseline.x = RIGHT_SIDE_BASELINE_X;	t.baseline.y = SCAN_BASELINE_Y;	t.align = ALIGN_RIGHT;	SetSemaphore (&GraphicsSem);	t.pStr = buf;	{		DWORD tr;		tr = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius;		if ((tr = (tr * tr * tr / 100L				* (DWORD)pSolarSysState->SysInfo.PlanetInfo.PlanetDensity				+ (DWORD)((100L * 100L) >> 1))				/ (DWORD)(100L * 100L)) == 0)			tr = 1;		if (tr >= 10 * 100)			wsprintf (buf, "%lu.%lu&", tr / 100, (tr / 10) % 10);		else			wsprintf (buf, "%lu.%02lu&", tr / 100, tr % 100);	}	t.CharCount = (COUNT)~0;	DrawText (&t);	t.baseline.y += SCAN_LEADING;	ClearSemaphore (&GraphicsSem);	SetSemaphore (&GraphicsSem);	t.pStr = buf;	if ((temp = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius) >= 10 * 100)		wsprintf (buf, "%u.%u&", temp / 100, (temp / 10) % 10);	else		wsprintf (buf, "%u.%02u&", temp / 100, temp % 100);	t.CharCount = (COUNT)~0;	DrawText (&t);	t.baseline.y += SCAN_LEADING;	ClearSemaphore (&GraphicsSem);	SetSemaphore (&GraphicsSem);	t.pStr = buf;	if ((temp = pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity) >= 10 * 100)		wsprintf (buf, "%u.%u&", temp / 100, (temp / 10) % 10);	else	{		if (temp == 0)			temp = 1;		wsprintf (buf, "%u.%02u&", temp / 100, temp % 100);	}	t.CharCount = (COUNT)~0;	DrawText (&t);	t.baseline.y += SCAN_LEADING;	ClearSemaphore (&GraphicsSem);	SetSemaphore (&GraphicsSem);	t.pStr = buf;	if ((temp = pSolarSysState->SysInfo.PlanetInfo.AxialTilt) < 0)		temp = -temp;	wsprintf (buf, "%u^", temp);	t.CharCount = (COUNT)~0;	DrawText (&t);	t.baseline.y += SCAN_LEADING;	ClearSemaphore (&GraphicsSem);	SetSemaphore (&GraphicsSem);	t.pStr = buf;	if (pSolarSysState->SysInfo.PlanetInfo.RotationPeriod < 240 * 10)	{		temp = (SIZE)(pSolarSysState->SysInfo.PlanetInfo.RotationPeriod * 10 / 24);		wsprintf (buf, "%u.%02u&", temp / 100, temp % 100);	}	else	{		temp = (SIZE)((pSolarSysState->SysInfo.PlanetInfo.RotationPeriod				+ (24 >> 1)) / 24);		wsprintf (buf, "%u.%u&", temp / 10, temp % 10);	}	t.CharCount = (COUNT)~0;	DrawText (&t);	ClearSemaphore (&GraphicsSem);}