Change i2c config on e200. Seems to speed things up somewhat.
[kugel-rb.git] / apps / plugins / credits.c
blob0bd2a511cd3b49281310b73adba4a1a1ab6f6305
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
19 #include "plugin.h"
21 PLUGIN_HEADER
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)
32 int j = 0;
33 int btn;
35 (void)parameter;
36 rb = api;
38 /* Turn off backlight timeout */
39 rb->backlight_set_timeout(1);
41 rb->show_logo();
42 #ifdef HAVE_LCD_CHARCELLS
43 rb->lcd_double_height(false);
44 #endif
46 /* Show the logo for about 3 secs allowing the user to stop */
47 for (j = 0; j < 15; j++) {
48 rb->sleep((HZ*2)/10);
50 btn = rb->button_get(false);
51 if (btn != BUTTON_NONE && !(btn & BUTTON_REL))
52 goto end_of_proc;
55 roll_credits();
57 end_of_proc:
58 /* Restore the values we've changed */
59 rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
61 return PLUGIN_OK;
64 #ifdef HAVE_LCD_CHARCELLS
66 void roll_credits(void)
68 int numnames = sizeof(credits)/sizeof(char*);
69 int curr_name = 0;
70 int curr_len = rb->utf8length(credits[0]);
71 int curr_index = 0;
72 int curr_line = 0;
73 int name, len, new_len, line, x;
75 while (1)
77 rb->lcd_clear_display();
79 name = curr_name;
80 x = -curr_index;
81 len = curr_len;
82 line = curr_line;
84 while (x < 11)
86 int x2;
88 if (x < 0)
89 rb->lcd_puts(0, line, credits[name] + rb->utf8seek(credits[name], -x));
90 else
91 rb->lcd_puts(x, line, credits[name]);
93 if (++name >= numnames)
94 break;
96 line ^= 1;
98 x2 = x + len/2;
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);
104 len = new_len;
106 rb->lcd_update();
108 /* abort on keypress */
109 if (rb->button_get_w_tmo(HZ/8) & BUTTON_REL)
110 return;
112 if (++curr_index >= curr_len)
114 if (++curr_name >= numnames)
115 break;
116 new_len = rb->utf8length(credits[curr_name]);
117 curr_index -= MAX(curr_len/2 + 2, curr_len - new_len/2 + 1);
118 curr_len = new_len;
119 curr_line ^= 1;
124 #else
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)
132 #define PAUSE_TIME 0
133 #define ANIM_SPEED 100
134 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
135 #define PAUSE_TIME 0
136 #define ANIM_SPEED 35
137 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
138 #define PAUSE_TIME 0
139 #define ANIM_SPEED 100
140 #else
141 #define PAUSE_TIME 1
142 #define ANIM_SPEED 40
143 #endif
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();
156 rb->lcd_update();
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",
162 j+1, numnames);
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",
184 i+1, numnames);
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))
201 return;
204 j+=i;
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))
209 return;
211 /* now begin looping the in-out animation */
212 while(j < numnames)
214 /* just a screen's worth at a time */
215 for(i=0; i<NUM_VISIBLE_LINES; i++)
217 if(j+i >= numnames)
218 break;
220 offset_dummy=1;
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))
237 return;
239 namepos += offset_dummy;
240 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",
247 j+i+1, numnames);
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))
264 return;
267 namepos = name_targetpos;
269 /* ..and repeat. */
271 j+=i;
273 btn = rb->button_get_w_tmo(HZ*PAUSE_TIME); /* exit on keypress */
274 if (btn != BUTTON_NONE && !(btn & BUTTON_REL))
275 return;
278 btn = rb->button_get_w_tmo(HZ*2.5); /* exit on keypress */
279 if (btn != BUTTON_NONE && !(btn & BUTTON_REL))
280 return;
282 offset_dummy = 1;
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);
292 rb->lcd_update();
296 #endif