Skip to content

Commit dc2c8d5

Browse files
committed
cleanup
1 parent addd984 commit dc2c8d5

File tree

1 file changed

+22
-85
lines changed

1 file changed

+22
-85
lines changed

minesweeper.c

Lines changed: 22 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef enum {
4343
} TileType;
4444

4545
typedef enum {
46-
FieldEmpty, // <-- same goes for this
46+
FieldEmpty,
4747
FieldMine
4848
} Field;
4949

@@ -99,121 +99,58 @@ static void render_callback(Canvas* const canvas, void* ctx) {
9999
furi_string_printf(timeStr, "%01d:%02d", minutes, seconds);
100100
canvas_draw_str_aligned(canvas, 128, 0, AlignRight, AlignTop, furi_string_get_cstr(timeStr));
101101

102+
uint8_t tile_to_draw;
103+
102104
for (int y = 0; y < PLAYFIELD_HEIGHT; y++) {
103105
for (int x = 0; x < PLAYFIELD_WIDTH; x++) {
104106
if ( x == minesweeper_state->cursor_x && y == minesweeper_state->cursor_y) {
105107
canvas_invert_color(canvas);
106108
}
107109
switch (minesweeper_state->playfield[x][y]) {
108110
case TileType0:
109-
canvas_draw_xbm(
110-
canvas,
111-
x*TILE_HEIGHT, // x
112-
8 + (y * TILE_WIDTH), // y
113-
TILE_WIDTH,
114-
TILE_HEIGHT,
115-
tile_0_bits);
111+
tile_to_draw = tile_0_bits;
116112
break;
117113
case TileType1:
118-
canvas_draw_xbm(
119-
canvas,
120-
x*TILE_HEIGHT, // x
121-
8 + (y * TILE_WIDTH), // y
122-
TILE_WIDTH,
123-
TILE_HEIGHT,
124-
tile_1_bits);
114+
tile_to_draw = tile_1_bits;
125115
break;
126116
case TileType2:
127-
canvas_draw_xbm(
128-
canvas,
129-
x*TILE_HEIGHT, // x
130-
8 + (y * TILE_WIDTH), // y
131-
TILE_WIDTH,
132-
TILE_HEIGHT,
133-
tile_2_bits);
117+
tile_to_draw = tile_2_bits;
134118
break;
135119
case TileType3:
136-
canvas_draw_xbm(
137-
canvas,
138-
x*TILE_HEIGHT, // x
139-
8 + (y * TILE_WIDTH), // y
140-
TILE_WIDTH,
141-
TILE_HEIGHT,
142-
tile_3_bits);
120+
tile_to_draw = tile_3_bits;
143121
break;
144122
case TileType4:
145-
canvas_draw_xbm(
146-
canvas,
147-
x*TILE_HEIGHT, // x
148-
8 + (y * TILE_WIDTH), // y
149-
TILE_WIDTH,
150-
TILE_HEIGHT,
151-
tile_4_bits);
123+
tile_to_draw = tile_4_bits;
152124
break;
153125
case TileType5:
154-
canvas_draw_xbm(
155-
canvas,
156-
x*TILE_HEIGHT, // x
157-
8 + (y * TILE_WIDTH), // y
158-
TILE_WIDTH,
159-
TILE_HEIGHT,
160-
tile_5_bits);
126+
tile_to_draw = tile_5_bits;
161127
break;
162128
case TileType6:
163-
canvas_draw_xbm(
164-
canvas,
165-
x*TILE_HEIGHT, // x
166-
8 + (y * TILE_WIDTH), // y
167-
TILE_WIDTH,
168-
TILE_HEIGHT,
169-
tile_6_bits);
129+
tile_to_draw = tile_6_bits;
170130
break;
171131
case TileType7:
172-
canvas_draw_xbm(
173-
canvas,
174-
x*TILE_HEIGHT, // x
175-
8 + (y * TILE_WIDTH), // y
176-
TILE_WIDTH,
177-
TILE_HEIGHT,
178-
tile_7_bits);
132+
tile_to_draw = tile_7_bits;
179133
break;
180134
case TileType8:
181-
canvas_draw_xbm(
182-
canvas,
183-
x*TILE_HEIGHT, // x
184-
8 + (y * TILE_WIDTH), // y
185-
TILE_WIDTH,
186-
TILE_HEIGHT,
187-
tile_8_bits);
135+
tile_to_draw = tile_8_bits;
188136
break;
189137
case TileTypeFlag:
190-
canvas_draw_xbm(
191-
canvas,
192-
x*TILE_HEIGHT, // x
193-
8 + (y * TILE_WIDTH), // y
194-
TILE_WIDTH,
195-
TILE_HEIGHT,
196-
tile_flag_bits);
138+
tile_to_draw = tile_flag_bits;
197139
break;
198140
case TileTypeUncleared:
199-
canvas_draw_xbm(
200-
canvas,
201-
x*TILE_HEIGHT, // x
202-
8 + (y * TILE_WIDTH), // y
203-
TILE_WIDTH,
204-
TILE_HEIGHT,
205-
tile_uncleared_bits);
141+
tile_to_draw = tile_uncleared_bits;
206142
break;
207143
case TileTypeMine:
208-
canvas_draw_xbm(
209-
canvas,
210-
x*TILE_HEIGHT, // x
211-
8 + (y * TILE_WIDTH), // y
212-
TILE_WIDTH,
213-
TILE_HEIGHT,
214-
tile_mine_bits);
144+
tile_to_draw = tile_mine_bits;
215145
break;
216146
}
147+
canvas_draw_xbm(
148+
canvas,
149+
x*TILE_HEIGHT, // x
150+
8 + (y * TILE_WIDTH), // y
151+
TILE_WIDTH,
152+
TILE_HEIGHT,
153+
tile_to_draw);
217154
if ( x == minesweeper_state->cursor_x && y == minesweeper_state->cursor_y) {
218155
canvas_invert_color(canvas);
219156
}

0 commit comments

Comments
 (0)