Fix yellow
[Rockbox.git] / apps / plugins / logo.c
blob79ff6acb62c8c796ca14557f21d8ee07ec9fadd1
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 Jonas H�gqvist
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"
20 #include "playergfx.h"
22 PLUGIN_HEADER
24 #ifdef HAVE_LCD_BITMAP
25 #define DISPLAY_WIDTH LCD_WIDTH
26 #define DISPLAY_HEIGHT LCD_HEIGHT
27 #define RAND_SCALE 5
29 #ifdef HAVE_REMOTE_LCD
30 #define REMOTE_WIDTH LCD_REMOTE_WIDTH
31 #define REMOTE_HEIGHT LCD_REMOTE_HEIGHT
32 #include "remote_rockboxlogo.h"
33 #define REMOTE_LOGO_WIDTH BMPWIDTH_remote_rockboxlogo
34 #define REMOTE_LOGO_HEIGHT BMPHEIGHT_remote_rockboxlogo
35 #define REMOTE_LOGO remote_rockboxlogo
36 extern const fb_remote_data remote_rockboxlogo[];
37 #endif /* HAVE_REMOTE_LCD */
39 #define LOGO rockboxlogo
40 #include "rockboxlogo.h"
41 #define LOGO_WIDTH BMPWIDTH_rockboxlogo
42 #define LOGO_HEIGHT BMPHEIGHT_rockboxlogo
43 extern const fb_data rockboxlogo[];
45 #else /* !LCD_BITMAP */
46 #define DISPLAY_WIDTH 55
47 #define DISPLAY_HEIGHT 14
48 #define RAND_SCALE 2
49 #define LOGO_WIDTH 16
50 #define LOGO_HEIGHT 7
51 #define LOGO rockbox16x7
52 const unsigned char rockbox16x7[] = {
53 0x47, 0x18, 0xa6, 0xd8, 0x66, 0xde, 0xb7, 0x9b,
54 0x76, 0xdb, 0x26, 0xdb, 0x66, 0xde,
56 #endif /* !LCD_BITMAP */
58 /* variable button definitions */
59 #if CONFIG_KEYPAD == PLAYER_PAD
60 #define LP_QUIT BUTTON_STOP
61 #define LP_DEC_X BUTTON_LEFT
62 #define LP_INC_X BUTTON_RIGHT
63 #define LP_DEC_Y (BUTTON_ON | BUTTON_LEFT)
64 #define LP_INC_Y (BUTTON_ON | BUTTON_RIGHT)
66 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
67 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
68 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
69 #define LP_QUIT BUTTON_MENU
70 #define LP_DEC_X BUTTON_LEFT
71 #define LP_INC_X BUTTON_RIGHT
72 #define LP_DEC_Y BUTTON_SCROLL_BACK
73 #define LP_INC_Y BUTTON_SCROLL_FWD
75 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
76 #define LP_QUIT BUTTON_PLAY
77 #define LP_DEC_X BUTTON_LEFT
78 #define LP_INC_X BUTTON_RIGHT
79 #define LP_DEC_Y BUTTON_DOWN
80 #define LP_INC_Y BUTTON_UP
82 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
83 #define LP_QUIT BUTTON_POWER
84 #define LP_DEC_X BUTTON_LEFT
85 #define LP_INC_X BUTTON_RIGHT
86 #define LP_DEC_Y BUTTON_DOWN
87 #define LP_INC_Y BUTTON_UP
89 #elif CONFIG_KEYPAD == GIGABEAT_PAD
90 #define LP_QUIT BUTTON_POWER
91 #define LP_DEC_X BUTTON_LEFT
92 #define LP_INC_X BUTTON_RIGHT
93 #define LP_DEC_Y BUTTON_DOWN
94 #define LP_INC_Y BUTTON_UP
96 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
97 (CONFIG_KEYPAD == SANSA_C200_PAD)
98 #define LP_QUIT BUTTON_POWER
99 #define LP_DEC_X BUTTON_LEFT
100 #define LP_INC_X BUTTON_RIGHT
101 #define LP_DEC_Y BUTTON_DOWN
102 #define LP_INC_Y BUTTON_UP
104 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
105 #define LP_QUIT BUTTON_POWER
106 #define LP_DEC_X BUTTON_LEFT
107 #define LP_INC_X BUTTON_RIGHT
108 #define LP_DEC_Y BUTTON_SCROLL_DOWN
109 #define LP_INC_Y BUTTON_SCROLL_UP
111 #elif CONFIG_KEYPAD == MROBE500_PAD
112 #define LP_QUIT BUTTON_POWER
113 #define LP_DEC_X BUTTON_LEFT
114 #define LP_INC_X BUTTON_RIGHT
115 #define LP_DEC_Y BUTTON_RC_DOWN
116 #define LP_INC_Y BUTTON_RC_PLAY
118 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
119 #define LP_QUIT BUTTON_BACK
120 #define LP_DEC_X BUTTON_LEFT
121 #define LP_INC_X BUTTON_RIGHT
122 #define LP_DEC_Y BUTTON_DOWN
123 #define LP_INC_Y BUTTON_UP
125 #elif CONFIG_KEYPAD == MROBE100_PAD
126 #define LP_QUIT BUTTON_POWER
127 #define LP_DEC_X BUTTON_LEFT
128 #define LP_INC_X BUTTON_RIGHT
129 #define LP_DEC_Y BUTTON_DOWN
130 #define LP_INC_Y BUTTON_UP
132 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
133 #define LP_QUIT BUTTON_RC_REC
134 #define LP_DEC_X BUTTON_RC_REW
135 #define LP_INC_X BUTTON_RC_FF
136 #define LP_DEC_Y BUTTON_RC_VOL_DOWN
137 #define LP_INC_Y BUTTON_RC_VOL_UP
139 #elif CONFIG_KEYPAD == COWOND2_PAD
140 #define LP_QUIT BUTTON_POWER
142 #else
143 #define LP_QUIT BUTTON_OFF
144 #define LP_DEC_X BUTTON_LEFT
145 #define LP_INC_X BUTTON_RIGHT
146 #define LP_DEC_Y BUTTON_DOWN
147 #define LP_INC_Y BUTTON_UP
148 #endif
150 #ifdef CONFIG_REMOTE_KEYPAD
151 #if (CONFIG_REMOTE_KEYPAD == H100_REMOTE) || \
152 (CONFIG_REMOTE_KEYPAD == H300_REMOTE)
153 #define LP_R_QUIT BUTTON_RC_STOP
154 #define LP_R_DEC_X BUTTON_RC_REW
155 #define LP_R_INC_X BUTTON_RC_FF
156 #define LP_R_DEC_Y BUTTON_RC_SOURCE
157 #define LP_R_INC_Y BUTTON_RC_BITRATE
158 #endif
159 #endif /* CONFIG_REMOTE_KEYPAD */
161 #ifdef HAVE_TOUCHPAD
162 #ifndef LP_QUIT
163 #define LP_QUIT BUTTON_TOPLEFT
164 #endif
165 #ifndef LP_DEC_X
166 #define LP_DEC_X BUTTON_MIDLEFT
167 #endif
168 #ifndef LP_INC_X
169 #define LP_INC_X BUTTON_MIDRIGHT
170 #endif
171 #ifndef LP_DEC_Y
172 #define LP_DEC_Y BUTTON_TOPMIDDLE
173 #endif
174 #ifndef LP_INC_Y
175 #define LP_INC_Y BUTTON_BOTTOMMIDDLE
176 #endif
177 #endif
179 enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) {
180 int button;
181 int timer = 10;
182 int x = (DISPLAY_WIDTH / 2) - (LOGO_WIDTH / 2);
183 int y = (DISPLAY_HEIGHT / 2) - (LOGO_HEIGHT / 2);
184 const struct plugin_api* rb = api;
185 int dx;
186 int dy;
187 #ifdef HAVE_LCD_CHARCELLS
188 int cpos = -1;
189 int old_cpos = -1;
190 #endif
192 (void)parameter;
194 #ifdef HAVE_LCD_CHARCELLS
195 if (!pgfx_init(rb, 4, 2)) {
196 rb->splash(HZ*2, "Old LCD :(");
197 return PLUGIN_OK;
199 #endif
200 rb->srand(*rb->current_tick);
201 dx = rb->rand()%(2*RAND_SCALE+1) - RAND_SCALE;
202 dy = rb->rand()%(2*RAND_SCALE+1) - RAND_SCALE;
204 while (1) {
205 #ifdef HAVE_LCD_BITMAP
206 rb->lcd_clear_display();
207 rb->lcd_bitmap(LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT);
208 #ifdef REMOTE_LOGO
209 rb->lcd_remote_clear_display();
210 rb->lcd_remote_bitmap(REMOTE_LOGO,
211 (x * (REMOTE_WIDTH - REMOTE_LOGO_WIDTH)) / (DISPLAY_WIDTH - LOGO_WIDTH),
212 (y * (REMOTE_HEIGHT - REMOTE_LOGO_HEIGHT)) / (DISPLAY_HEIGHT - LOGO_HEIGHT),
213 REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT);
214 #endif
215 #else
216 pgfx_clear_display();
217 pgfx_mono_bitmap(LOGO, x % 5, y, LOGO_WIDTH, LOGO_HEIGHT);
218 cpos = x / 5;
219 #endif
221 x += dx;
222 if (x < 0) {
223 dx = -dx;
224 x = 0;
226 if (x > DISPLAY_WIDTH - LOGO_WIDTH) {
227 dx = -dx;
228 x = DISPLAY_WIDTH - LOGO_WIDTH;
231 y += dy;
232 if (y < 0) {
233 dy = -dy;
234 y = 0;
236 if (y > DISPLAY_HEIGHT - LOGO_HEIGHT) {
237 dy = -dy;
238 y = DISPLAY_HEIGHT - LOGO_HEIGHT;
241 #ifdef HAVE_LCD_BITMAP
242 rb->lcd_update();
243 #ifdef REMOTE_LOGO
244 rb->lcd_remote_update();
245 #endif
246 #else
247 if (cpos != old_cpos) {
248 rb->lcd_clear_display();
249 pgfx_display(cpos, 0);
250 old_cpos = cpos;
252 pgfx_update();
253 #endif
254 rb->sleep(HZ/timer);
256 button = rb->button_get(false);
257 switch (button) {
258 case LP_QUIT:
259 #ifdef CONFIG_REMOTE_KEYPAD
260 case LP_R_QUIT:
261 #endif
262 #ifdef HAVE_LCD_CHARCELLS
263 pgfx_release();
264 #endif
265 return PLUGIN_OK;
266 case LP_DEC_X:
267 #ifdef CONFIG_REMOTE_KEYPAD
268 case LP_R_DEC_X:
269 #endif
270 if (dx)
271 dx += (dx < 0) ? 1 : -1;
272 break;
273 case LP_INC_X:
274 #ifdef CONFIG_REMOTE_KEYPAD
275 case LP_R_INC_X:
276 #endif
277 dx += (dx < 0) ? -1 : 1;
278 break;
279 case LP_DEC_Y:
280 #ifdef CONFIG_REMOTE_KEYPAD
281 case LP_R_DEC_Y:
282 #endif
283 if (dy)
284 dy += (dy < 0) ? 1 : -1;
285 break;
286 case LP_INC_Y:
287 #ifdef CONFIG_REMOTE_KEYPAD
288 case LP_R_INC_Y:
289 #endif
290 dy += (dy < 0) ? -1 : 1;
291 break;
293 default:
294 if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
295 #ifdef HAVE_LCD_CHARCELLS
296 pgfx_release();
297 #endif
298 return PLUGIN_USB_CONNECTED;
300 break;