/*
 * $Id: aed.trm,v 1.6 1995/12/20 21:47:38 drd Exp $
 *
 */

/* GNUPLOT - aed.trm */
/*
 * Copyright (C) 1990 - 1993
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted, 
 * provided that the above copyright notice appear in all copies and 
 * that both that copyright notice and this permission notice appear 
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the modified code.  Modifications are to be distributed 
 * as patches to released version.
 *  
 * This software  is provided "as is" without express or implied warranty.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   AED terminals
 *
 * AUTHORS
 *     Colin Kelley, Thomas Williams, Russell Lang
 *
 * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
 * 
 */

/*
 * adapted to the new terminal layout by Stefan Bodewig (Dez. 1995)
 */

#ifndef GOT_DRIVER_H
#include "driver.h"
#endif

#ifdef TERM_REGISTER
register_term(aed512)
register_term(aed767)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void AED_init __P((void));
TERM_PUBLIC void AED_graphics __P((void));
TERM_PUBLIC void AED_text __P((void));
TERM_PUBLIC void AED_linetype __P((int linetype));
TERM_PUBLIC void AED_move __P((unsigned int x, unsigned int y));
TERM_PUBLIC void AED_vector __P((unsigned int x, unsigned int y));
TERM_PUBLIC void AED_put_text __P((unsigned int x, unsigned int y, char str[]));
TERM_PUBLIC void AED_reset __P((void));

#define AED_XMAX 768
#define AED_YMAX 575

#define AED_VCHAR	13
#define AED_HCHAR	8
#define AED_VTIC	8
#define AED_HTIC	7

/* slightly different for AED 512 */
#define AED5_XMAX 512
#endif

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY

#define AED_XLAST (AED_XMAX - 1)
#define AED_YLAST (AED_YMAX - 1)

#define AED5_XLAST (AED5_XMAX - 1)

TERM_PUBLIC void AED_init()
{
	fprintf(outfile,
	"\033SEN3DDDN.SEC.7.SCT.0.1.80.80.90.SBC.0.AAV2.MOV.0.9.CHR.0.FFD");
/*   2            3     4                5     7    6       1
	1. Clear Screen
	2. Set Encoding
	3. Set Default Color
	4. Set Backround Color Table Entry
	5. Set Backround Color
	6. Move to Bottom Lefthand Corner
	7. Anti-Alias Vectors
*/
}


TERM_PUBLIC void AED_graphics()
{
	fprintf(outfile,"\033FFD\033");
}


TERM_PUBLIC void AED_text()
{
	fprintf(outfile,"\033MOV.0.9.SEC.7.XXX");
}



TERM_PUBLIC void AED_linetype(linetype)
int linetype;
{
static int color[2+9] = { 7, 1, 6, 2, 3, 5, 1, 6, 2, 3, 5 };
static int type[2+9] = { 85, 85, 255, 255, 255, 255, 255, 85, 85, 85, 85 };

	if (linetype >= 10)
		linetype %= 10;
	fprintf(outfile,"\033SLS%d.255.",type[linetype+2]);
	fprintf(outfile,"\033SEC%d.",color[linetype+2]);
}



TERM_PUBLIC void AED_move(x,y)
unsigned int x,y;
{
	fprintf(outfile,"\033MOV%d.%d.",x,y);
}


TERM_PUBLIC void AED_vector(x,y)
unsigned int x,y;
{
	fprintf(outfile,"\033DVA%d.%d.",x,y);
}


TERM_PUBLIC void AED_put_text(x,y,str)
unsigned int x,y;
char str[];
{
	AED_move(x,y - AED_VCHAR/2 + 2);
	fprintf(outfile,"\033XXX%s\033",str);
}


#define hxt (AED_HTIC/2)
#define hyt (AED_VTIC/2)

TERM_PUBLIC void AED_reset()
{
	fprintf(outfile,"\033SCT0.1.0.0.0.SBC.0.FFD");
}

#endif /* TERM_BODY */

#ifdef TERM_TABLE
TERM_TABLE_START(aed512_driver)
    "aed512", "AED 512 Terminal",
	   AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
	   AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
	   AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
	   AED_linetype, AED_put_text, null_text_angle, 
	   null_justify_text, do_point, do_arrow, set_font_null
TERM_TABLE_END(aed512_driver)
#undef LAST_TERM
#define LAST_TERM aed512_driver

TERM_TABLE_START(aed767_driver)
    "aed767", "AED 767 Terminal",
	   AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
	   AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
	   AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
	   AED_linetype, AED_put_text, null_text_angle, 
	   null_justify_text, do_point, do_arrow, set_font_null
TERM_TABLE_END(aed767_driver)
#undef LAST_TERM
#define LAST_TERM aed767_driver

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

/*
 * NAME: aed512
 *
 * OPTIONS: none
 *
 * SUPPORTS: AED 512 Terminals
 *
 * Further Info: Looks like a plain graphics terminal driver, nothing
 *		 special.
 */
/*
 * NAME: aed767
 *
 * OPTIONS: none
 *
 * SUPPORTS: AED 767 Terminals
 *
 * Further Info: Also looks like a plain graphics terminal driver, nothing
 *		 special either. Only difference to aed512 is the
 *		 horizontal range.
 *
 */
