rush.c

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005 Michael K. McCarty & Fritz Bronner
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 // Interplay's BUZZ ALDRIN's RACE into SPACE
00019 //
00020 // Formerly -=> LiftOff : Race to the Moon :: IBM version MCGA
00021 // Copyright 1991 by Strategic Visions, Inc.
00022 // Designed by Fritz Bronner
00023 // Programmed by Michael K McCarty
00024 //
00025 
00026 #include "Buzz_inc.h"
00027 #include "externs.h"
00028 
00029 // Function Prototype
00030 
00031 char Mon[12][4] = {
00032    "JAN","FEB","MAR","APR","MAY","JUN",
00033    "JUL","AUG","SEP","OCT","NOV","DEC"};
00034 
00035 int fCsh; //rush cash
00036 extern struct mStr Mis;
00037 extern char pNeg[NUM_PLAYERS][MAX_MISSIONS];
00038 
00039 char dg[62][6] =
00040 {  {00,00,00,00,00,00},   // 0
00041    {00,00,00,00,00,00},   // 1
00042    {00,00,00,00,00,00},   // 2
00043    {00,00,00,00,00,00},   // 3
00044    {02,00,00,00,00,00},   // 4
00045    {00,00,00,00,00,00},   // 5
00046    {04,02,00,00,00,00},   // 6
00047    {00,00,00,00,00,00},   // 7
00048    {00,00,00,00,00,00},   // 8
00049    {00,00,00,00,00,00},   // 9
00050    {00,00,00,00,00,00},   // 10
00051    {00,00,00,00,00,00},   // 11
00052    {00,00,00,00,00,00},   // 12
00053    {00,00,00,00,00,00},   // 13
00054    {04,02,00,00,00,00},   // 14
00055    {00,00,00,00,00,00},   // 15
00056    {00,00,00,00,00,00},   // 16
00057    {04,02,00,00,00,00},   // 17
00058    {00,00,00,00,00,00},   // 18
00059    {00,00,00,00,00,00},   // 19
00060    {04,00,00,00,00,00},   // 20
00061    {16,00,00,00,00,00},   // 21
00062    {19,00,00,00,00,00},   // 22
00063    {19,00,00,00,00,00},   // 23
00064    {17,06,04,00,00,00},   // 24
00065    {04,00,00,00,00,00},   // 25
00066    {25,06,04,00,00,00},   // 26
00067    {25,14,06,04,00,00},   // 27
00068    {25,17,04,00,00,00},   // 28
00069    {24,26,17,14,06,00},   // 29
00070    {18,04,00,00,00,00},   // 30
00071    {19,00,00,00,00,00},   // 31
00072    {19,00,00,00,00,00},   // 32
00073    {26,27,25,14,06,00},   // 33
00074    {31,21,16,00,00,00},   // 34
00075    {22,37,19,00,00,00},   // 35
00076    {32,37,22,19,00,00},   // 36
00077    {19,00,00,00,00,00},   // 37
00078    {04,00,00,00,00,00},   // 38
00079    {16,00,00,00,00,00},   // 39
00080    {38,25,14,06,04,00},   // 40
00081    {39,16,00,00,00,00},   // 41
00082    {00,00,00,00,00,00},   // 42
00083    {04,00,00,00,00,00},   // 43
00084    {16,00,00,00,00,00},   // 44
00085    {00,00,00,00,00,00},   // 45
00086    {43,04,00,00,00,00},   // 46
00087    {44,16,00,00,00,00},   // 47
00088    {46,43,38,04,00,00},   // 48
00089    {38,16,00,00,00,00},   // 49
00090    {48,46,43,38,04,00},   // 50
00091    {49,39,16,00,00,00},   // 51
00092    {47,44,38,16,00,00},   // 52
00093    {46,43,00,00,00,00},   // 53
00094    {46,43,00,00,00,00},   // 54
00095    {47,44,00,00,00,00},   // 55
00096    {49,00,00,00,00,00},   // 56
00097    {49,00,00,00,00,00},   // 57
00098    {00,00,00,00,00,00},   // 58
00099    {00,00,00,00,00,00},   // 59
00100    {00,00,00,00,00,00},   // 60
00101    {00,00,00,00,00,00}    // 61
00102 };
00103 
00104 
00105 void DrawRush(char plr)
00106 {
00107   int i,k=0,l=0,JR=0;
00108   FILE *fin;
00109   
00110   FadeOut(2,pal,10,0,0);
00111 
00112  #if 0
00113   fin=sOpen("CONTROL.IMG","rb",0);
00114   fread(&pal[0],768,1,fin);
00115   if (plr==1) {
00116     fread(&len[0],4,1,fin);
00117     fseek(fin,len[0],SEEK_CUR);
00118     fread(&pal[0],768,1,fin);
00119   }
00120   fclose(fin);
00121 #endif
00122   fin=sOpen("LPADS.BUT","rb",0);
00123   i=fread(screen,1,MAX_X*MAX_Y,fin);fclose(fin);
00124   RLED_img(screen,vhptr.vptr,i,vhptr.w,vhptr.h);
00125   gxClearDisplay(0,0);
00126   JR=0;
00127   for (l=0;l<3;l++) {
00128     if (Data->P[plr].Mission[l].Joint==1) JR=1;
00129     if (Data->P[plr].Mission[l].MissionCode>0 &&
00130     Data->P[plr].Mission[l].part==0) k++;
00131   if (Data->P[plr].Mission[l].Rushing==1) Data->P[plr].Cash+=3;
00132     else if (Data->P[plr].Mission[l].Rushing==2) Data->P[plr].Cash+=6;
00133   Data->P[plr].Mission[l].Rushing=0;   // Clear Data
00134   }
00135 
00136   if (k==3) {   // Three non joint missions
00137     Data->P[plr].Mission[0].Month=2+Data->Season*6;
00138     Data->P[plr].Mission[1].Month=3+Data->Season*6;
00139     Data->P[plr].Mission[2].Month=4+Data->Season*6;
00140   };
00141 
00142   if (k==2 && JR==0) {     // Two non joint missions
00143     l=3;
00144     if (Data->P[plr].Mission[0].MissionCode>0) {
00145       Data->P[plr].Mission[0].Month=l+Data->Season*6; l+=2; };
00146     if (Data->P[plr].Mission[1].MissionCode>0) {
00147       Data->P[plr].Mission[1].Month=l+Data->Season*6; l+=2; };
00148     if (Data->P[plr].Mission[2].MissionCode>0)
00149       Data->P[plr].Mission[2].Month=l+Data->Season*6;
00150   };
00151 
00152   if (k==1 && JR==0) {     // Single Mission Non joint
00153     if (Data->P[plr].Mission[0].MissionCode>0)
00154       Data->P[plr].Mission[0].Month=4+Data->Season*6;
00155     if (Data->P[plr].Mission[1].MissionCode>0)
00156       Data->P[plr].Mission[1].Month=4+Data->Season*6;
00157     if (Data->P[plr].Mission[2].MissionCode>0)
00158       Data->P[plr].Mission[2].Month=4+Data->Season*6;
00159   };
00160 
00161   if (k==2 && JR==1) {  // Two launches, one Joint;
00162     if (Data->P[plr].Mission[1].part==1) {  // Joint first
00163       Data->P[plr].Mission[0].Month=3+Data->Season*6;
00164       Data->P[plr].Mission[1].Month=3+Data->Season*6;
00165       Data->P[plr].Mission[2].Month=5+Data->Season*6;
00166     };
00167     if (Data->P[plr].Mission[2].part==1) { // Joint second
00168       Data->P[plr].Mission[0].Month=3+Data->Season*6;
00169       Data->P[plr].Mission[1].Month=5+Data->Season*6;
00170       Data->P[plr].Mission[2].Month=5+Data->Season*6;
00171     };
00172   };
00173 
00174   if (k==1 && JR==1) { //  Single Joint Launch
00175     if (Data->P[plr].Mission[1].part==1) {   // found on pad 1+2
00176       Data->P[plr].Mission[0].Month=4+Data->Season*6;
00177       Data->P[plr].Mission[1].Month=4+Data->Season*6;
00178     } else {   // found on pad 2+3
00179       Data->P[plr].Mission[1].Month=4+Data->Season*6;
00180       Data->P[plr].Mission[2].Month=4+Data->Season*6;
00181     };
00182   }
00183 
00184   ShBox(0,0,319,23);
00185   IOBox(243,3,316,19);
00186   InBox(3,3,30,19);
00187   grSetColor(1);PrintAt(258,13,"ASSIGN");
00188   FlagSm(plr,4,4);
00189   for (i=0;i<3;i++) {
00190     if (Data->P[plr].Mission[i].MissionCode>0 &&
00191       Data->P[plr].Mission[i].part==0 ) {
00192       ShBox(0,25+i*58,80,82+i*58-1);ShBox(83,25+i*58,319,82+i*58-1);
00193 
00194       IOBox(278,30+i*58,314,42+i*58);
00195       IOBox(278,47+i*58,314,59+i*58);
00196       IOBox(278,64+i*58,314,76+i*58);
00197 
00198       IOBox(89,39+i*58,266,61+i*58);
00199       grSetColor(1);PrintAt(89,33+i*58,"SCHEDULE:");
00200       PrintAt(88,69+i*58,"RUSHING PENALTY: ");
00201       PrintAt(88,77+i*58,"DOWNGRADE PENALTY: ");
00202       PrintAt(196,69+i*58,"COST:");
00203       OutBox(11 ,33+i*58, 69, 74+i*58);
00204       InBox(20,38+i*58,60,69+i*58);
00205       gxVirtualDisplay(&vhptr,156*plr,i*30,21,39+i*58,59,68+i*58,0);
00206 
00207       SetRush(Data->P[plr].Mission[i].Rushing,i);
00208       grSetColor(1);
00209       DispBig(60,5,"MISSION SCHEDULE",0,-1);
00210 
00211       grSetColor(5);
00212 
00213       GetMisType(Data->P[plr].Mission[i].MissionCode);
00214 
00215       PrintAt(96,48+58*i,Mis.Abbr);
00216       if (Data->P[plr].Mission[i].Name[24]==1)
00217        {
00218         grSetColor(9);PrintAt(145,33+i*58,"DOWNGRADED MISSION");
00219          PrintAt(193,77+i*58,"-3 PRESTIGE");
00220        }
00221       else
00222        {
00223         grSetColor(7);PrintAt(145,33+i*58,"ORIGINAL MISSION");
00224         PrintAt(193,77+i*58,"NO PENALTY");
00225        }
00226       grSetColor(11);
00227       PrintAt(288,38+58*i,&Mon[Data->P[plr].Mission[i].Month-0][0]);
00228       PrintAt(288,55+58*i,&Mon[Data->P[plr].Mission[i].Month-1][0]);
00229       PrintAt(288,72+58*i,&Mon[Data->P[plr].Mission[i].Month-2][0]);
00230     }; /* End if */
00231   }; /* End for i */
00232   
00233   return;
00234 }
00235 
00236 void Rush(char plr)
00237 {
00238 int i,R1,R2,R3,oR1,oR2,oR3,dgflag[3]={0,0,0};
00239 char pRush=0;
00240 
00241   R1=R2=R3=oR1=oR2=oR3=0;fCsh=0;
00242   DrawRush(plr);
00243   pRush=(Data->P[plr].Cash>=3) ? 1 : 0;
00244   fCsh=Data->P[plr].Cash;
00245   grSetColor(1);
00246   music_start((plr==1)?M_USMIL:M_USSRMIL);
00247   FadeIn(2,pal,10,0,0);
00248   WaitForMouseUp();
00249   while (1)
00250   {
00251    key=0;GetMouse();
00252    if (mousebuttons > 0 || key>0)
00253     {
00254      if (((y>=32 && y<=74 && x>=280 && x<=312 && mousebuttons>0) || (key>='1' && key<='3'))
00255       && pRush && Data->P[plr].Mission[0].MissionCode>0 && Data->P[plr].Mission[0].part!=1)  /* L1: Row One */
00256       {
00257       // R1=oR1;
00258        if (((y>=49 && y<=57 && mousebuttons>0) || key=='2') && oR1!=1 && fCsh<3) Help("i117");
00259        R1=(((y>=49 && y<=57 && mousebuttons>0) || key=='2') && fCsh>=3) ? 1 : R1;
00260         if (((y>=66 && y<=74 && mousebuttons>0) || key=='3') && oR1!=2 && fCsh<6) Help("i117");
00261        R1=(((y>=66 && y<=74 && mousebuttons>0) || key=='3') && fCsh>=6) ? 2 : R1;
00262         R1=((y>=32 && y<=40 && mousebuttons>0) || key=='1') ? 0 : R1;
00263         if (oR1!=R1) {ResetRush(oR1,0);SetRush(R1,0);oR1=R1;}
00264       }
00265     else
00266     if (((x>=280 && x<=312 && y>=90 && y<=132 && mousebuttons>0) || (key>='4' && key<='6'))
00267       && pRush && Data->P[plr].Mission[1].MissionCode>0 && Data->P[plr].Mission[1].part!=1)  /* L2: Row One */
00268      {
00269       // R2=oR2;
00270       if (((y>=107 && y<=115 && mousebuttons>0) || key=='5') && oR2!=1 && fCsh<3) Help("i117");
00271       R2=(((y>=107 && y<=115 && mousebuttons>0) || key=='5') && fCsh>=3) ? 1 : R2;
00272     if (((y>=124 && y<=132 && mousebuttons>0) || key=='6') && oR2!=2 && fCsh<6) Help("i117");
00273       R2=(((y>=124 && y<=132 && mousebuttons>0) || key=='6') && fCsh>=6) ? 2 : R2;
00274        R2=((y>=90 && y<=98 && mousebuttons>0) || key=='4') ? 0 : R2;
00275     if (oR2!=R2) {ResetRush(oR2,1);SetRush(R2,1);oR2=R2;}
00276      }
00277     else
00278    if (((x>=280 && x<=312 && y>=148 && y<=190 && mousebuttons>0) || (key>='7' && key<='9'))
00279      && pRush && Data->P[plr].Mission[2].MissionCode>0 && Data->P[plr].Mission[2].part!=1)  /* L3: Row One */
00280     {
00281      // R3=oR3;
00282      if (((y>=165 && y<=173 && mousebuttons>0) || key=='8') && oR3!=1 && fCsh<3) Help("i117");
00283      R3=(((y>=165 && y<=173 && mousebuttons>0) || key=='8') && fCsh>=3) ? 1 : R3;
00284      if (((y>=182 && y<=190 && mousebuttons>0) || key=='9') && oR3!=2 && fCsh<6) Help("i117");
00285      R3=(((y>=182 && y<=190 && mousebuttons>0) || key=='9') && fCsh>=6) ? 2 : R3;
00286      R3=((y>=148 && y<=156 && mousebuttons>0) || key=='7') ? 0 : R3;
00287      if (oR3!=R3) {ResetRush(oR3,2);SetRush(R3,2);oR3=R3;}
00288     };
00289    // DOWNGRADE MISSION KEYBOARD
00290     if (key=='Q' || key=='R' || key=='U')
00291     {
00292       if (key=='Q') i=0; 
00293       else if (key=='R') i=1; 
00294       else if (key=='U') i=2;
00295       else i=0;
00296 
00297      if (Data->P[plr].Mission[i].MissionCode>0 && Data->P[plr].Mission[i].part!=1)    
00298        {
00299         
00300         InBox(91,41+i*58,264,59+i*58);
00301         RectFill(144,29+i*58,270,37+i*58,3);
00302         if (dg[Data->P[plr].Mission[i].MissionCode][dgflag[i]]!=0)
00303          {
00304           RectFill(93,43+i*58,262,57+i*58,3);
00305 
00306         grSetColor(5);
00307         GetMisType(dg[Data->P[plr].Mission[i].MissionCode][dgflag[i]]);
00308 
00309         PrintAt(96,48+58*i,Mis.Abbr);
00310 
00311           //Missions(plr,96,48+58*i,dg[Data->P[plr].Mission[i].MissionCode][dgflag[i]],0);
00312 
00313           dgflag[i]++;
00314           RectFill(191,71+i*58,270,78+i*58,3);
00315           grSetColor(9);PrintAt(145,33+i*58,"DOWNGRADED MISSION");
00316           PrintAt(193,77+i*58,"-3 PRESTIGE");
00317          }
00318         else 
00319          {
00320           dgflag[i]=0;
00321           RectFill(93,43+i*58,262,57+i*58,3);
00322         grSetColor(5);
00323         GetMisType(Data->P[plr].Mission[i].MissionCode);
00324 
00325         PrintAt(96,48+58*i,Mis.Abbr);
00326 
00327           //Missions(plr,96,48+58*i,Data->P[plr].Mission[i].MissionCode,0);   
00328           RectFill(191,71+i*58,270,78+i*58,3);
00329          if (Data->P[plr].Mission[i].Name[24]==1)
00330           {
00331            grSetColor(9);PrintAt(145,33+i*58,"DOWNGRADED MISSION");
00332             PrintAt(193,77+i*58,"-3 PRESTIGE");
00333           }
00334          else
00335           {
00336            grSetColor(7);PrintAt(145,33+i*58,"ORIGINAL MISSION");
00337            PrintAt(193,77+i*58,"NO PENALTY");
00338           }
00339           //grSetColor(7);
00340           //PrintAt(145,33+i*58,"ORIGINAL MISSION");
00341           //PrintAt(193,77+i*58,"NO PENALTY");
00342          }
00343         WaitForMouseUp();
00344         OutBox(91,41+i*58,264,59+i*58);
00345         
00346        }
00347     };
00348    for (i=0;i<3;i++)
00349     {
00350       if (x>=91 && x<=264 && y>=41+i*59 && y<=59+i*59 && mousebuttons>0 
00351        && Data->P[plr].Mission[i].MissionCode>0
00352        && Data->P[plr].Mission[i].part!=1)     // Downgrade
00353       {
00354        
00355        InBox(91,41+i*58,264,59+i*58);
00356        RectFill(144,29+i*58,270,37+i*58,3);
00357        if (dg[Data->P[plr].Mission[i].MissionCode][dgflag[i]]!=0)
00358         {
00359          RectFill(93,43+i*58,262,57+i*58,3);
00360         grSetColor(5);
00361         GetMisType(dg[Data->P[plr].Mission[i].MissionCode][dgflag[i]]);
00362         PrintAt(96,48+58*i,Mis.Abbr);
00363 
00364 
00365          //Missions(plr,96,48+58*i,dg[Data->P[plr].Mission[i].MissionCode][dgflag[i]],0);
00366          dgflag[i]++;
00367          RectFill(191,71+i*58,270,78+i*58,3);
00368          grSetColor(9);PrintAt(145,33+i*58,"DOWNGRADED MISSION");
00369          PrintAt(193,77+i*58,"-3 PRESTIGE");
00370         }
00371       else 
00372         {
00373          dgflag[i]=0;
00374          RectFill(93,43+i*58,262,57+i*58,3);
00375         grSetColor(5);
00376         GetMisType(Data->P[plr].Mission[i].MissionCode);
00377 
00378         PrintAt(96,48+58*i,Mis.Abbr);
00379 
00380 
00381          //Missions(plr,96,48+58*i,Data->P[plr].Mission[i].MissionCode,0);   
00382          RectFill(191,71+i*58,270,78+i*58,3);
00383         if (Data->P[plr].Mission[i].Name[24]==1)
00384          {
00385           grSetColor(9);PrintAt(145,33+i*58,"DOWNGRADED MISSION");
00386            PrintAt(193,77+i*58,"-3 PRESTIGE");
00387          }
00388         else
00389          {
00390           grSetColor(7);PrintAt(145,33+i*58,"ORIGINAL MISSION");
00391           PrintAt(193,77+i*58,"NO PENALTY");
00392          }
00393          //grSetColor(7);
00394          //PrintAt(145,33+i*58,"ORIGINAL MISSION");
00395          //PrintAt(193,77+i*58,"NO PENALTY");
00396         }
00397       WaitForMouseUp();
00398       OutBox(91,41+i*58,264,59+i*58);
00399       
00400      }
00401    };
00402   if ((x>=245 && y>=5 && x<=314 && y<=17 && mousebuttons>0) || key==K_ENTER)     //  CONTINUE
00403    {
00404      InBox(245,5,314,17);
00405      WaitForMouseUp();
00406     if (key>0) delay(150);
00407      OutBox(245,5,314,17);delay(10);
00408      for (i=0;i<3;i++)
00409      {
00410       if (Data->P[plr].Mission[i].MissionCode>0)
00411        {
00412         if (dgflag[i]!=0)
00413         {
00414            Data->P[plr].Mission[i].MissionCode=dg[Data->P[plr].Mission[i].MissionCode][dgflag[i]-1];
00415          pNeg[plr][i]=1;
00416         }
00417        }
00418      }
00419      if (Data->P[plr].Mission[1].part==1) R2=R1;
00420      if (Data->P[plr].Mission[2].part==1) R3=R2;
00421      if (Data->P[plr].Mission[0].MissionCode>0 && Data->P[plr].Cash>=3*R1)
00422      {
00423        Data->P[plr].Cash-=3*R1;
00424        Data->P[plr].Mission[0].Month-=R1;
00425        Data->P[plr].Mission[0].Rushing=R1;
00426       };
00427      if (Data->P[plr].Mission[1].MissionCode>0 && Data->P[plr].Cash>=3*R2)
00428      {
00429        Data->P[plr].Cash-=3*R2;
00430        Data->P[plr].Mission[1].Month-=R2;
00431        Data->P[plr].Mission[1].Rushing=R2;
00432       };
00433      if (Data->P[plr].Mission[2].MissionCode>0 && Data->P[plr].Cash>=3*R3)
00434      {
00435        Data->P[plr].Cash-=3*R3;
00436        Data->P[plr].Mission[2].Month-=R3;
00437        Data->P[plr].Mission[2].Rushing=R3;
00438       }
00439     music_stop();
00440      return;  // Done
00441    };
00442   }
00443  };
00444 }
00445 
00446 void ResetRush(int mode,int val)
00447 {
00448   
00449   OutBox(280,32+17*mode+val*58,312,40+17*mode+val*58);
00450   fCsh+=mode*3;
00451   
00452   return;
00453 }
00454 
00455 void SetRush(int mode,int val)
00456 {
00457   
00458   InBox(280,32+17*mode+val*58,312,40+17*mode+val*58);  
00459   RectFill(177,63+58*val,192,70+58*val,3);
00460   RectFill(225,62+58*val,270,70+58*val,3);
00461   grSetColor(11);DispNum(179,69+58*val,mode*3);DispChr('%');
00462   grSetColor(9);DispNum(230,69+58*val,mode*3);grSetColor(1);PrintAt(237,69+58*val,"MB");
00463   fCsh-=mode*3;
00464   
00465   return;
00466 }

Generated on Fri Sep 28 00:35:46 2007 for raceintospace by  doxygen 1.5.3