Adapt most single-file plugins to the M3 keypad and screen. It's still preliminary...
[kugel-rb.git] / apps / plugins / flipit.c
blob831cc857ec9c1353f6eaa98ec17b4c5e61e2b1dd
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Vicentini Martin
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "plugin.h"
21 PLUGIN_HEADER
23 /* variable button definitions */
24 #if CONFIG_KEYPAD == RECORDER_PAD
25 #define FLIPIT_LEFT BUTTON_LEFT
26 #define FLIPIT_RIGHT BUTTON_RIGHT
27 #define FLIPIT_UP BUTTON_UP
28 #define FLIPIT_DOWN BUTTON_DOWN
29 #define FLIPIT_QUIT BUTTON_OFF
30 #define FLIPIT_SHUFFLE BUTTON_F1
31 #define FLIPIT_SOLVE BUTTON_F2
32 #define FLIPIT_STEP_BY_STEP BUTTON_F3
33 #define FLIPIT_TOGGLE BUTTON_PLAY
35 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
36 #define FLIPIT_LEFT BUTTON_LEFT
37 #define FLIPIT_RIGHT BUTTON_RIGHT
38 #define FLIPIT_UP BUTTON_UP
39 #define FLIPIT_DOWN BUTTON_DOWN
40 #define FLIPIT_QUIT BUTTON_OFF
41 #define FLIPIT_SHUFFLE BUTTON_F1
42 #define FLIPIT_SOLVE BUTTON_F2
43 #define FLIPIT_STEP_BY_STEP BUTTON_F3
44 #define FLIPIT_TOGGLE BUTTON_SELECT
46 #elif CONFIG_KEYPAD == PLAYER_PAD
47 #define FLIPIT_LEFT BUTTON_LEFT
48 #define FLIPIT_RIGHT BUTTON_RIGHT
49 #define FLIPIT_UP_PRE BUTTON_ON
50 #define FLIPIT_UP (BUTTON_ON | BUTTON_REL)
51 #define FLIPIT_DOWN BUTTON_MENU
52 #define FLIPIT_QUIT BUTTON_STOP
53 #define FLIPIT_SHUFFLE (BUTTON_ON | BUTTON_LEFT)
54 #define FLIPIT_SOLVE (BUTTON_ON | BUTTON_RIGHT)
55 #define FLIPIT_STEP_BY_STEP (BUTTON_ON | BUTTON_PLAY)
56 #define FLIPIT_TOGGLE BUTTON_PLAY
58 #elif CONFIG_KEYPAD == ONDIO_PAD
59 #define FLIPIT_LEFT BUTTON_LEFT
60 #define FLIPIT_RIGHT BUTTON_RIGHT
61 #define FLIPIT_UP BUTTON_UP
62 #define FLIPIT_DOWN BUTTON_DOWN
63 #define FLIPIT_QUIT BUTTON_OFF
64 #define FLIPIT_SHUFFLE (BUTTON_MENU | BUTTON_LEFT)
65 #define FLIPIT_SOLVE (BUTTON_MENU | BUTTON_UP)
66 #define FLIPIT_STEP_BY_STEP (BUTTON_MENU | BUTTON_RIGHT)
67 #define FLIPIT_TOGGLE_PRE BUTTON_MENU
68 #define FLIPIT_TOGGLE (BUTTON_MENU | BUTTON_REL)
70 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
71 (CONFIG_KEYPAD == IRIVER_H300_PAD)
72 #define FLIPIT_LEFT BUTTON_LEFT
73 #define FLIPIT_RIGHT BUTTON_RIGHT
74 #define FLIPIT_UP BUTTON_UP
75 #define FLIPIT_DOWN BUTTON_DOWN
76 #define FLIPIT_QUIT BUTTON_OFF
77 #define FLIPIT_SHUFFLE BUTTON_MODE
78 #define FLIPIT_SOLVE BUTTON_ON
79 #define FLIPIT_STEP_BY_STEP BUTTON_REC
80 #define FLIPIT_TOGGLE_PRE BUTTON_SELECT
81 #define FLIPIT_TOGGLE (BUTTON_SELECT | BUTTON_REL)
83 #define FLIPIT_RC_QUIT BUTTON_RC_STOP
85 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
86 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
87 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
89 #define FLIPIT_LEFT BUTTON_LEFT
90 #define FLIPIT_RIGHT BUTTON_RIGHT
91 #define FLIPIT_UP BUTTON_MENU
92 #define FLIPIT_DOWN BUTTON_PLAY
93 #define FLIPIT_QUIT (BUTTON_SELECT | BUTTON_MENU)
94 #define FLIPIT_SHUFFLE (BUTTON_SELECT | BUTTON_LEFT)
95 #define FLIPIT_SOLVE (BUTTON_SELECT | BUTTON_PLAY)
96 #define FLIPIT_STEP_BY_STEP (BUTTON_SELECT | BUTTON_RIGHT)
97 #define FLIPIT_TOGGLE_PRE BUTTON_SELECT
98 #define FLIPIT_TOGGLE (BUTTON_SELECT | BUTTON_REL)
100 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
102 #define FLIPIT_LEFT BUTTON_LEFT
103 #define FLIPIT_RIGHT BUTTON_RIGHT
104 #define FLIPIT_UP BUTTON_UP
105 #define FLIPIT_DOWN BUTTON_DOWN
106 #define FLIPIT_QUIT BUTTON_POWER
107 #define FLIPIT_SHUFFLE BUTTON_REC
108 #define FLIPIT_SOLVE_PRE BUTTON_PLAY
109 #define FLIPIT_SOLVE (BUTTON_PLAY | BUTTON_REPEAT)
110 #define FLIPIT_STEP_PRE BUTTON_PLAY
111 #define FLIPIT_STEP_BY_STEP (BUTTON_PLAY | BUTTON_REL)
112 #define FLIPIT_TOGGLE BUTTON_SELECT
114 #elif CONFIG_KEYPAD == GIGABEAT_PAD
116 #define FLIPIT_LEFT BUTTON_LEFT
117 #define FLIPIT_RIGHT BUTTON_RIGHT
118 #define FLIPIT_UP BUTTON_UP
119 #define FLIPIT_DOWN BUTTON_DOWN
120 #define FLIPIT_QUIT BUTTON_POWER
121 #define FLIPIT_SHUFFLE BUTTON_MENU
122 #define FLIPIT_SOLVE BUTTON_VOL_UP
123 #define FLIPIT_STEP_BY_STEP BUTTON_VOL_DOWN
124 #define FLIPIT_TOGGLE BUTTON_SELECT
126 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
127 (CONFIG_KEYPAD == SANSA_C200_PAD)
129 #define FLIPIT_LEFT BUTTON_LEFT
130 #define FLIPIT_RIGHT BUTTON_RIGHT
131 #define FLIPIT_UP BUTTON_UP
132 #define FLIPIT_DOWN BUTTON_DOWN
133 #define FLIPIT_QUIT BUTTON_POWER
134 #define FLIPIT_SHUFFLE (BUTTON_REC | BUTTON_LEFT)
135 #define FLIPIT_SOLVE (BUTTON_REC | BUTTON_RIGHT)
136 #define FLIPIT_STEP_BY_STEP (BUTTON_REC | BUTTON_SELECT)
137 #define FLIPIT_TOGGLE BUTTON_SELECT
139 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
141 #define FLIPIT_LEFT BUTTON_LEFT
142 #define FLIPIT_RIGHT BUTTON_RIGHT
143 #define FLIPIT_UP BUTTON_SCROLL_UP
144 #define FLIPIT_DOWN BUTTON_SCROLL_DOWN
145 #define FLIPIT_QUIT BUTTON_POWER
146 #define FLIPIT_SHUFFLE (BUTTON_PLAY | BUTTON_LEFT)
147 #define FLIPIT_SOLVE (BUTTON_PLAY | BUTTON_RIGHT)
148 #define FLIPIT_STEP_BY_STEP (BUTTON_PLAY | BUTTON_SCROLL_UP)
149 #define FLIPIT_TOGGLE_PRE BUTTON_REW
150 #define FLIPIT_TOGGLE (BUTTON_REW | BUTTON_REL)
152 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
154 #define FLIPIT_LEFT BUTTON_LEFT
155 #define FLIPIT_RIGHT BUTTON_RIGHT
156 #define FLIPIT_UP BUTTON_UP
157 #define FLIPIT_DOWN BUTTON_DOWN
158 #define FLIPIT_QUIT BUTTON_BACK
159 #define FLIPIT_SHUFFLE BUTTON_MENU
160 #define FLIPIT_SOLVE BUTTON_VOL_UP
161 #define FLIPIT_STEP_BY_STEP BUTTON_VOL_DOWN
162 #define FLIPIT_TOGGLE BUTTON_SELECT
164 #elif CONFIG_KEYPAD == MROBE100_PAD
166 #define FLIPIT_LEFT BUTTON_LEFT
167 #define FLIPIT_RIGHT BUTTON_RIGHT
168 #define FLIPIT_UP BUTTON_UP
169 #define FLIPIT_DOWN BUTTON_DOWN
170 #define FLIPIT_QUIT BUTTON_POWER
171 #define FLIPIT_SHUFFLE BUTTON_MENU
172 #define FLIPIT_SOLVE BUTTON_PLAY
173 #define FLIPIT_STEP_BY_STEP BUTTON_DISPLAY
174 #define FLIPIT_TOGGLE BUTTON_SELECT
176 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
178 #define FLIPIT_LEFT BUTTON_RC_REW
179 #define FLIPIT_RIGHT BUTTON_RC_FF
180 #define FLIPIT_UP BUTTON_RC_VOL_UP
181 #define FLIPIT_DOWN BUTTON_RC_VOL_DOWN
182 #define FLIPIT_QUIT BUTTON_RC_REC
183 #define FLIPIT_SHUFFLE BUTTON_RC_MODE
184 #define FLIPIT_SOLVE_PRE BUTTON_RC_MENU
185 #define FLIPIT_SOLVE (BUTTON_RC_MENU|BUTTON_REPEAT)
186 #define FLIPIT_STEP_PRE BUTTON_RC_MENU
187 #define FLIPIT_STEP_BY_STEP (BUTTON_RC_MENU|BUTTON_REL)
188 #define FLIPIT_TOGGLE BUTTON_RC_PLAY
190 #define FLIPIT_RC_QUIT BUTTON_REC
192 #else
193 #error No keymap defined!
194 #endif
196 static struct plugin_api* rb;
197 static int spots[20];
198 static int toggle[20];
199 static int cursor_pos, moves;
201 #ifdef HAVE_LCD_BITMAP
203 #include "flipit_cursor.h"
204 #include "flipit_tokens.h"
206 #define PANEL_HEIGHT 12
207 #define TK_WIDTH BMPWIDTH_flipit_cursor
208 #define TK_HEIGHT BMPHEIGHT_flipit_cursor
209 #define TK_SPACE MAX(0, MIN((LCD_WIDTH - 5*TK_WIDTH)/4, \
210 (LCD_HEIGHT - PANEL_HEIGHT - 4*TK_HEIGHT)/4))
211 #define GRID_WIDTH (5*TK_WIDTH + 4*TK_SPACE)
212 #define GRID_LEFT ((LCD_WIDTH - GRID_WIDTH)/2)
213 #define GRID_HEIGHT (4*TK_HEIGHT + 4*TK_SPACE) /* includes grid-panel space */
214 #define GRID_TOP MAX(0, ((LCD_HEIGHT - PANEL_HEIGHT - GRID_HEIGHT)/2))
216 /* draw a spot at the coordinates (x,y), range of p is 0-19 */
217 static void draw_spot(int p)
219 rb->lcd_bitmap_part( flipit_tokens, 0, spots[p] * TK_HEIGHT, TK_WIDTH,
220 GRID_LEFT + (p%5) * (TK_WIDTH+TK_SPACE),
221 GRID_TOP + (p/5) * (TK_HEIGHT+TK_SPACE),
222 TK_WIDTH, TK_HEIGHT );
225 /* draw the cursor at the current cursor position */
226 static void draw_cursor(void)
228 #ifdef HAVE_LCD_COLOR
229 rb->lcd_bitmap_transparent( flipit_cursor,
230 GRID_LEFT + (cursor_pos%5) * (TK_WIDTH+TK_SPACE),
231 GRID_TOP + (cursor_pos/5) * (TK_HEIGHT+TK_SPACE),
232 TK_WIDTH, TK_HEIGHT );
233 #else
234 rb->lcd_set_drawmode(DRMODE_FG);
235 rb->lcd_mono_bitmap( flipit_cursor,
236 GRID_LEFT + (cursor_pos%5) * (TK_WIDTH+TK_SPACE),
237 GRID_TOP + (cursor_pos/5) * (TK_HEIGHT+TK_SPACE),
238 TK_WIDTH, TK_HEIGHT );
239 rb->lcd_set_drawmode(DRMODE_SOLID);
240 #endif
243 /* draw the info panel ... duh */
244 static void draw_info_panel(void)
246 char s[32];
248 rb->lcd_set_drawmode( DRMODE_SOLID|DRMODE_INVERSEVID );
249 rb->lcd_fillrect( GRID_LEFT, GRID_TOP + 4*(TK_HEIGHT+TK_SPACE),
250 GRID_WIDTH, PANEL_HEIGHT );
251 rb->lcd_set_drawmode( DRMODE_SOLID );
252 rb->lcd_drawrect( GRID_LEFT, GRID_TOP + 4*(TK_HEIGHT+TK_SPACE),
253 GRID_WIDTH, PANEL_HEIGHT );
255 rb->snprintf( s, sizeof(s), "Flips: %d", moves );
256 rb->lcd_putsxy( (LCD_WIDTH - rb->lcd_getstringsize(s, NULL, NULL)) / 2,
257 GRID_TOP + 4*(TK_HEIGHT+TK_SPACE) + 2, s );
260 #else /* HAVE_LCD_CHARCELLS */
262 static const unsigned char tk_pat[4][7] = {
263 { 0x0e, 0x11, 0x0e, 0x00, 0x0e, 0x11, 0x0e }, /* white - white */
264 { 0x0e, 0x11, 0x0e, 0x00, 0x0e, 0x1f, 0x0e }, /* white - black */
265 { 0x0e, 0x1f, 0x0e, 0x00, 0x0e, 0x11, 0x0e }, /* black - white */
266 { 0x0e, 0x1f, 0x0e, 0x00, 0x0e, 0x1f, 0x0e } /* black - black */
269 static unsigned char cur_pat[7];
270 static unsigned long gfx_chars[5];
272 static void release_gfx(void)
274 int i;
276 for (i = 0; i < 5; i++)
277 if (gfx_chars[i])
278 rb->lcd_unlock_pattern(gfx_chars[i]);
281 static bool init_gfx(void)
283 int i;
285 for (i = 0; i < 5; i++) {
286 if ((gfx_chars[i] = rb->lcd_get_locked_pattern()) == 0) {
287 release_gfx();
288 return false;
291 for (i = 0; i < 4; i++)
292 rb->lcd_define_pattern(gfx_chars[i], tk_pat[i]);
293 return true;
296 /* draw a spot at the coordinates (x,y), range of p is 0-19 */
297 static void draw_spot(int p)
299 if ((p/5) & 1)
300 p -= 5;
302 rb->lcd_putc (p%5, p/10, gfx_chars[2*spots[p]+spots[p+5]]);
305 /* draw the cursor at the current cursor position */
306 static void draw_cursor(void)
308 if ((cursor_pos/5) & 1) {
309 rb->memcpy( cur_pat, tk_pat[2*spots[cursor_pos-5]+spots[cursor_pos]], 7 );
310 cur_pat[4] ^= 0x15;
311 cur_pat[6] ^= 0x11;
313 else {
314 rb->memcpy( cur_pat, tk_pat[2*spots[cursor_pos]+spots[cursor_pos+5]], 7 );
315 cur_pat[0] ^= 0x15;
316 cur_pat[2] ^= 0x11;
318 rb->lcd_define_pattern(gfx_chars[4], cur_pat);
319 rb->lcd_putc( cursor_pos%5, cursor_pos/10, gfx_chars[4] );
322 /* draw the info panel ... duh */
323 static void draw_info_panel(void)
325 char s[16];
327 rb->lcd_puts( 6, 0, "Flips" );
328 rb->snprintf( s, sizeof(s), "%d", moves );
329 rb->lcd_puts( 6, 1, s );
332 #endif /* LCD */
334 /* clear the cursor where it is */
335 static inline void clear_cursor(void)
337 draw_spot( cursor_pos );
340 /* check if the puzzle is finished */
341 static bool flipit_finished(void)
343 int i;
344 for (i=0; i<20; i++)
345 if (!spots[i])
346 return false;
347 clear_cursor();
348 return true;
351 /* draws the toggled spots */
352 static void flipit_toggle(void)
354 spots[cursor_pos] = 1-spots[cursor_pos];
355 toggle[cursor_pos] = 1-toggle[cursor_pos];
356 draw_spot(cursor_pos);
357 if (cursor_pos%5 > 0) {
358 spots[cursor_pos-1] = 1-spots[cursor_pos-1];
359 draw_spot(cursor_pos-1);
361 if (cursor_pos%5 < 4) {
362 spots[cursor_pos+1] = 1-spots[cursor_pos+1];
363 draw_spot(cursor_pos+1);
365 if (cursor_pos/5 > 0) {
366 spots[cursor_pos-5] = 1-spots[cursor_pos-5];
367 draw_spot(cursor_pos-5);
369 if (cursor_pos/5 < 3) {
370 spots[cursor_pos+5] = 1-spots[cursor_pos+5];
371 draw_spot(cursor_pos+5);
373 moves++;
375 draw_info_panel();
377 if (flipit_finished())
378 clear_cursor();
381 /* move the cursor in any direction */
382 static void move_cursor(int x, int y)
384 if (!(flipit_finished())) {
385 clear_cursor();
386 cursor_pos = ( x + 5 + cursor_pos%5 )%5
387 + ( ( y + 4 + cursor_pos/5 )%4 )*5;
388 draw_cursor();
390 rb->lcd_update();
393 /* initialize the board */
394 static void flipit_init(void)
396 int i;
398 rb->lcd_clear_display();
399 for (i=0; i<20; i++) {
400 spots[i]=1;
401 toggle[i]=1;
402 draw_spot(i);
404 rb->lcd_update();
406 for (i=0; i<20; i++) {
407 cursor_pos = (rb->rand() % 20);
408 flipit_toggle();
411 cursor_pos = 0;
412 draw_cursor();
413 moves = 0;
414 draw_info_panel();
415 rb->lcd_update();
418 /* the main game loop */
419 static bool flipit_loop(void)
421 int i;
422 int button;
423 int lastbutton = BUTTON_NONE;
425 flipit_init();
426 while(true) {
427 button = rb->button_get(true);
428 switch (button) {
429 #ifdef FLIPIT_RC_QUIT
430 case FLIPIT_RC_QUIT:
431 #endif
432 case FLIPIT_QUIT:
433 /* get out of here */
434 return PLUGIN_OK;
436 case FLIPIT_SHUFFLE:
437 /* mix up the pieces */
438 flipit_init();
439 break;
441 case FLIPIT_SOLVE:
442 #ifdef FLIPIT_SOLVE_PRE
443 if (lastbutton != FLIPIT_SOLVE_PRE)
444 break;
445 #endif
446 /* solve the puzzle */
447 if (!flipit_finished()) {
448 for (i=0; i<20; i++)
449 if (!toggle[i]) {
450 clear_cursor();
451 cursor_pos = i;
452 flipit_toggle();
453 draw_cursor();
454 rb->lcd_update();
455 rb->sleep(HZ*2/3);
458 break;
460 case FLIPIT_STEP_BY_STEP:
461 #ifdef FLIPIT_STEP_PRE
462 if (lastbutton != FLIPIT_STEP_PRE)
463 break;
464 #endif
465 if (!flipit_finished()) {
466 for (i=0; i<20; i++)
467 if (!toggle[i]) {
468 clear_cursor();
469 cursor_pos = i;
470 flipit_toggle();
471 draw_cursor();
472 rb->lcd_update();
473 break;
476 break;
478 case FLIPIT_TOGGLE:
479 #ifdef FLIPIT_TOGGLE_PRE
480 if (lastbutton != FLIPIT_TOGGLE_PRE)
481 break;
482 #endif
483 /* toggle the pieces */
484 if (!flipit_finished()) {
485 flipit_toggle();
486 draw_cursor();
487 rb->lcd_update();
489 break;
491 case FLIPIT_LEFT:
492 move_cursor(-1, 0);
493 break;
495 case FLIPIT_RIGHT:
496 move_cursor(1, 0);
497 break;
499 case FLIPIT_UP:
500 #ifdef FLIPIT_UP_PRE
501 if (lastbutton != FLIPIT_UP_PRE)
502 break;
503 #endif
504 move_cursor(0, -1);
505 break;
507 case FLIPIT_DOWN:
508 move_cursor(0, 1);
509 break;
511 default:
512 if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
513 return PLUGIN_USB_CONNECTED;
514 break;
516 if (button != BUTTON_NONE)
517 lastbutton = button;
521 /* called function from outside */
522 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
524 int i, rc;
526 (void)parameter;
527 rb = api;
529 #ifdef HAVE_LCD_COLOR
530 rb->lcd_set_background(LCD_WHITE);
531 rb->lcd_set_foreground(LCD_BLACK);
532 #endif
534 #if LCD_DEPTH > 1
535 rb->lcd_set_backdrop(NULL);
536 #endif
538 rb->splash(HZ, "FlipIt!");
540 #ifdef HAVE_LCD_BITMAP
541 /* print instructions */
542 rb->lcd_clear_display();
543 rb->lcd_setfont(FONT_SYSFIXED);
544 #if CONFIG_KEYPAD == RECORDER_PAD
545 rb->lcd_putsxy(2, 8, "[OFF] to stop");
546 rb->lcd_putsxy(2, 18, "[PLAY] toggle");
547 rb->lcd_putsxy(2, 28, "[F1] shuffle");
548 rb->lcd_putsxy(2, 38, "[F2] solution");
549 rb->lcd_putsxy(2, 48, "[F3] step by step");
550 #elif CONFIG_KEYPAD == ONDIO_PAD
551 rb->lcd_putsxy(2, 8, "[OFF] to stop");
552 rb->lcd_putsxy(2, 18, "[MODE] toggle");
553 rb->lcd_putsxy(2, 28, "[M-LEFT] shuffle");
554 rb->lcd_putsxy(2, 38, "[M-UP] solution");
555 rb->lcd_putsxy(2, 48, "[M-RIGHT] step by step");
556 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
557 (CONFIG_KEYPAD == IRIVER_H300_PAD)
558 rb->lcd_putsxy(2, 8, "[STOP] to stop");
559 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
560 rb->lcd_putsxy(2, 28, "[MODE] shuffle");
561 rb->lcd_putsxy(2, 38, "[PLAY] solution");
562 rb->lcd_putsxy(2, 48, "[REC] step by step");
563 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
564 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
565 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
566 rb->lcd_putsxy(2, 8, "[S-MENU] to stop");
567 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
568 rb->lcd_putsxy(2, 28, "[S-LEFT] shuffle");
569 rb->lcd_putsxy(2, 38, "[S-PLAY] solution");
570 rb->lcd_putsxy(2, 48, "[S-RIGHT] step by step");
571 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
572 rb->lcd_putsxy(2, 8, "[POWER] to stop");
573 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
574 rb->lcd_putsxy(2, 28, "[REC] shuffle");
575 rb->lcd_putsxy(2, 38, "[PLAY..] solution");
576 rb->lcd_putsxy(2, 48, "[PLAY] step by step");
577 #elif CONFIG_KEYPAD == GIGABEAT_PAD
578 rb->lcd_putsxy(2, 8, "[POWER] to stop");
579 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
580 rb->lcd_putsxy(2, 28, "[MENU] shuffle");
581 rb->lcd_putsxy(2, 38, "[VOL+] solution");
582 rb->lcd_putsxy(2, 48, "[VOL-] step by step");
583 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
584 rb->lcd_putsxy(2, 8, "[POWER] to stop");
585 rb->lcd_putsxy(2, 18, "[REW] toggle");
586 rb->lcd_putsxy(2, 28, "[PL-LEFT] shuffle");
587 rb->lcd_putsxy(2, 38, "[PL-RIGHT] solution");
588 rb->lcd_putsxy(2, 48, "[PL-UP] step by step");
589 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
590 (CONFIG_KEYPAD == SANSA_C200_PAD)
591 rb->lcd_putsxy(2, 8, "[POWER] to stop");
592 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
593 rb->lcd_putsxy(2, 28, "[REC-LEFT] shuffle");
594 rb->lcd_putsxy(2, 38, "[REC-RIGHT] solution");
595 rb->lcd_putsxy(2, 48, "[REC-SEL] step by step");
596 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
597 rb->lcd_putsxy(2, 8, "[REC] to stop");
598 rb->lcd_putsxy(2, 18, "[PLAY] toggle");
599 rb->lcd_putsxy(2, 28, "[MODE] shuffle");
600 rb->lcd_putsxy(2, 38, "[MENU..] solution");
601 rb->lcd_putsxy(2, 48, "[MENU] step by step");
602 #endif
603 rb->lcd_update();
604 #else /* HAVE_LCD_CHARCELLS */
605 if (!init_gfx())
606 return PLUGIN_ERROR;
607 #endif
608 rb->button_get_w_tmo(HZ*3);
610 rb->lcd_clear_display();
611 draw_info_panel();
612 for (i=0; i<20; i++) {
613 spots[i]=1;
614 draw_spot(i);
616 rb->lcd_update();
617 rb->sleep(HZ*3/2);
618 rb->srand(*rb->current_tick);
620 rc = flipit_loop();
621 #ifdef HAVE_LCD_CHARCELLS
622 release_gfx();
623 #endif
624 return rc;