Rearranged the StartGame() code paths to make it cleaner and allow it to return FALSE on Quit (partially fixes #52); Intro now plays on New Game only, and Main menu times out into Credits
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2220 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -87,7 +87,8 @@ DoConfirmExit (void)
|
|||||||
static BOOLEAN in_confirm = FALSE;
|
static BOOLEAN in_confirm = FALSE;
|
||||||
fprintf (stderr, "Confirming Exit!\n");
|
fprintf (stderr, "Confirming Exit!\n");
|
||||||
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
|
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
|
||||||
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE)
|
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE &&
|
||||||
|
!(LastActivity & CHECK_RESTART))
|
||||||
SuspendGameClock ();
|
SuspendGameClock ();
|
||||||
if (CommData.ConversationPhrases && PlayingTrack ())
|
if (CommData.ConversationPhrases && PlayingTrack ())
|
||||||
PauseTrack ();
|
PauseTrack ();
|
||||||
@@ -180,7 +181,8 @@ DoConfirmExit (void)
|
|||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
|
|
||||||
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
|
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
|
||||||
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE)
|
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE &&
|
||||||
|
!(LastActivity & CHECK_RESTART))
|
||||||
ResumeGameClock ();
|
ResumeGameClock ();
|
||||||
if (CommData.ConversationPhrases && PlayingTrack ())
|
if (CommData.ConversationPhrases && PlayingTrack ())
|
||||||
{
|
{
|
||||||
|
|||||||
+18
-18
@@ -75,7 +75,7 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Introduction (void)
|
SplashScreen (void (* DoProcessing)(DWORD TimeOut))
|
||||||
{
|
{
|
||||||
BYTE xform_buf[1];
|
BYTE xform_buf[1];
|
||||||
STAMP s;
|
STAMP s;
|
||||||
@@ -95,16 +95,9 @@ Introduction (void)
|
|||||||
|
|
||||||
xform_buf[0] = FadeAllToColor;
|
xform_buf[0] = FadeAllToColor;
|
||||||
TimeOut = XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2);
|
TimeOut = XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2);
|
||||||
LoadMasterShipList ();
|
|
||||||
FlushInput ();
|
|
||||||
InitGameKernel ();
|
|
||||||
|
|
||||||
while ((GetTimeCounter () <= TimeOut) &&
|
if (DoProcessing)
|
||||||
!(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
DoProcessing (TimeOut);
|
||||||
{
|
|
||||||
UpdateInputState ();
|
|
||||||
TaskSwitch ();
|
|
||||||
}
|
|
||||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -136,15 +129,22 @@ Introduction (void)
|
|||||||
* engine. -- Michael */
|
* engine. -- Michael */
|
||||||
xform_buf[0] = FadeAllToBlack;
|
xform_buf[0] = FadeAllToBlack;
|
||||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2));
|
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2));
|
||||||
|
}
|
||||||
|
|
||||||
if (InputState == 0)
|
void
|
||||||
{ /* by default we do 3DO cinematics; or PC slides when 3DO files are
|
Introduction (void)
|
||||||
* not present */
|
{
|
||||||
if (optWhichIntro == OPT_PC ||
|
BYTE xform_buf[1];
|
||||||
!DoFMV ("slides/intro/intro.duk", NULL, TRUE))
|
|
||||||
ShowPresentation ( CaptureStringTable (
|
/* by default we do 3DO cinematics; or PC slides when 3DO files are
|
||||||
LoadStringTable (INTROPRES_STRTAB)));
|
* not present */
|
||||||
}
|
if (optWhichIntro == OPT_PC ||
|
||||||
|
!DoFMV ("slides/intro/intro.duk", NULL, TRUE))
|
||||||
|
ShowPresentation ( CaptureStringTable (
|
||||||
|
LoadStringTable (INTROPRES_STRTAB)));
|
||||||
|
|
||||||
|
xform_buf[0] = FadeAllToBlack;
|
||||||
|
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
extern void Logo (void);
|
extern void Logo (void);
|
||||||
|
extern void SplashScreen (void (* DoProcessing)(DWORD TimeOut));
|
||||||
extern void Introduction (void);
|
extern void Introduction (void);
|
||||||
extern void Victory (void);
|
extern void Victory (void);
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ LoadMasterShipList (void)
|
|||||||
RES_INSTANCE ri;
|
RES_INSTANCE ri;
|
||||||
RES_PACKAGE rp;
|
RES_PACKAGE rp;
|
||||||
|
|
||||||
if (master_q.head != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
rt = GET_TYPE (ARILOU_SHIP_INDEX);
|
rt = GET_TYPE (ARILOU_SHIP_INDEX);
|
||||||
ri = GET_INSTANCE (ARILOU_SHIP_INDEX);
|
ri = GET_INSTANCE (ARILOU_SHIP_INDEX);
|
||||||
rp = GET_PACKAGE (ARILOU_SHIP_INDEX);
|
rp = GET_PACKAGE (ARILOU_SHIP_INDEX);
|
||||||
@@ -94,9 +91,6 @@ if (master_q.head != 0)
|
|||||||
InsertQueue (&master_q, hBuiltShip, hStarShip);
|
InsertQueue (&master_q, hBuiltShip, hStarShip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskSwitch ();
|
|
||||||
// XXX: what is this doing here?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+140
-117
@@ -257,138 +257,161 @@ else if (InputState & DEVICE_EXIT) return (FALSE);
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
StartGame (void)
|
RestartMenu (PMENU_STATE pMS)
|
||||||
{
|
{
|
||||||
MENU_STATE MenuState;
|
DWORD TimeOut;
|
||||||
|
BYTE black_buf[1];
|
||||||
|
|
||||||
TimedOut:
|
ReinitQueue (&race_q[0]);
|
||||||
LastActivity = GLOBAL (CurrentActivity);
|
ReinitQueue (&race_q[1]);
|
||||||
GLOBAL (CurrentActivity) = 0;
|
|
||||||
if (LastActivity == (ACTIVITY)~0)
|
black_buf[0] = FadeAllToBlack;
|
||||||
|
|
||||||
|
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
|
||||||
|
BYTE white_buf[] = {FadeAllToWhite};
|
||||||
|
|
||||||
|
SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0);
|
||||||
|
|
||||||
|
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)white_buf,
|
||||||
|
ONE_SECOND / 8) + ONE_SECOND / 60);
|
||||||
|
SetContextBackGroundColor (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
|
||||||
|
ClearDrawable ();
|
||||||
|
FlushColorXForms ();
|
||||||
|
|
||||||
|
TimeOut = ONE_SECOND / 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Introduction ();
|
TimeOut = ONE_SECOND / 2;
|
||||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
|
||||||
|
if (LOBYTE (LastActivity) == WON_LAST_BATTLE)
|
||||||
{
|
{
|
||||||
TFB_Abort ();
|
GLOBAL (CurrentActivity) = WON_LAST_BATTLE;
|
||||||
|
Victory ();
|
||||||
|
Credits (TRUE);
|
||||||
|
|
||||||
|
FreeGameData ();
|
||||||
|
|
||||||
|
TimeOut = ONE_SECOND / 2;
|
||||||
|
GLOBAL (CurrentActivity) = CHECK_ABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset ((PMENU_STATE)&MenuState, 0, sizeof (MenuState));
|
LastActivity = NextActivity = 0;
|
||||||
|
|
||||||
|
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, TimeOut));
|
||||||
|
if (TimeOut == ONE_SECOND / 8)
|
||||||
|
SleepThread (ONE_SECOND * 3);
|
||||||
|
DrawRestartMenuGraphic (pMS);
|
||||||
|
FlushInput ();
|
||||||
|
GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
|
||||||
|
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
|
||||||
|
DoInput (pMS, TRUE);
|
||||||
|
|
||||||
|
StopMusic ();
|
||||||
|
if (pMS->hMusic)
|
||||||
|
{
|
||||||
|
DestroyMusic (pMS->hMusic);
|
||||||
|
pMS->hMusic = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LockMutex (GraphicsLock);
|
||||||
|
SetFlashRect ((PRECT)0, (FRAME)0);
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
|
DestroyDrawable (ReleaseDrawable (pMS->CurFrame));
|
||||||
|
|
||||||
|
if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
||||||
|
return (FALSE); // timed out
|
||||||
|
|
||||||
|
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||||
|
return (FALSE); // quit
|
||||||
|
|
||||||
|
TimeOut = XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND / 2);
|
||||||
|
|
||||||
|
SleepThreadUntil (TimeOut);
|
||||||
|
FlushColorXForms ();
|
||||||
|
|
||||||
|
SeedRandomNumbers ();
|
||||||
|
|
||||||
|
return (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
TryStartGame (void)
|
||||||
|
{
|
||||||
|
MENU_STATE MenuState;
|
||||||
|
|
||||||
|
LastActivity = GLOBAL (CurrentActivity);
|
||||||
|
GLOBAL (CurrentActivity) = 0;
|
||||||
|
|
||||||
|
memset (&MenuState, 0, sizeof (MenuState));
|
||||||
MenuState.InputFunc = DoRestart;
|
MenuState.InputFunc = DoRestart;
|
||||||
|
|
||||||
{
|
while (!RestartMenu (&MenuState))
|
||||||
DWORD TimeOut;
|
{ // spin until a game is started or loaded
|
||||||
BYTE black_buf[1];
|
if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE &&
|
||||||
|
!(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
||||||
TryAgain:
|
|
||||||
ReinitQueue (&race_q[0]);
|
|
||||||
ReinitQueue (&race_q[1]);
|
|
||||||
|
|
||||||
black_buf[0] = FadeAllToBlack;
|
|
||||||
|
|
||||||
SetContext (ScreenContext);
|
|
||||||
|
|
||||||
GLOBAL (CurrentActivity) |= CHECK_ABORT;
|
|
||||||
if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
|
|
||||||
&& GET_GAME_STATE (UTWIG_BOMB_ON_SHIP)
|
|
||||||
&& !GET_GAME_STATE (UTWIG_BOMB))
|
|
||||||
{
|
|
||||||
BYTE white_buf[] = {FadeAllToWhite};
|
|
||||||
|
|
||||||
SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0);
|
|
||||||
|
|
||||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)white_buf,
|
|
||||||
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;
|
|
||||||
#ifdef NOTYET
|
|
||||||
LastActivity = WON_LAST_BATTLE;
|
|
||||||
#endif /* NOTYET */
|
|
||||||
if (LOBYTE (LastActivity) == WON_LAST_BATTLE)
|
|
||||||
{
|
|
||||||
GLOBAL (CurrentActivity) = WON_LAST_BATTLE;
|
|
||||||
Victory ();
|
|
||||||
InitGameKernel ();
|
|
||||||
Credits (TRUE);
|
|
||||||
|
|
||||||
FreeGameData ();
|
|
||||||
|
|
||||||
TimeOut = ONE_SECOND / 2;
|
|
||||||
GLOBAL (CurrentActivity) = CHECK_ABORT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LastActivity = NextActivity = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, TimeOut));
|
|
||||||
if (TimeOut == ONE_SECOND / 8)
|
|
||||||
SleepThread (ONE_SECOND * 3);
|
|
||||||
DrawRestartMenuGraphic (&MenuState);
|
|
||||||
FlushInput ();
|
|
||||||
GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
|
|
||||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
|
|
||||||
DoInput ((PVOID)&MenuState, TRUE);
|
|
||||||
|
|
||||||
StopMusic ();
|
|
||||||
if (MenuState.hMusic)
|
|
||||||
{
|
|
||||||
DestroyMusic (MenuState.hMusic);
|
|
||||||
MenuState.hMusic = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
|
||||||
SetFlashRect ((PRECT)0, (FRAME)0);
|
|
||||||
UnlockMutex (GraphicsLock);
|
|
||||||
DestroyDrawable (ReleaseDrawable (MenuState.CurFrame));
|
|
||||||
|
|
||||||
if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
|
||||||
goto TimedOut;
|
|
||||||
|
|
||||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
|
||||||
{
|
|
||||||
TFB_Abort ();
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeOut = XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
SleepThreadUntil (TimeOut);
|
|
||||||
FlushColorXForms ();
|
|
||||||
|
|
||||||
SeedRandomNumbers ();
|
|
||||||
|
|
||||||
if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE)
|
|
||||||
{
|
{
|
||||||
FreeGameData ();
|
FreeGameData ();
|
||||||
Melee ();
|
Melee ();
|
||||||
MenuState.Initialized = FALSE;
|
MenuState.Initialized = FALSE;
|
||||||
goto TryAgain;
|
|
||||||
}
|
}
|
||||||
|
else if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
||||||
{
|
{ // timed out
|
||||||
extern STAR_DESC starmap_array[];
|
BYTE black_buf[] = {FadeAllToBlack};
|
||||||
extern const BYTE element_array[];
|
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf,
|
||||||
extern const PlanetFrame planet_array[];
|
ONE_SECOND / 2));
|
||||||
|
return (FALSE);
|
||||||
star_array = starmap_array;
|
}
|
||||||
Elements = element_array;
|
else if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||||
PlanData = planet_array;
|
{ // quit
|
||||||
}
|
return (FALSE);
|
||||||
|
}
|
||||||
PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING;
|
|
||||||
PlayerControl[1] = COMPUTER_CONTROL | AWESOME_RATING;
|
|
||||||
SetPlayerInput ();
|
|
||||||
return (TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (FALSE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
StartGame (void)
|
||||||
|
{
|
||||||
|
while (!TryStartGame ())
|
||||||
|
{
|
||||||
|
if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
||||||
|
{ // timed out
|
||||||
|
GLOBAL (CurrentActivity) = 0;
|
||||||
|
SplashScreen (0);
|
||||||
|
Credits (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||||
|
return (FALSE); // quit
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LastActivity & CHECK_RESTART)
|
||||||
|
{ // starting a new game
|
||||||
|
Introduction ();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
extern STAR_DESC starmap_array[];
|
||||||
|
extern const BYTE element_array[];
|
||||||
|
extern const PlanetFrame planet_array[];
|
||||||
|
|
||||||
|
star_array = starmap_array;
|
||||||
|
Elements = element_array;
|
||||||
|
PlanData = planet_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING;
|
||||||
|
PlayerControl[1] = COMPUTER_CONTROL | AWESOME_RATING;
|
||||||
|
SetPlayerInput ();
|
||||||
|
|
||||||
|
return (TRUE);
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
#include "restart.h"
|
#include "restart.h"
|
||||||
#include "starbase.h"
|
#include "starbase.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
#include "master.h"
|
||||||
|
#include "controls.h"
|
||||||
#include "starcon.h"
|
#include "starcon.h"
|
||||||
#include "uqmdebug.h"
|
#include "uqmdebug.h"
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
@@ -75,6 +77,20 @@ arilou_gate_task(void *data)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
BackgroundInitKernel (DWORD TimeOut)
|
||||||
|
{
|
||||||
|
LoadMasterShipList ();
|
||||||
|
TaskSwitch ();
|
||||||
|
InitGameKernel ();
|
||||||
|
|
||||||
|
while ((GetTimeCounter () <= TimeOut) &&
|
||||||
|
!(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
||||||
|
{
|
||||||
|
UpdateInputState ();
|
||||||
|
TaskSwitch ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define DEBUG_PSYTRON 0
|
#define DEBUG_PSYTRON 0
|
||||||
|
|
||||||
@@ -127,6 +143,10 @@ while (--ac > 0)
|
|||||||
fprintf (stderr, "We've loaded the Kernel\n");
|
fprintf (stderr, "We've loaded the Kernel\n");
|
||||||
|
|
||||||
Logo ();
|
Logo ();
|
||||||
|
|
||||||
|
GLOBAL (CurrentActivity) = 0;
|
||||||
|
// show splash and init the kernel in the meantime
|
||||||
|
SplashScreen (BackgroundInitKernel);
|
||||||
|
|
||||||
// OpenJournal ();
|
// OpenJournal ();
|
||||||
while (StartGame ())
|
while (StartGame ())
|
||||||
@@ -249,6 +269,8 @@ while (--ac > 0)
|
|||||||
UninitSIS ();
|
UninitSIS ();
|
||||||
}
|
}
|
||||||
// CloseJournal ();
|
// CloseJournal ();
|
||||||
|
|
||||||
|
FreeGameData ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -256,6 +278,10 @@ while (--ac > 0)
|
|||||||
}
|
}
|
||||||
FreeKernel ();
|
FreeKernel ();
|
||||||
|
|
||||||
|
// XXX: the abort can now be changed to something cleaner;
|
||||||
|
// something to terminate the for(;;) loop in main()
|
||||||
|
TFB_Abort ();
|
||||||
|
|
||||||
(void) threadArg; /* Satisfying compiler (unused parameter) */
|
(void) threadArg; /* Satisfying compiler (unused parameter) */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user