1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Robert Hak <rhak at ramapo.edu>
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 ****************************************************************************/
23 void roll_credits(void);
24 const char* const credits
[] = {
25 #include "credits.raw" /* generated list of names from docs/CREDITS */
28 static struct plugin_api
* rb
;
30 enum plugin_status
plugin_start(struct plugin_api
* api
, void* parameter
)
38 /* Turn off backlight timeout */
39 rb
->backlight_set_timeout(1);
42 #ifdef HAVE_LCD_CHARCELLS
43 rb
->lcd_double_height(false);
46 /* Show the logo for about 3 secs allowing the user to stop */
47 for (j
= 0; j
< 15; j
++) {
50 btn
= rb
->button_get(false);
51 if (btn
!= BUTTON_NONE
&& !(btn
& BUTTON_REL
))
58 /* Restore the values we've changed */
59 rb
->backlight_set_timeout(rb
->global_settings
->backlight_timeout
);
64 #ifdef HAVE_LCD_CHARCELLS
66 void roll_credits(void)
68 int numnames
= sizeof(credits
)/sizeof(char*);
70 int curr_len
= rb
->utf8length(credits
[0]);
73 int name
, len
, new_len
, line
, x
;
77 rb
->lcd_clear_display();
89 rb
->lcd_puts(0, line
, credits
[name
] + rb
->utf8seek(credits
[name
], -x
));
91 rb
->lcd_puts(x
, line
, credits
[name
]);
93 if (++name
>= numnames
)
99 if ((unsigned)x2
< 11)
100 rb
->lcd_putc(x2
, line
, '*');
102 new_len
= rb
->utf8length(credits
[name
]);
103 x
+= MAX(len
/2 + 2, len
- new_len
/2 + 1);
108 /* abort on keypress */
109 if (rb
->button_get_w_tmo(HZ
/8) & BUTTON_REL
)
112 if (++curr_index
>= curr_len
)
114 if (++curr_name
>= numnames
)
116 new_len
= rb
->utf8length(credits
[curr_name
]);
117 curr_index
-= MAX(curr_len
/2 + 2, curr_len
- new_len
/2 + 1);
126 void roll_credits(void)
128 #if (CONFIG_KEYPAD == RECORDER_PAD)
129 #define PAUSE_TIME 1.2
130 #define ANIM_SPEED 35
131 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD)
133 #define ANIM_SPEED 100
134 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
136 #define ANIM_SPEED 35
137 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
139 #define ANIM_SPEED 100
142 #define ANIM_SPEED 40
145 #define NUM_VISIBLE_LINES (LCD_HEIGHT/font_h - 1)
146 #define CREDITS_TARGETPOS ((LCD_WIDTH/2)-(credits_w/2))
148 int i
=0, j
=0, namepos
=0, offset_dummy
, btn
;
149 int name_w
, name_h
, name_targetpos
=1, font_h
;
150 int credits_w
, credits_pos
;
151 int numnames
= (sizeof(credits
)/sizeof(char*));
152 char name
[40], elapsednames
[20];
154 rb
->lcd_setfont(FONT_UI
);
155 rb
->lcd_clear_display();
158 rb
->lcd_getstringsize("A", NULL
, &font_h
);
160 /* snprintf "credits" text, and save the width and height */
161 rb
->snprintf(elapsednames
, sizeof(elapsednames
), "[Credits] %d/%d",
163 rb
->lcd_getstringsize(elapsednames
, &credits_w
, NULL
);
165 /* fly in "credits" text from the left */
166 for(credits_pos
= 0 - credits_w
; credits_pos
<= CREDITS_TARGETPOS
;
167 credits_pos
+= (CREDITS_TARGETPOS
-credits_pos
+ 14) / 7)
169 rb
->lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
170 rb
->lcd_fillrect(0, 0, LCD_WIDTH
, font_h
);
171 rb
->lcd_set_drawmode(DRMODE_SOLID
);
172 rb
->lcd_putsxy(credits_pos
, 0, elapsednames
);
173 rb
->lcd_update_rect(0, 0, LCD_WIDTH
, font_h
);
174 rb
->sleep(HZ
/ANIM_SPEED
);
177 /* first screen's worth of lines fly in */
178 for(i
=0; i
<NUM_VISIBLE_LINES
; i
++)
180 rb
->snprintf(name
, sizeof(name
), "%s", credits
[i
]);
181 rb
->lcd_getstringsize(name
, &name_w
, &name_h
);
183 rb
->snprintf(elapsednames
, sizeof(elapsednames
), "[Credits] %d/%d",
185 rb
->lcd_getstringsize(elapsednames
, &credits_w
, NULL
);
186 rb
->lcd_putsxy(CREDITS_TARGETPOS
, 0, elapsednames
);
188 for(namepos
= 0-name_w
; namepos
<= name_targetpos
;
189 namepos
+= (name_targetpos
- namepos
+ 14) / 7)
191 rb
->lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
192 rb
->lcd_fillrect(0, font_h
*(i
+1), LCD_WIDTH
, font_h
); /* clear any trails left behind */
193 rb
->lcd_set_drawmode(DRMODE_SOLID
);
194 rb
->lcd_putsxy(namepos
, font_h
*(i
+1), name
);
195 rb
->lcd_update_rect(0, font_h
*(i
+1), LCD_WIDTH
, font_h
);
196 rb
->lcd_update_rect(CREDITS_TARGETPOS
, 0, credits_w
, font_h
);
198 /* exit on keypress */
199 btn
= rb
->button_get_w_tmo(HZ
/ANIM_SPEED
);
200 if (btn
!= BUTTON_NONE
&& !(btn
& BUTTON_REL
))
206 /* pause for a bit if needed */
207 btn
= rb
->button_get_w_tmo(HZ
*PAUSE_TIME
); /* exit on keypress */
208 if (btn
!= BUTTON_NONE
&& !(btn
& BUTTON_REL
))
211 /* now begin looping the in-out animation */
214 /* just a screen's worth at a time */
215 for(i
=0; i
<NUM_VISIBLE_LINES
; i
++)
222 rb
->snprintf(name
, sizeof(name
), "%s", credits
[j
+i
-NUM_VISIBLE_LINES
]);
223 rb
->lcd_getstringsize(name
, &name_w
, &name_h
);
225 /* fly out an existing line.. */
226 while(namepos
<LCD_WIDTH
+offset_dummy
)
228 rb
->lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
229 rb
->lcd_fillrect(0, font_h
*(i
+1), LCD_WIDTH
, font_h
); /* clear trails */
230 rb
->lcd_set_drawmode(DRMODE_SOLID
);
231 rb
->lcd_putsxy(namepos
, font_h
*(i
+1), name
);
232 rb
->lcd_update_rect(0, font_h
*(i
+1), LCD_WIDTH
, font_h
);
234 /* exit on keypress */
235 btn
= rb
->button_get_w_tmo(HZ
/ANIM_SPEED
);
236 if (btn
!= BUTTON_NONE
&& !(btn
& BUTTON_REL
))
239 namepos
+= offset_dummy
;
243 rb
->snprintf(name
, sizeof(name
), "%s", credits
[j
+i
]);
244 rb
->lcd_getstringsize(name
, &name_w
, &name_h
);
246 rb
->snprintf(elapsednames
, sizeof(elapsednames
), "[Credits] %d/%d",
248 rb
->lcd_getstringsize(elapsednames
, &credits_w
, NULL
);
249 rb
->lcd_putsxy(CREDITS_TARGETPOS
, 0, elapsednames
);
251 for(namepos
= 0-name_w
; namepos
<= name_targetpos
;
252 namepos
+= (name_targetpos
- namepos
+ 14) / 7)
254 rb
->lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
255 rb
->lcd_fillrect(0, font_h
*(i
+1), LCD_WIDTH
, font_h
);
256 rb
->lcd_set_drawmode(DRMODE_SOLID
);
257 rb
->lcd_putsxy(namepos
, font_h
*(i
+1), name
);
258 rb
->lcd_update_rect(0, font_h
*(i
+1), LCD_WIDTH
, font_h
);
259 rb
->lcd_update_rect(CREDITS_TARGETPOS
, 0, credits_w
, font_h
);
261 /* exit on keypress */
262 btn
= rb
->button_get_w_tmo(HZ
/ANIM_SPEED
);
263 if (btn
!= BUTTON_NONE
&& !(btn
& BUTTON_REL
))
267 namepos
= name_targetpos
;
273 btn
= rb
->button_get_w_tmo(HZ
*PAUSE_TIME
); /* exit on keypress */
274 if (btn
!= BUTTON_NONE
&& !(btn
& BUTTON_REL
))
278 btn
= rb
->button_get_w_tmo(HZ
*2.5); /* exit on keypress */
279 if (btn
!= BUTTON_NONE
&& !(btn
& BUTTON_REL
))
284 /* now make the text exit to the right */
285 for(credits_pos
= (LCD_WIDTH
/2)-(credits_w
/2); credits_pos
<= LCD_WIDTH
+offset_dummy
;
286 credits_pos
+= offset_dummy
, offset_dummy
++)
288 rb
->lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
289 rb
->lcd_fillrect(0, 0, LCD_WIDTH
, font_h
);
290 rb
->lcd_set_drawmode(DRMODE_SOLID
);
291 rb
->lcd_putsxy(credits_pos
, 0, elapsednames
);