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
piece
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 \
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

View File

@@ -11,7 +11,6 @@
*
*/
//#ifdef DEBUG
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
@@ -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 */

View File

@@ -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 {

View File

@@ -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