home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame Game Cube 1: DOS / aztechhalloffamegamecubedisc1- / batlemm / show-pcx.c < prev    next >
Text File  |  1995-02-18  |  4KB  |  180 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define TRUE  1
  6. #define FALSE 0
  7. #define OK    1
  8. #define ERR   0
  9.  
  10. void view_picture(char *file_name,char typ_in, char typ_out)
  11. {
  12. char far *double_buffer;
  13. char inp;
  14. int how_high[320];
  15. char how_fast[320];
  16. long num,num2;
  17. FILE *pic;
  18. int x,y;
  19.  
  20. if(typ_in==1)
  21. {
  22. fade_out(1);
  23. pic=fopen(file_name,"rb");
  24. for(num=0;num<64000;num++)
  25.     video_mem[num]=getc(pic);
  26. fclose(pic);
  27. fade_in(1);
  28. }
  29.  
  30. if(typ_in==2)
  31. {
  32. double_buffer=(char far *)_fmalloc((unsigned int)64000);
  33. pic=fopen(file_name,"rb");
  34. for(num=0;num<64000;num++)
  35.     double_buffer[num]=getc(pic);
  36. fclose(pic);
  37. for(num=0;num<400000;num++)
  38.     {
  39. //    num2=rand()%64000;
  40.     x=rand()%320;
  41.     y=rand()%200;
  42.     video_mem[x+y*320]=double_buffer[x+y*320];
  43.     }
  44. _fmemcpy((char far *)&video_mem[0],(char far *)&double_buffer[0],(unsigned int)64000);
  45. _ffree(double_buffer);
  46. }
  47.  
  48. if(typ_in==3)
  49. {
  50. double_buffer=(char far *)_fmalloc((unsigned int)64000);
  51. pic=fopen(file_name,"rb");
  52. for(num=0;num<64000;num++)
  53.     double_buffer[num]=getc(pic);
  54. fclose(pic);
  55. for(num=0;num<320;num++)
  56.     {
  57. //    y=rand()%10+5;
  58. //    for(x=0;x<5;x++)
  59. //{
  60.     how_high[num]=0;
  61.     how_fast[num]=rand()%10+5;
  62. //    }
  63.     }
  64. for(num=0;num<50;num++)
  65. {
  66. for(num2=0;num2<320;num2++)
  67.     {
  68.     how_high[num2]+=how_fast[num2];
  69.     if(how_high[num2]>200)
  70.     how_high[num2]=200;
  71.     }
  72. for(num2=0;num2<320;num2++)
  73. {
  74. for(x=0;x<how_high[num2];x++)
  75.     video_mem[num2+x*320]=double_buffer[num2+(200-how_high[num2]+x)*320];
  76. }
  77. }
  78. _ffree(double_buffer);
  79. }
  80.  
  81. if(typ_in==4)
  82. {
  83. double_buffer=(char far *)_fmalloc((unsigned int)64000);
  84. pic=fopen(file_name,"rb");
  85. for(num=0;num<64000;num++)
  86.     double_buffer[num]=getc(pic);
  87. fclose(pic);
  88.  
  89.  
  90. for(y=0;y<200;y+=3)
  91.     _fmemcpy((char far *)&video_mem[64000-y*320],(char far *)&double_buffer[0],y*320);
  92. _ffree(double_buffer);
  93. }
  94.  
  95. if(typ_in==5)
  96. {
  97. double_buffer=(char far *)_fmalloc((unsigned int)64000);
  98. pic=fopen(file_name,"rb");
  99. for(num=0;num<64000;num++)
  100.     double_buffer[num]=getc(pic);
  101. fclose(pic);
  102.  
  103. for(x=0;x<320;x+=11)
  104. {
  105. for(y=0;y<100;y++)
  106. {
  107. _fmemcpy((char far *)&video_mem[y*640],(char far *)&double_buffer[y*640+319-x],x);
  108. _fmemcpy((char far *)&video_mem[y*640+639-x],(char far *)&double_buffer[y*640+320],x);
  109. }
  110. }
  111. _ffree(double_buffer);
  112. }
  113.  
  114. //printf("\n Press any key to continue.\n");
  115. inp=getch();
  116. }
  117.  
  118. void main(argc,argv)
  119. int argc;
  120. char *argv[];
  121. {
  122.    char *pcxheader;
  123.    char pcxname[13];
  124.  
  125.    pcxheader = malloc(128);
  126.    strncpy(pcxname,argv[1],13);
  127.    if (!check_suffix(pcxname))
  128.    {
  129.       printf("unable to open pcx file: %s",argv[1]);
  130.       exit(1);
  131.    }
  132.    if (fg_pcxhead(pcxname,pcxheader) != 0)
  133.    {
  134.       printf("unable to open pcx file: %s",argv[1]);
  135.       exit(1);
  136.    }
  137.    fg_svgainit(0);
  138.    fg_setmode(fg_pcxmode(pcxheader));
  139.    fg_showpcx(pcxname,0);
  140.  
  141.    fg_waitkey();
  142.    fg_setmode(3);
  143.    fg_reset();
  144.    exit(0);
  145. }
  146.  
  147. check_suffix(char *fname)
  148. {
  149.    char *strptr;
  150.    int index;
  151.    int error;
  152.  
  153.    error = FALSE;
  154.    strptr = strchr(fname,'.');
  155.  
  156.    /* period in string */
  157.    if (strptr > 0)
  158.    {
  159.       index = (int)(strptr - fname);
  160.       if (index > 8)
  161.       error = TRUE;
  162.    }
  163.  
  164.    /* no period in string */
  165.    else
  166.    {
  167.       index = strlen(fname);
  168.       if (index > 8)
  169.         error = TRUE;
  170.       else
  171.       {
  172.         fname[index] = '.';
  173.         strcat(fname,"pcx");
  174.       }
  175.    }
  176.    if (error) return(ERR);
  177.    return(OK);
  178. }
  179. 
  180.