Flattened palette transforms into the general animation thread

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@314 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2002-12-04 04:36:14 +00:00
parent c9af4829b1
commit db100b7b20
4 changed files with 210 additions and 849 deletions
+2 -2
View File
@@ -85,10 +85,10 @@ So be it - The Empire of
#(FUEL_UP0) coman016.ogg #(FUEL_UP0) coman016.ogg
We are initiating transfer of radioactives, Captain. We are initiating transfer of radioactives, Captain.
Now, as soon as our engineers can refit the energy cores Now, as soon as our engineers can refit the energy cores...
#(FUEL_UP1) coman017.ogg #(FUEL_UP1) coman017.ogg
there, that's much better. Power ratings are climbing, life support is coming back into the green. ...there, that's much better. Power ratings are climbing, life support is coming back into the green.
Deep radar systems and sensors are now online and I can scan your vessel. Deep radar systems and sensors are now online and I can scan your vessel.
!!!? -- WHAT THE HELL KIND OF SHIP IS THAT!? !!!? -- WHAT THE HELL KIND OF SHIP IS THAT!?
Just who ARE you, Captain? Just who ARE you, Captain?
+107 -78
View File
@@ -358,64 +358,86 @@ DrawAlienFrame (FRAME aframe, PSEQUENCE pSeq)
UnbatchGraphics (); UnbatchGraphics ();
} }
static struct typedef struct xform_control
{ {
COLORMAPPTR CMapPtr; COLORMAPPTR CMapPtr;
SIZE Ticks; SIZE Ticks, TTotal, TOrig;
Task XFormTask; DWORD OldCMap[NUMBER_OF_PLUT_UINT32s];
} TaskControl; } XFORM_CONTROL;
#define MAX_XFORMS 32
static struct {
XFORM_CONTROL TaskControl[MAX_XFORMS];
volatile int XFormCurrent, XFormInsertPoint;
volatile BOOLEAN XFormsPending;
Semaphore XFormSem;
} XFormControl;
void
init_xform_control ()
{
XFormControl.XFormCurrent = XFormControl.XFormInsertPoint = 0;
XFormControl.XFormsPending = FALSE;
XFormControl.XFormSem = CreateSemaphore (1);
}
void
uninit_xform_control ()
{
DestroySemaphore (XFormControl.XFormSem);
}
void
xform_complete ()
{
SetSemaphore (XFormControl.XFormSem);
if (XFormControl.XFormsPending)
{
SetColorMap (XFormControl.TaskControl[XFormControl.XFormCurrent].CMapPtr);
if (++XFormControl.XFormCurrent >= MAX_XFORMS)
{
XFormControl.XFormCurrent = 0;
}
if (XFormControl.XFormCurrent == XFormControl.XFormInsertPoint)
{
XFormControl.XFormsPending = FALSE;
}
}
ClearSemaphore (XFormControl.XFormSem);
}
static BOOLEAN ColorChange; static BOOLEAN ColorChange;
static BOOLEAN volatile XFormFlush;
static COUNT volatile NumXFormTasks;
int xform_PLUT_task (void* data) /* Only one thread should ever be allowed to be calling this at any time */
void
xform_PLUT_step (SIZE TDelta)
{ {
COLORMAPPTR CurMapPtr; XFORM_CONTROL *control;
Task task = (Task) data;
while (TaskControl.XFormTask == 0 && !Task_ReadState (task, TASK_EXIT))
TaskSwitch ();
TaskControl.XFormTask = 0;
CurMapPtr = TaskControl.CMapPtr;
{
BYTE i;
SIZE TDelta, TTotal, TTotalOrig;
DWORD CurTime;
DWORD OldCMap[NUMBER_OF_PLUT_UINT32s], *pOldCMap, *pCurCMap;
pCurCMap = (DWORD *)((BYTE *)_varPLUTs + (*CurMapPtr * PLUT_BYTE_SIZE));
pOldCMap = OldCMap;
for (i = 0; i < NUMBER_OF_PLUT_UINT32s; ++i)
*pOldCMap++ = *pCurCMap++;
TTotal = TTotalOrig = TaskControl.Ticks;
TaskControl.CMapPtr = 0;
CurTime = GetTimeCounter ();
do
{
DWORD StartTime;
COLORMAPPTR ColorMapPtr; COLORMAPPTR ColorMapPtr;
DWORD *pCurCMap, *pOldCMap;
int i;
StartTime = CurTime; if (!XFormControl.XFormsPending)
SleepThread (2); return;
CurTime = GetTimeCounter ();
if (XFormFlush || (TDelta = (SIZE)(CurTime - StartTime)) > TTotal) control = &XFormControl.TaskControl[XFormControl.XFormCurrent];
TDelta = TTotal;
ColorMapPtr = control->CMapPtr;
if (TDelta > control->TTotal)
TDelta = control->TTotal;
ColorMapPtr = CurMapPtr;
pCurCMap = (DWORD *)((BYTE *)_varPLUTs + (*ColorMapPtr * PLUT_BYTE_SIZE)); pCurCMap = (DWORD *)((BYTE *)_varPLUTs + (*ColorMapPtr * PLUT_BYTE_SIZE));
pOldCMap = OldCMap; pOldCMap = control->OldCMap;
ColorMapPtr += 2; ColorMapPtr += 2;
i = NUMBER_OF_PLUT_UINT32s;
if (_varPLUTs) if (_varPLUTs)
do {
for (i = 0; i < NUMBER_OF_PLUT_UINT32s; i++)
{ {
SIZE c0, c1; SIZE c0, c1;
DWORD v0, v1, val; DWORD v0, v1, val;
float f = (TTotalOrig - TTotal) / (float)TTotalOrig; float f = (control->TOrig - control->TTotal) / (float)control->TOrig;
COLORMAPPTR oldmap = (COLORMAPPTR) pOldCMap; COLORMAPPTR oldmap = (COLORMAPPTR) pOldCMap;
v0 = MAKE_DWORD v0 = MAKE_DWORD
@@ -470,29 +492,27 @@ int xform_PLUT_task (void* data)
MAKE_WORD ((val >> 8 ) & 0xff, (val >> 0 ) & 0xff) MAKE_WORD ((val >> 8 ) & 0xff, (val >> 0 ) & 0xff)
); );
} while (--i); }
ColorChange = TRUE; ColorChange = TRUE;
}
} while (TTotal -= TDelta && !Task_ReadState (task, TASK_EXIT)); control->TTotal -= TDelta;
if (!control->TTotal)
{
xform_complete ();
}
} }
--NumXFormTasks; /* This should be thread-safe without locking the XFormControl because
* only one thread should be Flushing at any given time, constant
FinishTask (task); * writes are atomic anyway, and Flush is the only routine that writes
return(0); * XFormFlush. */
}
void void
FlushPLUTXForms (void) FlushPLUTXForms (void)
{ {
if (NumXFormTasks) while (XFormControl.XFormsPending)
{ {
XFormFlush = TRUE; xform_complete ();
do
TaskSwitch ();
while (NumXFormTasks);
XFormFlush = FALSE;
} }
} }
@@ -502,32 +522,40 @@ XFormPLUT (COLORMAPPTR ColorMapPtr, SIZE TimeInterval)
if (ColorMapPtr) if (ColorMapPtr)
{ {
DWORD TimeOut; DWORD TimeOut;
DWORD *pOldCMap, *pCurCMap;
XFORM_CONTROL *control;
int i;
// FlushPLUTXForms ();
SetSemaphore (XFormControl.XFormSem);
while (XFormControl.XFormsPending
&& (XFormControl.XFormInsertPoint == XFormControl.XFormCurrent))
{
ClearSemaphore (XFormControl.XFormSem);
FlushPLUTXForms (); FlushPLUTXForms ();
SetSemaphore (XFormControl.XFormSem);
TaskControl.CMapPtr = ColorMapPtr;
if ((TaskControl.Ticks = TimeInterval) <= 0)
TaskControl.Ticks = 1; /* prevent divide by zero and negative fade */
if (TimeInterval == 0 || (TaskControl.XFormTask =
AssignTask (xform_PLUT_task, 1024,
"transform palette")) == 0)
{
SetColorMap (ColorMapPtr);
ColorChange = TRUE;
TimeOut = GetTimeCounter ();
} }
else
{
do
TaskSwitch ();
while (TaskControl.CMapPtr);
++NumXFormTasks; control = &XFormControl.TaskControl[XFormControl.XFormInsertPoint];
TimeOut = GetTimeCounter () + TaskControl.Ticks + 1;
} pCurCMap = (DWORD *)((BYTE *)_varPLUTs + (*ColorMapPtr * PLUT_BYTE_SIZE));
TaskControl.CMapPtr = 0; pOldCMap = control->OldCMap;
for (i = 0; i < NUMBER_OF_PLUT_UINT32s; ++i)
*pOldCMap++ = *pCurCMap++;
control->CMapPtr = ColorMapPtr;
if ((control->Ticks = TimeInterval) <= 0)
control->Ticks = 1; /* prevent divide by zero and negative fade */
control->TTotal = control->TOrig = TimeInterval;
if (++XFormControl.XFormInsertPoint >= MAX_XFORMS)
XFormControl.XFormInsertPoint = 0;
XFormControl.XFormsPending = TRUE;
ClearSemaphore (XFormControl.XFormSem);
return (TimeOut);
} }
return (0); return (0);
@@ -1056,6 +1084,7 @@ if (LastOscillTime + (ONE_SECOND / 32) < CurTime)
} }
UnbatchGraphics (); UnbatchGraphics ();
ClearSemaphore (GraphicsSem); ClearSemaphore (GraphicsSem);
xform_PLUT_step(ElapsedTicks);
} }
FinishTask (task); FinishTask (task);
return(0); return(0);
-669
View File
@@ -1,669 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "reslib.h"
#include "comm/comandr/resinst.h"
#include "starcon.h"
#include "commglue.h"
#include "comm/comandr/strings.h"
#include "libs/graphics/gfx_common.h"
static LOCDATA commander_desc =
{
NULL_PTR, /* init_encounter_func */
NULL_PTR, /* uninit_encounter_func */
(FRAME)COMMANDER_PMAP_ANIM, /* AlienFrame */
(FONT)COMMANDER_FONT, /* AlienFont */
WHITE_COLOR, /* AlienTextFColor */
BLACK_COLOR, /* AlienTextBColor */
0, /* SIS_TEXT_WIDTH, */ /* AlienTextWidth */
COMMANDER_COLOR_MAP, /* AlienColorMap */
COMMANDER_MUSIC, /* AlienSong */
COMMANDER_CONVERSATION_PHRASES, /* PlayerPhrases */
3, /* NumAnimations */
{
{ /* Blink */
1, /* StartIndex */
3, /* NumFrames */
YOYO_ANIM, /* AnimFlags */
8, 0, /* FrameRate */
0, ONE_SECOND * 8, /* RestartRate */
},
{ /* Running light */
10, /* StartIndex */
30, /* NumFrames */
CIRCULAR_ANIM, /* AnimFlags */
3, 0, /* FrameRate */
ONE_SECOND * 2, 0, /* RestartRate */
},
{
1, /* StartIndex */
3, /* NumFrames */
RANDOM_ANIM | COLORXFORM_ANIM,/* AnimFlags */
0, 4, /* FrameRate */
0, 8, /* RestartRate */
},
},
{
0, /* StartIndex */
0, /* NumFrames */
0, /* AnimFlags */
0, 0, /* FrameRate */
0, 0, /* RestartRate */
},
{
4, /* StartIndex */
6, /* NumFrames */
0, /* AnimFlags */
12, 8, /* FrameRate */
14, 10, /* RestartRate */
},
};
static void
ByeBye (RESPONSE_REF R)
{
if (PLAYER_SAID (R, ok_i_will_get_radios))
NPCPhrase (THANKS_FOR_HELPING);
else if (PLAYER_SAID (R, well_go_get_them_now))
NPCPhrase (GLAD_WHEN_YOU_COME_BACK);
else if (PLAYER_SAID (R, we_will_take_care_of_base))
{
NPCPhrase (GOOD_LUCK_WITH_BASE);
SET_GAME_STATE (WILL_DESTROY_BASE, 1);
}
else if (PLAYER_SAID (R, take_care_of_base_again))
NPCPhrase (GOOD_LUCK_AGAIN);
else if (PLAYER_SAID (R, base_was_abandoned)
|| PLAYER_SAID (R, i_lied_it_was_abandoned))
{
NPCPhrase (IT_WAS_ABANDONED);
NPCPhrase (HERE_COMES_ILWRATH);
SET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER, 1);
}
else if (PLAYER_SAID (R, oh_yes_big_fight))
{
NPCPhrase (IM_GLAD_YOU_WON);
NPCPhrase (HERE_COMES_ILWRATH);
SET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER, 1);
}
else if (PLAYER_SAID (R, i_cant_talk_about_it))
{
NPCPhrase (IM_SURE_IT_WAS_DIFFICULT);
NPCPhrase (HERE_COMES_ILWRATH);
SET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER, 1);
}
else if (PLAYER_SAID (R, cook_their_butts)
|| PLAYER_SAID (R, overthrow_evil_aliens)
|| PLAYER_SAID (R, annihilate_those_monsters))
{
SET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER, 0);
if (PLAYER_SAID (R, cook_their_butts))
NPCPhrase (COOK_BUTTS);
else if (PLAYER_SAID (R, overthrow_evil_aliens))
NPCPhrase (OVERTHROW_ALIENS);
else /* if (R == annihilate_those_monsters) */
NPCPhrase (KILL_MONSTERS);
construct_response (shared_phrase_buf,
name_40,
GLOBAL_SIS (CommanderName),
name_41,
0);
NPCPhrase (THIS_MAY_SEEM_SILLY);
Response (name_1, ByeBye);
Response (name_2, ByeBye);
Response (name_3, ByeBye);
DoResponsePhrase (name_40, ByeBye, shared_phrase_buf);
SET_GAME_STATE (STARBASE_AVAILABLE, 1);
}
else
{
if (PLAYER_SAID (R, name_1))
{
NPCPhrase (OK_THE_NAFS);
SET_GAME_STATE (NEW_ALLIANCE_NAME, 0);
}
else if (PLAYER_SAID (R, name_2))
{
NPCPhrase (OK_THE_CAN);
SET_GAME_STATE (NEW_ALLIANCE_NAME, 1);
}
else if (PLAYER_SAID (R, name_3))
{
NPCPhrase (OK_THE_UFW);
SET_GAME_STATE (NEW_ALLIANCE_NAME, 2);
}
else /* if (PLAYER_SAID (R, name_4)) */
{
NPCPhrase (OK_THE_NAME_IS_EMPIRE0);
NPCPhrase (GLOBAL_PLAYER_NAME);
NPCPhrase (OK_THE_NAME_IS_EMPIRE1);
SET_GAME_STATE (NEW_ALLIANCE_NAME, 3);
}
NPCPhrase (STARBASE_WILL_BE_READY);
}
}
static void
NoRadioactives (RESPONSE_REF R)
{
if (PLAYER_SAID (R, yes_this_is_supply_ship))
{
NPCPhrase (ABOUT_TIME);
Response (i_lied, NoRadioactives);
Response (plumb_out, NoRadioactives);
}
else
{
if (PLAYER_SAID (R, where_can_i_get_radios))
{
NPCPhrase (RADIOS_ON_MERCURY);
DISABLE_PHRASE (where_can_i_get_radios);
}
else if (PLAYER_SAID (R, no_but_well_help0))
NPCPhrase (THE_WHAT_FROM_WHERE);
else if (PLAYER_SAID (R, what_slave_planet)
|| PLAYER_SAID (R, i_lied))
NPCPhrase (DONT_KNOW_WHO_YOU_ARE);
else if (PLAYER_SAID (R, plumb_out))
NPCPhrase (WHAT_KIND_OF_IDIOT);
else if (PLAYER_SAID (R, i_lost_my_lander))
{
NPCPhrase (HERE_IS_A_NEW_LANDER);
++GLOBAL_SIS (NumLanders);
SetSemaphore (GraphicsSem);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
ClearSemaphore (GraphicsSem);
SET_GAME_STATE (LANDERS_LOST, 1);
}
else if (PLAYER_SAID (R, i_lost_another_lander))
{
NPCPhrase (HERE_IS_ANOTHER_LANDER);
++GLOBAL_SIS (NumLanders);
SetSemaphore (GraphicsSem);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
ClearSemaphore (GraphicsSem);
}
else if (PLAYER_SAID (R, need_fuel))
{
NPCPhrase (GIVE_FUEL);
SetSemaphore (GraphicsSem);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
ClearSemaphore (GraphicsSem);
SET_GAME_STATE (GIVEN_FUEL_BEFORE, 1);
}
else if (PLAYER_SAID (R, need_fuel_again))
{
NPCPhrase (GIVE_FUEL_AGAIN);
SetSemaphore (GraphicsSem);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
ClearSemaphore (GraphicsSem);
}
if (GLOBAL_SIS (NumLanders) == 0)
{
if (GET_GAME_STATE (LANDERS_LOST))
Response (i_lost_another_lander, NoRadioactives);
else
Response (i_lost_my_lander, NoRadioactives);
}
if (GLOBAL_SIS (FuelOnBoard) < 2 * FUEL_TANK_SCALE)
{
if (GET_GAME_STATE (GIVEN_FUEL_BEFORE))
Response (need_fuel_again, NoRadioactives);
else
Response (need_fuel, NoRadioactives);
}
Response (ok_i_will_get_radios, ByeBye);
if (PHRASE_ENABLED (where_can_i_get_radios))
{
Response (where_can_i_get_radios, NoRadioactives);
}
}
}
static void
AskAfterRadios (RESPONSE_REF R)
{
if (PLAYER_SAID (R, i_lost_my_lander))
{
NPCPhrase (HERE_IS_A_NEW_LANDER);
++GLOBAL_SIS (NumLanders);
SetSemaphore (GraphicsSem);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
ClearSemaphore (GraphicsSem);
SET_GAME_STATE (LANDERS_LOST, 1);
}
else if (PLAYER_SAID (R, i_lost_another_lander))
{
NPCPhrase (HERE_IS_ANOTHER_LANDER);
++GLOBAL_SIS (NumLanders);
SetSemaphore (GraphicsSem);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
ClearSemaphore (GraphicsSem);
}
else if (PLAYER_SAID (R, need_fuel))
{
NPCPhrase (GIVE_FUEL);
SetSemaphore (GraphicsSem);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
ClearSemaphore (GraphicsSem);
SET_GAME_STATE (GIVEN_FUEL_BEFORE, 1);
}
else if (PLAYER_SAID (R, need_fuel_again))
{
NPCPhrase (GIVE_FUEL_AGAIN);
SetSemaphore (GraphicsSem);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
ClearSemaphore (GraphicsSem);
}
else if (PLAYER_SAID (R, where_get_radios))
{
NPCPhrase (RADIOS_ON_MERCURY);
DISABLE_PHRASE (where_get_radios);
}
{
if (GLOBAL_SIS (NumLanders) == 0)
{
if (GET_GAME_STATE (LANDERS_LOST))
Response (i_lost_another_lander, AskAfterRadios);
else
Response (i_lost_my_lander, AskAfterRadios);
}
if (GLOBAL_SIS (FuelOnBoard) < 2 * FUEL_TANK_SCALE)
{
if (GET_GAME_STATE (GIVEN_FUEL_BEFORE))
Response (need_fuel_again, AskAfterRadios);
else
Response (need_fuel, AskAfterRadios);
}
Response (well_go_get_them_now, ByeBye);
if (PHRASE_ENABLED (where_get_radios))
{
Response (where_get_radios, AskAfterRadios);
}
}
}
static void
BaseDestroyed (RESPONSE_REF R)
{
if (PLAYER_SAID (R, we_fought_them))
{
NPCPhrase (YOU_REALLY_FOUGHT_BASE);
Response (oh_yes_big_fight, ByeBye);
Response (i_lied_it_was_abandoned, ByeBye);
Response (i_cant_talk_about_it, ByeBye);
}
else
{
if (PLAYER_SAID (R, we_are_here_to_help))
{
NPCPhrase (BASE_ON_MOON);
}
else
{
NPCPhrase (DEALT_WITH_BASE_YET);
}
Response (base_was_abandoned, ByeBye);
Response (we_fought_them, BaseDestroyed);
}
}
static void
TellMoonBase (RESPONSE_REF R)
{
if (R == 0)
{
NPCPhrase (DEALT_WITH_BASE_YET);
}
else if (PLAYER_SAID (R, i_lost_my_lander))
{
NPCPhrase (HERE_IS_A_NEW_LANDER);
++GLOBAL_SIS (NumLanders);
SetSemaphore (GraphicsSem);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
ClearSemaphore (GraphicsSem);
SET_GAME_STATE (LANDERS_LOST, 1);
}
else if (PLAYER_SAID (R, i_lost_another_lander))
{
NPCPhrase (HERE_IS_ANOTHER_LANDER);
++GLOBAL_SIS (NumLanders);
SetSemaphore (GraphicsSem);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
ClearSemaphore (GraphicsSem);
}
else if (PLAYER_SAID (R, need_fuel))
{
NPCPhrase (GIVE_FUEL);
SetSemaphore (GraphicsSem);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
ClearSemaphore (GraphicsSem);
SET_GAME_STATE (GIVEN_FUEL_BEFORE, 1);
}
else if (PLAYER_SAID (R, need_fuel_again))
{
NPCPhrase (GIVE_FUEL_AGAIN);
SetSemaphore (GraphicsSem);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
ClearSemaphore (GraphicsSem);
}
else if (PLAYER_SAID (R, we_are_here_to_help))
{
NPCPhrase (BASE_ON_MOON);
}
else if (GET_GAME_STATE (STARBASE_YACK_STACK1) == 0)
{
NPCPhrase (ABOUT_BASE);
SET_GAME_STATE (STARBASE_YACK_STACK1, 1);
}
else
{
NPCPhrase (ABOUT_BASE_AGAIN);
}
if (GLOBAL_SIS (NumLanders) == 0)
{
if (GET_GAME_STATE (LANDERS_LOST))
Response (i_lost_another_lander, TellMoonBase);
else
Response (i_lost_my_lander, TellMoonBase);
}
if (GLOBAL_SIS (FuelOnBoard) < 2 * FUEL_TANK_SCALE)
{
if (GET_GAME_STATE (GIVEN_FUEL_BEFORE))
Response (need_fuel_again, TellMoonBase);
else
Response (need_fuel, TellMoonBase);
}
if (GET_GAME_STATE (WILL_DESTROY_BASE) == 0)
Response (we_will_take_care_of_base, ByeBye);
else
Response (take_care_of_base_again, ByeBye);
if (GET_GAME_STATE (STARBASE_YACK_STACK1) == 0)
Response (tell_me_about_base, TellMoonBase);
else
Response (tell_me_again, TellMoonBase);
}
static void RevealSelf (RESPONSE_REF R);
static void
TellProbe (RESPONSE_REF R)
{
NPCPhrase (THAT_WAS_PROBE);
DISABLE_PHRASE (what_was_red_thing);
Response (it_went_away, RevealSelf);
Response (we_destroyed_it, RevealSelf);
Response (what_probe, RevealSelf);
}
static void
RevealSelf (RESPONSE_REF R)
{
BYTE i, stack;
stack = 0;
if (PLAYER_SAID (R, we_are_vindicator0))
{
NPCPhrase (THATS_IMPOSSIBLE);
DISABLE_PHRASE (we_are_vindicator0);
}
else if (PLAYER_SAID (R, our_mission_was_secret))
{
NPCPhrase (ACKNOWLEDGE_SECRET);
DISABLE_PHRASE (our_mission_was_secret);
}
else if (PLAYER_SAID (R, first_give_info))
{
NPCPhrase (ASK_AWAY);
stack = 1;
DISABLE_PHRASE (first_give_info);
}
else if (PLAYER_SAID (R, whats_this_starbase))
{
NPCPhrase (STARBASE_IS);
stack = 1;
DISABLE_PHRASE (whats_this_starbase);
}
else if (PLAYER_SAID (R, what_about_earth))
{
NPCPhrase (HAPPENED_TO_EARTH);
stack = 1;
DISABLE_PHRASE (what_about_earth);
}
else if (PLAYER_SAID (R, where_are_urquan))
{
NPCPhrase (URQUAN_LEFT);
stack = 1;
DISABLE_PHRASE (where_are_urquan);
}
else if (PLAYER_SAID (R, it_went_away))
NPCPhrase (DEEP_TROUBLE);
else if (PLAYER_SAID (R, we_destroyed_it))
NPCPhrase (GOOD_NEWS);
else if (PLAYER_SAID (R, what_probe))
NPCPhrase (SURE_HOPE);
for (i = 0; i < 2; ++i, stack ^= 1)
{
if (stack == 1)
{
if (PHRASE_ENABLED (first_give_info))
Response (first_give_info, RevealSelf);
else if (PHRASE_ENABLED (whats_this_starbase))
Response (whats_this_starbase, RevealSelf);
else if (PHRASE_ENABLED (what_about_earth))
Response (what_about_earth, RevealSelf);
else if (PHRASE_ENABLED (where_are_urquan))
Response (where_are_urquan, RevealSelf);
else if (PHRASE_ENABLED (what_was_red_thing))
{
Response (what_was_red_thing, TellProbe);
}
}
else
{
if (PHRASE_ENABLED (we_are_vindicator0))
{
construct_response (shared_phrase_buf,
we_are_vindicator0,
GLOBAL_SIS (CommanderName),
we_are_vindicator1,
GLOBAL_SIS (ShipName),
we_are_vindicator2,
0);
DoResponsePhrase (we_are_vindicator0, RevealSelf, shared_phrase_buf);
}
else if (PHRASE_ENABLED (our_mission_was_secret))
Response (our_mission_was_secret, RevealSelf);
else
{
if (GET_GAME_STATE (MOONBASE_DESTROYED) == 0)
Response (we_are_here_to_help, TellMoonBase);
else
Response (we_are_here_to_help, BaseDestroyed);
}
}
}
}
static void
GiveRadios (RESPONSE_REF R)
{
if (PLAYER_SAID (R, we_will_transfer_now))
{
SET_GAME_STATE (RADIOACTIVES_PROVIDED, 1);
NPCPhrase (FUEL_UP0);
NPCPhrase (FUEL_UP1);
AlienTalkSegue (1);
SetSemaphore (GraphicsSem);
CommData.AlienAmbientArray[2].AnimFlags |= ANIM_DISABLED;
XFormPLUT (GetColorMapAddress (
SetAbsColorMapIndex (CommData.AlienColorMap, 0)
), 0);
ClearSemaphore (GraphicsSem);
AlienTalkSegue ((COUNT)~0);
RevealSelf (NULL_PTR);
}
else
{
if (PLAYER_SAID (R, what_will_you_give_us))
NPCPhrase (MESSAGE_GARBLED_1);
else if (PLAYER_SAID (R, before_radios_we_need_info))
NPCPhrase (MESSAGE_GARBLED_2);
Response (we_will_transfer_now, GiveRadios);
Response (what_will_you_give_us, GiveRadios);
Response (before_radios_we_need_info, GiveRadios);
}
}
static void
Intro (void)
{
if (GET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER))
{
NPCPhrase (VERY_IMPRESSIVE);
Response (cook_their_butts, ByeBye);
Response (overthrow_evil_aliens, ByeBye);
Response (annihilate_those_monsters, ByeBye);
}
else if (GET_GAME_STATE (STARBASE_VISITED))
{
if (GET_GAME_STATE (RADIOACTIVES_PROVIDED))
{
if (GET_GAME_STATE (MOONBASE_DESTROYED) == 0)
{
TellMoonBase (NULL_PTR);
}
else
{
BaseDestroyed (NULL_PTR);
}
}
else
{
CommData.AlienColorMap =
SetAbsColorMapIndex (CommData.AlienColorMap, 1);
NPCPhrase (DO_YOU_HAVE_RADIO_THIS_TIME);
if (GLOBAL_SIS (ElementAmounts[RADIOACTIVE]))
GiveRadios (NULL_PTR);
else
AskAfterRadios (NULL_PTR);
}
}
else /* first visit */
{
CommData.AlienColorMap =
SetAbsColorMapIndex (CommData.AlienColorMap, 1);
SET_GAME_STATE (STARBASE_VISITED, 1);
NPCPhrase (ARE_YOU_SUPPLY_SHIP);
if (GLOBAL_SIS (ElementAmounts[RADIOACTIVE]))
GiveRadios (NULL_PTR);
else
{
construct_response (
shared_phrase_buf,
no_but_well_help0,
GLOBAL_SIS (ShipName),
no_but_well_help1,
0
);
DoResponsePhrase (no_but_well_help0, NoRadioactives, shared_phrase_buf);
Response (yes_this_is_supply_ship, NoRadioactives);
Response (what_slave_planet, NoRadioactives);
}
}
}
static COUNT
uninit_commander (void)
{
return (0);
}
LOCDATAPTR
init_commander_comm ()
{
LOCDATAPTR retval;
commander_desc.init_encounter_func = Intro;
commander_desc.uninit_encounter_func = uninit_commander;
if (GET_GAME_STATE (RADIOACTIVES_PROVIDED))
commander_desc.AlienAmbientArray[2].AnimFlags |= ANIM_DISABLED;
commander_desc.AlienTextWidth = 143;
commander_desc.AlienTextTemplate.baseline.x = 164;
commander_desc.AlienTextTemplate.baseline.y = 20;
commander_desc.AlienTextTemplate.align = ALIGN_CENTER;
SET_GAME_STATE (BATTLE_SEGUE, 0);
retval = &commander_desc;
return (retval);
}
+1
View File
@@ -215,6 +215,7 @@ main (int argc, char *argv[])
_MemorySem = CreateSemaphore (1); _MemorySem = CreateSemaphore (1);
GraphicsSem = CreateSemaphore (1); GraphicsSem = CreateSemaphore (1);
mem_init (); mem_init ();
init_xform_control ();
TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp); TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp);
TFB_InitSound (TFB_SOUNDDRIVER_SDL, soundflags); TFB_InitSound (TFB_SOUNDDRIVER_SDL, soundflags);