/****************************************************************
 * 	universal include for my ChemNiMate program		*
 *								*
 *structures:							*
 *	DisplayInfo						*
 *	ParserInfo						*
 *								*
 *								*
 *==============================================================*
 *uni1	06Apr91	KvGend	created from ch5.c & parser2.c		 *
 *uni2  07Apr91 KvGend	added ParserInfo			 *
 *uni4	14Jun91	KvGend	removed some errornumbers, some structure*
 *			elements which weren't used anymore	 *
 *			removed.				 *
 *			fixed some macros to use (x) instead of x*
 *	28Aug91	KvGend	first release				 *
 *								 *
 *****************************************************************/

#include <stdio.h>

 /* calculate real coords on screen (displaymode 0).
  * y+ : to the right.
  * x- : to the front (is put diagonally to show 3d)
  * z+ : upwards.
  */
#define RX(y,x)         (di.mx+(y)-(x)/2)
#define RY(z,x)         (di.my-(z)+(x)/2)

#define FULLCRAZY -568932871	/*this is a crazy value, ain't it? */
#define ISNUM(x)   ((( (x)>='0'&&(x)<='9') ||(x)=='-') ? 1 : 0)
#define ABS(x)          ( (x)<0 ? -(x) : (x))

#define ARR	array[j]
#define RAD	[0]
#define ADD	[1]
#define HEIGHT	[2]
#define KIND	[3]
#define BIND	[4]
#define XC	[5]
#define YC	[6]
#define ZC	[7]


#define VWIDTH 340		/* width of viewport */
#define VHEIGHT 256

#define PWIDTH 380		/* width of the two bitmaps */
#define PHEIGHT 296
#define PDEPTH	3		/* 3 bitplanes means 8 colors. I think it's enough */

/* values of bitmap for sourcebitmap */
#define SWIDTH 320
#define SHEIGHT	96		/* it was only a brush */
#define SDEPTH 3

#define LBOR	((PWIDTH-VWIDTH)/2)
#define UBOR	((PHEIGHT-VHEIGHT)/2)

/* In this structure is information put about the display-system */
struct DisplayInfo
{
  int mx, my;			/* what is the centre of the screen? */
  int angle, dangle;		/* angle, delta angle (how turn around?)*/
  char modes;			/* draw lines/balls ? */
  int whichone;			/* which playfield is active at the moment?*/
};

#define VALUESMAX 8		/* maximum number of values in one line */
#define MXNUMB 64		/* maximum number of items in memory */

#define LINES 32
#define BALLS 64

/* In this structure is information put about the parsing */
struct ParserInfo
{
  int datanr;			/* which should next data-line be placed in ?*/
  int linenr;			/* current linenr in script file */
  int valnr;			/* number of values in current line */
  int error;			/* if an error occured, its number is here
				 * otherwise it will be -1 */
  int skip;			/* should a line be skipped? */
  int I;			/* some easy variables */
  int J;
};


#define ON	91		/* it doesn't matter WHAT these values are*/
#define OFF	97		/* as long as they're different from each other*/

#define USEPI   -1

#define INFINITYMAX 250

/***********************the error-numbers *****/
#define NOTNUMBER_ERR	0
#define EDWD_ERR	1
#define VAL_ERR		2
#define ERWR_ERR	3
#define DATA_ERR	4
#define HEADACHE_ERR	5
#define TOOFEW_ERR	6
#define TOOMUCH_ERR	7
#define OUTSCREEN_ERR	8
#define DIVISION_ERR	9	/*errors of evalexp*/
#define ITTAKESTWO_ERR	10
#define PARENTH_ERR	11
#define NOVAR_ERR	12	/*variables*/
#define VAREND_ERR	13
#define INFINITY_ERR	14
#define NOSKIP_ERR	15
#define DATAEXPR_ERR	16

#ifdef PARSER
char *errtxt[] =		/* the errors*/
{				/* all lines end in \0 because they aren't equal in length*/
  "# WARNING: NOT RIGHT NUMBER OF VALUES\0",
  "## EndData WITHOUT Data\0",
  "## INCORRECT VALUE(S) \0",
  "## EndRepeat/Until WITHOUT Repeat/Loop\0",
  "# WARNING: MORE / LESS THAN 5 data VALUES\0",
  "## SYNTAX ERROR\0",
  "## NEEDED # , BUT GOT ONLY # VALUES\0",	/* #1: 10, #2: 27 */
  "# WARNING : MORE THAN REQUIRED # VALUES\0",	/* #1: 31 */
  "# WARNING : ONE OF BALLS GOT OUT SCREEN\0",
  "## EXPRESSION: DIVISION BY ZERO \0",
  "## EXPRESSION: 2 VALUES AND 1 OF: +- * /\0",
  "## EXPRESSION: UNEQUAL NUMBER OF [ AND ]\0",
  "## NOT A KNOWN VARIABLE \0",
  "## VARIABLE NOT TERMINATED BY '#'\0",
  "### until : INFINITY ERROR\0",
  "## EndSkip WITHOUT Skip\0",
  "#### EXPRESSION IN A DATA LINE\0"
};
#else
extern char *errtxt[];		/*for other files than parser.c */
#endif


/* the amiga-specific stuff */
#ifdef AMIGA
#define RP		&rastport
#define BM		bitmap
#define SBM		&sourcebitmap
#define LINETO(x,y)     Draw(RP,x,y)
#define MOVE(x,y)       Move(RP,x,y)
#define COLOR(x)        SetAPen(RP,x)
#define TEXT(s)		Text(RP,s,strlen(s))
#define WAITFRAME	WaitTOF
#endif /* def AMIGA */


/* the defines for my stack-routine: */

#define ST_INIT 1
#define ST_PUSH 2
#define ST_POP	3
#define ST_QUIT	4
#define ST_NOST -1
#define STMAX	10

#define ST_REPEAT	0x02	/*stack was called from repeat*/
#define ST_LOOP		0x03
#define ST_GOSUB	0x04	/*stack was called from gosub */

/* end-of-file */
