radar.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 extern char AI[2];
00031 
00032 void PadDraw(char plr,char pad)
00033 {
00034   int i,j,k,l;
00035   
00036   FadeOut(2,pal,10,0,0);
00037   gxClearDisplay(0,0);
00038   ShBox(0,0,319,22); ShBox(0,24,319,198); InBox(3,3,30,19); IOBox(243,3,316,19);
00039   InBox(167,27,316,176);RectFill(168,28,315,175,0);
00040   IOBox(167,179,316,195);
00041   ShBox(4,28,162,43);InBox(6,30,160,41);
00042   ShBox(4,46,162,61);InBox(6,48,160,59);
00043   ShBox(4,68,162,97);InBox(6,70,160,95);
00044   ShBox(56,64,110,74);InBox(57,65,109,73);
00045   ShBox(4,180,162,195);InBox(6,182,160,193); //sched. duration
00046   InBox(6,99,160,178);
00047   grSetColor(9);PrintAt(11,190,"SCHEDULED DURATION: ");
00048   grSetColor(7);
00049   switch(Data->P[plr].Mission[pad].Duration)
00050    {
00051     case 1:PrintAt(0,0,"A");break;
00052     case 2:PrintAt(0,0,"B");break;
00053     case 3:PrintAt(0,0,"C");break;
00054     case 4:PrintAt(0,0,"D");break;
00055     case 5:PrintAt(0,0,"E");break;
00056     case 6:PrintAt(0,0,"F");break;
00057     default:PrintAt(0,0,"NONE");break;
00058    }   
00059   grSetColor(7);PrintAt(63,71,"MISSION");
00060   FlagSm(plr,4,4);
00061   if (Data->P[plr].LaunchFacility[pad]==1 && Data->P[plr].Mission[pad].MissionCode>0) PadPict(2+plr);
00062     else if (Data->P[plr].LaunchFacility[pad]==1 && Data->P[plr].Mission[pad].MissionCode==0) PadPict(4+plr);
00063      else if (Data->P[plr].LaunchFacility[pad]>1) PadPict(0+plr);
00064   grSetColor(1);PrintAt(15,37,"STATUS: ");grSetColor(9);
00065   if (Data->P[plr].LaunchFacility[pad]==1)
00066     PrintAt(0,0,"OPERATIONAL"); else PrintAt(0,0,"DESTROYED");
00067   grSetColor(1);
00068 
00069   if (Data->P[plr].LaunchFacility[pad]>1)
00070     {
00071      PrintAt(15,56,"REPAIR COST: ");grSetColor(9);
00072      DispNum(0,0,Data->P[plr].LaunchFacility[pad]);
00073      PrintAt(0,0,"MB");
00074     if (Data->P[plr].Cash<Data->P[plr].LaunchFacility[pad])
00075      InBox(169,181,314,193);
00076     }
00077    else
00078     {
00079      grSetColor(9);
00080       if (Data->P[plr].Mission[pad].MissionCode==0)
00081       {
00082        PrintAt(15,56,"NO LAUNCH SCHEDULED");
00083        InBox(169,181,314,193);
00084       }
00085       else PrintAt(15,56,"PRE-MISSION CHECK");
00086     }
00087   grSetColor(1);
00088   PrintAt(258,13,"CONTINUE");
00089   if (Data->P[plr].LaunchFacility[pad]==1)
00090    {
00091     grSetColor(9);PrintAt(210,189,"S");grSetColor(1);PrintAt(0,0,"CRUB MISSION");
00092    }
00093   else
00094    {
00095     grSetColor(9);PrintAt(205,189,"F");grSetColor(1);PrintAt(0,0,"IX LAUNCH PAD");
00096    }
00097   DispBig(35,5,"LAUNCH FACILITY",0,-1);
00098   switch(pad) {
00099      case 0: DispBig(201,5,"A",0,-1);break;
00100      case 1: DispBig(201,5,"B",0,-1);break;
00101      case 2: DispBig(201,5,"C",0,-1);break;
00102   }
00103    grSetColor(6);MissionName(Data->P[plr].Mission[pad].MissionCode,11,81,20);
00104    grSetColor(1);
00105   // joint mission part
00106   if (Data->P[plr].Mission[pad].Joint==1) 
00107     {
00108      ShBox(38,91,131,101);InBox(39,92,130,100);
00109      grSetColor(1);
00110      if (Data->P[plr].Mission[pad].part==0) PrintAt(53,98,"PRIMARY PART");
00111        else PrintAt(44,98,"SECONDARY PART");
00112     }
00113   // Hardware to Use
00114 
00115   i=Data->P[plr].Mission[pad].Prog;
00116   j=Data->P[plr].Mission[pad].PCrew-1;
00117   l=Data->P[plr].Mission[pad].BCrew-1;
00118 
00119   // Crews
00120   grSetColor(7);PrintAt(13,107,"PRIMARY CREW");PrintAt(13,145,"BACKUP CREW");
00121   grSetColor(11);
00122   if (j>=0) {
00123     for (k=0;k<Data->P[plr].Gcnt[i][j];k++) {
00124         PrintAt(25,115+7*k,&Data->P[plr].Pool[Data->P[plr].Crew[i][j][k]-1].Name[0]);
00125     }
00126     if (l==-1) PrintAt(25,174,"UNAVAILABLE");
00127   }
00128   if (l>=0) {
00129     for (k=0;k<Data->P[plr].Gcnt[i][l];k++) {
00130         PrintAt(25,153+7*k,&Data->P[plr].Pool[Data->P[plr].Crew[i][l][k]-1].Name[0]);
00131     }
00132     if (j==-1) PrintAt(25,136,"UNAVAILABLE");
00133   }
00134 
00135     if(Data->P[plr].Mission[pad].Prog>0)
00136         PatchMe(plr,126,40,Data->P[plr].Mission[pad].Prog-1,
00137             Data->P[plr].Mission[pad].Patch,32);
00138   FadeIn(2,pal,10,0,0);
00139   
00140   return;
00141 }
00142 
00143 
00144 /** pad is +3 for compatability with News so that 
00145  * it will go ahead and scrub the mission automatically
00146  * 
00147  */
00148 void ClrMiss(char plr,char pad)
00149 {
00150  char prime,back,men,i,prg,temp=0,padd;
00151  padd=pad%3;
00152 
00153  //pad joint first part/second part/single 
00154  if (Data->P[plr].Mission[padd].Joint==0)
00155   {
00156    if (!AI[plr] && pad<3) temp=Help("i111");
00157   }
00158   else 
00159    switch(padd)
00160     {
00161      case 0:if (!AI[plr] && pad<3) temp=Help("i110");break;
00162      case 1:if (Data->P[plr].Mission[1].Joint==1)
00163              {
00164               if (Data->P[plr].Mission[0].Joint==1)
00165                {
00166                 if (!AI[plr] && pad<3) temp=Help("i112");
00167                 padd=0;
00168                }
00169               else
00170                {
00171                 if (!AI[plr] && pad<3) temp=Help("i110");
00172                }
00173              }
00174             break;
00175      case 2:padd=1;if (!AI[plr] && pad<3) temp=Help("i112");break;
00176      default:temp=0;break;
00177     }
00178  if (AI[plr]) temp=1;
00179  if (temp==-1) return;
00180 
00181  prg=Data->P[plr].Mission[padd].Prog;
00182  Data->P[plr].Mission[padd].Hard[Mission_PrimaryBooster] = 0;
00183  if (Data->P[plr].Mission[padd].PCrew!=0)
00184    prime=Data->P[plr].Mission[padd].PCrew-1; else prime=-1;
00185    if (Data->P[plr].Mission[padd].BCrew!=0)
00186      back=Data->P[plr].Mission[padd].BCrew-1; else back=-1;
00187       men= Data->P[plr].Mission[padd].Men;
00188       if (prime!=-1)
00189       for (i=0;i<men;i++)
00190         Data->P[plr].Pool[Data->P[plr].Crew[prg][prime][i]-1].Prime=0;
00191       if (back!=-1)
00192       for (i=0;i<men;i++)
00193         Data->P[plr].Pool[Data->P[plr].Crew[prg][back][i]-1].Prime=0;
00194       if (Data->P[plr].Mission[padd].Joint==1)
00195         {
00196       prg=Data->P[plr].Mission[padd+1].Prog;
00197          if (Data->P[plr].Mission[padd+1].PCrew!=0)
00198            prime=Data->P[plr].Mission[padd+1].PCrew-1; else prime=-1;
00199          if (Data->P[plr].Mission[padd+1].BCrew!=0)
00200            back=Data->P[plr].Mission[padd+1].BCrew-1; else back=-1;
00201          men=Data->P[plr].Mission[padd+1].Men;
00202          if (prime!=-1)
00203            for (i=0;i<men;i++)
00204           Data->P[plr].Pool[Data->P[plr].Crew[prg][prime][i]-1].Prime=0;
00205          if (back!=-1)
00206            for (i=0;i<men;i++)
00207         Data->P[plr].Pool[Data->P[plr].Crew[prg][back][i]-1].Prime=0;
00208          Data->P[plr].Mission[padd+1].part=0;
00209          Data->P[plr].Mission[padd+1].Prog=0;
00210          Data->P[plr].Mission[padd+1].PCrew=0;
00211          Data->P[plr].Mission[padd+1].BCrew=0;
00212          Data->P[plr].Mission[padd+1].Joint=0;
00213          Data->P[plr].Mission[padd+1].Men=0;
00214          Data->P[plr].Mission[padd+1].MissionCode=0;
00215       }
00216       Data->P[plr].Mission[padd].Prog=0;
00217       Data->P[plr].Mission[padd].PCrew=0;
00218       Data->P[plr].Mission[padd].BCrew=0;
00219       Data->P[plr].Mission[padd].Men=0;
00220      Data->P[plr].Mission[padd].Joint=0;
00221       Data->P[plr].Mission[padd].MissionCode=0;
00222       if (Data->P[plr].Mission[padd].Joint==1 && Data->P[plr].Mission[padd].part==0)
00223       memset(&Data->P[plr].Mission[padd+1],0x00,sizeof (struct MissionType));
00224       if (Data->P[plr].Mission[padd+1].Joint==1 && Data->P[plr].Mission[padd+1].part==1)
00225         memset(&Data->P[plr].Mission[padd+1],0x00,sizeof (struct MissionType));
00226  return;
00227 }
00228 
00229 
00230 void PadPict(char poff)
00231 {
00232   GXHEADER local,local2;
00233     SimpleHdr table;
00234   FILE *in;
00235   in=sOpen("LFACIL.BUT","rb",0);
00236   fread_SimpleHdr(&table,1,in);
00237   fseek(in,6*sizeof_SimpleHdr,SEEK_SET);
00238   fread(pal,768,1,in);
00239   fseek(in,table.offset,SEEK_SET);
00240   fread(buffer,table.size,1,in);
00241   GV(&local,148,148); GV(&local2,148,148);
00242   RLED_img(buffer,local.vptr,table.size,local.w,local.h);
00243   fseek(in,(poff)*sizeof_SimpleHdr,SEEK_SET);
00244   fread_SimpleHdr(&table,1,in);
00245   fseek(in,table.offset,SEEK_SET);
00246   fread(buffer,table.size,1,in);
00247   RLED_img(buffer,local2.vptr,table.size,local2.w,local2.h);
00248   
00249   gxPutImage(&local2,gxSET,168,28,0);
00250   
00251   fclose(in);
00252   DV(&local); DV(&local2);
00253   return;
00254 }
00255 
00256 
00257 void ShowPad(char plr,char pad)
00258 {
00259   char temp;
00260   music_start((plr==1)?M_USMIL:M_USSRMIL);
00261   PadDraw(plr,pad);
00262   temp=CheckCrewOK(plr,pad);
00263    if (temp==1) //found mission no crews
00264    {
00265 
00266     ClrMiss(plr,pad+3);
00267     return;
00268    }
00269   strcpy(IDT,"i028\0");strcpy(IKEY,"k028\0");
00270   WaitForMouseUp();
00271   while (1)
00272   {
00273     key=0;GetMouse();
00274     if ((Data->P[plr].LaunchFacility[pad]==1 && x>=169 && y>=181 && x<=314 && y<=193 && mousebuttons>0 && Data->P[plr].Mission[pad].MissionCode>0)
00275       || (Data->P[plr].LaunchFacility[pad]==1 && Data->P[plr].Mission[pad].MissionCode>0 && key=='S')) 
00276       {  // Scrub Mission
00277        InBox(169,181,314,193);
00278        key=0;
00279        WaitForMouseUp();
00280      ClrMiss(plr,pad);
00281        OutBox(169,181,314,193);
00282        key=0; 
00283        if (Data->P[plr].Mission[pad].MissionCode==0) return;
00284       }
00285    else
00286     if ((Data->P[plr].LaunchFacility[pad]<=Data->P[plr].Cash && Data->P[plr].LaunchFacility[pad]>1 && x>=169 && y>=181 && x<=314 && y<=193 && mousebuttons>0)
00287     || (key=='F' && Data->P[plr].LaunchFacility[pad]>1 && Data->P[plr].LaunchFacility[pad]<=Data->P[plr].Cash)) 
00288       {  // Scrub Mission
00289        InBox(169,181,314,193);
00290        key=0;
00291        WaitForMouseUp();
00292        if (Data->P[plr].Cash>=Data->P[plr].LaunchFacility[pad]) 
00293          { 
00294            temp=0;
00295            temp=Help("i115");
00296            if (temp==1)
00297           {
00298            Data->P[plr].Cash=Data->P[plr].Cash-Data->P[plr].LaunchFacility[pad];
00299            Data->P[plr].LaunchFacility[pad]=1;
00300           }
00301          }
00302        else 
00303         {
00304          temp=0;
00305          temp=Help("i116");
00306         temp=0;
00307         }
00308        OutBox(169,181,314,193);
00309        key=0;
00310       if (temp==1) return;
00311       }
00312    else
00313     if ((x>=245 && y>=5 && x<=314 && y<=17 && mousebuttons>0) || key==K_ENTER)
00314     {
00315        InBox(245,5,314,17);key=0;
00316        WaitForMouseUp();
00317        OutBox(245,5,314,17);
00318       if (key>0) delay(150);
00319        key=0; return;  /* Done */
00320     };
00321   }
00322 }
00323 
00324 // EOF

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