Logo Search packages:      
Sourcecode: vgacardgames version File versions  Download package

spider.h

/*
 * Spider
 *
 * Copyright (C) Evan Harris, 1991, 1993, 1994
 *
 * Permission is granted to freely redistribute and modify this code,
 * providing the author(s) get credit for having written it.
 */

#include "common.h"


#define FROMSTOCK       -10
#define MOVEOFF               -11
#define TOFOUNDATION          -12
#define COLSPECBASE           -20

#define IMPOSSIBLE            0
#define POSSIBLE        1
#define DESIRABLE       2


#define POSN(col, row)        ((col) * 100 + (row))
#define ROW(pos)        ((pos) % 100)
#define COL(pos)        ((pos) / 100)
#define NOPOSN                -1


#define SPADES                0
#define CLUBS                 1
#define HEARTS                2
#define DIAMONDS        3

#define NUMSUITS        8

#define CARD(suit, type)      ((suit) * 13 + (type))
#define NOCARD                255
#define SUIT(card)            (((card) % 52) / 13)
#define TYPE(card)            ((card) % 13)
#define ISCARD(card)          ((card) >= 0 && (card) < 104)
#define ISBLACK(card)         (SUIT(card) == SPADES || SUIT(card) == CLUBS)
#define ISRED(card)           (SUIT(card) == HEARTS || SUIT(card) == DIAMONDS)

#define NUMCARDS        104
#define COLUMNS               10
#define STOCK                 (COLUMNS)
#define PILE                  (STOCK + 1)
#define FOUNDATION            (PILE + 1)

#define TOHINT(col)           (((col) + 1) << 7)
#define NOHINT(cmd)           ((cmd) & 0x7f)
#define HINT(hint)            (((hint) >> 7) - 1)
#define HASHINT(cmd)          ((cmd) & ~0x7f)


#define ISCOLSPEC(spec)       ((spec) <= COLSPECBASE)
#define COLTOSPEC(col)        (COLSPECBASE - (col))
#define SPECTOCOL(spec)       (COLSPECBASE - (spec))


#define ACE             0
#define TWO             1
#define THREE                 2
#define FOUR                  3
#define FIVE                  4
#define SIX             5
#define SEVEN                 6
#define EIGHT                 7
#define NINE                  8
#define TEN             9
#define JACK                  10
#define QUEEN                 11
#define KING                  12


extern unsigned char    column[COLUMNS];  /* First card of column */
extern unsigned char    stock, pile;            /* First card of stock, pile */
extern short            cards[NUMCARDS];  /* Positions of cards */
extern unsigned char    next[NUMCARDS];         /* Card underneath */
extern unsigned char    hidden[NUMCARDS]; /* Cards which are face down */
extern unsigned char    foundation[NUMSUITS];


void  main(int, char **);
void  exit(int);

void  InitDisplay(int, char **);
void  DisplayColumn(short);
void  DisplayFoundations(void);
void  DisplayStockPile(void);

void  Deal(void);

short GetCmd(void);
short FindDest(short);
short FindHintedDest(short, short);
void  MakeMove(unsigned char, short);
void  FromStock(void);
void  MoveOff(unsigned char);
short CanMoveOff(unsigned char);
short CheckFullTerminatingSuit(unsigned char);
void  AddUndo(unsigned char, unsigned char, short);
void  Undo(void);
void  UndoMove(unsigned char, short, unsigned char);
void  UndoMoveOff(unsigned char, short, unsigned char);
void  UndoFromStock(void);

Generated by  Doxygen 1.6.0   Back to index