]> git.draconx.ca Git - rrace.git/blob - t/boardbit.c
6ecb6c6b3ad85c2e4a4202aeeafc41dd00d123c1
[rrace.git] / t / boardbit.c
1 /*
2  * Test board mask calculation functions.
3  * Copyright © 2022 Nick Bowler
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  */
18
19 #include <config.h>
20 #include <stdio.h>
21 #include "game.h"
22
23 enum { display_width = 12 };
24
25 static void show_patterns(const char *name, uint_fast32_t func(int))
26 {
27         unsigned long vals[5];
28         int i, row, labelw = display_width;
29
30         for (i = 0; i < 5; i++) {
31                 printf("%*s", display_width-labelw, "");
32                 labelw = printf("%2s(%d)", name, i);
33                 vals[i] = func(i);
34         }
35         putchar('\n');
36
37         for (row = 0; row < 5; row++) {
38                 putchar(' ');
39                 for (i = 0; i < 25; i++) {
40                         unsigned long val;
41         
42                         val = vals[i/5];
43                         vals[i/5] >>= 1;
44         
45                         if (i && i % 5 == 0)
46                                 printf("%*s", display_width-5, "");
47                         putchar(val & 1 ? '@' : '.');
48                         if (i == 24)
49                                 putchar('\n');
50                 }
51         }
52 }
53
54 int main(void)
55 {
56         show_patterns("left", board_left);
57         putchar('\n');
58         show_patterns("right", board_right);
59         putchar('\n');
60         show_patterns("above", board_above);
61         putchar('\n');
62         show_patterns("below", board_below);
63 }