Commit | Line | Data |
---|---|---|
54f1c58c JB |
1 | /* |
2 | * ===================================================================================== | |
3 | * | |
4 | * Filename: debug.c | |
5 | * | |
6 | * Description: Debugging functions | |
7 | * | |
8 | * Version: 1.0 | |
9 | * Created: 27/04/2017 12:58:37 | |
10 | * Revision: none | |
11 | * Compiler: gcc | |
12 | * | |
13 | * Author: Jerome Benoit (fraggle), jerome.benoit@piment-noir.org | |
14 | * Organization: Piment Noir | |
15 | * | |
16 | * ===================================================================================== | |
17 | */ | |
18 | ||
19 | #include <string.h> | |
20 | ||
a80646b7 | 21 | #include "othello.h" |
54f1c58c JB |
22 | #include "debug.h" |
23 | ||
21e06607 JB |
24 | #if BUILD_TYPE == debug |
25 | void dbg_mvprintw(int y, int x, const char* debug_text, ...) { | |
26 | va_list func_args; | |
27 | char debug_msg[256]; | |
28 | ||
29 | snprintf(debug_msg, sizeof(debug_msg), "%s%s", "DEBUG: ", debug_text); | |
30 | va_start(func_args, debug_text); | |
31 | mvprintw(y, x, debug_msg, func_args); | |
32 | va_end(func_args); | |
33 | } | |
34 | #else | |
acd1c2e8 | 35 | void dbg_mvprintw(int y, int x, const char* debug_text, ...); |
21e06607 JB |
36 | #endif |
37 | ||
a80646b7 | 38 | void display_array(int base_y, int base_x, unsigned int pawn_array[board_size][board_size]) { |
54f1c58c | 39 | |
a80646b7 | 40 | for (int i = 1; i <= board_size; i++) { |
21e06607 | 41 | dbg_mvprintw(base_y + i, base_x, "%d", i); |
a80646b7 | 42 | for (int j = 1; j <= board_size; j++) { |
21e06607 JB |
43 | dbg_mvprintw(base_y, base_x + j, "%d", j); |
44 | dbg_mvprintw(base_y + i, base_x + j, "%d", get_box_value(i, j, pawn_array)); | |
a80646b7 JB |
45 | } |
46 | } | |
54f1c58c | 47 | } |