1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Vicentini Martin
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 /* variable button definitions */
26 #if CONFIG_KEYPAD == RECORDER_PAD
27 #define FLIPIT_LEFT BUTTON_LEFT
28 #define FLIPIT_RIGHT BUTTON_RIGHT
29 #define FLIPIT_UP BUTTON_UP
30 #define FLIPIT_DOWN BUTTON_DOWN
31 #define FLIPIT_QUIT BUTTON_OFF
32 #define FLIPIT_SHUFFLE BUTTON_F1
33 #define FLIPIT_SOLVE BUTTON_F2
34 #define FLIPIT_STEP_BY_STEP BUTTON_F3
35 #define FLIPIT_TOGGLE BUTTON_PLAY
37 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
38 #define FLIPIT_LEFT BUTTON_LEFT
39 #define FLIPIT_RIGHT BUTTON_RIGHT
40 #define FLIPIT_UP BUTTON_UP
41 #define FLIPIT_DOWN BUTTON_DOWN
42 #define FLIPIT_QUIT BUTTON_OFF
43 #define FLIPIT_SHUFFLE BUTTON_F1
44 #define FLIPIT_SOLVE BUTTON_F2
45 #define FLIPIT_STEP_BY_STEP BUTTON_F3
46 #define FLIPIT_TOGGLE BUTTON_SELECT
48 #elif CONFIG_KEYPAD == PLAYER_PAD
49 #define FLIPIT_LEFT BUTTON_LEFT
50 #define FLIPIT_RIGHT BUTTON_RIGHT
51 #define FLIPIT_UP_PRE BUTTON_ON
52 #define FLIPIT_UP (BUTTON_ON | BUTTON_REL)
53 #define FLIPIT_DOWN BUTTON_MENU
54 #define FLIPIT_QUIT BUTTON_STOP
55 #define FLIPIT_SHUFFLE (BUTTON_ON | BUTTON_LEFT)
56 #define FLIPIT_SOLVE (BUTTON_ON | BUTTON_RIGHT)
57 #define FLIPIT_STEP_BY_STEP (BUTTON_ON | BUTTON_PLAY)
58 #define FLIPIT_TOGGLE BUTTON_PLAY
60 #elif CONFIG_KEYPAD == ONDIO_PAD
61 #define FLIPIT_LEFT BUTTON_LEFT
62 #define FLIPIT_RIGHT BUTTON_RIGHT
63 #define FLIPIT_UP BUTTON_UP
64 #define FLIPIT_DOWN BUTTON_DOWN
65 #define FLIPIT_QUIT BUTTON_OFF
66 #define FLIPIT_SHUFFLE (BUTTON_MENU | BUTTON_LEFT)
67 #define FLIPIT_SOLVE (BUTTON_MENU | BUTTON_UP)
68 #define FLIPIT_STEP_BY_STEP (BUTTON_MENU | BUTTON_RIGHT)
69 #define FLIPIT_TOGGLE_PRE BUTTON_MENU
70 #define FLIPIT_TOGGLE (BUTTON_MENU | BUTTON_REL)
72 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
73 (CONFIG_KEYPAD == IRIVER_H300_PAD)
74 #define FLIPIT_LEFT BUTTON_LEFT
75 #define FLIPIT_RIGHT BUTTON_RIGHT
76 #define FLIPIT_UP BUTTON_UP
77 #define FLIPIT_DOWN BUTTON_DOWN
78 #define FLIPIT_QUIT BUTTON_OFF
79 #define FLIPIT_SHUFFLE BUTTON_MODE
80 #define FLIPIT_SOLVE BUTTON_ON
81 #define FLIPIT_STEP_BY_STEP BUTTON_REC
82 #define FLIPIT_TOGGLE_PRE BUTTON_SELECT
83 #define FLIPIT_TOGGLE (BUTTON_SELECT | BUTTON_REL)
85 #define FLIPIT_RC_QUIT BUTTON_RC_STOP
87 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
88 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
89 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
91 #define FLIPIT_SCROLLWHEEL
92 #define FLIPIT_LEFT BUTTON_LEFT
93 #define FLIPIT_RIGHT BUTTON_RIGHT
94 #define FLIPIT_UP BUTTON_MENU
95 #define FLIPIT_DOWN BUTTON_PLAY
96 #define FLIPIT_NEXT BUTTON_SCROLL_FWD
97 #define FLIPIT_PREV BUTTON_SCROLL_BACK
98 #define FLIPIT_QUIT (BUTTON_SELECT | BUTTON_MENU)
99 #define FLIPIT_SHUFFLE (BUTTON_SELECT | BUTTON_LEFT)
100 #define FLIPIT_SOLVE (BUTTON_SELECT | BUTTON_PLAY)
101 #define FLIPIT_STEP_BY_STEP (BUTTON_SELECT | BUTTON_RIGHT)
102 #define FLIPIT_TOGGLE_PRE BUTTON_SELECT
103 #define FLIPIT_TOGGLE (BUTTON_SELECT | BUTTON_REL)
105 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
107 #define FLIPIT_LEFT BUTTON_LEFT
108 #define FLIPIT_RIGHT BUTTON_RIGHT
109 #define FLIPIT_UP BUTTON_UP
110 #define FLIPIT_DOWN BUTTON_DOWN
111 #define FLIPIT_QUIT BUTTON_POWER
112 #define FLIPIT_SHUFFLE BUTTON_REC
113 #define FLIPIT_SOLVE_PRE BUTTON_PLAY
114 #define FLIPIT_SOLVE (BUTTON_PLAY | BUTTON_REPEAT)
115 #define FLIPIT_STEP_PRE BUTTON_PLAY
116 #define FLIPIT_STEP_BY_STEP (BUTTON_PLAY | BUTTON_REL)
117 #define FLIPIT_TOGGLE BUTTON_SELECT
119 #elif CONFIG_KEYPAD == GIGABEAT_PAD
121 #define FLIPIT_LEFT BUTTON_LEFT
122 #define FLIPIT_RIGHT BUTTON_RIGHT
123 #define FLIPIT_UP BUTTON_UP
124 #define FLIPIT_DOWN BUTTON_DOWN
125 #define FLIPIT_QUIT BUTTON_POWER
126 #define FLIPIT_SHUFFLE BUTTON_MENU
127 #define FLIPIT_SOLVE BUTTON_VOL_UP
128 #define FLIPIT_STEP_BY_STEP BUTTON_VOL_DOWN
129 #define FLIPIT_TOGGLE BUTTON_SELECT
131 #elif CONFIG_KEYPAD == SANSA_E200_PAD
133 #define FLIPIT_SCROLLWHEEL
134 #define FLIPIT_LEFT BUTTON_LEFT
135 #define FLIPIT_RIGHT BUTTON_RIGHT
136 #define FLIPIT_UP BUTTON_UP
137 #define FLIPIT_DOWN BUTTON_DOWN
138 #define FLIPIT_NEXT BUTTON_SCROLL_FWD
139 #define FLIPIT_PREV BUTTON_SCROLL_BACK
140 #define FLIPIT_QUIT BUTTON_POWER
141 #define FLIPIT_SHUFFLE (BUTTON_REC | BUTTON_LEFT)
142 #define FLIPIT_SOLVE (BUTTON_REC | BUTTON_RIGHT)
143 #define FLIPIT_STEP_BY_STEP (BUTTON_REC | BUTTON_SELECT)
144 #define FLIPIT_TOGGLE BUTTON_SELECT
146 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
148 #define FLIPIT_SCROLLWHEEL
149 #define FLIPIT_LEFT BUTTON_LEFT
150 #define FLIPIT_RIGHT BUTTON_RIGHT
151 #define FLIPIT_UP BUTTON_UP
152 #define FLIPIT_DOWN BUTTON_DOWN
153 #define FLIPIT_NEXT BUTTON_SCROLL_FWD
154 #define FLIPIT_PREV BUTTON_SCROLL_BACK
155 #define FLIPIT_QUIT (BUTTON_HOME|BUTTON_REPEAT)
156 #define FLIPIT_SHUFFLE (BUTTON_SELECT | BUTTON_LEFT)
157 #define FLIPIT_SOLVE (BUTTON_SELECT | BUTTON_DOWN)
158 #define FLIPIT_STEP_BY_STEP (BUTTON_SELECT | BUTTON_RIGHT)
159 #define FLIPIT_TOGGLE_PRE BUTTON_SELECT
160 #define FLIPIT_TOGGLE (BUTTON_SELECT | BUTTON_REL)
162 #elif CONFIG_KEYPAD == SANSA_C200_PAD
164 #define FLIPIT_LEFT BUTTON_LEFT
165 #define FLIPIT_RIGHT BUTTON_RIGHT
166 #define FLIPIT_UP BUTTON_UP
167 #define FLIPIT_DOWN BUTTON_DOWN
168 #define FLIPIT_QUIT BUTTON_POWER
169 #define FLIPIT_SHUFFLE (BUTTON_REC | BUTTON_LEFT)
170 #define FLIPIT_SOLVE (BUTTON_REC | BUTTON_RIGHT)
171 #define FLIPIT_STEP_BY_STEP (BUTTON_REC | BUTTON_SELECT)
172 #define FLIPIT_TOGGLE BUTTON_SELECT
174 #elif CONFIG_KEYPAD == SANSA_CLIP_PAD
176 #define FLIPIT_LEFT BUTTON_LEFT
177 #define FLIPIT_RIGHT BUTTON_RIGHT
178 #define FLIPIT_UP BUTTON_UP
179 #define FLIPIT_DOWN BUTTON_DOWN
180 #define FLIPIT_QUIT BUTTON_POWER
181 #define FLIPIT_SHUFFLE (BUTTON_HOME | BUTTON_LEFT)
182 #define FLIPIT_SOLVE (BUTTON_HOME | BUTTON_RIGHT)
183 #define FLIPIT_STEP_BY_STEP (BUTTON_HOME | BUTTON_SELECT)
184 #define FLIPIT_TOGGLE BUTTON_SELECT
186 #elif CONFIG_KEYPAD == SANSA_M200_PAD
188 #define FLIPIT_LEFT BUTTON_LEFT
189 #define FLIPIT_RIGHT BUTTON_RIGHT
190 #define FLIPIT_UP BUTTON_UP
191 #define FLIPIT_DOWN BUTTON_DOWN
192 #define FLIPIT_QUIT BUTTON_POWER
193 #define FLIPIT_SHUFFLE (BUTTON_SELECT | BUTTON_LEFT)
194 #define FLIPIT_SOLVE (BUTTON_SELECT | BUTTON_RIGHT)
195 #define FLIPIT_STEP_BY_STEP (BUTTON_SELECT | BUTTON_UP)
196 #define FLIPIT_TOGGLE (BUTTON_SELECT | BUTTON_REL)
198 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
200 #define FLIPIT_LEFT BUTTON_LEFT
201 #define FLIPIT_RIGHT BUTTON_RIGHT
202 #define FLIPIT_UP BUTTON_SCROLL_UP
203 #define FLIPIT_DOWN BUTTON_SCROLL_DOWN
204 #define FLIPIT_QUIT BUTTON_POWER
205 #define FLIPIT_SHUFFLE (BUTTON_PLAY | BUTTON_LEFT)
206 #define FLIPIT_SOLVE (BUTTON_PLAY | BUTTON_RIGHT)
207 #define FLIPIT_STEP_BY_STEP (BUTTON_PLAY | BUTTON_SCROLL_UP)
208 #define FLIPIT_TOGGLE_PRE BUTTON_REW
209 #define FLIPIT_TOGGLE (BUTTON_REW | BUTTON_REL)
211 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
213 #define FLIPIT_LEFT BUTTON_LEFT
214 #define FLIPIT_RIGHT BUTTON_RIGHT
215 #define FLIPIT_UP BUTTON_UP
216 #define FLIPIT_DOWN BUTTON_DOWN
217 #define FLIPIT_QUIT BUTTON_BACK
218 #define FLIPIT_SHUFFLE BUTTON_MENU
219 #define FLIPIT_SOLVE BUTTON_VOL_UP
220 #define FLIPIT_STEP_BY_STEP BUTTON_VOL_DOWN
221 #define FLIPIT_TOGGLE BUTTON_SELECT
223 #elif CONFIG_KEYPAD == MROBE100_PAD
225 #define FLIPIT_LEFT BUTTON_LEFT
226 #define FLIPIT_RIGHT BUTTON_RIGHT
227 #define FLIPIT_UP BUTTON_UP
228 #define FLIPIT_DOWN BUTTON_DOWN
229 #define FLIPIT_QUIT BUTTON_POWER
230 #define FLIPIT_SHUFFLE BUTTON_MENU
231 #define FLIPIT_SOLVE BUTTON_PLAY
232 #define FLIPIT_STEP_BY_STEP BUTTON_DISPLAY
233 #define FLIPIT_TOGGLE BUTTON_SELECT
235 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
237 #define FLIPIT_LEFT BUTTON_RC_REW
238 #define FLIPIT_RIGHT BUTTON_RC_FF
239 #define FLIPIT_UP BUTTON_RC_VOL_UP
240 #define FLIPIT_DOWN BUTTON_RC_VOL_DOWN
241 #define FLIPIT_QUIT BUTTON_RC_REC
242 #define FLIPIT_SHUFFLE BUTTON_RC_MODE
243 #define FLIPIT_SOLVE_PRE BUTTON_RC_MENU
244 #define FLIPIT_SOLVE (BUTTON_RC_MENU|BUTTON_REPEAT)
245 #define FLIPIT_STEP_PRE BUTTON_RC_MENU
246 #define FLIPIT_STEP_BY_STEP (BUTTON_RC_MENU|BUTTON_REL)
247 #define FLIPIT_TOGGLE BUTTON_RC_PLAY
249 #define FLIPIT_RC_QUIT BUTTON_REC
251 #elif CONFIG_KEYPAD == COWON_D2_PAD
253 #define FLIPIT_QUIT BUTTON_POWER
255 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
257 #define FLIPIT_LEFT BUTTON_LEFT
258 #define FLIPIT_RIGHT BUTTON_RIGHT
259 #define FLIPIT_UP BUTTON_UP
260 #define FLIPIT_DOWN BUTTON_DOWN
261 #define FLIPIT_QUIT BUTTON_BACK
262 #define FLIPIT_SHUFFLE BUTTON_CUSTOM
263 #define FLIPIT_SOLVE BUTTON_PLAY
264 #define FLIPIT_STEP_BY_STEP BUTTON_MENU
265 #define FLIPIT_TOGGLE BUTTON_SELECT
267 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
269 #define FLIPIT_LEFT BUTTON_LEFT
270 #define FLIPIT_RIGHT BUTTON_RIGHT
271 #define FLIPIT_UP BUTTON_UP
272 #define FLIPIT_DOWN BUTTON_DOWN
273 #define FLIPIT_QUIT BUTTON_POWER
274 #define FLIPIT_SHUFFLE BUTTON_MENU
275 #define FLIPIT_SOLVE BUTTON_VIEW
276 #define FLIPIT_STEP_BY_STEP BUTTON_PLAYLIST
277 #define FLIPIT_TOGGLE BUTTON_SELECT
279 #elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
281 #define FLIPIT_LEFT BUTTON_LEFT
282 #define FLIPIT_RIGHT BUTTON_RIGHT
283 #define FLIPIT_UP BUTTON_UP
284 #define FLIPIT_DOWN BUTTON_DOWN
285 #define FLIPIT_QUIT BUTTON_POWER
286 #define FLIPIT_SHUFFLE BUTTON_MENU
287 #define FLIPIT_SOLVE BUTTON_VIEW
288 #define FLIPIT_STEP_BY_STEP BUTTON_NEXT
289 #define FLIPIT_TOGGLE BUTTON_PLAY
291 #elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
293 #define FLIPIT_LEFT BUTTON_PREV
294 #define FLIPIT_RIGHT BUTTON_NEXT
295 #define FLIPIT_UP BUTTON_UP
296 #define FLIPIT_DOWN BUTTON_DOWN
297 #define FLIPIT_QUIT BUTTON_POWER
298 #define FLIPIT_SHUFFLE BUTTON_MENU
299 #define FLIPIT_SOLVE BUTTON_RIGHT
300 #define FLIPIT_STEP_BY_STEP BUTTON_LEFT
301 #define FLIPIT_TOGGLE BUTTON_PLAY
303 #elif CONFIG_KEYPAD == ONDAVX747_PAD || CONFIG_KEYPAD == MROBE500_PAD
305 #define FLIPIT_QUIT BUTTON_POWER
307 #elif CONFIG_KEYPAD == ONDAVX777_PAD
309 #define FLIPIT_QUIT BUTTON_POWER
311 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
313 #define FLIPIT_LEFT BUTTON_LEFT
314 #define FLIPIT_RIGHT BUTTON_RIGHT
315 #define FLIPIT_UP BUTTON_UP
316 #define FLIPIT_DOWN BUTTON_DOWN
317 #define FLIPIT_QUIT BUTTON_REC
318 #define FLIPIT_SHUFFLE BUTTON_PLAY
319 #define FLIPIT_SOLVE BUTTON_FFWD
320 #define FLIPIT_STEP_BY_STEP (BUTTON_PLAY|BUTTON_UP)
321 #define FLIPIT_TOGGLE (BUTTON_PLAY|BUTTON_DOWN)
323 #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
325 #define FLIPIT_LEFT BUTTON_PREV
326 #define FLIPIT_RIGHT BUTTON_NEXT
327 #define FLIPIT_UP BUTTON_UP
328 #define FLIPIT_DOWN BUTTON_DOWN
329 #define FLIPIT_QUIT BUTTON_REC
330 #define FLIPIT_SHUFFLE BUTTON_PLAY
331 #define FLIPIT_SOLVE BUTTON_MENU
332 #define FLIPIT_STEP_BY_STEP BUTTON_CANCEL
333 #define FLIPIT_TOGGLE BUTTON_OK
335 #elif CONFIG_KEYPAD == MPIO_HD200_PAD
337 #define FLIPIT_LEFT BUTTON_VOL_DOWN
338 #define FLIPIT_RIGHT BUTTON_VOL_UP
339 #define FLIPIT_UP BUTTON_REW
340 #define FLIPIT_DOWN BUTTON_FF
341 #define FLIPIT_QUIT (BUTTON_REC|BUTTON_PLAY)
342 #define FLIPIT_SHUFFLE BUTTON_FUNC
343 #define FLIPIT_SOLVE BUTTON_REC
344 #define FLIPIT_STEP_BY_STEP (BUTTON_PLAY|BUTTON_REW)
345 #define FLIPIT_TOGGLE (BUTTON_PLAY|BUTTON_FF)
347 #elif CONFIG_KEYPAD == MPIO_HD300_PAD
349 #define FLIPIT_LEFT BUTTON_REW
350 #define FLIPIT_RIGHT BUTTON_FF
351 #define FLIPIT_UP BUTTON_UP
352 #define FLIPIT_DOWN BUTTON_DOWN
353 #define FLIPIT_QUIT (BUTTON_REC|BUTTON_REPEAT)
354 #define FLIPIT_SHUFFLE BUTTON_PLAY
355 #define FLIPIT_SOLVE BUTTON_MENU
356 #define FLIPIT_STEP_BY_STEP BUTTON_REC
357 #define FLIPIT_TOGGLE BUTTON_ENTER
360 #error No keymap defined!
363 #ifdef HAVE_TOUCHSCREEN
365 #define FLIPIT_LEFT BUTTON_MIDLEFT
368 #define FLIPIT_RIGHT BUTTON_MIDRIGHT
371 #define FLIPIT_UP BUTTON_TOPMIDDLE
374 #define FLIPIT_DOWN BUTTON_BOTTOMMIDDLE
377 #define FLIPIT_QUIT BUTTON_TOPLEFT
379 #ifndef FLIPIT_SHUFFLE
380 #define FLIPIT_SHUFFLE BUTTON_TOPRIGHT
383 #define FLIPIT_SOLVE BUTTON_BOTTOMLEFT
385 #ifndef FLIPIT_STEP_BY_STEP
386 #define FLIPIT_STEP_BY_STEP BUTTON_BOTTOMRIGHT
388 #ifndef FLIPIT_TOGGLE
389 #define FLIPIT_TOGGLE BUTTON_CENTER
393 static int spots
[20];
394 static int toggle
[20];
395 static int cursor_pos
, moves
;
397 #ifdef HAVE_LCD_BITMAP
399 #include "pluginbitmaps/flipit_cursor.h"
400 #include "pluginbitmaps/flipit_tokens.h"
402 #define PANEL_HEIGHT 12
403 #define TK_WIDTH BMPWIDTH_flipit_cursor
404 #define TK_HEIGHT BMPHEIGHT_flipit_cursor
405 #define TK_SPACE MAX(0, MIN((LCD_WIDTH - 5*TK_WIDTH)/4, \
406 (LCD_HEIGHT - PANEL_HEIGHT - 4*TK_HEIGHT)/4))
407 #define GRID_WIDTH (5*TK_WIDTH + 4*TK_SPACE)
408 #define GRID_LEFT ((LCD_WIDTH - GRID_WIDTH)/2)
409 #define GRID_HEIGHT (4*TK_HEIGHT + 4*TK_SPACE) /* includes grid-panel space */
410 #define GRID_TOP MAX(0, ((LCD_HEIGHT - PANEL_HEIGHT - GRID_HEIGHT)/2))
412 /* draw a spot at the coordinates (x,y), range of p is 0-19 */
413 static void draw_spot(int p
)
415 rb
->lcd_bitmap_part( flipit_tokens
, 0, spots
[p
] * TK_HEIGHT
,
416 STRIDE(SCREEN_MAIN
, BMPWIDTH_flipit_tokens
,
417 BMPHEIGHT_flipit_tokens
),
418 GRID_LEFT
+ (p
%5) * (TK_WIDTH
+TK_SPACE
),
419 GRID_TOP
+ (p
/5) * (TK_HEIGHT
+TK_SPACE
),
420 TK_WIDTH
, TK_HEIGHT
);
423 /* draw the cursor at the current cursor position */
424 static void draw_cursor(void)
426 #ifdef HAVE_LCD_COLOR
427 rb
->lcd_bitmap_transparent( flipit_cursor
,
428 GRID_LEFT
+ (cursor_pos
%5) * (TK_WIDTH
+TK_SPACE
),
429 GRID_TOP
+ (cursor_pos
/5) * (TK_HEIGHT
+TK_SPACE
),
430 TK_WIDTH
, TK_HEIGHT
);
432 rb
->lcd_set_drawmode(DRMODE_FG
);
433 rb
->lcd_mono_bitmap( flipit_cursor
,
434 GRID_LEFT
+ (cursor_pos
%5) * (TK_WIDTH
+TK_SPACE
),
435 GRID_TOP
+ (cursor_pos
/5) * (TK_HEIGHT
+TK_SPACE
),
436 TK_WIDTH
, TK_HEIGHT
);
437 rb
->lcd_set_drawmode(DRMODE_SOLID
);
441 /* draw the info panel ... duh */
442 static void draw_info_panel(void)
446 rb
->lcd_set_drawmode( DRMODE_SOLID
|DRMODE_INVERSEVID
);
447 rb
->lcd_fillrect( GRID_LEFT
, GRID_TOP
+ 4*(TK_HEIGHT
+TK_SPACE
),
448 GRID_WIDTH
, PANEL_HEIGHT
);
449 rb
->lcd_set_drawmode( DRMODE_SOLID
);
450 rb
->lcd_drawrect( GRID_LEFT
, GRID_TOP
+ 4*(TK_HEIGHT
+TK_SPACE
),
451 GRID_WIDTH
, PANEL_HEIGHT
);
453 rb
->snprintf( s
, sizeof(s
), "Flips: %d", moves
);
454 rb
->lcd_putsxy( (LCD_WIDTH
- rb
->lcd_getstringsize(s
, NULL
, NULL
)) / 2,
455 GRID_TOP
+ 4*(TK_HEIGHT
+TK_SPACE
) + 2, s
);
458 #else /* HAVE_LCD_CHARCELLS */
460 static const unsigned char tk_pat
[4][7] = {
461 { 0x0e, 0x11, 0x0e, 0x00, 0x0e, 0x11, 0x0e }, /* white - white */
462 { 0x0e, 0x11, 0x0e, 0x00, 0x0e, 0x1f, 0x0e }, /* white - black */
463 { 0x0e, 0x1f, 0x0e, 0x00, 0x0e, 0x11, 0x0e }, /* black - white */
464 { 0x0e, 0x1f, 0x0e, 0x00, 0x0e, 0x1f, 0x0e } /* black - black */
467 static unsigned char cur_pat
[7];
468 static unsigned long gfx_chars
[5];
470 static void release_gfx(void)
474 for (i
= 0; i
< 5; i
++)
476 rb
->lcd_unlock_pattern(gfx_chars
[i
]);
479 static bool init_gfx(void)
483 for (i
= 0; i
< 5; i
++) {
484 if ((gfx_chars
[i
] = rb
->lcd_get_locked_pattern()) == 0) {
489 for (i
= 0; i
< 4; i
++)
490 rb
->lcd_define_pattern(gfx_chars
[i
], tk_pat
[i
]);
494 /* draw a spot at the coordinates (x,y), range of p is 0-19 */
495 static void draw_spot(int p
)
500 rb
->lcd_putc (p
%5, p
/10, gfx_chars
[2*spots
[p
]+spots
[p
+5]]);
503 /* draw the cursor at the current cursor position */
504 static void draw_cursor(void)
506 if ((cursor_pos
/5) & 1) {
507 rb
->memcpy( cur_pat
, tk_pat
[2*spots
[cursor_pos
-5]+spots
[cursor_pos
]], 7 );
512 rb
->memcpy( cur_pat
, tk_pat
[2*spots
[cursor_pos
]+spots
[cursor_pos
+5]], 7 );
516 rb
->lcd_define_pattern(gfx_chars
[4], cur_pat
);
517 rb
->lcd_putc( cursor_pos
%5, cursor_pos
/10, gfx_chars
[4] );
520 /* draw the info panel ... duh */
521 static void draw_info_panel(void)
523 rb
->lcd_puts( 6, 0, "Flips" );
524 rb
->lcd_putsf( 6, 1, "%d", moves
);
529 /* clear the cursor where it is */
530 static inline void clear_cursor(void)
532 draw_spot( cursor_pos
);
535 /* check if the puzzle is finished */
536 static bool flipit_finished(void)
546 /* draws the toggled spots */
547 static void flipit_toggle(void)
549 spots
[cursor_pos
] = 1-spots
[cursor_pos
];
550 toggle
[cursor_pos
] = 1-toggle
[cursor_pos
];
551 draw_spot(cursor_pos
);
552 if (cursor_pos
%5 > 0) {
553 spots
[cursor_pos
-1] = 1-spots
[cursor_pos
-1];
554 draw_spot(cursor_pos
-1);
556 if (cursor_pos
%5 < 4) {
557 spots
[cursor_pos
+1] = 1-spots
[cursor_pos
+1];
558 draw_spot(cursor_pos
+1);
560 if (cursor_pos
/5 > 0) {
561 spots
[cursor_pos
-5] = 1-spots
[cursor_pos
-5];
562 draw_spot(cursor_pos
-5);
564 if (cursor_pos
/5 < 3) {
565 spots
[cursor_pos
+5] = 1-spots
[cursor_pos
+5];
566 draw_spot(cursor_pos
+5);
572 if (flipit_finished())
576 /* move the cursor in any direction */
577 static void move_cursor(int x
, int y
)
579 if (!(flipit_finished())) {
581 cursor_pos
= ( x
+ 5 + cursor_pos
%5 )%5
582 + ( ( y
+ 4 + cursor_pos
/5 )%4 )*5;
588 /* initialize the board */
589 static void flipit_init(void)
593 rb
->lcd_clear_display();
594 for (i
=0; i
<20; i
++) {
601 for (i
=0; i
<20; i
++) {
602 cursor_pos
= (rb
->rand() % 20);
613 /* the main game loop */
614 static bool flipit_loop(void)
618 int lastbutton
= BUTTON_NONE
;
622 button
= rb
->button_get(true);
624 #ifdef FLIPIT_RC_QUIT
628 /* get out of here */
632 /* mix up the pieces */
637 #ifdef FLIPIT_SOLVE_PRE
638 if (lastbutton
!= FLIPIT_SOLVE_PRE
)
641 /* solve the puzzle */
642 if (!flipit_finished()) {
655 case FLIPIT_STEP_BY_STEP
:
656 #ifdef FLIPIT_STEP_PRE
657 if (lastbutton
!= FLIPIT_STEP_PRE
)
660 if (!flipit_finished()) {
674 #ifdef FLIPIT_TOGGLE_PRE
675 if (lastbutton
!= FLIPIT_TOGGLE_PRE
)
678 /* toggle the pieces */
679 if (!flipit_finished()) {
693 /*move cursor though the entire field*/
694 #ifdef FLIPIT_SCROLLWHEEL
696 case FLIPIT_PREV
|BUTTON_REPEAT
:
697 if ((cursor_pos
)%5 == 0) {
706 case FLIPIT_NEXT
|BUTTON_REPEAT
:
707 if ((cursor_pos
+1)%5 == 0) {
717 if (lastbutton
!= FLIPIT_UP_PRE
)
728 if (rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
729 return PLUGIN_USB_CONNECTED
;
732 if (button
!= BUTTON_NONE
)
737 /* called function from outside */
738 enum plugin_status
plugin_start(const void* parameter
)
744 #ifdef HAVE_LCD_COLOR
745 rb
->lcd_set_background(LCD_WHITE
);
746 rb
->lcd_set_foreground(LCD_BLACK
);
750 rb
->lcd_set_backdrop(NULL
);
753 rb
->splash(HZ
, "FlipIt!");
755 #ifdef HAVE_LCD_BITMAP
756 /* print instructions */
757 rb
->lcd_clear_display();
758 rb
->lcd_setfont(FONT_SYSFIXED
);
759 #if CONFIG_KEYPAD == RECORDER_PAD
760 rb
->lcd_putsxy(2, 8, "[OFF] to stop");
761 rb
->lcd_putsxy(2, 18, "[PLAY] toggle");
762 rb
->lcd_putsxy(2, 28, "[F1] shuffle");
763 rb
->lcd_putsxy(2, 38, "[F2] solution");
764 rb
->lcd_putsxy(2, 48, "[F3] step by step");
765 #elif CONFIG_KEYPAD == ONDIO_PAD
766 rb
->lcd_putsxy(2, 8, "[OFF] to stop");
767 rb
->lcd_putsxy(2, 18, "[MODE] toggle");
768 rb
->lcd_putsxy(2, 28, "[M-LEFT] shuffle");
769 rb
->lcd_putsxy(2, 38, "[M-UP] solution");
770 rb
->lcd_putsxy(2, 48, "[M-RIGHT] step by step");
771 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
772 (CONFIG_KEYPAD == IRIVER_H300_PAD)
773 rb
->lcd_putsxy(2, 8, "[STOP] to stop");
774 rb
->lcd_putsxy(2, 18, "[SELECT] toggle");
775 rb
->lcd_putsxy(2, 28, "[MODE] shuffle");
776 rb
->lcd_putsxy(2, 38, "[PLAY] solution");
777 rb
->lcd_putsxy(2, 48, "[REC] step by step");
778 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
779 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
780 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
781 rb
->lcd_putsxy(2, 8, "[S-MENU] to stop");
782 rb
->lcd_putsxy(2, 18, "[SELECT] toggle");
783 rb
->lcd_putsxy(2, 28, "[S-LEFT] shuffle");
784 rb
->lcd_putsxy(2, 38, "[S-PLAY] solution");
785 rb
->lcd_putsxy(2, 48, "[S-RIGHT] step by step");
786 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
787 rb
->lcd_putsxy(2, 8, "[POWER] to stop");
788 rb
->lcd_putsxy(2, 18, "[SELECT] toggle");
789 rb
->lcd_putsxy(2, 28, "[REC] shuffle");
790 rb
->lcd_putsxy(2, 38, "[PLAY..] solution");
791 rb
->lcd_putsxy(2, 48, "[PLAY] step by step");
792 #elif CONFIG_KEYPAD == GIGABEAT_PAD
793 rb
->lcd_putsxy(2, 8, "[POWER] to stop");
794 rb
->lcd_putsxy(2, 18, "[SELECT] toggle");
795 rb
->lcd_putsxy(2, 28, "[MENU] shuffle");
796 rb
->lcd_putsxy(2, 38, "[VOL+] solution");
797 rb
->lcd_putsxy(2, 48, "[VOL-] step by step");
798 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
799 rb
->lcd_putsxy(2, 8, "[POWER] to stop");
800 rb
->lcd_putsxy(2, 18, "[REW] toggle");
801 rb
->lcd_putsxy(2, 28, "[PL-LEFT] shuffle");
802 rb
->lcd_putsxy(2, 38, "[PL-RIGHT] solution");
803 rb
->lcd_putsxy(2, 48, "[PL-UP] step by step");
804 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
805 rb
->lcd_putsxy(2, 8, "[BACK] to stop");
806 rb
->lcd_putsxy(2, 18, "[SELECT] toggle");
807 rb
->lcd_putsxy(2, 28, "[MENU] shuffle");
808 rb
->lcd_putsxy(2, 38, "[VOL+] solution");
809 rb
->lcd_putsxy(2, 48, "[VOL-] step by step");
810 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
811 (CONFIG_KEYPAD == SANSA_C200_PAD)
812 rb
->lcd_putsxy(2, 8, "[POWER] to stop");
813 rb
->lcd_putsxy(2, 18, "[SELECT] toggle");
814 rb
->lcd_putsxy(2, 28, "[REC-LEFT] shuffle");
815 rb
->lcd_putsxy(2, 38, "[REC-RIGHT] solution");
816 rb
->lcd_putsxy(2, 48, "[REC-SEL] step by step");
817 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
818 rb
->lcd_putsxy(2, 8, "[REC] to stop");
819 rb
->lcd_putsxy(2, 18, "[PLAY] toggle");
820 rb
->lcd_putsxy(2, 28, "[MODE] shuffle");
821 rb
->lcd_putsxy(2, 38, "[MENU..] solution");
822 rb
->lcd_putsxy(2, 48, "[MENU] step by step");
825 #ifdef HAVE_TOUCHSCREEN
826 rb
->lcd_putsxy(2, 8, "[BOTTOMLEFT] to stop");
827 rb
->lcd_putsxy(2, 18, "[CENTRE] toggle");
828 rb
->lcd_putsxy(2, 28, "[TOPRIGHT] shuffle");
829 rb
->lcd_putsxy(2, 38, "[BOTTOMLEFT] solution");
830 rb
->lcd_putsxy(2, 48, "[BOTTOMRIGHT] step by step");
834 #else /* HAVE_LCD_CHARCELLS */
838 rb
->button_get_w_tmo(HZ
*3);
840 rb
->lcd_clear_display();
842 for (i
=0; i
<20; i
++) {
848 rb
->srand(*rb
->current_tick
);
851 #ifdef HAVE_LCD_CHARCELLS