diff options
Diffstat (limited to 'apps/plugins/credits.c')
-rw-r--r-- | apps/plugins/credits.c | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c new file mode 100644 index 0000000000..f172cc6c18 --- /dev/null +++ b/apps/plugins/credits.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Robert Hak <rhak at ramapo.edu> | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "plugin.h" | ||
20 | |||
21 | void roll_credits(void); | ||
22 | const char* const credits[] = { | ||
23 | #include "credits.raw" /* generated list of names from docs/CREDITS */ | ||
24 | }; | ||
25 | |||
26 | static struct plugin_api* rb; | ||
27 | |||
28 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | ||
29 | { | ||
30 | int j = 0; | ||
31 | int btn; | ||
32 | |||
33 | TEST_PLUGIN_API(api); | ||
34 | (void)parameter; | ||
35 | rb = api; | ||
36 | |||
37 | rb->show_logo(); | ||
38 | #ifdef HAVE_LCD_CHARCELLS | ||
39 | rb->lcd_double_height(false); | ||
40 | #endif | ||
41 | |||
42 | for (j = 0; j < 10; j++) { | ||
43 | rb->sleep((HZ*2)/10); | ||
44 | |||
45 | btn = rb->button_get(false); | ||
46 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
47 | return PLUGIN_OK; | ||
48 | } | ||
49 | |||
50 | roll_credits(); | ||
51 | |||
52 | return PLUGIN_OK; | ||
53 | } | ||
54 | |||
55 | #ifdef HAVE_LCD_CHARCELLS | ||
56 | void roll_credits(void) | ||
57 | { | ||
58 | int numnames = sizeof(credits)/sizeof(char*); | ||
59 | int curr_name = 0; | ||
60 | int curr_len = rb->strlen(credits[0]); | ||
61 | int curr_index = 0; | ||
62 | int curr_line = 0; | ||
63 | int name, len, new_len, line, x; | ||
64 | |||
65 | while (1) | ||
66 | { | ||
67 | rb->lcd_clear_display(); | ||
68 | |||
69 | name = curr_name; | ||
70 | x = -curr_index; | ||
71 | len = curr_len; | ||
72 | line = curr_line; | ||
73 | |||
74 | while (x < 11) | ||
75 | { | ||
76 | int x2; | ||
77 | |||
78 | if (x < 0) | ||
79 | rb->lcd_puts(0, line, credits[name] - x); | ||
80 | else | ||
81 | rb->lcd_puts(x, line, credits[name]); | ||
82 | |||
83 | if (++name >= numnames) | ||
84 | break; | ||
85 | line ^= 1; | ||
86 | |||
87 | x2 = x + len/2; | ||
88 | if ((unsigned)x2 < 11) | ||
89 | rb->lcd_putc(x2, line, '*'); | ||
90 | |||
91 | new_len = rb->strlen(credits[name]); | ||
92 | x += MAX(len/2 + 2, len - new_len/2 + 1); | ||
93 | len = new_len; | ||
94 | } | ||
95 | /* abort on keypress */ | ||
96 | if (rb->button_get_w_tmo(HZ/8) & BUTTON_REL) | ||
97 | return; | ||
98 | |||
99 | if (++curr_index >= curr_len) | ||
100 | { | ||
101 | if (++curr_name >= numnames) | ||
102 | break; | ||
103 | new_len = rb->strlen(credits[curr_name]); | ||
104 | curr_index -= MAX(curr_len/2 + 2, curr_len - new_len/2 + 1); | ||
105 | curr_len = new_len; | ||
106 | curr_line ^= 1; | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | #else | ||
111 | |||
112 | void roll_credits(void) | ||
113 | { | ||
114 | int i; | ||
115 | int line = 0; | ||
116 | int numnames = sizeof(credits)/sizeof(char*); | ||
117 | char buffer[40]; | ||
118 | |||
119 | int y=LCD_HEIGHT; | ||
120 | |||
121 | int height; | ||
122 | int width; | ||
123 | |||
124 | rb->lcd_setfont(FONT_UI); | ||
125 | |||
126 | rb->lcd_getstringsize("A", &width, &height); | ||
127 | |||
128 | while(1) { | ||
129 | rb->lcd_clear_display(); | ||
130 | for ( i=0; i <= (LCD_HEIGHT-y)/height; i++ ) | ||
131 | rb->lcd_putsxy(0, i*height+y, line+i<numnames?credits[line+i]:""); | ||
132 | rb->snprintf(buffer, sizeof(buffer), " [Credits] %2d/%2d ", | ||
133 | line+1, numnames); | ||
134 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
135 | rb->lcd_fillrect(0, 0, LCD_WIDTH, height); | ||
136 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
137 | rb->lcd_putsxy(0, 0, buffer); | ||
138 | rb->lcd_update(); | ||
139 | |||
140 | if (rb->button_get_w_tmo(HZ/20) & BUTTON_REL) | ||
141 | return; | ||
142 | |||
143 | y--; | ||
144 | |||
145 | if(y<0) { | ||
146 | line++; | ||
147 | if(line >= numnames) | ||
148 | break; | ||
149 | y+=height; | ||
150 | } | ||
151 | |||
152 | } | ||
153 | } | ||
154 | #endif | ||