/*
 *  CELLS       An Implementation of the WireWorld cellular automata
 *              as described in Scientific American, Jan 1990.
 *
 *              Copyright 1990 by Davide P. Cervone.
 *  You may use this code, provided this copyright notice is kept intact.
 *  See the CELLS.HELP file for complete information on distribution conditions.
 */

/*
 *  File:  Cells.h      Main header file
 */


#define INTUITION_PREFERENCES_H             /* don't need 'em */
#include <intuition/intuition.h>

#define INTUITION_REV   0
#define GRAPHICS_REV    0
#define DISKFONT_REV    0

#define ERROR_EXIT      10
#define OK_EXIT         0

#define SHIFTKEYS       (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)
#define ALTKEYS         (IEQUALIFIER_LALT|IEQUALIFIER_RALT)

#define CELLSIZE        6                   /* default initial cell size */
#define MINCELLSIZE     3                   /* smallest zoom out size */
#define MAXCELLSIZE     15                  /* largest zoom in size */


#define SCREEND         3                   /* screen depth */
#define SCREENW         320                 /*        width */
#define SCREENH         200                 /*        height */
#define WINDOWW         320                 /* window width */
#define WINDOWH         (SCREENH-10)        /*        height */
#define WINDOWX         0                   /*        x position */
#define WINDOWY         10                  /*        y position */

#define BOARDW          256                 /* width of grid area */
#define BOARDH          180                 /* height of grid area */

#define MAXGRIDW        ((BOARDW-1)/MINCELLSIZE)    /* max size (in cells) */
#define MAXGRIDH        ((BOARDH-1)/MINCELLSIZE)    /*   of entire grid */
#define ARRAYSIZE       (MAXGRIDW*MAXGRIDH)         /* size of grid arrays */

/*
 *  Pen numbers for specific functions
 */

#define BACKGROUND      0
#define HIGHLIGHT       1
#define FOREGROUND      2
#define SHADOW          3

#define POINTERPEN      18

#define BOXPEN          BACKGROUND
#define HIGHPEN         HIGHLIGHT
#define SELECTPEN       FOREGROUND
#define MOVEPEN         HIGHLIGHT
#define TEXTPEN         SHADOW
#define TEXTSELECT      5

#define GRID            BACKGROUND
#define BLANK           SHADOW
#define WIRE            7
#define HEAD            5
#define TAIL            4

/*
 *  MouseMove Types (i.e., what kind of action are mouse moves going to cause?)
 */

#define MM_NONE         0
#define MM_DRAW         1
#define MM_SELECT       2
#define MM_MOVE         3
#define MM_COPY         4

/*
 *  Select Type (i.e., what kind of selection is in effect?)
 */

#define SEL_NONE        0       /* no selection */
#define SEL_WAIT        1       /* waiting for start of selection or move */
#define SEL_BOX         2       /* select box being dragged */
#define SEL_CELLS       3       /* individual cells being selected */
#define SEL_REPOSITION  4       /* select box being repositioned */
#define SEL_MOVE        5       /* selection being moved */
#define SEL_COPY        6       /* selection being copied */

#ifndef MAX
#define MAX(x,y)        (((x)>(y))?(x):(y))
#define MIN(x,y)        (((x)<(y))?(x):(y))
#endif

/*
 *  flag number to flag bit mask
 *  (use MutualExclude field of gadgets for my own flags
 */

#define BIT(x)          (1<<(x))
#define MyFlags         MutualExclude

typedef void  (*FUNCTION)();

#define AllocMem        myAllocMem

extern struct IntuitionBase *IntuitionBase;
extern struct GfxBase *GfxBase; 
extern struct DiskfontBase *DiskfontBase;

extern struct Screen *myScreen;             /* the CELLS screen */
extern struct Window *myWindow;             /* the CELLS window */
extern struct RastPort *rp,*wrp,*irp;       /* some rast ports */
extern int DBufMode;                        /* TRUE if double buffering */
extern int BufferMouse;                     /* TRUE if collecting mouse moves */
extern struct ExtRequest *ActiveRequest;    /* requester in use */

extern struct Gadget cGadget[];             /* the main gadget list */
extern struct IntuiText cIText[];           /* the main gadget text list */
extern struct Border cBorder[];             /* the main border list */
extern struct Image cImage[];               /* the main image list */
extern struct PropInfo cSlider[];           /* the sliders */

extern int Running,QuitInProgress;          /* flags */
extern int Changed;
extern int SliderActive;

extern int SelectType;                      /* selection type */
extern int MouseMoveType;                   /* mouse move event type */
extern int ColorInUse,PenInUse;             /* current drawing color */

extern short CellSize;                      /* current cell size */
extern short GridX,GridY, GridW,GridH;      /* current (visible) grid size */
extern short BoardX,BoardY, BoardW,BoardH;  /*  and screen position (pixels) */
extern short MaxGridW,MaxGridH;             /* max for this cell size */

extern UBYTE *ResetArray,*UndoArray,*CurGen,*NewGen;    /* the state arrays */
extern int GenerationDelay;                 /* delay between generations */
