/* toshiba special commands */

#include <exec/types.h>
#include <devices/printer.h>
#include <devices/prtbase.h>

extern struct PrinterData *PD;
extern struct PrinterExtendedData *PED;

DoSpecial(command,outputBuffer,vline,currentVMI,crlfFlag,Parms)
register UWORD *command;
register char *outputBuffer;
register BYTE *vline;
register BYTE *currentVMI;
register BYTE *crlfFlag;
register UBYTE *Parms;
{
	/* Aztec doesn't preserve a6... we need this in a printer driver */
#asm
	move.l	a6,-(sp)
#endasm
	int result;

	dbprintf("DoSpecial:");

	switch (*command) {

	case aRIN: 
		/* start with initialization string */

		strcpy(outputBuffer,"\x1b\x1aI");

		/* set to ELITE mode on LETTER or ELITE spacing... */

		if (
		    (PD->pd_Preferences.PrintQuality == LETTER) ||
		    (PD->pd_Preferences.PrintPitch == ELITE)
		   )  strcat(outputBuffer,"\x1b*1");

		/* set to condensed mode if req'd */

	    	if (PD->pd_Preferences.PrintPitch == FINE)
			strcat(outputBuffer,"\x1b[");

		/* this might look backwards but it's not */
		/* the toshiba allows you to specify the spacing */
		/* in 48ths of an inch, 6/48 == 1/8, 8/48 == 1/6 */

		if (PD->pd_Preferences.PrintSpacing == SIX_LPI) {
			strcat(outputBuffer,"\x1b\x1e\x08");	/* 8 48ths */
			*currentVMI = 36;
			dbprintf(" VMI=36");
		}
		else {
			strcat(outputBuffer,"\x1b\x1e\x06");	/* 6 48ths */
			*currentVMI = 27;
			dbprintf(" VMI=27");
		}
		dbprintf(" aRIN\n");
		result = strlen(outputBuffer);
		break;
	

	case aVERP0:
		*currentVMI=27;
		dbprintf(" VMI=27\n");
		break;

	case aVERP1:
		*currentVMI=36;
		dbprintf(" VMI=36\n");
		break;

	default:
		dbprintf("req:%d\n",*command);
		break;
	}
#asm
	move.l	(sp)+,a6
#endasm
	return(result);
}
