static void DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode) { RECT r; SetContext (SpaceContext); GetContextClipRect (&r); BatchGraphics (); if (Mode != DRAW_ORBITAL_UPDATE) { SetTransitionSource (NULL); DrawSISFrame (); DrawSISMessage (NULL); DrawSISTitle (GLOBAL_SIS (PlanetName)); DrawStarBackGround (); DrawPlanetSurfaceBorder (); } if (Mode == DRAW_ORBITAL_WAIT) { STAMP s; SetContext (GetScanContext (NULL)); s.frame = CaptureDrawable (LoadGraphic (ORBENTER_PMAP_ANIM)); s.origin.x = -SAFE_X; s.origin.y = 0; DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); } else if (Mode == DRAW_ORBITAL_FULL) { DrawDefaultPlanetSphere (); } if (Mode != DRAW_ORBITAL_WAIT) { SetContext (GetScanContext (NULL)); DrawPlanet (0, BLACK_COLOR); } if (Mode != DRAW_ORBITAL_UPDATE) { ScreenTransition (3, &r); } UnbatchGraphics (); // for later RepairBackRect() // JMS_GFX if (RESOLUTION_FACTOR == 0) LoadIntoExtraScreen (&r); else LoadIntoExtraScreen_Fs (&r); }
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 void DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode) { RECT r = { { SIS_ORG_X, SIS_ORG_Y }, { SIS_SCREEN_WIDTH, SIS_SCREEN_HEIGHT } }; BatchGraphics (); if (Mode != DRAW_ORBITAL_UPDATE) { SetTransitionSource (NULL); DrawSISFrame (); DrawSISMessage (NULL_PTR); DrawSISTitle (GLOBAL_SIS (PlanetName)); DrawStarBackGround (TRUE); } SetContext (SpaceContext); if (Mode == DRAW_ORBITAL_WAIT) { STAMP s; s.frame = CaptureDrawable ( LoadGraphic (ORBENTER_PMAP_ANIM)); s.origin.x = -SAFE_X; s.origin.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT; DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); } else { DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0); } if (Mode != DRAW_ORBITAL_UPDATE) { ScreenTransition (3, &r); } UnbatchGraphics (); if (Mode != DRAW_ORBITAL_WAIT) { LoadIntoExtraScreen (&r); } }
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 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 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; }
static BOOLEAN DoRestart (PMENU_STATE pMS) { static DWORD InTime; static DWORD InactTimeOut; /* Cancel any presses of the Pause key. */ GamePaused = FALSE; 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; PlayMusic (pMS->hMusic, TRUE, 1); DrawRestartMenu ((BYTE)~0, pMS->CurState, pMS->CurFrame); pMS->Initialized = TRUE; { BYTE clut_buf[] = {FadeAllToColor}; DWORD TimeOut = XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 2); while ((GetTimeCounter () <= TimeOut) && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { UpdateInputState (); TaskSwitch (); } } } #ifdef TESTING else if (InputState & DEVICE_EXIT) return (FALSE); #endif /* TESTING */ else if (GLOBAL (CurrentActivity) & CHECK_ABORT) { return (FALSE); } else if (!(PulsedInputState.menu[KEY_MENU_UP] || PulsedInputState.menu[KEY_MENU_DOWN] || PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_RIGHT] || PulsedInputState.menu[KEY_MENU_SELECT] || MouseButtonDown)) { if (GetTimeCounter () - InTime < InactTimeOut) return (TRUE); SleepThreadUntil (FadeMusic (0, ONE_SECOND)); StopMusic (); FadeMusic (NORMAL_VOLUME, 0); GLOBAL (CurrentActivity) = (ACTIVITY)~0; return (FALSE); } else if (PulsedInputState.menu[KEY_MENU_SELECT]) { BYTE fade_buf[1]; 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: LockMutex (GraphicsLock); SetFlashRect (NULL_PTR, (FRAME)0); UnlockMutex (GraphicsLock); SetupMenu (); SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); InTime = GetTimeCounter (); SetTransitionSource (NULL); BatchGraphics (); DrawRestartMenuGraphic (pMS); DrawRestartMenu ((BYTE)~0, pMS->CurState, pMS->CurFrame); ScreenTransition (3, NULL); UnbatchGraphics (); return TRUE; case QUIT_GAME: fade_buf[0] = FadeAllToBlack; SleepThreadUntil (XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND / 2)); GLOBAL (CurrentActivity) = CHECK_ABORT; break; } LockMutex (GraphicsLock); SetFlashRect (NULL_PTR, (FRAME)0); UnlockMutex (GraphicsLock); return (FALSE); } else { BYTE NewState; NewState = pMS->CurState; if (PulsedInputState.menu[KEY_MENU_UP]) { if (NewState-- == START_NEW_GAME) NewState = QUIT_GAME; } else if (PulsedInputState.menu[KEY_MENU_DOWN]) { if (NewState++ == QUIT_GAME) NewState = START_NEW_GAME; } if (NewState != pMS->CurState) { BatchGraphics (); DrawRestartMenu (pMS->CurState, NewState, pMS->CurFrame); UnbatchGraphics (); pMS->CurState = NewState; } } // if (MouseButtonDown) // { // LockMutex (GraphicsLock); // SetFlashRect (NULL_PTR, (FRAME)0); // UnlockMutex (GraphicsLock); // MouseError (); // SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT); // SetTransitionSource (NULL); // BatchGraphics (); // DrawRestartMenuGraphic (pMS); // DrawRestartMenu ((BYTE)~0, pMS->CurState, pMS->CurFrame); // ScreenTransition (3, NULL); // UnbatchGraphics (); // } if (MouseButtonDown) { // TODO WTF FIX GAME CONTROLS } InTime = GetTimeCounter (); return (TRUE); }
static BOOLEAN DoBattle (BATTLE_STATE *bs) { extern UWORD nth_frame; RECT r; BYTE battle_speed; SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); #if defined (NETPLAY) && defined (NETPLAY_CHECKSUM) if (getNumNetConnections() > 0 && battleFrameCount % NETPLAY_CHECKSUM_INTERVAL == 0) { crc_State state; Checksum checksum; crc_init(&state); crc_processState (&state); checksum = (Checksum) crc_finish (&state); Netplay_NotifyAll_checksum ((uint32) battleFrameCount, (uint32) checksum); flushPacketQueues (); addLocalChecksum (battleFrameCount, checksum); } #endif ProcessInput (); // Also calls NetInput() #if defined (NETPLAY) && defined (NETPLAY_CHECKSUM) if (getNumNetConnections() > 0) { size_t delay = getBattleInputDelay(); if (battleFrameCount >= delay && (battleFrameCount - delay) % NETPLAY_CHECKSUM_INTERVAL == 0) { if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) { if (!verifyChecksums (battleFrameCount - delay)) { GLOBAL(CurrentActivity) |= CHECK_ABORT; resetConnections (ResetReason_syncLoss); } } } } #endif LockMutex (GraphicsLock); if (bs->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; SetTransitionSource (&r); } BatchGraphics (); // Call the callback function, if set if (bs->frame_cb) bs->frame_cb (); RedrawQueue (TRUE); if (bs->first_time) { bs->first_time = FALSE; ScreenTransition (3, &r); } UnbatchGraphics (); UnlockMutex (GraphicsLock); if ((!(GLOBAL (CurrentActivity) & IN_BATTLE)) || (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) { return FALSE; } battle_speed = HIBYTE (nth_frame); if (battle_speed == (BYTE)~0) { // maximum speed, nothing rendered at all TaskSwitch (); } else { SleepThreadUntil (bs->NextTime + BATTLE_FRAME_RATE / (battle_speed + 1)); bs->NextTime = GetTimeCounter (); } if ((GLOBAL (CurrentActivity) & IN_BATTLE) == 0) return FALSE; #ifdef NETPLAY battleFrameCount++; #endif return TRUE; }
BOOLEAN ProcessCommAnimations (BOOLEAN FullRedraw, BOOLEAN paused) { if (paused) { // Drive colormap xforms and nothing else XFormColorMap_step (); return FALSE; } else { COUNT i; SEQUENCE *pSeq; BOOLEAN Change; BOOLEAN CanTalk = TRUE; TimeCount CurTime; DWORD ElapsedTicks; DWORD NextActiveMask; CurTime = GetTimeCounter (); ElapsedTicks = CurTime - LastTime; LastTime = CurTime; // Process ambient animations NextActiveMask = ActiveMask; pSeq = Sequences + FirstAmbient; for (i = 0; i < CommData.NumAnimations; ++i, ++pSeq) { ANIMATION_DESC *ADPtr = pSeq->ADPtr; DWORD ActiveBit = 1L << i; // JMS: Shofixti Colony comm screen anims start after lighting up. if (ADPtr->AnimFlags & ANIM_DISABLED && CommData.AlienConv == SHOFIXTICOLONY_CONVERSATION && GET_GAME_STATE (SHOFIXTI_COLONY_MET) > 1 && i < CommData.NumAnimations - 1 ) ADPtr->AnimFlags &= ~ANIM_DISABLED; // JMS: Shofixti Colony comm screen is blacked out upon the first encounter. if ((ADPtr->AnimFlags & ANIM_DISABLED) || (CommData.AlienConv == SHOFIXTICOLONY_CONVERSATION && GET_GAME_STATE (SHOFIXTI_COLONY_MET) == 0 && i < CommData.NumAnimations - 1) || (CommData.AlienConv == SHOFIXTICOLONY_CONVERSATION && GET_GAME_STATE (SHOFIXTI_COLONY_MET) >= 1 && i == CommData.NumAnimations - 1) ) continue; if (pSeq->Direction == NO_DIR) { // animation is paused if (!conflictsWithTalkingAnim (pSeq)) { // start it up pSeq->Direction = UP_DIR; } } else if (pSeq->Alarm > ElapsedTicks) { // not time yet pSeq->Alarm -= ElapsedTicks; } else if (ActiveMask & ADPtr->BlockMask) { // animation is blocked assert (!(ActiveMask & ActiveBit) && "Check animations' mutual blocking masks"); assert (animAtNeutralIndex (pSeq)); // reschedule pSeq->Alarm = randomRestartRate (pSeq) + 1; continue; } else { // Time to start or advance the animation if (AdvanceAmbientSequence (pSeq)) { // Animation is active this frame and the next ActiveMask |= ActiveBit; NextActiveMask |= ActiveBit; } else { // Animation remains active this frame but not the next // This keeps any conflicting animations (BlockMask) // from activating in the same frame and scribbling over // our last image. NextActiveMask &= ~ActiveBit; } } if (pSeq->AnimType == PICTURE_ANIM && pSeq->Direction != NO_DIR && conflictsWithTalkingAnim (pSeq)) { // We want to talk, but this is a running picture animation // which conflicts with the talking animation // See if it is safe to stop it now. if (animAtNeutralIndex (pSeq)) { // pause the animation pSeq->Direction = NO_DIR; NextActiveMask &= ~ActiveBit; // Talk animation is drawn last, so it's not a conflict // for this frame. The talk animation will be drawn // over the neutral frame. } else { // Otherwise, let the animation run until it's safe CanTalk = FALSE; } } // BW: to be checked. I've tried to remove what's supposed to be removed while keeping the Syreen zoom-in feature. // It may have to be re-programmed in the new commanim style. if (pSeq->AnimType == PICTURE_ANIM && (ADPtr->AnimFlags & CommData.AlienTalkDesc.AnimFlags & WAIT_TALKING) && pSeq->Direction != NO_DIR) { // JMS: Cut marked animations short when starting talk. // The animations are marked with FAST_STOP_AT_TALK_START in the races' comm source codes. if (ADPtr->AnimFlags & FAST_STOP_AT_TALK_START) { CanTalk = TRUE; //pSeq->AnimObj.CurFrame = SetAbsFrameIndex(pSeq->AnimObj.CurFrame, ADPtr->StartIndex); pSeq->Direction = NO_DIR; } } // JMS: This handles ambient animations which should occur only during talk // A lot of conditions are necessary to eliminate unwanted animations // from the duration of talk transition! if (pSeq->AnimType == PICTURE_ANIM && ADPtr->AnimFlags & WHEN_TALKING && (!(CommData.AlienTalkDesc.AnimFlags & WAIT_TALKING) || (CommData.AlienTalkDesc.AnimFlags & TALK_INTRO) || (CommData.AlienTalkDesc.AnimFlags & TALK_DONE)) && !(CommData.AlienTransitionDesc.AnimFlags & PAUSE_TALKING) && pSeq->Direction != NO_DIR) { // Stop the anim if not talking pSeq->Direction = NO_DIR; } } // All ambient animations have been processed. Advance the mask. ActiveMask = NextActiveMask; // Process the talking and transition animations if (CanTalk && haveTalkingAnim () && runningTalkingAnim ()) { BOOLEAN done = FALSE; // for (i = 0; i < CommData.NumAnimations; i++) // if (ActiveMask & (1L << i) // && CommData.AlienAmbientArray[i].AnimFlags & WAIT_TALKING // && !(CommData.AlienAmbientArray[i].AnimFlags & FAST_STOP_AT_TALK_START)) // JMS: Don't wait for fast-stopped animations // done = TRUE; // to finish (would have to wait forever). // if (!done) // { if (signaledStopTalkingAnim () && haveTransitionAnim ()) { // Run the transition. We will clear everything // when it is done CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; } if (CommData.AlienTransitionDesc.AnimFlags & (TALK_INTRO | TALK_DONE)) { // Transitioning in or out of talking if ((CommData.AlienTransitionDesc.AnimFlags & TALK_DONE) && Transit->Direction == NO_DIR) { // This is needed when switching talking anims ResetSequence (Talk); } done = AdvanceTransitSequence (Transit, ElapsedTicks); } else if (!signaledStopTalkingAnim ()) { // Talking, transition is done AdvanceTalkingSequence (Talk, ElapsedTicks); } else { // Not talking ResetSequence (Talk); done = TRUE; } if (signaledStopTalkingAnim () && done) { clearRunTalkingAnim (); clearStopTalkingAnim (); } } else { // Not talking -- disable talking anim if it is done if (Talk->Direction == NO_DIR) TalkDesc.AnimFlags |= ANIM_DISABLED; } BatchGraphics (); // Draw all animations { BOOLEAN ColorChange = XFormColorMap_step (); if (ColorChange) FullRedraw = TRUE; // JMS: Shofixti Colony comm screen lights up. if (CommData.AlienConv == SHOFIXTICOLONY_CONVERSATION && GET_GAME_STATE (SHOFIXTI_COLONY_MET) == 1) { LockMutex (GraphicsLock); SetTransitionSource (&CommWndRect); DrawAlienFrame (NULL, 0, TRUE); ScreenTransition (3, &CommWndRect); UnlockMutex (GraphicsLock); SET_GAME_STATE (SHOFIXTI_COLONY_MET, 2); CommData.AlienAmbientArray[CommData.NumAnimations-1].AnimFlags |= ANIM_DISABLED; } // Colormap animations are processed separately // from picture anims (see XFormColorMap_step) ProcessColormapAnims (Sequences + FirstAmbient, CommData.NumAnimations); Change = DrawAlienFrame (Sequences, TotalSequences, FullRedraw); if (FullRedraw) Change = TRUE; } UnbatchGraphics (); // Post-process ambient animations pSeq = Sequences + FirstAmbient; for (i = 0; i < CommData.NumAnimations; ++i, ++pSeq) { ANIMATION_DESC *ADPtr = pSeq->ADPtr; DWORD ActiveBit = 1L << i; if (ADPtr->AnimFlags & ANIM_DISABLED) continue; // We can only disable a one-shot anim here, otherwise the // last frame will not be drawn if ((ADPtr->AnimFlags & ONE_SHOT_ANIM) && !(NextActiveMask & ActiveBit)) { // One-shot animation, inactive next frame ADPtr->AnimFlags |= ANIM_DISABLED; } } return Change; } }