FS#8708: D2/m:robe500 touchscreen keymaps by Andreas Mueller.
[kugel-rb.git] / apps / plugins / bounce.c
blobc8a40dec4a543becbe18e5eb4f69b5be60599b71
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Daniel Stenberg
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 "time.h"
21 #include "fixedpoint.h"
23 PLUGIN_HEADER
25 #define SS_TITLE "Bouncer"
27 #define YSPEED 2
28 #define XSPEED 3
29 #define YADD -4
31 /* variable button definitions */
32 #if CONFIG_KEYPAD == RECORDER_PAD
33 #define BOUNCE_LEFT BUTTON_LEFT
34 #define BOUNCE_RIGHT BUTTON_RIGHT
35 #define BOUNCE_UP BUTTON_UP
36 #define BOUNCE_DOWN BUTTON_DOWN
37 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
38 #define BOUNCE_MODE (BUTTON_ON | BUTTON_REL)
40 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
41 #define BOUNCE_LEFT BUTTON_LEFT
42 #define BOUNCE_RIGHT BUTTON_RIGHT
43 #define BOUNCE_UP BUTTON_UP
44 #define BOUNCE_DOWN BUTTON_DOWN
45 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
46 #define BOUNCE_MODE (BUTTON_ON | BUTTON_REL)
48 #elif CONFIG_KEYPAD == ONDIO_PAD
49 #define BOUNCE_LEFT BUTTON_LEFT
50 #define BOUNCE_RIGHT BUTTON_RIGHT
51 #define BOUNCE_UP BUTTON_UP
52 #define BOUNCE_DOWN BUTTON_DOWN
53 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
54 #define BOUNCE_MODE (BUTTON_MENU | BUTTON_REL)
56 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
57 (CONFIG_KEYPAD == IRIVER_H300_PAD)
58 #define BOUNCE_LEFT BUTTON_LEFT
59 #define BOUNCE_RIGHT BUTTON_RIGHT
60 #define BOUNCE_UP BUTTON_UP
61 #define BOUNCE_DOWN BUTTON_DOWN
62 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
63 #define BOUNCE_MODE (BUTTON_SELECT | BUTTON_REL)
65 #define BOUNCE_RC_QUIT (BUTTON_RC_STOP | BUTTON_REL)
67 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
68 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
69 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
70 #define BOUNCE_LEFT BUTTON_LEFT
71 #define BOUNCE_RIGHT BUTTON_RIGHT
72 #define BOUNCE_UP BUTTON_SCROLL_BACK
73 #define BOUNCE_DOWN BUTTON_SCROLL_FWD
74 #define BOUNCE_QUIT (BUTTON_MENU | BUTTON_REL)
75 #define BOUNCE_MODE (BUTTON_SELECT | BUTTON_REL)
77 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
78 #define BOUNCE_LEFT BUTTON_LEFT
79 #define BOUNCE_RIGHT BUTTON_RIGHT
80 #define BOUNCE_UP BUTTON_UP
81 #define BOUNCE_DOWN BUTTON_DOWN
82 #define BOUNCE_QUIT BUTTON_POWER
83 #define BOUNCE_MODE BUTTON_PLAY
85 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
86 #define BOUNCE_LEFT BUTTON_LEFT
87 #define BOUNCE_RIGHT BUTTON_RIGHT
88 #define BOUNCE_UP BUTTON_UP
89 #define BOUNCE_DOWN BUTTON_DOWN
90 #define BOUNCE_QUIT BUTTON_POWER
91 #define BOUNCE_MODE BUTTON_A
93 #elif CONFIG_KEYPAD == SANSA_E200_PAD
94 #define BOUNCE_LEFT BUTTON_LEFT
95 #define BOUNCE_RIGHT BUTTON_RIGHT
96 #define BOUNCE_UP BUTTON_SCROLL_BACK
97 #define BOUNCE_DOWN BUTTON_SCROLL_FWD
98 #define BOUNCE_QUIT BUTTON_POWER
99 #define BOUNCE_MODE BUTTON_SELECT
101 #elif CONFIG_KEYPAD == SANSA_C200_PAD
102 #define BOUNCE_LEFT BUTTON_LEFT
103 #define BOUNCE_RIGHT BUTTON_RIGHT
104 #define BOUNCE_UP BUTTON_UP
105 #define BOUNCE_DOWN BUTTON_DOWN
106 #define BOUNCE_QUIT BUTTON_POWER
107 #define BOUNCE_MODE BUTTON_SELECT
109 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
110 #define BOUNCE_LEFT BUTTON_LEFT
111 #define BOUNCE_RIGHT BUTTON_RIGHT
112 #define BOUNCE_UP BUTTON_SCROLL_UP
113 #define BOUNCE_DOWN BUTTON_SCROLL_DOWN
114 #define BOUNCE_QUIT BUTTON_POWER
115 #define BOUNCE_MODE BUTTON_PLAY
117 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
118 #define BOUNCE_LEFT BUTTON_LEFT
119 #define BOUNCE_RIGHT BUTTON_RIGHT
120 #define BOUNCE_UP BUTTON_UP
121 #define BOUNCE_DOWN BUTTON_DOWN
122 #define BOUNCE_QUIT BUTTON_BACK
123 #define BOUNCE_MODE BUTTON_MENU
125 #elif (CONFIG_KEYPAD == MROBE100_PAD)
126 #define BOUNCE_LEFT BUTTON_LEFT
127 #define BOUNCE_RIGHT BUTTON_RIGHT
128 #define BOUNCE_UP BUTTON_UP
129 #define BOUNCE_DOWN BUTTON_DOWN
130 #define BOUNCE_QUIT BUTTON_POWER
131 #define BOUNCE_MODE BUTTON_DISPLAY
133 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
134 #define BOUNCE_LEFT BUTTON_RC_REW
135 #define BOUNCE_RIGHT BUTTON_RC_FF
136 #define BOUNCE_UP BUTTON_RC_VOL_UP
137 #define BOUNCE_DOWN BUTTON_RC_VOL_DOWN
138 #define BOUNCE_QUIT BUTTON_RC_REC
139 #define BOUNCE_MODE BUTTON_RC_MODE
141 #elif (CONFIG_KEYPAD == COWOND2_PAD)
142 #define BOUNCE_QUIT BUTTON_POWER
143 #define BOUNCE_MODE BUTTON_MENU
145 #else
146 #error No keymap defined!
147 #endif
149 #ifdef HAVE_TOUCHPAD
150 #ifndef BOUNCE_LEFT
151 #define BOUNCE_LEFT BUTTON_MIDLEFT
152 #endif
153 #ifndef BOUNCE_RIGHT
154 #define BOUNCE_RIGHT BUTTON_MIDRIGHT
155 #endif
156 #ifndef BOUNCE_UP
157 #define BOUNCE_UP BUTTON_TOPMIDDLE
158 #endif
159 #ifndef BOUNCE_DOWN
160 #define BOUNCE_DOWN BUTTON_BOTTOMMIDDLE
161 #endif
162 #ifndef BOUNCE_QUIT
163 #define BOUNCE_QUIT BUTTON_TOPLEFT
164 #endif
165 #ifndef BOUNCE_MODE
166 #define BOUNCE_MODE BUTTON_CENTER
167 #endif
168 #endif
170 static struct plugin_api* rb;
172 #define LETTER_WIDTH 11
173 #define LETTER_HEIGHT 16
175 const unsigned char char_gen_12x16[][22] =
177 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
178 { 0x00,0x00,0x00,0x7c,0xff,0xff,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00 },
179 { 0x00,0x00,0x3c,0x3c,0x00,0x00,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
180 { 0x00,0x10,0x90,0xf0,0x7e,0x1e,0x90,0xf0,0x7e,0x1e,0x10,0x02,0x1e,0x1f,0x03,0x02,0x1e,0x1f,0x03,0x02,0x00,0x00 },
181 { 0x00,0x78,0xfc,0xcc,0xff,0xff,0xcc,0xcc,0x88,0x00,0x00,0x00,0x04,0x0c,0x0c,0x3f,0x3f,0x0c,0x0f,0x07,0x00,0x00 },
182 { 0x00,0x38,0x38,0x38,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x38,0x38,0x38,0x00 },
183 { 0x00,0x00,0xb8,0xfc,0xc6,0xe2,0x3e,0x1c,0x00,0x00,0x00,0x00,0x1f,0x3f,0x31,0x21,0x37,0x1e,0x1c,0x36,0x22,0x00 },
184 { 0x00,0x00,0x00,0x27,0x3f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
185 { 0x00,0x00,0xf0,0xfc,0xfe,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x0f,0x1f,0x38,0x20,0x20,0x00,0x00,0x00 },
186 { 0x00,0x00,0x01,0x01,0x07,0xfe,0xfc,0xf0,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x38,0x1f,0x0f,0x03,0x00,0x00,0x00 },
187 { 0x00,0x98,0xb8,0xe0,0xf8,0xf8,0xe0,0xb8,0x98,0x00,0x00,0x00,0x0c,0x0e,0x03,0x0f,0x0f,0x03,0x0e,0x0c,0x00,0x00 },
188 { 0x00,0x80,0x80,0x80,0xf0,0xf0,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x0f,0x0f,0x01,0x01,0x01,0x00,0x00 },
189 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xf8,0x78,0x00,0x00,0x00,0x00,0x00 },
190 { 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00 },
191 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00 },
192 { 0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x18,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00 },
193 { 0xf8,0xfe,0x06,0x03,0x83,0xc3,0x63,0x33,0x1e,0xfe,0xf8,0x07,0x1f,0x1e,0x33,0x31,0x30,0x30,0x30,0x18,0x1f,0x07 },
194 { 0x00,0x00,0x0c,0x0c,0x0e,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x3f,0x3f,0x30,0x30,0x30,0x00 },
195 { 0x1c,0x1e,0x07,0x03,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x30,0x38,0x3c,0x3e,0x37,0x33,0x31,0x30,0x30,0x30,0x30 },
196 { 0x0c,0x0e,0x07,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e,0x3c,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0e },
197 { 0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x07,0xff,0xff,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x3f,0x3f,0x03,0x03 },
198 { 0x3f,0x7f,0x63,0x63,0x63,0x63,0x63,0x63,0xe3,0xc3,0x83,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f },
199 { 0xc0,0xf0,0xf8,0xdc,0xce,0xc7,0xc3,0xc3,0xc3,0x80,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
200 { 0x03,0x03,0x03,0x03,0x03,0x03,0xc3,0xf3,0x3f,0x0f,0x03,0x00,0x00,0x00,0x30,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00 },
201 { 0x00,0xbc,0xfe,0xe7,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
202 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xfc,0x00,0x00,0x30,0x30,0x30,0x38,0x1c,0x0e,0x07,0x03,0x00 },
203 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00 },
204 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xfc,0x7c,0x00,0x00,0x00,0x00,0x00 },
205 { 0x00,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00,0x00 },
206 { 0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00 },
207 { 0x00,0x03,0x07,0x0e,0x1c,0x38,0xf0,0xe0,0xc0,0x00,0x00,0x00,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00 },
208 { 0x1c,0x1e,0x07,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x00,0x00 },
209 { 0xf8,0xfe,0x07,0xf3,0xfb,0x1b,0xfb,0xfb,0x07,0xfe,0xf8,0x0f,0x1f,0x18,0x33,0x37,0x36,0x37,0x37,0x36,0x03,0x01 },
210 { 0x00,0x00,0xe0,0xfc,0x1f,0x1f,0xfc,0xe0,0x00,0x00,0x00,0x38,0x3f,0x07,0x06,0x06,0x06,0x06,0x07,0x3f,0x38,0x00 },
211 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
212 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x03,0x07,0x0e,0x0c,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x38,0x1c,0x0c,0x00 },
213 { 0xff,0xff,0x03,0x03,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
214 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
215 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
216 { 0xf0,0xfc,0x0e,0x07,0x03,0xc3,0xc3,0xc3,0xc7,0xc6,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
217 { 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
218 { 0x00,0x00,0x03,0x03,0xff,0xff,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
219 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x0e,0x1e,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
220 { 0xff,0xff,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x3f,0x3f,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00 },
221 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
222 { 0xff,0xff,0x1e,0x78,0xe0,0xe0,0x78,0x1e,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x01,0x01,0x00,0x00,0x3f,0x3f,0x00 },
223 { 0xff,0xff,0x0e,0x38,0xf0,0xc0,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x03,0x07,0x1c,0x3f,0x3f,0x00 },
224 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
225 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00 },
226 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x36,0x3e,0x1c,0x3f,0x33,0x00 },
227 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x03,0x07,0x0f,0x1d,0x38,0x30,0x00 },
228 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc7,0x8e,0x0c,0x00,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
229 { 0x00,0x03,0x03,0x03,0xff,0xff,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
230 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x07,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
231 { 0x07,0x3f,0xf8,0xc0,0x00,0x00,0xc0,0xf8,0x3f,0x07,0x00,0x00,0x00,0x01,0x0f,0x3e,0x3e,0x0f,0x01,0x00,0x00,0x00 },
232 { 0xff,0xff,0x00,0x00,0x80,0x80,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x1c,0x06,0x03,0x03,0x06,0x1c,0x3f,0x3f,0x00 },
233 { 0x03,0x0f,0x1c,0x30,0xe0,0xe0,0x30,0x1c,0x0f,0x03,0x00,0x30,0x3c,0x0e,0x03,0x01,0x01,0x03,0x0e,0x3c,0x30,0x00 },
234 { 0x03,0x0f,0x3c,0xf0,0xc0,0xc0,0xf0,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
235 { 0x03,0x03,0x03,0x03,0xc3,0xe3,0x33,0x1f,0x0f,0x03,0x00,0x30,0x3c,0x3e,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x00 },
236 { 0x00,0x00,0xff,0xff,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
237 { 0x0e,0x1c,0x38,0x70,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x18 },
238 { 0x00,0x00,0x03,0x03,0x03,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00,0x00,0x00 },
239 { 0x60,0x70,0x38,0x1c,0x0e,0x07,0x0e,0x1c,0x38,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
240 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },
241 { 0x00,0x00,0x00,0x00,0x3e,0x7e,0x4e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
242 { 0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x1c,0x3e,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x3f,0x00 },
243 { 0xff,0xff,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
244 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x18,0x08,0x00 },
245 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0xe0,0xc0,0xff,0xff,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
246 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x3b,0x33,0x33,0x33,0x33,0x33,0x13,0x01,0x00 },
247 { 0xc0,0xc0,0xfc,0xfe,0xc7,0xc3,0xc3,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
248 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x03,0xc7,0xce,0xcc,0xcc,0xcc,0xcc,0xe6,0x7f,0x3f,0x00 },
249 { 0xff,0xff,0xc0,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00 },
250 { 0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
251 { 0x00,0x00,0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x60,0xe0,0xc0,0xc0,0xff,0x7f,0x00,0x00,0x00 },
252 { 0x00,0xff,0xff,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x00,0x00,0x3f,0x3f,0x03,0x07,0x0f,0x1c,0x38,0x30,0x00,0x00 },
253 { 0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
254 { 0xe0,0xc0,0xe0,0xe0,0xc0,0xc0,0xe0,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00 },
255 { 0x00,0xe0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
256 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
257 { 0xe0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0xff,0xff,0x0c,0x18,0x18,0x18,0x18,0x1c,0x0f,0x07,0x00 },
258 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x07,0x0f,0x1c,0x18,0x18,0x18,0x18,0x0c,0xff,0xff,0x00 },
259 { 0x00,0xe0,0xe0,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
260 { 0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x11,0x33,0x33,0x33,0x33,0x33,0x3f,0x1e,0x00,0x00,0x00 },
261 { 0x60,0x60,0xfe,0xfe,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
262 { 0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x18,0x3f,0x3f,0x00 },
263 { 0x60,0xe0,0x80,0x00,0x00,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x01,0x07,0x1e,0x38,0x38,0x1e,0x07,0x01,0x00,0x00 },
264 { 0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x07,0x1f,0x38,0x1c,0x0f,0x0f,0x1c,0x38,0x1f,0x07,0x00 },
265 { 0x60,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x30,0x38,0x1d,0x0f,0x07,0x0f,0x1d,0x38,0x30,0x00,0x00 },
266 { 0x00,0x60,0xe0,0x80,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00,0x00,0x81,0xe7,0x7e,0x1e,0x07,0x01,0x00,0x00,0x00 },
267 { 0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,0x20,0x00,0x00,0x30,0x38,0x3c,0x36,0x33,0x31,0x30,0x30,0x30,0x00,0x00 },
268 { 0x00,0x80,0xc0,0xfc,0x7e,0x07,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x01,0x1f,0x3f,0x70,0x60,0x60,0x60,0x00,0x00 },
269 { 0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
270 { 0x00,0x03,0x03,0x03,0x07,0x7e,0xfc,0xc0,0x80,0x00,0x00,0x00,0x60,0x60,0x60,0x70,0x3f,0x1f,0x01,0x00,0x00,0x00 },
271 { 0x10,0x18,0x0c,0x04,0x0c,0x18,0x10,0x18,0x0c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
272 { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00 }
275 static signed char speed[]={
276 1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1,
279 #if LCD_WIDTH > LCD_HEIGHT /* landscape LCD */
281 #define TABLE_SIZE LCD_HEIGHT
282 #define RADIUS_MINUTE (3*LCD_HEIGHT/8)
283 #define RADIUS_HOUR (LCD_HEIGHT/4)
285 #else /* portrait (or square) LCD */
287 #define TABLE_SIZE LCD_WIDTH
288 #define RADIUS_MINUTE (3*LCD_WIDTH/8)
289 #define RADIUS_HOUR (LCD_WIDTH/4)
291 #endif /* LCD orientation */
293 #define RADIUS_X ((LCD_WIDTH-LETTER_WIDTH)/2)
294 #define RADIUS_Y ((LCD_HEIGHT-LETTER_HEIGHT)/2)
296 #define PHASE_STEP (0xffffffff/TABLE_SIZE)
297 #define PHASE_FRAC (0xffffffff%TABLE_SIZE)
298 #define DIV_X (0x7ffffffe/RADIUS_X+1)
299 #define DIV_Y (0x7ffffffe/RADIUS_Y+1)
301 static int xtable[TABLE_SIZE];
302 static int ytable[TABLE_SIZE];
304 static void init_tables(void)
306 int i;
307 int pfrac;
308 unsigned long phase;
309 long sin;
311 phase = pfrac = 0;
313 for (i = 0; i < TABLE_SIZE; i++) {
314 sin = fsincos(phase, NULL);
315 xtable[i] = RADIUS_X + sin / DIV_X;
316 ytable[i] = RADIUS_Y + sin / DIV_Y;
318 phase += PHASE_STEP;
319 pfrac += PHASE_FRAC;
320 if (pfrac >= TABLE_SIZE) {
321 pfrac -= TABLE_SIZE;
322 phase++;
327 enum {
328 NUM_XSANKE,
329 NUM_YSANKE,
330 NUM_XADD,
331 NUM_YADD,
332 NUM_XDIST,
333 NUM_YDIST,
335 NUM_LAST
338 struct counter {
339 char *what;
340 int num;
343 struct counter values[]={
344 {"xsanke", 1},
345 {"ysanke", 1},
346 {"xadd", 1},
347 {"yadd", 2},
348 {"xdist", -4},
349 {"ydist", -6},
352 #if CONFIG_RTC
354 #define CLOCK_STEP (0xffffffff/60)
355 #define CLOCK_FRAC (0xffffffff%60)
357 #define DIV_MY (0x7ffffffe/RADIUS_MINUTE+1)
358 #define DIV_HY (0x7ffffffe/RADIUS_HOUR+1)
360 #if LCD_WIDTH == 112 && LCD_HEIGHT == 64 /* Archos LCD: non-square pixels */
361 #define DIV_MX (0x7ffffffe/(5*RADIUS_MINUTE/4)+1)
362 #define DIV_HX (0x7ffffffe/(5*RADIUS_HOUR/4)+1)
363 #else /* Square pixels */
364 #define DIV_MX DIV_MY
365 #define DIV_HX DIV_HY
366 #endif
368 static int xminute[60], yminute[60];
369 static int xhour[60], yhour[60];
371 static void init_clock(void)
373 int i;
374 int pfrac;
375 unsigned long phase;
376 long sin, cos;
378 phase = pfrac = 0;
380 for (i = 0; i < 60; i++) {
381 sin = fsincos(phase, &cos);
382 xminute[i] = LCD_WIDTH/2 + sin / DIV_MX;
383 yminute[i] = LCD_HEIGHT/2 - cos / DIV_MY;
384 xhour[i] = LCD_WIDTH/2 + sin / DIV_HX;
385 yhour[i] = LCD_HEIGHT/2 - cos / DIV_HY;
387 phase += CLOCK_STEP;
388 pfrac += CLOCK_FRAC;
389 if (pfrac >= 60) {
390 pfrac -= 60;
391 phase++;
396 static void addclock(void)
398 int i;
399 int hour;
400 int minute;
402 struct tm* current_time = rb->get_time();
403 hour = current_time->tm_hour;
404 minute = current_time->tm_min;
406 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2,
407 xminute[minute], yminute[minute]);
409 hour = (hour % 12) * 5 + minute / 12;
411 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour[hour], yhour[hour]);
413 /* draw a circle */
414 for(i = 1; i < 60; i += 3)
415 rb->lcd_drawline(xminute[i], yminute[i],
416 xminute[(i+1)%60], yminute[(i+1)%60]);
418 #endif /* CONFIG_RTC */
420 #if LCD_DEPTH > 1
421 static const unsigned face_colors[] =
423 #ifdef HAVE_LCD_COLOR
424 LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
425 #else
426 LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
427 #endif
429 #endif
431 static int scrollit(void)
433 int b;
434 unsigned int y=100;
435 unsigned int yy;
436 int x = LCD_WIDTH;
437 int xx;
438 unsigned int i;
439 unsigned int textpos=0;
441 char* rock="Rockbox! Pure pleasure. Pure fun. Oooh. What fun! ;-) ";
442 unsigned int rocklen = rb->strlen(rock);
443 int letter;
445 rb->lcd_clear_display();
446 while(1)
448 b = rb->button_get_w_tmo(HZ/10);
449 switch(b)
451 #ifdef BOUNCE_RC_QUIT
452 case BOUNCE_RC_QUIT :
453 #endif
454 case BOUNCE_QUIT :
455 return 0;
456 case BOUNCE_MODE :
457 return 1;
458 default:
459 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
460 return -1;
462 rb->lcd_clear_display();
463 #if CONFIG_RTC
464 addclock();
465 #endif
467 for(i=0, yy=y, xx=x; xx < LCD_WIDTH; i++) {
468 letter = rock[(i+textpos) % rocklen ];
469 #if LCD_DEPTH > 1
470 rb->lcd_set_foreground(face_colors[letter % 3]);
471 #endif
472 rb->lcd_mono_bitmap(char_gen_12x16[letter-0x20],
473 xx, ytable[yy % TABLE_SIZE],
474 LETTER_WIDTH, LETTER_HEIGHT);
475 yy += YADD;
476 xx += LETTER_WIDTH;
478 #if LCD_DEPTH > 1
479 rb->lcd_set_foreground(LCD_BLACK);
480 #endif
481 rb->lcd_update();
483 x-= XSPEED;
485 if(x < -LETTER_WIDTH) {
486 x += LETTER_WIDTH;
487 y += YADD;
488 textpos++;
491 y+=YSPEED;
495 static int loopit(void)
497 int b;
498 unsigned int y=100;
499 unsigned int x=100;
500 unsigned int yy,xx;
501 unsigned int i;
502 unsigned int ysanke=0;
503 unsigned int xsanke=0;
505 char* rock="ROCKbox";
506 unsigned int rocklen = rb->strlen(rock);
508 int show=0;
509 int timeout=0;
510 char buffer[30];
512 rb->lcd_clear_display();
513 while(1)
515 b = rb->button_get_w_tmo(HZ/10);
516 if ( b == BOUNCE_QUIT )
517 return 0;
519 if ( b == BOUNCE_MODE )
520 return 1;
522 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
523 return -1;
525 if ( b != BUTTON_NONE )
526 timeout=20;
528 y+= speed[ysanke&15] + values[NUM_YADD].num;
529 x+= speed[xsanke&15] + values[NUM_XADD].num;
531 rb->lcd_clear_display();
532 #if CONFIG_RTC
533 addclock();
534 #endif
535 if(timeout) {
536 switch(b) {
537 case BOUNCE_LEFT:
538 case BOUNCE_LEFT|BUTTON_REPEAT:
539 values[show].num--;
540 break;
541 case BOUNCE_RIGHT:
542 case BOUNCE_RIGHT|BUTTON_REPEAT:
543 values[show].num++;
544 break;
545 case BOUNCE_UP:
546 case BOUNCE_UP|BUTTON_REPEAT:
547 if(++show == NUM_LAST)
548 show=0;
549 break;
550 case BOUNCE_DOWN:
551 case BOUNCE_DOWN|BUTTON_REPEAT:
552 if(--show < 0)
553 show=NUM_LAST-1;
554 break;
556 rb->snprintf(buffer, 30, "%s: %d",
557 values[show].what, values[show].num);
558 rb->lcd_putsxy(0, LCD_HEIGHT - 8, (unsigned char *)buffer);
559 timeout--;
561 for(i=0, yy=y, xx=x;
562 i<rocklen;
563 i++, yy+=values[NUM_YDIST].num, xx+=values[NUM_XDIST].num)
564 rb->lcd_mono_bitmap(char_gen_12x16[rock[i]-0x20],
565 xtable[xx % TABLE_SIZE],
566 ytable[yy % TABLE_SIZE],
567 LETTER_WIDTH, LETTER_HEIGHT);
568 rb->lcd_update();
570 ysanke+= values[NUM_YSANKE].num;
571 xsanke+= values[NUM_XSANKE].num;
576 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
578 int w, h;
579 char *off = "[Off] to stop";
581 (void)(parameter);
582 rb = api;
584 rb->lcd_setfont(FONT_SYSFIXED);
585 rb->lcd_clear_display();
587 /* Get horizontel centering for text */
588 rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h);
589 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2,
590 (unsigned char *)SS_TITLE);
592 /* Get horizontel centering for text */
593 rb->lcd_getstringsize((unsigned char *)off, &w, &h);
594 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h,
595 (unsigned char *)off);
597 rb->lcd_update();
598 rb->sleep(HZ);
599 rb->lcd_set_drawmode(DRMODE_FG);
600 init_tables();
601 #if CONFIG_RTC
602 init_clock();
603 #endif
605 do {
606 h = loopit();
607 if (h > 0)
608 h = scrollit();
609 } while(h > 0);
611 rb->lcd_set_drawmode(DRMODE_SOLID);
612 rb->lcd_setfont(FONT_UI);
614 return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;