rem: SetSemaphore (&GraphicsSem);
add: SetSemaphore (GraphicsSem);
context: Battle (void){	SIZE num_ships;	extern SIZE InitShips (void);	void UninitShips (void);	SetSemaphore (&GraphicsSem);	SetResourceIndex (hResIndex);#if !(DEMO_MODE || CREATE_JOURNAL)	SeedRandom (GetTimeCounter ());#else /* DEMO_MODE */	if (BattleSeed == 0)		BattleSeed = Random ();	SeedRandom (BattleSeed);	BattleSeed = Random (); /* get next battle seed */#endif /* DEMO_MODE */	BattleSong (FALSE);		num_ships = InitShips ();	if (num_ships)	{		DWORD NextTime;BOOLEAN first_time;		GLOBAL (CurrentActivity) |= IN_BATTLE;		battle_counter = MAKE_WORD (				CountLinks (&race_q[0]),				CountLinks (&race_q[1])				);		while (num_ships--)		{			if (!GetNextStarShip (NULL_PTR, num_ships))				goto AbortBattle;		}		BattleSong (TRUE);		NextTime = 0;first_time = (BOOLEAN)(LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE);		do		{			extern UWORD nth_frame;BatchGraphics ();			if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)				SeedUniverse ();			RedrawQueue (TRUE);if (first_time){	RECT r;		first_time = FALSE;	r.corner.x = SIS_ORG_X;	r.corner.y = SIS_ORG_Y;	r.extent.width = SIS_SCREEN_WIDTH;	r.extent.height = SIS_SCREEN_HEIGHT;	ScreenTransition (3, &r);}UnbatchGraphics ();			ClearSemaphore (&GraphicsSem);			if (nth_frame)				TaskSwitch ();			else				NextTime = SleepTask (NextTime + BATTLE_FRAME_RATE);			ProcessInput ();			SetSemaphore (&GraphicsSem);		} while (GLOBAL (CurrentActivity) & IN_BATTLE);AbortBattle:		StopMusic ();		StopSound ();	}	UninitShips ();	FreeBattleSong ();	ClearSemaphore (&GraphicsSem);		return (num_ships < 0);}