+ for (y = 0; y < LEVHEIGHT; y++)
+ for (x = 0; x < LEVWIDTH; x++)
+ if ((*level)[y][x] == BLOCK_EMPTY)
+ (*level)[y][x] = BLOCK_WALL;
+}
+\f
+
+/* Check to see if the x and y value are in the corners.
+ * we could probable compute these values once and avoid
+ * go through the loops every time.
+ */
+static void
+top_left (lev_t * level, unsigned int *passed_x, unsigned int *passed_y)
+{
+ int x, y;
+ for (y = 0; y < LEVHEIGHT; y++)
+ for (x = 0; x < LEVWIDTH; x++) {
+ if (checkset (level, x, y) == 0) {
+ *passed_x = x;
+ *passed_y = y;
+ return;
+ }
+ }
+}
+
+
+static void
+bottom_left (lev_t * level, unsigned int *passed_x, unsigned int *passed_y)
+{
+ int x, y;
+ for (y = LEVHEIGHT; y > -1; y--)
+ for (x = 0; x < LEVWIDTH; x++) {
+ if (checkset (level, x, y) == 0) {
+ *passed_x = x;
+ *passed_y = y;
+ return;
+ }
+ }
+}
+
+static void
+top_right (lev_t * level, unsigned int *passed_x, unsigned int *passed_y)
+{
+ int x, y;
+
+ for (y = 0; y < LEVHEIGHT; y++)
+ for (x = LEVWIDTH; x >= 0; x--) {
+ if (checkset (level, x, y) == 0) {
+ *passed_x = x;
+ *passed_y = y;
+ return;
+ }
+ }
+}
+
+static void
+bottom_right (lev_t * level, unsigned int *passed_x, unsigned int *passed_y)
+{
+ int x, y;
+
+ for (y = LEVHEIGHT; y >= 0; y--)
+ for (x = LEVWIDTH; x >= 0; x--) {
+ if (checkset (level, x, y) == 0) {
+ *passed_x = x;
+ *passed_y = y;
+ return;
+ }
+ }
+}
+
+static void
+init_bonus_dots (lev_t * level)
+{
+ unsigned int x, y;
+ top_left (level, &x, &y);
+ bonus_dots[TOP_LEFT].x = x;
+ bonus_dots[TOP_LEFT].y = y;
+ bonus_dots[TOP_LEFT].eaten = False;
+ top_right (level, &x, &y);
+ bonus_dots[TOP_RIGHT].x = x;
+ bonus_dots[TOP_RIGHT].y = y;
+ bonus_dots[TOP_RIGHT].eaten = False;
+ bottom_left (level, &x, &y);
+ bonus_dots[BOTTOM_LEFT].x = x;
+ bonus_dots[BOTTOM_LEFT].y = y;
+ bonus_dots[BOTTOM_LEFT].eaten = False;
+ bottom_right (level, &x, &y);
+ bonus_dots[BOTTOM_RIGHT].x = x;
+ bonus_dots[BOTTOM_RIGHT].y = y;
+ bonus_dots[BOTTOM_RIGHT].eaten = False;
+}
+
+int
+is_bonus_dot (int x, int y, int *idx)
+{
+ int ret = False;
+ int i;
+ for (i = 0; i <= NUM_BONUS_DOTS; i++) {
+/* fprintf(stderr,"is bonus: passed x (%d, %d) bonus (%d, %d)\n",x,y,bonus_dots[i].x, bonus_dots[i].y); */
+ if (x == bonus_dots[i].x && y == bonus_dots[i].y) {
+ ret = True;
+ *idx = i;
+ break;
+ }
+ }
+ return ret;
+}
+
+static void
+check_bonus_idx (int idx)
+{
+ assert (0 <= idx && idx <= NUM_BONUS_DOTS);
+}
+
+int
+bonus_dot_eaten (int idx)
+{
+ check_bonus_idx (idx);
+ return bonus_dots[idx].eaten;
+}
+
+void
+eat_bonus_dot (int idx)
+{
+ check_bonus_idx (idx);
+ bonus_dots[idx].eaten = True;
+}
+
+void
+bonus_dot_pos (int idx, int *x, int *y)
+{
+ check_bonus_idx (idx);
+ *x = bonus_dots[idx].x;
+ *y = bonus_dots[idx].y;