rem: DrawMeleeFrame (LastStarShipPtr, which_player);
add: s.origin.x = PICK_X_OFFS - 3; s.origin.y = PICK_Y_OFFS - 9 + ((1 - which_player) * PICK_SIDE_OFFS);  DrawStamp (&s);
context: GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player){	COUNT ships_left, row, col;	DWORD NewTime, OldTime, LastTime;	INPUT_STATE OldInputState;	HSTARSHIP hBattleShip, hNextShip;	STARSHIPPTR StarShipPtr;	RECT flash_rect;	if (!(GLOBAL (CurrentActivity) & IN_BATTLE))		return (0);	SetContext (SpaceContext);	DrawMeleeFrame (LastStarShipPtr, which_player);	if (LOBYTE (battle_counter) == 0 || HIBYTE (battle_counter) == 0)	{		DWORD TimeOut;		INPUT_STATE PressState, ButtonState;		DrawMeleeFrame (LastStarShipPtr, 1 - which_player);		TimeOut = GetTimeCounter () + (ONE_SECOND * 4);		ClearSemaphore (GraphicsSem);		PressState = AnyButtonPress (TRUE);		do		{			ButtonState = AnyButtonPress (TRUE);			if (PressState)			{				PressState = ButtonState;				ButtonState = 0;			}		} while (!ButtonState				&& (!(PlayerControl[0] & PlayerControl[1] & PSYTRON_CONTROL)				|| (TaskSwitch (), GetTimeCounter ()) < TimeOut));		if (ButtonState)			ButtonState = GetInputState (NormalInput);		if (ButtonState & DEVICE_EXIT)			ConfirmExit ();		SetSemaphore (GraphicsSem);		return (0);	}	if (LastStarShipPtr == 0 && which_player)	{		BYTE fade_buf[] = {FadeAllToColor};								SleepThreadUntil (XFormColorMap				((COLORMAPPTR) fade_buf, ONE_SECOND / 2) + 2);		FlushColorXForms ();	}	row = 0;	col = NUM_MELEE_COLS_ORIG;	if (which_player == 0)		ships_left = LOBYTE (battle_counter);	else		ships_left = HIBYTE (battle_counter);	flash_rect.extent.width = (ICON_WIDTH + 2);	flash_rect.extent.height = (ICON_HEIGHT + 2);	NewTime = OldTime = LastTime = GetTimeCounter ();	OldInputState = 0;	goto ChangeSelection;	for (;;)	{		INPUT_STATE InputState;		SleepThread (1);		NewTime = GetTimeCounter ();				if ((InputState = GetInputState (PlayerInput[which_player])) == 0)			InputState = GetInputState (ArrowInput);		if (InputState)			LastTime = NewTime;		else if (!(PlayerControl[1 - which_player] & PSYTRON_CONTROL)				&& NewTime - LastTime >= ONE_SECOND * 3)			InputState = GetInputState (PlayerInput[1 - which_player]);		if (InputState & DEVICE_EXIT)		{			if (ConfirmExit ())			{				hBattleShip = 0;				break;			}			continue;		}		if (InputState == OldInputState				&& NewTime - OldTime < (DWORD)MENU_REPEAT_DELAY)			InputState = 0;		else		{			OldInputState = InputState;			OldTime = NewTime;		}		if (InputState & DEVICE_BUTTON1)		{			if (hBattleShip || (col == NUM_MELEE_COLS_ORIG && ConfirmExit ()))			{				GLOBAL (CurrentActivity) &= ~CHECK_ABORT;				break;			}		}		else		{			COUNT new_row, new_col;			new_row = row;			new_col = col;			if (GetInputXComponent (InputState) < 0)			{				if (new_col-- == 0)					new_col = NUM_MELEE_COLS_ORIG;			}			else if (GetInputXComponent (InputState) > 0)			{				if (new_col++ == NUM_MELEE_COLS_ORIG)					new_col = 0;			}			if (GetInputYComponent (InputState) < 0)			{				if (new_row-- == 0)					new_row = NUM_MELEE_ROWS - 1;			}			else if (GetInputYComponent (InputState) > 0)			{				if (++new_row == NUM_MELEE_ROWS)					new_row = 0;			}			if (new_row != row || new_col != col)			{				COUNT ship_index;				row = new_row;				col = new_col;				PlaySoundEffect (MenuSounds, 0, 0);				SetSemaphore (GraphicsSem);ChangeSelection:				flash_rect.corner.x = PICK_X_OFFS						+ ((ICON_WIDTH + 2) * col);				flash_rect.corner.y = PICK_Y_OFFS						+ ((ICON_HEIGHT + 2) * row)						+ ((1 - which_player) * PICK_SIDE_OFFS);				SetFlashRect (&flash_rect, (FRAME)0);				hBattleShip = GetHeadLink (&race_q[which_player]);				if (col == NUM_MELEE_COLS_ORIG)				{					if (row)						hBattleShip = 0;					else					{						ship_index = (COUNT)TFB_Random () % ships_left;						for (hBattleShip = GetHeadLink (&race_q[which_player]);								hBattleShip != 0; hBattleShip = hNextShip)						{							StarShipPtr = LockStarShip (&race_q[which_player], hBattleShip);							if (StarShipPtr->RaceResIndex && ship_index-- == 0)							{								UnlockStarShip (&race_q[which_player], hBattleShip);								break;							}							hNextShip = _GetSuccLink (StarShipPtr);							UnlockStarShip (&race_q[which_player], hBattleShip);						}					}				}				else				{					ship_index = (row * NUM_MELEE_COLS_ORIG) + col;					for (hBattleShip = GetHeadLink (&race_q[which_player]);							hBattleShip != 0; hBattleShip = hNextShip)					{						StarShipPtr = LockStarShip (&race_q[which_player], hBattleShip);						if (StarShipPtr->ShipFacing == ship_index)						{							hNextShip = hBattleShip;							if (StarShipPtr->RaceResIndex == 0)								hBattleShip = 0;							UnlockStarShip (&race_q[which_player], hNextShip);							break;						}						hNextShip = _GetSuccLink (StarShipPtr);						UnlockStarShip (&race_q[which_player], hBattleShip);					}				}				ClearSemaphore (GraphicsSem);			}		}	}	SetSemaphore (GraphicsSem);	SetFlashRect (NULL_PTR, (FRAME)0);		if (hBattleShip == 0)		GLOBAL (CurrentActivity) &= ~IN_BATTLE;	else	{		StarShipPtr = LockStarShip (&race_q[which_player], hBattleShip);		OwnStarShip (StarShipPtr,				1 << which_player, StarShipPtr->captains_name_index);		StarShipPtr->captains_name_index = 0;		UnlockStarShip (&race_q[which_player], hBattleShip);		PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 1), 0, 0);		while (ChannelPlaying (0))			;	}	return (hBattleShip);}