home *** CD-ROM | disk | FTP | other *** search
/ RBBS in a Box Volume 1 #3.1 / RBBSIABOX31.cdr / dosc / disphr.c < prev    next >
Text File  |  1986-10-10  |  2KB  |  89 lines

  1. /************************************************************************/
  2. /*    DISPHR.C                            */
  3. /*                                    */
  4. /*        This program provides for the local display of high res    */
  5. /*        images transmitted by CompuServe.            */
  6. /*                                    */
  7. /*    Format:                                */
  8. /*        disphr <filename>                    */
  9. /*                                    */
  10. /*            where <filename> is the name of the file that    */
  11. /*            contains the captured high res text from CIS    */
  12. /*                                    */
  13. /*                                    */
  14. /************************************************************************/
  15.  
  16. #include    <stdio.h>
  17.  
  18. main(argc,argv)
  19. int    argc;
  20. char    **argv;
  21. {
  22.     char    l[132];
  23.     FILE    *fopen(),*inf;
  24.     int    c;
  25.     int    curcol,currow,temp;
  26.     int    black,white,white2,i,j;
  27.  
  28.     curcol=0;
  29.     currow=0;
  30.  
  31.     if (argc != 2) {
  32.         printf("usage: disphr <file>\n");
  33.         exit(1);
  34.         }
  35.  
  36.     inf    =fopen(argv[1],"rb");
  37.     if (inf == NULL) {
  38.         printf("Unable to open %s\n",argv[1]);
  39.         return;
  40.         }
  41.  
  42.     crt_mode(5);
  43.  
  44.     while ('\033' != (c = getc(inf)));
  45.     getc(inf);    /* G */
  46.     getc(inf);    /* H */
  47.  
  48.     for (;;) {
  49.         black = (getc(inf) & 0x7f) - 32;
  50.         if (black <0)    {
  51.             goto pr;
  52.             }
  53.  
  54.         white = (getc(inf) & 0x7f) - 32;
  55.         if (white < 0)    {
  56.             goto pr;
  57.             }
  58.             curcol = curcol + black;
  59.             if (curcol>=256) {
  60.                 curcol = curcol - 256;
  61.                 currow++;
  62.                 }
  63.  
  64.         do {
  65.             white2 = 0;
  66.             if ((curcol+white)>=256) {
  67.                 white2 = white+curcol-256;
  68.                 white  = 256-curcol;
  69.                 }
  70.             for (i=curcol;i<(curcol+white);i++) {
  71.                 crt_wdot(currow,i,3);
  72.                 }
  73.             curcol = curcol+white;
  74.             if (curcol == 256) {
  75.                 curcol = 0;
  76.                 currow++;
  77.                 }
  78.             white = white2;
  79.         } while (white != 0);
  80.  
  81.         }
  82. pr:
  83.     crt_srcp(24,0,0);
  84.     printf("Press return: ");
  85.     gets(l,132,stdin);
  86.     crt_mode(2);
  87. }
  88.  
  89.