Skip to content
Browse files

making point.meta's bitfield type a little more natural

  • Loading branch information...
1 parent 5e7414a commit 3d6bd74cb9ad288a2079f3f0a69c33eff7cececb @beerriot committed Mar 3, 2011
Showing with 5 additions and 2 deletions.
  1. +3 −0 include/bggame.h
  2. +2 −2 src/bggame.c
View
3 include/bggame.h
@@ -25,6 +25,9 @@ typedef struct {
uint8_t meta;
} point_t;
+// metadata for point.meta bitfield
+#define PM_SELECTED 1
+
char bggame_random_piece(game_t game);
void bggame_board_init(game_t *game);
void bggame_move_cursor(game_t game,
View
4 src/bggame.c
@@ -80,7 +80,7 @@ void bggame_invalidate_selection(point_t *selection) {
}
uint8_t bggame_selection_is_active(point_t selection) {
- return selection.meta != 0;
+ return selection.meta & PM_SELECTED;
}
void bggame_clear_selection(game_t *game, point_t *selection) {
@@ -96,7 +96,7 @@ void bggame_set_selection(game_t *game,
point_t cursor) {
selection->row = cursor.row;
selection->column = cursor.column;
- selection->meta = 1;
+ selection->meta |= PM_SELECTED;
game->board[selection->row][selection->column] &= ~0x20;
lcd_goto_position(selection->row, selection->column);
lcd_write_data(game->board[selection->row][selection->column]);

0 comments on commit 3d6bd74

Please sign in to comment.
Something went wrong with that request. Please try again.