X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lib%2Fdebug.c;h=ead321696671087f620e28e89ef5d71ec6071d4e;hb=21e06607a012704bed3c3b009fa76c4a7f973887;hp=e3229901502f1d0da3306b640faa1b57955ef5ef;hpb=54f1c58cef6764fdd611eedc267e7491e777c09b;p=Project_algorithmic_C.git diff --git a/lib/debug.c b/lib/debug.c index e322990..ead3216 100644 --- a/lib/debug.c +++ b/lib/debug.c @@ -18,9 +18,30 @@ #include +#include "othello.h" #include "debug.h" -void dbg_mvprintw(int base_y, int base_x, const char* fmt, va_list varglist) { +#if BUILD_TYPE == debug +void dbg_mvprintw(int y, int x, const char* debug_text, ...) { + va_list func_args; + char debug_msg[256]; - mvprintw(base_y, base_x - strlen(fmt)/2, fmt, varglist); + snprintf(debug_msg, sizeof(debug_msg), "%s%s", "DEBUG: ", debug_text); + va_start(func_args, debug_text); + mvprintw(y, x, debug_msg, func_args); + va_end(func_args); +} +#else +void dbg_mvprintw(int y, int x, const char* debug_text, ...) { } +#endif + +void display_array(int base_y, int base_x, unsigned int pawn_array[board_size][board_size]) { + + for (int i = 1; i <= board_size; i++) { + dbg_mvprintw(base_y + i, base_x, "%d", i); + for (int j = 1; j <= board_size; j++) { + dbg_mvprintw(base_y, base_x + j, "%d", j); + dbg_mvprintw(base_y + i, base_x + j, "%d", get_box_value(i, j, pawn_array)); + } + } }