rem: BYTE NewState; RECT r;  r.extent.height = 1;  NewState = pMS->CurState; if (GetInputXComponent (InputState) < 0 || GetInputYComponent (InputState) < 0) { if (NewState == OUTFIT_DOFUEL) { SetSemaphore (GraphicsSem); SetContext (SpaceContext); if (GetFTankCapacity (&r.corner) > GLOBAL_SIS (FuelOnBoard) && GLOBAL_SIS (ResUnits) >= (DWORD)GLOBAL (FuelCost)) { if (GLOBAL_SIS (FuelOnBoard) >= FUEL_RESERVE - FUEL_TANK_SCALE) { r.extent.width = 3; DrawPoint (&r.corner); r.corner.x += r.extent.width + 1; DrawPoint (&r.corner); r.corner.x -= r.extent.width; SetContextForeGroundColor (SetContextBackGroundColor (BLACK_COLOR)); DrawFilledRectangle (&r); } DeltaSISGauges (0, FUEL_TANK_SCALE, -GLOBAL (FuelCost)); SetContext (StatusContext); GetGaugeRect (&r, FALSE); SetFlashRect (&r, (FRAME)0); } ClearSemaphore (GraphicsSem); } else if (NewState-- == OUTFIT_FUEL) NewState = OUTFIT_EXIT; } else if (GetInputXComponent (InputState) > 0 || GetInputYComponent (InputState) > 0) { if (NewState == OUTFIT_DOFUEL) { SetSemaphore (GraphicsSem); SetContext (SpaceContext); if (GLOBAL_SIS (FuelOnBoard)) { DeltaSISGauges (0, -FUEL_TANK_SCALE, GLOBAL (FuelCost)); if (GLOBAL_SIS (FuelOnBoard) % FUEL_VOLUME_PER_ROW == 0) { GetFTankCapacity (&r.corner); SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xB, 0x00, 0x00), 0x2E)); r.extent.width = 5; DrawFilledRectangle (&r); } } SetContext (StatusContext); GetGaugeRect (&r, FALSE); SetFlashRect (&r, (FRAME)0); ClearSemaphore (GraphicsSem); } else if (NewState++ == OUTFIT_EXIT) NewState = OUTFIT_FUEL; }  if (NewState != pMS->CurState) { DrawMenuStateStrings (PM_FUEL, NewState); pMS->CurState = NewState; }
add: if (pMS->CurState == OUTFIT_DOFUEL) ChangeFuelQuantity(InputState); else DoMenuChooser (InputState, pMS, PM_FUEL);
context: DoOutfit (INPUT_STATE InputState, PMENU_STATE pMS){	if (GLOBAL (CurrentActivity) & CHECK_ABORT)		goto ExitOutfit;	if (!pMS->Initialized)	{		pMS->InputFunc = DoOutfit;		pMS->Initialized = TRUE;		{			COUNT num_frames;			STAMP s;			extern void DrawFlagshipName (BOOLEAN InStatusArea);			pMS->CurFrame = CaptureDrawable (					LoadGraphic (MODULES_PMAP_ANIM)					);			pMS->hMusic = LoadMusicInstance (OUTFIT_MUSIC);			pMS->CurState = OUTFIT_FUEL;			pMS->ModuleFrame = CaptureDrawable (					LoadGraphic (SISMODS_MASK_PMAP_ANIM)					);			s.origin.x = s.origin.y = 0;			s.frame = CaptureDrawable (					LoadGraphic (OUTFIT_PMAP_ANIM)					);			BatchGraphics ();			DrawSISFrame ();			SetSemaphore(GraphicsSem);			DrawSISMessage (GAME_STRING (STARBASE_STRING_BASE + 2));			DrawSISTitle (GAME_STRING (STARBASE_STRING_BASE));			SetContext (SpaceContext);			SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);			DrawStamp (&s);			DestroyDrawable (ReleaseDrawable (s.frame));			for (num_frames = 0; num_frames < NUM_DRIVE_SLOTS; ++num_frames)			{				BYTE which_piece;				if ((which_piece =						GLOBAL_SIS (DriveSlots[num_frames])) < EMPTY_SLOT)					DrawShipPiece (pMS, which_piece, num_frames, FALSE);			}			for (num_frames = 0; num_frames < NUM_JET_SLOTS; ++num_frames)			{				BYTE which_piece;				if ((which_piece =						GLOBAL_SIS (JetSlots[num_frames])) < EMPTY_SLOT)					DrawShipPiece (pMS, which_piece, num_frames, FALSE);			}			for (num_frames = 0; num_frames < NUM_MODULE_SLOTS; ++num_frames)			{				BYTE which_piece;				if ((which_piece =						GLOBAL_SIS (ModuleSlots[num_frames])) < EMPTY_SLOT)					DrawShipPiece (pMS, which_piece, num_frames, FALSE);			}			RedistributeFuel ();			DisplayLanders (pMS);			if (GET_GAME_STATE (CHMMR_BOMB_STATE) < 3)			{				BYTE ShieldFlags;								ShieldFlags = GET_GAME_STATE (LANDER_SHIELDS);				s.frame = SetAbsFrameIndex (pMS->ModuleFrame,						GetFrameCount (pMS->ModuleFrame) - 5);				if (ShieldFlags & (1 << EARTHQUAKE_DISASTER))					DrawStamp ((PSTAMP)&s);				s.frame = IncFrameIndex (s.frame);				if (ShieldFlags & (1 << BIOLOGICAL_DISASTER))					DrawStamp ((PSTAMP)&s);				s.frame = IncFrameIndex (s.frame);				if (ShieldFlags & (1 << LIGHTNING_DISASTER))					DrawStamp ((PSTAMP)&s);				s.frame = IncFrameIndex (s.frame);				if (ShieldFlags & (1 << LAVASPOT_DISASTER))					DrawStamp ((PSTAMP)&s);			}			ClearSemaphore(GraphicsSem);			DrawMenuStateStrings (PM_FUEL, pMS->CurState);			SetSemaphore(GraphicsSem);			DrawFlagshipName (FALSE);			ClearSemaphore(GraphicsSem);{	RECT r;	r.corner.x = 0;	r.corner.y = 0;	r.extent.width = SCREEN_WIDTH;	r.extent.height = SCREEN_HEIGHT;	ScreenTransition (3, &r);}			PlayMusic (pMS->hMusic, TRUE, 1);			UnbatchGraphics ();						SetSemaphore (GraphicsSem);			SetFlashRect ((PRECT)~0L, (FRAME)0);			ClearSemaphore (GraphicsSem);			GLOBAL_SIS (FuelOnBoard) =					(GLOBAL_SIS (FuelOnBoard)					+ (FUEL_TANK_SCALE >> 1)) / FUEL_TANK_SCALE;			GLOBAL_SIS (FuelOnBoard) *= FUEL_TANK_SCALE;		}		SetContext (StatusContext);		SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);	}	else if ((InputState & DEVICE_BUTTON2)			|| ((InputState & DEVICE_BUTTON1)			&& pMS->CurState == OUTFIT_EXIT))	{		if (pMS->CurState == OUTFIT_DOFUEL)		{			pMS->CurState = OUTFIT_FUEL;			SetSemaphore (GraphicsSem);			SetFlashRect ((PRECT)~0L, (FRAME)0);			ClearSemaphore (GraphicsSem);		}		else		{ExitOutfit:			DestroyDrawable (ReleaseDrawable (pMS->CurFrame));			pMS->CurFrame = 0;			DestroyDrawable (ReleaseDrawable (pMS->ModuleFrame));			pMS->ModuleFrame = 0;			return (FALSE);		}	}	else if (InputState & DEVICE_BUTTON1)	{		switch (pMS->CurState)		{			case OUTFIT_FUEL:			{				RECT r;				pMS->CurState = OUTFIT_DOFUEL;				SetSemaphore (GraphicsSem);				SetContext (StatusContext);				GetGaugeRect (&r, FALSE);				SetFlashRect (&r, (FRAME)0);				ClearSemaphore (GraphicsSem);				break;			}			case OUTFIT_DOFUEL:				pMS->CurState = OUTFIT_FUEL;				SetSemaphore (GraphicsSem);				SetFlashRect ((PRECT)~0L, (FRAME)0);				ClearSemaphore (GraphicsSem);				break;			case OUTFIT_MODULES:				pMS->CurState = EMPTY_SLOT + 2;				if (GET_GAME_STATE (CHMMR_BOMB_STATE) != 3)					pMS->delta_item = 0;				else					pMS->delta_item = NUM_BOMB_MODULES;				pMS->first_item.y = 0;				pMS->Initialized = 0;				DoInstallModule (InputState, pMS);				break;			case OUTFIT_SAVELOAD:				if (GameOptions () == 0)					goto ExitOutfit;				DrawMenuStateStrings (PM_FUEL, pMS->CurState);				SetSemaphore (GraphicsSem);				SetFlashRect ((PRECT)~0L, (FRAME)0);				ClearSemaphore (GraphicsSem);				break;		}	}	else	{		BYTE NewState;		RECT r;		r.extent.height = 1;		NewState = pMS->CurState;		if (GetInputXComponent (InputState) < 0				|| GetInputYComponent (InputState) < 0)		{			if (NewState == OUTFIT_DOFUEL)			{				SetSemaphore (GraphicsSem);				SetContext (SpaceContext);				if (GetFTankCapacity (&r.corner) > GLOBAL_SIS (FuelOnBoard)						&& GLOBAL_SIS (ResUnits) >=						(DWORD)GLOBAL (FuelCost))				{					if (GLOBAL_SIS (FuelOnBoard) >=							FUEL_RESERVE - FUEL_TANK_SCALE)					{						r.extent.width = 3;						DrawPoint (&r.corner);						r.corner.x += r.extent.width + 1;						DrawPoint (&r.corner);						r.corner.x -= r.extent.width;						SetContextForeGroundColor (SetContextBackGroundColor (BLACK_COLOR));						DrawFilledRectangle (&r);					}					DeltaSISGauges (0, FUEL_TANK_SCALE, -GLOBAL (FuelCost));					SetContext (StatusContext);					GetGaugeRect (&r, FALSE);					SetFlashRect (&r, (FRAME)0);				}				ClearSemaphore (GraphicsSem);			}			else if (NewState-- == OUTFIT_FUEL)				NewState = OUTFIT_EXIT;		}		else if (GetInputXComponent (InputState) > 0				|| GetInputYComponent (InputState) > 0)		{			if (NewState == OUTFIT_DOFUEL)			{				SetSemaphore (GraphicsSem);				SetContext (SpaceContext);				if (GLOBAL_SIS (FuelOnBoard))				{					DeltaSISGauges (0, -FUEL_TANK_SCALE,							GLOBAL (FuelCost));					if (GLOBAL_SIS (FuelOnBoard)							% FUEL_VOLUME_PER_ROW == 0)					{						GetFTankCapacity (&r.corner);						SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xB, 0x00, 0x00), 0x2E));						r.extent.width = 5;						DrawFilledRectangle (&r);					}				}				SetContext (StatusContext);				GetGaugeRect (&r, FALSE);				SetFlashRect (&r, (FRAME)0);				ClearSemaphore (GraphicsSem);			}			else if (NewState++ == OUTFIT_EXIT)				NewState = OUTFIT_FUEL;		}		if (NewState != pMS->CurState)		{			DrawMenuStateStrings (PM_FUEL, NewState);			pMS->CurState = NewState;		}	}	return (TRUE);}