diff --git a/sc2/content/comm/comandr/comandr.txt b/sc2/content/comm/comandr/comandr.txt index bb60d6f2b..40c1dfa1f 100755 --- a/sc2/content/comm/comandr/comandr.txt +++ b/sc2/content/comm/comandr/comandr.txt @@ -85,10 +85,10 @@ So be it - The Empire of #(FUEL_UP0) coman016.ogg 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 -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. !!!? -- WHAT THE HELL KIND OF SHIP IS THAT!? Just who ARE you, Captain? diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index 3bd7c580f..b3d5c1f09 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -358,141 +358,161 @@ DrawAlienFrame (FRAME aframe, PSEQUENCE pSeq) UnbatchGraphics (); } -static struct +typedef struct xform_control { COLORMAPPTR CMapPtr; - SIZE Ticks; - Task XFormTask; -} TaskControl; + SIZE Ticks, TTotal, TOrig; + DWORD OldCMap[NUMBER_OF_PLUT_UINT32s]; +} 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 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; - Task task = (Task) data; + XFORM_CONTROL *control; + COLORMAPPTR ColorMapPtr; + DWORD *pCurCMap, *pOldCMap; + int i; - while (TaskControl.XFormTask == 0 && !Task_ReadState (task, TASK_EXIT)) - TaskSwitch (); - TaskControl.XFormTask = 0; - CurMapPtr = TaskControl.CMapPtr; + if (!XFormControl.XFormsPending) + return; + control = &XFormControl.TaskControl[XFormControl.XFormCurrent]; + + ColorMapPtr = control->CMapPtr; + + if (TDelta > control->TTotal) + TDelta = control->TTotal; + + pCurCMap = (DWORD *)((BYTE *)_varPLUTs + (*ColorMapPtr * PLUT_BYTE_SIZE)); + pOldCMap = control->OldCMap; + + ColorMapPtr += 2; + if (_varPLUTs) { - 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 + for (i = 0; i < NUMBER_OF_PLUT_UINT32s; i++) { - DWORD StartTime; - COLORMAPPTR ColorMapPtr; - - StartTime = CurTime; - SleepThread (2); - CurTime = GetTimeCounter (); - if (XFormFlush || (TDelta = (SIZE)(CurTime - StartTime)) > TTotal) - TDelta = TTotal; - - ColorMapPtr = CurMapPtr; - pCurCMap = (DWORD *)((BYTE *)_varPLUTs + (*ColorMapPtr * PLUT_BYTE_SIZE)); - pOldCMap = OldCMap; - - ColorMapPtr += 2; - i = NUMBER_OF_PLUT_UINT32s; - if (_varPLUTs) - do - { - SIZE c0, c1; - DWORD v0, v1, val; - float f = (TTotalOrig - TTotal) / (float)TTotalOrig; - COLORMAPPTR oldmap = (COLORMAPPTR) pOldCMap; + SIZE c0, c1; + DWORD v0, v1, val; + float f = (control->TOrig - control->TTotal) / (float)control->TOrig; + COLORMAPPTR oldmap = (COLORMAPPTR) pOldCMap; - v0 = MAKE_DWORD - ( - MAKE_WORD (oldmap[3], oldmap[2]), - MAKE_WORD (oldmap[1], oldmap[0]) - ); + v0 = MAKE_DWORD + ( + MAKE_WORD (oldmap[3], oldmap[2]), + MAKE_WORD (oldmap[1], oldmap[0]) + ); - v1 = MAKE_DWORD - ( - MAKE_WORD (ColorMapPtr[3], ColorMapPtr[2]), - MAKE_WORD (ColorMapPtr[1], ColorMapPtr[0]) - ); + v1 = MAKE_DWORD + ( + MAKE_WORD (ColorMapPtr[3], ColorMapPtr[2]), + MAKE_WORD (ColorMapPtr[1], ColorMapPtr[0]) + ); - ColorMapPtr += sizeof (DWORD); + ColorMapPtr += sizeof (DWORD); + + c0 = (SIZE)((v0 >> (10 + 16)) & 0x1F); + c1 = (SIZE)((v1 >> (10 + 16)) & 0x1F); + c0 += (SIZE)((c1 - c0) * f); + val = (c0 & 0x1F) | (1 << 5); - c0 = (SIZE)((v0 >> (10 + 16)) & 0x1F); - c1 = (SIZE)((v1 >> (10 + 16)) & 0x1F); - c0 += (SIZE)((c1 - c0) * f); - val = (c0 & 0x1F) | (1 << 5); + c0 = (SIZE)((v0 >> (5 + 16)) & 0x1F); + c1 = (SIZE)((v1 >> (5 + 16)) & 0x1F); + c0 += (SIZE)((c1 - c0) * f); + val = (val << 5) | (c0 & 0x1F); - c0 = (SIZE)((v0 >> (5 + 16)) & 0x1F); - c1 = (SIZE)((v1 >> (5 + 16)) & 0x1F); - c0 += (SIZE)((c1 - c0) * f); - val = (val << 5) | (c0 & 0x1F); + c0 = (SIZE)((v0 >> (0 + 16)) & 0x1F); + c1 = (SIZE)((v1 >> (0 + 16)) & 0x1F); + c0 += (SIZE)((c1 - c0) * f); + val = (val << 5) | (c0 & 0x1F); - c0 = (SIZE)((v0 >> (0 + 16)) & 0x1F); - c1 = (SIZE)((v1 >> (0 + 16)) & 0x1F); - c0 += (SIZE)((c1 - c0) * f); - val = (val << 5) | (c0 & 0x1F); + c0 = (SIZE)((v0 >> 10) & 0x1F); + c1 = (SIZE)((v1 >> 10) & 0x1F); + c0 += (SIZE)((c1 - c0) * f); + val = (val << (5 + 1)) | (c0 & 0x1F) | (1 << 5); - c0 = (SIZE)((v0 >> 10) & 0x1F); - c1 = (SIZE)((v1 >> 10) & 0x1F); - c0 += (SIZE)((c1 - c0) * f); - val = (val << (5 + 1)) | (c0 & 0x1F) | (1 << 5); + c0 = (SIZE)((v0 >> 5) & 0x1F); + c1 = (SIZE)((v1 >> 5) & 0x1F); + c0 += (SIZE)((c1 - c0) * f); + val = (val << 5) | (c0 & 0x1F); + + c0 = (SIZE)((v0 >> 0) & 0x1F); + c1 = (SIZE)((v1 >> 0) & 0x1F); + c0 += (SIZE)((c1 - c0) * f); + val = (val << 5) | (c0 & 0x1F); - c0 = (SIZE)((v0 >> 5) & 0x1F); - c1 = (SIZE)((v1 >> 5) & 0x1F); - c0 += (SIZE)((c1 - c0) * f); - val = (val << 5) | (c0 & 0x1F); + *pOldCMap++; + *pCurCMap++ = MAKE_DWORD + ( + MAKE_WORD ((val >> 24 ) & 0xff, (val >> 16) & 0xff), + MAKE_WORD ((val >> 8 ) & 0xff, (val >> 0 ) & 0xff) + ); - c0 = (SIZE)((v0 >> 0) & 0x1F); - c1 = (SIZE)((v1 >> 0) & 0x1F); - c0 += (SIZE)((c1 - c0) * f); - val = (val << 5) | (c0 & 0x1F); - - *pOldCMap++; - *pCurCMap++ = MAKE_DWORD - ( - MAKE_WORD ((val >> 24 ) & 0xff, (val >> 16) & 0xff), - MAKE_WORD ((val >> 8 ) & 0xff, (val >> 0 ) & 0xff) - ); - - } while (--i); - - ColorChange = TRUE; - - } while (TTotal -= TDelta && !Task_ReadState (task, TASK_EXIT)); + } + ColorChange = TRUE; + } + control->TTotal -= TDelta; + if (!control->TTotal) + { + xform_complete (); } - - --NumXFormTasks; - - FinishTask (task); - return(0); } +/* This should be thread-safe without locking the XFormControl because + * only one thread should be Flushing at any given time, constant + * writes are atomic anyway, and Flush is the only routine that writes + * XFormFlush. */ + void FlushPLUTXForms (void) { - if (NumXFormTasks) + while (XFormControl.XFormsPending) { - XFormFlush = TRUE; - do - TaskSwitch (); - while (NumXFormTasks); - XFormFlush = FALSE; + xform_complete (); } } @@ -502,32 +522,40 @@ XFormPLUT (COLORMAPPTR ColorMapPtr, SIZE TimeInterval) if (ColorMapPtr) { DWORD TimeOut; + DWORD *pOldCMap, *pCurCMap; + XFORM_CONTROL *control; + int i; - FlushPLUTXForms (); + // FlushPLUTXForms (); - 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) + SetSemaphore (XFormControl.XFormSem); + while (XFormControl.XFormsPending + && (XFormControl.XFormInsertPoint == XFormControl.XFormCurrent)) { - SetColorMap (ColorMapPtr); - ColorChange = TRUE; - TimeOut = GetTimeCounter (); + ClearSemaphore (XFormControl.XFormSem); + FlushPLUTXForms (); + SetSemaphore (XFormControl.XFormSem); } - else - { - do - TaskSwitch (); - while (TaskControl.CMapPtr); + + control = &XFormControl.TaskControl[XFormControl.XFormInsertPoint]; - ++NumXFormTasks; - TimeOut = GetTimeCounter () + TaskControl.Ticks + 1; - } - TaskControl.CMapPtr = 0; + pCurCMap = (DWORD *)((BYTE *)_varPLUTs + (*ColorMapPtr * PLUT_BYTE_SIZE)); + 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); @@ -709,7 +737,7 @@ int ambient_anim_task(void* data) PSEQUENCE pSeq; ANIMATION_DESCPTR ADPtr; DWORD ActiveMask; -DWORD LastOscillTime; + DWORD LastOscillTime; Task task = (Task) data; while ((CommFrame = CommData.AlienFrame) == 0 && !Task_ReadState (task, TASK_EXIT)) @@ -724,7 +752,7 @@ DWORD LastOscillTime; TalkAlarm = 0; TalkFrame = 0; LastTime = GetTimeCounter (); -LastOscillTime = LastTime; + LastOscillTime = LastTime; while (!Task_ReadState (task, TASK_EXIT)) { BOOLEAN Change, CanTalk; @@ -1049,13 +1077,14 @@ pBatch->Object.Stamp.origin.x = -SAFE_X; SetContext (OldContext); } -if (LastOscillTime + (ONE_SECOND / 32) < CurTime) -{ - LastOscillTime = CurTime; - UpdateSpeechGraphics (FALSE); -} + if (LastOscillTime + (ONE_SECOND / 32) < CurTime) + { + LastOscillTime = CurTime; + UpdateSpeechGraphics (FALSE); + } UnbatchGraphics (); ClearSemaphore (GraphicsSem); + xform_PLUT_step(ElapsedTicks); } FinishTask (task); return(0); @@ -1176,7 +1205,7 @@ AlienTalkSegue (COUNT wait_track) { SetColorMap (GetColorMapAddress (CommData.AlienColorMap)); DrawAlienFrame (CommData.AlienFrame, NULL_PTR); -UpdateSpeechGraphics (TRUE); + UpdateSpeechGraphics (TRUE); if (LOBYTE (GLOBAL (CurrentActivity)) == WON_LAST_BATTLE || (!GET_GAME_STATE (PLAYER_HYPNOTIZED) @@ -1185,31 +1214,31 @@ UpdateSpeechGraphics (TRUE); && (pMenuState == 0 || !GET_GAME_STATE (MOONBASE_ON_SHIP) || GET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER)))) { -RECT r; + RECT r; -if (pMenuState == 0) -{ - 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); -} -else -{ - r.corner.x = 0; - r.corner.y = 0; - r.extent.width = SCREEN_WIDTH; - r.extent.height = SCREEN_HEIGHT; - ScreenTransition (3, &r); -} -UnbatchGraphics (); + if (pMenuState == 0) + { + 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); + } + else + { + r.corner.x = 0; + r.corner.y = 0; + r.extent.width = SCREEN_WIDTH; + r.extent.height = SCREEN_HEIGHT; + ScreenTransition (3, &r); + } + UnbatchGraphics (); } else { BYTE clut_buf[] = {FadeAllToColor}; - -UnbatchGraphics (); + + UnbatchGraphics (); if (GET_GAME_STATE (MOONBASE_ON_SHIP) || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND * 2); @@ -1239,38 +1268,38 @@ UnbatchGraphics (); LastActivity &= ~CHECK_LOAD; } -if (wait_track == (COUNT)~0 || CommData.AlienTalkDesc.NumFrames) -{ - if (!(CommData.AlienTransitionDesc.AnimFlags & TALK_INTRO)) + if (wait_track == (COUNT)~0 || CommData.AlienTalkDesc.NumFrames) { - CommData.AlienTransitionDesc.AnimFlags |= TALK_INTRO; - if (CommData.AlienTransitionDesc.NumFrames) - CommData.AlienTalkDesc.AnimFlags |= TALK_INTRO; - } + if (!(CommData.AlienTransitionDesc.AnimFlags & TALK_INTRO)) + { + CommData.AlienTransitionDesc.AnimFlags |= TALK_INTRO; + if (CommData.AlienTransitionDesc.NumFrames) + CommData.AlienTalkDesc.AnimFlags |= TALK_INTRO; + } - CommData.AlienTransitionDesc.AnimFlags &= ~PAUSE_TALKING; - if (CommData.AlienTalkDesc.NumFrames) - CommData.AlienTalkDesc.AnimFlags |= WAIT_TALKING; + CommData.AlienTransitionDesc.AnimFlags &= ~PAUSE_TALKING; + if (CommData.AlienTalkDesc.NumFrames) + CommData.AlienTalkDesc.AnimFlags |= WAIT_TALKING; - while (CommData.AlienTalkDesc.AnimFlags & TALK_INTRO) - { - ClearSemaphore (GraphicsSem); - TaskSwitch (); - SetSemaphore (GraphicsSem); + while (CommData.AlienTalkDesc.AnimFlags & TALK_INTRO) + { + ClearSemaphore (GraphicsSem); + TaskSwitch (); + SetSemaphore (GraphicsSem); + } } -} if (!SpewPhrases (wait_track) || wait_track == (COUNT)~0) FadeMusic (FOREGROUND_VOL, ONE_SECOND); else CommData.AlienTransitionDesc.AnimFlags &= ~TALK_INTRO; -if (wait_track == (COUNT)~0 || CommData.AlienTalkDesc.NumFrames) -{ - CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; - if ((CommData.AlienTalkDesc.AnimFlags & WAIT_TALKING)) - CommData.AlienTalkDesc.AnimFlags |= PAUSE_TALKING; -} + if (wait_track == (COUNT)~0 || CommData.AlienTalkDesc.NumFrames) + { + CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE; + if ((CommData.AlienTalkDesc.AnimFlags & WAIT_TALKING)) + CommData.AlienTalkDesc.AnimFlags |= PAUSE_TALKING; + } ClearSemaphore (GraphicsSem); diff --git a/sc2/src/sc2code/comm/comandr/comandr.c b/sc2/src/sc2code/comm/comandr/comandr.c index beda06f74..e69de29bb 100644 --- a/sc2/src/sc2code/comm/comandr/comandr.c +++ b/sc2/src/sc2code/comm/comandr/comandr.c @@ -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); -} diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index e5b660d36..3f3efc284 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -215,6 +215,7 @@ main (int argc, char *argv[]) _MemorySem = CreateSemaphore (1); GraphicsSem = CreateSemaphore (1); mem_init (); + init_xform_control (); TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp); TFB_InitSound (TFB_SOUNDDRIVER_SDL, soundflags);