/***********************************************************************
 * 
 *  G F O ! 
 *  by Chee Chew
 *      and 
 *     Ken Duda 
 *
 *  (c) 1990
 *
 *  This software is free for distribution.  This notice, however, may 
 *  not be altered.
 *  
 *  Enjoy! (and punt... )
 *
 ***********************************************************************/


#define MAX_WLENGTH 10
#define MAX_WWIDTH 10
#define MAX_WDEPTH 20

#define MAX_BLENGTH 5
#define MAX_BWIDTH 5
#define MAX_BDEPTH 5

#define MAXPOINTS 100

typedef struct t_Object {
	int npoints;
	int x[MAXPOINTS], y[MAXPOINTS], z[MAXPOINTS], connect[MAXPOINTS];
	int length, width, depth;
	int filled[MAX_BLENGTH][MAX_BWIDTH][MAX_BDEPTH];
} Object;

typedef struct t_Well {
  XC *xc;
  struct t_Game *game;
  int length, width, depth;
  unsigned int valid_blocks;	/* Bit mask: what piece numbers are valid? */
  int filled[MAX_WLENGTH][MAX_WWIDTH][MAX_WDEPTH];
  int max_x, max_y;		/* These Projection parameters are */
  int center_x, center_y;	/* computed from the above quantities */
  int z_offset;			/* and the current window size */
  int x_adjust, y_adjust,	/* for shifting when the size is odd */
      z_adjust;
} Well;

typedef struct t_Block {
  Object *object;
  int x, y, z;
  int min_x, min_y, max_x, max_y; /* Screen coordinate bounding box for... */
} Block;
	
typedef struct t_Keydef {  
  char up, down , right ,left ,rotate1,  rotate2 , rotate3 , drop;
  char upright, upleft, downright, downleft;
} Keydef; 

typedef struct t_Game {
  XC *xc;
  Well *well;
  int emptydepth;
  int faces_required;
  int score;
  int faces;
  int round;
  int usecs;
  int started;
  Block *block; 
  Keydef *kd;
} Game;

Game *begin_game(XC *xc);
