/**********************************************************                   VDI.C                       ******** VDI-Treiber, gibt (Teil-)Seite ueber GDOS aus **********************************************************//* Geaendert von Thomas Wieschebrink am 23.7.95 */
/* Neu an DVI 3.00 angepažt 7.10.95 m. Pristovsek */#include <vdi.h>#include <tos.h>
#include <stdlib.h>#define FALSE 0#define TRUE 1/********************************************************************/
long	max_puffer_laenge = 0;

#if (__PUREC__<=100)

/* VDI */typedef struct{  int  *contrl;    /* Zeiger auf contrl-Array */  int  *intin;     /* Zeiger auf intin-Array  */  int  *ptsin;     /* Zeiger auf ptsin-Array  */  int  *intout;    /* Zeiger auf intout-Array */  int  *ptsout;    /* Zeiger auf ptsout-Array */} VDIPB;
extern void vdi( VDIPB * );

#endif

/* Neue Routine wegen erweiterter Parameterbergabe */
void vq2_extnd( int handle, int owflag, int *work_out, int weite, int hoehe ){/* ACHTUNG:																						*/
/* Funktioniert SO nur mit PC 1.1! 										*/
/* Žltere Versionen brauchen eine andere Behandlung!	*/
/* Die Funktion "vdi()" und die Definition der 				*/
/* Parameterbl”cke ist sehr stark Bibliotheksabh„ngig!*/
	VDIPB	vdipb;
#if (__PUREC__<=100)	/* Fr Version 1.0 */
	vdipb.contrl = _GemParBlk.contrl;	vdipb.intin  = _GemParBlk.intin;	vdipb.ptsin  = _GemParBlk.ptsin;#else
	vdipb.contrl = _VDIParBlk.contrl;
	vdipb.intin  = _VDIParBlk.intin;	vdipb.ptsin = _VDIParBlk.ptsin;
#endif	vdipb.intout = work_out;	vdipb.ptsout = &(work_out[45]);
  vdipb.contrl[0] = 102;  vdipb.contrl[1] = 0;  if(  vdipb.ptsin[0] > 0  &&  vdipb.ptsin[1] > 0  )    vdipb.contrl[1] = 1;  vdipb.contrl[3] = 1;  vdipb.contrl[6] = handle;
  vdipb.intin[0] = owflag;
  vdipb.ptsin[0] = weite;  vdipb.ptsin[1] = hoehe;	vdi( &vdipb );}
/* 7.10.95 */
/********************************************************************//* Schreibe in DVI-Datei */int drucke( char *p, long start_x, long weite, long hoehe, long h_dpi, long v_dpi, 
						short fh, short flag, short quer, char *optionen ){  int       i, hdl, work_in[11], work_out[57];  MFDB      bitmap, drucker;
	(void)quer;	/* Ignorieren */
	(void)start_x;
	(void)h_dpi;
	(void)v_dpi;
  if(  vq_gdos()==0  )
  {
  	Cconws( "Kein GDOS installiert!\7" );
    return -1;  }
  if(  fh>5  )
  {
  	Cconws( "Kann nicht in Dateien drucken!\7" );
    return -1;  }
  if(  flag!=7  )
  {
  	Cconws( "Nur ganze Seiten!\7" );
    return -1;  }

  /* Und nun die Ausgabe auf Geraet 21 oder neue Unit */	if(  optionen[0]  )
	  work_in[0] = (int)atol( optionen );
	if(  work_in[0]<=0  )
	  work_in[0] = 21;  for( i = 1; i < 10; i++ )    work_in[i] = 1;  work_in[10] = 2;  v_opnwk( work_in, &hdl, work_out );
	if(  hdl<=0  )
  {
  	Cconws( "Ger„t l„žt sich nicht ”ffnen!\7" );
    return -1;  }
	
	if(  flag&2  )	{
		/* Seitengroesse setzen */		vq2_extnd( hdl, 0, work_out, (short)weite-1, (short)hoehe-1 );
		bitmap.fd_addr      = p;		bitmap.fd_w         = (int)weite;		bitmap.fd_h         = (int)hoehe;		bitmap.fd_wdwidth   = (int)(weite+15)>>4;		bitmap.fd_stand     = 1;		bitmap.fd_nplanes   = 1;
		/* Adresse wird vom Treiber gesetzt!! */		drucker.fd_addr     = 0;		/* Breite bzw. Hoehe ist ein Pixel mehr!! */		drucker.fd_w        = work_out[0]+1;		drucker.fd_h        = work_out[1]+1;		drucker.fd_wdwidth  = (work_out[0]+16)>>4;		drucker.fd_stand    = 1;		drucker.fd_nplanes  = 1;
		/* work_in als pxyarray missbrauchen */		work_in[0] = work_in[1] = 0;		work_in[4] = work_in[5] = 0;
		work_in[2] = work_in[6] = (int)weite-1;		if(  weite>drucker.fd_w  )			work_in[2] = work_in[6] = drucker.fd_w-1;
		work_in[3] = work_in[7] = (int)hoehe-1;		if(  hoehe>drucker.fd_h  )			work_in[3] = work_in[7] = drucker.fd_h-1;
		/* Bitmap auf Druckerseite kopieren */		vro_cpyfm( hdl, S_ONLY, work_in, &bitmap, &drucker);
		/* drucken */		v_updwk( hdl );	}	if(  flag&4  )		v_form_adv( hdl );	v_clswk( hdl );	return 0;}/* Žnderungen 7.10.95 M. Pristovsek */