/*
SVF	- svfcom.h
	(C) Copyright 1994-1995 by SoftSource.  All rights reserved.
Scott Sherman 9-94...

	definition of SVF (simple vector format)
*/

#ifndef SVFCOM_H
#define SVFCOM_H

/*	Intel		80x86	LITTLEENDIAN
	Motorola	680x0	BIGENDIAN
	Sun	Sparc	BIGENDIAN */
#if !defined(BIGENDIAN) && !defined(LITTLEENDIAN)
#error must define BIGENDIAN or LITTLEENDIAN
#endif

#ifndef TRUE
#define TRUE	1
#define FALSE	0
#endif

#define SVF_OFF	0
#define SVF_ON	1

/* convenience types */
typedef unsigned long ulong;
typedef unsigned short ushort;
typedef unsigned char uchar;
typedef int bool;

/* maximum allowable type for svf values */
typedef ushort svfvalue;
typedef short svfoffset;
typedef char *svfstring;
typedef uchar SVFCommands;
#define	SVF_MAX		(ushort)65535

/* SVF intro string */
#define SVF_HEADER	"SVF v1.10"


#define SVF_Error		253
#define SVF_Null		254

	/* commands */
#define SVF_FirstCommand	0	/* mark 1st command */
	/* header commands */
#define SVF_Name		1
#define SVF_Extents		2
#define SVF_ColorTable		3
#define SVF_Background		4
#define SVF_LayerTable		5
#define SVF_Width		7
#define SVF_NotifyTable		8
#define SVF_Transparent		9
#define SVF_Transform		10
#define SVF_Flags		11
#define SVF_LastHeaderCommand	12	/* mark last header command */
	/* commands in the main body */
#define SVF_Point		16
#define SVF_MoveTo		17
#define SVF_LineTo		18
#define SVF_Polyline		19
#define SVF_RelMoveTo		20
#define SVF_RelLineTo		21
#define SVF_RelPolyline		22
#define SVF_Rectangle		23
#define SVF_Circle		24
#define SVF_Arc			25
#define SVF_Bezier		26
#define SVF_Text		27
#define SVF_TextHeight		28
#define SVF_SetColor		29
#define SVF_SetLayer		30
#define SVF_SetPenWidth		31
#define SVF_FillMode		32
#define SVF_Data		34
#define SVF_1dLink	35
#define SVF_2dLink	36
#define SVF_Invisible	37
#define SVF_LastCommand		38	/* mark last command */

#define SVFLength	0xc0
#define SVFLength1or2	0x40
#define SVFLength4or8	0x80

#define CommandLength1(command)	(SVFCommands)(command & ~SVFLength1or2)
#define CommandLength2(command)	(SVFCommands)(command | SVFLength1or2)
#define CommandLength4(command)	(SVFCommands)(command | SVFLength4or8)
#define CommandLength8(command)	(SVFCommands)(command | SVFLength4or8 | SVFLength1or2)
#define GetCommandLength(command)	(1 << ((command & SVFLength) >> 6))
#define BasicCommand(command)	(SVFCommands)(command & ~SVFLength)

#define IsValidCommand(command) \
	( ((command > SVF_FirstCommand) && (command < SVF_LastCommand)) \
		|| ((command > SVF_FirstCommand | SVFLength) && (command < SVF_LastCommand | SVFLength)) )

#define IsCoordLength2(x)	(x > 255)
#define IsOffsetLength2(x)	(x > 127) || (x < -128)


	/* colors in the default palette */
#define SVFC_Black	0
#define SVFC_White	255

#define SVFC_Red		224
#define SVFC_Green	28
#define SVFC_Blue	3
#define SVFC_Yellow	252
#define SVFC_Cyan	31
#define SVFC_Magenta	227

#define SVFC_LightGray	219
#define SVFC_Gray	146
#define SVFC_DarkGray	73
#define SVFC_LightGrey	SVFC_LightGray
#define SVFC_Grey	SVFC_Gray
#define SVFC_DarkGrey	SVFC_DarkGray

#endif
