ast3.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 /** \file ast3.c Training and Hospital code
00026  */
00027 
00028 #include "Buzz_inc.h"
00029 #include "externs.h"
00030 
00031 
00032 void DrawTrain(char plr,char lvl)
00033 {
00034  char TrnName[20];
00035  char *Trner="TRAINING\0";
00036   
00037   if (lvl==0) {
00038    strcpy(IDT,"i038");strcpy(IKEY,"k038");
00039    }
00040    else {strcpy(IDT,"i037");strcpy(IKEY,"k037");}
00041   FadeOut(2,pal,10,0,0);
00042   gxClearDisplay(0,0);
00043   ShBox(0,0,319,22);
00044   ShBox(0,24,158,114);
00045   ShBox(161,24,319,199);
00046   ShBox(0,116,158,199);
00047   RectFill(5,129,19,195,0);
00048   RectFill(25,129,153,195,0);
00049   ShBox(6,130,18,161);ShBox(6,163,18,194);
00050   IOBox(243,3,316,19);IOBox(166,179,316,195);
00051   InBox(3,3,30,19);InBox(202,28,283,79);
00052   InBox(4,128,20,196);
00053   InBox(24,128,154,196);
00054   InBox(3,27,154,110);
00055   UPArrow(9,133);DNArrow(9,166);
00056   grSetColor(5);
00057   if (plr==0) PrintAt(17,124,"ASTRONAUTS");
00058   else PrintAt(17,124,"COSMONAUTS");
00059   PrintAt(0,0," IN TRAINING");
00060   memset(TrnName,0x00,sizeof(TrnName));
00061   switch(lvl) {
00062     case 0:strcpy(TrnName,"BASIC ");strcat(TrnName,Trner);
00063           DispBig(40,5,TrnName,0,-1);break;
00064     case 1:strcpy(TrnName,"CAPSULE ");strcat(TrnName,Trner);
00065           DispBig(37,5,TrnName,0,-1);break; 
00066     case 2:strcpy(TrnName,"LM ");strcat(TrnName,Trner);
00067           DispBig(40,5,TrnName,0,-1);break; 
00068     case 3:strcpy(TrnName,"EVA ");strcat(TrnName,Trner);
00069           DispBig(40,5,TrnName,0,-1);break; 
00070     case 4:strcpy(TrnName,"DOCKING ");strcat(TrnName,Trner);
00071           DispBig(37,5,TrnName,0,-1);break; 
00072     case 5:strcpy(TrnName,"ENDURANCE ");strcat(TrnName,Trner);
00073           DispBig(37,5,TrnName,0,-1);break; 
00074     default:break;
00075   };
00076   grSetColor(1);
00077   PrintAt(258,13,"CONTINUE");
00078   grSetColor(7);PrintAt(169,88,"NAME:");        /* 196,32 */
00079   grSetColor(1);
00080   PrintAt(169,97,"GROUP ");
00081   PrintAt(240,97,"TENURE: ");
00082   grMoveTo(201,97);
00083 
00084   /*  Data->P[plr].AstroLevel     201,41 */
00085 
00086   grSetColor(7);
00087   PrintAt(169,115,"STATUS:");
00088   grSetColor(9);PrintAt(169,133,"SKILL:");
00089   grSetColor(7);
00090   PrintAt(192,142,"CAP:"); PrintAt(192,150,"L.M.:");
00091   PrintAt(192,158,"E.V.A.:"); PrintAt(192,166,"DOCK:");
00092   PrintAt(192,174,"END:");
00093   grSetColor(9);PrintAt(181,189,"W");
00094   grSetColor(1);PrintAt(0,0,"ITHDRAW FROM TRAINING");
00095   RectFill(203,29,282,78,7+(plr*3));
00096   FlagSm(plr,4,4);
00097   
00098   return;
00099 }
00100 
00101 void TrainText(char plr,int astro,int cnt)
00102 {
00103  char Fritz[20];
00104 
00105   RectFill(200,83,291,88,3);RectFill(202,93,220,97,3);
00106   RectFill(216,102,294,106,3);RectFill(212,111,317,124,3);
00107   RectFill(215,138,235,142,3);RectFill(213,145,243,150,3);
00108   RectFill(221,153,241,158,3);RectFill(220,161,240,166,3);
00109   RectFill(215,170,235,174,3);
00110   RectFill(282,91,318,97,3);
00111   if (cnt==0) return;
00112   grSetColor(1);
00113   PrintAt(200,88,&Data->P[plr].Pool[astro].Name[0]);
00114   grMoveTo(212,115);
00115   grSetColor(11);
00116   memset(Fritz,0x00,sizeof(Fritz));
00117   if (Data->P[plr].Pool[astro].Status>=4 && Data->P[plr].Pool[astro].Status<=6)
00118    strncpy(Fritz,"BASIC TRAINING ",14);
00119 
00120   switch(Data->P[plr].Pool[astro].Status) {
00121     case 0:PrintAt(0,0,"ACTIVE");break;
00122     case 4:strcat(Fritz,"I");PrintAt(0,0,&Fritz[0]);break;
00123     case 5:strcat(Fritz,"II");PrintAt(0,0,&Fritz[0]);break;
00124     case 6:strcat(Fritz,"III");PrintAt(0,0,&Fritz[0]);break;
00125     case 7:PrintAt(0,0,"ADV TRAINING I");break;
00126     case 8:PrintAt(0,0,"ADV TRAINING II");break;
00127     case 9:PrintAt(0,0,"ADV TRAINING III");break;
00128     case 10:PrintAt(0,0,"ADV TRAINING IV");break;
00129     default:break;
00130   };
00131   grSetColor(11);
00132   grMoveTo(203,97);
00133   switch(Data->P[plr].Pool[astro].Group) {
00134     case 0: PrintAt(0,0,"I");break;
00135     case 1: PrintAt(0,0,"II");break;
00136     case 2: PrintAt(0,0,"III");break;
00137     case 3: PrintAt(0,0,"IV");break;
00138   };
00139   DispNum(282,97,Data->P[plr].Pool[astro].Active);
00140   grSetColor(1);
00141   DispNum(215,142,Data->P[plr].Pool[astro].Cap);
00142   DispNum(213,150,Data->P[plr].Pool[astro].LM);
00143   DispNum(221,158,Data->P[plr].Pool[astro].EVA);
00144   DispNum(220,166,Data->P[plr].Pool[astro].Docking);
00145   DispNum(215,174,Data->P[plr].Pool[astro].Endurance);
00146   AstFaces(plr,203,29,Data->P[plr].Pool[astro].Face);
00147   return;
00148 };
00149 
00150 
00151 /* level is as follows
00152      0  =  Basic Training
00153      1  =  Advanced Capsule
00154      2  =  Advanced LM
00155      3  =  Advanced EVA
00156      4  =  Advanced Docking
00157      5  =  Advanced Duration
00158 */
00159 
00160 void Train(char plr,int level)
00161 {
00162   int now2,BarA,count,i,M[100];
00163   char temp,Train[10];
00164   static int m=1;
00165   for (i=0;i<100;i++) M[i]=-1;
00166   now2=BarA=count=0;
00167   DrawTrain(plr,level);
00168 
00169   ShBox(26,130+BarA*8,152,138+BarA*8);
00170   for (i=0;i<Data->P[plr].AstroCount;i++) {
00171     if (Data->P[plr].Pool[i].Status>=4 && Data->P[plr].Pool[i].Status<=6 &&
00172     level==0 )  M[count++]=i;
00173     if (Data->P[plr].Pool[i].Status>=7 && Data->P[plr].Pool[i].Status<=10 &&
00174     Data->P[plr].Pool[i].Focus==level )  M[count++]=i;
00175   };
00176   
00177   DispLeft(plr,BarA,count,now2,&M[0]);
00178   if (count>0) TrainText(plr,M[0],count);
00179   FadeIn(2,pal,10,0,0);
00180   if (level==0)
00181    {
00182     if (m>4) m=1;
00183      else m++;
00184     level=m;
00185    }
00186   memset(Train,0x00,sizeof(Train));
00187 
00188     if (level==0)
00189         music_start((plr==0)?M_ASTTRNG:M_ASSEMBLY);
00190   else
00191         music_start(M_DRUMSM);
00192     
00193     switch(level) {
00194     case 1:strcpy(Train,(plr==0)?"UTCP":"STCP");
00195          Replay(plr,0,4,28,149,82,Train);break;
00196     case 2:strcpy(Train,(plr==0)?"UTLM":"STLM");
00197          Replay(plr,0,4,28,149,82,Train);break;
00198     case 3:strcpy(Train,(plr==0)?"UTEV":"STEV");
00199          Replay(plr,0,4,28,149,82,Train);break;
00200     case 4:strcpy(Train,(plr==0)?"UTDO":"STDO");
00201          Replay(plr,0,4,28,149,82,Train);break;
00202     case 5:strcpy(Train,(plr==0)?"UTDU":"STDU");
00203          Replay(plr,0,4,28,149,82,Train);break;
00204     default:break;
00205   };
00206   
00207   WaitForMouseUp();
00208   while (1)
00209   {
00210     key=0;GetMouse();
00211     for (i=0;i<8;i++) {  // Right Select Box
00212       if (x>=27 && y>=(131+i*8) && x<=151 && y<=(137+i*8) && mousebuttons>0 && (now2-BarA+i)<=(count-1)) { // Left
00213          
00214      now2-=BarA; now2+=i; BarA=i;
00215      RectFill(26,129,153,195,0);
00216      ShBox(26,130+BarA*8,152,138+BarA*8);
00217      DispLeft(plr,BarA,count,now2,&M[0]);
00218          TrainText(plr,M[now2],count);
00219      WaitForMouseUp();
00220      
00221       }
00222     }
00223 
00224     if (mousebuttons > 0 || key>0)
00225     {
00226      if (((x>=6 && y>=130 && x<=18 && y<=161 && mousebuttons>0) || key==UP_ARROW) && count>0)
00227      { /* Lft Up */
00228        InBox(6,130,18,161);
00229       for (i=0;i<50;i++)
00230        {
00231          key=0;
00232          GetMouse();
00233          delay(10);
00234          if (mousebuttons==0) {
00235          
00236           if (BarA==0)
00237            if (now2>0) {
00238              now2--;
00239              RectFill(26,129,153,195,0);
00240              ShBox(26,130+BarA*8,152,138+BarA*8);
00241              DispLeft(plr,BarA,count,now2,&M[0]);
00242              TrainText(plr,M[now2],count);
00243           };
00244          if (BarA>0) {
00245           RectFill(26,129,153,195,0);
00246           BarA--;now2--;
00247           ShBox(26,130+BarA*8,152,138+BarA*8);
00248           DispLeft(plr,BarA,count,now2,&M[0]);
00249           TrainText(plr,M[now2],count);
00250          };
00251          
00252         i=51;
00253         }
00254        }
00255       while (mousebuttons==1 || key==UP_ARROW)
00256        {
00257         delay(100);
00258         
00259        if (BarA==0)
00260         if (now2>0) {
00261           now2--;
00262           RectFill(26,129,153,195,0);
00263           ShBox(26,130+BarA*8,152,138+BarA*8);
00264           DispLeft(plr,BarA,count,now2,&M[0]);
00265           TrainText(plr,M[now2],count);
00266         };
00267        if (BarA>0) {
00268         RectFill(26,129,153,195,0);
00269         BarA--;now2--;
00270         ShBox(26,130+BarA*8,152,138+BarA*8);
00271         DispLeft(plr,BarA,count,now2,&M[0]);
00272         TrainText(plr,M[now2],count);
00273        };
00274        
00275         key=0;
00276         GetMouse();
00277        }
00278        //WaitForMouseUp();
00279        OutBox(6,130,18,161);delay(10);
00280      }
00281      else
00282      if (((x>=6 && y>=163 && x<=18 && y<=194 && mousebuttons>0) || key==DN_ARROW) && count>0)
00283       { /* Lft Dwn */
00284         InBox(6,163,18,194);
00285        for (i=0;i<50;i++)
00286        {
00287          key=0;
00288          GetMouse();
00289          delay(10);
00290          if (mousebuttons==0) {
00291         
00292         if (BarA==7)
00293          if (now2 < count-1) {
00294            now2++;
00295            RectFill(26,129,153,195,0);
00296            ShBox(26,130+BarA*8,152,138+BarA*8);
00297            DispLeft(plr,BarA,count,now2,&M[0]);
00298            TrainText(plr,M[now2],count);
00299          };
00300         if (BarA<7)
00301          if (now2<count-1) {
00302           RectFill(26,129,153,195,0);
00303           BarA++;now2++;
00304            ShBox(26,130+BarA*8,152,138+BarA*8);
00305            DispLeft(plr,BarA,count,now2,&M[0]);
00306            TrainText(plr,M[now2],count);
00307          };
00308         
00309         i=51;
00310         }
00311        }
00312       while (mousebuttons==1 || key==DN_ARROW)
00313        {
00314         delay(100);
00315         
00316         if (BarA==7)
00317          if (now2 < count-1) {
00318            now2++;
00319            RectFill(26,129,153,195,0);
00320            ShBox(26,130+BarA*8,152,138+BarA*8);
00321            DispLeft(plr,BarA,count,now2,&M[0]);
00322            TrainText(plr,M[now2],count);
00323          };
00324         if (BarA<7)
00325          if (now2<count-1) {
00326           RectFill(26,129,153,195,0);
00327           BarA++;now2++;
00328            ShBox(26,130+BarA*8,152,138+BarA*8);
00329            DispLeft(plr,BarA,count,now2,&M[0]);
00330            TrainText(plr,M[now2],count);
00331          };
00332         
00333         key=0;
00334         GetMouse();
00335        }
00336         //WaitForMouseUp();
00337         OutBox(6,163,18,194);delay(10);
00338        }
00339      else
00340       if (((x>=168 && y>=181 && x<=314 && y<=193 && mousebuttons>0) || key=='W') && count>0)
00341       {
00342         InBox(168,181,314,193);
00343         WaitForMouseUp();
00344        if (key>0) delay(150);
00345         OutBox(168,181,314,193);
00346        // Help box are you sure
00347        temp=0;if (plr==0) temp=Help("i102"); else temp=Help("i109");
00348        if (temp==1)
00349         {
00350           Data->P[plr].Pool[M[now2]].TrainingLevel=Data->P[plr].Pool[M[now2]].Status;
00351           Data->P[plr].Pool[M[now2]].Status=0;
00352           Data->P[plr].Pool[M[now2]].Assign=0;
00353           if (Data->P[plr].Pool[M[now2]].Cap<0) Data->P[plr].Pool[M[now2]].Cap=0;
00354           if (Data->P[plr].Pool[M[now2]].LM<0) Data->P[plr].Pool[M[now2]].LM=0;
00355           if (Data->P[plr].Pool[M[now2]].EVA<0) Data->P[plr].Pool[M[now2]].EVA=0;
00356           if (Data->P[plr].Pool[M[now2]].Docking<0) Data->P[plr].Pool[M[now2]].Docking=0;
00357           if (Data->P[plr].Pool[M[now2]].Endurance<0) Data->P[plr].Pool[M[now2]].Endurance=0;
00358           for (i=now2;i<count;i++) M[i]=M[i+1];
00359           M[i]=-1;count--;
00360         
00361           if (count==0) RectFill(203,29,282,78,7+(plr*3));
00362           if (now2==count)
00363           {
00364             if (now2>0) now2--;
00365             if (BarA>0) BarA--;
00366            };
00367           RectFill(26,129,153,195,0);
00368           ShBox(26,130+BarA*8,152,138+BarA*8);
00369           DispLeft(plr,BarA,count,now2,&M[0]);
00370           TrainText(plr,M[now2],count);
00371         
00372         }
00373         
00374       } /* end x-y if */
00375      else
00376       if ((x>=245 && y>=5 && x<=314 && y<=17 && mousebuttons>0) || key==K_ENTER)
00377       {
00378         InBox(245,5,314,17);
00379         WaitForMouseUp();
00380        if (key>0) delay(150);
00381         OutBox(245,5,314,17);
00382        music_stop();
00383         return;  /* Done */
00384       }; /* end x-y if */
00385     } /* end mouse if */
00386   };  /* end while */
00387 } /* end Limbo */
00388 
00389 
00390 void Hospital(char plr,int sel)
00391 {
00392   int now2,BarA,count,i,j,M[100];
00393   FILE *fin;
00394   long size;
00395   if (sel==0) {strcpy(IDT,"i041");strcpy(IKEY,"k041");}
00396     else {strcpy(IDT,"i020");strcpy(IKEY,"k020");}
00397   for (i=0;i<100;i++) M[i]=0;
00398   now2=0;BarA=count=0;
00399   
00400   FadeOut(2,pal,10,0,0);
00401 
00402 // pal, len, image 
00403   
00404   fin=sOpen("CEM.IMG","rb",0);
00405   fread(&pal[0],768,1,fin);
00406   fread(&size,4,1,fin);
00407     Swap32bit(size);
00408   if (sel==1) {
00409 
00410     if (plr==1) {
00411       fseek(fin,size,SEEK_CUR);  // place on the sov cem
00412       fread(&pal[0],768,1,fin);
00413       fread(&size,4,1,fin);
00414             Swap32bit(size);
00415       }
00416     }
00417   if (sel==0) {
00418     fseek(fin,size,SEEK_CUR);  // Skip past us cem
00419     fread(&pal[0],768,1,fin);     
00420     fread(&size,4,1,fin);
00421         Swap32bit(size);
00422 
00423     fseek(fin,size,SEEK_CUR);  // Place on the US hosp
00424     fread(&pal[0],768,1,fin);
00425     fread(&size,4,1,fin);
00426         Swap32bit(size);
00427 
00428     if (plr==1) {
00429       fseek(fin,size,SEEK_CUR);  // Skip to SOv hosp
00430       fread(&pal[0],768,1,fin);
00431       fread(&size,4,1,fin);
00432             Swap32bit(size);
00433       }
00434     }
00435   fread(screen,size,1,fin);
00436   fclose(fin);
00437   PCX_D(screen,vhptr.vptr,(unsigned int)size);
00438 
00439   gxClearDisplay(0,0);
00440   ShBox(0,0,319,22);
00441   ShBox(161,103,319,199);
00442   ShBox(0,103,158,199);IOBox(243,3,316,19);
00443   RectFill(5,129,19,195,0);RectFill(25,129,153,195,0);
00444   ShBox(6,163,18,194);ShBox(6,130,18,161);
00445   InBox(3,3,30,19);InBox(26,38,107,89);
00446   InBox(166,107,313,195);
00447   InBox(9,109,148,123);InBox(4,128,20,196);
00448   InBox(24,128,154,196);
00449   UPArrow(9,133);DNArrow(9,166);
00450   FlagSm(plr,4,4);
00451   ShBox(0,24,319,101);
00452   gxVirtualDisplay(&vhptr,0,0,1,25,318,100,0);
00453   
00454   gxVirtualDisplay(&vhptr,0,81,167,108,312,194,0);
00455 
00456   grSetColor(1);
00457   if (plr==0) {
00458     if (sel==0) {DispBig(40,5,"US HOSPITAL",0,-1);music_start(M_BADNEWS);}
00459     else {DispBig(37,5,"ARLINGTON CEMETERY",0,-1);music_start(M_USFUN);}
00460   };
00461   if (plr==1) {
00462     if (sel==0) {DispBig(40,5,"SOVIET INFIRMARY",0,-1);music_start(M_INTERLUD);}
00463     else {DispBig(40,5,"KREMLIN WALL",0,-1);music_start(M_SVFUN);}
00464   }
00465   grSetColor(1);
00466   PrintAt(257,13,"CONTINUE");
00467   grSetColor(11);
00468   if (plr==0) PrintAt(27,118,"ASTRONAUT"); else PrintAt(27,118,"COSMONAUT");
00469   PrintAt(0,0," SELECTION");
00470   ShBox(26,130+BarA*8,152,138+BarA*8);
00471   
00472 
00473   j=(sel==0) ? 3 : 1;   /* Hosp or WormFood */
00474   for (i=0;i<Data->P[plr].AstroCount;i++)
00475     if (Data->P[plr].Pool[i].Status==j) {
00476       M[count++]=i;
00477     };
00478   DispLeft(plr,BarA,count,now2,&M[0]);
00479   FadeIn(2,pal,10,0,0);
00480   WaitForMouseUp();
00481   while (1)
00482   {
00483     key=0;GetMouse();
00484     for (i=0;i<8;i++)
00485      { 
00486       if (x>=27 && y>=(131+i*8) && x<=151 && y<=(137+i*8) && mousebuttons>0 && (now2-BarA+i)<=(count-1))
00487        { 
00488          
00489          now2-=BarA; now2+=i; BarA=i;
00490          RectFill(26,129,153,195,0);
00491          ShBox(26,130+BarA*8,152,138+BarA*8);
00492          DispLeft(plr,BarA,count,now2,&M[0]);
00493          WaitForMouseUp();
00494          
00495         }
00496      }  
00497       if (((x>=6 && y>=130 && x<=18 && y<=161 && mousebuttons>0) || key==UP_ARROW) && count>0)
00498        { // Up
00499          InBox(6,130,18,161);
00500          if (BarA==0)
00501           if (now2>0) {
00502            now2--;
00503            RectFill(26,129,153,195,0);
00504            ShBox(26,130+BarA*8,152,138+BarA*8);
00505            DispLeft(plr,BarA,count,now2,&M[0]);
00506           };
00507          if (BarA>0) {
00508           RectFill(26,129,153,195,0);
00509           BarA--;now2--;
00510           ShBox(26,130+BarA*8,152,138+BarA*8);
00511           DispLeft(plr,BarA,count,now2,&M[0]);
00512          };
00513         
00514        // WaitForMouseUp();
00515         OutBox(6,130,18,161);delay(10);
00516       }
00517     else 
00518     if (((mousebuttons>0 && x>=6 && y>=163 && x<=18 && y<=194) || key==DN_ARROW) && count>0)
00519      {  // Down 
00520        InBox(6,163,18,194);
00521        if (BarA==7)
00522         if (now2 < count-1) {
00523          now2++;
00524          RectFill(26,129,153,195,0);
00525          ShBox(26,130+BarA*8,152,138+BarA*8);
00526          DispLeft(plr,BarA,count,now2,&M[0]);
00527         };
00528        if (BarA<7)
00529         if (now2<count-1) {
00530          RectFill(26,129,153,195,0);
00531          BarA++;now2++;
00532          ShBox(26,130+BarA*8,152,138+BarA*8);
00533           DispLeft(plr,BarA,count,now2,&M[0]);
00534         };
00535        
00536       // WaitForMouseUp();
00537        OutBox(6,163,18,194);delay(10);
00538      };
00539    if ((mousebuttons>0 && x>=245 && y>=5 && x<=314 && y<=17) || key==K_ENTER)
00540     {
00541       InBox(245,5,314,17);
00542       WaitForMouseUp();
00543     music_stop();
00544       return;  /* Done */
00545     }; /* end x-y if */
00546   };  /* end while */
00547 };
00548 
00549 
00550 
00551 
00552 
00553 
00554 
00555 
00556 
00557 
00558 
00559 
00560 
00561 
00562 
00563 
00564 
00565 

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