/* DEFNS.H
 * This file contains global definitions of structure members to be #included
 * file which needs them; no data is allocated storage here, and no extern
 * declarations appear. Instances of these data types are allocated in the
 * file DECL.C whose compiled form is linked with other modules. Various
 * #defines are also set up in here.
 */

struct	card
{
	unsigned n:4;	/* card number */
	unsigned s:2;	/* card suit */
};

struct	set
{
	struct	card	cards[15];
	USHORT	ncard;
};


struct	playerinfo
{
	USHORT	viewcard,manctrl;
	char	name[18];
	USHORT	level;	/* playing level */
	USHORT	wins;	/* number of hands won by player */
	USHORT	playernum;
	struct	Image	*cards; /* linked list of image structures of cards held */
	USHORT	nchld,xc,yc,score;	/* number of cards held */
	struct	card	hand[8];	/* cards held by player */
	USHORT	mem[53];	/* store location of each card */
	USHORT	turn;
};

struct custptr
{
	USHORT	*ptr;
	SHORT	h,w,x,y;
};

struct	suitset
{
	USHORT	nc;
	struct	card	c[16];
};

struct	numset
{
	USHORT	nc;
	struct	card	c[5];
};

struct	condset
{
	USHORT	ns,score,nd,ig,type,addtoset,uc;
	struct	card	set[10],dep[10];
};



/***** defines *****/
/* menus */
#define	FHEIGHT	8
#define	FWIDTH	8
#define	MENUCOL1	4
#define	MENUCOL2	1
#define	SMOS	10*FWIDTH
#define	SMVOS	FHEIGHT >> 1
/* smos = Sub menu (vertical) offset (from its menu item left edge)*/
#define	PROJMENU	0
#define	INTELLMENU	1
#define	DEBUGMENU	2
#define	VERIFYMENU	3

/* suits */
#define	DM	0
#define	HT	1
#define	CL	2
#define	SP	3
#define	JACK	11
#define	QUEEN	12
#define	KING	13
#define	ACE	1
#define	CARDW	64
#define	CARDH	48


/* memory cell location flags */
#define	UNKNOWN	0
#define	PREVPLRHOLDS	1
#define	CURRPLRHOLDS	2
#define	NEXTPLRHOLDS	4
#define	PREVPLRDROPD	8
#define	CURRPLRDROPD	16
#define	NEXTPLRDROPD	32
#define	GONEPAST	64
#define	INFUPSET	128

/* gadget defintions */
#define	FUPX	94
#define	FUPY	14
#define	FDPX	10
#define	FDPY	14

/* gadget ids */
#define	N1G	0
#define	N2G	1
#define	N3G	2
#define	CONTG	3
#define	SUBMITG	4
#define	FUPG	5
#define	FDPG	6
#define	NHANDG	7
#define	ADDG	8

#define	HANDG1	31
#define	HANDG2	32
#define	HANDG3	33
#define	HANDG4	34
#define	HANDG5	35
#define	HANDG6	36
#define	HANDG7	37

#define	SETGAD0	40
#define	SETGAD1	41
#define	SETGAD2	42
#define	SETGAD3	43
#define	SETGAD4	44
#define	SETGAD5	45

#define	PROCG	100

#define	MMSETFG	110
#define	MMACCEPTG	111
#define	MMCANCELG	112
#define	CARDG	5000

#define	MDAUTODG	200
#define	MDACCEPTG	201

/* position of display areas */
#define	P1DX	0
#define	P2DX	0
#define	P3DX	0
#define	P1DY	71
#define	P2DY	131
#define	P3DY	191
#define	IDX	0
#define	IDY	0
#define	SCTPX	180
#define	SCTPY	14
#define	HVTPX	180
#define	HVTPY	23
#define	NWTPX	180
#define	NWTPY	32
#define	NGPX	175
#define	NGPY	1
#define	MESX	180
#define	MESY	30
#define	NHGADX	170+15*FWIDTH
#define	NHGADY	39
#define	HANDLEFT	106
#define	HANDTOP	2

/*defines used in accessing initpack[]/shufpack[]*/
#define	BEFOREHAND	0
#define	BEFOREGAME	1

/*macros for accessing packs and hands of cards*/
#define	NEXTFDP	fdptc==1 ? rvspk() : fdp[fdptc--]
#define	PUTFDP(card)	 fdp[++fdptc]=card
#define	NEXTFUP	fuptc==0?nulcard:fup[fuptc--]
#define	PUTFUP(card)	fup[++fuptc]=card
#define	NEXTPLC(plrinfo)	plrinfo->nchld==0?nulcard:plrinfo->hand[plrinfo->nchld--]
#define	PUTPLC(plrinfo,card)	plrinfo->hand[++plrinfo->nchld]=card

#define	CARD(n,s)	((s)*13+(n))
#define	CARD2(c)	((c).s*13+(c).n)
#define	WAITCONT	for(cont=0;!cont && !quit && !exgm;) {Wait(1<<mp->mp_SigBit); ReplyMsg(GetMsg(mp));}
#define	TXTOUT(x,y,f,b,t)	gt.FrontPen=(f);gt.BackPen=(b);gt.IText=(UBYTE *)(t);PrintIText(wind->RPort,&gt,x,y);
#define	DRAWFUP	DrawImage(wind->RPort,packim[0][CARD2(fup[fuptc])],FUPX,FUPY);
#define	CDEQU(c1,c2)	((c1).n==(c2).n && (c1).s==(c2).s)
#define	DRAWFDP	DrawImage(wind->RPort,packim[0][CARD2(fdp[fdptc])],FDPX,FDPY);
#define	REMHAND(p)	DrawImage(wind->RPort,&handrem,0,(p)->yc+HANDTOP);


/* ptr stack macros */
#define	SETPTR(p)	SetPointer(wind,(p).ptr,(p).h,(p).w,(p).x,(p).y);

#define	ISNUL(c) ((c).n==0)
#define NOTSET	0
#define	SUITSET	1
#define	NUMSET	2
#define	SUB	4
#define	ADD	8
#define	TOSTART	16
#define	TOEND	32
