add: UnlockMutex (GraphicsLock);
context: DoPickGame (PMENU_STATE pMS){	BYTE NewState;	SUMMARY_DESC *pSD;	BOOLEAN first_time;	if (GLOBAL (CurrentActivity) & CHECK_ABORT)	{		pMS->ModuleFrame = 0;				return (FALSE);	}	first_time = (BOOLEAN)(pMS->Initialized == 0);	if (!pMS->Initialized)	{		pMS->delta_item = (SIZE)pMS->CurState;		pMS->CurState = NewState = prev_save;		pMS->InputFunc = DoPickGame;		SleepThreadUntil ((DWORD)pMS->CurFrame);		pMS->CurFrame = 0;		PauseMusic ();		StopSound ();		FadeMusic (128, 0);		{			extern FRAME PlayFrame;			pMS->ModuleFrame = SetAbsFrameIndex (PlayFrame, 41);		}		LockMutex (GraphicsLock);		SetTransitionSource (NULL);		BatchGraphics ();Restart:		SetContext (SpaceContext);		LoadGameDescriptions ((SUMMARY_DESC *)pMS->CurString);		DrawCargo (1);		pMS->Initialized = TRUE;		goto ChangeGameSelection;	}	else if (CurrentMenuState.cancel)	{		SetFlashRect ((PRECT)~0L, (FRAME)0);		pMS->ModuleFrame = 0;		pMS->CurState = (BYTE)pMS->delta_item;		ResumeMusic ();		if (pSolarSysState)		{#define DRAW_REFRESH (1 << 5)#define REPAIR_SCAN (1 << 6)			extern BYTE draw_sys_flags;			if (pSolarSysState->MenuState.Initialized < 3)				draw_sys_flags |= DRAW_REFRESH;			else if (pSolarSysState->MenuState.Initialized == 4)				draw_sys_flags |= REPAIR_SCAN;		}		return (FALSE);	}	else if (CurrentMenuState.select)	{		pSD = &((SUMMARY_DESC *)pMS->CurString)[pMS->CurState];		prev_save = pMS->CurState;		if (pMS->delta_item == SAVE_GAME || pSD->year_index)		{			LockMutex (GraphicsLock);			if (pMS->delta_item == SAVE_GAME)			{				STAMP MsgStamp;				extern BOOLEAN SaveGame (COUNT						which_game, SUMMARY_DESC						*summary_desc);				ConfirmSaveLoad (&MsgStamp);				if (SaveGame ((COUNT)pMS->CurState, pSD))				{					DestroyDrawable (ReleaseDrawable (MsgStamp.frame));					GLOBAL (CurrentActivity) |= CHECK_LOAD;				}				else				{					SetFlashRect (NULL_PTR, (FRAME)0);					DrawStamp (&MsgStamp);					DestroyDrawable (ReleaseDrawable (MsgStamp.frame));					UnlockMutex (GraphicsLock);										SaveProblem ();					pMS->Initialized = FALSE;					NewState = pMS->CurState;					LockMutex (GraphicsLock);					BatchGraphics ();					goto Restart;				}				ResumeMusic ();				if (pSolarSysState)				{#define DRAW_REFRESH (1 << 5)#define REPAIR_SCAN (1 << 6)					extern BYTE draw_sys_flags;										if (pSolarSysState->MenuState.Initialized < 3)						draw_sys_flags |= DRAW_REFRESH;					else if (pSolarSysState->MenuState.Initialized == 4)						draw_sys_flags |= REPAIR_SCAN;				}			}			else			{				extern BOOLEAN LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc);				ConfirmSaveLoad (0);				if (LoadGame ((COUNT)pMS->CurState, NULL_PTR))					GLOBAL (CurrentActivity) |= CHECK_LOAD;			}			SetFlashRect (NULL_PTR, (FRAME)0);			UnlockMutex (GraphicsLock);			pMS->ModuleFrame = 0;			pMS->CurState = (BYTE)pMS->delta_item;			return (FALSE);		}	}	else	{		NewState = pMS->CurState;		if (CurrentMenuState.left || CurrentMenuState.page_up)		{			if (NewState == 0)				NewState = MAX_SAVED_GAMES - 1;			else if ((NewState - SAVES_PER_PAGE) > 0)				NewState -= SAVES_PER_PAGE;			else 				NewState = 0;		}		else if (CurrentMenuState.right || CurrentMenuState.page_down)		{			if (NewState == MAX_SAVED_GAMES - 1)				NewState = 0;			else if ((NewState + SAVES_PER_PAGE) < MAX_SAVED_GAMES - 1)				NewState += SAVES_PER_PAGE;			else 				NewState = MAX_SAVED_GAMES - 1;		}		else if (CurrentMenuState.up)		{			if (NewState == 0)				NewState = MAX_SAVED_GAMES - 1;			else				NewState--;		}		else if (CurrentMenuState.down)		{			if (NewState == MAX_SAVED_GAMES - 1)				NewState = 0;			else				NewState++;		}		if (NewState != pMS->CurState)		{			RECT r;			TEXT t;			BYTE i, SHIFT;			UNICODE buf[80],buf2[15];			LockMutex (GraphicsLock);			BatchGraphics ();			if (((SUMMARY_DESC *)pMS->CurString)[NewState].year_index != 0)			{				if (!(((SUMMARY_DESC *)pMS->CurString)[NewState].Flags						& AFTER_BOMB_INSTALLED))				{					if (((SUMMARY_DESC *)pMS->CurString)[pMS->CurState].year_index == 0)						DrawCargo (1);					else if (((SUMMARY_DESC *)pMS->CurString)[pMS->CurState].Flags							& AFTER_BOMB_INSTALLED)						DrawCargo (2);				}				else if (((SUMMARY_DESC *)pMS->CurString)[pMS->CurState].year_index == 0)					DrawCargo (3);			}ChangeGameSelection:			pMS->CurState = NewState;			ShowSummary (&((SUMMARY_DESC *)pMS->CurString)[pMS->CurState]);			SetContextFont (TinyFont);			r.extent.width = 240;			r.extent.height = 65;			r.corner.x = 1;			r.corner.y = 160;			SetContextForeGroundColor (BLACK_COLOR);			DrawFilledRectangle (&r);			t.CharCount = (COUNT)~0;			t.pStr = buf;			t.align = ALIGN_LEFT;#if 0			/* This code will return in modified form later. */			if (optSmoothScroll == OPT_3DO)  // 'Smooth' Scrolling			{				if (NewState <= (SAVES_PER_PAGE / 2))					SHIFT = NewState;				else if ((NewState > (SAVES_PER_PAGE / 2)) &&						(NewState < (MAX_SAVED_GAMES - (SAVES_PER_PAGE / 2))))					SHIFT = (SAVES_PER_PAGE / 2);				else //if (NewState >= (MAX_SAVED_GAMES - (SAVES_PER_PAGE / 2)))					SHIFT = SAVES_PER_PAGE - (MAX_SAVED_GAMES - NewState) ;			}			else         // 'Per-Page'  Scrolling#endif				SHIFT = NewState - ((NewState / SAVES_PER_PAGE) * SAVES_PER_PAGE);			for (i = 0; i < SAVES_PER_PAGE && NewState - SHIFT + i < MAX_SAVED_GAMES; i++)			{				SetContextForeGroundColor ((i == SHIFT) ?						(BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x1B), 0x33)):						(BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)));				r.extent.width = 15;				if (MAX_SAVED_GAMES > 99)					r.extent.width += 5;				r.extent.height = 11;				r.corner.x = 8;				r.corner.y = 160 + (i * 13);				DrawRectangle (&r);				t.baseline.x = r.corner.x + 3;				t.baseline.y = r.corner.y + 8;				wsprintf (buf, "%02i", NewState - SHIFT + i);				if (MAX_SAVED_GAMES > 99)					wsprintf (buf, "%03i", NewState - SHIFT + i);				font_DrawText (&t);				r.extent.width = 204 - SAFE_X;				r.corner.x = 30 + SAFE_X;				DrawRectangle (&r);				t.baseline.x = r.corner.x + 3;				if (((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].year_index == 0)					wsprintf (buf, "Empty Slot");				else				{					DateToString (buf2,							((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].month_index,							((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].day_index,							((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].year_index);					wsprintf (buf, "Saved Game - Date: %s",buf2);				}				font_DrawText (&t);			}			if (LastActivity == CHECK_LOAD)			{				BYTE clut_buf[] = {FadeAllToColor};				UnbatchGraphics ();				LastActivity = 0;				XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 2);			}			else			{				if (first_time)				{					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 ();			}			SetFlashRect (0, (FRAME)0);			UnlockMutex (GraphicsLock);		}	}	return (TRUE);}