add license information & rename typedefs
This commit is contained in:
49
src/board.h
49
src/board.h
@@ -1,26 +1,35 @@
|
||||
/* board.h - board definitions.
|
||||
*
|
||||
* Copyright (C) 2021 Bruno Raoult ("br")
|
||||
* Licensed under the GNU General Public License v3.0 or later.
|
||||
* Some rights reserved. See COPYING.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this
|
||||
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.htmlL>.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H
|
||||
#define BOARD_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* ffff rrrr */
|
||||
typedef unsigned char SQUARE;
|
||||
#define SQUARE_F(s) ((s) >> 4)
|
||||
#define SQUARE_R(s) ((s) & 0x0f)
|
||||
#define SET_F(s, f) ((s) &= 0x0f, (s) |= (f)<<4)
|
||||
#define SET_R(s, r) ((s) &= 0xf0, (s) |= (r))
|
||||
#include "chessdefs.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned char piece;
|
||||
piece_t piece;
|
||||
//struct piece *s_piece;
|
||||
} BOARD[8*8*2]; /* 0x88 board */
|
||||
} board_t[8*8*2]; /* 0x88 board */
|
||||
|
||||
/* definitions for 0x88 representation */
|
||||
#define SQ88(f, r) (16 * (r) + (f))
|
||||
#define FILE88(s) ((s) & 7)
|
||||
#define RANK88(s) ((s) >> 8)
|
||||
/* definitions for 0x88 representation
|
||||
*/
|
||||
#define SQ88(f, r) (16 * (r) + (f)) /* from rank,file to sq88 */
|
||||
#define FILE88(s) ((s) & 7) /* from sq88 to file */
|
||||
#define RANK88(s) ((s) >> 8) /* from sq88 to rank */
|
||||
|
||||
/* piece notation */
|
||||
/* piece human notation
|
||||
*/
|
||||
#define CHAR_EMPTY ' '
|
||||
#define CHAR_PAWN 'P'
|
||||
#define CHAR_KNIGHT 'N'
|
||||
@@ -29,9 +38,13 @@ typedef struct {
|
||||
#define CHAR_QUEEN 'Q'
|
||||
#define CHAR_KING 'K'
|
||||
|
||||
#define C2FILE(c) (tolower(c)-'a')
|
||||
#define C2RANK(c) (tolower(c)-'1')
|
||||
#define FILE2C(c) ((c)+'a')
|
||||
#define RANK2C(c) ((c)+'1')
|
||||
/* from human to machine
|
||||
*/
|
||||
#define C2FILE(c) (tolower(c) - 'a')
|
||||
#define C2RANK(c) (tolower(c) - '1')
|
||||
/* from machine to human
|
||||
*/
|
||||
#define FILE2C(f) ((f) + 'a')
|
||||
#define RANK2C(r) ((r) + '1')
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user