ast0.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 
00030 char MCol[110],sel[25],MaxSel;
00031 
00032 void Moon(char plr)
00033 {
00034   int val;
00035     SimpleHdr table;
00036   FILE *in;
00037   GXHEADER local;
00038   long size;
00039   strcpy(IDT,"i029");strcpy(IKEY,"k029");
00040   val=Data->P[plr].Misc[5].Safety;
00041   FadeOut(2,pal,0,0,0);
00042 
00043   
00044   gxClearDisplay(0,0);
00045   ShBox(109,24,222,167);
00046   InBox(113,27,218,39);RectFill(114,28,217,38,7+3*plr);
00047   InBox(113,130,218,146);RectFill(114,131,217,145,7+3*other(plr));
00048   IOBox(113,150,218,164);
00049 
00050   size=(int) ((val-55)/3);
00051   if (size>13) size=13;
00052 
00053   in=sOpen("MOON.BUT","rb",0);
00054   fseek(in,sizeof_SimpleHdr * plr,SEEK_SET);
00055   fread_SimpleHdr(&table,1,in);
00056   fseek(in,table.offset,SEEK_SET);
00057   GV(&local,104,82);
00058   fread(&pal[384],384,1,in);  // Individual Palette
00059   fread(buffer,table.size,1,in);  // Get Image
00060   fclose(in);
00061   RLED_img(buffer,local.vptr,table.size,local.w,local.h);
00062   for (size=0;size<(104*82);size++) local.vptr[size]+=128;
00063   gxPutImage(&local,gxSET,114,43,0);
00064   DV(&local);
00065   InBox(113,42,218,125);
00066   ShBox(113,42,143,60);RectFill(113,42,142,59,3);InBox(113,42,140,58);  
00067   grSetColor(11);
00068   PrintAt(117,35,"PHOTO RECON.");
00069   PrintAt(118,137,"CURRENT RECON ");
00070   PrintAt(118,143,"LEVEL IS AT ");
00071   DispNum(0,0,val);PrintAt(0,0,"%");
00072   grSetColor(1);PrintAt(144,159,"CONTINUE");
00073   FlagSm(plr,114,43);
00074   
00075   music_start(M_HISTORY);
00076   FadeIn(2,pal,0,0,0);
00077   WaitForMouseUp();
00078   while (1)
00079   {
00080     key=0;GetMouse();
00081      if ((x>=115 && y>=152 && x<=216 && y<=162 && mousebuttons>0) || key==K_ENTER) {
00082        InBox(115,152,216,162);
00083        WaitForMouseUp();
00084        if (key>0) delay(150);
00085       music_stop();
00086        key=0;return; // Continue
00087       }
00088   }
00089 }
00090 
00091 
00092 
00093 void DispLeft(char plr,int lc,int cnt,int nw,int *ary)
00094 {
00095   int i,start,num;
00096 
00097   start=nw-lc;
00098   if (cnt<8) num=cnt; else num=8;
00099   grSetColor(11);
00100   for (i=start;i<start+num;i++) {
00101     if (ary[i]>=0) {
00102         grSetColor(11+Data->P[plr].Pool[ary[i]].Sex);
00103         PrintAt(28,136+(i-start)*8,&Data->P[plr].Pool[ary[i]].Name[0]);
00104     }
00105   }
00106   return;
00107 }
00108 
00109 void BarSkill(char plr,int lc,int nw,int *ary)
00110 {
00111   grSetColor(11);
00112   grMoveTo(28,136+lc*8);
00113   // CA LM EV DO EN
00114   PrintAt(0,0,"CA:");DispNum(0,0,Data->P[plr].Pool[ary[nw]].Cap);
00115   PrintAt(0,0," LM:");DispNum(0,0,Data->P[plr].Pool[ary[nw]].LM);
00116   PrintAt(0,0," EV:");DispNum(0,0,Data->P[plr].Pool[ary[nw]].EVA);
00117   PrintAt(0,0," DO:");DispNum(0,0,Data->P[plr].Pool[ary[nw]].Docking);
00118   PrintAt(0,0," EN:");DispNum(0,0,Data->P[plr].Pool[ary[nw]].Endurance);
00119   return;
00120 }
00121 
00122 
00123 void SatDraw(char plr)
00124 {
00125     PatchHdrSmall P;
00126   int i,loc[4];
00127   FILE *fin;
00128 
00129   GXHEADER local;
00130   FadeOut(2,pal,0,0,0);
00131   
00132   gxClearDisplay(0,0);
00133   ShBox(1,0,319,22);IOBox(243,3,316,19);InBox(4,3,31,19);
00134 
00135   for (i=0;i<4;i++) {
00136    ShBox(1+i*80,24,79+i*80,71);ShBox(1+i*80,73,79+i*80,199);
00137    if (i==2) {
00138       InBox(4+i*80,27,76+i*80,56);
00139       RectFill(5+i*80,28,75+i*80,55,0);
00140       InBox(164,58,236,68); RectFill(165,59,235,67,0);
00141       ShBox(166,60,199,66);ShBox(201,60,234,66);
00142       }
00143    else {
00144       InBox(4+i*80,27,76+i*80,68);
00145       RectFill(5+i*80,28,75+i*80,67,7);
00146       }
00147    }
00148 
00149   loc[0]=(Data->P[plr].Misc[4].Num<0) ? 0 : 1+plr*3;
00150   loc[1]=(Data->P[plr].Probe[0].Num<0) ? 0 : 2+plr*3;
00151   loc[2]=(Data->P[plr].Probe[1].Num<0) ? 0 : 0;
00152   loc[3]=(Data->P[plr].Probe[2].Num<0) ? 0 : 3+plr*3;
00153 
00154   fin=sOpen("SATBLD.BUT","rb",0);
00155   fread(&pal[0],768,1,fin);
00156 
00157   for (i=0;i<4;i++) {
00158    
00159    fseek(fin,(sizeof P)*loc[i]+768,SEEK_SET);
00160    fread(&P,sizeof P,1,fin);
00161     SwapPatchHdrSmall(&P);
00162    GV(&local,P.w,P.h);
00163    fseek(fin,P.offset,SEEK_SET);
00164    fread(buffer,P.size,1,fin);
00165    RLED_img(buffer,local.vptr,P.size,local.w,local.h);
00166    if (i!=2) gxPutImage(&local,gxSET,5+i*80,28,0);
00167    else gxVirtualDisplay(&local,0,0,5+i*80,28,75+i*80,55,0);
00168    DV(&local);
00169    }
00170   fclose(fin);
00171 
00172   FlagSm(plr,5,4);
00173   grSetColor(11);
00174   grMoveTo(180,63);grLineTo(184,63);
00175   grMoveTo(215,63);grLineTo(219,63);
00176   grMoveTo(217,61);grLineTo(217,65);
00177   DispBig(40,5,"SATELLITE BUILDING",0,-1);
00178   grSetColor(1);
00179   PrintAt(258,13,"CONTINUE");
00180   
00181   return;
00182 }
00183 
00184 
00185 void LMDraw(char plr)
00186 {
00187   char ind=0;
00188   FadeOut(2,pal,0,0,0);
00189   
00190   gxClearDisplay(0,0);
00191   ShBox(1,0,319,22);IOBox(243,3,316,19);InBox(4,3,31,19);
00192   ShBox(1,24,319,118);InBox(4,26,316,116);RectFill(5,27,315,115,0); // middle screen
00193   if (Data->P[plr].Manned[6].Num>=0) ind=4+plr; else ind=0+plr;
00194   LMPict(ind);ind=0;
00195   if (Data->P[plr].Manned[5].Num>=0) ind=6+plr; else ind=2+plr;
00196   LMPict(ind);
00197   ShBox(110,24,203,36);InBox(112,26,201,34);grSetColor(1);PrintAt(117,32,"CENTRAL HANGAR");
00198   FlagSm(plr,5,4);
00199   DispBig(40,5,"LUNAR MODULE",0,-1);
00200   grSetColor(1);PrintAt(258,13,"CONTINUE");
00201   
00202   return;
00203 }
00204 
00205 void SatText(char plr)
00206 {
00207    int i;
00208    
00209    grSetColor(11);
00210    for (i=0;i<4;i++) {
00211       if (i!=2) {
00212      grSetColor(11);
00213      switch(i) {
00214         case 0: PrintAt(5+i*80,80,"DOCKING");
00215 
00216             if (Data->P[plr].Misc[4].Num>=0)
00217                DispNum(5+i*80,110,Data->P[plr].Misc[4].Safety);
00218                     else DispNum(5+i*80,110,0);
00219             PrintAt(0,0,"%");
00220 
00221             DispNum(5+i*80,127,Data->P[plr].Misc[4].Steps);
00222 
00223             DispNum(5+i*80,144,Data->P[plr].Misc[4].Steps-Data->P[plr].Misc[4].Failures);
00224 
00225             if (Data->P[plr].Misc[4].Steps > 0) DispNum(5+i*80,161,100*(Data->P[plr].Misc[4].Steps-Data->P[plr].Misc[4].Failures)/Data->P[plr].Misc[4].Steps);
00226             else DispNum(5+i*80,161,0);
00227 
00228             if (Data->Prestige[24].Place==0) PrintAt(5+i*80,178,"U.S.");
00229             else if (Data->Prestige[24].Place==1) PrintAt(5+i*80,178,"SOVIET");
00230             else PrintAt(5+i*80,178,"NONE");
00231 
00232             DispNum(5+i*80,195,Data->Prestige[24].Points[plr]);
00233             break;
00234 
00235         case 1: PrintAt(5+i*80,80,"ORBITAL SAT");
00236 
00237                     if (Data->P[plr].Probe[0].Num>=0)
00238                DispNum(5+i*80,110,Data->P[plr].Probe[0].Safety);
00239             else DispNum(5+i*80,110,0);
00240             PrintAt(0,0,"%");
00241            
00242             DispNum(5+i*80,127,Data->P[plr].Probe[0].Used);
00243 
00244             DispNum(5+i*80,144,Data->P[plr].Probe[0].Used-Data->P[plr].Probe[0].Failures);
00245 
00246             if (Data->P[plr].Probe[0].Used > 0) DispNum(5+i*80,161,100*(Data->P[plr].Probe[0].Used-Data->P[plr].Probe[0].Failures)/Data->P[plr].Probe[0].Used);
00247             else DispNum(5+i*80,161,0);
00248 
00249             if (Data->Prestige[0].Place==0) PrintAt(5+i*80,178,"U.S.");
00250             else if (Data->Prestige[0].Place==1) PrintAt(5+i*80,178,"SOVIET");
00251             else PrintAt(5+i*80,178,"NONE");
00252 
00253             DispNum(5+i*80,195,Data->Prestige[0].Points[plr]);
00254             break;
00255 
00256 
00257         case 3: PrintAt(5+i*80,80,"LUNAR PROBE");
00258             if (Data->P[plr].Probe[2].Num>=0)
00259                DispNum(5+i*80,110,Data->P[plr].Probe[2].Safety);
00260             else DispNum(5+i*80,110,0);
00261             PrintAt(0,0,"%");
00262            
00263              DispNum(5+i*80,127,Data->P[plr].Probe[2].Used);
00264 
00265             DispNum(5+i*80,144,Data->P[plr].Probe[2].Used-Data->P[plr].Probe[2].Failures);
00266 
00267             if (Data->P[plr].Probe[2].Used > 0) DispNum(5+i*80,161,100*(Data->P[plr].Probe[2].Used-Data->P[plr].Probe[2].Failures)/Data->P[plr].Probe[2].Used);
00268             else DispNum(5+i*80,161,0);
00269 
00270             if (Data->Prestige[7].Place==0) PrintAt(5+i*80,178,"U.S.");
00271                     else if (Data->Prestige[7].Place==1) PrintAt(5+i*80,178,"SOVIET");
00272             else PrintAt(5+i*80,178,"NONE");
00273 
00274             DispNum(5+i*80,195,Data->Prestige[7].Points[plr]);
00275             break;
00276 
00277         }
00278      }
00279     else PlanText(plr,0);
00280 
00281     grSetColor(6+3*plr);
00282      PrintAt(5+i*80,103,"SAFETY:");
00283      PrintAt(5+i*80,120,"ATTEMPTS:");
00284      PrintAt(5+i*80,137,"SUCCESSFUL:");
00285      PrintAt(5+i*80,154,"% SUCCESS:");
00286      PrintAt(5+i*80,171,"FIRST:");
00287      PrintAt(5+i*80,188,"PRESTIGE:");
00288 
00289       }
00290 
00291    
00292    return;
00293 }
00294 
00295 void PlanText(char plr,char plan)
00296 {
00297   char tx;
00298   int pUsed,pFails,Find,i;
00299 
00300   Find = 0; /* XXX check uninitialized */
00301 
00302   tx=(Data->P[plr].Probe[1].Num>=0) ? 1 : 0;
00303   
00304   RectFill(164,75,78+160,89,3);
00305   RectFill(162,105,218,113,3);RectFill(162,123,218,131,3);
00306   RectFill(162,157,218,165,3);
00307   RectFill(162,173,218,181,3);RectFill(162,190,218,198,3);
00308 
00309   RectFill(162,139,218,145,3);
00310   if (tx==1) RectFill(165,28,235,55,0);
00311   grSetColor(11);
00312   switch (plan) {
00313    case 0: PrintAt(4+160,80,"LUNAR FLYBY");
00314        grSetColor(11);
00315        PrintAt(4+160,87,"RECON: ");
00316        DispNum(0,0,Data->P[plr].Misc[5].Safety);
00317        PrintAt(0,0,"%");Find=7;
00318       if (tx==1) SmHardMe(plr,190,34,6,6,32);
00319        break;
00320    case 1: PrintAt(4+160,80,"MERCURY FLYBY");
00321            SmHardMe(plr,190,34,6,1,32);Find=11;
00322            break;
00323    case 2: PrintAt(4+160,80,"VENUS FLYBY");
00324            SmHardMe(plr,190,34,6,2,32);Find=9;
00325            break;
00326    case 3: PrintAt(4+160,80,"MARS FLYBY");
00327            SmHardMe(plr,190,34,6,3,32);Find=10;
00328            break;
00329    case 4: PrintAt(4+160,80,"JUPITER FLYBY");
00330            SmHardMe(plr,190,34,6,4,32);Find=12;
00331            break;
00332    case 5: PrintAt(4+160,80,"SATURN FLYBY");
00333            SmHardMe(plr,190,34,6,5,32);
00334            Find=13;
00335            break;
00336    }
00337 
00338    pUsed=pFails=0;
00339    for (i=0;i<Data->P[plr].PastMis;i++)
00340      if (Data->P[plr].History[i].MissionCode==Find) {
00341         pUsed++;
00342         if (Data->P[plr].History[i].spResult!=1) pFails++;
00343      }
00344 
00345    DispNum(5+160,110,Data->P[plr].Probe[1].Safety*tx);PrintAt(0,0,"%");
00346 
00347 
00348    DispNum(5+160,127,pUsed);
00349    DispNum(5+160,144,pUsed-pFails);
00350 
00351    if (pUsed) DispNum(5+160,161,100*(pUsed-pFails)/pUsed);
00352    else DispNum(5+160,161,0);
00353 
00354    if (Data->Prestige[1+plan].Place==0) PrintAt(5+160,178,"U.S.");
00355    else if (Data->Prestige[1+plan].Place==1) PrintAt(5+160,178,"SOVIET");
00356    else PrintAt(5+160,178,"NONE");
00357    DispNum(5+160,195,Data->Prestige[1+plan].Points[plr]);
00358 
00359    
00360    return;
00361 }
00362 
00363 
00364 
00365 void LMPict(char poff)
00366 {
00367   GXHEADER local,local2;
00368     SimpleHdr table;
00369   FILE *in;
00370   in=sOpen("LMER.BUT","rb",0);
00371   fread_SimpleHdr(&table,1,in);
00372   fseek(in,8*sizeof_SimpleHdr,SEEK_SET);
00373   fread(&pal[32*3],672,1,in);
00374   fseek(in,table.offset,SEEK_SET);
00375   fread(buffer,table.size,1,in);
00376   GV(&local,156,89); GV(&local2,156,89);
00377   RLED_img(buffer,local.vptr,table.size,local.w,local.h);
00378   fseek(in,(poff)*sizeof_SimpleHdr,SEEK_SET);
00379   fread_SimpleHdr(&table,1,in);
00380   fseek(in,table.offset,SEEK_SET);
00381   fread(buffer,table.size,1,in);
00382   RLED_img(buffer,local2.vptr,table.size,local2.w,local2.h);
00383   
00384   if (poff==0 || poff==1 || poff==4 || poff==5)
00385     gxPutImage(&local2,gxSET,5,27,0);
00386        else gxPutImage(&local2,gxSET,160,27,0);
00387   
00388   fclose(in);
00389   DV(&local); DV(&local2);
00390   return;
00391 }
00392 
00393 void LMBld(char plr)
00394 {
00395     int i,m;
00396   LMDraw(plr);
00397   
00398   ShBox(1,120,157,168);InBox(4,122,154,166);
00399   ShBox(160,120,319,168);InBox(163,122,316,166);
00400   ShBox(1,170,319,194);InBox(41,172,279,192);
00401   DispBig(71,176,"TOTAL LM POINTS",0,-1);
00402   memset(Name,0,sizeof Name);
00403   sprintf(&Name[0],"%d",Data->P[plr].LMpts);
00404   DispBig(240,176,&Name[0],0,-1);
00405   for (i=0;i<2;i++)
00406     {
00407      if (i==0) m=172; else m=12;
00408      grSetColor(8);PrintAt(m,130,&Data->P[plr].Manned[5+i].Name[0]);grSetColor(9);
00409      grSetColor(6);PrintAt(m,138,"SAFETY FACTOR: ");
00410     grSetColor(1);DispNum(0,0,(Data->P[plr].Manned[5+i].Num>=0) ? Data->P[plr].Manned[5+i].Safety : 0 );
00411     PrintAt(0,0,"%");
00412      grSetColor(6);PrintAt(m,146,"CURRENT QUANTITY: ");
00413     grSetColor(1);DispNum(0,0,(Data->P[plr].Manned[5+i].Num>=0) ? Data->P[plr].Manned[5+i].Num : 0 );
00414 
00415      grSetColor(6);PrintAt(m,154,"NUMBER OF ATTEMPTS: ");grSetColor(1);DispNum(0,0,Data->P[plr].Manned[5+i].Steps);
00416    grSetColor(6);PrintAt(m,162,"SUCCESSFUL ATTEMPTS: ");grSetColor(1);DispNum(0,0,Data->P[plr].Manned[5+i].Steps-Data->P[plr].Manned[5+i].Failures);
00417     }
00418   
00419   music_start(M_HISTORY);
00420   FadeIn(2,pal,0,0,0);
00421   WaitForMouseUp();
00422   while (1)
00423   {
00424     key=0;GetMouse();
00425      if ((x>=245 && y>=5 && x<=314 && y<=17 && mousebuttons>0) || key==K_ENTER) {
00426        InBox(245,5,314,17);
00427        WaitForMouseUp();
00428        if (key>0) delay(150);
00429      music_stop();
00430        key=0;return; // Continue
00431       }
00432   }
00433 }
00434 
00435 void SatBld(char plr)
00436 {
00437   int plan;
00438   plan=0;
00439   SatDraw(plr);
00440   SatText(plr);
00441   strcpy(IDT,"i019");strcpy(IKEY,"k019");
00442   if (Data->P[plr].Probe[1].Num>=0) PlanText(plr,plan);
00443   music_start(M_HISTORY);
00444   FadeIn(2,pal,0,0,0);
00445 
00446   key=0;
00447   WaitForMouseUp();
00448   while (1)
00449   {
00450     GetMouse();
00451      if ((x>=245 && y>=5 && x<=314 && y<=17 && mousebuttons>0) || key==K_ENTER) {
00452        InBox(245,5,314,17);
00453        WaitForMouseUp();
00454        if (key>0) delay(150);
00455       // OutBox(245,5,314,17);
00456       music_stop();
00457        key=0;return; // Continue
00458       }
00459     else if (Data->P[plr].Probe[1].Num>=0 && ((x>=166 && y>=60 && x<=199 && y<=66 && mousebuttons>0) || key==LT_ARROW)) { 
00460        InBox(166,60,199,66);key=0;
00461        WaitForMouseUp();
00462       delay(10);key=0;
00463       if (plan==0) plan=5; else plan--;
00464       PlanText(plr,plan);
00465        OutBox(166,60,199,66);
00466       }
00467     else if (Data->P[plr].Probe[1].Num>=0 && ((x>=201 && y>=60 && x<=234 && y<=66 && mousebuttons>0) || key==RT_ARROW)) {
00468        InBox(201,60,234,66);key=0;
00469        WaitForMouseUp();
00470       delay(10);key=0;
00471       if (plan>4) plan=0; else plan++;
00472       PlanText(plr,plan);
00473        OutBox(201,60,234,66);
00474       }
00475   }
00476 }
00477 
00478 
00479 // EOF

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