summaryrefslogtreecommitdiff
path: root/apps/plugins/credits.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/credits.c')
-rw-r--r--apps/plugins/credits.c188
1 files changed, 147 insertions, 41 deletions
diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c
index 531ad1f5b7..1b855dbd88 100644
--- a/apps/plugins/credits.c
+++ b/apps/plugins/credits.c
@@ -21,6 +21,66 @@
21 21
22PLUGIN_HEADER 22PLUGIN_HEADER
23 23
24#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
25
26#define QUIT BUTTON_OFF
27#define UP BUTTON_UP
28#define DOWN BUTTON_DOWN
29
30#elif CONFIG_KEYPAD == ONDIO_PAD
31
32#define QUIT BUTTON_OFF
33#define UP BUTTON_UP
34#define DOWN BUTTON_DOWN
35
36#elif CONFIG_KEYPAD == RECORDER_PAD
37
38#define QUIT BUTTON_OFF
39#define UP BUTTON_UP
40#define DOWN BUTTON_DOWN
41
42#elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
43
44#define QUIT BUTTON_OFF
45#define UP BUTTON_UP
46#define DOWN BUTTON_DOWN
47
48#elif (CONFIG_KEYPAD == IPOD_3G_PAD) || \
49 (CONFIG_KEYPAD == IPOD_4G_PAD)
50
51#define QUIT BUTTON_MENU
52#define UP BUTTON_SCROLL_BACK
53#define DOWN BUTTON_SCROLL_FWD
54
55#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
56
57#define QUIT BUTTON_A
58#define UP BUTTON_UP
59#define DOWN BUTTON_DOWN
60
61#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD /* grayscale at the moment */
62
63#define QUIT BUTTON_POWER
64#define UP BUTTON_UP
65#define DOWN BUTTON_DOWN
66
67#elif CONFIG_KEYPAD == SANSA_E200_PAD
68
69#define QUIT BUTTON_POWER
70#define UP BUTTON_SCROLL_UP
71#define DOWN BUTTON_SCROLL_DOWN
72
73#elif CONFIG_KEYPAD == IRIVER_H10_PAD /* grayscale at the moment */
74
75#define QUIT BUTTON_POWER
76#define UP BUTTON_SCROLL_UP
77#define DOWN BUTTON_SCROLL_DOWN
78
79#else
80#error Unsupported keypad
81#endif
82
83
24void roll_credits(void); 84void roll_credits(void);
25const char* const credits[] = { 85const char* const credits[] = {
26#include "credits.raw" /* generated list of names from docs/CREDITS */ 86#include "credits.raw" /* generated list of names from docs/CREDITS */
@@ -49,7 +109,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
49 rb->sleep((HZ*2)/10); 109 rb->sleep((HZ*2)/10);
50 110
51 btn = rb->button_get(false); 111 btn = rb->button_get(false);
52 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 112 if (btn != BUTTON_NONE && (btn & QUIT))
53 goto end_of_proc; 113 goto end_of_proc;
54 } 114 }
55 115
@@ -107,7 +167,7 @@ void roll_credits(void)
107 rb->lcd_update(); 167 rb->lcd_update();
108 168
109 /* abort on keypress */ 169 /* abort on keypress */
110 if (rb->button_get_w_tmo(HZ/8) & BUTTON_REL) 170 if (rb->button_get_w_tmo(HZ/8) & QUIT)
111 return; 171 return;
112 172
113 if (++curr_index >= curr_len) 173 if (++curr_index >= curr_len)
@@ -147,7 +207,7 @@ void roll_credits(void)
147 #define NUM_VISIBLE_LINES (LCD_HEIGHT/font_h - 1) 207 #define NUM_VISIBLE_LINES (LCD_HEIGHT/font_h - 1)
148 #define CREDITS_TARGETPOS ((LCD_WIDTH/2)-(credits_w/2)) 208 #define CREDITS_TARGETPOS ((LCD_WIDTH/2)-(credits_w/2))
149 209
150 int i=0, j=0, namepos=0, offset_dummy, btn; 210 int i=0, j=0, k=0, namepos=0, offset_dummy, btn;
151 int name_w, name_h, name_targetpos=1, font_h; 211 int name_w, name_h, name_targetpos=1, font_h;
152 int credits_w, credits_pos; 212 int credits_w, credits_pos;
153 int numnames = (sizeof(credits)/sizeof(char*)); 213 int numnames = (sizeof(credits)/sizeof(char*));
@@ -197,9 +257,9 @@ void roll_credits(void)
197 rb->lcd_update_rect(0, font_h*(i+1), LCD_WIDTH, font_h); 257 rb->lcd_update_rect(0, font_h*(i+1), LCD_WIDTH, font_h);
198 rb->lcd_update_rect(CREDITS_TARGETPOS, 0, credits_w, font_h); 258 rb->lcd_update_rect(CREDITS_TARGETPOS, 0, credits_w, font_h);
199 259
200 /* exit on keypress */ 260 /* exit on power key */
201 btn = rb->button_get_w_tmo(HZ/ANIM_SPEED); 261 btn = rb->button_get_w_tmo(HZ/ANIM_SPEED);
202 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 262 if (btn != BUTTON_NONE && (btn & QUIT))
203 return; 263 return;
204 } 264 }
205 } 265 }
@@ -207,52 +267,91 @@ void roll_credits(void)
207 267
208 /* pause for a bit if needed */ 268 /* pause for a bit if needed */
209 btn = rb->button_get_w_tmo(HZ*PAUSE_TIME); /* exit on keypress */ 269 btn = rb->button_get_w_tmo(HZ*PAUSE_TIME); /* exit on keypress */
210 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 270 if (btn != BUTTON_NONE && (btn & QUIT))
211 return; 271 return;
212 272
213 /* now begin looping the in-out animation */ 273 /* now begin looping the in-out animation */
214 while(j < numnames) 274 do {
215 { 275 for(; j < numnames; j+=i)
216 /* just a screen's worth at a time */
217 for(i=0; i<NUM_VISIBLE_LINES; i++)
218 { 276 {
219 if(j+i >= numnames) 277 /* just a screen's worth at a time */
278 for(i=0; i<NUM_VISIBLE_LINES; i++)
279 {
280 if(j+i >= numnames)
220 break; 281 break;
221 282
222 offset_dummy=1; 283 offset_dummy=1;
223 284
224 rb->snprintf(name, sizeof(name), "%s", credits[j+i-NUM_VISIBLE_LINES]); 285 rb->snprintf(name, sizeof(name), "%s",
225 rb->lcd_getstringsize(name, &name_w, &name_h); 286 credits[(j>=NUM_VISIBLE_LINES)?
287 j+i-NUM_VISIBLE_LINES:j+i]);
288 rb->lcd_getstringsize(name, &name_w, &name_h);
226 289
227 /* fly out an existing line.. */ 290 /* fly out an existing line.. */
228 while(namepos<LCD_WIDTH+offset_dummy) 291 while(namepos<LCD_WIDTH+offset_dummy)
229 { 292 {
230 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 293 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
231 rb->lcd_fillrect(0, font_h*(i+1), LCD_WIDTH, font_h); /* clear trails */ 294 rb->lcd_fillrect(0, font_h*(i+1), LCD_WIDTH, font_h); /* clear trails */
232 rb->lcd_set_drawmode(DRMODE_SOLID); 295 rb->lcd_set_drawmode(DRMODE_SOLID);
233 rb->lcd_putsxy(namepos, font_h*(i+1), name); 296 rb->lcd_putsxy(namepos, font_h*(i+1), name);
234 rb->lcd_update_rect(0, font_h*(i+1), LCD_WIDTH, font_h); 297 rb->lcd_update_rect(0, font_h*(i+1), LCD_WIDTH, font_h);
235 298
236 /* exit on keypress */ 299 /* exit on keypress, react to scrolling */
237 btn = rb->button_get_w_tmo(HZ/ANIM_SPEED); 300 btn = rb->button_get_w_tmo(HZ/ANIM_SPEED);
238 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 301 if (btn != BUTTON_NONE)
302 {
303 if (btn & QUIT)
239 return; 304 return;
240 305 else if ((btn & UP) ^ (btn & DOWN))
306 {
307 /* compute the new position */
308 j+=((btn & UP)?-1:1)*(NUM_VISIBLE_LINES/2);
309 if (j+i >= numnames) j=numnames-i-1;
310 if (j < 0) j = 0;
311
312 /* and refresh the whole screen */
313 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
314 rb->lcd_fillrect(0, 0, LCD_WIDTH,
315 font_h * (NUM_VISIBLE_LINES+1));
316 rb->lcd_set_drawmode(DRMODE_SOLID);
317
318 rb->snprintf(elapsednames, sizeof(elapsednames),
319 "[Credits] %d/%d", j+i+1, numnames);
320 rb->lcd_getstringsize(elapsednames, &credits_w, NULL);
321 rb->lcd_putsxy(CREDITS_TARGETPOS, 0, elapsednames);
322
323 for (k=0; k<NUM_VISIBLE_LINES; k++)
324 if (k!=i)
325 {
326 rb->snprintf(name, sizeof(name), "%s",
327 credits[(j>=NUM_VISIBLE_LINES)?
328 ((k<i)?
329 (j+k):(j+k-NUM_VISIBLE_LINES)):
330 j+k]);
331 rb->lcd_putsxy(0, font_h*(k+1), name);
332 }
333 rb->lcd_update_rect(0, font_h, LCD_WIDTH,
334 font_h * (NUM_VISIBLE_LINES+1));
335 break;
336 }
337 }
241 namepos += offset_dummy; 338 namepos += offset_dummy;
242 offset_dummy++; 339 offset_dummy++;
243 } 340 }
244 341
245 rb->snprintf(name, sizeof(name), "%s", credits[j+i]); 342 rb->snprintf(name, sizeof(name), "%s", credits[j+i]);
246 rb->lcd_getstringsize(name, &name_w, &name_h); 343 rb->lcd_getstringsize(name, &name_w, &name_h);
247 344
248 rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d/%d", 345 rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d/%d",
249 j+i+1, numnames); 346 j+i+1, numnames);
250 rb->lcd_getstringsize(elapsednames, &credits_w, NULL); 347 rb->lcd_getstringsize(elapsednames, &credits_w, NULL);
251 rb->lcd_putsxy(CREDITS_TARGETPOS, 0, elapsednames); 348 rb->lcd_putsxy(CREDITS_TARGETPOS, 0, elapsednames);
349 if (j+i < NUM_VISIBLE_LINES) /* takes care of trail on loop */
350 rb->lcd_update_rect(0, 0, LCD_WIDTH, font_h);
252 351
253 for(namepos = 0-name_w; namepos <= name_targetpos; 352 for(namepos = 0-name_w; namepos <= name_targetpos;
254 namepos += (name_targetpos - namepos + 14) / 7) 353 namepos += (name_targetpos - namepos + 14) / 7)
255 { 354 {
256 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 355 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
257 rb->lcd_fillrect(0, font_h*(i+1), LCD_WIDTH, font_h); 356 rb->lcd_fillrect(0, font_h*(i+1), LCD_WIDTH, font_h);
258 rb->lcd_set_drawmode(DRMODE_SOLID); 357 rb->lcd_set_drawmode(DRMODE_SOLID);
@@ -262,23 +361,30 @@ void roll_credits(void)
262 361
263 /* exit on keypress */ 362 /* exit on keypress */
264 btn = rb->button_get_w_tmo(HZ/ANIM_SPEED); 363 btn = rb->button_get_w_tmo(HZ/ANIM_SPEED);
265 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 364 if (btn != BUTTON_NONE && (btn & QUIT))
266 return; 365 return;
267 } 366 }
268 367
269 namepos = name_targetpos; 368 namepos = name_targetpos;
270 369
271 /* ..and repeat. */ 370 /* ..and repeat. */
272 } 371 }
273 j+=i;
274 372
275 btn = rb->button_get_w_tmo(HZ*PAUSE_TIME); /* exit on keypress */ 373 btn = rb->button_get_w_tmo(HZ*PAUSE_TIME); /* exit on keypress */
276 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 374 if (btn != BUTTON_NONE && (btn & QUIT))
277 return; 375 return;
278 } 376 }
377
378 j = 0;
379 if(k) {
380 /* on loop, the new credit line might shorten */
381 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
382 rb->lcd_fillrect(0, 0, LCD_WIDTH, font_h);
383 }
384 } while(k); /* repeat in-out animation forever if scrolling occured */
279 385
280 btn = rb->button_get_w_tmo(HZ*2.5); /* exit on keypress */ 386 btn = rb->button_get_w_tmo(HZ*2.5); /* exit on keypress */
281 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 387 if (btn != BUTTON_NONE && (btn & QUIT))
282 return; 388 return;
283 389
284 offset_dummy = 1; 390 offset_dummy = 1;