fix red.
[kugel-rb.git] / apps / plugins / bounce.c
blobf193818850499116344f0ecb957834284902bcf8
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Daniel Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 **************************************************************************/
21 #include "plugin.h"
22 #include "time.h"
23 #include "lib/fixedpoint.h"
25 PLUGIN_HEADER
27 #define SS_TITLE "Bouncer"
29 #define YSPEED 2
30 #define XSPEED 3
31 #define YADD -4
33 /* variable button definitions */
34 #if CONFIG_KEYPAD == RECORDER_PAD
35 #define BOUNCE_LEFT BUTTON_LEFT
36 #define BOUNCE_RIGHT BUTTON_RIGHT
37 #define BOUNCE_UP BUTTON_UP
38 #define BOUNCE_DOWN BUTTON_DOWN
39 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
40 #define BOUNCE_MODE (BUTTON_ON | BUTTON_REL)
42 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
43 #define BOUNCE_LEFT BUTTON_LEFT
44 #define BOUNCE_RIGHT BUTTON_RIGHT
45 #define BOUNCE_UP BUTTON_UP
46 #define BOUNCE_DOWN BUTTON_DOWN
47 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
48 #define BOUNCE_MODE (BUTTON_ON | BUTTON_REL)
50 #elif CONFIG_KEYPAD == ONDIO_PAD
51 #define BOUNCE_LEFT BUTTON_LEFT
52 #define BOUNCE_RIGHT BUTTON_RIGHT
53 #define BOUNCE_UP BUTTON_UP
54 #define BOUNCE_DOWN BUTTON_DOWN
55 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
56 #define BOUNCE_MODE (BUTTON_MENU | BUTTON_REL)
58 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
59 (CONFIG_KEYPAD == IRIVER_H300_PAD)
60 #define BOUNCE_LEFT BUTTON_LEFT
61 #define BOUNCE_RIGHT BUTTON_RIGHT
62 #define BOUNCE_UP BUTTON_UP
63 #define BOUNCE_DOWN BUTTON_DOWN
64 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
65 #define BOUNCE_MODE (BUTTON_SELECT | BUTTON_REL)
67 #define BOUNCE_RC_QUIT (BUTTON_RC_STOP | BUTTON_REL)
69 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
70 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
71 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
72 #define BOUNCE_LEFT BUTTON_LEFT
73 #define BOUNCE_RIGHT BUTTON_RIGHT
74 #define BOUNCE_UP BUTTON_SCROLL_BACK
75 #define BOUNCE_DOWN BUTTON_SCROLL_FWD
76 #define BOUNCE_QUIT (BUTTON_MENU | BUTTON_REL)
77 #define BOUNCE_MODE (BUTTON_SELECT | BUTTON_REL)
79 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
80 #define BOUNCE_LEFT BUTTON_LEFT
81 #define BOUNCE_RIGHT BUTTON_RIGHT
82 #define BOUNCE_UP BUTTON_UP
83 #define BOUNCE_DOWN BUTTON_DOWN
84 #define BOUNCE_QUIT BUTTON_POWER
85 #define BOUNCE_MODE BUTTON_PLAY
87 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
88 #define BOUNCE_LEFT BUTTON_LEFT
89 #define BOUNCE_RIGHT BUTTON_RIGHT
90 #define BOUNCE_UP BUTTON_UP
91 #define BOUNCE_DOWN BUTTON_DOWN
92 #define BOUNCE_QUIT BUTTON_POWER
93 #define BOUNCE_MODE BUTTON_A
95 #elif (CONFIG_KEYPAD == SANSA_E200_PAD)
96 #define BOUNCE_LEFT BUTTON_LEFT
97 #define BOUNCE_RIGHT BUTTON_RIGHT
98 #define BOUNCE_UP BUTTON_SCROLL_BACK
99 #define BOUNCE_DOWN BUTTON_SCROLL_FWD
100 #define BOUNCE_QUIT BUTTON_POWER
101 #define BOUNCE_MODE BUTTON_SELECT
103 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
104 #define BOUNCE_LEFT BUTTON_LEFT
105 #define BOUNCE_RIGHT BUTTON_RIGHT
106 #define BOUNCE_UP BUTTON_SCROLL_BACK
107 #define BOUNCE_DOWN BUTTON_SCROLL_FWD
108 #define BOUNCE_QUIT (BUTTON_HOME|BUTTON_REPEAT)
109 #define BOUNCE_MODE BUTTON_SELECT
111 #elif CONFIG_KEYPAD == SANSA_C200_PAD || \
112 CONFIG_KEYPAD == SANSA_CLIP_PAD || \
113 CONFIG_KEYPAD == SANSA_M200_PAD
114 #define BOUNCE_LEFT BUTTON_LEFT
115 #define BOUNCE_RIGHT BUTTON_RIGHT
116 #define BOUNCE_UP BUTTON_UP
117 #define BOUNCE_DOWN BUTTON_DOWN
118 #define BOUNCE_QUIT BUTTON_POWER
119 #define BOUNCE_MODE BUTTON_SELECT
121 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
122 #define BOUNCE_LEFT BUTTON_LEFT
123 #define BOUNCE_RIGHT BUTTON_RIGHT
124 #define BOUNCE_UP BUTTON_SCROLL_UP
125 #define BOUNCE_DOWN BUTTON_SCROLL_DOWN
126 #define BOUNCE_QUIT BUTTON_POWER
127 #define BOUNCE_MODE BUTTON_PLAY
129 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
130 #define BOUNCE_LEFT BUTTON_LEFT
131 #define BOUNCE_RIGHT BUTTON_RIGHT
132 #define BOUNCE_UP BUTTON_UP
133 #define BOUNCE_DOWN BUTTON_DOWN
134 #define BOUNCE_QUIT BUTTON_BACK
135 #define BOUNCE_MODE BUTTON_MENU
137 #elif (CONFIG_KEYPAD == MROBE100_PAD)
138 #define BOUNCE_LEFT BUTTON_LEFT
139 #define BOUNCE_RIGHT BUTTON_RIGHT
140 #define BOUNCE_UP BUTTON_UP
141 #define BOUNCE_DOWN BUTTON_DOWN
142 #define BOUNCE_QUIT BUTTON_POWER
143 #define BOUNCE_MODE BUTTON_DISPLAY
145 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
146 #define BOUNCE_LEFT BUTTON_RC_REW
147 #define BOUNCE_RIGHT BUTTON_RC_FF
148 #define BOUNCE_UP BUTTON_RC_VOL_UP
149 #define BOUNCE_DOWN BUTTON_RC_VOL_DOWN
150 #define BOUNCE_QUIT BUTTON_RC_REC
151 #define BOUNCE_MODE BUTTON_RC_MODE
153 #elif (CONFIG_KEYPAD == COWON_D2_PAD)
154 #define BOUNCE_QUIT BUTTON_POWER
155 #define BOUNCE_MODE BUTTON_MENU
157 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
158 #define BOUNCE_LEFT BUTTON_LEFT
159 #define BOUNCE_RIGHT BUTTON_RIGHT
160 #define BOUNCE_UP BUTTON_UP
161 #define BOUNCE_DOWN BUTTON_DOWN
162 #define BOUNCE_QUIT BUTTON_BACK
163 #define BOUNCE_MODE BUTTON_MENU
165 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
166 #define BOUNCE_LEFT BUTTON_LEFT
167 #define BOUNCE_RIGHT BUTTON_RIGHT
168 #define BOUNCE_UP BUTTON_UP
169 #define BOUNCE_DOWN BUTTON_DOWN
170 #define BOUNCE_QUIT BUTTON_POWER
171 #define BOUNCE_MODE BUTTON_MENU
173 #elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
174 #define BOUNCE_LEFT BUTTON_PREV
175 #define BOUNCE_RIGHT BUTTON_NEXT
176 #define BOUNCE_UP BUTTON_UP
177 #define BOUNCE_DOWN BUTTON_DOWN
178 #define BOUNCE_QUIT BUTTON_POWER
179 #define BOUNCE_MODE BUTTON_MENU
181 #elif (CONFIG_KEYPAD == ONDAVX747_PAD)
182 #define BOUNCE_QUIT BUTTON_POWER
183 #define BOUNCE_MODE BUTTON_MENU
185 #elif (CONFIG_KEYPAD == ONDAVX777_PAD)
186 #define BOUNCE_QUIT BUTTON_POWER
188 #elif CONFIG_KEYPAD == MROBE500_PAD
189 #define BOUNCE_QUIT BUTTON_POWER
191 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
192 #define BOUNCE_LEFT BUTTON_LEFT
193 #define BOUNCE_RIGHT BUTTON_RIGHT
194 #define BOUNCE_UP BUTTON_UP
195 #define BOUNCE_DOWN BUTTON_DOWN
196 #define BOUNCE_QUIT BUTTON_FFWD
197 #define BOUNCE_MODE BUTTON_PLAY
199 #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
200 #define BOUNCE_LEFT BUTTON_PREV
201 #define BOUNCE_RIGHT BUTTON_NEXT
202 #define BOUNCE_UP BUTTON_UP
203 #define BOUNCE_DOWN BUTTON_DOWN
204 #define BOUNCE_QUIT BUTTON_REC
205 #define BOUNCE_MODE BUTTON_MENU
207 #elif CONFIG_KEYPAD == MPIO_HD200_PAD
208 #define BOUNCE_LEFT BUTTON_VOL_DOWN
209 #define BOUNCE_RIGHT BUTTON_VOL_UP
210 #define BOUNCE_UP BUTTON_PREV
211 #define BOUNCE_DOWN BUTTON_NEXT
212 #define BOUNCE_QUIT (BUTTON_REC | BUTTON_PLAY)
213 #define BOUNCE_MODE BUTTON_SELECT
215 #else
216 #error No keymap defined!
217 #endif
219 #ifdef HAVE_TOUCHSCREEN
220 #ifndef BOUNCE_LEFT
221 #define BOUNCE_LEFT BUTTON_MIDLEFT
222 #endif
223 #ifndef BOUNCE_RIGHT
224 #define BOUNCE_RIGHT BUTTON_MIDRIGHT
225 #endif
226 #ifndef BOUNCE_UP
227 #define BOUNCE_UP BUTTON_TOPMIDDLE
228 #endif
229 #ifndef BOUNCE_DOWN
230 #define BOUNCE_DOWN BUTTON_BOTTOMMIDDLE
231 #endif
232 #ifndef BOUNCE_QUIT
233 #define BOUNCE_QUIT BUTTON_TOPLEFT
234 #endif
235 #ifndef BOUNCE_MODE
236 #define BOUNCE_MODE BUTTON_CENTER
237 #endif
238 #endif
240 #define LETTER_WIDTH 11
241 #define LETTER_HEIGHT 16
243 const unsigned char char_gen_12x16[][22] =
245 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
246 { 0x00,0x00,0x00,0x7c,0xff,0xff,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00 },
247 { 0x00,0x00,0x3c,0x3c,0x00,0x00,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
248 { 0x00,0x10,0x90,0xf0,0x7e,0x1e,0x90,0xf0,0x7e,0x1e,0x10,0x02,0x1e,0x1f,0x03,0x02,0x1e,0x1f,0x03,0x02,0x00,0x00 },
249 { 0x00,0x78,0xfc,0xcc,0xff,0xff,0xcc,0xcc,0x88,0x00,0x00,0x00,0x04,0x0c,0x0c,0x3f,0x3f,0x0c,0x0f,0x07,0x00,0x00 },
250 { 0x00,0x38,0x38,0x38,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x38,0x38,0x38,0x00 },
251 { 0x00,0x00,0xb8,0xfc,0xc6,0xe2,0x3e,0x1c,0x00,0x00,0x00,0x00,0x1f,0x3f,0x31,0x21,0x37,0x1e,0x1c,0x36,0x22,0x00 },
252 { 0x00,0x00,0x00,0x27,0x3f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
253 { 0x00,0x00,0xf0,0xfc,0xfe,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x0f,0x1f,0x38,0x20,0x20,0x00,0x00,0x00 },
254 { 0x00,0x00,0x01,0x01,0x07,0xfe,0xfc,0xf0,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x38,0x1f,0x0f,0x03,0x00,0x00,0x00 },
255 { 0x00,0x98,0xb8,0xe0,0xf8,0xf8,0xe0,0xb8,0x98,0x00,0x00,0x00,0x0c,0x0e,0x03,0x0f,0x0f,0x03,0x0e,0x0c,0x00,0x00 },
256 { 0x00,0x80,0x80,0x80,0xf0,0xf0,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x0f,0x0f,0x01,0x01,0x01,0x00,0x00 },
257 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xf8,0x78,0x00,0x00,0x00,0x00,0x00 },
258 { 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00 },
259 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00 },
260 { 0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x18,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00 },
261 { 0xf8,0xfe,0x06,0x03,0x83,0xc3,0x63,0x33,0x1e,0xfe,0xf8,0x07,0x1f,0x1e,0x33,0x31,0x30,0x30,0x30,0x18,0x1f,0x07 },
262 { 0x00,0x00,0x0c,0x0c,0x0e,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x3f,0x3f,0x30,0x30,0x30,0x00 },
263 { 0x1c,0x1e,0x07,0x03,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x30,0x38,0x3c,0x3e,0x37,0x33,0x31,0x30,0x30,0x30,0x30 },
264 { 0x0c,0x0e,0x07,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e,0x3c,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0e },
265 { 0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x07,0xff,0xff,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x3f,0x3f,0x03,0x03 },
266 { 0x3f,0x7f,0x63,0x63,0x63,0x63,0x63,0x63,0xe3,0xc3,0x83,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f },
267 { 0xc0,0xf0,0xf8,0xdc,0xce,0xc7,0xc3,0xc3,0xc3,0x80,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
268 { 0x03,0x03,0x03,0x03,0x03,0x03,0xc3,0xf3,0x3f,0x0f,0x03,0x00,0x00,0x00,0x30,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00 },
269 { 0x00,0xbc,0xfe,0xe7,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
270 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xfc,0x00,0x00,0x30,0x30,0x30,0x38,0x1c,0x0e,0x07,0x03,0x00 },
271 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00 },
272 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xfc,0x7c,0x00,0x00,0x00,0x00,0x00 },
273 { 0x00,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00,0x00 },
274 { 0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00 },
275 { 0x00,0x03,0x07,0x0e,0x1c,0x38,0xf0,0xe0,0xc0,0x00,0x00,0x00,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00 },
276 { 0x1c,0x1e,0x07,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x00,0x00 },
277 { 0xf8,0xfe,0x07,0xf3,0xfb,0x1b,0xfb,0xfb,0x07,0xfe,0xf8,0x0f,0x1f,0x18,0x33,0x37,0x36,0x37,0x37,0x36,0x03,0x01 },
278 { 0x00,0x00,0xe0,0xfc,0x1f,0x1f,0xfc,0xe0,0x00,0x00,0x00,0x38,0x3f,0x07,0x06,0x06,0x06,0x06,0x07,0x3f,0x38,0x00 },
279 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
280 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x03,0x07,0x0e,0x0c,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x38,0x1c,0x0c,0x00 },
281 { 0xff,0xff,0x03,0x03,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
282 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
283 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
284 { 0xf0,0xfc,0x0e,0x07,0x03,0xc3,0xc3,0xc3,0xc7,0xc6,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
285 { 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
286 { 0x00,0x00,0x03,0x03,0xff,0xff,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
287 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x0e,0x1e,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
288 { 0xff,0xff,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x3f,0x3f,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00 },
289 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
290 { 0xff,0xff,0x1e,0x78,0xe0,0xe0,0x78,0x1e,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x01,0x01,0x00,0x00,0x3f,0x3f,0x00 },
291 { 0xff,0xff,0x0e,0x38,0xf0,0xc0,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x03,0x07,0x1c,0x3f,0x3f,0x00 },
292 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
293 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00 },
294 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x36,0x3e,0x1c,0x3f,0x33,0x00 },
295 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x03,0x07,0x0f,0x1d,0x38,0x30,0x00 },
296 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc7,0x8e,0x0c,0x00,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
297 { 0x00,0x03,0x03,0x03,0xff,0xff,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
298 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x07,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
299 { 0x07,0x3f,0xf8,0xc0,0x00,0x00,0xc0,0xf8,0x3f,0x07,0x00,0x00,0x00,0x01,0x0f,0x3e,0x3e,0x0f,0x01,0x00,0x00,0x00 },
300 { 0xff,0xff,0x00,0x00,0x80,0x80,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x1c,0x06,0x03,0x03,0x06,0x1c,0x3f,0x3f,0x00 },
301 { 0x03,0x0f,0x1c,0x30,0xe0,0xe0,0x30,0x1c,0x0f,0x03,0x00,0x30,0x3c,0x0e,0x03,0x01,0x01,0x03,0x0e,0x3c,0x30,0x00 },
302 { 0x03,0x0f,0x3c,0xf0,0xc0,0xc0,0xf0,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
303 { 0x03,0x03,0x03,0x03,0xc3,0xe3,0x33,0x1f,0x0f,0x03,0x00,0x30,0x3c,0x3e,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x00 },
304 { 0x00,0x00,0xff,0xff,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
305 { 0x0e,0x1c,0x38,0x70,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x18 },
306 { 0x00,0x00,0x03,0x03,0x03,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00,0x00,0x00 },
307 { 0x60,0x70,0x38,0x1c,0x0e,0x07,0x0e,0x1c,0x38,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
308 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },
309 { 0x00,0x00,0x00,0x00,0x3e,0x7e,0x4e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
310 { 0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x1c,0x3e,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x3f,0x00 },
311 { 0xff,0xff,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
312 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x18,0x08,0x00 },
313 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0xe0,0xc0,0xff,0xff,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
314 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x3b,0x33,0x33,0x33,0x33,0x33,0x13,0x01,0x00 },
315 { 0xc0,0xc0,0xfc,0xfe,0xc7,0xc3,0xc3,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
316 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x03,0xc7,0xce,0xcc,0xcc,0xcc,0xcc,0xe6,0x7f,0x3f,0x00 },
317 { 0xff,0xff,0xc0,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00 },
318 { 0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
319 { 0x00,0x00,0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x60,0xe0,0xc0,0xc0,0xff,0x7f,0x00,0x00,0x00 },
320 { 0x00,0xff,0xff,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x00,0x00,0x3f,0x3f,0x03,0x07,0x0f,0x1c,0x38,0x30,0x00,0x00 },
321 { 0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
322 { 0xe0,0xc0,0xe0,0xe0,0xc0,0xc0,0xe0,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00 },
323 { 0x00,0xe0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
324 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
325 { 0xe0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0xff,0xff,0x0c,0x18,0x18,0x18,0x18,0x1c,0x0f,0x07,0x00 },
326 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x07,0x0f,0x1c,0x18,0x18,0x18,0x18,0x0c,0xff,0xff,0x00 },
327 { 0x00,0xe0,0xe0,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
328 { 0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x11,0x33,0x33,0x33,0x33,0x33,0x3f,0x1e,0x00,0x00,0x00 },
329 { 0x60,0x60,0xfe,0xfe,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
330 { 0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x18,0x3f,0x3f,0x00 },
331 { 0x60,0xe0,0x80,0x00,0x00,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x01,0x07,0x1e,0x38,0x38,0x1e,0x07,0x01,0x00,0x00 },
332 { 0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x07,0x1f,0x38,0x1c,0x0f,0x0f,0x1c,0x38,0x1f,0x07,0x00 },
333 { 0x60,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x30,0x38,0x1d,0x0f,0x07,0x0f,0x1d,0x38,0x30,0x00,0x00 },
334 { 0x00,0x60,0xe0,0x80,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00,0x00,0x81,0xe7,0x7e,0x1e,0x07,0x01,0x00,0x00,0x00 },
335 { 0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,0x20,0x00,0x00,0x30,0x38,0x3c,0x36,0x33,0x31,0x30,0x30,0x30,0x00,0x00 },
336 { 0x00,0x80,0xc0,0xfc,0x7e,0x07,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x01,0x1f,0x3f,0x70,0x60,0x60,0x60,0x00,0x00 },
337 { 0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
338 { 0x00,0x03,0x03,0x03,0x07,0x7e,0xfc,0xc0,0x80,0x00,0x00,0x00,0x60,0x60,0x60,0x70,0x3f,0x1f,0x01,0x00,0x00,0x00 },
339 { 0x10,0x18,0x0c,0x04,0x0c,0x18,0x10,0x18,0x0c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
340 { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00 }
343 static signed char speed[]={
344 1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1,
347 #if LCD_WIDTH > LCD_HEIGHT /* landscape LCD */
349 #define TABLE_SIZE LCD_HEIGHT
350 #define RADIUS_MINUTE (3*LCD_HEIGHT/8)
351 #define RADIUS_HOUR (LCD_HEIGHT/4)
353 #else /* portrait (or square) LCD */
355 #define TABLE_SIZE LCD_WIDTH
356 #define RADIUS_MINUTE (3*LCD_WIDTH/8)
357 #define RADIUS_HOUR (LCD_WIDTH/4)
359 #endif /* LCD orientation */
361 #define RADIUS_X ((LCD_WIDTH-LETTER_WIDTH)/2)
362 #define RADIUS_Y ((LCD_HEIGHT-LETTER_HEIGHT)/2)
364 #define PHASE_STEP (0xffffffff/TABLE_SIZE)
365 #define PHASE_FRAC (0xffffffff%TABLE_SIZE)
366 #define DIV_X (0x7ffffffe/RADIUS_X+1)
367 #define DIV_Y (0x7ffffffe/RADIUS_Y+1)
369 static int xtable[TABLE_SIZE];
370 static int ytable[TABLE_SIZE];
372 static void init_tables(void)
374 int i;
375 int pfrac;
376 unsigned long phase;
377 long sin;
379 phase = pfrac = 0;
381 for (i = 0; i < TABLE_SIZE; i++) {
382 sin = fp_sincos(phase, NULL);
383 xtable[i] = RADIUS_X + sin / DIV_X;
384 ytable[i] = RADIUS_Y + sin / DIV_Y;
386 phase += PHASE_STEP;
387 pfrac += PHASE_FRAC;
388 if (pfrac >= TABLE_SIZE) {
389 pfrac -= TABLE_SIZE;
390 phase++;
395 enum {
396 NUM_XSANKE,
397 NUM_YSANKE,
398 NUM_XADD,
399 NUM_YADD,
400 NUM_XDIST,
401 NUM_YDIST,
403 NUM_LAST
406 struct counter {
407 char *what;
408 int num;
411 struct counter values[]={
412 {"xsanke", 1},
413 {"ysanke", 1},
414 {"xadd", 1},
415 {"yadd", 2},
416 {"xdist", -4},
417 {"ydist", -6},
420 #if CONFIG_RTC
422 #define CLOCK_STEP (0xffffffff/60)
423 #define CLOCK_FRAC (0xffffffff%60)
425 #define DIV_MY (0x7ffffffe/RADIUS_MINUTE+1)
426 #define DIV_HY (0x7ffffffe/RADIUS_HOUR+1)
428 #if LCD_WIDTH == 112 && LCD_HEIGHT == 64 /* Archos LCD: non-square pixels */
429 #define DIV_MX (0x7ffffffe/(5*RADIUS_MINUTE/4)+1)
430 #define DIV_HX (0x7ffffffe/(5*RADIUS_HOUR/4)+1)
431 #else /* Square pixels */
432 #define DIV_MX DIV_MY
433 #define DIV_HX DIV_HY
434 #endif
436 static int xminute[60], yminute[60];
437 static int xhour[60], yhour[60];
439 static void init_clock(void)
441 int i;
442 int pfrac;
443 unsigned long phase;
444 long sin, cos;
446 phase = pfrac = 0;
448 for (i = 0; i < 60; i++) {
449 sin = fp_sincos(phase, &cos);
450 xminute[i] = LCD_WIDTH/2 + sin / DIV_MX;
451 yminute[i] = LCD_HEIGHT/2 - cos / DIV_MY;
452 xhour[i] = LCD_WIDTH/2 + sin / DIV_HX;
453 yhour[i] = LCD_HEIGHT/2 - cos / DIV_HY;
455 phase += CLOCK_STEP;
456 pfrac += CLOCK_FRAC;
457 if (pfrac >= 60) {
458 pfrac -= 60;
459 phase++;
464 static void addclock(void)
466 int i;
467 int hour;
468 int minute;
470 struct tm* current_time = rb->get_time();
471 hour = current_time->tm_hour;
472 minute = current_time->tm_min;
474 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2,
475 xminute[minute], yminute[minute]);
477 hour = (hour % 12) * 5 + minute / 12;
479 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour[hour], yhour[hour]);
481 /* draw a circle */
482 for(i = 1; i < 60; i += 3)
483 rb->lcd_drawline(xminute[i], yminute[i],
484 xminute[(i+1)%60], yminute[(i+1)%60]);
486 #endif /* CONFIG_RTC */
488 #if LCD_DEPTH > 1
489 static const unsigned face_colors[] =
491 #ifdef HAVE_LCD_COLOR
492 LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
493 #else
494 LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
495 #endif
497 #endif
499 static int scrollit(void)
501 int b;
502 unsigned int y=100;
503 unsigned int yy;
504 int x = LCD_WIDTH;
505 int xx;
506 unsigned int i;
507 unsigned int textpos=0;
509 char* rock="Rockbox! Pure pleasure. Pure fun. Oooh. What fun! ;-) ";
510 unsigned int rocklen = rb->strlen(rock);
511 int letter;
512 #if LCD_DEPTH > 1
513 unsigned prev_color;
514 #endif
516 rb->lcd_clear_display();
517 while(1)
519 b = rb->button_get_w_tmo(HZ/10);
520 switch(b)
522 #ifdef BOUNCE_RC_QUIT
523 case BOUNCE_RC_QUIT :
524 #endif
525 case BOUNCE_QUIT :
526 return 0;
527 case BOUNCE_MODE :
528 return 1;
529 default:
530 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
531 return -1;
533 rb->lcd_clear_display();
534 #if CONFIG_RTC
535 addclock();
536 #endif
538 #if LCD_DEPTH > 1
539 prev_color = rb->lcd_get_foreground();
540 #endif
542 for(i=0, yy=y, xx=x; xx < LCD_WIDTH; i++) {
543 letter = rock[(i+textpos) % rocklen ];
544 #if LCD_DEPTH > 1
545 rb->lcd_set_foreground(face_colors[letter % 3]);
546 #endif
547 rb->lcd_mono_bitmap(char_gen_12x16[letter-0x20],
548 xx, ytable[yy % TABLE_SIZE],
549 LETTER_WIDTH, LETTER_HEIGHT);
550 yy += YADD;
551 xx += LETTER_WIDTH;
553 #if LCD_DEPTH > 1
554 rb->lcd_set_foreground(prev_color);
555 #endif
556 rb->lcd_update();
558 x-= XSPEED;
560 if(x < -LETTER_WIDTH) {
561 x += LETTER_WIDTH;
562 y += YADD;
563 textpos++;
566 y+=YSPEED;
570 static int loopit(void)
572 int b;
573 unsigned int y=100;
574 unsigned int x=100;
575 unsigned int yy,xx;
576 unsigned int i;
577 unsigned int ysanke=0;
578 unsigned int xsanke=0;
580 char* rock="ROCKbox";
581 unsigned int rocklen = rb->strlen(rock);
583 int show=0;
584 int timeout=0;
585 char buffer[30];
587 rb->lcd_clear_display();
588 while(1)
590 b = rb->button_get_w_tmo(HZ/10);
591 if ( b == BOUNCE_QUIT )
592 return 0;
594 if ( b == BOUNCE_MODE )
595 return 1;
597 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
598 return -1;
600 if ( b != BUTTON_NONE )
601 timeout=20;
603 y+= speed[ysanke&15] + values[NUM_YADD].num;
604 x+= speed[xsanke&15] + values[NUM_XADD].num;
606 rb->lcd_clear_display();
607 #if CONFIG_RTC
608 addclock();
609 #endif
610 if(timeout) {
611 switch(b) {
612 case BOUNCE_LEFT:
613 case BOUNCE_LEFT|BUTTON_REPEAT:
614 values[show].num--;
615 break;
616 case BOUNCE_RIGHT:
617 case BOUNCE_RIGHT|BUTTON_REPEAT:
618 values[show].num++;
619 break;
620 case BOUNCE_UP:
621 case BOUNCE_UP|BUTTON_REPEAT:
622 if(++show == NUM_LAST)
623 show=0;
624 break;
625 case BOUNCE_DOWN:
626 case BOUNCE_DOWN|BUTTON_REPEAT:
627 if(--show < 0)
628 show=NUM_LAST-1;
629 break;
631 rb->snprintf(buffer, 30, "%s: %d",
632 values[show].what, values[show].num);
633 rb->lcd_putsxy(0, LCD_HEIGHT - 8, (unsigned char *)buffer);
634 timeout--;
636 for(i=0, yy=y, xx=x;
637 i<rocklen;
638 i++, yy+=values[NUM_YDIST].num, xx+=values[NUM_XDIST].num)
639 rb->lcd_mono_bitmap(char_gen_12x16[rock[i]-0x20],
640 xtable[xx % TABLE_SIZE],
641 ytable[yy % TABLE_SIZE],
642 LETTER_WIDTH, LETTER_HEIGHT);
643 rb->lcd_update();
645 ysanke+= values[NUM_YSANKE].num;
646 xsanke+= values[NUM_XSANKE].num;
651 enum plugin_status plugin_start(const void* parameter)
653 int w, h;
654 char *off = "[Off] to stop";
656 (void)(parameter);
658 rb->lcd_setfont(FONT_SYSFIXED);
659 rb->lcd_clear_display();
661 /* Get horizontel centering for text */
662 rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h);
663 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2,
664 (unsigned char *)SS_TITLE);
666 /* Get horizontel centering for text */
667 rb->lcd_getstringsize((unsigned char *)off, &w, &h);
668 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h,
669 (unsigned char *)off);
671 rb->lcd_update();
672 rb->sleep(HZ);
673 rb->lcd_set_drawmode(DRMODE_FG);
674 init_tables();
675 #if CONFIG_RTC
676 init_clock();
677 #endif
679 do {
680 h = loopit();
681 if (h > 0)
682 h = scrollit();
683 } while(h > 0);
685 rb->lcd_set_drawmode(DRMODE_SOLID);
686 rb->lcd_setfont(FONT_UI);
688 return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;