place.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 #include "race.h"
00019 #include "gamedata.h"
00020 #include "Buzz_inc.h"
00021 #include "externs.h"
00022 #include "av.h"
00023 #include "utils.h"
00024 
00025 extern char IDT[5],IKEY[5],AL_CALL,AI[2];
00026 extern struct mStr Mis;
00027 extern char Option,MAIL;
00028 
00029 void BCDraw(int y)
00030 {
00031   ShBox(23,y,54,20+y);//ShBox(56,y,296,20+y);
00032   return;
00033 }
00034 
00035 int MChoice(char qty,char *Name)
00036 {
00037     PatchHdr P;
00038     GXHEADER local,local2;
00039     int starty,coff;
00040     int i,j;
00041     char poff;
00042     FILE *in;
00043 
00044 
00045     //FadeOut(2,pal,30,0,0);
00046 
00047     ShBox(21,9,180,34);
00048     ShBox(21,36,180,61);
00049     ShBox(21,63,180,88);
00050     ShBox(21,90,180,115);
00051     ShBox(21,117,180,142);
00052     ShBox(21,144,180,169);
00053 
00054     DispBig(34,15,"NEW GAME",1,0);
00055     DispBig(34,42,"OLD GAME",1,0);
00056     DispBig(34,69,"MODEM",1,0);
00057     DispBig(34,96,"PLAY BY MAIL",1,0);
00058     DispBig(34,123,"CREDITS",1,0);
00059     DispBig(34,150,"EXIT",1,0);
00060 
00061     in=sOpen("BEGGAM.BUT","rb",0);
00062     poff=0;coff=128;
00063     fread(&pal[coff*3],384,1,in);
00064     fseek(in,(poff)*(sizeof P),SEEK_CUR);
00065     fread(&P,sizeof P,1,in);
00066     SwapPatchHdr(&P);
00067 
00068     fseek(in,P.offset,SEEK_SET);
00069     GV(&local,P.w,P.h); 
00070     GV(&local2,P.w,P.h);
00071     gxGetImage(&local2,0,0,P.w-1,P.h-1,0);
00072     fread(local.vptr,P.size,1,in);
00073     fclose(in);
00074 
00075     for (j=0;j<P.size;j++)
00076         if(local.vptr[j]!=0) local2.vptr[j]=local.vptr[j]+coff;
00077     gxPutImage(&local2,gxSET,0,0,0);
00078     DV(&local); DV(&local2);
00079 
00080     ShBox(21,9,180,34);
00081     ShBox(21,36,180,61);
00082     ShBox(21,63,180,88);
00083     ShBox(21,90,180,115);
00084     ShBox(21,117,180,142);
00085     ShBox(21,144,180,169);
00086 
00087     DispBig(34,15,"NEW GAME",1,0);
00088     DispBig(34,42,"OLD GAME",1,0);
00089     DispBig(34,69,"MODEM",1,0);
00090     DispBig(34,96,"PLAY BY MAIL",1,0);
00091     DispBig(34,123,"CREDITS",1,0);
00092     DispBig(34,150,"EXIT",1,0);
00093 
00094     FadeIn(2,pal,30,0,0);
00095     WaitForMouseUp();
00096     j=-1;starty=9;
00097     while(j==-1)
00098     {
00099         GetMouse();
00100         for (i=0;i<qty;i++) // keyboard stuff
00101             if ((char)key==Name[i*22])
00102             {
00103 
00104                 InBox(21,starty+27*i,180,starty+25+27*i);
00105 
00106                 delay(50);
00107                 j=i+1;key=0;
00108             }
00109         if (mousebuttons!=0)
00110         {
00111             for (i=0;i<qty;i++)
00112                 if (x>=21 && x<=180 && y>=starty+27*i && y<=starty+25+27*i)
00113                 {
00114 
00115                     InBox(21,starty+27*i,180,starty+25+27*i);
00116 
00117                     delay(50);
00118                     j=i+1;
00119                 }
00120         }
00121     }   //while(j=...
00122 
00123     return j;
00124 }
00125 
00126 int BChoice(char plr,char qty,char *Name,char *Imx)  // Name[][22]
00127 {
00128   int i,j,starty=100;
00129   GXHEADER local;
00130   FILE *fin=sOpen("PORTBUT.BUT","rb",0);
00131   
00132   //FadeOut(2,pal,10,0,0);
00133 
00134   GV(&local,30,19);
00135 
00136   starty-=(qty*23/2);
00137 
00138   /* hard-coded magic numbers, yuck */
00139   for (i=0;i<qty;i++) {
00140      BCDraw(starty+23*i);
00141      DispBig(60,starty+4+23*i,&Name[i*22],1,0);
00142     fseek(fin,Imx[i]*570,SEEK_SET);
00143     fread((char *)local.vptr,570,1,fin);
00144     gxPutImage(&local,gxSET,24,starty+1+23*i,0);
00145   }
00146   fclose(fin);
00147   DV(&local);
00148 
00149   av_need_update_xy(23, starty, 60+22*15, starty+23*i);
00150   
00151   // FadeIn(2,pal,10,0,0);
00152     WaitForMouseUp();
00153   j=-1;
00154   while(j==-1) {
00155     av_block ();
00156     GetMse(plr,0);
00157     for (i=0;i<qty;i++) // keyboard stuff
00158        if ((char)key==Name[i*22])
00159     {
00160       
00161       InBox(23,starty+23*i,54,starty+20+23*i);
00162       
00163       delay(50);
00164       j=i+1;key=0;
00165     }
00166     if (mousebuttons!=0) {
00167       for (i=0;i<qty;i++)
00168     if ((x>=23 && x<=54 && y>=starty+23*i && y<=starty+20+23*i) ||
00169         (x>56 && y>starty+23*i && x<296 && y<starty+20+23*i))
00170     {
00171       
00172       InBox(23,starty+23*i,54,starty+20+23*i);
00173       
00174       delay(50);
00175       j=i+1;
00176     }
00177     }
00178 
00179   }
00180   return j;
00181 }
00182 
00183 void PatchMe(char plr,int x,int y,char prog,char poff,unsigned char coff) 
00184 {
00185     /* 
00186      * XXX: HACK WARNING.  In my datafiles some Patch entries have
00187      * errors in widths. That causes malformed images, though the data
00188      * is there.  I corrected the problem here (look for do_fix).
00189      * Someone else might also run into this problem, but maybe only
00190      * my data files are corrupted. For correct data behavior is not
00191      * changed.
00192      */
00193     PatchHdrSmall P;
00194   GXHEADER local,local2;
00195   unsigned int j, do_fix = 0;
00196   FILE *in;
00197   in=sOpen("PATCHES.BUT","rb",0);
00198   fread(&pal[coff*3],96,1,in);
00199   fseek(in,(50*plr+prog*10+poff)*(sizeof P),SEEK_CUR);
00200   fread(&P,sizeof P,1,in);
00201     SwapPatchHdrSmall(&P);
00202   fseek(in,P.offset,SEEK_SET);
00203   if (P.w * P.h != P.size)
00204   {
00205       /* fprintf(stderr, "PatchMe(): w*h != size (%hhd*%hhd == %d != %hd)\n",
00206               P.w, P.h, P.w*P.h, P.size); */
00207       if ((P.w+1) * P.h == P.size) {
00208           /* fprintf(stderr, "PatchMe(): P.w++ saves the day!\n"); */
00209           P.w++;
00210           do_fix = 1;
00211       }
00212       P.size = P.w * P.h;
00213   }
00214   GV(&local,P.w,P.h); GV(&local2,P.w,P.h);
00215   gxGetImage(&local2,x,y,x+P.w-1,y+P.h-1,0);
00216 
00217   fread(local.vptr, P.size, 1, in);
00218   fclose(in);
00219   //RLED(buffer+20000,local.vptr,P.size);
00220     for (j = 0; j < P.size; j++)
00221         if (local.vptr[j] != 0) 
00222         {
00223             if (do_fix && ((j % P.w) + 1 == (unsigned char)P.w))
00224                 continue;
00225             local2.vptr[j] = local.vptr[j] + coff;
00226         }
00227   
00228   gxPutImage(&local2,gxSET,x,y,0);
00229   DV(&local); DV(&local2);
00230   return;
00231 }
00232 
00233 void
00234 AstFaces(char plr, int x, int y, char face)
00235 {
00236     long offset;
00237     GXHEADER local, local2, local3;
00238     int fx, fy;
00239     unsigned int j;
00240     int face_offset = 0;
00241     FILE *fin;
00242 
00243     memset(&pal[192], 0x00, 192);
00244     fin = sOpen("FACES.BUT", "rb", 0);
00245     fseek(fin, 87 * sizeof(long), SEEK_SET);
00246     fread(&pal[192], 96, 1, fin);
00247     face_offset = ((int)face) * sizeof(i32);
00248     fseek(fin, face_offset, SEEK_SET);  // Get Face
00249     fread(&offset, sizeof(long), 1, fin);
00250     Swap32bit(offset);
00251     fseek(fin, offset, SEEK_SET);
00252     GV(&local, 18, 15);
00253     fread(local.vptr, 18 * 15, 1, fin);
00254 
00255     
00256     face_offset = ((int)(85+plr)) * sizeof(i32);
00257     fseek(fin, face_offset, SEEK_SET);  // Get Helmet
00258     fread(&offset, sizeof(long), 1, fin);
00259     Swap32bit(offset);
00260     fseek(fin, offset, SEEK_SET);
00261     GV(&local2, 80, 50);
00262     GV(&local3, 80, 50);
00263     fread(local2.vptr, 80 * 50, 1, fin);
00264     fclose(fin);
00265     memset(local3.vptr, 0x00, 80 * 50);
00266     if (plr == 0)   { fx = 32; fy = 17; }
00267     else            { fx = 33; fy = 21; }
00268     gxVirtualVirtual(&local, 0, 0, local.w - 1, local.h - 1,
00269             &local3, fx, fy, gxSET);
00270     for (j = 0; j < 80 * 50; j++)
00271         if (local2.vptr[j] == 0)
00272             local2.vptr[j] = local3.vptr[j];
00273     gxGetImage(&local3, x, y, x + 79, y + 49, 0);
00274     for (j = 0; j < 80 * 50; j++)
00275         if (local2.vptr[j] != 0)
00276             local3.vptr[j] = local2.vptr[j];
00277     for (j = 0; j < 80 * 50; j++)
00278         if (local3.vptr[j] != (7 + plr * 3))
00279             local3.vptr[j] -= 160;
00280     gxPutImage(&local3, gxSET, x, y, 0);
00281     DV(&local3);
00282     DV(&local2);
00283     DV(&local);                    // deallocate in reverse order
00284     return;
00285 }
00286 
00287 
00288 void SmHardMe(char plr,int x,int y,char prog,char planet,unsigned char coff)
00289 {
00290   PatchHdrSmall P;
00291   GXHEADER local,local2;
00292   unsigned int j;
00293   int do_fix = 0;
00294   FILE *in;
00295 
00296   in=sOpen("MHIST.BUT","rb",0);
00297   fread(&pal[coff*3],64*3,1,in);
00298   if (planet>0) fseek(in,(planet-1)*(sizeof P),SEEK_CUR);
00299   else fseek(in,(7+plr*8+prog)*(sizeof P),SEEK_CUR);
00300   fread(&P,sizeof P,1,in);
00301     SwapPatchHdrSmall(&P);
00302   fseek(in,P.offset,SEEK_SET);
00303   if (P.w * P.h != P.size) {
00304       /* fprintf(stderr, "SmHardMe(): w*h != size (%hhd*%hhd == %d != %hd)\n",
00305               P.w, P.h, P.w*P.h, P.size); */
00306       if ((P.w+1) * P.h == P.size) {
00307           /* fprintf(stderr, "SmHardMe(): P.w++ saves the day!\n"); */
00308           P.w++;
00309           do_fix = 1;
00310       }
00311       P.size = P.w * P.h;
00312   }
00313   GV(&local,P.w,P.h); GV(&local2,P.w,P.h);
00314   gxGetImage(&local2,x,y,x+P.w-1,y+P.h-1,0);
00315   fread(local.vptr,P.size,1,in);
00316   fclose(in);
00317   //RLED(buffer+20000,local.vptr,P.size);
00318     for (j = 0; j < P.size; j++)
00319         if (local.vptr[j] != 0) 
00320         {
00321             if (do_fix && ((j % P.w) + 1 == (unsigned char)P.w))
00322                 continue;
00323             local2.vptr[j] = local.vptr[j] + coff;
00324         }
00325   gxPutImage(&local2,gxSET,x,y,0);
00326   DV(&local); DV(&local2);
00327   if (planet>0 && prog==6) SmHardMe(plr,x+planet*2,y+5,prog,0,coff);
00328   if (planet==7 || planet==6) SmHardMe(plr,x+planet*2,y+5,prog,0,coff);
00329   return;
00330 }
00331 
00332 void BigHardMe(char plr,int x,int y,char hw,char unit,char sh,unsigned char coff)
00333 {
00334     SimpleHdr table;
00335   char ch;
00336   GXHEADER local,local2;
00337   long size;
00338   unsigned int j, n;
00339   FILE *in,*fin;
00340   struct TM {
00341       char ID[4];
00342       long offset;
00343       long size;
00344       } AIndex;
00345 
00346   extern struct AnimType AHead;
00347   extern struct BlockHead BHead;
00348 
00349   
00350    if (sh==0) {
00351       size=(plr*32)+(hw*8)+unit;
00352       in=sOpen("RDFULL.BUT","rb",0);
00353       fseek(in,size*sizeof_SimpleHdr,SEEK_CUR);
00354       fread_SimpleHdr(&table,1,in);
00355       fseek(in,table.offset,SEEK_SET);
00356       GV(&local,104,77);GV(&local2,104,77);
00357       fread(&pal[coff*3],96*3,1,in);  // Individual Palette
00358       fread(local2.vptr,table.size,1,in);  // Get Image
00359       fclose(in);
00360       RLED_img(local2.vptr,local.vptr,table.size,local.w,local.h);
00361 
00362       n = gxVirtualSize(gxVGA_13,104,77);
00363       for (j=0;j<n;j++) local.vptr[j]+=coff;
00364 
00365       local.vptr[n - 1]=0;
00366       if (FADE==0) gxSetDisplayPalette(pal);
00367       gxPutImage(&local,gxSET,x,y,0);
00368       DV(&local); DV(&local2);
00369       }
00370    else {
00371       memset(Name,0x00,sizeof Name);
00372       if (plr==0) strcat(Name,"US");
00373       else strcat(Name,"SV");
00374       ch=0x30+unit;
00375 
00376       switch(hw) {
00377      case 0: strcat(Name,"P");
00378          break;
00379      case 1: strcat(Name,"R");
00380          break;
00381      case 2: strcat(Name,"C");
00382 //       if (strncmp(Data->P[plr].Manned[1].Name,"ZOND",4)==0) ch=0x37;
00383          break;
00384      case 3: strcat(Name,"M");
00385          break;
00386      }
00387 
00388       Name[3]=ch;
00389 
00390       fin=sOpen("LIFTOFF.ABZ","rb",0);
00391       fread(&AIndex,sizeof AIndex,1,fin);
00392       while (strncmp(AIndex.ID,Name,4)!=0) {
00393        fread(&AIndex,sizeof AIndex,1,fin);
00394       }
00395             Swap32bit(AIndex.offset);
00396             Swap32bit(AIndex.size);
00397       fseek(fin,AIndex.offset,SEEK_SET);
00398 
00399       fread(&AHead,sizeof AHead,1,fin);
00400             Swap16bit(AHead.w);
00401             Swap16bit(AHead.h);
00402       fread(&pal[coff*3],64*3,1,fin);
00403       fseek(fin,3*(AHead.cNum-64),SEEK_CUR);
00404       GV(&local,AHead.w,AHead.h);
00405 
00406       fread(&BHead,sizeof BHead,1,fin);
00407             Swap32bit(BHead.fSize);
00408       fread(vhptr.vptr,BHead.fSize,1,fin);
00409       RLED_img(vhptr.vptr,local.vptr,BHead.fSize,local.w,local.h);
00410       n = gxVirtualSize(gxVGA_13,AHead.w,AHead.h);
00411       for (j=0;j<n;j++) {
00412           if (local.vptr[j]!=0) local.vptr[j]-=(128-coff);
00413       }
00414       local.vptr[0]=0x00;
00415       
00416       if (FADE==0) gxSetDisplayPalette(pal);
00417       gxVirtualDisplay(&local,0,0,x+1,y,x+102,y+76,0);
00418        //gxPutImage(&dply,mode,x,y,0);
00419       
00420 
00421       DV(&local);
00422       fclose(fin);
00423       }
00424   return;
00425 }
00426 
00427 void
00428 DispHelp(char top, char bot, char *txt)
00429 {
00430     int i, pl = 0;
00431 
00432     i = 0;
00433 
00434     while (i++ < top)
00435     {
00436         if (txt[i * 42] == (char) 0xcc)
00437             grSetColor(txt[i * 42 + 1]);
00438     }
00439     i = top;
00440     RectFill(38, 49, 260, 127, 3);
00441     while (i <= bot && pl < 11)
00442     {
00443         if (txt[i * 42] == (char) 0xCC)
00444         {
00445             grSetColor(txt[i * 42 + 1]);
00446             PrintAt(45, 55 + 7 * pl, &txt[i * 42 + 2]);
00447         }
00448         else
00449         {
00450             PrintAt(45, 55 + 7 * pl, &txt[i * 42]);
00451         }
00452         pl++;
00453         i++;
00454     }
00455 
00456     return;
00457 }
00458 
00459 int Help(char *FName)
00460 {
00461   int i,j,line,top=0,bot=0,plc=0;
00462   char *Help,*NTxt,mode;
00463   int fsize;
00464   GXHEADER local;
00465   FILE *fin;
00466   i32 count;
00467   struct Help {
00468     char Code[6];
00469     i32 offset;
00470     i16 size;
00471   } Pul;
00472 
00473   mode = 0; /* XXX check uninitialized */
00474   NTxt = NULL; /* XXX check uninitialized */
00475 
00476   if (strncmp(&FName[1],"000",3)==0) return 0;
00477 
00478   fin=sOpen("HELP.CDR","rb",0);
00479   fread(&count,sizeof count,1,fin);
00480   fread(&Pul,sizeof Pul,1,fin);
00481     Swap32bit(count);
00482     
00483   i=0;
00484   while (xstrncasecmp(Pul.Code,FName,4)!=0 && i<count) {
00485      fread(&Pul,sizeof Pul,1,fin);
00486      i++;
00487   }
00488   if (i==count) {fclose(fin);return 0;}
00489     Swap32bit(Pul.offset);
00490     Swap16bit(Pul.size);
00491 
00492   AL_CALL=1;
00493   Help=xmalloc(Pul.size);
00494   fseek(fin,Pul.offset,SEEK_SET);
00495   fread(Help,Pul.size,1,fin);
00496   fclose(fin);
00497 
00498   // Process File
00499   i=0;j=0;line=0;fsize=1;
00500   
00501   while(line<fsize) {
00502    if (Help[i]==0x3B) while(Help[i++]!=0x0a);  // Remove Comments
00503    else if (Help[i]==0x25) {  // Percent for line qty
00504       i++;
00505       fsize=10*(Help[i]-0x30)+(Help[i+1]-0x30)+1;
00506       bot=fsize;
00507 
00508       NTxt=xmalloc((unsigned int) (42*fsize));
00509       memset(NTxt,0x00,(unsigned int)(42*fsize));
00510       j=line*42;  // should be 0
00511       mode=Help[i+3]-0x30;
00512       i+=6;
00513       }
00514    else if (Help[i]==0x2e) {  // Period
00515       i++;
00516       NTxt[j++]=0xcc;
00517       NTxt[j++]=(Help[i]-0x30)*100+(Help[i+1]-0x30)*10+(Help[i+2]-0x30);
00518       i+=5;
00519       }
00520    else {   // Text of Line
00521       while (Help[i]!=0x0d) NTxt[j++]=Help[i++];
00522       NTxt[j]=0x00;
00523       i+=2;line++;
00524       j=line*42;
00525       }
00526    }
00527   free(Help);
00528 
00529   key=0;
00530   GV(&local,250,128);
00531   gxGetImage(&local,34,32,283,159,0);
00532   av_need_update_xy(34,32,283,159);
00533 
00534   ShBox(34,32,283,159);
00535   InBox(37,35,279,45); InBox(37,48,261,128);
00536   InBox(264,48,279,128);RectFill(265,49,278,127,0);
00537   ShBox(266,50,277,87); UPArrow(268,56);
00538   ShBox(266,89,277,126);DNArrow(268,95);
00539   RectFill(38,36,278,44,7);
00540   if (mode==0) {
00541    IOBox(83,131,241,156);
00542    DispBig(119,137,"CONTINUE",1,0);
00543    }
00544   else {
00545    IOBox(83,131,156,156);
00546    IOBox(168,131,241,156);
00547    DispBig(88,137,"YES",1,0);
00548    DispBig(175,137,"NO",1,0);
00549    }
00550 
00551   // Display Title
00552   grSetColor(NTxt[1]);
00553   fsize=strlen(&NTxt[2]);
00554   PrintAt(157-fsize*3,42,&NTxt[2]);
00555   top=plc=1;
00556   DispHelp(plc,bot-1,&NTxt[0]);
00557   av_sync();
00558 
00559     WaitForMouseUp();
00560   i=2;
00561   while(i==2) {
00562     GetMouse();
00563     if (mode==0 && ((x>85 && y>=133 && x<=239 && y<=154 && mousebuttons>0) || (key=='C' || key==K_ENTER))) {
00564       InBox(85,133,239,154);i=0;
00565             WaitForMouseUp();
00566             key = 0;
00567       // Continue Response
00568     }
00569     if (mode==1 && ((x>=85 && y>=133 && x<=154 && y<=154 && mousebuttons>0) || key=='Y')) {
00570       InBox(85,133,154,154);i=1;
00571             WaitForMouseUp();
00572             key = 0;
00573       // Yes Response
00574     }
00575     if (mode==1 && ((x>170 && y>=133 && x<=239 && y<=154 && mousebuttons>0) || key=='N')) {
00576       InBox(170,133,239,154);i=-1;
00577             WaitForMouseUp();
00578             key = 0;
00579       // No Response
00580     }
00581     if (plc>top && ((x>=266 && y>50 && x<=277 && y<=87 && mousebuttons>0) || (key>>8)==72 ))
00582       {
00583        InBox(266,50,277,87);
00584       // WaitForMouseUp();
00585        plc--;
00586        DispHelp(plc,bot,&NTxt[0]);
00587        OutBox(266,50,277,87);
00588        key=0;
00589       }  // Up
00590     if ((plc+11)<bot && ((x>=266 && y>89 && x<=277 && y<=126 && mousebuttons>0) || (key>>8)==80 ))
00591       {
00592        InBox(266,89,277,126);
00593       // WaitForMouseUp();
00594        plc++;
00595        DispHelp(plc,bot,&NTxt[0]);
00596        OutBox(266,89,277,126);
00597        key=0;
00598       }  // Down
00599 
00600   }
00601   
00602   gxPutImage(&local,gxSET,34,32,0);
00603   free(NTxt);
00604   DV(&local);
00605   
00606   AL_CALL=0;
00607   return i;
00608 }
00609 
00610 
00611 void Draw_Mis_Stats(char plr, char index, int *where,char mode)
00612 {
00613   int j,k,mcode;
00614   int let;
00615   
00616 
00617   if (mode==0) InBox(245,5,314,17);
00618 
00619   ShBox(6,30,209,168);  // Left Side
00620   RectFill(10,34,205,44,9);InBox(9,33,206,45);
00621   RectFill(10,49,205,119,7);InBox(9,48,206,120);
00622   RectFill(10,124,205,164,7);InBox(9,123,206,165);
00623   ShBox(62,117,154,127);grSetColor(1);PrintAt(80,124,"FLIGHT CREW");
00624   grSetColor(11);PrintAt(58,41,"MISSION INFORMATION");
00625   PrintAt(12,104,"MISSION DURATION: ");
00626   Name[0]=(char)Data->P[plr].History[index].Duration+'A'-1;
00627   Name[1]=0;
00628   if (Name[0] >= 'A') PrintAt(0,0,Name);
00629   else PrintAt(0,0,"NONE");
00630   PrintAt(12,112,"PRESTIGE EARNED: ");
00631   if ((MAIL==-1 && Option==-1) || mode==0) DispNum(0,0,Data->P[plr].History[index].Prestige);
00632    else PrintAt(0,0,"PENDING");
00633   mcode=Data->P[plr].History[index].MissionCode;
00634 
00635   GetMisType(mcode);
00636 
00637   grSetColor(1);
00638   PrintAt(12,56,"MISSION NAME: ");
00639   PrintAt(0,0,(char *)Data->P[plr].History[index].MissionName);
00640   PrintAt(12,64,"MISSION TYPE:");
00641   grSetColor(11);
00642   PrintAt(15,72,Mis.Abbr);
00643   grSetColor(1);
00644   PrintAt(12,80,"RESULT: ");
00645   if(Data->P[plr].History[index].Duration!=0) {
00646 
00647       if (Data->P[plr].History[index].spResult==4197)
00648         PrintAt(0,0,"PRIMARY CREW DEAD");
00649       else if (Data->P[plr].History[index].spResult==4198)
00650         PrintAt(0,0,"SECONDARY CREW DEAD");
00651       else if (Data->P[plr].History[index].spResult==4199)
00652         PrintAt(0,0,"BOTH CREWS DEAD");
00653       else PrintAt(0,0,((Data->P[plr].History[index].spResult<500) || (Data->P[plr].History[index].spResult>=5000)) ? "SUCCESS" : 
00654         (Data->P[plr].History[index].spResult<1999) ? "PARTIAL FAILURE" :
00655         (Data->P[plr].History[index].spResult==1999) ? "FAILURE" :
00656         (Data->P[plr].History[index].spResult<3000) ? "MISSION INJURY" :
00657         (Data->P[plr].History[index].spResult<4000) ? "MISSION DEATH" :
00658         "ALL DEAD");
00659   }
00660   else if (Data->P[plr].History[index].Event==0)
00661      PrintAt(0,0,(Data->P[plr].History[index].spResult == 1)?"SUCCESS":"FAILURE");
00662   else if (Data->P[plr].History[index].Event>0) {
00663      PrintAt(0,0,"ARRIVE IN ");
00664      DispNum(0,0,Data->P[plr].History[index].Event);
00665      PrintAt(0,0," SEASON");
00666      if (Data->P[plr].History[index].Event>=2) PrintAt(0,0,"S");
00667   }
00668 
00669   RectFill(210,30,211,168,0); // Clear any left over stuff
00670   ShBox(211,30,313,168); // Right Side
00671   RectFill(215,34,309,44,9);InBox(214,33,310,45);
00672   grSetColor(11);PrintAt(225,41,"MISSION REPLAY");
00673   InBox(214,55,310,116);
00674 
00675   AbzFrame(plr,index,215,56,94,60,"OOOO",mode);
00676    
00677   IOBox(214,134,310,148);grSetColor(1);PrintAt(223,143,"REPLAY MISSION");
00678   if (mode==0) {
00679      IOBox(214,151,310,165);
00680      grSetColor(1);PrintAt(250,160,"EXIT");
00681   }
00682 
00683   // Crew Stuff
00684     grSetColor(11);
00685   if (Data->P[plr].History[index].Man[0][0]==-1 && Data->P[plr].History[index].Man[1][0]==-1)
00686      PrintAt(13,137,"UNMANNED MISSION");
00687   else {
00688     // First Part -- Men
00689     if (Data->P[plr].History[index].Man[0][0]!=-1) {
00690         for(j=0;j<4;j++) {
00691           k=Data->P[plr].History[index].Man[0][j];
00692           if(k!=-1) PrintAt(13,137+j*7,Data->P[plr].Pool[k].Name);
00693         }
00694       let=1;   // Men on Part 1
00695     }
00696     else let=0;   // Men not on Part 1
00697     // Second Part -- Men
00698     if (Data->P[plr].History[index].Man[1][0]!=-1) {
00699         for(j=0;j<4;j++) {
00700           k=Data->P[plr].History[index].Man[1][j];
00701           if(k!=-1) PrintAt(13+let*100,137+j*7,Data->P[plr].Pool[k].Name);
00702         }
00703     }
00704 
00705   }  
00706   
00707 
00708   if (mode==1) {
00709      FadeIn(2,pal,10,0,0);
00710   };
00711 
00712     WaitForMouseUp();
00713   while(1) {
00714        GetMouse();
00715        if (mode==0 && ((x>=216 && y>=153 && x<=308 && y<=163 && mousebuttons==1) || (key==K_ENTER || key=='E')))
00716        { 
00717           InBox(216,153,308,153);OutBox(245,5,314,17); 
00718           WaitForMouseUp();
00719         if(key>0) delay(150);
00720           DrawMisHist(plr,where);
00721         key=0;
00722           break;
00723        }
00724      else if (mode==1 && ((x>=245 && y>=5 && x<=314 && y<=17 && mousebuttons==1) || key==K_ENTER))
00725      {
00726         InBox(245,5,314,17);
00727           WaitForMouseUp();
00728         if (key>0) delay(150);
00729           OutBox(245,5,314,17);delay(10);
00730         if (!AI[plr]) music_stop();
00731         FadeOut(2,pal,10,0,0);
00732         key=0;
00733           break;
00734      }
00735        else if ((x>=216 && y>=136 && x<=308 && y<=146 && mousebuttons==1) || (key=='R'))
00736        {
00737           InBox(216,136,308,146);
00738         if (mode==0) InBox(216,153,309,163);
00739         grSetColor(11);PrintAt(225,125,"PLAYING...");
00740          
00741           WaitForMouseUp();
00742         grSetColor(1);
00743 
00744         if (x==0 && y==0) {
00745            FILE *tin;
00746            
00747            tin=sOpen("REPL.TMP","wb",1); // Create temp image file
00748            fwrite(pal,sizeof pal,1,tin);
00749            fwrite(screen,64000,1,tin);
00750            fclose(tin);
00751            FadeOut(2,pal,10,0,0);
00752            memset(screen,0x00,64000);
00753            FadeIn(2,pal,10,0,0);
00754            if (Data->P[plr].History[index].MissionCode==10 ||
00755              Data->P[plr].History[index].MissionCode==12 ||
00756              Data->P[plr].History[index].MissionCode==13)
00757             {
00758              if (Data->P[plr].History[index].Event==0 &&
00759               Data->P[plr].History[index].spResult==1) 
00760                switch(Data->P[plr].History[index].MissionCode)
00761                 {
00762                  case 10:Replay(plr,index,0,0,320,200,(plr==0) ? "WUM1" : "WSM1");break;
00763                  case 12:Replay(plr,index,0,0,320,200,(plr==0) ? "WUJ1" : "WSJ1");break;
00764                  case 13:Replay(plr,index,0,0,320,200,(plr==0) ? "WUS1" : "WSS1");break;
00765                  default:break;
00766                 };
00767             }
00768             else Replay(plr,index,0,0,320,200,"OOOO");
00769            FadeOut(2,pal,10,0,0);
00770            tin=sOpen("REPL.TMP","rb",1);  // replad temp image file
00771            fread(pal,sizeof pal,1,tin);
00772            fread(screen,64000,1,tin);
00773            fclose(tin);
00774            FadeIn(2,pal,10,0,0);
00775            key=0;
00776            remove_savedat("REPL.TMP");
00777            
00778         }
00779         else {
00780           //Specs: Planetary Mission Klugge
00781           if (Data->P[plr].History[index].MissionCode==10 ||
00782               Data->P[plr].History[index].MissionCode==12 ||
00783               Data->P[plr].History[index].MissionCode==13)
00784             {
00785              if (Data->P[plr].History[index].Event==0 &&
00786                 Data->P[plr].History[index].spResult==1) {
00787                switch(Data->P[plr].History[index].MissionCode)
00788                 {
00789                  case 10:Replay(plr,index,215,56,94,60,(plr==0) ? "WUM1" : "WSM1");break;
00790                  case 12:Replay(plr,index,215,56,94,60,(plr==0) ? "WUJ1" : "WSJ1");break;
00791                  case 13:Replay(plr,index,215,56,94,60,(plr==0) ? "WUS1" : "WSS1");break;
00792                  default:break;
00793                 };
00794               }
00795              else Replay(plr,index,215,56,94,60,"OOOO");
00796             }
00797           else Replay(plr,index,215,56,94,60,"OOOO");
00798           AbzFrame(plr,index,215,56,94,60,"OOOO",mode);
00799          }
00800           OutBox(216,136,308,146);
00801           if (mode==0) OutBox(216,153,309,163);
00802           RectFill(212,119,312,127,3);
00803           key=0;
00804           
00805        }; // if
00806 
00807   }; // while
00808   video_rect.w = 0;
00809   video_rect.h = 0;
00810 
00811 }
00812 
00813 
00814 // EOF

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