piece: printf -> logX

This commit is contained in:
2021-11-04 10:01:07 +01:00
parent 0e117bc2f9
commit ad155b5a60
5 changed files with 13 additions and 15 deletions

3
.gitignore vendored
View File

@@ -6,3 +6,6 @@ fen
pool pool
piece piece
move move
debug
/test/
/obj/

View File

@@ -4,7 +4,7 @@
./obj/move.o:: src/move.c src/chessdefs.h src/piece.h src/board.h src/list.h \ ./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 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 \ ./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/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 \ ./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 src/list.h src/fen.h src/piece.h src/pool.h

View File

@@ -11,7 +11,6 @@
* *
*/ */
//#ifdef DEBUG
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h> #include <time.h>
@@ -56,7 +55,7 @@ inline static int64_t timer_elapsed()
/* void debug - log function /* void debug - log function
* @timestamp : boolean * @timestamp : boolean
* @indent : indent level (2 spaces each) * @indent : indent level (2 spaces each)
* @src : source filename (or NULL) * @src : source file/func name (or NULL)
* @line : line number * @line : line number
*/ */
void debug(uint32_t level, bool timestamp, uint32_t indent, const char *src, 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++); log_f(1, "log_f 5=%d\n", foo++);
} }
#endif #endif
//#endif /* DEBUG_H */

View File

@@ -15,6 +15,7 @@
#include "chessdefs.h" #include "chessdefs.h"
#include "piece.h" #include "piece.h"
#include "ctype.h" #include "ctype.h"
#include "debug.h"
static pool_t *pieces_pool; 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; piece_list_t *new;
short color = COLOR(piece); short color = COLOR(piece);
/* printf("%s: piece=%02x square=%02x\n", __func__, piece, square); # ifdef DEBUG_PIECE
printf("%s: Adding %s %s on %c%c\n", log_f(2, "piece=%02x square=%02x\n", piece, square);
__func__, log_f(5, "Adding %s %s on %c%c\n", color? "Black": "White",
color? "Black": "White", piece2string(piece), FILE2C(GET_F(square)), RANK2C(GET_R(square)));
piece2string(piece), # endif
FILE2C(GET_F(square)),
RANK2C(GET_R(square)));
*/
if ((new = pool_get(pieces_pool))) { if ((new = pool_get(pieces_pool))) {
//printf("color=%d addp=%p\n", COLOR(piece), &pos->pieces[COLOR(piece)]);
list_add_tail(&new->list, list_add_tail(&new->list,
color? &pos->pieces_black: &pos->pieces_white); color? &pos->pieces_black: &pos->pieces_white);
new->piece = piece; new->piece = piece;
@@ -101,10 +98,10 @@ int main(int ac, char**av)
{ {
pos_t *pos; pos_t *pos;
debug_init(5);
pos = pos_create(); pos = pos_create();
piece_pool_init(); piece_pool_init();
if (ac == 1) { if (ac == 1) {
pos_startpos(pos); pos_startpos(pos);
} else { } else {

View File

@@ -49,6 +49,7 @@ extern struct piece_details {
char *name; char *name;
int64_t value; int64_t value;
} piece_details[]; } piece_details[];
#define P_NAME(p) piece_details[PIECE(p)].name #define P_NAME(p) piece_details[PIECE(p)].name
#define P_LETTER(p) piece_details[PIECE(p)].abbrev_w #define P_LETTER(p) piece_details[PIECE(p)].abbrev_w
#define P_SYM(p) piece_details[PIECE(p)].symbol_b #define P_SYM(p) piece_details[PIECE(p)].symbol_b