summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/bitmaps/mono/SOURCES9
-rwxr-xr-xapps/plugins/bitmaps/mono/flipit_cursor.16x13x1.bmpbin0 -> 116 bytes
-rwxr-xr-xapps/plugins/bitmaps/mono/flipit_cursor.25x25x1.bmpbin0 -> 162 bytes
-rw-r--r--apps/plugins/bitmaps/native/SOURCES27
-rwxr-xr-xapps/plugins/bitmaps/native/flipit_cursor.25x25x16.bmpbin0 -> 1954 bytes
-rwxr-xr-xapps/plugins/bitmaps/native/flipit_cursor.40x40x16.bmpbin0 -> 4854 bytes
-rwxr-xr-xapps/plugins/bitmaps/native/flipit_cursor.56x56x16.bmpbin0 -> 9462 bytes
-rwxr-xr-xapps/plugins/bitmaps/native/flipit_tokens.16x26x1.bmpbin0 -> 1302 bytes
-rw-r--r--apps/plugins/bitmaps/native/flipit_tokens.20x20x2.bmpbin3654 -> 0 bytes
-rwxr-xr-xapps/plugins/bitmaps/native/flipit_tokens.25x50x16.bmpbin0 -> 3854 bytes
-rwxr-xr-xapps/plugins/bitmaps/native/flipit_tokens.25x50x2.bmpbin0 -> 2478 bytes
-rw-r--r--apps/plugins/bitmaps/native/flipit_tokens.30x30.bmpbin8334 -> 0 bytes
-rw-r--r--apps/plugins/bitmaps/native/flipit_tokens.30x30x2.bmpbin8334 -> 0 bytes
-rw-r--r--apps/plugins/bitmaps/native/flipit_tokens.40x40.bmpbin14454 -> 0 bytes
-rwxr-xr-xapps/plugins/bitmaps/native/flipit_tokens.40x80x16.bmpbin0 -> 9654 bytes
-rw-r--r--apps/plugins/bitmaps/native/flipit_tokens.50x50.bmpbin22854 -> 0 bytes
-rwxr-xr-xapps/plugins/bitmaps/native/flipit_tokens.56x112x16.bmpbin0 -> 18870 bytes
-rw-r--r--apps/plugins/flipit.c192
18 files changed, 74 insertions, 154 deletions
diff --git a/apps/plugins/bitmaps/mono/SOURCES b/apps/plugins/bitmaps/mono/SOURCES
index 9dfc312348..75b85d1546 100644
--- a/apps/plugins/bitmaps/mono/SOURCES
+++ b/apps/plugins/bitmaps/mono/SOURCES
@@ -32,4 +32,13 @@ brickmania_powerups.112x64x1.bmp
32rockblox_background.112x64x1.bmp 32rockblox_background.112x64x1.bmp
33#endif 33#endif
34 34
35/* Flip it */
36#ifndef HAVE_LCD_COLOR
37#if LCD_WIDTH >= 125 && LCD_HEIGHT >= 110
38flipit_cursor.25x25x1.bmp
39#elif LCD_WIDTH >= 80 && LCD_HEIGHT >= 62
40flipit_cursor.16x13x1.bmp
41#endif
42#endif
43
35#endif /* HAVE_LCD_BITMAP */ 44#endif /* HAVE_LCD_BITMAP */
diff --git a/apps/plugins/bitmaps/mono/flipit_cursor.16x13x1.bmp b/apps/plugins/bitmaps/mono/flipit_cursor.16x13x1.bmp
new file mode 100755
index 0000000000..38db15aa95
--- /dev/null
+++ b/apps/plugins/bitmaps/mono/flipit_cursor.16x13x1.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/mono/flipit_cursor.25x25x1.bmp b/apps/plugins/bitmaps/mono/flipit_cursor.25x25x1.bmp
new file mode 100755
index 0000000000..5445f8b01d
--- /dev/null
+++ b/apps/plugins/bitmaps/mono/flipit_cursor.25x25x1.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/SOURCES b/apps/plugins/bitmaps/native/SOURCES
index c5729a09b7..c7eaa91751 100644
--- a/apps/plugins/bitmaps/native/SOURCES
+++ b/apps/plugins/bitmaps/native/SOURCES
@@ -127,18 +127,23 @@ sokoban_tiles.6x6x2.bmp
127 127
128/* Flip it */ 128/* Flip it */
129#ifdef HAVE_LCD_COLOR 129#ifdef HAVE_LCD_COLOR
130#if LCD_HEIGHT >= 200 130#if LCD_WIDTH >= 280 && LCD_HEIGHT >= 234
131flipit_tokens.50x50.bmp 131flipit_cursor.56x56x16.bmp
132#elif LCD_HEIGHT >= 160 132flipit_tokens.56x112x16.bmp
133flipit_tokens.40x40.bmp 133#elif LCD_WIDTH >= 200 && LCD_HEIGHT >= 170
134#else 134flipit_cursor.40x40x16.bmp
135flipit_tokens.30x30.bmp 135flipit_tokens.40x80x16.bmp
136#elif LCD_WIDTH >= 125 && LCD_HEIGHT >= 110
137flipit_cursor.25x25x16.bmp
138flipit_tokens.25x50x16.bmp
136#endif 139#endif
137#elif LCD_DEPTH >= 2 140#elif LCD_DEPTH > 1 /* greyscale */
138#if LCD_WIDTH >= 150 141#if LCD_WIDTH >= 125 && LCD_HEIGHT >= 110
139flipit_tokens.30x30x2.bmp 142flipit_tokens.25x50x2.bmp
140#else 143#endif
141flipit_tokens.20x20x2.bmp 144#else /* monochrome */
145#if LCD_WIDTH >= 80 && LCD_HEIGHT >= 62
146flipit_tokens.16x26x1.bmp
142#endif 147#endif
143#endif 148#endif
144 149
diff --git a/apps/plugins/bitmaps/native/flipit_cursor.25x25x16.bmp b/apps/plugins/bitmaps/native/flipit_cursor.25x25x16.bmp
new file mode 100755
index 0000000000..faa81518f8
--- /dev/null
+++ b/apps/plugins/bitmaps/native/flipit_cursor.25x25x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_cursor.40x40x16.bmp b/apps/plugins/bitmaps/native/flipit_cursor.40x40x16.bmp
new file mode 100755
index 0000000000..d91a363a99
--- /dev/null
+++ b/apps/plugins/bitmaps/native/flipit_cursor.40x40x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_cursor.56x56x16.bmp b/apps/plugins/bitmaps/native/flipit_cursor.56x56x16.bmp
new file mode 100755
index 0000000000..7fffb25a15
--- /dev/null
+++ b/apps/plugins/bitmaps/native/flipit_cursor.56x56x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.16x26x1.bmp b/apps/plugins/bitmaps/native/flipit_tokens.16x26x1.bmp
new file mode 100755
index 0000000000..fcf164b336
--- /dev/null
+++ b/apps/plugins/bitmaps/native/flipit_tokens.16x26x1.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.20x20x2.bmp b/apps/plugins/bitmaps/native/flipit_tokens.20x20x2.bmp
deleted file mode 100644
index 5dbae762c9..0000000000
--- a/apps/plugins/bitmaps/native/flipit_tokens.20x20x2.bmp
+++ /dev/null
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.25x50x16.bmp b/apps/plugins/bitmaps/native/flipit_tokens.25x50x16.bmp
new file mode 100755
index 0000000000..deca4c7410
--- /dev/null
+++ b/apps/plugins/bitmaps/native/flipit_tokens.25x50x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.25x50x2.bmp b/apps/plugins/bitmaps/native/flipit_tokens.25x50x2.bmp
new file mode 100755
index 0000000000..e2db260483
--- /dev/null
+++ b/apps/plugins/bitmaps/native/flipit_tokens.25x50x2.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.30x30.bmp b/apps/plugins/bitmaps/native/flipit_tokens.30x30.bmp
deleted file mode 100644
index 7aa7748282..0000000000
--- a/apps/plugins/bitmaps/native/flipit_tokens.30x30.bmp
+++ /dev/null
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.30x30x2.bmp b/apps/plugins/bitmaps/native/flipit_tokens.30x30x2.bmp
deleted file mode 100644
index 63262b5f65..0000000000
--- a/apps/plugins/bitmaps/native/flipit_tokens.30x30x2.bmp
+++ /dev/null
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.40x40.bmp b/apps/plugins/bitmaps/native/flipit_tokens.40x40.bmp
deleted file mode 100644
index b50245edde..0000000000
--- a/apps/plugins/bitmaps/native/flipit_tokens.40x40.bmp
+++ /dev/null
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.40x80x16.bmp b/apps/plugins/bitmaps/native/flipit_tokens.40x80x16.bmp
new file mode 100755
index 0000000000..38975020fd
--- /dev/null
+++ b/apps/plugins/bitmaps/native/flipit_tokens.40x80x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.50x50.bmp b/apps/plugins/bitmaps/native/flipit_tokens.50x50.bmp
deleted file mode 100644
index bc2c543b39..0000000000
--- a/apps/plugins/bitmaps/native/flipit_tokens.50x50.bmp
+++ /dev/null
Binary files differ
diff --git a/apps/plugins/bitmaps/native/flipit_tokens.56x112x16.bmp b/apps/plugins/bitmaps/native/flipit_tokens.56x112x16.bmp
new file mode 100755
index 0000000000..c56f9daae2
--- /dev/null
+++ b/apps/plugins/bitmaps/native/flipit_tokens.56x112x16.bmp
Binary files differ
diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c
index 7d423335d3..0b9878856c 100644
--- a/apps/plugins/flipit.c
+++ b/apps/plugins/flipit.c
@@ -105,169 +105,73 @@ static struct plugin_api* rb;
105static int spots[20]; 105static int spots[20];
106static int toggle[20]; 106static int toggle[20];
107static int cursor_pos, moves; 107static int cursor_pos, moves;
108static char s[5];
109 108
110#if LCD_DEPTH >= 2 109#include "flipit_cursor.h"
111 110#include "flipit_tokens.h"
112#ifdef HAVE_LCD_COLOR
113
114#if LCD_HEIGHT >= 200
115#define tksize 50
116#elif LCD_HEIGHT >=160
117#define tksize 40
118#else
119#define tksize 30
120#endif
121
122#else
123
124#if LCD_WIDTH >= 150
125#define tksize 30
126#else
127#define tksize 20
128#endif
129
130#endif
131
132extern const fb_data flipit_tokens[];
133
134#else
135
136static char *ptr;
137
138#define tksize 16
139
140static unsigned char spot_pic[2][28] = {
141 { 0xe0, 0xf8, 0xfc, 0xfe, 0xfe, 0xff, 0xff,
142 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xe0,
143 0x01, 0x07, 0x0f, 0x1f, 0x1f, 0x3f, 0x3f,
144 0x3f, 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x01 },
145 { 0xe0, 0x18, 0x04, 0x02, 0x02, 0x01, 0x01,
146 0x01, 0x01, 0x02, 0x02, 0x04, 0x18, 0xe0,
147 0x01, 0x06, 0x08, 0x10, 0x10, 0x20, 0x20,
148 0x20, 0x20, 0x10, 0x10, 0x08, 0x06, 0x01 }
149};
150static unsigned char cursor_pic[32] = {
151 0x55, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
152 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xaa,
153 0x55, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80,
154 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xaa };
155#endif
156
157#define INFO_WIDTH 32
158
159#if LCD_WIDTH - 5*tksize - INFO_WIDTH < 0
160# define INFO_UNDER
161# undef INFO_WIDTH
162# define INFO_WIDTH 60
163# define GRID_LEFT ((LCD_WIDTH-5*tksize)/2)
164# define GRID_TOP 0
165#else
166# define GRID_LEFT 0
167# define GRID_TOP ((LCD_HEIGHT-4*tksize)/2)
168#endif
169 111
112#define PANEL_HEIGHT 12
113#define TK_WIDTH BMPWIDTH_flipit_cursor
114#define TK_HEIGHT BMPHEIGHT_flipit_cursor
115#define TK_SPACE MAX(0, MIN((LCD_WIDTH - 5*TK_WIDTH)/4, \
116 (LCD_HEIGHT - PANEL_HEIGHT - 4*TK_HEIGHT)/4))
117#define GRID_WIDTH (5*TK_WIDTH + 4*TK_SPACE)
118#define GRID_LEFT ((LCD_WIDTH - GRID_WIDTH)/2)
119#define GRID_HEIGHT (4*TK_HEIGHT + 4*TK_SPACE) /* includes grid-panel space */
120#define GRID_TOP MAX(0, ((LCD_HEIGHT - PANEL_HEIGHT - GRID_HEIGHT)/2))
170 121
171/* draw a spot at the coordinates (x,y), range of p is 0-19 */ 122/* draw a spot at the coordinates (x,y), range of p is 0-19 */
172static void draw_spot(int p) { 123static void draw_spot(int p)
173#if LCD_DEPTH >= 2 124{
174 rb->lcd_bitmap_part( flipit_tokens, 0, spots[p]*tksize, tksize, 125 rb->lcd_bitmap_part( flipit_tokens, 0, spots[p] * TK_HEIGHT, TK_WIDTH,
175 (p%5)*tksize+GRID_LEFT, (p/5)*tksize+GRID_TOP, 126 GRID_LEFT + (p%5) * (TK_WIDTH+TK_SPACE),
176 tksize, tksize ); 127 GRID_TOP + (p/5) * (TK_HEIGHT+TK_SPACE),
177#else 128 TK_WIDTH, TK_HEIGHT );
178 ptr = spot_pic[spots[p]];
179 rb->lcd_mono_bitmap (ptr, (p%5)*16+1, (p/5)*16+1, 14, 8);
180 ptr += 14;
181 rb->lcd_mono_bitmap (ptr, (p%5)*16+1, (p/5)*16+9, 14, 6);
182#endif
183} 129}
184 130
185/* draw the cursor at the current cursor position */ 131/* draw the cursor at the current cursor position */
186static void draw_cursor(void) { 132static void draw_cursor(void)
187 133{
188#ifdef HAVE_LCD_COLOR 134#ifdef HAVE_LCD_COLOR
189 rb->lcd_bitmap_transparent_part( flipit_tokens, 0, 2*tksize, tksize, 135 rb->lcd_bitmap_transparent( flipit_cursor,
190 (cursor_pos%5)*tksize+GRID_LEFT, 136 GRID_LEFT + (cursor_pos%5) * (TK_WIDTH+TK_SPACE),
191 (cursor_pos/5)*tksize+GRID_TOP, 137 GRID_TOP + (cursor_pos/5) * (TK_HEIGHT+TK_SPACE),
192 tksize, tksize ); 138 TK_WIDTH, TK_HEIGHT );
193#elif LCD_DEPTH >= 2
194/* grayscale doesn't have transparent bitmap ... */
195 int i,j;
196 i = ( cursor_pos%5 )*tksize;
197 j = ( cursor_pos/5 )*tksize;
198 rb->lcd_set_drawmode( DRMODE_SOLID );
199 rb->lcd_drawline( i+GRID_LEFT, j+GRID_TOP,
200 i+tksize-1+GRID_LEFT, j+GRID_TOP );
201 rb->lcd_drawline( i+GRID_LEFT, j+tksize-1+GRID_TOP,
202 i+tksize-1+GRID_LEFT, j+tksize-1+GRID_TOP );
203 rb->lcd_drawline( i+GRID_LEFT, j+GRID_TOP,
204 i+GRID_LEFT, j+tksize-1+GRID_TOP );
205 rb->lcd_drawline( i+tksize-1+GRID_LEFT, j+GRID_TOP,
206 i+tksize-1+GRID_LEFT, j+tksize-1+GRID_TOP );
207#else 139#else
208 int i,j;
209 i = (cursor_pos%5)*16;
210 j = (cursor_pos/5)*16;
211 rb->lcd_set_drawmode(DRMODE_FG); 140 rb->lcd_set_drawmode(DRMODE_FG);
212 ptr = cursor_pic; 141 rb->lcd_mono_bitmap( flipit_cursor,
213 rb->lcd_mono_bitmap (ptr, i, j, 16, 8); 142 GRID_LEFT + (cursor_pos%5) * (TK_WIDTH+TK_SPACE),
214 ptr += 16; 143 GRID_TOP + (cursor_pos/5) * (TK_HEIGHT+TK_SPACE),
215 rb->lcd_mono_bitmap (ptr, i, j+8, 16, 8); 144 TK_WIDTH, TK_HEIGHT );
216 rb->lcd_set_drawmode(DRMODE_SOLID); 145 rb->lcd_set_drawmode(DRMODE_SOLID);
217#endif 146#endif
218} 147}
219 148
220/* clear the cursor where it is */ 149/* clear the cursor where it is */
221static void clear_cursor(void) { 150static inline void clear_cursor(void)
222#if LCD_DEPTH >= 2 151{
223 draw_spot( cursor_pos ); 152 draw_spot( cursor_pos );
224#else
225 int i,j;
226 i = (cursor_pos%5)*16;
227 j = (cursor_pos/5)*16;
228 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
229 rb->lcd_drawline(i, j, i+15, j);
230 rb->lcd_drawline(i, j+15, i+15, j+15);
231 rb->lcd_drawline(i, j, i, j+15);
232 rb->lcd_drawline(i+15, j, i+15, j+15);
233 rb->lcd_set_drawmode(DRMODE_SOLID);
234#endif
235} 153}
236 154
237/* draw the info panel ... duh */ 155/* draw the info panel ... duh */
238static void draw_info_panel(void) 156static void draw_info_panel(void)
239{ 157{
240#ifdef INFO_UNDER 158 char s[32];
241# define HEIGHT ( LCD_HEIGHT - 4*tksize ) 159
242# define LEFT ( ( LCD_WIDTH - INFO_WIDTH ) / 2 )
243# define TOP ( LCD_HEIGHT - HEIGHT )
244#else
245# define HEIGHT 64
246# define LEFT ( LCD_WIDTH - (LCD_WIDTH- 5*tksize-INFO_WIDTH)/2 - INFO_WIDTH )
247# define TOP ( ( LCD_HEIGHT - HEIGHT ) / 2 )
248#endif
249 rb->lcd_set_drawmode( DRMODE_SOLID|DRMODE_INVERSEVID ); 160 rb->lcd_set_drawmode( DRMODE_SOLID|DRMODE_INVERSEVID );
250 rb->lcd_fillrect( LEFT, TOP, INFO_WIDTH, HEIGHT ); 161 rb->lcd_fillrect( GRID_LEFT, GRID_TOP + 4*(TK_HEIGHT+TK_SPACE),
162 GRID_WIDTH, PANEL_HEIGHT );
251 rb->lcd_set_drawmode( DRMODE_SOLID ); 163 rb->lcd_set_drawmode( DRMODE_SOLID );
252 rb->lcd_drawrect( LEFT, TOP, INFO_WIDTH, HEIGHT ); 164 rb->lcd_drawrect( GRID_LEFT, GRID_TOP + 4*(TK_HEIGHT+TK_SPACE),
253#ifdef INFO_UNDER 165 GRID_WIDTH, PANEL_HEIGHT );
254 rb->lcd_putsxy( LEFT+1, TOP+1, "Flips" ); 166
255#else 167 rb->snprintf( s, sizeof(s), "Flips: %d", moves );
256 rb->lcd_putsxy( LEFT+1, TOP+10, "Flips" ); 168 rb->lcd_putsxy( (LCD_WIDTH - rb->lcd_getstringsize(s, NULL, NULL)) / 2,
257#endif 169 GRID_TOP + 4*(TK_HEIGHT+TK_SPACE) + 2, s );
258 rb->snprintf( s, sizeof(s), "%d", moves );
259#ifdef INFO_UNDER
260 rb->lcd_putsxy( LEFT+32, TOP+1, s );
261#else
262 rb->lcd_putsxy( LEFT+1, TOP+20, s );
263#endif
264# undef HEIGHT
265# undef LEFT
266# undef TOP
267} 170}
268 171
269/* check if the puzzle is finished */ 172/* check if the puzzle is finished */
270static bool flipit_finished(void) { 173static bool flipit_finished(void)
174{
271 int i; 175 int i;
272 for (i=0; i<20; i++) 176 for (i=0; i<20; i++)
273 if (!spots[i]) 177 if (!spots[i])
@@ -277,7 +181,8 @@ static bool flipit_finished(void) {
277} 181}
278 182
279/* draws the toggled spots */ 183/* draws the toggled spots */
280static void flipit_toggle(void) { 184static void flipit_toggle(void)
185{
281 spots[cursor_pos] = 1-spots[cursor_pos]; 186 spots[cursor_pos] = 1-spots[cursor_pos];
282 toggle[cursor_pos] = 1-toggle[cursor_pos]; 187 toggle[cursor_pos] = 1-toggle[cursor_pos];
283 draw_spot(cursor_pos); 188 draw_spot(cursor_pos);
@@ -306,7 +211,8 @@ static void flipit_toggle(void) {
306} 211}
307 212
308/* move the cursor in any direction */ 213/* move the cursor in any direction */
309static void move_cursor(int x, int y) { 214static void move_cursor(int x, int y)
215{
310 if (!(flipit_finished())) { 216 if (!(flipit_finished())) {
311 clear_cursor(); 217 clear_cursor();
312 cursor_pos = ( x + 5 + cursor_pos%5 )%5 218 cursor_pos = ( x + 5 + cursor_pos%5 )%5
@@ -317,7 +223,8 @@ static void move_cursor(int x, int y) {
317} 223}
318 224
319/* initialize the board */ 225/* initialize the board */
320static void flipit_init(void) { 226static void flipit_init(void)
227{
321 int i; 228 int i;
322 rb->lcd_clear_display(); 229 rb->lcd_clear_display();
323 moves = 0; 230 moves = 0;
@@ -340,7 +247,8 @@ static void flipit_init(void) {
340} 247}
341 248
342/* the main game loop */ 249/* the main game loop */
343static bool flipit_loop(void) { 250static bool flipit_loop(void)
251{
344 int i; 252 int i;
345 int button; 253 int button;
346 int lastbutton = BUTTON_NONE; 254 int lastbutton = BUTTON_NONE;
@@ -398,9 +306,7 @@ static bool flipit_loop(void) {
398 /* toggle the pieces */ 306 /* toggle the pieces */
399 if (!flipit_finished()) { 307 if (!flipit_finished()) {
400 flipit_toggle(); 308 flipit_toggle();
401#if LCD_DEPTH >= 2
402 draw_cursor(); 309 draw_cursor();
403#endif
404 rb->lcd_update(); 310 rb->lcd_update();
405 } 311 }
406 break; 312 break;