]> git.draconx.ca Git - rrace.git/blob - t/overlaygoal.c
Fix bitmap generation in goal overlay feature.
[rrace.git] / t / overlaygoal.c
1 /*
2  * Helper to test game_overlay_goal function.
3  * Copyright © 2023 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 <stdlib.h>
22 #include <string.h>
23 #include <errno.h>
24 #include "game.h"
25
26 #define X3(x) x x x
27
28 static const char *progname = "overlaygoal";
29
30 int main(int argc, char **argv)
31 {
32         struct board board;
33         int rc;
34
35         if (argc > 0)
36                 progname = argv[0];
37
38         while ((rc = scanf(X3("%" SCNxLEAST32) X3("%" SCNxLEAST16),
39                               &board.game[0], &board.game[1],
40                               &board.game[2], &board.goal[0],
41                               &board.goal[1], &board.goal[2])) == 6)
42         {
43                 uint_least32_t buf[3];
44
45                 game_overlay_goal(&board, buf);
46                 printf(X3(" %.7" PRIxLEAST32)"\n"+1, buf[0], buf[1], buf[2]);
47         }
48
49         if (rc == EOF) {
50                 if (ferror(stdin)) {
51                         fprintf(stderr, "%s: read error: %s\n", progname,
52                                         strerror(errno));
53                         return EXIT_FAILURE;
54                 }
55
56                 return EXIT_SUCCESS;
57         }
58
59         fprintf(stderr, "%s: invalid input sequence\n", progname);
60         return EXIT_FAILURE;
61 }