#define PC_PAWN_UNMOVED 1
#define PC_PAWN_MOVED 2
#define PC_ROOK 3
#define PC_KNIGHT 4
#define PC_BISHOP 5
#define PC_QUEEN 6
#define PC_KING 7

#define PC_WHITE 0x00
#define PC_BLACK 0x08
#define PC_MOVED 0x80 // for kings and rooks to know when castling is possible
#define PC_PAWN_ENPASS 0x40 // to indicate that this pawn can be killed via en passant
                            // set this bit at the end of double move
                            // unset this bit at the end of any other turn


struct board
{
  unsigned char tiles[8][8];
};

struct coord
{
  unsigned char row; // for memcmp() this struct must not contain bitfields
  unsigned char col;
};

#define TURN_WHITE 0
#define TURN_BLACK 1

struct move
{
  int32_t score;
  unsigned char ascend;
  struct coord src;
  struct coord dst;
  unsigned char checkmate_found;
  unsigned staledraw:1;
};

struct piece_all_moves
{
  unsigned char move_count;
  struct move *moves;
  struct coord *legal_moves;
};

struct game_position
{
  struct board board;
  unsigned turn:1;
};

#define LAST_MOVES_COUNT 0x100
#define LAST_MOVES_MASK 0xFF

struct last_moves
{
  struct game_position position[LAST_MOVES_COUNT];
  char last_moves_white[2][16];
  char last_moves_black[2][16];
  unsigned index:8;
};


struct game_status
{
  struct last_moves last_moves;
  unsigned moves_pawn_capture;
  unsigned turn:1;
};

struct piece_count
{
  unsigned char queen_count;
  unsigned char rook_count;
  unsigned char bishop_count;
  unsigned char knight_count;
  unsigned char pawn_count;
};

struct menuitem
{
  char *str;
  void (*fnptr)(void);
  struct menu *submenu;
  unsigned char *value;
  char **choices;
  unsigned char *minvalue;
  unsigned char *maxvalue;
  unsigned passive:1;
};

struct menu
{
  struct menuitem *menuitems;
  signed char menuitem_count;
  unsigned prev:1;
};



struct bitmap
{
  unsigned char height;
  unsigned char width;
  unsigned char *bitmap;
};

struct movekeys
{
  int up:1;
  int down:1;
  int left:1;
  int right:1;
};

struct entitybitmap
{
  unsigned char height;
  unsigned char width;
  unsigned char depth;
  unsigned char *front;
  unsigned char *right;
  unsigned char *left;
  unsigned char *back;
  unsigned char *bottom;
  unsigned char *top;
};

