X-Git-Url: http://git.draconx.ca/gitweb/rrace.git/blobdiff_plain/f6be82664a5b8e8bc34c048b56417b591dcd5a5e..071d6e37df30a93f6cebbe4ea7e5cd30655af546:/src/game.h diff --git a/src/game.h b/src/game.h index e5b9cbe..56fb442 100644 --- a/src/game.h +++ b/src/game.h @@ -1,6 +1,6 @@ /* * Slide puzzle core game logic - * Copyright © 2022 Nick Bowler + * Copyright © 2022-2023 Nick Bowler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ enum { #define GOAL_SHIFT 6 #define GOAL_MASK 0x739c0ul +#define GAME_MASK 0x1fffffful struct board { /* @@ -220,4 +221,21 @@ int_fast32_t game_elapsed(struct board *board); */ int_fast32_t game_finish(struct board *board); +/* + * Constructs a new set of game bitmaps into buf, with tiles in the + * objective area replaced by the goal tile colours, and returns buf. + */ +static inline uint_least32_t * +game_overlay_goal(struct board *board, uint_least32_t *buf) +{ + int i; + + for (i = 0; i < 3; i++) { + buf[i] = (unsigned long)board->goal[i] << GOAL_SHIFT; + buf[i] = (buf[i] & GOAL_MASK) | (board->game[i] & ~GOAL_MASK); + } + + return buf; +} + #endif