diff --git a/.gitignore b/.gitignore index b09654a..5f5d2ff 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ fen pool piece move +debug +/test/ +/obj/ diff --git a/make.deps b/make.deps index 9e9963b..7fa7bce 100644 --- a/make.deps +++ b/make.deps @@ -4,7 +4,7 @@ ./obj/move.o:: src/move.c src/chessdefs.h src/piece.h src/board.h src/list.h \ src/position.h src/pool.h src/move.h ./obj/piece.o:: src/piece.c src/chessdefs.h src/piece.h src/board.h src/list.h \ - src/position.h src/pool.h + src/position.h src/pool.h src/debug.h ./obj/pool.o:: src/pool.c src/list.h src/pool.h src/debug.h ./obj/position.o:: src/position.c src/chessdefs.h src/position.h src/board.h \ src/list.h src/fen.h src/piece.h src/pool.h diff --git a/src/debug.c b/src/debug.c index 4a78ffb..ca11303 100644 --- a/src/debug.c +++ b/src/debug.c @@ -11,7 +11,6 @@ * */ -//#ifdef DEBUG #include #include #include @@ -56,7 +55,7 @@ inline static int64_t timer_elapsed() /* void debug - log function * @timestamp : boolean * @indent : indent level (2 spaces each) - * @src : source filename (or NULL) + * @src : source file/func name (or NULL) * @line : line number */ void debug(uint32_t level, bool timestamp, uint32_t indent, const char *src, @@ -105,5 +104,3 @@ int main() log_f(1, "log_f 5=%d\n", foo++); } #endif - -//#endif /* DEBUG_H */ diff --git a/src/piece.c b/src/piece.c index f7e3b0e..28593bb 100644 --- a/src/piece.c +++ b/src/piece.c @@ -15,6 +15,7 @@ #include "chessdefs.h" #include "piece.h" #include "ctype.h" +#include "debug.h" static pool_t *pieces_pool; @@ -74,16 +75,12 @@ piece_list_t *piece_add(pos_t *pos, piece_t piece, square_t square) piece_list_t *new; short color = COLOR(piece); - /* printf("%s: piece=%02x square=%02x\n", __func__, piece, square); - printf("%s: Adding %s %s on %c%c\n", - __func__, - color? "Black": "White", - piece2string(piece), - FILE2C(GET_F(square)), - RANK2C(GET_R(square))); - */ +# ifdef DEBUG_PIECE + log_f(2, "piece=%02x square=%02x\n", piece, square); + log_f(5, "Adding %s %s on %c%c\n", color? "Black": "White", + piece2string(piece), FILE2C(GET_F(square)), RANK2C(GET_R(square))); +# endif if ((new = pool_get(pieces_pool))) { - //printf("color=%d addp=%p\n", COLOR(piece), &pos->pieces[COLOR(piece)]); list_add_tail(&new->list, color? &pos->pieces_black: &pos->pieces_white); new->piece = piece; @@ -101,10 +98,10 @@ int main(int ac, char**av) { pos_t *pos; + debug_init(5); pos = pos_create(); piece_pool_init(); - if (ac == 1) { pos_startpos(pos); } else { diff --git a/src/piece.h b/src/piece.h index 41d1c58..2c5bde2 100644 --- a/src/piece.h +++ b/src/piece.h @@ -49,6 +49,7 @@ extern struct piece_details { char *name; int64_t value; } piece_details[]; + #define P_NAME(p) piece_details[PIECE(p)].name #define P_LETTER(p) piece_details[PIECE(p)].abbrev_w #define P_SYM(p) piece_details[PIECE(p)].symbol_b