/********************************************************************* **** Universaltreiber fr HP-kompatible Drucker **** *********************************************************************/ /* Siehe auch Datei JP350WS.C */ #include #include #include #include #include "treiber.h" #include "portab.h" /********************************************************************/ /* Setzt die freien Werte auf Standartwerte */ #ifndef OBEN /* Wenn noch kein oberer Rand definiert */ #define OBEN 0L #endif #ifndef LINKS /* Wenn noch kein linker Rand definiert */ #define LINKS 0L #endif #ifndef MAX_DPI /* Wenn keine maximale Aufl”sung definiert */ #define MAX_DPI 1200L #endif #ifndef WEITE /* druckbare Breite (in Pixel) */ #define WEITE 9344L #endif #ifndef HOEHE /* druckbare H”he (in Pixel) */ #define HOEHE 13544L #endif #ifndef EXT char *drucker_ext="hp"; #else char *drucker_ext=EXT; #endif LONG max_puffer_laenge = 4*WEITE+256; /********************************************************************/ /* Findet entweder Wiederholung (TRUE) oder nichts */ WORD find_next_same( WORD *rep, UBYTE *p, LONG limit ) { WORD i; /* Spezialf„lle */ if( limit<1 ) { *rep = 1; return FALSE; } if( limit<2 && p[0]==p[1] ) { *rep = 2; return TRUE; } /* Sonst getrennt */ if( p[0]==p[1] && p[1]==p[2] ) { /* Abstand zum n„chsten Ungleichen... */ i = 3; while( i<128 && i(HOEHE*h_dpi)/MAX_DPI ) v_weite = ((HOEHE-start_x)*h_dpi)/MAX_DPI; else v_weite = weite; weite = ((weite+15)>>4)*2; /* aufgerundete Byteweite */ /* Nicht druckbarer Rand */ i = (OBEN*h_dpi)/MAX_DPI; p += i*weite; max_zeile = max_zeile-i-1; v_hoehe = max_zeile; if( v_hoehe>(WEITE*h_dpi)/MAX_DPI ) max_zeile = (WEITE*h_dpi)/MAX_DPI; else /* Linken Rand setzen */ sprintf( x_offset, "%ldx", ((WEITE*h_dpi)/MAX_DPI-max_zeile+7)&0x7FFFFFF8L ); v_hoehe = (max_zeile+7)>>3; /* Falls Hoehe nicht durch 8 teilbar */ and = (WORD)(max_zeile&7); if( and==0 ) and = 0x00FF; else and = 0x00FF>>(8-and); /* R„nder feststellen */ for( x=0; x*80 ) { /* Rand an der linken Seite */ sprintf( tmp1, "\33*p+%ldY", x-i ); print_str( tmp1, th ); /*FF*/ } else if( flag&1 ) x = i; /* Grafikdruck Anfang */ /* Grafikaufl”sung festlegen */ /* Grafikweite festlegen */ sprintf( tmp1, "\33&100L\33*rB\33*t%ldR\33*r0A", h_dpi ); print_str( tmp1, th ); for( modus=-1; x>3); i = 0; while( i=max_zeile ) { i = x; if( i>v_weite ) i = v_weite; i = 8-(i&7); sprintf( tmp1, "\33*b%ldY", i ); print_str( tmp1, th ); x += i; continue; } else rechts = (i>>3); } #ifdef NO_COMPRESSION /* Fr LaserJet II & kompatible: Unkomprimiert */ drehe_90( p, tmp2, weite, v_hoehe-1, x ); tmp2[0] &= and; sprintf( tmp1, "\33*b%liW", v_hoehe ); print_str( tmp1, th ); print_block( v_hoehe, tmp2, th ); #else /* und den Needle-Warp... */ drehe_90( p+rechts*8*weite, tmp2, weite, v_hoehe-rechts-1, x ); tmp2[0] &= and; /* Wir komprimieren */ for( i=0, j=0; i0 ) druckzeile[j++] = tmp2[i++]; } } /* Und nun den interessanten Rest */ if( j700 ) h_dpi = 1200; else if( h_dpi>350 ) h_dpi = 600; else if( h_dpi>175 ) h_dpi = 300; else if( h_dpi>110 ) h_dpi = 150; else if( h_dpi>80 ) h_dpi = 100; else h_dpi = 75; /* Unsinnige Werte werden als Maximum angenommen */ if( h_dpi<=0 || h_dpi>MAX_DPI ) h_dpi = MAX_DPI; (void)v_dpi; /* h_dpi = v_dpi bei HP-kompatiblen! */ (void)optionen; if( quer ) return drucke_quer( p, start_y, weite, max_zeile, h_dpi, th, flag ); i = 0; if( flag&1 ) i = (OBEN*h_dpi)/MAX_DPI; /* Oberen Rand berspringen */ j = (LINKS*h_dpi)/MAX_DPI; max_spalte = (weite+15)/16; max_spalte *= 2; p += (max_spalte*i) + j; /* Nicht druckbare R„nder*/ max_spalte -= j; if( weite>(WEITE+LINKS*8)*h_dpi/MAX_DPI /* LINKS*8 nicht druckbar!*/ ) max_spalte = (WEITE*h_dpi)/(8*MAX_DPI); max_zeile -= i+1; max_zeile += start_y; if( max_zeile>(HOEHE*h_dpi)/MAX_DPI ) max_zeile = (HOEHE*h_dpi)/MAX_DPI; zeile = start_y; weite = (weite+15)/16; weite *= 2; /* R„nder feststellen */ while( max_spalte>0 && ist_next_leer( p+max_spalte-1, weite, max_zeile ) ) max_spalte--; if( flag==4 || (flag==7 && max_spalte<=1) ) { /* Seite leer */ lz = max_zeile-zeile; zeile = max_zeile; } if( flag&1 ) { /* In die obere Ecke */ /* & Grafikaufl”sung festlegen */ sprintf( tmp1, " \33*p0Y\33*p-300Y\33*p0X\33*p-300X\33*rB\33*t%ldR", h_dpi ); print_str( tmp1, th ); #ifndef NO_COMPRESSION /* Grafikweite festlegen */ sprintf( tmp1, "\033*r%lds1A\033*b0M", max_spalte*8 ); print_str( tmp1, th ); #endif } while( zeile0 ) { #ifdef NO_COMPRESSION sprintf( tmp1, "\33*p+%ldY", lz ); #else sprintf( tmp1, "\33*b%ldY", lz ); #endif print_str( tmp1, th ); } /* eine oder Druckzeilen an den Drucker! */ for( lz=max_zeile; zeile0 ) druckzeile[j++] = p[i++]; } } /* Und nun den interessanten Rest */ if( j0 ) { #ifdef NO_COMPRESSION sprintf( tmp1, "\33*p+%ldY", lz ); #else sprintf( tmp1, "\33*b%ldY", lz ); #endif print_str( tmp1, th ); } /* Sollte immer gut gehen! (d.h. kein File zu drucken!) */ flush_block( th ); return 0; } /* 22.1.93 */