// This is defines.h CVS version: $Id: defines.h,v 1.2 2000/02/28 18:06:24 andreaha Exp $
#ifndef defines_h_included
#define defines_h_included

/* #define DEBUG */

#include "vars.h"

/********************************************************************/
/********************************************************************/
/* MACRO DEFINITIONS */
/********************************************************************/
/********************************************************************/

#ifdef DEBUG
#define DEB(a) a;
#else
#define DEB(a)
#endif

#ifdef DEBUG

#define dpush1(a) {                                   \
   debugptr = &firstdebug;                            \
   sprintf(temp, "%14s:%5d | ", __FILE__, __LINE__);  \
   strcat(temp, a);                                   \
   while (debugptr->next) debugptr = debugptr->next;  \
   debugptr->next = new DEbug(temp);                  \
   debugptr->next->prev = debugptr; }

#define dpush2(a,b) {                                 \
   debugptr = &firstdebug;                            \
   sprintf(temp, "%14s:%5d | ", __FILE__, __LINE__);  \
   sprintf(temp2, a, b);                              \
   strcat(temp, temp2);                               \
   while (debugptr->next) debugptr = debugptr->next;  \
   debugptr->next = new DEbug(temp);                  \
   debugptr->next->prev = debugptr; }

#define dpush3(a,b,c) {                               \
   debugptr = &firstdebug;                            \
   sprintf(temp, "%14s:%5d | ", __FILE__, __LINE__);  \
   sprintf(temp2, a, b, c);                           \
   strcat(temp, temp2);                               \
   while (debugptr->next) debugptr = debugptr->next;  \
   debugptr->next = new DEbug(temp);                  \
   debugptr->next->prev = debugptr; }

#define dpush4(a,b,c,d) {                             \
   debugptr = &firstdebug;                            \
   sprintf(temp, "%14s:%5d | ", __FILE__, __LINE__);  \
   sprintf(temp2, a, b, c, d);                        \
   strcat(temp, temp2);                               \
   while (debugptr->next) debugptr = debugptr->next;  \
   debugptr->next = new DEbug(temp);                  \
   debugptr->next->prev = debugptr; }

#define dpush5(a,b,c,d,e) {                           \
   debugptr = &firstdebug;                            \
   sprintf(temp, "%14s:%5d | ", __FILE__, __LINE__);  \
   sprintf(temp2, a, b, c, d, e);                     \
   strcat(temp, temp2);                               \
   while (debugptr->next) debugptr = debugptr->next;  \
   debugptr->next = new DEbug(temp);                  \
   debugptr->next->prev = debugptr; }

#define dpush6(a,b,c,d,e,f) {                         \
   debugptr = &firstdebug;                            \
   sprintf(temp, "%14s:%5d | ", __FILE__, __LINE__);  \
   sprintf(temp2, a, b, c, d, e, f);                  \
   strcat(temp, temp2);                               \
   while (debugptr->next) debugptr = debugptr->next;  \
   debugptr->next = new DEbug(temp);                  \
   debugptr->next->prev = debugptr; }

#define dpop() {                                      \
   debugptr = &firstdebug;                            \
   while (debugptr->next) debugptr = debugptr->next;  \
   if (debugptr == &firstdebug) {                     \
     printf("Stack overflow. Exiting.\n");            \
     exit(1);                                         \
   } else {                                           \
     debugptr->prev->next = NULL;                     \
     delete debugptr;                                 \
   }}

#else
#define dpush1(a) {}
#define dpush2(a,b) {}
#define dpush3(a,b,c) {}
#define dpush4(a,b,c,d) {}
#define dpush5(a,b,c,d,e) {}
#define dpush6(a,b,c,d,e,f) {}
#define dpop()   {}
#endif

#define error(a) { printf("\n******** Errorsignal is set. Exiting. \n");     \
                   printf("******** Compile with -dDEBUG to find error.\n"); \
                   printf("******** Message: \"%s\"\n\n", a);                \
	           exit(0); }
#define error2(a,b) {printf("\n******** Errorsignal is set. Exiting. \n");   \
                   printf("******** Compile with -dDEBUG to find error.\n"); \
                   printf("******** Message: \"");                           \
                   printf(a,b); printf("\"\n\n");                            \
	           exit(0); }

#ifdef DEBUG

#define debug(a) {                                                 \
         printf(a);                                                \
         if ((a[strlen(a)-1] != '\n')&&(a[strlen(a)-1] != ';'))    \
           printf("\n"); }

#define debug2(a,b) {                                              \
         printf(a,b);                                              \
         if ((a[strlen(a)-1] != '\n')&&(a[strlen(a)-1] != ';'))    \
           printf("\n"); }

#define debug3(a,b,c) {                                            \
         printf(a,b,c);                                            \
         if ((a[strlen(a)-1] != '\n')&&(a[strlen(a)-1] != ';'))    \
           printf("\n"); }

#define debug4(a,b,c,d) {                                          \
         printf(a,b,c,d);                                          \
         if ((a[strlen(a)-1] != '\n')&&(a[strlen(a)-1] != ';'))    \
           printf("\n"); }

#else
#define debug(a) {}
#define debug2(a,b) {}
#define debug3(a,b,c) {}
#define debug4(a,b,c,d) {}
#endif

#ifdef OUTPUT
#define print(a) { printf(a); }
#define print2(a,b) { printf(a,b); }
#define print3(a,b,c) { printf(a,b,c); }
#define print4(a,b,c,d) { printf(a,b,c,d); }
#define print5(a,b,c,d,e) { printf(a,b,c,d,e); }
#define print6(a,b,c,d,e,f) { printf(a,b,c,d,e,f); }
#else
#define print(a) {}
#define print2(a,b) {}
#define print3(a,b,c) {}
#define print4(a,b,c,d) {}
#define print5(a,b,c,d,e) {}
#define print6(a,b,c,d,e,f) {}
#endif

/********************************************************************/
/********************************************************************/
/* DEFINES FROM PIXLOADER */
/********************************************************************/
/********************************************************************/

#ifndef byte
#define byte unsigned char
#define word unsigned short int
#define dword unsigned int
#endif

#define NOFILL       0x10000000
#define PLAIN        0x20000000
#define TEXTURE      0x40000000

#define GOURAUD      0x01000000
#define FAKEPHONG    0x02000000
#define METAL        0x04000000

#define MIP          0x00100000
#define TRANSPARENT  0x00200000
#define REFRACT      0x00400000
#define BUMP         0x00800000
#define PERSPECTIVE  0x00010000

#define PHONG FAKEPHONG

#endif


