]> git.draconx.ca Git - rrace.git/blobdiff - src/game.h
Fix bitmap generation in goal overlay feature.
[rrace.git] / src / game.h
index efa7ef0fc95d229d1d045bde9ab45dce19348db4..56fb4427fcc18abb2b3d99abdfe98006b7143fbd 100644 (file)
@@ -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
@@ -221,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