11 #define coord_raw(c) (c)
12 #define coord_x(c, b) ((c) % (b)->size)
13 #define coord_y(c, b) ((c) / (b)->size)
14 #define coord_eq(c1, c2) ((c1) == (c2))
16 static coord_t pass
= -1;
17 static coord_t resign
= -2;
18 #define is_pass(c) (coord_eq(c, pass))
19 #define is_resign(c) (coord_eq(c, resign))
21 /* Initialize existing coord */
22 #define coord_pos(coord, pos_, board) do { (coord) = (pos_); } while (0)
23 #define coord_xy(coord, x, y, board) coord_pos(coord, (x) + (y) * (board)->size, board)
24 #define coord_xy_otf(x, y, board) ((x) + (y) * (board)->size)
27 static coord_t
*coord_init(int x
, int y
, int size
);
28 static coord_t
*coord_copy(coord_t c
);
29 static coord_t
*coord_pass(void);
30 static coord_t
*coord_resign(void);
31 static void coord_done(coord_t
*c
);
34 char *coord2str(coord_t c
, struct board
*b
);
35 char *coord2sstr(coord_t c
, struct board
*b
);
36 coord_t
*str2coord(char *str
, int board_size
);
46 static inline coord_t
*
47 coord_init(int x
, int y
, int size
)
49 coord_t
*c
= calloc(1, sizeof(coord_t
));
54 static inline coord_t
*
57 coord_t
*c2
= calloc(1, sizeof(coord_t
));
58 memcpy(c2
, &c
, sizeof(c
));
62 static inline coord_t
*
65 return coord_copy(pass
);
68 static inline coord_t
*
71 return coord_copy(resign
);
75 coord_done(coord_t
*c
)