prefs.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 "gamedata.h"
00027 #include "Buzz_inc.h"
00028 #include "externs.h"
00029 #include <assert.h>
00030 
00031 extern struct ManPool *Men;
00032 struct ManPool *Sov;
00033 char M_Us[106],M_Sv[106];
00034 extern char Option;
00035 
00036 void DrawPrefs(int where,char a1,char a2)
00037 {
00038   int i,mode=0;
00039   FILE *fin;
00040   
00041   FadeOut(2,pal,10,0,0);
00042   strcpy(IDT,"i013");strcpy(IKEY,"K013");
00043   fin=sOpen("PREFS.BUT","rb",0);
00044   fread(&pal[0],768,1,fin);
00045   i=fread((char *)screen,1,MAX_X*MAX_Y,fin);
00046   fclose(fin);
00047 
00048   RLED_img((char *)screen,vhptr.vptr,i,vhptr.w,vhptr.h);
00049 
00050   gxClearDisplay(0,0);
00051   ShBox(0,0,319,22);ShBox(0,24,89,199);
00052   ShBox(91,24,228,107);
00053   IOBox(98,28,137,63);IOBox(98,68,137,103);
00054   IOBox(144,28,221,63);
00055   /* This draws disabled button around camera */
00056   /* IOBox(144,68,221,103); */
00057   InBox(144,68,221,103);
00058 
00059   ShBox(91,109,228,199);InBox(95,113,224,195);RectFill(96,114,223,194,0);
00060   ShBox(230,24,319,199);
00061 
00062   if (where==2) where=mode=1; //modem klugge
00063    else if (where==3) where=mode=2; //play-by-mail
00064 
00065   if (where==0 || where==2) {
00066     music_start(M_SOVTYP);
00067     IOBox(6,105,83,140);IOBox(6,158,83,193);
00068     IOBox(236,105,313,140);IOBox(236,158,313,193);
00069     InBox(6,52,83,87);InBox(236,52,313,87);
00070     RectFill(7,53,82,86,0);RectFill(237,53,312,86,0);
00071     OutBox(8,77,18,85);OutBox(238,77,248,85);
00072     //BinT(8,54,0);BinT(238,54,0);  // Old way with buttons
00073     BinT(8,54,1);BinT(238,54,1);    // No select Buttons
00074     RectFill(237,35,312,41,0);RectFill(7,35,82,41,0);
00075   } else {
00076     music_start(M_DRUMSM);
00077     InBox(8,107,81,138);InBox(8,160,81,191);
00078     InBox(238,107,311,138);InBox(238,160,311,191);
00079       InBox(8,77,18,85);InBox(238,77,248,85);
00080     BinT(8,54,1);BinT(238,54,1);
00081     RectFill(237,35,312,41,0);RectFill(7,35,82,41,0);
00082   };
00083 
00084   if (mode==0) DispBig(6,5,"PREFERENCES SELECTIONS",0,-1);
00085    else if (mode==2) DispBig(3,5,"PLAY BY MAIL SELECTIONS",0,-1);
00086     else DispBig(6,5,"MODEM GAME SELECTIONS",0,-1);
00087 
00088   IOBox(243,3,316,19);
00089   InBox(236,34,313,42);
00090   InBox(6,34,83,42);
00091   PLevels(0,Data->Def.Plr1);CLevels(0,a1);
00092   PLevels(1,Data->Def.Plr2);CLevels(1,a2);
00093   Levels(0,Data->Def.Lev1,1);
00094   Levels(0,Data->Def.Ast1,0);
00095   Levels(1,Data->Def.Lev2,1);
00096   Levels(1,Data->Def.Ast2,0);
00097   if (where==0 || where==2) grSetColor(9);
00098     else grSetColor(34);
00099   PrintAt(23,30,"PLAYER 1");
00100   grSetColor(34);PrintAt(253,30,"PLAYER 2");
00101   grSetColor(5);
00102   PrintAt(20,49,"COUNTRY");PrintAt(250,49,"COUNTRY");
00103   PrintAt(17,101,"GAME LEVEL");PrintAt(247,101,"GAME LEVEL");
00104   PrintAt(250,148,"ASTRONAUT");PrintAt(250,155,"SELECTION");
00105   PrintAt(20,148,"ASTRONAUT");PrintAt(20,155,"SELECTION");
00106   grSetColor(1);PrintAt(258,13,"CONTINUE");
00107   PrintAt(8,40,&Data->P[ Data->Def.Plr1 ].Name[0]);
00108   PrintAt(238,40,&Data->P[ Data->Def.Plr2 ].Name[0]);
00109   gxVirtualDisplay(&vhptr,153+34*(Data->Def.Music),0,101,31,134,60,0);
00110   gxVirtualDisplay(&vhptr,221+34*(Data->Def.Sound),0,101,71,134,100,0);
00111 
00112   gxVirtualDisplay(&vhptr,216,30,147,31,218,60,0);
00113   gxVirtualDisplay(&vhptr,72*(Data->Def.Anim),90,147,71,218,100,0);
00114   HModel(Data->Def.Input,1);
00115 
00116   // if (where==0 || where==2) 
00117   FadeIn(2,pal,10,0,0);
00118   return;
00119 }
00120 
00121 void HModel(char mode,char tx)
00122 {
00123   unsigned int j,n;
00124     SimpleHdr table;
00125 
00126   GXHEADER local;
00127   FILE *in;
00128 
00129   in=sOpen("PRFX.BUT","rb",0);
00130   fseek(in,(mode==0 || mode==1)*sizeof_SimpleHdr,SEEK_CUR);
00131   fread_SimpleHdr(&table,1,in);
00132   fseek(in,table.offset,SEEK_SET);
00133   GV(&local,127,80);
00134   fread(&pal[112*3],96*3,1,in);  // Individual Palette
00135   fread(buffer,table.size,1,in);  // Get Image
00136   fclose(in);
00137 
00138   RLED_img(buffer,local.vptr,table.size, local.w, local.h);
00139   n = gxVirtualSize(gxVGA_13,127,80);
00140   for (j=0;j<n;j++) local.vptr[j]+=112;
00141   
00142   RectFill(96,114,223,194,0);
00143   if (tx==0) gxSetDisplayPalette(pal);
00144   gxPutImage(&local,gxSET,97,115,0);
00145   DV(&local);
00146   grSetColor(11);
00147   if (mode==2 || mode==3) PrintAt(100,122,"HISTORICAL MODEL");
00148   else PrintAt(100,122,"BASIC MODEL");
00149   grSetColor(9);
00150   if (mode==0 || mode==2) PrintAt(100,128,"HISTORICAL ROSTER");
00151   else PrintAt(100,128,"CUSTOM ROSTER");
00152   
00153   return;
00154 }
00155 
00156 
00157 void Levels(char plr,char which,char x)
00158 {
00159  unsigned char v[2][2]={{9,239}, {161,108}};
00160  
00161  gxVirtualDisplay(&vhptr,0+which*72,30+x*30,v[0][plr],v[1][x],v[0][plr]+71,v[1][x]+29,0);
00162  
00163  return;
00164 }
00165 
00166 void BinT(int x,int y,char st)
00167 {
00168   char sta[2][2]={{2,4},{4,2}};
00169   
00170   grSetColor(sta[st][0]);
00171   grMoveTo(0+x,y+20);grLineTo(0+x,y+0);grLineTo(72+x,y+0);
00172   grMoveTo(12+x,y+21);grLineTo(12+x,y+30);
00173   grSetColor(sta[st][1]);
00174   grMoveTo(0+x,y+21);grLineTo(11+x,y+21);
00175   grMoveTo(12+x,y+31);grLineTo(73+x,y+31);grLineTo(73+x,y+0);
00176   
00177   return;
00178 }
00179 
00180 void PLevels(char side,char wh)
00181 {
00182  
00183  if (side==0) {
00184    gxVirtualDisplay(&vhptr, 0+wh*72,     0,   9,  55,  20,  74,  0);
00185    gxVirtualDisplay(&vhptr, 0+wh*72+11,  0,  21,  55,  80,  84,  0);
00186  }
00187  else {
00188    gxVirtualDisplay(&vhptr, 0+wh*72,     0, 239,  55, 250,  74,  0);
00189    gxVirtualDisplay(&vhptr, 0+wh*72+11,  0, 250,  55, 310,  84,  0);
00190  }
00191  
00192  return;
00193 }
00194 
00195 void CLevels(char side,char wh)
00196 {
00197  
00198  if (side==0)
00199    gxVirtualDisplay(&vhptr,144,wh*7,9,78,17,84,0);
00200  else gxVirtualDisplay(&vhptr,144,wh*7,239,78,247,84,0);
00201  
00202  return;
00203 }
00204 
00205 
00206 /* Pref Levels:
00207   Player Select : 0 = USA
00208           1 = USSR
00209           2 = USA AI
00210           3 = USSR AI
00211           4 = FOREIGN (maybe)
00212           5 = FOREIGN AI (maybe)
00213 
00214        6 = USA (modem play)
00215        7 = USSR (modem play)
00216 
00217 
00218   Game Level:  0 = Easy
00219            1 = Medium
00220            2 = Hard
00221   Astro Level: 0 = Easy
00222            1 = Meduim
00223            2 = Hard
00224   Input:       0 = Mouse
00225            1 = Keyboard
00226            2 = Joystick (maybe)
00227   Anim Level:  0 = Full
00228            1 = Partial
00229            2 = Results Only
00230   Music Level: 0 = Full
00231            1 = Partial
00232            2 = None
00233   Sound FX:    0 = On
00234            1 = Off
00235   */
00236 
00237 void Prefs(int where)
00238 {
00239 int i,num,hum1=0,hum2=0;
00240 FILE *fin;
00241 char ch,Name[20],ksel=0;
00242 GXHEADER local2;
00243 long size;
00244 
00245  if (where!=3)
00246   {
00247    if (where==0)
00248     {
00249      plr[0]=0;plr[1]=1;
00250      Data->Def.Plr2=1;
00251      Data->Def.Plr1=0;
00252      hum1=0,hum2=1;
00253      Data->Def.Lev1=Data->Def.Ast1=Data->Def.Ast2=0;
00254      Data->Def.Lev2=2;  //start computer level 3
00255      Data->Def.Input=0;
00256      Data->Def.Sound=Data->Def.Music=1;
00257      MuteChannel(AV_ALL_CHANNELS, 0);
00258     }
00259    if (Data->Def.Plr1>1) {Data->Def.Plr1-=2;hum1=1;}
00260    if (Data->Def.Plr2>1) {Data->Def.Plr2-=2;hum2=1;}
00261   }
00262 
00263   /* Data->Def.Sound=Data->Def.Music=1; */
00264   DrawPrefs(where,hum1,hum2);
00265   WaitForMouseUp();
00266   while (1)
00267   {
00268     key=0;GetMouse();
00269     if (mousebuttons > 0 || key>0)  /* Game Play */
00270     {
00271       if (((x>=245 && y>=5 && x<=314 && y<=17) || key==K_ENTER) && !(hum1==1 && hum2==1))
00272       {
00273         InBox(245,5,314,17);
00274         WaitForMouseUp();
00275        if (key>0) delay(150); 
00276         OutBox(245,5,314,17);
00277         if (Data->Def.Plr1!=Data->Def.Plr2)
00278          {
00279            if (Data->Def.Plr1==1)
00280             {
00281               strcpy(&Name[0],&Data->P[0].Name[0]);
00282               strcpy(&Data->P[0].Name[0],&Data->P[1].Name[0]);
00283               strcpy(&Data->P[1].Name[0],&Name[0]);
00284               i=Data->Def.Lev1;Data->Def.Lev1=Data->Def.Lev2;Data->Def.Lev2=i;
00285               i=Data->Def.Ast1;Data->Def.Ast1=Data->Def.Ast2;Data->Def.Ast2=i;
00286              }
00287            Data->Def.Plr1+=hum1*2;
00288            Data->Def.Plr2+=hum2*2;
00289            if (where==0 || where==3) FadeOut(2,pal,10,0,0);
00290           key=0;
00291           if ((where==0 || where==3) && (Data->Def.Input==2 || Data->Def.Input==3))
00292             {
00293               fin=sOpen("HIST.DAT","rb",0);
00294               fread(&Data->P[0].Probe[0],28*(sizeof (Equipment)),1,fin);
00295               fread(&Data->P[1].Probe[0],28*(sizeof (Equipment)),1,fin);
00296               fclose(fin);
00297              }
00298            if (Data->Def.Input==0 || Data->Def.Input==2)
00299            { // Hist Crews
00300              fin=sOpen("CREW.DAT","rb",0);
00301             size=fread(buffer,1,BUFFER_SIZE,fin);
00302             fclose(fin);
00303              fin=sOpen("MEN.DAT","wb",1);
00304             fwrite(buffer,size,1,fin);
00305             fclose(fin);
00306             }
00307           else if (Data->Def.Input==1 || Data->Def.Input==3)
00308            { // User Crews
00309              fin=sOpen("USER.DAT","rb",0);
00310              size=fread(buffer,1,BUFFER_SIZE,fin);fclose(fin);
00311              fin=sOpen("MEN.DAT","wb",1);fwrite(buffer,size,1,fin);fclose(fin);
00312             }
00313          music_stop();
00314            return;
00315          };
00316       }
00317      else
00318       if (key=='P' && (where==0 || where==3))
00319         {
00320         RectFill(59,26,68,31,3);RectFill(290,26,298,31,3);
00321          if (ksel==0)
00322            {
00323             ksel=1;
00324             grSetColor(9);PrintAt(253,30,"PLAYER 2");
00325             grSetColor(34);PrintAt(23,30,"PLAYER 1");
00326             }
00327            else
00328             {
00329              ksel=0;
00330              grSetColor(34);PrintAt(253,30,"PLAYER 2");
00331              grSetColor(9);PrintAt(23,30,"PLAYER 1");
00332             }
00333         }
00334       else
00335       if ((x>=146 && y>=30 && x<=219 && y<=61 && mousebuttons>0) || key=='E')
00336        {
00337          InBox(146,30,219,61);
00338          WaitForMouseUp();
00339         if (key>0) delay(150);
00340          OutBox(146,30,219,61);
00341          GV(&local2,320,200);
00342          
00343          gxGetImage(&local2,0,0,319,199,0);
00344          
00345         music_stop();
00346         music_start(M_FILLER);
00347          EditAst();
00348        strcpy(IDT,"i013");strcpy(IKEY,"K013");
00349         music_stop();
00350         music_start((where==0 || where==3) ? M_SOVTYP : M_DRUMSM);
00351          
00352          gxPutImage(&local2,gxSET,0,0,0);
00353          
00354          DV(&local2);
00355          FadeIn(2,pal,10,0,0); 
00356          // Astronaut Changes
00357        }
00358       else
00359       if (((x>=96 && y>=114 && x<=223 && y<=194 && mousebuttons>0) || key==K_SPACE) && (where==3 || where==0))  // Hist
00360        {
00361          WaitForMouseUp();
00362          Data->Def.Input++;
00363         if (Data->Def.Input>3) Data->Def.Input=0;
00364          HModel(Data->Def.Input,0);
00365       }
00366       else
00367       if ((x>=146 && y>=70 && x<=219 && y<=101 && mousebuttons>0) || key=='A')
00368        {
00369            /* disable this option right now */
00370 #if 0
00371          InBox(146,70,219,101);
00372          WaitForMouseUp();
00373          Data->Def.Anim=abs(Data->Def.Anim-1);
00374          gxVirtualDisplay(&vhptr,72*(Data->Def.Anim),90,147,71,218,100,0);
00375          OutBox(146,70,219,101);
00376          /* Anim Level */
00377 #endif
00378        }
00379       else
00380       if ((x>=100 && y>=30 && x<=135 && y<=61 && mousebuttons>0) || key=='M')
00381        {
00382          InBox(100,30,135,61);
00383          WaitForMouseUp();
00384         Data->Def.Music = !Data->Def.Music;
00385         // SetMusicVolume((Data->Def.Music==1)?100:0);
00386                 music_set_mute(!Data->Def.Music);
00387         gxVirtualDisplay(&vhptr,153+34*(Data->Def.Music),0,101,31,134,60,0);
00388          OutBox(100,30,135,61);
00389          /* Music Level */
00390        }
00391       else
00392       if ((x>=100 && y>=70 && x<=135 && y<=101 && mousebuttons>0) || key=='S')
00393        {
00394          InBox(100,70,135,101);
00395          WaitForMouseUp();
00396         Data->Def.Sound = !Data->Def.Sound;
00397         MuteChannel(AV_SOUND_CHANNEL, !Data->Def.Sound);
00398         gxVirtualDisplay(&vhptr,221+34*(Data->Def.Sound),0,101,71,134,100,0);
00399          OutBox(100,70,135,101);
00400          /* Sound Level */
00401        }
00402 
00403 #if 0
00404       else
00405       if (((x>=8 && y>=54 && x<=19 && y<=75 && where==0) || (x>=20 && y>=54 && x<=81 && y<=85 && where==0)) 
00406            || (where==0 && ksel==0 && key=='C'))
00407        {
00408          BinT(8,54,1);
00409          WaitForMouseUp();
00410          Data->Def.Plr1++;
00411          if (Data->Def.Plr1>1) Data->Def.Plr1=0;
00412          PLevels(0,Data->Def.Plr1);BinT(8,54,0);
00413          /* Player 1 Select */
00414        }
00415 #endif
00416 
00417       else
00418       if ((x>=8 && y>=77 && x<=18 && y<=85 && where==0 && mousebuttons>0) ||
00419           (where==0 && ksel==0 && key=='H'))
00420        {
00421          InBox(8,77,18,85);
00422          WaitForMouseUp();
00423          hum1++; if (hum1>1) hum1=0;
00424          CLevels(0,hum1);
00425          OutBox(8,77,18,85);
00426          /* P1: Human/Computer */
00427        }
00428       else
00429       if ((x>=8 && y>=107 && x<=81 && y<=138 && (where==0 || where==3) && mousebuttons>0) ||
00430           ((where==3 || where==0) && ksel==0 && key=='G'))
00431        {
00432          InBox(8,107,81,138);
00433          WaitForMouseUp();
00434          OutBox(8,107,81,138);
00435          Data->Def.Lev1++;
00436          if (Data->Def.Lev1>2) Data->Def.Lev1=0;
00437          Levels(0,Data->Def.Lev1,1);
00438          /* P1: Game Level */
00439        }
00440       else
00441       if ((x>=8 && y>=160 && x<=81 && y<=191 && ((where==0 || where==3) && mousebuttons>0)) ||
00442           ((where==3 || where==0) && ksel==0 && key=='L'))
00443        {
00444          InBox(8,160,81,191);
00445          WaitForMouseUp();
00446          OutBox(8,160,81,191);
00447          Data->Def.Ast1++;
00448          if (Data->Def.Ast1>2) Data->Def.Ast1=0;
00449          Levels(0,Data->Def.Ast1,0);
00450          /* P1: Astro Level */
00451        }
00452 #if 0
00453       else
00454       if (((x>=238 && y>=54 && x<=249 && y<=75 && ((where==3 || where==0) && mousebuttons>0) || (x>=250 && y>=54 && x<=311 && y<=85 && where==0)) 
00455           || (where==0 && ksel==1 && key=='C'))
00456        {
00457          BinT(238,54,1);
00458          WaitForMouseUp();
00459          Data->Def.Plr2++;
00460          if (Data->Def.Plr2>1) Data->Def.Plr2=0;
00461          PLevels(1,Data->Def.Plr2);BinT(238,54,0);
00462          /* Player 2 Select */
00463        }
00464 #endif
00465       else
00466       if ((x>=238 && y>=77 && x<=248 && y<=85 && where==0 && mousebuttons>0) ||
00467           (where==0 && ksel==1 && key=='H'))
00468        {
00469          InBox(238,77,248,85);
00470          WaitForMouseUp();
00471          hum2++; if (hum2>1) hum2=0;
00472          CLevels(1,hum2);
00473          OutBox(238,77,248,85);
00474          /* P2:Human/Computer */
00475        }
00476       else
00477       if ((x>=238 && y>=107 && x<=311 && y<=138 && (where==0 || where==3) && mousebuttons>0) ||
00478           ((where==0 || where==3) && ksel==1 && key=='G'))
00479        {
00480          InBox(238,107,311,138);
00481          WaitForMouseUp();
00482          OutBox(238,107,311,138);
00483          Data->Def.Lev2++;
00484          if (Data->Def.Lev2>2) Data->Def.Lev2=0;
00485          Levels(1,Data->Def.Lev2,1);
00486          /* P2: Game Level */
00487        }
00488       else
00489       if ((x>=238 && y>=160 && x<=311 && y<=191 && (where==0 || where==3) && mousebuttons>0) ||
00490          ((where==0 || where==3) && ksel==1 && key=='L'))
00491       {
00492         InBox(238,160,311,191);
00493             WaitForMouseUp();
00494         OutBox(238,160,311,191);
00495         Data->Def.Ast2++;
00496         if (Data->Def.Ast2>2) Data->Def.Ast2=0;
00497         Levels(1,Data->Def.Ast2,0);
00498         /* P2: Astro Level */
00499       }
00500      else
00501      if ((x>=6 && y>=34 && x<=83 && y<=42 && (where==3 || where==0) && mousebuttons>0) ||
00502        ((where==3 || where==0) && ksel==0 && key=='N'))
00503       {
00504         RectFill(7,35,82,41,0);
00505         for (i=0;i<20;i++) Data->P[0].Name[i]=0x00;
00506         num=0;ch=0;
00507         grSetColor(1);grMoveTo(8,40);DispChr(0x14);
00508         while(ch!=K_ENTER)
00509         {
00510           ch=getch();
00511         if (ch!=(ch&0xff)) ch=0x00;
00512         if (ch>='a' && ch<='z') ch-=0x20;
00513           if (ch==0x08 && num>0) Data->P[0].Name[--num]=0x00;
00514           else if (num<12 && ( isupper(ch) || isdigit(ch) || ch==0x20))
00515            Data->P[0].Name[num++]=ch;
00516           RectFill(7,35,82,41,0);
00517           grSetColor(1);PrintAt(8,40,&Data->P[0].Name[0]);
00518           DispChr(0x14);
00519           av_sync ();
00520        }
00521        Data->P[0].Name[num]=0x00;
00522        RectFill(7,35,82,41,0);
00523        grSetColor(1);PrintAt(8,40,&Data->P[0].Name[0]);
00524        
00525        av_sync ();
00526        /* P1: Director Name */
00527      }
00528      else
00529       if ((x>=236 && y>=34 && x<=313 && y<=42 && (where==3 || where==0) && mousebuttons>0) ||
00530          ((where==3 || where==0) && ksel==1 && key=='N'))
00531       {
00532         RectFill(237,35,312,41,0);
00533         for (i=0;i<20;i++) Data->P[1].Name[i]=0x00;
00534         num=0;ch=0;
00535         grSetColor(1); grMoveTo(238,40);DispChr(0x14);
00536         while(ch!=K_ENTER) {
00537         ch=getch();
00538         if (ch!=(ch&0xff)) ch=0x00;
00539         if (ch>='a' && ch<='z') ch-=0x20;
00540           if (ch==0x08 && num>0) Data->P[1].Name[--num]=0x00;
00541           else if (num<12 && ( isupper(ch) || isdigit(ch) || ch==0x20))
00542            Data->P[1].Name[num++]=ch;
00543           RectFill(237,35,312,41,0);
00544           grSetColor(1);PrintAt(238,40,&Data->P[1].Name[0]);
00545           av_sync ();
00546        }
00547 
00548       Data->P[1].Name[num]=0x00;
00549       RectFill(237,35,312,41,0);
00550       grSetColor(1);PrintAt(238,40,&Data->P[1].Name[0]);
00551       
00552       av_sync ();
00553       /* P2: Director Name */
00554     };
00555    }
00556   };
00557 }
00558 
00559 void EditAst(void)
00560 {
00561  int now,now2,BarA,BarB,i;
00562  FILE *fin;
00563  char Cur,Cnt,temp,b;
00564  strcpy(IDT,"i040");strcpy(IKEY,"k040");
00565  FadeOut(2,pal,10,0,0);        
00566  
00567  gxClearDisplay(0,0);
00568  ShBox(0,0,319,22);;IOBox(243,3,316,19);
00569  grSetColor(1);PrintAt(258,13,"CONTINUE");
00570  DispBig(11,5,"NAME AND SKILL EDITOR",0,-1);
00571  ShBox(1,24,159,118);ShBox(161,24,319,118);
00572  InBox(40,28,149,42);InBox(200,28,309,42);
00573  InBox(6,27,33,43);OutBox(167,27,194,43);FlagSm(0,7,28);FlagSm(1,168,28);
00574  IOBox(25,47,155,115);RectFill(26,48,154,114,0);IOBox(5,47,21,115);
00575  IOBox(185,47,315,115);RectFill(186,48,314,114,0);IOBox(165,47,181,115);
00576  RectFill(6,48,20,81,0);RectFill(166,48,180,81,0);
00577  ShBox(7,49,19,80);ShBox(7,82,19,113);UPArrow(10,52);DNArrow(10,85);
00578  ShBox(167,49,179,80);ShBox(167,82,179,113);UPArrow(170,52);DNArrow(170,85);
00579  grSetColor(6);PrintAt(66,37,"ASTRONAUTS");grSetColor(9);PrintAt(227,37,"COSMONAUTS");
00580  ShBox(0,120,319,199);
00581  OutBox(60,125,197,195);RectFill(61,126,196,194,9);InBox(65,129,192,191);RectFill(66,130,191,190,3);
00582  OutBox(6,124,43,136);OutBox(6,139,43,151);OutBox(6,154,43,166);
00583  OutBox(6,169,43,181);OutBox(6,184,43,196);
00584  grSetColor(9);
00585  PrintAt(13,132,"CAP");PrintAt(13,147,"L.M.");         
00586  PrintAt(13,162,"EVA");PrintAt(13,177,"DOCK.");PrintAt(13,192,"ENDR.");             
00587  grSetColor(1);
00588  PrintAt(71,138,"NAME:");PrintAt(71,147,"SKILL:");
00589  PrintAt(94,155,"CAP");PrintAt(94,163,"L.M.");PrintAt(94,171,"EVA");PrintAt(94,179,"DOCK");   
00590  PrintAt(94,187,"ENDR.");
00591  ShBox(206,126,311,146);RectFill(207,127,310,145,6);InBox(209,129,308,143); 
00592  RectFill(210,130,307,142,3);
00593  now=now2=BarA=BarB=0;
00594  Cnt=Cur=0; // holds current change
00595  ShBox(27,49+BarA*8,153,57+BarA*8); ShBox(187,49+BarB*8,313,57+BarB*8);
00596  Men=(struct ManPool *) buffer;
00597  Sov=(struct ManPool *) buffer+106*sizeof(struct ManPool);
00598  assert(2 * 106 * sizeof(struct ManPool) < BUFFER_SIZE);
00599  FadeIn(2,pal,10,0,0);  
00600  
00601  temp=Help("i105");
00602  
00603  if (temp==1) fin = sOpen("CREW.DAT","rb",0);   /* Open Astronaut Data File  */
00604    else fin=sOpen("USER.DAT","rb",0);
00605  /* fseek(fin,((sizeof (struct ManPool))*106)*0,SEEK_SET); */
00606  fread(Men,(sizeof (struct ManPool))*106,1,fin);
00607  /* fseek(fin,((sizeof (struct ManPool))*106)*1,SEEK_SET); */
00608  fread(Sov,(sizeof (struct ManPool))*106,1,fin);
00609  fclose(fin);
00610 
00611  First(now,BarA);DrawStats(now,0);
00612  for (i=0;i<106;i++) M_Us[i]=0;
00613  for (i=0;i<106;i++) M_Sv[i]=0;
00614  for (i=0;i<106;i++) M_Us[i]=Men[i].Cap+Men[i].LM+Men[i].EVA+Men[i].Docking+Men[i].Endurance;
00615  for (i=0;i<106;i++) M_Sv[i]=Sov[i].Cap+Sov[i].LM+Sov[i].EVA+Sov[i].Docking+Sov[i].Endurance; 
00616  FadeIn(2,pal,10,0,0);
00617  
00618  WaitForMouseUp();
00619   while (1)
00620   {
00621     key=0;GetMouse();
00622     if (mousebuttons > 0 || key>0)  /* Game Play */
00623       {
00624        if ((x>=245 && y>=5 && x<=314 && y<=17) || key==K_ENTER)
00625      {
00626       InBox(245,5,314,17);
00627       WaitForMouseUp();
00628       temp=0;
00629       temp=Help("i106");
00630       if (temp==1)
00631       {
00632         fin=sOpen("USER.DAT","wb",1);
00633          fwrite(Men,(sizeof (struct ManPool))*106,1,fin);   
00634          fwrite(Sov,(sizeof (struct ManPool))*106,1,fin); 
00635          fclose(fin);
00636         }
00637      // delay(10);  
00638       OutBox(245,5,314,17);
00639       FadeOut(2,pal,10,0,0);       
00640       delay(10);
00641       return;
00642      }
00643     }
00644     if ((x>=6 && y>=27 && x<=33 && y<=43 && mousebuttons>0 && Cnt==1) || key=='U')
00645       {
00646         InBox(6,27,33,43);
00647         WaitForMouseUp();
00648         delay(10);
00649         RectFill(186,48,314,114,0);Cnt=0;DrawStats(now,Cnt);
00650         ShBox(27,49+BarA*8,153,57+BarA*8);First(now,BarA);
00651         OutBox(167,27,194,43);
00652       }
00653      if ((x>=167 && y>=27 && x<=194 && y<=43 && mousebuttons>0 && Cnt==0) || key=='S')
00654        {
00655          InBox(167,27,194,43);
00656          WaitForMouseUp();
00657          delay(10);RectFill(26,48,154,114,0);Cnt=1;DrawStats(now2,Cnt);
00658          ShBox(187,49+BarB*8,313,57+BarB*8);Second(now2,BarB);
00659          OutBox(6,27,33,43);
00660        }
00661      if (((x>=27 && y>=49+BarA*8 && x<=153 && y<=57+BarA*8 && mousebuttons>0) || key==K_SPACE) && Cnt==0)
00662        {
00663          
00664          ChangeStat(now,0,Cnt);  
00665          ShBox(27,49+BarA*8,153,57+BarA*8);     
00666          First(now,BarA);  
00667          
00668        }
00669      if (((x>=187 && y>=49+BarB*8 && x<=313 && y<=57+BarB*8 && mousebuttons>0) || key==K_SPACE) && Cnt==1)
00670        {
00671          
00672          ChangeStat(now2,0,Cnt);
00673          ShBox(187,49+BarB*8,313,57+BarB*8);   
00674          Second(now2,BarB);
00675          
00676        }
00677      if ((x>=6 && y>=124 && x<=43 && y<=136 && mousebuttons>0) || key=='C')
00678        {
00679         InBox(6,124,43,136);
00680         if (Cur>0) OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));Cur=1;
00681       grSetColor(11);PrintAt(13,132,"CAP");
00682       
00683         if (Cnt==0) ChangeStat(now,Cur,Cnt);
00684          else ChangeStat(now2,Cur,Cnt);
00685        if (Cnt==0) ShBox(27,49+BarA*8,153,57+BarA*8);   
00686          else ShBox(187,49+BarB*8,313,57+BarB*8);      
00687         if (Cnt==0) First(now,BarA);
00688          else Second(now2,BarB);
00689        OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));
00690         WaitForMouseUp();
00691         
00692       }
00693      if ((x>=6 && y>=139 && x<=43 && y<=151 && mousebuttons>0) || key=='L')
00694        {
00695         InBox(6,139,43,151);
00696         if (Cur>0) OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));Cur=2;
00697       grSetColor(11);PrintAt(13,147,"L.M.");
00698       
00699         if (Cnt==0) ChangeStat(now,Cur,Cnt);
00700          else ChangeStat(now2,Cur,Cnt);
00701        if (Cnt==0) ShBox(27,49+BarA*8,153,57+BarA*8);   
00702          else ShBox(187,49+BarB*8,313,57+BarB*8);      
00703         if (Cnt==0) First(now,BarA);
00704          else Second(now2,BarB);
00705         OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));
00706         WaitForMouseUp();
00707         
00708       }
00709      if ((x>=6 && y>=154 && x<=43 && y<=166 && mousebuttons>0) || key=='E')
00710        {
00711         InBox(6,154,43,166);
00712         if (Cur>0) OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));Cur=3;
00713       grSetColor(11);PrintAt(13,162,"EVA");
00714       
00715        if (Cnt==0) ChangeStat(now,Cur,Cnt);
00716          else ChangeStat(now2,Cur,Cnt);
00717        if (Cnt==0) ShBox(27,49+BarA*8,153,57+BarA*8);   
00718          else ShBox(187,49+BarB*8,313,57+BarB*8);      
00719         if (Cnt==0) First(now,BarA);
00720          else Second(now2,BarB);
00721         OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));
00722         WaitForMouseUp();
00723         
00724       }
00725      if ((x>=6 && y>=169 && x<=43 && y<=181 && mousebuttons>0) || key=='D')
00726        {
00727         InBox(6,169,43,181);
00728         if (Cur>0) OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));Cur=4;
00729       grSetColor(11);PrintAt(13,177,"DOCK.");
00730       
00731         if (Cnt==0) ChangeStat(now,Cur,Cnt);                           
00732          else ChangeStat(now2,Cur,Cnt);
00733        if (Cnt==0) ShBox(27,49+BarA*8,153,57+BarA*8);   
00734          else ShBox(187,49+BarB*8,313,57+BarB*8);      
00735         if (Cnt==0) First(now,BarA);
00736          else Second(now2,BarB);
00737         OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));
00738         WaitForMouseUp();
00739         
00740       }
00741      if ((x>=6 && y>=184 && x<=43 && y<=196 && mousebuttons>0) || key=='N')
00742        {
00743         InBox(6,184,43,196);
00744         if (Cur>0) OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));Cur=5;
00745       grSetColor(11);PrintAt(13,192,"ENDR.");
00746       
00747         if (Cnt==0) ChangeStat(now,Cur,Cnt);
00748          else ChangeStat(now2,Cur,Cnt);
00749        if (Cnt==0) ShBox(27,49+BarA*8,153,57+BarA*8);   
00750          else ShBox(187,49+BarB*8,313,57+BarB*8);      
00751         if (Cnt==0) First(now,BarA);
00752          else Second(now2,BarB);
00753         OutBox(6,124+((Cur-1)*15),43,136+((Cur-1)*15));
00754         WaitForMouseUp();
00755         
00756       }
00757       //US SIDE
00758       if (Cnt==0)
00759        {
00760         for(b=0;b<8;b++)
00761          {
00762           if (x>=27 && y>=(49+b*8) && x<=153 && y<=(57+b*8) && mousebuttons>0 && (now-BarA+b)<=105)
00763            {
00764             now-=BarA;now+=b;BarA=b;
00765             key=0;
00766             GetMouse();
00767              delay(10);
00768             
00769              if (BarA==0)
00770               if (now>=0)
00771               {
00772                 RectFill(26,48,154,114,0);
00773                 ShBox(27,49+BarA*8,153,57+BarA*8);
00774                 First(now,BarA);
00775                };
00776              if (BarA>0)
00777              {
00778                RectFill(26,48,154,114,0);
00779                ShBox(27,49+BarA*8,153,57+BarA*8);
00780                First(now,BarA);
00781               };
00782             WaitForMouseUp();
00783              DrawStats(now,0);
00784              
00785            }
00786          }
00787        }
00788       else if (Cnt==1)
00789        {
00790         for(b=0;b<8;b++)
00791          {
00792           if (x>=187 && y>=(49+b*8) && x<=314 && y<=(57+b*8) && mousebuttons>0 && (now2-BarB+b)<=105)
00793            {
00794             now2-=BarB;now2+=b;BarB=b;
00795             key=0;
00796             GetMouse();
00797              delay(10);
00798             
00799              if (BarB==0)
00800              if (now2>=0)
00801              {
00802                RectFill(186,48,314,114,0);
00803                ShBox(187,49+BarB*8,313,57+BarB*8);
00804                Second(now2,BarB);
00805               };
00806              if (BarB>0)
00807              {
00808                RectFill(186,48,314,114,0);
00809                ShBox(187,49+BarB*8,313,57+BarB*8);
00810                Second(now2,BarB);
00811              };
00812            WaitForMouseUp();
00813             DrawStats(now2,1);
00814             
00815           }
00816         }
00817        }
00818 
00819       if (((x>=7 && y>=49 && x<=19 && y<=80 && mousebuttons>0) || key==UP_ARROW) && Cnt==0)
00820         { /* Lft Up */
00821           InBox(7,49,19,80);
00822          for (i=0;i<50;i++)
00823           {
00824             key=0;
00825             GetMouse();
00826             delay(10);
00827             if (mousebuttons==0) {
00828             
00829           if (BarA==0)
00830            if (now>0)
00831            {
00832              now--;
00833              RectFill(26,48,154,114,0);
00834              ShBox(27,49+BarA*8,153,57+BarA*8);
00835              First(now,BarA);
00836             };
00837           if (BarA>0)
00838            {
00839              RectFill(26,48,154,114,0);
00840              BarA--;now--;
00841              ShBox(27,49+BarA*8,153,57+BarA*8);
00842              First(now,BarA);
00843             };
00844           DrawStats(now,0);
00845           
00846          i=51;
00847         }
00848        }
00849       while (mousebuttons==1 || key==UP_ARROW)
00850        {
00851         delay(100);
00852         
00853           if (BarA==0)
00854            if (now>0)
00855            {
00856              now--;
00857              RectFill(26,48,154,114,0);
00858              ShBox(27,49+BarA*8,153,57+BarA*8);
00859              First(now,BarA);
00860             };
00861           if (BarA>0)
00862            {
00863              RectFill(26,48,154,114,0);
00864              BarA--;now--;
00865              ShBox(27,49+BarA*8,153,57+BarA*8);
00866              First(now,BarA);
00867             };
00868           DrawStats(now,0);
00869           
00870          key=0;
00871          GetMouse();
00872          }
00873           //WaitForMouseUp();
00874           OutBox(7,49,19,80);delay(10);
00875         }
00876       if (((x>=7 && y>=82 && x<=19 && y<=113 && mousebuttons>0) || key==DN_ARROW) && Cnt==0)
00877         { /* Lft Dwn */
00878           InBox(7,82,19,113);
00879          for (i=0;i<50;i++)
00880           {
00881             key=0;
00882             GetMouse();
00883             delay(10);
00884             if (mousebuttons==0) {
00885            
00886              if (BarA==7)
00887              if (now < 105)
00888              {
00889                now++;
00890                RectFill(26,48,154,114,0);
00891                ShBox(27,49+BarA*8,153,57+BarA*8);
00892                First(now,BarA);
00893              };
00894             if (BarA<7)
00895             if (now<105)
00896             {
00897               RectFill(26,48,154,114,0);
00898               BarA++;now++;
00899                ShBox(27,49+BarA*8,153,57+BarA*8);
00900               First(now,BarA);
00901              };
00902             DrawStats(now,0);
00903           
00904         i=51;
00905         }
00906        }
00907       while (mousebuttons==1 || key==DN_ARROW)
00908        {
00909         delay(100);
00910         
00911          if (BarA==7)
00912           if (now < 105)
00913           {
00914             now++;
00915             RectFill(26,48,154,114,0);
00916             ShBox(27,49+BarA*8,153,57+BarA*8);
00917             First(now,BarA);
00918            };
00919          if (BarA<7)
00920           if (now<105)
00921           {
00922             RectFill(26,48,154,114,0);
00923             BarA++;now++;
00924              ShBox(27,49+BarA*8,153,57+BarA*8);
00925             First(now,BarA);
00926            };
00927           DrawStats(now,0);
00928           
00929          key=0;
00930          GetMouse();
00931          }
00932           //WaitForMouseUp();
00933           OutBox(7,82,19,113);delay(10);
00934         };
00935       if (((x>=167 && y>=49 && x<=179 && y<=80 && mousebuttons>0) || key==UP_ARROW) && Cnt==1)
00936         { /* Rt Up */
00937           InBox(167,49,179,80);
00938          for (i=0;i<50;i++)
00939           {
00940             key=0;
00941             GetMouse();
00942             delay(10);
00943             if (mousebuttons==0) {
00944             
00945              if (BarB==0)
00946               if (now2 > 0)
00947               {
00948                 now2--;
00949                 RectFill(186,48,314,114,0);
00950                 ShBox(187,49+BarB*8,313,57+BarB*8);
00951                 Second(now2,BarB);
00952                };
00953              if (BarB>0)
00954              {
00955                RectFill(186,48,314,114,0);
00956                BarB--;now2--;
00957                ShBox(187,49+BarB*8,313,57+BarB*8);
00958                Second(now2,BarB);
00959               };
00960              DrawStats(now2,1);
00961              
00962             i=51;
00963           }
00964          }
00965       while (mousebuttons==1 || key==UP_ARROW)
00966        {
00967         delay(100);
00968         
00969           if (BarB==0)
00970           if (now2 > 0)
00971            {
00972              now2--;
00973              RectFill(186,48,314,114,0);
00974              ShBox(187,49+BarB*8,313,57+BarB*8);
00975              Second(now2,BarB);
00976             };
00977           if (BarB>0)
00978            {
00979              RectFill(186,48,314,114,0);
00980              BarB--;now2--;
00981              ShBox(187,49+BarB*8,313,57+BarB*8);
00982              Second(now2,BarB);
00983             };
00984           DrawStats(now2,1);
00985           
00986          key=0;
00987          GetMouse();
00988         }
00989          //WaitForMouseUp();
00990          OutBox(167,49,179,80);delay(10);
00991         };
00992       if (((x>=167 && y>=82 && x<=179 && y<=113 && mousebuttons>0) || key==DN_ARROW) && Cnt==1)
00993         { /* Rt Dwn */
00994           InBox(167,82,179,113);
00995          for (i=0;i<50;i++)
00996           {
00997             key=0;
00998             GetMouse();
00999             delay(10);
01000             if (mousebuttons==0) {
01001            
01002             if (BarB==7)
01003              if (now2 < 105)
01004              {
01005                 now2++;
01006                 RectFill(186,48,314,114,0);
01007                 ShBox(187,49+BarB*8,313,57+BarB*8);
01008                 Second(now2,BarB);
01009               };
01010             if (BarB<7)
01011               if (now2<105)
01012              {
01013                RectFill(186,48,314,114,0);
01014                BarB++;now2++;
01015                ShBox(187,49+BarB*8,313,57+BarB*8);
01016                Second(now2,BarB);
01017               };
01018             DrawStats(now2,1);
01019             
01020            i=51;
01021          }
01022        }
01023       while (mousebuttons==1 || key==DN_ARROW)
01024        {
01025         delay(100);
01026         
01027          if (BarB==7)
01028           if (now2 < 105)
01029           {
01030              now2++;
01031              RectFill(186,48,314,114,0);
01032              ShBox(187,49+BarB*8,313,57+BarB*8);
01033              Second(now2,BarB);
01034            };
01035           if (BarB<7)
01036            if (now2<105)
01037            {
01038              RectFill(186,48,314,114,0);
01039              BarB++;now2++;
01040              ShBox(187,49+BarB*8,313,57+BarB*8);
01041              Second(now2,BarB);
01042             };
01043           DrawStats(now2,1);
01044           
01045         key=0;
01046         GetMouse();
01047        }
01048         //WaitForMouseUp();
01049         OutBox(167,82,179,113);delay(10);
01050        };
01051   }
01052 }
01053 
01054 void
01055 ChangeStat(char mum, char Cur, char Cnt)    // Cur holds current setting
01056 {
01057     char tot, srt = 0, max, i, mxc, Save_Name[14];
01058 
01059     memset(Save_Name, 0x00, sizeof Save_Name);
01060     RectFill(210, 130, 307, 142, 3);
01061     RectFill(205, 151, 316, 196, 3);
01062     grSetColor(6);
01063     if (Cur == 0)
01064     {
01065         PrintAt(231, 138, "NAME CHANGE");
01066         InBox(209, 155, 308, 169);
01067         RectFill(210, 156, 307, 168, 0);
01068         if (Cnt == 0)
01069         {
01070             strcpy(Save_Name, Men[mum].Name);
01071             memset(Men[mum].Name, 0x00, sizeof Men[mum].Name);
01072         }
01073         else if (Cnt == 1)
01074         {
01075             strcpy(Save_Name, Sov[mum].Name);
01076             memset(Sov[mum].Name, 0x00, sizeof Sov[mum].Name);
01077         }
01078         grSetColor(1);
01079         grMoveTo(215, 165);
01080         key = 0;
01081         i = 0;
01082 
01083         while (!(key == K_ENTER || key == K_ESCAPE))
01084         {
01085             gr_maybe_sync();
01086             key = getch();
01087             if (key >= 'a' && key <= 'z')
01088                 key = toupper(key);
01089             if (key & 0x00ff)
01090             {
01091                 if ((i < 13) && ((key == ' ') || ((key >= 'A' && key <= 'Z'))
01092                         || (key >= '0' && key <= '9')))
01093                 {                  // valid key
01094                     if (Cnt == 0)
01095                     {
01096                         Men[mum].Name[i++] = key;
01097                         grSetColor(1);
01098                         PrintAt(215, 165, &Men[mum].Name[0]);
01099                     }
01100                     else
01101                     {
01102                         Sov[mum].Name[i++] = key;
01103                         grSetColor(1);
01104                         PrintAt(215, 165, &Sov[mum].Name[0]);
01105                     }
01106                     key = 0;
01107                 }
01108                 if (i > 0 && key == 0x08)
01109                 {
01110                     if (Cnt == 0)
01111                         Men[mum].Name[--i] = 0x00;
01112                     else
01113                         Sov[mum].Name[--i] = 0x00;
01114                     RectFill(210, 156, 307, 168, 0);
01115                     grSetColor(1);
01116                     if (Cnt == 0)
01117                         PrintAt(215, 165, &Men[mum].Name[0]);
01118                     else
01119                         PrintAt(215, 165, &Sov[mum].Name[0]);
01120                     key = 0;
01121                 }
01122                 if (key == K_ESCAPE)
01123                 {
01124                     if (Cnt == 0)
01125                         memset(Men[mum].Name, 0x00, sizeof Men[mum].Name);
01126                     else
01127                         memset(Sov[mum].Name, 0x00, sizeof Sov[mum].Name);
01128                     i = 0;
01129                     RectFill(210, 156, 307, 168, 0);
01130                     grSetColor(1);
01131                     if (Cnt == 0)
01132                         PrintAt(215, 165, &Men[mum].Name[0]);
01133                     else
01134                         PrintAt(215, 165, &Sov[mum].Name[0]);
01135                     key = 0;
01136                 }
01137 
01138             }
01139         }
01140         if (i == 0)
01141         {
01142             if (Cnt == 0)
01143                 strcpy(Men[mum].Name, Save_Name);
01144             else
01145                 strcpy(Sov[mum].Name, Save_Name);
01146         }
01147         DrawStats(mum, Cnt);
01148         RectFill(210, 156, 307, 168, 0);
01149         RectFill(210, 130, 307, 142, 3);
01150         RectFill(205, 151, 316, 196, 3);
01151 
01152         return;
01153     }
01154     else if (Cur >= 1 && Cur <= 5)
01155     {
01156         grSetColor(9);
01157         PrintAt(228, 138, "SKILL CHANGE");
01158         tot = 0;
01159         if (Cur != 1)
01160         {
01161             if (Cnt == 0)
01162                 tot += Men[mum].Cap;
01163             else
01164                 tot += Sov[mum].Cap;
01165         }
01166         if (Cur != 2)
01167         {
01168             if (Cnt == 0)
01169                 tot += Men[mum].LM;
01170             else
01171                 tot += Sov[mum].LM;
01172         }
01173         if (Cur != 3)
01174         {
01175             if (Cnt == 0)
01176                 tot += Men[mum].EVA;
01177             else
01178                 tot += Sov[mum].EVA;
01179         }
01180         if (Cur != 4)
01181         {
01182             if (Cnt == 0)
01183                 tot += Men[mum].Docking;
01184             else
01185                 tot += Sov[mum].Docking;
01186         }
01187         if (Cur != 5)
01188         {
01189             if (Cnt == 0)
01190                 tot += Men[mum].Endurance;
01191             else
01192                 tot += Sov[mum].Endurance;
01193         }
01194         switch (Cur)
01195         {
01196             case 1:
01197                 if (Cnt == 0)
01198                     srt = Men[mum].Cap;
01199                 else
01200                     srt = Sov[mum].Cap;
01201                 break;
01202             case 2:
01203                 if (Cnt == 0)
01204                     srt = Men[mum].LM;
01205                 else
01206                     srt = Sov[mum].LM;
01207                 break;
01208             case 3:
01209                 if (Cnt == 0)
01210                     srt = Men[mum].EVA;
01211                 else
01212                     srt = Sov[mum].EVA;
01213                 break;
01214             case 4:
01215                 if (Cnt == 0)
01216                     srt = Men[mum].Docking;
01217                 else
01218                     srt = Sov[mum].Docking;
01219                 break;
01220             case 5:
01221                 if (Cnt == 0)
01222                     srt = Men[mum].Endurance;
01223                 else
01224                     srt = Sov[mum].Endurance;
01225                 break;
01226             default:
01227                 break;
01228         }
01229         mxc = 0;
01230         if (Cnt == 0)
01231             mxc = M_Us[mum];
01232         else
01233             mxc = M_Sv[mum];
01234         tot = mxc - tot;
01235         InBox(209, 151, 241, 161);
01236         InBox(247, 151, 270, 161);
01237         InBox(276, 151, 308, 161);
01238         RectFill(248, 152, 269, 160, 0);
01239         grSetColor(9);
01240         PrintAt(214, 158, "MIN 0");
01241         PrintAt(281, 158, "MAX");
01242         if (strcmp(Men[97].Name, "VON BRAUN") == 0)
01243             tot = 4;
01244         if (tot >= 4)
01245             tot = 4;
01246         DispNum(302, 158, tot);
01247         max = tot;
01248         grSetColor(1);
01249         DispNum(256, 158, srt);
01250         // plus minus goes here
01251         IOBox(210, 166, 253, 178);
01252         IOBox(265, 166, 308, 178);
01253         IOBox(247, 181, 278, 193);
01254         grSetColor(1);
01255         PrintAt(222, 174, "PLUS");
01256         PrintAt(273, 174, "MINUS");
01257         PrintAt(252, 189, "DONE");
01258         WaitForMouseUp();
01259         while (1)
01260         {
01261             key = 0;
01262             GetMouse();
01263             if ((x >= 212 && y >= 168 && x <= 251 && y <= 176 && srt < max
01264                     && mousebuttons > 0) || (key == '+' && srt < max))
01265             {
01266                 InBox(212, 168, 251, 176);
01267                 ++srt;
01268                 RectFill(248, 152, 269, 160, 0);
01269                 grSetColor(1);
01270                 DispNum(256, 158, srt);
01271                 delay(10);
01272                 WaitForMouseUp();
01273                 OutBox(212, 168, 251, 176);
01274             }
01275             if ((x >= 267 && y >= 168 && x <= 306 && y <= 176 && srt >= 1
01276                     && mousebuttons > 0) || (key == '-' && srt >= 1))
01277             {
01278                 InBox(267, 168, 306, 176);
01279                 --srt;
01280                 RectFill(248, 152, 269, 160, 0);
01281                 grSetColor(1);
01282                 DispNum(256, 158, srt);
01283                 delay(10);
01284                 WaitForMouseUp();
01285                 OutBox(267, 168, 306, 176);
01286             }
01287             if ((x >= 249 && y >= 183 && x <= 276 && y <= 191
01288                     && mousebuttons > 0) || key == K_ENTER)
01289             {
01290                 InBox(249, 183, 276, 191);
01291 
01292                 switch (Cur)
01293                 {
01294                     case 1:
01295                         if (Cnt == 0)
01296                             Men[mum].Cap = srt;
01297                         else
01298                             Sov[mum].Cap = srt;
01299                         break;
01300                     case 2:
01301                         if (Cnt == 0)
01302                             Men[mum].LM = srt;
01303                         else
01304                             Sov[mum].LM = srt;
01305                         break;
01306                     case 3:
01307                         if (Cnt == 0)
01308                             Men[mum].EVA = srt;
01309                         else
01310                             Sov[mum].EVA = srt;
01311                         break;
01312                     case 4:
01313                         if (Cnt == 0)
01314                             Men[mum].Docking = srt;
01315                         else
01316                             Sov[mum].Docking = srt;
01317                         break;
01318                     case 5:
01319                         if (Cnt == 0)
01320                             Men[mum].Endurance = srt;
01321                         else
01322                             Sov[mum].Endurance = srt;
01323                         break;
01324                     default:
01325                         break;
01326                 }
01327                 DrawStats(mum, Cnt);
01328 
01329                 WaitForMouseUp();
01330                 OutBox(249, 183, 276, 191);
01331                 RectFill(210, 156, 307, 168, 0);
01332                 RectFill(210, 130, 307, 142, 3);
01333                 RectFill(205, 151, 316, 196, 3);
01334                 grSetColor(9);
01335                 PrintAt(13, 132, "CAP");
01336                 PrintAt(13, 147, "L.M.");
01337                 PrintAt(13, 162, "EVA");
01338                 PrintAt(13, 177, "DOCK.");
01339                 PrintAt(13, 192, "ENDR.");
01340 
01341                 return;
01342             }
01343         }
01344     }                              // end else-if
01345     return;
01346 }
01347 
01348 void DrawStats(char mum,char chce)
01349 {
01350  RectFill(100,133,186,141,3);RectFill(122,151,186,190,3); 
01351  grSetColor(6);
01352  if (chce==0) 
01353    {
01354     PrintAt(100,138,&Men[mum].Name[0]);
01355     grSetColor(11);
01356     DispNum(124,155,Men[mum].Cap);
01357     DispNum(124,163,Men[mum].LM);  
01358     DispNum(124,171,Men[mum].EVA);  
01359     DispNum(124,179,Men[mum].Docking);  
01360     DispNum(124,187,Men[mum].Endurance);
01361    }
01362    else 
01363      {
01364       PrintAt(100,138,&Sov[mum].Name[0]);
01365       grSetColor(11);
01366       DispNum(124,155,Sov[mum].Cap);
01367       DispNum(124,163,Sov[mum].LM);  
01368       DispNum(124,171,Sov[mum].EVA);  
01369       DispNum(124,179,Sov[mum].Docking);  
01370       DispNum(124,187,Sov[mum].Endurance);
01371      }
01372  return;
01373 }
01374 
01375 void First(char now,char loc)
01376 {
01377   int i,start;
01378   start=now-loc;
01379   for (i=start;i<start+8;i++) {
01380     grSetColor(1);
01381     DispNum(32,55+(i-start)*8,i);
01382    if (Men[i].Sex==0) grSetColor(1);
01383     else grSetColor(8);
01384     PrintAt(52,55+(i-start)*8,&Men[i].Name[0]);
01385   };
01386   return;
01387 }
01388 
01389 void Second(int nw,int lc)
01390 {
01391   int i,start;
01392   start=nw-lc;
01393   for (i=start;i<start+8;i++) {
01394     grSetColor(1);
01395     DispNum(190,55+(i-start)*8,i);
01396    if (Men[i].Sex==0) grSetColor(1);
01397     else grSetColor(8);
01398     PrintAt(210,55+(i-start)*8,&Sov[i].Name[0]);
01399   };
01400   return;
01401 }
01402 

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