review.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 // Review Main Files
00026 
00027 #include "gamedata.h"
00028 #include "Buzz_inc.h"
00029 #include "externs.h"
00030 
00031 extern struct MisAst MA[2][4];
00032 extern char AI[2];
00033 
00034 void DrawReview(char plr)
00035 {
00036 int clr,i,cte,P_value;
00037 char Fired_Flag=0,Reset_Flag=0;
00038   
00039 if (Data->P[plr].PresRev[0]!=0x7F) FadeOut(2,pal,10,0,0);
00040   PortPal(plr);
00041   gxClearDisplay(0,0);
00042   if (Data->P[plr].PresRev[0]==0x7F) {Fired_Flag=1;Data->P[plr].PresRev[0]=16;}
00043    else if (Data->P[plr].PresRev[0]>=16) {Reset_Flag=1;Data->P[plr].PresRev[0]=15;}
00044   ShBox(0,0,319,22);ShBox(0,24,319,199);
00045   FlagSm(plr,4,4);
00046   RectFill(5,28,314,195,0);
00047   RectFill(5,122,314,195,0);ShBox(6,123,313,194);
00048   RectFill(7,124,312,193,9); 
00049   InBox(11,128,307,189);
00050   RectFill(12,129,306,188,7);
00051   ShBox(6,29,177,121);ShBox(179,29,313,121);
00052   InBox(182,32,309,117);InBox(3,3,30,19);
00053   IOBox(243,3,316,19);
00054   if (plr==0) DispBig(40,5,"PRESIDENTIAL REVIEW",0,-1);
00055   else DispBig(40,5,"POLITBURO REVIEW",0,-1);
00056   grSetColor(1);
00057   PrintAt(257,13,"CONTINUE");
00058   grSetColor(1);PrintAt(59,36,"JOB PERFORMANCE");
00059   grSetColor(6);PrintAt(8,46,"GOOD");
00060   grSetColor(1);PrintAt(8,77,"FAIR");
00061   grSetColor(9);PrintAt(8,109,"POOR");
00062   grSetColor(1);
00063   DispNum(154,117,Data->Year-1);
00064   DispNum(126,117,Data->Year-2);
00065   DispNum(97,117,Data->Year-3);
00066   DispNum(70,117,Data->Year-4);
00067   DispNum(42,117,Data->Year-5);
00068   RectFill(32,39,172,111,0);
00069   GradRect(33,39,171,74,0);GradRect(33,75,171,110,0);
00070   grSetColor(3);
00071   pline(60,40,60,110);
00072   pline(88,40,88,110);
00073   pline(116,40,116,110);
00074   pline(144,40,144,110);
00075   pline(33,48,171,48);
00076   pline(33,57,171,57);
00077   pline(33,66,171,66);
00078   pline(33,75,171,75);
00079   pline(33,84,171,84);
00080   pline(33,93,171,93);
00081   pline(33,102,171,102);
00082   InBox(32,39,172,111);
00083   for (i=0;i<5;i++) if (Data->P[plr].PresRev[i]>16) Data->P[plr].PresRev[i]=16;
00084     for(i=0;i<5;i++)
00085      {
00086       cte=0;
00087       if (Data->P[plr].PresRev[i]<8)
00088        {
00089          if (Data->P[plr].PresRev[i]==7) cte=73;
00090           else cte=40+Data->P[plr].PresRev[i]*5;
00091        }
00092        else
00093       if (Data->P[plr].PresRev[i]>8)
00094        {
00095           if (Data->P[plr].PresRev[i]==9) cte=77;
00096           else cte=80+(Data->P[plr].PresRev[i]-10)*5;
00097        };
00098       if (Data->P[plr].PresRev[i]==8) cte=73;
00099       RectFill(166-i*28,75,151-i*28,cte,5+((Data->P[plr].PresRev[i] <=8) ? 0 : 3));
00100       grSetColor(6+((Data->P[plr].PresRev[i] <=8) ? 0 : 3));
00101       pline(167-i*28,75,167-i*28,cte);
00102      }
00103   if (Fired_Flag==1)
00104    {
00105     clr=0;
00106     for (i=0;i<Data->P[plr].AstroCount;i++)
00107      if (Data->P[plr].Pool[i].Status==1) clr++;
00108     Data->P[plr].PresRev[0]= (clr>=2) ? 17 : 16; 
00109    }
00110   DrawRevText(plr,Data->P[plr].PresRev[0]);
00111   if (Data->P[plr].PresRev[0]==17) Data->P[plr].PresRev[0]=16;
00112   P_value=0;
00113   // 0 pres. 1 v.p.
00114   if (plr==0) 
00115     {
00116      if (Data->P[plr].PresRev[0]<=4 || Data->P[plr].PresRev[0]>=11)
00117        P_value=0; else P_value=1;
00118     };
00119   if (plr==1) 
00120     {
00121      if (Data->P[plr].PresRev[0]<=4 || Data->P[plr].PresRev[0]>=12)
00122        P_value=0; else P_value=1;
00123     }
00124   if (plr==0) 
00125     {
00126      if (Data->Year<=60) {if (P_value==0) PresPict(0); else PresPict(1);}
00127        else if (Data->Year>=61 && Data->Year<=63) 
00128           {if (P_value==0) PresPict(2); else PresPict(3);}
00129      else if (Data->Year>=64 && Data->Year<=68)
00130         {if (P_value==0) PresPict(4); else PresPict(5);}
00131          else if (Data->Year>=69 && Data->Year<=73)
00132             {if (P_value==0) PresPict(6); else PresPict(7);}
00133         else if (Data->Year>=74 && Data->Year<=76)
00134                {if (P_value==0) PresPict(8); else PresPict(9);}
00135            else if (Data->Year>=77) {if (P_value==0) PresPict(10); else PresPict(11);}
00136     }
00137   if (plr==1)
00138    {
00139     if (Data->Year<61) {if (P_value==0) PresPict(14); else PresPict(15);}
00140     else if (Data->Year<=64) {if (P_value==0) PresPict(12); else PresPict(13);}
00141       else if (Data->Year>=65) {if (P_value==0) PresPict(16); else PresPict(17);}
00142    }
00143   if (Reset_Flag==1) Data->P[plr].PresRev[0]=16;
00144   FadeIn(2,pal,10,0,0);
00145   
00146   return;
00147 }
00148 
00149 
00150 void Review(char plr)
00151 {
00152 DrawReview(plr);
00153 music_start((plr==0)?M_PRES:M_RD);
00154 WaitForMouseUp();
00155  while (1)
00156   {
00157    key=0;GetMouse();
00158    if (mousebuttons > 0 || key>0)  /* Game Play */
00159      {
00160       if ((x>=245 && y>=5 && x<=314 && y<=17) || key==K_ENTER)
00161         {
00162          InBox(245,5,314,17);
00163          WaitForMouseUp();
00164        music_stop();
00165          return;  /* Done */
00166        };
00167      }
00168   };
00169 }
00170 
00171 // Mission Review
00172 
00173 void MisRev(char plr,int pres)
00174 {
00175   if (!AI[plr]) music_start((pres>0) ? M_SUCCESS: M_UNSUCC);
00176   
00177   FadeOut(2,pal,10,0,0);
00178   gxClearDisplay(0,0);
00179   ShBox(0,0,319,22);InBox(3,3,30,19);IOBox(243,3,316,19);
00180   DispBig(40,5,"MISSION REVIEW",0,-1);
00181   grSetColor(1);PrintAt(258,13,"CONTINUE");
00182   FlagSm(plr,4,4);
00183   
00184   key=0;
00185   Draw_Mis_Stats(plr,Data->P[plr].PastMis-1,0,1);
00186   key=0;
00187   gxClearDisplay(0,0);
00188   return;
00189 }
00190 
00191 
00192 void PresPict(char poff)
00193 {
00194   GXHEADER local;
00195     SimpleHdr table;
00196   FILE *in;
00197   in=sOpen("PRESR.BUT","rb",0);
00198   fseek(in,poff*sizeof_SimpleHdr,SEEK_SET);
00199   fread_SimpleHdr(&table,1,in);
00200   fseek(in,table.offset,SEEK_SET);
00201   fread(&pal[96],672,1,in);
00202   fread(buffer,table.size,1,in);
00203   fclose(in);
00204   GV(&local,126,84);
00205   RLED_img(buffer,local.vptr,table.size,local.w,local.h);
00206   
00207   gxPutImage(&local,gxSET,183,33,0);
00208   
00209   DV(&local);
00210   return;
00211 }
00212 
00213 void CalcPresRev(void)
00214 {
00215     i16 *ip;
00216     int val,max,min,i,j;
00217     char plr;
00218 
00219     if(Data->Year==57 && Data->Season==0)return;
00220     // Move PresRev down One
00221     for(j=0;j<NUM_PLAYERS;j++) 
00222         for(i=4;i>0;i--)
00223             Data->P[j].PresRev[i] = Data->P[j].PresRev[i-1];
00224 
00225     Data->P[0].Prestige=Data->P[1].Prestige=0; // Clear Prest when finished
00226     for(plr=0;plr<NUM_PLAYERS;plr++)
00227     {
00228         ip=&Data->P[plr].PresRev[0];
00229 
00230         max = maxx(Data->P[plr].tempPrestige[0],Data->P[plr].tempPrestige[1]);
00231         min = minn(Data->P[plr].tempPrestige[0],Data->P[plr].tempPrestige[1]);
00232 
00233         val = ((max >= 0 && min >= 0) || (max <= 0 && min <= 0 )) ? max + min : max/2+min;
00234 
00235         *ip = (val < 0 && (*ip<4)) ? *ip+1 : ((val>1 && val<=10) ? *ip-1 
00236                 : ((val >= 11 && val <= 20) ? ((*ip<4) ? *ip-1 : *ip-2) 
00237                     : ((val >= 21) ? ((*ip<4) ? *ip-1 : *ip-3)
00238                         : ((val >= -9 && val <= 0) ? *ip+1 : ((val<=-10) ? 
00239                                 ((plr==0) ? *ip+Data->Def.Lev1+1: *ip+Data->Def.Lev2+1) : *ip)))));
00240 
00241         *ip = (*ip>16) ? 16 : ((*ip<1) ? 1 : *ip);
00242 
00243         Data->P[plr].tempPrestige[0] = 0;
00244         Data->P[plr].tempPrestige[1] = 0;
00245         Data->P[plr].PresRev[0] += (Data->P[plr].PresRev[0] > Data->P[abs(plr-1)].PresRev[0]) ? 1 : 0;
00246     }
00247 
00248 }
00249 
00250 void DrawRevText(char plr, int val)
00251 {
00252   int index=0,length,line=0;
00253   FILE *fin;
00254   memset(buffer,0x00,10000);
00255   fin=sOpen("P_REV.DAT","rb",0);      // Read Mission Structure
00256   fseek(fin, 204*18*plr+204*val,SEEK_SET);
00257   fread(buffer,204,1,fin);
00258   fclose(fin);
00259 
00260   grSetColor(1);
00261 
00262   grMoveTo(20,140);
00263   do{
00264      if(buffer[index]=='*') {
00265        length=0;
00266        index++;
00267        line++;
00268        grMoveTo(20,140+12*line);
00269      }
00270      DispChr(buffer[index]);
00271      length++;
00272      index++;
00273   } while(buffer[index]!=0);
00274 }
00275 
00276 
00277 /* EOF */
00278 

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