home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / CreativeComputers.iso / shareware / text / dvi_3.62 / source / dvisrc.lha / dvihplj.c < prev    next >
C/C++ Source or Header  |  1993-11-01  |  3KB  |  141 lines

  1. /*
  2. ** Datei: DVIHPLJ.C
  3. ** Autor: Ingo Eichenseher
  4. **        Gerhard Wilhelms, 27.8.92
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <stdarg.h>
  9. #include "dvi.h"
  10. #include "dvihdcp.h"
  11. #include "dviframe.h"
  12.  
  13. static void prstr(char *format, ...)
  14. {
  15.     char line[256], *p;
  16.     va_list l;
  17.     va_start(l,format);
  18.     vsprintf(line,format,l);
  19.     va_end(l);
  20.     for (p=line; *p; p++) prbyte(*p);
  21. }
  22.  
  23. static int vpos;
  24.  
  25. static void skpl_hplj(int skip)
  26. {
  27.     vpos += skip;
  28.     prstr("\033*p%dY",vpos);
  29. }
  30.  
  31. static void skpl_hpljlow(int skip)
  32. {
  33.     vpos += 3 * skip;
  34.     prstr("\033*p%dY",vpos);
  35. }
  36.  
  37. static int send_hplj(long addr, int words, int frame_width, int pos)
  38. {
  39.     int i, j, l, gleich, ungleich;
  40.     register unsigned char huge *a = frame_ptr(addr);
  41.  
  42.     words += words;
  43.     prstr("\033&f0S\033*p%dX",pos);
  44.     prstr("\033*r1A"); /* Grafikdruck Anfang */
  45.     for (l=0; l<24; l++)
  46.     {
  47. /*
  48.         for( i = 0; i < words; i += gleich + ungleich )
  49.         {
  50.           gleich = ungleich = 0;
  51.           for( j = i; j < words - 1; j++ )
  52.           {
  53.             if( a[j] == a[j+1] )
  54.             {
  55.               if( !ungleich && gleich < 255 )
  56.                 gleich++;
  57.               else
  58.                 break;
  59.             }
  60.             else
  61.             {
  62.               if( !gleich )
  63.                 ungleich++;
  64.               else
  65.                 break;
  66.             }
  67.           }
  68.           if( gleich )
  69.           {
  70.             prstr( "\033*b1m2W" );
  71.             prbyte( (unsigned char)( gleich++ ) );
  72.             prbyte( a[i] );
  73.           }
  74.           else if( ungleich )
  75.           {
  76.             prstr( "\033*b0m%dW", ungleich );
  77.             for( j = 0; j < ungleich; j++ )
  78.               prbyte( a[i+j] );
  79.           }
  80.           else
  81.           {
  82.             printf( "error!\n" ); return 0;
  83.           }
  84.         }
  85.         a += frame_width;
  86. */
  87.         prstr("\033*b%dW",words);
  88.         for(i=0; i<words; i++)
  89.           prbyte(*a++);
  90.         a += frame_width - words;
  91.     }
  92.     prstr("\033*rbC\033&f1S");
  93.     return 0;
  94. }
  95.  
  96. static int send_hpljlow(long addr, int words, int frame_width, int pos)
  97. {
  98.     int i,l;
  99.     register unsigned char huge *a = frame_ptr(addr);
  100.  
  101.     words += words;
  102.     prstr("\033&f0S\033*p%dX",3*pos);
  103.     prstr("\033*r1A");
  104.     for (l=0; l<24; l++)
  105.     {
  106.         prstr("\033*b%dW",words);
  107.         for(i=0; i<words; i++)
  108.           prbyte(*a++);
  109.         a += frame_width - words;
  110.     }
  111.     prstr("\033*rbC\033&f1S");
  112.     return 0;
  113. }
  114.  
  115. static void init_hplj(void)
  116. {
  117.     vpos = 0;
  118.     prstr("\033E\033*t300R\033&l0O");
  119. }
  120.  
  121. static void init_hpljlow(void)
  122. {
  123.     vpos = 0;
  124.     prstr("\033E\033*t100R\033&l0O");
  125. }
  126.  
  127. static void exit_hplj(void)
  128. {
  129.     prstr("\014");
  130. }
  131.  
  132. int hplj(void)
  133. {
  134.     return print_page(24,skpl_hplj,send_hplj,init_hplj,exit_hplj);
  135. }
  136.  
  137. int hpljlow(void)
  138. {
  139.     return print_page(24,skpl_hpljlow,send_hpljlow,init_hpljlow,exit_hplj);
  140. }
  141.