44 lines
719 B
C
44 lines
719 B
C
#ifndef __TYPES_H_INC
|
|
#define __TYPES_H_INC
|
|
|
|
#include "Config.h""
|
|
|
|
#ifdef _ACF_DEBUG_PRINT
|
|
#define DEBUG(x) Serial.println(F(x)); Serial.flush()
|
|
#else
|
|
#define DEBUG(x)
|
|
#endif
|
|
|
|
enum Piece: byte {
|
|
P_EMPTY = 0b0000,
|
|
P_ANY = 0b1000,
|
|
|
|
W_PAWN = 0b0001,
|
|
W_KNGT = 0b0010,
|
|
W_KING = 0b0011,
|
|
W_BSHP = 0b0101,
|
|
W_ROOK = 0b0110,
|
|
W_QUEN = 0b0111,
|
|
|
|
B_PAWN = 0b1001,
|
|
B_KNGT = 0b1010,
|
|
B_KING = 0b1011,
|
|
B_BSHP = 0b1101,
|
|
B_ROOK = 0b1110,
|
|
B_QUEN = 0b1111,
|
|
};
|
|
|
|
const char CHAR_STRS[] PROGMEM = " pnkbrq PNKBRQ";
|
|
Piece char_to_piece(char c) {
|
|
for(byte i = 0; i < 0b1111; i++) {
|
|
if(pgm_read_byte_near(CHAR_STRS + i) == c)
|
|
return (Piece)i;
|
|
}
|
|
return P_EMPTY;
|
|
}
|
|
char piece_to_char(Piece p) {
|
|
return CHAR_STRS[p];
|
|
}
|
|
|
|
#endif
|