Commit FS#9617 - Keymaps for Plugins fuze by Thomas Martitz.
[kugel-rb.git] / apps / plugins / bounce.c
blob755f7f7338e740ff595e9b263d58cf4f27eb7dfb
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 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
97 #define BOUNCE_LEFT BUTTON_LEFT
98 #define BOUNCE_RIGHT BUTTON_RIGHT
99 #define BOUNCE_UP BUTTON_SCROLL_BACK
100 #define BOUNCE_DOWN BUTTON_SCROLL_FWD
101 #define BOUNCE_QUIT BUTTON_POWER
102 #define BOUNCE_MODE BUTTON_SELECT
104 #elif CONFIG_KEYPAD == SANSA_C200_PAD || \
105 CONFIG_KEYPAD == SANSA_CLIP_PAD || \
106 CONFIG_KEYPAD == SANSA_M200_PAD
107 #define BOUNCE_LEFT BUTTON_LEFT
108 #define BOUNCE_RIGHT BUTTON_RIGHT
109 #define BOUNCE_UP BUTTON_UP
110 #define BOUNCE_DOWN BUTTON_DOWN
111 #define BOUNCE_QUIT BUTTON_POWER
112 #define BOUNCE_MODE BUTTON_SELECT
114 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
115 #define BOUNCE_LEFT BUTTON_LEFT
116 #define BOUNCE_RIGHT BUTTON_RIGHT
117 #define BOUNCE_UP BUTTON_SCROLL_UP
118 #define BOUNCE_DOWN BUTTON_SCROLL_DOWN
119 #define BOUNCE_QUIT BUTTON_POWER
120 #define BOUNCE_MODE BUTTON_PLAY
122 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
123 #define BOUNCE_LEFT BUTTON_LEFT
124 #define BOUNCE_RIGHT BUTTON_RIGHT
125 #define BOUNCE_UP BUTTON_UP
126 #define BOUNCE_DOWN BUTTON_DOWN
127 #define BOUNCE_QUIT BUTTON_BACK
128 #define BOUNCE_MODE BUTTON_MENU
130 #elif (CONFIG_KEYPAD == MROBE100_PAD)
131 #define BOUNCE_LEFT BUTTON_LEFT
132 #define BOUNCE_RIGHT BUTTON_RIGHT
133 #define BOUNCE_UP BUTTON_UP
134 #define BOUNCE_DOWN BUTTON_DOWN
135 #define BOUNCE_QUIT BUTTON_POWER
136 #define BOUNCE_MODE BUTTON_DISPLAY
138 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
139 #define BOUNCE_LEFT BUTTON_RC_REW
140 #define BOUNCE_RIGHT BUTTON_RC_FF
141 #define BOUNCE_UP BUTTON_RC_VOL_UP
142 #define BOUNCE_DOWN BUTTON_RC_VOL_DOWN
143 #define BOUNCE_QUIT BUTTON_RC_REC
144 #define BOUNCE_MODE BUTTON_RC_MODE
146 #elif (CONFIG_KEYPAD == COWOND2_PAD)
147 #define BOUNCE_QUIT BUTTON_POWER
148 #define BOUNCE_MODE BUTTON_MENU
150 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
151 #define BOUNCE_LEFT BUTTON_LEFT
152 #define BOUNCE_RIGHT BUTTON_RIGHT
153 #define BOUNCE_UP BUTTON_UP
154 #define BOUNCE_DOWN BUTTON_DOWN
155 #define BOUNCE_QUIT BUTTON_BACK
156 #define BOUNCE_MODE BUTTON_MENU
158 #else
159 #error No keymap defined!
160 #endif
162 #ifdef HAVE_TOUCHSCREEN
163 #ifndef BOUNCE_LEFT
164 #define BOUNCE_LEFT BUTTON_MIDLEFT
165 #endif
166 #ifndef BOUNCE_RIGHT
167 #define BOUNCE_RIGHT BUTTON_MIDRIGHT
168 #endif
169 #ifndef BOUNCE_UP
170 #define BOUNCE_UP BUTTON_TOPMIDDLE
171 #endif
172 #ifndef BOUNCE_DOWN
173 #define BOUNCE_DOWN BUTTON_BOTTOMMIDDLE
174 #endif
175 #ifndef BOUNCE_QUIT
176 #define BOUNCE_QUIT BUTTON_TOPLEFT
177 #endif
178 #ifndef BOUNCE_MODE
179 #define BOUNCE_MODE BUTTON_CENTER
180 #endif
181 #endif
183 static const struct plugin_api* rb;
185 #define LETTER_WIDTH 11
186 #define LETTER_HEIGHT 16
188 const unsigned char char_gen_12x16[][22] =
190 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
191 { 0x00,0x00,0x00,0x7c,0xff,0xff,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00 },
192 { 0x00,0x00,0x3c,0x3c,0x00,0x00,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
193 { 0x00,0x10,0x90,0xf0,0x7e,0x1e,0x90,0xf0,0x7e,0x1e,0x10,0x02,0x1e,0x1f,0x03,0x02,0x1e,0x1f,0x03,0x02,0x00,0x00 },
194 { 0x00,0x78,0xfc,0xcc,0xff,0xff,0xcc,0xcc,0x88,0x00,0x00,0x00,0x04,0x0c,0x0c,0x3f,0x3f,0x0c,0x0f,0x07,0x00,0x00 },
195 { 0x00,0x38,0x38,0x38,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x38,0x38,0x38,0x00 },
196 { 0x00,0x00,0xb8,0xfc,0xc6,0xe2,0x3e,0x1c,0x00,0x00,0x00,0x00,0x1f,0x3f,0x31,0x21,0x37,0x1e,0x1c,0x36,0x22,0x00 },
197 { 0x00,0x00,0x00,0x27,0x3f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
198 { 0x00,0x00,0xf0,0xfc,0xfe,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x0f,0x1f,0x38,0x20,0x20,0x00,0x00,0x00 },
199 { 0x00,0x00,0x01,0x01,0x07,0xfe,0xfc,0xf0,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x38,0x1f,0x0f,0x03,0x00,0x00,0x00 },
200 { 0x00,0x98,0xb8,0xe0,0xf8,0xf8,0xe0,0xb8,0x98,0x00,0x00,0x00,0x0c,0x0e,0x03,0x0f,0x0f,0x03,0x0e,0x0c,0x00,0x00 },
201 { 0x00,0x80,0x80,0x80,0xf0,0xf0,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x0f,0x0f,0x01,0x01,0x01,0x00,0x00 },
202 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xf8,0x78,0x00,0x00,0x00,0x00,0x00 },
203 { 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00 },
204 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00 },
205 { 0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x18,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00 },
206 { 0xf8,0xfe,0x06,0x03,0x83,0xc3,0x63,0x33,0x1e,0xfe,0xf8,0x07,0x1f,0x1e,0x33,0x31,0x30,0x30,0x30,0x18,0x1f,0x07 },
207 { 0x00,0x00,0x0c,0x0c,0x0e,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x3f,0x3f,0x30,0x30,0x30,0x00 },
208 { 0x1c,0x1e,0x07,0x03,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x30,0x38,0x3c,0x3e,0x37,0x33,0x31,0x30,0x30,0x30,0x30 },
209 { 0x0c,0x0e,0x07,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e,0x3c,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0e },
210 { 0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x07,0xff,0xff,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x3f,0x3f,0x03,0x03 },
211 { 0x3f,0x7f,0x63,0x63,0x63,0x63,0x63,0x63,0xe3,0xc3,0x83,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f },
212 { 0xc0,0xf0,0xf8,0xdc,0xce,0xc7,0xc3,0xc3,0xc3,0x80,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
213 { 0x03,0x03,0x03,0x03,0x03,0x03,0xc3,0xf3,0x3f,0x0f,0x03,0x00,0x00,0x00,0x30,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00 },
214 { 0x00,0xbc,0xfe,0xe7,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
215 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xfc,0x00,0x00,0x30,0x30,0x30,0x38,0x1c,0x0e,0x07,0x03,0x00 },
216 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00 },
217 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xfc,0x7c,0x00,0x00,0x00,0x00,0x00 },
218 { 0x00,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00,0x00 },
219 { 0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00 },
220 { 0x00,0x03,0x07,0x0e,0x1c,0x38,0xf0,0xe0,0xc0,0x00,0x00,0x00,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00 },
221 { 0x1c,0x1e,0x07,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x00,0x00 },
222 { 0xf8,0xfe,0x07,0xf3,0xfb,0x1b,0xfb,0xfb,0x07,0xfe,0xf8,0x0f,0x1f,0x18,0x33,0x37,0x36,0x37,0x37,0x36,0x03,0x01 },
223 { 0x00,0x00,0xe0,0xfc,0x1f,0x1f,0xfc,0xe0,0x00,0x00,0x00,0x38,0x3f,0x07,0x06,0x06,0x06,0x06,0x07,0x3f,0x38,0x00 },
224 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
225 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x03,0x07,0x0e,0x0c,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x38,0x1c,0x0c,0x00 },
226 { 0xff,0xff,0x03,0x03,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
227 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
228 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
229 { 0xf0,0xfc,0x0e,0x07,0x03,0xc3,0xc3,0xc3,0xc7,0xc6,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
230 { 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
231 { 0x00,0x00,0x03,0x03,0xff,0xff,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
232 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x0e,0x1e,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
233 { 0xff,0xff,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x3f,0x3f,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00 },
234 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
235 { 0xff,0xff,0x1e,0x78,0xe0,0xe0,0x78,0x1e,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x01,0x01,0x00,0x00,0x3f,0x3f,0x00 },
236 { 0xff,0xff,0x0e,0x38,0xf0,0xc0,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x03,0x07,0x1c,0x3f,0x3f,0x00 },
237 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
238 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00 },
239 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x36,0x3e,0x1c,0x3f,0x33,0x00 },
240 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x03,0x07,0x0f,0x1d,0x38,0x30,0x00 },
241 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc7,0x8e,0x0c,0x00,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
242 { 0x00,0x03,0x03,0x03,0xff,0xff,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
243 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x07,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
244 { 0x07,0x3f,0xf8,0xc0,0x00,0x00,0xc0,0xf8,0x3f,0x07,0x00,0x00,0x00,0x01,0x0f,0x3e,0x3e,0x0f,0x01,0x00,0x00,0x00 },
245 { 0xff,0xff,0x00,0x00,0x80,0x80,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x1c,0x06,0x03,0x03,0x06,0x1c,0x3f,0x3f,0x00 },
246 { 0x03,0x0f,0x1c,0x30,0xe0,0xe0,0x30,0x1c,0x0f,0x03,0x00,0x30,0x3c,0x0e,0x03,0x01,0x01,0x03,0x0e,0x3c,0x30,0x00 },
247 { 0x03,0x0f,0x3c,0xf0,0xc0,0xc0,0xf0,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
248 { 0x03,0x03,0x03,0x03,0xc3,0xe3,0x33,0x1f,0x0f,0x03,0x00,0x30,0x3c,0x3e,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x00 },
249 { 0x00,0x00,0xff,0xff,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
250 { 0x0e,0x1c,0x38,0x70,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x18 },
251 { 0x00,0x00,0x03,0x03,0x03,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00,0x00,0x00 },
252 { 0x60,0x70,0x38,0x1c,0x0e,0x07,0x0e,0x1c,0x38,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
253 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },
254 { 0x00,0x00,0x00,0x00,0x3e,0x7e,0x4e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
255 { 0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x1c,0x3e,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x3f,0x00 },
256 { 0xff,0xff,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
257 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x18,0x08,0x00 },
258 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0xe0,0xc0,0xff,0xff,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
259 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x3b,0x33,0x33,0x33,0x33,0x33,0x13,0x01,0x00 },
260 { 0xc0,0xc0,0xfc,0xfe,0xc7,0xc3,0xc3,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
261 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x03,0xc7,0xce,0xcc,0xcc,0xcc,0xcc,0xe6,0x7f,0x3f,0x00 },
262 { 0xff,0xff,0xc0,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00 },
263 { 0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
264 { 0x00,0x00,0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x60,0xe0,0xc0,0xc0,0xff,0x7f,0x00,0x00,0x00 },
265 { 0x00,0xff,0xff,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x00,0x00,0x3f,0x3f,0x03,0x07,0x0f,0x1c,0x38,0x30,0x00,0x00 },
266 { 0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
267 { 0xe0,0xc0,0xe0,0xe0,0xc0,0xc0,0xe0,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00 },
268 { 0x00,0xe0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
269 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
270 { 0xe0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0xff,0xff,0x0c,0x18,0x18,0x18,0x18,0x1c,0x0f,0x07,0x00 },
271 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x07,0x0f,0x1c,0x18,0x18,0x18,0x18,0x0c,0xff,0xff,0x00 },
272 { 0x00,0xe0,0xe0,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
273 { 0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x11,0x33,0x33,0x33,0x33,0x33,0x3f,0x1e,0x00,0x00,0x00 },
274 { 0x60,0x60,0xfe,0xfe,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
275 { 0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x18,0x3f,0x3f,0x00 },
276 { 0x60,0xe0,0x80,0x00,0x00,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x01,0x07,0x1e,0x38,0x38,0x1e,0x07,0x01,0x00,0x00 },
277 { 0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x07,0x1f,0x38,0x1c,0x0f,0x0f,0x1c,0x38,0x1f,0x07,0x00 },
278 { 0x60,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x30,0x38,0x1d,0x0f,0x07,0x0f,0x1d,0x38,0x30,0x00,0x00 },
279 { 0x00,0x60,0xe0,0x80,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00,0x00,0x81,0xe7,0x7e,0x1e,0x07,0x01,0x00,0x00,0x00 },
280 { 0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,0x20,0x00,0x00,0x30,0x38,0x3c,0x36,0x33,0x31,0x30,0x30,0x30,0x00,0x00 },
281 { 0x00,0x80,0xc0,0xfc,0x7e,0x07,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x01,0x1f,0x3f,0x70,0x60,0x60,0x60,0x00,0x00 },
282 { 0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
283 { 0x00,0x03,0x03,0x03,0x07,0x7e,0xfc,0xc0,0x80,0x00,0x00,0x00,0x60,0x60,0x60,0x70,0x3f,0x1f,0x01,0x00,0x00,0x00 },
284 { 0x10,0x18,0x0c,0x04,0x0c,0x18,0x10,0x18,0x0c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
285 { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00 }
288 static signed char speed[]={
289 1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1,
292 #if LCD_WIDTH > LCD_HEIGHT /* landscape LCD */
294 #define TABLE_SIZE LCD_HEIGHT
295 #define RADIUS_MINUTE (3*LCD_HEIGHT/8)
296 #define RADIUS_HOUR (LCD_HEIGHT/4)
298 #else /* portrait (or square) LCD */
300 #define TABLE_SIZE LCD_WIDTH
301 #define RADIUS_MINUTE (3*LCD_WIDTH/8)
302 #define RADIUS_HOUR (LCD_WIDTH/4)
304 #endif /* LCD orientation */
306 #define RADIUS_X ((LCD_WIDTH-LETTER_WIDTH)/2)
307 #define RADIUS_Y ((LCD_HEIGHT-LETTER_HEIGHT)/2)
309 #define PHASE_STEP (0xffffffff/TABLE_SIZE)
310 #define PHASE_FRAC (0xffffffff%TABLE_SIZE)
311 #define DIV_X (0x7ffffffe/RADIUS_X+1)
312 #define DIV_Y (0x7ffffffe/RADIUS_Y+1)
314 static int xtable[TABLE_SIZE];
315 static int ytable[TABLE_SIZE];
317 static void init_tables(void)
319 int i;
320 int pfrac;
321 unsigned long phase;
322 long sin;
324 phase = pfrac = 0;
326 for (i = 0; i < TABLE_SIZE; i++) {
327 sin = fsincos(phase, NULL);
328 xtable[i] = RADIUS_X + sin / DIV_X;
329 ytable[i] = RADIUS_Y + sin / DIV_Y;
331 phase += PHASE_STEP;
332 pfrac += PHASE_FRAC;
333 if (pfrac >= TABLE_SIZE) {
334 pfrac -= TABLE_SIZE;
335 phase++;
340 enum {
341 NUM_XSANKE,
342 NUM_YSANKE,
343 NUM_XADD,
344 NUM_YADD,
345 NUM_XDIST,
346 NUM_YDIST,
348 NUM_LAST
351 struct counter {
352 char *what;
353 int num;
356 struct counter values[]={
357 {"xsanke", 1},
358 {"ysanke", 1},
359 {"xadd", 1},
360 {"yadd", 2},
361 {"xdist", -4},
362 {"ydist", -6},
365 #if CONFIG_RTC
367 #define CLOCK_STEP (0xffffffff/60)
368 #define CLOCK_FRAC (0xffffffff%60)
370 #define DIV_MY (0x7ffffffe/RADIUS_MINUTE+1)
371 #define DIV_HY (0x7ffffffe/RADIUS_HOUR+1)
373 #if LCD_WIDTH == 112 && LCD_HEIGHT == 64 /* Archos LCD: non-square pixels */
374 #define DIV_MX (0x7ffffffe/(5*RADIUS_MINUTE/4)+1)
375 #define DIV_HX (0x7ffffffe/(5*RADIUS_HOUR/4)+1)
376 #else /* Square pixels */
377 #define DIV_MX DIV_MY
378 #define DIV_HX DIV_HY
379 #endif
381 static int xminute[60], yminute[60];
382 static int xhour[60], yhour[60];
384 static void init_clock(void)
386 int i;
387 int pfrac;
388 unsigned long phase;
389 long sin, cos;
391 phase = pfrac = 0;
393 for (i = 0; i < 60; i++) {
394 sin = fsincos(phase, &cos);
395 xminute[i] = LCD_WIDTH/2 + sin / DIV_MX;
396 yminute[i] = LCD_HEIGHT/2 - cos / DIV_MY;
397 xhour[i] = LCD_WIDTH/2 + sin / DIV_HX;
398 yhour[i] = LCD_HEIGHT/2 - cos / DIV_HY;
400 phase += CLOCK_STEP;
401 pfrac += CLOCK_FRAC;
402 if (pfrac >= 60) {
403 pfrac -= 60;
404 phase++;
409 static void addclock(void)
411 int i;
412 int hour;
413 int minute;
415 struct tm* current_time = rb->get_time();
416 hour = current_time->tm_hour;
417 minute = current_time->tm_min;
419 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2,
420 xminute[minute], yminute[minute]);
422 hour = (hour % 12) * 5 + minute / 12;
424 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour[hour], yhour[hour]);
426 /* draw a circle */
427 for(i = 1; i < 60; i += 3)
428 rb->lcd_drawline(xminute[i], yminute[i],
429 xminute[(i+1)%60], yminute[(i+1)%60]);
431 #endif /* CONFIG_RTC */
433 #if LCD_DEPTH > 1
434 static const unsigned face_colors[] =
436 #ifdef HAVE_LCD_COLOR
437 LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
438 #else
439 LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
440 #endif
442 #endif
444 static int scrollit(void)
446 int b;
447 unsigned int y=100;
448 unsigned int yy;
449 int x = LCD_WIDTH;
450 int xx;
451 unsigned int i;
452 unsigned int textpos=0;
454 char* rock="Rockbox! Pure pleasure. Pure fun. Oooh. What fun! ;-) ";
455 unsigned int rocklen = rb->strlen(rock);
456 int letter;
457 #if LCD_DEPTH > 1
458 unsigned prev_color;
459 #endif
461 rb->lcd_clear_display();
462 while(1)
464 b = rb->button_get_w_tmo(HZ/10);
465 switch(b)
467 #ifdef BOUNCE_RC_QUIT
468 case BOUNCE_RC_QUIT :
469 #endif
470 case BOUNCE_QUIT :
471 return 0;
472 case BOUNCE_MODE :
473 return 1;
474 default:
475 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
476 return -1;
478 rb->lcd_clear_display();
479 #if CONFIG_RTC
480 addclock();
481 #endif
483 #if LCD_DEPTH > 1
484 prev_color = rb->lcd_get_foreground();
485 #endif
487 for(i=0, yy=y, xx=x; xx < LCD_WIDTH; i++) {
488 letter = rock[(i+textpos) % rocklen ];
489 #if LCD_DEPTH > 1
490 rb->lcd_set_foreground(face_colors[letter % 3]);
491 #endif
492 rb->lcd_mono_bitmap(char_gen_12x16[letter-0x20],
493 xx, ytable[yy % TABLE_SIZE],
494 LETTER_WIDTH, LETTER_HEIGHT);
495 yy += YADD;
496 xx += LETTER_WIDTH;
498 #if LCD_DEPTH > 1
499 rb->lcd_set_foreground(prev_color);
500 #endif
501 rb->lcd_update();
503 x-= XSPEED;
505 if(x < -LETTER_WIDTH) {
506 x += LETTER_WIDTH;
507 y += YADD;
508 textpos++;
511 y+=YSPEED;
515 static int loopit(void)
517 int b;
518 unsigned int y=100;
519 unsigned int x=100;
520 unsigned int yy,xx;
521 unsigned int i;
522 unsigned int ysanke=0;
523 unsigned int xsanke=0;
525 char* rock="ROCKbox";
526 unsigned int rocklen = rb->strlen(rock);
528 int show=0;
529 int timeout=0;
530 char buffer[30];
532 rb->lcd_clear_display();
533 while(1)
535 b = rb->button_get_w_tmo(HZ/10);
536 if ( b == BOUNCE_QUIT )
537 return 0;
539 if ( b == BOUNCE_MODE )
540 return 1;
542 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
543 return -1;
545 if ( b != BUTTON_NONE )
546 timeout=20;
548 y+= speed[ysanke&15] + values[NUM_YADD].num;
549 x+= speed[xsanke&15] + values[NUM_XADD].num;
551 rb->lcd_clear_display();
552 #if CONFIG_RTC
553 addclock();
554 #endif
555 if(timeout) {
556 switch(b) {
557 case BOUNCE_LEFT:
558 case BOUNCE_LEFT|BUTTON_REPEAT:
559 values[show].num--;
560 break;
561 case BOUNCE_RIGHT:
562 case BOUNCE_RIGHT|BUTTON_REPEAT:
563 values[show].num++;
564 break;
565 case BOUNCE_UP:
566 case BOUNCE_UP|BUTTON_REPEAT:
567 if(++show == NUM_LAST)
568 show=0;
569 break;
570 case BOUNCE_DOWN:
571 case BOUNCE_DOWN|BUTTON_REPEAT:
572 if(--show < 0)
573 show=NUM_LAST-1;
574 break;
576 rb->snprintf(buffer, 30, "%s: %d",
577 values[show].what, values[show].num);
578 rb->lcd_putsxy(0, LCD_HEIGHT - 8, (unsigned char *)buffer);
579 timeout--;
581 for(i=0, yy=y, xx=x;
582 i<rocklen;
583 i++, yy+=values[NUM_YDIST].num, xx+=values[NUM_XDIST].num)
584 rb->lcd_mono_bitmap(char_gen_12x16[rock[i]-0x20],
585 xtable[xx % TABLE_SIZE],
586 ytable[yy % TABLE_SIZE],
587 LETTER_WIDTH, LETTER_HEIGHT);
588 rb->lcd_update();
590 ysanke+= values[NUM_YSANKE].num;
591 xsanke+= values[NUM_XSANKE].num;
596 enum plugin_status plugin_start(const struct plugin_api* api,
597 const void* parameter)
599 int w, h;
600 char *off = "[Off] to stop";
602 (void)(parameter);
603 rb = api;
605 rb->lcd_setfont(FONT_SYSFIXED);
606 rb->lcd_clear_display();
608 /* Get horizontel centering for text */
609 rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h);
610 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2,
611 (unsigned char *)SS_TITLE);
613 /* Get horizontel centering for text */
614 rb->lcd_getstringsize((unsigned char *)off, &w, &h);
615 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h,
616 (unsigned char *)off);
618 rb->lcd_update();
619 rb->sleep(HZ);
620 rb->lcd_set_drawmode(DRMODE_FG);
621 init_tables();
622 #if CONFIG_RTC
623 init_clock();
624 #endif
626 do {
627 h = loopit();
628 if (h > 0)
629 h = scrollit();
630 } while(h > 0);
632 rb->lcd_set_drawmode(DRMODE_SOLID);
633 rb->lcd_setfont(FONT_UI);
635 return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;