Fix some quotation marks. Thanks to Alexander Levin for pointing it out.
[Rockbox.git] / apps / plugins / flipit.c
blob37e49af68e7fdaf4d198e3afc04fef310a6fe27c
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 #elif CONFIG_KEYPAD == COWOND2_PAD
194 #define FLIPIT_LEFT BUTTON_LEFT
195 #define FLIPIT_RIGHT BUTTON_RIGHT
196 #define FLIPIT_UP BUTTON_UP
197 #define FLIPIT_DOWN BUTTON_DOWN
198 #define FLIPIT_QUIT BUTTON_POWER
199 #define FLIPIT_SHUFFLE (BUTTON_LEFT|BUTTON_MENU)
200 #define FLIPIT_SOLVE (BUTTON_RIGHT|BUTTON_MENU)
201 #define FLIPIT_STEP_BY_STEP BUTTON_MINUS
202 #define FLIPIT_TOGGLE_PRE BUTTON_PLUS
203 #define FLIPIT_TOGGLE BUTTON_SELECT
205 #else
206 #error No keymap defined!
207 #endif
209 static struct plugin_api* rb;
210 static int spots[20];
211 static int toggle[20];
212 static int cursor_pos, moves;
214 #ifdef HAVE_LCD_BITMAP
216 #include "flipit_cursor.h"
217 #include "flipit_tokens.h"
219 #define PANEL_HEIGHT 12
220 #define TK_WIDTH BMPWIDTH_flipit_cursor
221 #define TK_HEIGHT BMPHEIGHT_flipit_cursor
222 #define TK_SPACE MAX(0, MIN((LCD_WIDTH - 5*TK_WIDTH)/4, \
223 (LCD_HEIGHT - PANEL_HEIGHT - 4*TK_HEIGHT)/4))
224 #define GRID_WIDTH (5*TK_WIDTH + 4*TK_SPACE)
225 #define GRID_LEFT ((LCD_WIDTH - GRID_WIDTH)/2)
226 #define GRID_HEIGHT (4*TK_HEIGHT + 4*TK_SPACE) /* includes grid-panel space */
227 #define GRID_TOP MAX(0, ((LCD_HEIGHT - PANEL_HEIGHT - GRID_HEIGHT)/2))
229 /* draw a spot at the coordinates (x,y), range of p is 0-19 */
230 static void draw_spot(int p)
232 rb->lcd_bitmap_part( flipit_tokens, 0, spots[p] * TK_HEIGHT, TK_WIDTH,
233 GRID_LEFT + (p%5) * (TK_WIDTH+TK_SPACE),
234 GRID_TOP + (p/5) * (TK_HEIGHT+TK_SPACE),
235 TK_WIDTH, TK_HEIGHT );
238 /* draw the cursor at the current cursor position */
239 static void draw_cursor(void)
241 #ifdef HAVE_LCD_COLOR
242 rb->lcd_bitmap_transparent( flipit_cursor,
243 GRID_LEFT + (cursor_pos%5) * (TK_WIDTH+TK_SPACE),
244 GRID_TOP + (cursor_pos/5) * (TK_HEIGHT+TK_SPACE),
245 TK_WIDTH, TK_HEIGHT );
246 #else
247 rb->lcd_set_drawmode(DRMODE_FG);
248 rb->lcd_mono_bitmap( flipit_cursor,
249 GRID_LEFT + (cursor_pos%5) * (TK_WIDTH+TK_SPACE),
250 GRID_TOP + (cursor_pos/5) * (TK_HEIGHT+TK_SPACE),
251 TK_WIDTH, TK_HEIGHT );
252 rb->lcd_set_drawmode(DRMODE_SOLID);
253 #endif
256 /* draw the info panel ... duh */
257 static void draw_info_panel(void)
259 char s[32];
261 rb->lcd_set_drawmode( DRMODE_SOLID|DRMODE_INVERSEVID );
262 rb->lcd_fillrect( GRID_LEFT, GRID_TOP + 4*(TK_HEIGHT+TK_SPACE),
263 GRID_WIDTH, PANEL_HEIGHT );
264 rb->lcd_set_drawmode( DRMODE_SOLID );
265 rb->lcd_drawrect( GRID_LEFT, GRID_TOP + 4*(TK_HEIGHT+TK_SPACE),
266 GRID_WIDTH, PANEL_HEIGHT );
268 rb->snprintf( s, sizeof(s), "Flips: %d", moves );
269 rb->lcd_putsxy( (LCD_WIDTH - rb->lcd_getstringsize(s, NULL, NULL)) / 2,
270 GRID_TOP + 4*(TK_HEIGHT+TK_SPACE) + 2, s );
273 #else /* HAVE_LCD_CHARCELLS */
275 static const unsigned char tk_pat[4][7] = {
276 { 0x0e, 0x11, 0x0e, 0x00, 0x0e, 0x11, 0x0e }, /* white - white */
277 { 0x0e, 0x11, 0x0e, 0x00, 0x0e, 0x1f, 0x0e }, /* white - black */
278 { 0x0e, 0x1f, 0x0e, 0x00, 0x0e, 0x11, 0x0e }, /* black - white */
279 { 0x0e, 0x1f, 0x0e, 0x00, 0x0e, 0x1f, 0x0e } /* black - black */
282 static unsigned char cur_pat[7];
283 static unsigned long gfx_chars[5];
285 static void release_gfx(void)
287 int i;
289 for (i = 0; i < 5; i++)
290 if (gfx_chars[i])
291 rb->lcd_unlock_pattern(gfx_chars[i]);
294 static bool init_gfx(void)
296 int i;
298 for (i = 0; i < 5; i++) {
299 if ((gfx_chars[i] = rb->lcd_get_locked_pattern()) == 0) {
300 release_gfx();
301 return false;
304 for (i = 0; i < 4; i++)
305 rb->lcd_define_pattern(gfx_chars[i], tk_pat[i]);
306 return true;
309 /* draw a spot at the coordinates (x,y), range of p is 0-19 */
310 static void draw_spot(int p)
312 if ((p/5) & 1)
313 p -= 5;
315 rb->lcd_putc (p%5, p/10, gfx_chars[2*spots[p]+spots[p+5]]);
318 /* draw the cursor at the current cursor position */
319 static void draw_cursor(void)
321 if ((cursor_pos/5) & 1) {
322 rb->memcpy( cur_pat, tk_pat[2*spots[cursor_pos-5]+spots[cursor_pos]], 7 );
323 cur_pat[4] ^= 0x15;
324 cur_pat[6] ^= 0x11;
326 else {
327 rb->memcpy( cur_pat, tk_pat[2*spots[cursor_pos]+spots[cursor_pos+5]], 7 );
328 cur_pat[0] ^= 0x15;
329 cur_pat[2] ^= 0x11;
331 rb->lcd_define_pattern(gfx_chars[4], cur_pat);
332 rb->lcd_putc( cursor_pos%5, cursor_pos/10, gfx_chars[4] );
335 /* draw the info panel ... duh */
336 static void draw_info_panel(void)
338 char s[16];
340 rb->lcd_puts( 6, 0, "Flips" );
341 rb->snprintf( s, sizeof(s), "%d", moves );
342 rb->lcd_puts( 6, 1, s );
345 #endif /* LCD */
347 /* clear the cursor where it is */
348 static inline void clear_cursor(void)
350 draw_spot( cursor_pos );
353 /* check if the puzzle is finished */
354 static bool flipit_finished(void)
356 int i;
357 for (i=0; i<20; i++)
358 if (!spots[i])
359 return false;
360 clear_cursor();
361 return true;
364 /* draws the toggled spots */
365 static void flipit_toggle(void)
367 spots[cursor_pos] = 1-spots[cursor_pos];
368 toggle[cursor_pos] = 1-toggle[cursor_pos];
369 draw_spot(cursor_pos);
370 if (cursor_pos%5 > 0) {
371 spots[cursor_pos-1] = 1-spots[cursor_pos-1];
372 draw_spot(cursor_pos-1);
374 if (cursor_pos%5 < 4) {
375 spots[cursor_pos+1] = 1-spots[cursor_pos+1];
376 draw_spot(cursor_pos+1);
378 if (cursor_pos/5 > 0) {
379 spots[cursor_pos-5] = 1-spots[cursor_pos-5];
380 draw_spot(cursor_pos-5);
382 if (cursor_pos/5 < 3) {
383 spots[cursor_pos+5] = 1-spots[cursor_pos+5];
384 draw_spot(cursor_pos+5);
386 moves++;
388 draw_info_panel();
390 if (flipit_finished())
391 clear_cursor();
394 /* move the cursor in any direction */
395 static void move_cursor(int x, int y)
397 if (!(flipit_finished())) {
398 clear_cursor();
399 cursor_pos = ( x + 5 + cursor_pos%5 )%5
400 + ( ( y + 4 + cursor_pos/5 )%4 )*5;
401 draw_cursor();
403 rb->lcd_update();
406 /* initialize the board */
407 static void flipit_init(void)
409 int i;
411 rb->lcd_clear_display();
412 for (i=0; i<20; i++) {
413 spots[i]=1;
414 toggle[i]=1;
415 draw_spot(i);
417 rb->lcd_update();
419 for (i=0; i<20; i++) {
420 cursor_pos = (rb->rand() % 20);
421 flipit_toggle();
424 cursor_pos = 0;
425 draw_cursor();
426 moves = 0;
427 draw_info_panel();
428 rb->lcd_update();
431 /* the main game loop */
432 static bool flipit_loop(void)
434 int i;
435 int button;
436 int lastbutton = BUTTON_NONE;
438 flipit_init();
439 while(true) {
440 button = rb->button_get(true);
441 switch (button) {
442 #ifdef FLIPIT_RC_QUIT
443 case FLIPIT_RC_QUIT:
444 #endif
445 case FLIPIT_QUIT:
446 /* get out of here */
447 return PLUGIN_OK;
449 case FLIPIT_SHUFFLE:
450 /* mix up the pieces */
451 flipit_init();
452 break;
454 case FLIPIT_SOLVE:
455 #ifdef FLIPIT_SOLVE_PRE
456 if (lastbutton != FLIPIT_SOLVE_PRE)
457 break;
458 #endif
459 /* solve the puzzle */
460 if (!flipit_finished()) {
461 for (i=0; i<20; i++)
462 if (!toggle[i]) {
463 clear_cursor();
464 cursor_pos = i;
465 flipit_toggle();
466 draw_cursor();
467 rb->lcd_update();
468 rb->sleep(HZ*2/3);
471 break;
473 case FLIPIT_STEP_BY_STEP:
474 #ifdef FLIPIT_STEP_PRE
475 if (lastbutton != FLIPIT_STEP_PRE)
476 break;
477 #endif
478 if (!flipit_finished()) {
479 for (i=0; i<20; i++)
480 if (!toggle[i]) {
481 clear_cursor();
482 cursor_pos = i;
483 flipit_toggle();
484 draw_cursor();
485 rb->lcd_update();
486 break;
489 break;
491 case FLIPIT_TOGGLE:
492 #ifdef FLIPIT_TOGGLE_PRE
493 if (lastbutton != FLIPIT_TOGGLE_PRE)
494 break;
495 #endif
496 /* toggle the pieces */
497 if (!flipit_finished()) {
498 flipit_toggle();
499 draw_cursor();
500 rb->lcd_update();
502 break;
504 case FLIPIT_LEFT:
505 move_cursor(-1, 0);
506 break;
508 case FLIPIT_RIGHT:
509 move_cursor(1, 0);
510 break;
512 case FLIPIT_UP:
513 #ifdef FLIPIT_UP_PRE
514 if (lastbutton != FLIPIT_UP_PRE)
515 break;
516 #endif
517 move_cursor(0, -1);
518 break;
520 case FLIPIT_DOWN:
521 move_cursor(0, 1);
522 break;
524 default:
525 if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
526 return PLUGIN_USB_CONNECTED;
527 break;
529 if (button != BUTTON_NONE)
530 lastbutton = button;
534 /* called function from outside */
535 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
537 int i, rc;
539 (void)parameter;
540 rb = api;
542 #ifdef HAVE_LCD_COLOR
543 rb->lcd_set_background(LCD_WHITE);
544 rb->lcd_set_foreground(LCD_BLACK);
545 #endif
547 #if LCD_DEPTH > 1
548 rb->lcd_set_backdrop(NULL);
549 #endif
551 rb->splash(HZ, "FlipIt!");
553 #ifdef HAVE_LCD_BITMAP
554 /* print instructions */
555 rb->lcd_clear_display();
556 rb->lcd_setfont(FONT_SYSFIXED);
557 #if CONFIG_KEYPAD == RECORDER_PAD
558 rb->lcd_putsxy(2, 8, "[OFF] to stop");
559 rb->lcd_putsxy(2, 18, "[PLAY] toggle");
560 rb->lcd_putsxy(2, 28, "[F1] shuffle");
561 rb->lcd_putsxy(2, 38, "[F2] solution");
562 rb->lcd_putsxy(2, 48, "[F3] step by step");
563 #elif CONFIG_KEYPAD == ONDIO_PAD
564 rb->lcd_putsxy(2, 8, "[OFF] to stop");
565 rb->lcd_putsxy(2, 18, "[MODE] toggle");
566 rb->lcd_putsxy(2, 28, "[M-LEFT] shuffle");
567 rb->lcd_putsxy(2, 38, "[M-UP] solution");
568 rb->lcd_putsxy(2, 48, "[M-RIGHT] step by step");
569 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
570 (CONFIG_KEYPAD == IRIVER_H300_PAD)
571 rb->lcd_putsxy(2, 8, "[STOP] to stop");
572 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
573 rb->lcd_putsxy(2, 28, "[MODE] shuffle");
574 rb->lcd_putsxy(2, 38, "[PLAY] solution");
575 rb->lcd_putsxy(2, 48, "[REC] step by step");
576 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
577 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
578 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
579 rb->lcd_putsxy(2, 8, "[S-MENU] to stop");
580 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
581 rb->lcd_putsxy(2, 28, "[S-LEFT] shuffle");
582 rb->lcd_putsxy(2, 38, "[S-PLAY] solution");
583 rb->lcd_putsxy(2, 48, "[S-RIGHT] step by step");
584 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
585 rb->lcd_putsxy(2, 8, "[POWER] to stop");
586 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
587 rb->lcd_putsxy(2, 28, "[REC] shuffle");
588 rb->lcd_putsxy(2, 38, "[PLAY..] solution");
589 rb->lcd_putsxy(2, 48, "[PLAY] step by step");
590 #elif CONFIG_KEYPAD == GIGABEAT_PAD
591 rb->lcd_putsxy(2, 8, "[POWER] to stop");
592 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
593 rb->lcd_putsxy(2, 28, "[MENU] shuffle");
594 rb->lcd_putsxy(2, 38, "[VOL+] solution");
595 rb->lcd_putsxy(2, 48, "[VOL-] step by step");
596 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
597 rb->lcd_putsxy(2, 8, "[POWER] to stop");
598 rb->lcd_putsxy(2, 18, "[REW] toggle");
599 rb->lcd_putsxy(2, 28, "[PL-LEFT] shuffle");
600 rb->lcd_putsxy(2, 38, "[PL-RIGHT] solution");
601 rb->lcd_putsxy(2, 48, "[PL-UP] step by step");
602 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
603 (CONFIG_KEYPAD == SANSA_C200_PAD)
604 rb->lcd_putsxy(2, 8, "[POWER] to stop");
605 rb->lcd_putsxy(2, 18, "[SELECT] toggle");
606 rb->lcd_putsxy(2, 28, "[REC-LEFT] shuffle");
607 rb->lcd_putsxy(2, 38, "[REC-RIGHT] solution");
608 rb->lcd_putsxy(2, 48, "[REC-SEL] step by step");
609 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
610 rb->lcd_putsxy(2, 8, "[REC] to stop");
611 rb->lcd_putsxy(2, 18, "[PLAY] toggle");
612 rb->lcd_putsxy(2, 28, "[MODE] shuffle");
613 rb->lcd_putsxy(2, 38, "[MENU..] solution");
614 rb->lcd_putsxy(2, 48, "[MENU] step by step");
615 #endif
616 rb->lcd_update();
617 #else /* HAVE_LCD_CHARCELLS */
618 if (!init_gfx())
619 return PLUGIN_ERROR;
620 #endif
621 rb->button_get_w_tmo(HZ*3);
623 rb->lcd_clear_display();
624 draw_info_panel();
625 for (i=0; i<20; i++) {
626 spots[i]=1;
627 draw_spot(i);
629 rb->lcd_update();
630 rb->sleep(HZ*3/2);
631 rb->srand(*rb->current_tick);
633 rc = flipit_loop();
634 #ifdef HAVE_LCD_CHARCELLS
635 release_gfx();
636 #endif
637 return rc;