BOOLEAN GetInitialMeleeStarShips (HSTARSHIP *result) { COUNT playerI; COUNT playerMask; for (playerI = 0; playerI < NUM_PLAYERS; playerI++) { FRAME frame; frame = SetAbsFrameIndex (PickMeleeFrame, playerI); UpdatePickMeleeFleetValue (frame, playerI); DrawPickMeleeFrame (playerI); } // Fade in SleepThreadUntil (FadeScreen (FadeAllToColor, ONE_SECOND / 2) + ONE_SECOND / 60); FlushColorXForms (); playerMask = 0; for (playerI = 0; playerI < NUM_PLAYERS; playerI++) playerMask |= (1 << playerI); return GetMeleeStarShips (playerMask, result); }
static BOOLEAN TryStartGame (void) { MENU_STATE MenuState; LastActivity = GLOBAL (CurrentActivity); GLOBAL (CurrentActivity) = 0; memset (&MenuState, 0, sizeof (MenuState)); MenuState.InputFunc = DoRestart; while (!RestartMenu (&MenuState)) { // spin until a game is started or loaded if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { FreeGameData (); Melee (); MenuState.Initialized = FALSE; } else if (GLOBAL (CurrentActivity) == (ACTIVITY)~0) { // timed out SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); return (FALSE); } else if (GLOBAL (CurrentActivity) & CHECK_ABORT) { // quit return (FALSE); } } return TRUE; }
static void Mailbox_Give(u8 taskId) { if(CalculatePlayerPartyCount() == 0) Mailbox_NoPokemonForMail(taskId); // cannot be reached normally else { FadeScreen(1, 0); TASK.FUNC = Mailbox_DoGiveMailPokeMenu; } }
static void CommIntroTransition (void) { if (curIntroMode == CIM_CROSSFADE_SCREEN) { ScreenTransition (3, NULL); UnbatchGraphics (); } else if (curIntroMode == CIM_CROSSFADE_SPACE) { RECT r; 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 (); } else if (curIntroMode == CIM_CROSSFADE_WINDOW) { ScreenTransition (3, &CommWndRect); UnbatchGraphics (); } else if (curIntroMode == CIM_FADE_IN_SCREEN) { UnbatchGraphics (); FadeScreen (FadeAllToColor, fadeTime); } else { // Uknown transition // Have to unbatch anyway or no more graphics, ever UnbatchGraphics (); assert (0 && "Unknown comm intro transition"); } // Reset the mode for next time. Everything that needs a // different one will let us know. curIntroMode = CIM_DEFAULT; }
static BOOLEAN RestartMessage(MENU_STATE *pMS, TimeCount TimeIn){ if(optRequiresRestart){ SetFlashRect (NULL); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 35)); // Got to restart -message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); SleepThreadUntil (FadeScreen(FadeAllToBlack, ONE_SECOND / 2)); GLOBAL (CurrentActivity) = CHECK_ABORT; restartGame = TRUE; return TRUE; } else if (!PacksInstalled()) { Flash_pause(pMS->flashContext); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 35 + RESOLUTION_FACTOR)); // Could not find graphics pack - message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); Flash_continue(pMS->flashContext); SleepThreadUntil (TimeIn + ONE_SECOND / 30); return TRUE; } else return FALSE; }
static BOOLEAN DoRestart (MENU_STATE *pMS) { static TimeCount LastInputTime; static TimeCount InactTimeOut; TimeCount TimeIn = GetTimeCounter (); /* Cancel any presses of the Pause key. */ GamePaused = FALSE; if (pMS->Initialized) Flash_process(pMS->flashContext); if (!pMS->Initialized) { if (pMS->hMusic) { StopMusic (); DestroyMusic (pMS->hMusic); pMS->hMusic = 0; } pMS->hMusic = LoadMusic (MAINMENU_MUSIC); InactTimeOut = (pMS->hMusic ? 120 : 20) * ONE_SECOND; pMS->flashContext = Flash_createOverlay (ScreenContext, NULL, NULL); Flash_setMergeFactors (pMS->flashContext, -3, 3, 16); Flash_setSpeed (pMS->flashContext, (6 * ONE_SECOND) / 16, 0, (6 * ONE_SECOND) / 16, 0); Flash_setFrameTime (pMS->flashContext, ONE_SECOND / 16); Flash_setState(pMS->flashContext, FlashState_fadeIn, (3 * ONE_SECOND) / 16); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame); Flash_start (pMS->flashContext); PlayMusic (pMS->hMusic, TRUE, 1); LastInputTime = GetTimeCounter (); pMS->Initialized = TRUE; SleepThreadUntil (FadeScreen (FadeAllToColor, ONE_SECOND / 2)); } else if (GLOBAL (CurrentActivity) & CHECK_ABORT) { return FALSE; } else if (PulsedInputState.menu[KEY_MENU_SELECT]) { switch (pMS->CurState) { case LOAD_SAVED_GAME: LastActivity = CHECK_LOAD; GLOBAL (CurrentActivity) = IN_INTERPLANETARY; break; case START_NEW_GAME: LastActivity = CHECK_LOAD | CHECK_RESTART; GLOBAL (CurrentActivity) = IN_INTERPLANETARY; break; case PLAY_SUPER_MELEE: GLOBAL (CurrentActivity) = SUPER_MELEE; break; case SETUP_GAME: Flash_pause(pMS->flashContext); Flash_setState(pMS->flashContext, FlashState_fadeIn, (3 * ONE_SECOND) / 16); SetupMenu (); SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); LastInputTime = GetTimeCounter (); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); ScreenTransition (3, NULL); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame); Flash_continue(pMS->flashContext); UnbatchGraphics (); return TRUE; case QUIT_GAME: SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); GLOBAL (CurrentActivity) = CHECK_ABORT; break; } Flash_pause(pMS->flashContext); return FALSE; } else if (PulsedInputState.menu[KEY_MENU_UP] || PulsedInputState.menu[KEY_MENU_DOWN]) { BYTE NewState; NewState = pMS->CurState; if (PulsedInputState.menu[KEY_MENU_UP]) { if (NewState == START_NEW_GAME) NewState = QUIT_GAME; else --NewState; } else if (PulsedInputState.menu[KEY_MENU_DOWN]) { if (NewState == QUIT_GAME) NewState = START_NEW_GAME; else ++NewState; } if (NewState != pMS->CurState) { BatchGraphics (); DrawRestartMenu (pMS, NewState, pMS->CurFrame); UnbatchGraphics (); pMS->CurState = NewState; } LastInputTime = GetTimeCounter (); } else if (PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_RIGHT]) { // Does nothing, but counts as input for timeout purposes LastInputTime = GetTimeCounter (); } else if (MouseButtonDown) { Flash_pause(pMS->flashContext); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 54)); // Mouse not supported message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame); ScreenTransition (3, NULL); UnbatchGraphics (); Flash_continue(pMS->flashContext); LastInputTime = GetTimeCounter (); } else { // No input received, check if timed out if (GetTimeCounter () - LastInputTime > InactTimeOut) { SleepThreadUntil (FadeMusic (0, ONE_SECOND)); StopMusic (); FadeMusic (NORMAL_VOLUME, 0); GLOBAL (CurrentActivity) = (ACTIVITY)~0; return FALSE; } } SleepThreadUntil (TimeIn + ONE_SECOND / 30); return TRUE; }
static BOOLEAN RestartMenu (MENU_STATE *pMS) { TimeCount TimeOut; ReinitQueue (&race_q[0]); ReinitQueue (&race_q[1]); SetContext (ScreenContext); GLOBAL (CurrentActivity) |= CHECK_ABORT; if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0 && GET_GAME_STATE (UTWIG_BOMB_ON_SHIP) && !GET_GAME_STATE (UTWIG_BOMB)) { // player blew himself up with Utwig bomb SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0); SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND / 8) + ONE_SECOND / 60); SetContextBackGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); ClearDrawable (); FlushColorXForms (); TimeOut = ONE_SECOND / 8; } else { TimeOut = ONE_SECOND / 2; if (LOBYTE (LastActivity) == WON_LAST_BATTLE) { GLOBAL (CurrentActivity) = WON_LAST_BATTLE; Victory (); Credits (TRUE); FreeGameData (); GLOBAL (CurrentActivity) = CHECK_ABORT; } } LastActivity = 0; NextActivity = 0; // TODO: This fade is not always necessary, especially after a splash // screen. It only makes a user wait. SleepThreadUntil (FadeScreen (FadeAllToBlack, TimeOut)); if (TimeOut == ONE_SECOND / 8) SleepThread (ONE_SECOND * 3); pMS->CurFrame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM)); DrawRestartMenuGraphic (pMS); GLOBAL (CurrentActivity) &= ~CHECK_ABORT; SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetDefaultMenuRepeatDelay (); DoInput (pMS, TRUE); StopMusic (); if (pMS->hMusic) { DestroyMusic (pMS->hMusic); pMS->hMusic = 0; } Flash_terminate (pMS->flashContext); pMS->flashContext = 0; DestroyDrawable (ReleaseDrawable (pMS->CurFrame)); pMS->CurFrame = 0; if (GLOBAL (CurrentActivity) == (ACTIVITY)~0) return (FALSE); // timed out if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); // quit TimeOut = FadeScreen (FadeAllToBlack, ONE_SECOND / 2); SleepThreadUntil (TimeOut); FlushColorXForms (); SeedRandomNumbers (); return (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE); }
static BOOLEAN DoRestart (MENU_STATE *pMS) { static TimeCount LastInputTime; static TimeCount InactTimeOut; TimeCount TimeIn = GetTimeCounter (); /* Cancel any presses of the Pause key. */ GamePaused = FALSE; if(optSuperMelee && !optLoadGame && PacksInstalled()){ pMS->CurState = PLAY_SUPER_MELEE; PulsedInputState.menu[KEY_MENU_SELECT] = 65535; } if(optLoadGame && !optSuperMelee && PacksInstalled()){ pMS->CurState = LOAD_SAVED_GAME; PulsedInputState.menu[KEY_MENU_SELECT] = 65535; } if (pMS->Initialized) Flash_process(pMS->flashContext); if (!pMS->Initialized) { if (pMS->hMusic && !comingFromInit) { StopMusic (); DestroyMusic (pMS->hMusic); pMS->hMusic = 0; } pMS->hMusic = loadMainMenuMusic (Rando); InactTimeOut = (optMainMenuMusic ? 60 : 20) * ONE_SECOND; pMS->flashContext = Flash_createOverlay (ScreenContext, NULL, NULL); Flash_setMergeFactors (pMS->flashContext, -3, 3, 16); Flash_setSpeed (pMS->flashContext, (6 * ONE_SECOND) / 14, 0, (6 * ONE_SECOND) / 14, 0); Flash_setFrameTime (pMS->flashContext, ONE_SECOND / 16); Flash_setState(pMS->flashContext, FlashState_fadeIn, (3 * ONE_SECOND) / 16); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); Flash_start (pMS->flashContext); LastInputTime = GetTimeCounter (); pMS->Initialized = TRUE; SleepThreadUntil (FadeScreen (FadeAllToColor, ONE_SECOND / 2)); if (!comingFromInit){ FadeMusic(0,0); PlayMusic (pMS->hMusic, TRUE, 1); if (optMainMenuMusic) FadeMusic (NORMAL_VOLUME+70, ONE_SECOND * 3); } } else if (GLOBAL (CurrentActivity) & CHECK_ABORT) { return FALSE; } else if (PulsedInputState.menu[KEY_MENU_SELECT]) { //BYTE fade_buf[1]; COUNT oldresfactor; switch (pMS->CurState) { case LOAD_SAVED_GAME: if (!RestartMessage(pMS, TimeIn)) { LastActivity = CHECK_LOAD; GLOBAL (CurrentActivity) = IN_INTERPLANETARY; optLoadGame = FALSE; } else return TRUE; break; case START_NEW_GAME: if (!RestartMessage(pMS, TimeIn)) { LastActivity = CHECK_LOAD | CHECK_RESTART; GLOBAL (CurrentActivity) = IN_INTERPLANETARY; } else return TRUE; break; case PLAY_SUPER_MELEE: if (!RestartMessage(pMS, TimeIn)) { GLOBAL (CurrentActivity) = SUPER_MELEE; optSuperMelee = FALSE; } else return TRUE; break; case SETUP_GAME: oldresfactor = resolutionFactor; Flash_pause(pMS->flashContext); Flash_setState(pMS->flashContext, FlashState_fadeIn, (3 * ONE_SECOND) / 16); SetupMenu (); SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); InactTimeOut = (optMainMenuMusic ? 60 : 20) * ONE_SECOND; LastInputTime = GetTimeCounter (); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); ScreenTransition (3, NULL); // JMS_GFX: This prevents drawing an annoying wrong-sized "Setup" frame when changing resolution. if (oldresfactor < resolutionFactor) DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, TRUE); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); Flash_continue(pMS->flashContext); UnbatchGraphics (); return TRUE; case QUIT_GAME: SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); GLOBAL (CurrentActivity) = CHECK_ABORT; break; } Flash_pause(pMS->flashContext); return FALSE; } else if (PulsedInputState.menu[KEY_MENU_UP] || PulsedInputState.menu[KEY_MENU_DOWN]) { BYTE NewState; NewState = pMS->CurState; if (PulsedInputState.menu[KEY_MENU_UP]) { if (NewState == START_NEW_GAME) NewState = QUIT_GAME; else --NewState; } else if (PulsedInputState.menu[KEY_MENU_DOWN]) { if (NewState == QUIT_GAME) NewState = START_NEW_GAME; else ++NewState; } if (NewState != pMS->CurState) { BatchGraphics (); DrawRestartMenu (pMS, NewState, pMS->CurFrame, FALSE); UnbatchGraphics (); pMS->CurState = NewState; } LastInputTime = GetTimeCounter (); } else if (PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_RIGHT]) { // Does nothing, but counts as input for timeout purposes LastInputTime = GetTimeCounter (); } else if (MouseButtonDown) { Flash_pause(pMS->flashContext); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 54)); // Mouse not supported message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); ScreenTransition (3, NULL); UnbatchGraphics (); Flash_continue(pMS->flashContext); LastInputTime = GetTimeCounter (); } else { // No input received, check if timed out // JMS: After changing resolution mode, prevent displaying credits // (until the next time the game is restarted). This is to prevent // showing the credits with the wrong resolution mode's font&background. if (GetTimeCounter () - LastInputTime > InactTimeOut && !optRequiresRestart && PacksInstalled()) { SleepThreadUntil (FadeMusic (0, ONE_SECOND/2)); StopMusic (); FadeMusic (NORMAL_VOLUME, 0); GLOBAL (CurrentActivity) = (ACTIVITY)~0; return FALSE; } } comingFromInit = FALSE; SleepThreadUntil (TimeIn + ONE_SECOND / 30); return TRUE; }
static DeviceStatus InvokeDevice (BYTE which_device) { BYTE val; switch (which_device) { case ROSY_SPHERE_DEVICE: val = GET_GAME_STATE (ULTRON_CONDITION); if (val) { SET_GAME_STATE (ULTRON_CONDITION, val + 1); SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 0); SET_GAME_STATE (DISCUSSED_ULTRON, 0); SET_GAME_STATE (SUPOX_ULTRON_HELP, 0); return DEVICE_SUCCESS; } break; case ARTIFACT_2_DEVICE: break; case ARTIFACT_3_DEVICE: break; case SUN_EFFICIENCY_DEVICE: if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY && playerInPlanetOrbit ()) { PlayMenuSound (MENU_SOUND_INVOKED); SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND * 1) + (ONE_SECOND * 2)); if (CurStarDescPtr->Index != CHMMR_DEFINED || !matchWorld (pSolarSysState, pSolarSysState->pOrbitalDesc, 1, MATCH_PLANET)) { FadeScreen (FadeAllToColor, ONE_SECOND * 2); } else { SET_GAME_STATE (CHMMR_EMERGING, 1); EncounterGroup = 0; GLOBAL (CurrentActivity) |= START_ENCOUNTER; PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); CloneShipFragment (CHMMR_SHIP, &GLOBAL (npc_built_ship_q), 0); } return DEVICE_SUCCESS_NO_SOUND; } break; case UTWIG_BOMB_DEVICE: SET_GAME_STATE (UTWIG_BOMB, 0); GLOBAL (CurrentActivity) &= ~IN_BATTLE; GLOBAL_SIS (CrewEnlisted) = (COUNT)~0; return DEVICE_SUCCESS; case ULTRON_0_DEVICE: break; case ULTRON_1_DEVICE: break; case ULTRON_2_DEVICE: break; case ULTRON_3_DEVICE: break; case MAIDENS_DEVICE: break; case TALKING_PET_DEVICE: NextActivity |= CHECK_LOAD; /* fake a load game */ GLOBAL (CurrentActivity) |= START_ENCOUNTER; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 0); if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) { if (GetHeadEncounter ()) { SET_GAME_STATE (SHIP_TO_COMPEL, 1); } GLOBAL (CurrentActivity) &= ~IN_BATTLE; SaveSisHyperState (); } else { EncounterGroup = 0; if (GetHeadLink (&GLOBAL (ip_group_q))) { SET_GAME_STATE (SHIP_TO_COMPEL, 1); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); } if (CurStarDescPtr->Index == SAMATRA_DEFINED) { SET_GAME_STATE (READY_TO_CONFUSE_URQUAN, 1); } if (playerInPlanetOrbit ()) SaveSolarSysLocation (); } return DEVICE_SUCCESS; case AQUA_HELIX_DEVICE: val = GET_GAME_STATE (ULTRON_CONDITION); if (val) { SET_GAME_STATE (ULTRON_CONDITION, val + 1); SET_GAME_STATE (AQUA_HELIX_ON_SHIP, 0); SET_GAME_STATE (DISCUSSED_ULTRON, 0); SET_GAME_STATE (SUPOX_ULTRON_HELP, 0); return DEVICE_SUCCESS; } break; case CLEAR_SPINDLE_DEVICE: val = GET_GAME_STATE (ULTRON_CONDITION); if (val) { SET_GAME_STATE (ULTRON_CONDITION, val + 1); SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 0); SET_GAME_STATE (DISCUSSED_ULTRON, 0); SET_GAME_STATE (SUPOX_ULTRON_HELP, 0); return DEVICE_SUCCESS; } break; case UMGAH_HYPERWAVE_DEVICE: case BURVIX_HYPERWAVE_DEVICE: if (UseCaster ()) return DEVICE_SUCCESS; break; case TAALO_PROTECTOR_DEVICE: break; case EGG_CASING0_DEVICE: case EGG_CASING1_DEVICE: case EGG_CASING2_DEVICE: break; case SYREEN_SHUTTLE_DEVICE: break; case VUX_BEAST_DEVICE: break; case DESTRUCT_CODE_DEVICE: break; case PORTAL_SPAWNER_DEVICE: #define PORTAL_FUEL_COST (10 * FUEL_TANK_SCALE) if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE && GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1 && GLOBAL_SIS (FuelOnBoard) >= PORTAL_FUEL_COST) { /* No DeltaSISGauges because the flagship picture * is currently obscured. */ GLOBAL_SIS (FuelOnBoard) -= PORTAL_FUEL_COST; SET_GAME_STATE (PORTAL_COUNTER, 1); return DEVICE_SUCCESS; } break; case URQUAN_WARP_DEVICE: break; case LUNAR_BASE_DEVICE: break; } return DEVICE_FAILURE; }
static void ItemStorage_Deposit(u8 taskId) { TASK.FUNC = Task_ItemStorage_Deposit; FadeScreen(1, 0); }
static void Mailbox_DoMailRead(u8 taskId) { FadeScreen(1, 0); TASK.FUNC = Mailbox_FadeAndReadMail; }
static BOOLEAN DoRestart (MENU_STATE *pMS) { static TimeCount LastInputTime; static TimeCount InactTimeOut; TimeCount TimeIn = GetTimeCounter (); /* Cancel any presses of the Pause key. */ GamePaused = FALSE; if (pMS->Initialized) Flash_process(pMS->flashContext); if (!pMS->Initialized) { if (pMS->hMusic) { StopMusic (); DestroyMusic (pMS->hMusic); pMS->hMusic = 0; } pMS->hMusic = LoadMusic (MAINMENU_MUSIC); InactTimeOut = (pMS->hMusic ? 120 : 20) * ONE_SECOND; pMS->flashContext = Flash_createOverlay (ScreenContext, NULL, NULL); Flash_setMergeFactors (pMS->flashContext, -3, 3, 16); Flash_setSpeed (pMS->flashContext, (6 * ONE_SECOND) / 16, 0, (6 * ONE_SECOND) / 16, 0); Flash_setFrameTime (pMS->flashContext, ONE_SECOND / 16); Flash_setState(pMS->flashContext, FlashState_fadeIn, (3 * ONE_SECOND) / 16); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); Flash_start (pMS->flashContext); PlayMusic (pMS->hMusic, TRUE, 1); LastInputTime = GetTimeCounter (); pMS->Initialized = TRUE; SleepThreadUntil (FadeScreen (FadeAllToColor, ONE_SECOND / 2)); } else if (GLOBAL (CurrentActivity) & CHECK_ABORT) { return FALSE; } else if (PulsedInputState.menu[KEY_MENU_SELECT]) { //BYTE fade_buf[1]; COUNT oldresfactor; BOOLEAN packsInstalled; if (resolutionFactor == 0) packsInstalled = TRUE; else if (resolutionFactor == 1 && hires2xPackPresent) packsInstalled = TRUE; else if (resolutionFactor == 2 && hires4xPackPresent) packsInstalled = TRUE; else packsInstalled = FALSE; switch (pMS->CurState) { case LOAD_SAVED_GAME: if (resFactorWasChanged) { LockMutex (GraphicsLock); SetFlashRect (NULL); UnlockMutex (GraphicsLock); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 35)); // Got to restart -message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); ScreenTransition (3, NULL); UnbatchGraphics (); //fade_buf[0] = FadeAllToBlack; //SleepThreadUntil (XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND / 2)); SleepThreadUntil (FadeScreen(FadeAllToBlack, ONE_SECOND / 2)); GLOBAL (CurrentActivity) = CHECK_ABORT; } else if (!packsInstalled) { Flash_pause(pMS->flashContext); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 35 + resolutionFactor)); // Could not find graphics pack - message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); ScreenTransition (3, NULL); UnbatchGraphics (); Flash_continue(pMS->flashContext); SleepThreadUntil (TimeIn + ONE_SECOND / 30); return TRUE; } else { LastActivity = CHECK_LOAD; GLOBAL (CurrentActivity) = IN_INTERPLANETARY; } break; case START_NEW_GAME: if (resFactorWasChanged) { LockMutex (GraphicsLock); SetFlashRect (NULL); UnlockMutex (GraphicsLock); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 35)); // Got to restart -message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); ScreenTransition (3, NULL); UnbatchGraphics (); //fade_buf[0] = FadeAllToBlack; //SleepThreadUntil (XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND / 2)); SleepThreadUntil (FadeScreen(FadeAllToBlack, ONE_SECOND / 2)); GLOBAL (CurrentActivity) = CHECK_ABORT; } else if (!packsInstalled) { Flash_pause(pMS->flashContext); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 35 + resolutionFactor)); // Could not find graphics pack - message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); ScreenTransition (3, NULL); UnbatchGraphics (); Flash_continue(pMS->flashContext); SleepThreadUntil (TimeIn + ONE_SECOND / 30); return TRUE; } else { LastActivity = CHECK_LOAD | CHECK_RESTART; GLOBAL (CurrentActivity) = IN_INTERPLANETARY; } break; case PLAY_SUPER_MELEE: if (resFactorWasChanged) { LockMutex (GraphicsLock); SetFlashRect (NULL); UnlockMutex (GraphicsLock); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 35)); // Got to restart -message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); ScreenTransition (3, NULL); UnbatchGraphics (); //fade_buf[0] = FadeAllToBlack; //SleepThreadUntil (XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND / 2)); SleepThreadUntil (FadeScreen(FadeAllToBlack, ONE_SECOND / 2)); GLOBAL (CurrentActivity) = CHECK_ABORT; } else if (!packsInstalled) { Flash_pause(pMS->flashContext); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 35 + resolutionFactor)); // Could not find graphics pack - message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); ScreenTransition (3, NULL); UnbatchGraphics (); Flash_continue(pMS->flashContext); SleepThreadUntil (TimeIn + ONE_SECOND / 30); return TRUE; } else { GLOBAL (CurrentActivity) = SUPER_MELEE; } break; case SETUP_GAME: oldresfactor = resolutionFactor; Flash_pause(pMS->flashContext); Flash_setState(pMS->flashContext, FlashState_fadeIn, (3 * ONE_SECOND) / 16); SetupMenu (); SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); LastInputTime = GetTimeCounter (); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); ScreenTransition (3, NULL); // JMS_GFX: This prevents drawing an annoying wrong-sized "Setup" frame when changing resolution. if (oldresfactor < resolutionFactor) DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, TRUE); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); Flash_continue(pMS->flashContext); UnbatchGraphics (); return TRUE; case QUIT_GAME: SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2)); GLOBAL (CurrentActivity) = CHECK_ABORT; break; } Flash_pause(pMS->flashContext); return FALSE; } else if (PulsedInputState.menu[KEY_MENU_UP] || PulsedInputState.menu[KEY_MENU_DOWN]) { BYTE NewState; NewState = pMS->CurState; if (PulsedInputState.menu[KEY_MENU_UP]) { if (NewState == START_NEW_GAME) NewState = QUIT_GAME; else --NewState; } else if (PulsedInputState.menu[KEY_MENU_DOWN]) { if (NewState == QUIT_GAME) NewState = START_NEW_GAME; else ++NewState; } if (NewState != pMS->CurState) { BatchGraphics (); DrawRestartMenu (pMS, NewState, pMS->CurFrame, FALSE); UnbatchGraphics (); pMS->CurState = NewState; } LastInputTime = GetTimeCounter (); } else if (PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_RIGHT]) { // Does nothing, but counts as input for timeout purposes LastInputTime = GetTimeCounter (); } else if (MouseButtonDown) { Flash_pause(pMS->flashContext); DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 54)); // Mouse not supported message SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame, FALSE); ScreenTransition (3, NULL); UnbatchGraphics (); Flash_continue(pMS->flashContext); LastInputTime = GetTimeCounter (); } else { // No input received, check if timed out if (GetTimeCounter () - LastInputTime > InactTimeOut) { SleepThreadUntil (FadeMusic (0, ONE_SECOND)); StopMusic (); FadeMusic (NORMAL_VOLUME, 0); GLOBAL (CurrentActivity) = (ACTIVITY)~0; return FALSE; } } SleepThreadUntil (TimeIn + ONE_SECOND / 30); return TRUE; }