newmis.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 #include "Buzz_inc.h"
00019 #include "externs.h"
00020 
00021 char Month[12][11] = {
00022     "JANUARY ","FEBRUARY ","MARCH ","APRIL ","MAY ","JUNE ",
00023     "JULY ","AUGUST ","SEPTEMBER ","OCTOBER ","NOVEMBER ","DECEMBER "};
00024 
00025 struct order Order[7] ;
00026 unsigned int colss,VBlank;
00027 extern char AI[2];
00028 extern struct mStr Mis;
00029 extern char dg[62][6];
00030 extern char Option,MAIL,BIG;
00031 
00032 static int
00033 cmp_order(const void *p1, const void *p2)
00034 {
00035     struct order *o1 = (struct order *) p1;
00036     struct order *o2 = (struct order *) p2;
00037 
00038     if (o1->date < o2->date)
00039         return -1;
00040     else if (o1->date == o2->date)
00041     {
00042         if (o1->budget < o2->budget)
00043             return -1;
00044         else
00045             return 0;
00046     }
00047     else return 1;
00048 }
00049 
00050 char
00051 OrderMissions(void)
00052 {
00053     int i, j, k;
00054 
00055     memset(Order, 0x00, sizeof Order);
00056     // Sort Missions for Proper Order
00057     k = 0;
00058     for (i = 0; i < NUM_PLAYERS; i++)
00059         for (j = 0; j < MAX_MISSIONS; j++)
00060             if (Data->P[i].Mission[j].MissionCode > 0
00061                 && Data->P[i].Mission[j].part != 1)
00062             {
00063                 Order[k].plr = i;
00064                 Order[k].loc = j;
00065                 Order[k].budget = Data->P[i].Budget;
00066                 Order[k].date = Data->P[i].Mission[j].Month;
00067                 k++;
00068             };
00069     if (k)
00070         qsort(Order, k-1, sizeof(struct order), cmp_order);
00071 
00072     if (MAIL == -1 && Option == -1 && AI[0] == 0 && AI[1] == 0 && k != 0)
00073         MisOrd(k);
00074     return k;
00075 }
00076 
00077 void MisOrd(char num)
00078 {
00079   int i,j=0;
00080   
00081   ShBox(63,19,257,173);
00082   InBox(74,36,246,163);
00083   grSetColor(36);PrintAt(77,30,"       LAUNCH ORDER");
00084 
00085   for (i=0;i<num;i++) {
00086     InBox(78,39+21*j,105,55+21*j);
00087     FlagSm(Order[i].plr,79,40+21*j);
00088     grSetColor(34);
00089     PrintAt(110,45+21*j,"SCHEDULED LAUNCH");
00090     PrintAt(110,52+21*j,"DATE: ");
00091     grSetColor(1);
00092 
00093     PrintAt(0,0,
00094       Month[Data->P[Order[i].plr].Mission[Order[i].loc].Month]);
00095 
00096     PrintAt(0,0," 19");DispNum(0,0,Data->Year);
00097     j++;
00098   };
00099   FadeIn(2,pal,10,0,0);
00100   
00101   WaitForMouseUp();
00102     WaitForKeyOrMouseDown();
00103     WaitForMouseUp();
00104     FadeOut(2,pal,10,0,0);
00105 }
00106 
00107 
00108 void MisAnn(char plr,char pad)
00109 {
00110   int i,j,bud;
00111   struct mStr Mis2;
00112   char k,hold,Digit[4],HelpFlag=0;
00113   char pad_str[2] = {'A'+pad, '\0'};
00114   
00115   for (i=0;i<768;i++) pal[i]=0;
00116   gxSetDisplayPalette(pal);
00117   gxClearDisplay(0,0);
00118 
00119   PortPal(plr);
00120   ShBox(41,20,281,184);InBox(46,25,276,179);
00121   InBox(46,25,117,65);Flag(47,26,plr);
00122   InBox(122,25,276,65);
00123   grSetColor(34);
00124   PrintAt(154,33,"SCHEDULED LAUNCH");
00125   PrintAt(127,40,"LAUNCH FACILITY: ");
00126   grSetColor(1);
00127   PrintAt(0,0,"PAD ");
00128   PrintAt(0,0,pad_str);
00129   grSetColor(34);
00130   PrintAt(127,47,"DATE: ");
00131   grSetColor(1);
00132 
00133   PrintAt(0,0,Month[Data->P[plr].Mission[pad].Month]);
00134 
00135   PrintAt(0,0," 19");DispNum(0,0,Data->Year);
00136   grSetColor(1);
00137 
00138   GetMisType(Data->P[plr].Mission[pad].MissionCode);
00139   memcpy(&Mis2,&Mis,sizeof Mis);
00140 
00141 
00142   if ((Mis.mVab[0]&0x10)==0x10 && Data->P[plr].DMod<=0) {
00143      i=0;
00144      while (dg[Mis2.Index][i]!=0 && Mis.Doc==1) {
00145         GetMisType(dg[Mis2.Index][i]);
00146         i++;
00147      }
00148      if (dg[Mis2.Index][i]==0) Data->P[plr].Mission[pad].MissionCode=4;  // new mission
00149      else Data->P[plr].Mission[pad].MissionCode=Mis.Index;  // new mission
00150      GetMisType(Data->P[plr].Mission[pad].MissionCode);
00151      HelpFlag=1;
00152   }
00153 
00154   PrintAt(127,54,Mis.Abbr);
00155 
00156   IOBox(57,68,118,84);IOBox(131,68,197,84);IOBox(205,68,266,84);
00157   grSetColor(1);PrintAt(65,78,"CONTINUE");PrintAt(137,78,"PLAY FULL");
00158   PrintAt(221,78,"SCRUB");
00159   grSetColor(9);
00160   PrintAt(65,78,"C");PrintAt(137,78,"P");PrintAt(221,78,"S");
00161 
00162   //IOBox(85,68,158,84);IOBox(172,68,245,84);
00163   //grSetColor(1);PrintAt(102,78,"CONTINUE");PrintAt(189,78,"SCRUB");
00164   //grSetColor(9);
00165   //PrintAt(102,78,"C");PrintAt(189,78,"S");
00166 
00167   if (Data->P[plr].Mission[pad].Joint==0) PrintAt(129,91,"SINGLE LAUNCH");
00168     else 
00169      {
00170       PrintAt(129,91,"JOINT LAUNCH");
00171       PrintAt(49,101,"PART ONE");
00172       PrintAt(102,101,"PAD ");
00173       //DispNum(0,0,pad);
00174       switch(pad) {
00175           case 0: PrintAt(0,0,"A");break;
00176           case 1: PrintAt(0,0,"B");break;
00177           case 2: PrintAt(0,0,"C");break;
00178       };
00179 
00180       PrintAt(160,101,"PART TWO");
00181       PrintAt(213,101,"PAD ");
00182       //DispNum(0,0,pad+1);
00183       switch(pad+1) {
00184           case 0: PrintAt(0,0,"A");break;
00185           case 1: PrintAt(0,0,"B");break;
00186           case 2: PrintAt(0,0,"C");break;
00187       };
00188 
00189      }
00190 for (i=0;i<Data->P[plr].Mission[pad].Joint+1;i++)
00191   {
00192   k=0;if (i==0) bud=49; else bud=160;
00193   for(j=Mission_Capsule; j <= Mission_PrimaryBooster; j++)
00194    {
00195     hold = Data->P[plr].Mission[pad+i].Hard[j];
00196     switch(j)
00197      {
00198       case 0:if (hold>-1) 
00199            {
00200         grSetColor(7);PrintAt(bud,109+14*k,"CAPSULE: ");grSetColor(1);PrintAt(0,0,&Data->P[plr].Manned[hold].Name[0]);
00201         grSetColor(11);PrintAt(bud,116+14*k,"SAFETY FACTOR: ");grSetColor(1);
00202      sprintf(&Digit[0],"%d",Data->P[plr].Manned[hold].Safety);
00203      PrintAt(0,0,&Digit[0]);
00204      PrintAt(0,0,"%");
00205      // PrintAt(144+i*111,116+14*k,"%");
00206         ++k;
00207            };
00208          break;
00209       case 1:if (hold>-1)
00210            {
00211         grSetColor(7);PrintAt(bud,109+14*k,"KICKER: ");grSetColor(1);PrintAt(0,0,&Data->P[plr].Misc[hold].Name[0]);
00212      grSetColor(11);PrintAt(bud,116+14*k,"SAFETY FACTOR: ");grSetColor(1);
00213      sprintf(&Digit[0],"%d",Data->P[plr].Misc[hold].Safety);
00214      PrintAt(0,0,&Digit[0]);
00215      PrintAt(0,0,"%");
00216     // DispNum(0,0,Data->P[plr].Misc[hold].Safety);
00217       //    PrintAt(144+i*111,116+14*k,"%");  
00218         ++k;
00219            };
00220           break;
00221        case 2:if (hold>-1)          
00222         {
00223          grSetColor(7);PrintAt(bud,109+14*k,"LM: ");grSetColor(1);PrintAt(0,0,&Data->P[plr].Manned[hold].Name[0]);
00224          grSetColor(11);PrintAt(bud,116+14*k,"SAFETY FACTOR: ");grSetColor(1);
00225       sprintf(&Digit[0],"%d",Data->P[plr].Manned[hold].Safety);
00226       PrintAt(0,0,&Digit[0]);
00227       PrintAt(0,0,"%");
00228       //DispNum(0,0,Data->P[plr].Manned[hold].Safety);
00229          //PrintAt(144+i*111,116+14*k,"%");  
00230          ++k;
00231         };
00232            break;
00233     case 3:if (hold>-1)
00234          {
00235           if (hold<3)
00236             {
00237              grSetColor(7);PrintAt(bud,109+14*k,"PROBE: ");grSetColor(1);PrintAt(0,0,&Data->P[plr].Probe[hold].Name[0]);
00238              grSetColor(11);PrintAt(bud,116+14*k,"SAFETY FACTOR: ");grSetColor(1);
00239           sprintf(&Digit[0],"%d",Data->P[plr].Probe[hold].Safety);
00240           PrintAt(0,0,&Digit[0]);
00241           PrintAt(0,0,"%");
00242           //DispNum(0,0,Data->P[plr].Probe[hold].Safety);
00243              //PrintAt(144+i*111,116+14*k,"%");  
00244              ++k;
00245             }
00246            else if (hold==4)
00247             {
00248              grSetColor(7);PrintAt(bud,109+14*k,"DOCKING: ");grSetColor(1);PrintAt(0,0,&Data->P[plr].Misc[hold].Name[0]);
00249              grSetColor(11);PrintAt(bud,116+14*k,"SAFETY FACTOR: ");grSetColor(1);
00250           sprintf(&Digit[0],"%d",Data->P[plr].Misc[hold].Safety);
00251           PrintAt(0,0,&Digit[0]);
00252           PrintAt(0,0,"%");
00253           //DispNum(0,0,Data->P[plr].Misc[hold].Safety);
00254              //PrintAt(144+i*111,116+14*k,"%");    
00255              ++k;
00256             }
00257          };
00258            break;
00259     case 4:if (hold>-1)
00260          {
00261           if (hold<5)
00262             {
00263              grSetColor(7);PrintAt(bud,109+14*k,"ROCKET: ");grSetColor(1);PrintAt(0,0,&Data->P[plr].Rocket[hold-1].Name[0]);
00264              grSetColor(11);PrintAt(bud,116+14*k,"SAFETY FACTOR: ");grSetColor(1);
00265           sprintf(&Digit[0],"%d",Data->P[plr].Rocket[hold-1].Safety);
00266           PrintAt(0,0,&Digit[0]);
00267           PrintAt(0,0,"%");
00268           //DispNum(0,0,Data->P[plr].Rocket[hold-1].Safety);
00269              //PrintAt(144+i*111,116+14*k,"%");  
00270              ++k;
00271             }
00272           else 
00273            {
00274             grSetColor(7);PrintAt(bud,109+14*k,"ROCKET: ");grSetColor(1);PrintAt(0,0,&Data->P[plr].Rocket[hold-5].Name[0]);PrintAt(0,0," W/B");
00275             grSetColor(11);PrintAt(bud,116+14*k,"SAFETY FACTOR: ");grSetColor(1);
00276          sprintf(&Digit[0],"%d",(Data->P[plr].Rocket[hold-5].Safety+Data->P[plr].Rocket[4].Safety)/2);
00277          PrintAt(0,0,&Digit[0]);
00278          PrintAt(0,0,"%");
00279         // DispNum(0,0,(Data->P[plr].Rocket[hold-5].Safety+Data->P[plr].Rocket[4].Safety)/2);
00280            // PrintAt(144+i*111,116+14*k,"%");  
00281             ++k;
00282            }
00283          }
00284            break;
00285     default:break;
00286     }
00287    }
00288   }
00289   FadeIn(2,pal,10,0,0);
00290   
00291 
00292   WaitForMouseUp();
00293   if (HelpFlag) Help("i156");  // Notification of being an Help
00294 
00295   while (1)
00296   {
00297     key=0;GetMouse();
00298     if ((x>=59 && y>=70 && x<=116 && y<=82 && mousebuttons > 0) || key==K_ENTER || key=='C')
00299       {
00300        InBox(59,70,116,82);
00301         WaitForMouseUp();
00302        OutBox(59,70,116,82);
00303        FadeOut(2,pal,10,0,0);BIG=0;return;
00304       }
00305     else if ((x>=133 && y>=70 && x<=195 && y<=82 && mousebuttons > 0) || key==K_ENTER || key=='P')
00306       {
00307        InBox(133,70,195,82);
00308         WaitForMouseUp();
00309        OutBox(133,70,195,82);
00310        FadeOut(2,pal,10,0,0);BIG=1;return;
00311       }
00312 
00313      else
00314     if ((x>=207 && y>=70 && x<=264 && y<=82 && mousebuttons > 0) || key=='S')
00315       {
00316        InBox(207,70,264,82);
00317        WaitForMouseUp();
00318        OutBox(207,70,264,82);
00319         {
00320          ClrMiss(plr,pad);
00321         }
00322        if (Data->P[plr].Mission[pad].MissionCode==0) {FadeOut(2,pal,10,0,0);return;}
00323       }
00324   };
00325 }
00326 
00327 
00328 void AI_Begin(char plr)
00329 {
00330   int i;
00331   FILE *fin;
00332   long len[2];
00333 
00334   
00335   for (i=0;i<768;i++) pal[i]=0;
00336   gxSetDisplayPalette(pal);
00337 
00338   fin=sOpen("TURN.BUT","rb",0);
00339   fread(&pal,768,1,fin);
00340   len[0]=fread(screen,1,MAX_X*MAX_Y,fin);
00341   fclose(fin);
00342   RLED_img((char *)screen,vhptr.vptr,(unsigned int)len[0],
00343        vhptr.w,vhptr.h);
00344 
00345   gxClearDisplay(0,0); ShBox(0,60,319,80);
00346   grSetColor(6+plr*3);
00347   if (plr==0) DispBig(15,64,"DIRECTOR OF THE UNITED STATES",0,-1);
00348   else DispBig(30,64,"CHIEF DESIGNER OF THE USSR",0,-1);
00349   grSetColor(11);
00350   grMoveTo(175,122);
00351   if (Data->Season==0) PrintAt(0,0,"SPRING 19");
00352   else PrintAt(0,0,"FALL 19");
00353   DispNum(0,0,Data->Year);
00354   gxVirtualDisplay(&vhptr,1+110*plr,1,30,85,30+107,85+93,0);
00355   grSetColor(11);
00356   PrintAt(60,58,"COMPUTER TURN:  THINKING...");
00357   music_start(M_SOVTYP);
00358   FadeIn(2,pal,10,0,0);
00359   colss=0;
00360 }
00361 
00362 void AI_Done(void)
00363 {
00364   music_stop();
00365   FadeOut(2,pal,10,0,0);
00366   memset(screen,0x00,64000);
00367   
00368 }
00369 

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