home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / ARSRC21.ZIP / AR256T.CPP < prev    next >
C/C++ Source or Header  |  1995-05-25  |  6KB  |  318 lines

  1. #include<stdio.h>
  2. #include<process.h>
  3. #include<conio.h>
  4. #include<graphics.h>
  5. #include<string.h>
  6. #include<stdlib.h>
  7. int huge DetectVGA256();
  8. void fade();
  9. extern bigtile(int,int,unsigned char far *,char,char);
  10.  
  11.  
  12.  
  13. title()
  14.     {
  15.     //return(0);
  16.     FILE *in;
  17.     int i,col;char inbuf[0x400];
  18.     unsigned char count;
  19.     char c[14][81];
  20.     char title[5][0x400];char eye[2][0x400];
  21.     int gdriver = DETECT, gmode, errorcode;
  22.     //struct palette {int num,int red,int green,int blue;}palette;
  23.  
  24.     //installuserdriver("Svga256",DetectVGA256);
  25.     registerbgidriver(EGAVGA_driver);
  26.     initgraph(&gdriver, &gmode, "");
  27.     //printf("%u %u %u",getmaxx(),getmaxy(),getmaxcolor());
  28.  
  29.     errorcode = graphresult();
  30.  
  31.     if (errorcode != grOk)
  32.      {printf("Graphics error: %s\n", grapherrormsg(errorcode));
  33.      printf("Press any key to halt:");
  34.      getch();
  35.      exit(1);}
  36.  
  37.  
  38.  
  39.   fade();
  40.  
  41.     in=fopen("t1.dat","rb");
  42.     for (i=0;i<0x400;++i)
  43.         {
  44.         fscanf(in,"%c",&inbuf[i]);
  45.         title[0][i]=inbuf[i];
  46.         }
  47.     fclose(in);
  48.     in=fopen("t2.dat","rb");
  49.     for (i=0;i<0x400;++i)
  50.         {
  51.         fscanf(in,"%c",&inbuf[i]);
  52.         title[1][i]=inbuf[i];
  53.         }
  54.     fclose(in);
  55.     in=fopen("t3.dat","rb");
  56.     for (i=0;i<0x400;++i)
  57.         {
  58.         fscanf(in,"%c",&inbuf[i]);
  59.         title[2][i]=inbuf[i];
  60.         }
  61.     fclose(in);
  62.     in=fopen("t4.dat","rb");
  63.     for (i=0;i<0x400;++i)
  64.         {
  65.         fscanf(in,"%c",&inbuf[i]);
  66.         title[3][i]=inbuf[i];
  67.         }
  68.     fclose(in);
  69.     in=fopen("t5.dat","rb");
  70.     for (i=0;i<0x400;++i)
  71.         {
  72.         fscanf(in,"%c",&inbuf[i]);
  73.         title[4][i]=inbuf[i];
  74.         }
  75.     fclose(in);
  76.  
  77.     in=fopen("t7.dat","rb");
  78.     for (i=0;i<0x400;++i)
  79.         {
  80.         fscanf(in,"%c",&inbuf[i]);
  81.         eye[0][i]=inbuf[i];
  82.         }
  83.     fclose(in);
  84.  
  85.     in=fopen("t8.dat","rb");
  86.     for (i=0;i<0x400;++i)
  87.         {
  88.         fscanf(in,"%c",&inbuf[i]);
  89.         eye[1][i]=inbuf[i];
  90.         }
  91.     fclose(in);
  92.  
  93.  
  94.  
  95.     for(i=0;i<5;++i)
  96.         {
  97.         bigtile(155+i*67,100,title[i],2,0);
  98.         }
  99.     setfillstyle(1,0xff);bar(150,168,491,171);
  100.  
  101.     setcolor(0x1a);circle(320,382,45);setcolor(0x17);circle(320,382,46);
  102.     bigtile(290,350,eye[0],2,0);
  103.     setcolor(0x0f);
  104.  
  105.  
  106.  
  107.         strcpy(c[0],"Written by me, Benjamin Peterson, using Borland C++ v3.1, and ");
  108.         strcpy(c[1],"the SVGA256.BGI driver from Jordan Hargrafix Software. This");
  109.         strcpy(c[2],"here program is Copyright (C) Benjamin Peterson 1995 but somehow");
  110.         strcpy(c[3],"I don't think I'm going to be fighting any big legal battles");
  111.         strcpy(c[4],"over it.");
  112.         strcpy(c[5],"");
  113.         strcpy(c[6],"Press '?' in the game for help. 'Num lock' must be on...");
  114.         strcpy(c[7],"");
  115.         strcpy(c[8],"I accept no responsibility for migraines, fits of depression or");
  116.         strcpy(c[9],"damage to fists or computer equipment arising from the in-game");
  117.         strcpy(c[10],"sound effects.  I haven't got a soundcard and if you want me");
  118.         strcpy(c[11],"to put in proper sound, I suggest you mail me one.");
  119.         strcpy(c[12],"");
  120.         strcpy(c[13],"Good luck folks!");
  121.  
  122.     settextstyle(0,0,1);
  123.     for(i=0;i<14;++i)
  124.         {
  125.         setcolor(0x1f-(i/2));
  126.         outtextxy(70,200+i*10,c[i]);
  127.         }
  128.     i=0;
  129.  
  130.  
  131.  //    for(i=0;i<255;++i)
  132.  //        {
  133.  //        setpalette(i,0,0,i);
  134.  //        }
  135.  
  136.     for(;;)
  137.     {
  138.         for(i=0;i<20;++i)
  139.             {
  140.       col=240+(i+count+16)%32;
  141.       if(col>255)col=255-(col-255);
  142.             setcolor(col);
  143.             rectangle(i,i,639-i,479-i);
  144.             if(kbhit())break;
  145.  
  146.             }
  147.    /* ++count;
  148.     for(i=0;i<14;++i)
  149.             {
  150.             setcolor(256-(240+(i+count+16)%16));
  151.             rectangle(i,i,639-i,479-i);
  152.             if(kbhit())break;
  153.  
  154.             }        */
  155.         ++count;
  156.         if(kbhit())break;
  157.     }
  158.  
  159.     getch();
  160.  
  161.     setfillstyle(1,0);
  162.     bar(290,350,353,414);
  163.  
  164.     bigtile(290,350,eye[1],2,0);
  165.  
  166.  
  167.   for(i=239;i<256;++i)       //this ought to be in fade but I don't want a
  168.         {                              //delay there.
  169.         setrgbpalette(i,0,0,0);
  170.         }
  171.     setrgbpalette(238,0,0,0);
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.     //exit(0);
  179.     return(0);
  180. }
  181.  
  182.  
  183. int huge DetectVGA256()
  184. {
  185.  
  186.     int Vid=2;
  187.  
  188.  
  189.  
  190.     //union REGS regs;
  191.  
  192.      //    regs.x.ax = 0x4501;
  193.      //    int86(0x33, ®s, ®s);//ice hgx
  194.  
  195.     /*
  196.      regs.x.ax = 0x4500;               //reinit hgx
  197.         regs.x.si = 640;    // X resolution
  198.         regs.x.di = 400;    // Y resolution
  199.         regs.h.bl = 0;    // 8 bits packed ie normal 256col
  200.         regs.x.dx = 320;    // Bytes per line
  201.         int86(0x33, ®s, ®s);
  202.         //return ((regs.h.al == 0x45) ? 1 : 0); */
  203.     return Vid;
  204.  
  205. }
  206.  
  207. void fade()
  208.     {
  209.     int i,j,px,py,c,r;
  210.     float size;
  211.     FILE* in;
  212.     unsigned char fade[2][0x400];
  213.     unsigned char inbuf[0x400];
  214.  
  215.  
  216.  
  217.     in=fopen("are.dat","rb");
  218.     for (i=0;i<0x400;++i)
  219.         {
  220.         fscanf(in,"%c",&inbuf[i]);
  221.         fade[0][i]=inbuf[i];
  222.         }
  223.     fclose(in);
  224.     in=fopen("na.dat","rb");
  225.     for (i=0;i<0x400;++i)
  226.         {
  227.         fscanf(in,"%c",&inbuf[i]);
  228.         fade[1][i]=inbuf[i];
  229.         }
  230.     fclose(in);
  231.  
  232.  
  233.     for(i=239;i<250;++i)
  234.         {
  235.         setrgbpalette(i,0,0,0);
  236.         }
  237.     setrgbpalette(238,0,0,0);
  238.  
  239.     for(size=15;size>1.5;size-=0.5)
  240.         {
  241.         r=size-1;
  242.         for(i=0;i<0x400;++i)
  243.             {
  244.             px=310-size*32+(i%32)*size+random(r);py=200-size*16+(i/32)*size+random(r);
  245.             if(fade[0][i]<240)
  246.                 {
  247.                 if(!fade[0][i])setfillstyle(1,238);
  248.                 else setfillstyle(1,fade[0][i]+239-16);
  249.                 bar(px,py,px+size-1,py+size-1);
  250.                 }
  251.             }
  252.         for(i=0;i<0x400;++i)
  253.             {
  254.             px=309+(i%32)*size+random(r);py=200-size*16+(i/32)*size+random(r);
  255.             if(fade[1][i]<240)
  256.                 {
  257.                 if(!fade[1][i])setfillstyle(1,238);
  258.                 else setfillstyle(1,fade[1][i]+239-16);
  259.                 bar(px,py,px+size-1,py+size-1);
  260.                 }
  261.             }
  262.  
  263.         }
  264.  
  265.     for(i=-64;i<0;i+=8)
  266.         {
  267.  
  268.         for(j=16;j>0;--j)
  269.             {
  270.             c=i+j*4;if(c<0)c=0;
  271.             setrgbpalette(j+239,c,0,0);
  272.             }
  273.         setrgbpalette(238,i+64,(i+64)/8,(i+64)/8);
  274.         }
  275.  
  276.  
  277.     setfillstyle(1,0);setcolor(0x1e);
  278.     bar(230-1,289-1,390+1,301+1);
  279.     rectangle(230,289,390,301);
  280.  
  281.     outtextxy(237,291,"Prepare yourself...");
  282.      getch();
  283.                                                                      //word zooms out of screen
  284.     for(size=1.5;size<100;size*=1.2)
  285.         {
  286.         r=size-2;
  287.         for(i=0;i<0x400;++i)
  288.             {
  289.             px=310-size*32+(i%32)*size+random(r);py=200-size*16+(i/32)*size+random(r);
  290.             if(fade[0][i]<240)
  291.                 {
  292.                 if(!fade[0][i])setfillstyle(1,238);
  293.                 else setfillstyle(1,fade[0][i]+239-16);
  294.                 bar(px,py,px+size-1,py+size-1);
  295.                 }
  296.             }
  297.         for(i=0;i<0x400;++i)
  298.             {
  299.             px=309+(i%32)*size+random(r);py=200-size*16+(i/32)*size+random(r);
  300.             if(fade[1][i]<240)
  301.                 {
  302.                 if(!fade[1][i])setfillstyle(1,238);
  303.                 else setfillstyle(1,fade[1][i]+239-16);
  304.                 bar(px,py,px+size-1,py+size-1);
  305.                 }
  306.             }
  307.  
  308.         }
  309.  
  310.  
  311.  
  312.     setfillstyle(1,0);bar(0,0,639,479);
  313. }
  314.  
  315.  
  316.  
  317.  
  318.