Accept FS#8341 - rename BUTTON_SCROLL_UP/DOWN to FWD/BACK on the e200 to make it...
[Rockbox.git] / apps / plugins / bounce.c
blob67375021b5674d2baee73b1b4747936c1ce1b436
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_UP BUTTON_UP
34 #define BOUNCE_DOWN BUTTON_DOWN
35 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
36 #define BOUNCE_MODE (BUTTON_ON | BUTTON_REL)
38 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
39 #define BOUNCE_UP BUTTON_UP
40 #define BOUNCE_DOWN BUTTON_DOWN
41 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
42 #define BOUNCE_MODE (BUTTON_ON | BUTTON_REL)
44 #elif CONFIG_KEYPAD == ONDIO_PAD
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_MENU | BUTTON_REL)
50 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
51 (CONFIG_KEYPAD == IRIVER_H300_PAD)
52 #define BOUNCE_UP BUTTON_UP
53 #define BOUNCE_DOWN BUTTON_DOWN
54 #define BOUNCE_QUIT (BUTTON_OFF | BUTTON_REL)
55 #define BOUNCE_MODE (BUTTON_SELECT | BUTTON_REL)
57 #define BOUNCE_RC_QUIT (BUTTON_RC_STOP | BUTTON_REL)
59 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
60 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
61 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
62 #define BOUNCE_UP BUTTON_SCROLL_BACK
63 #define BOUNCE_DOWN BUTTON_SCROLL_FWD
64 #define BOUNCE_QUIT (BUTTON_MENU | BUTTON_REL)
65 #define BOUNCE_MODE (BUTTON_SELECT | BUTTON_REL)
67 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
68 #define BOUNCE_UP BUTTON_UP
69 #define BOUNCE_DOWN BUTTON_DOWN
70 #define BOUNCE_QUIT BUTTON_POWER
71 #define BOUNCE_MODE BUTTON_PLAY
73 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
74 #define BOUNCE_UP BUTTON_UP
75 #define BOUNCE_DOWN BUTTON_DOWN
76 #define BOUNCE_QUIT BUTTON_POWER
77 #define BOUNCE_MODE BUTTON_A
79 #elif CONFIG_KEYPAD == SANSA_E200_PAD
80 #define BOUNCE_UP BUTTON_SCROLL_BACK
81 #define BOUNCE_DOWN BUTTON_SCROLL_FWD
82 #define BOUNCE_QUIT BUTTON_POWER
83 #define BOUNCE_MODE BUTTON_SELECT
85 #elif CONFIG_KEYPAD == SANSA_C200_PAD
86 #define BOUNCE_UP BUTTON_UP
87 #define BOUNCE_DOWN BUTTON_DOWN
88 #define BOUNCE_QUIT BUTTON_POWER
89 #define BOUNCE_MODE BUTTON_SELECT
91 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
92 #define BOUNCE_UP BUTTON_SCROLL_UP
93 #define BOUNCE_DOWN BUTTON_SCROLL_DOWN
94 #define BOUNCE_QUIT BUTTON_POWER
95 #define BOUNCE_MODE BUTTON_PLAY
97 #endif
99 static struct plugin_api* rb;
101 #define LETTER_WIDTH 11
102 #define LETTER_HEIGHT 16
104 const unsigned char char_gen_12x16[][22] =
106 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
107 { 0x00,0x00,0x00,0x7c,0xff,0xff,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00 },
108 { 0x00,0x00,0x3c,0x3c,0x00,0x00,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
109 { 0x00,0x10,0x90,0xf0,0x7e,0x1e,0x90,0xf0,0x7e,0x1e,0x10,0x02,0x1e,0x1f,0x03,0x02,0x1e,0x1f,0x03,0x02,0x00,0x00 },
110 { 0x00,0x78,0xfc,0xcc,0xff,0xff,0xcc,0xcc,0x88,0x00,0x00,0x00,0x04,0x0c,0x0c,0x3f,0x3f,0x0c,0x0f,0x07,0x00,0x00 },
111 { 0x00,0x38,0x38,0x38,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x38,0x38,0x38,0x00 },
112 { 0x00,0x00,0xb8,0xfc,0xc6,0xe2,0x3e,0x1c,0x00,0x00,0x00,0x00,0x1f,0x3f,0x31,0x21,0x37,0x1e,0x1c,0x36,0x22,0x00 },
113 { 0x00,0x00,0x00,0x27,0x3f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
114 { 0x00,0x00,0xf0,0xfc,0xfe,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x0f,0x1f,0x38,0x20,0x20,0x00,0x00,0x00 },
115 { 0x00,0x00,0x01,0x01,0x07,0xfe,0xfc,0xf0,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x38,0x1f,0x0f,0x03,0x00,0x00,0x00 },
116 { 0x00,0x98,0xb8,0xe0,0xf8,0xf8,0xe0,0xb8,0x98,0x00,0x00,0x00,0x0c,0x0e,0x03,0x0f,0x0f,0x03,0x0e,0x0c,0x00,0x00 },
117 { 0x00,0x80,0x80,0x80,0xf0,0xf0,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x0f,0x0f,0x01,0x01,0x01,0x00,0x00 },
118 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xf8,0x78,0x00,0x00,0x00,0x00,0x00 },
119 { 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00 },
120 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00 },
121 { 0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x18,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00 },
122 { 0xf8,0xfe,0x06,0x03,0x83,0xc3,0x63,0x33,0x1e,0xfe,0xf8,0x07,0x1f,0x1e,0x33,0x31,0x30,0x30,0x30,0x18,0x1f,0x07 },
123 { 0x00,0x00,0x0c,0x0c,0x0e,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x3f,0x3f,0x30,0x30,0x30,0x00 },
124 { 0x1c,0x1e,0x07,0x03,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x30,0x38,0x3c,0x3e,0x37,0x33,0x31,0x30,0x30,0x30,0x30 },
125 { 0x0c,0x0e,0x07,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e,0x3c,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0e },
126 { 0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x07,0xff,0xff,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x3f,0x3f,0x03,0x03 },
127 { 0x3f,0x7f,0x63,0x63,0x63,0x63,0x63,0x63,0xe3,0xc3,0x83,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f },
128 { 0xc0,0xf0,0xf8,0xdc,0xce,0xc7,0xc3,0xc3,0xc3,0x80,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
129 { 0x03,0x03,0x03,0x03,0x03,0x03,0xc3,0xf3,0x3f,0x0f,0x03,0x00,0x00,0x00,0x30,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00 },
130 { 0x00,0xbc,0xfe,0xe7,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
131 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xfc,0x00,0x00,0x30,0x30,0x30,0x38,0x1c,0x0e,0x07,0x03,0x00 },
132 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00 },
133 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xfc,0x7c,0x00,0x00,0x00,0x00,0x00 },
134 { 0x00,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00,0x00 },
135 { 0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00 },
136 { 0x00,0x03,0x07,0x0e,0x1c,0x38,0xf0,0xe0,0xc0,0x00,0x00,0x00,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00 },
137 { 0x1c,0x1e,0x07,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x00,0x00 },
138 { 0xf8,0xfe,0x07,0xf3,0xfb,0x1b,0xfb,0xfb,0x07,0xfe,0xf8,0x0f,0x1f,0x18,0x33,0x37,0x36,0x37,0x37,0x36,0x03,0x01 },
139 { 0x00,0x00,0xe0,0xfc,0x1f,0x1f,0xfc,0xe0,0x00,0x00,0x00,0x38,0x3f,0x07,0x06,0x06,0x06,0x06,0x07,0x3f,0x38,0x00 },
140 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
141 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x03,0x07,0x0e,0x0c,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x38,0x1c,0x0c,0x00 },
142 { 0xff,0xff,0x03,0x03,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
143 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
144 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
145 { 0xf0,0xfc,0x0e,0x07,0x03,0xc3,0xc3,0xc3,0xc7,0xc6,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
146 { 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
147 { 0x00,0x00,0x03,0x03,0xff,0xff,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
148 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x0e,0x1e,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
149 { 0xff,0xff,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x3f,0x3f,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00 },
150 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
151 { 0xff,0xff,0x1e,0x78,0xe0,0xe0,0x78,0x1e,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x01,0x01,0x00,0x00,0x3f,0x3f,0x00 },
152 { 0xff,0xff,0x0e,0x38,0xf0,0xc0,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x03,0x07,0x1c,0x3f,0x3f,0x00 },
153 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
154 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00 },
155 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x36,0x3e,0x1c,0x3f,0x33,0x00 },
156 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x03,0x07,0x0f,0x1d,0x38,0x30,0x00 },
157 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc7,0x8e,0x0c,0x00,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
158 { 0x00,0x03,0x03,0x03,0xff,0xff,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
159 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x07,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
160 { 0x07,0x3f,0xf8,0xc0,0x00,0x00,0xc0,0xf8,0x3f,0x07,0x00,0x00,0x00,0x01,0x0f,0x3e,0x3e,0x0f,0x01,0x00,0x00,0x00 },
161 { 0xff,0xff,0x00,0x00,0x80,0x80,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x1c,0x06,0x03,0x03,0x06,0x1c,0x3f,0x3f,0x00 },
162 { 0x03,0x0f,0x1c,0x30,0xe0,0xe0,0x30,0x1c,0x0f,0x03,0x00,0x30,0x3c,0x0e,0x03,0x01,0x01,0x03,0x0e,0x3c,0x30,0x00 },
163 { 0x03,0x0f,0x3c,0xf0,0xc0,0xc0,0xf0,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
164 { 0x03,0x03,0x03,0x03,0xc3,0xe3,0x33,0x1f,0x0f,0x03,0x00,0x30,0x3c,0x3e,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x00 },
165 { 0x00,0x00,0xff,0xff,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
166 { 0x0e,0x1c,0x38,0x70,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x18 },
167 { 0x00,0x00,0x03,0x03,0x03,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00,0x00,0x00 },
168 { 0x60,0x70,0x38,0x1c,0x0e,0x07,0x0e,0x1c,0x38,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
169 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },
170 { 0x00,0x00,0x00,0x00,0x3e,0x7e,0x4e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
171 { 0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x1c,0x3e,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x3f,0x00 },
172 { 0xff,0xff,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
173 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x18,0x08,0x00 },
174 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0xe0,0xc0,0xff,0xff,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
175 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x3b,0x33,0x33,0x33,0x33,0x33,0x13,0x01,0x00 },
176 { 0xc0,0xc0,0xfc,0xfe,0xc7,0xc3,0xc3,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
177 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x03,0xc7,0xce,0xcc,0xcc,0xcc,0xcc,0xe6,0x7f,0x3f,0x00 },
178 { 0xff,0xff,0xc0,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00 },
179 { 0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
180 { 0x00,0x00,0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x60,0xe0,0xc0,0xc0,0xff,0x7f,0x00,0x00,0x00 },
181 { 0x00,0xff,0xff,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x00,0x00,0x3f,0x3f,0x03,0x07,0x0f,0x1c,0x38,0x30,0x00,0x00 },
182 { 0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
183 { 0xe0,0xc0,0xe0,0xe0,0xc0,0xc0,0xe0,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00 },
184 { 0x00,0xe0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
185 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
186 { 0xe0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0xff,0xff,0x0c,0x18,0x18,0x18,0x18,0x1c,0x0f,0x07,0x00 },
187 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x07,0x0f,0x1c,0x18,0x18,0x18,0x18,0x0c,0xff,0xff,0x00 },
188 { 0x00,0xe0,0xe0,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
189 { 0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x11,0x33,0x33,0x33,0x33,0x33,0x3f,0x1e,0x00,0x00,0x00 },
190 { 0x60,0x60,0xfe,0xfe,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
191 { 0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x18,0x3f,0x3f,0x00 },
192 { 0x60,0xe0,0x80,0x00,0x00,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x01,0x07,0x1e,0x38,0x38,0x1e,0x07,0x01,0x00,0x00 },
193 { 0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x07,0x1f,0x38,0x1c,0x0f,0x0f,0x1c,0x38,0x1f,0x07,0x00 },
194 { 0x60,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x30,0x38,0x1d,0x0f,0x07,0x0f,0x1d,0x38,0x30,0x00,0x00 },
195 { 0x00,0x60,0xe0,0x80,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00,0x00,0x81,0xe7,0x7e,0x1e,0x07,0x01,0x00,0x00,0x00 },
196 { 0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,0x20,0x00,0x00,0x30,0x38,0x3c,0x36,0x33,0x31,0x30,0x30,0x30,0x00,0x00 },
197 { 0x00,0x80,0xc0,0xfc,0x7e,0x07,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x01,0x1f,0x3f,0x70,0x60,0x60,0x60,0x00,0x00 },
198 { 0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
199 { 0x00,0x03,0x03,0x03,0x07,0x7e,0xfc,0xc0,0x80,0x00,0x00,0x00,0x60,0x60,0x60,0x70,0x3f,0x1f,0x01,0x00,0x00,0x00 },
200 { 0x10,0x18,0x0c,0x04,0x0c,0x18,0x10,0x18,0x0c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
201 { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00 }
204 static signed char speed[]={
205 1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1,
208 #if LCD_WIDTH > LCD_HEIGHT /* landscape LCD */
210 #define TABLE_SIZE LCD_HEIGHT
211 #define RADIUS_MINUTE (3*LCD_HEIGHT/8)
212 #define RADIUS_HOUR (LCD_HEIGHT/4)
214 #else /* portrait (or square) LCD */
216 #define TABLE_SIZE LCD_WIDTH
217 #define RADIUS_MINUTE (3*LCD_WIDTH/8)
218 #define RADIUS_HOUR (LCD_WIDTH/4)
220 #endif /* LCD orientation */
222 #define RADIUS_X ((LCD_WIDTH-LETTER_WIDTH)/2)
223 #define RADIUS_Y ((LCD_HEIGHT-LETTER_HEIGHT)/2)
225 #define PHASE_STEP (0xffffffff/TABLE_SIZE)
226 #define PHASE_FRAC (0xffffffff%TABLE_SIZE)
227 #define DIV_X (0x7ffffffe/RADIUS_X+1)
228 #define DIV_Y (0x7ffffffe/RADIUS_Y+1)
230 static int xtable[TABLE_SIZE];
231 static int ytable[TABLE_SIZE];
233 static void init_tables(void)
235 int i;
236 int pfrac;
237 unsigned long phase;
238 long sin;
240 phase = pfrac = 0;
242 for (i = 0; i < TABLE_SIZE; i++) {
243 sin = fsincos(phase, NULL);
244 xtable[i] = RADIUS_X + sin / DIV_X;
245 ytable[i] = RADIUS_Y + sin / DIV_Y;
247 phase += PHASE_STEP;
248 pfrac += PHASE_FRAC;
249 if (pfrac >= TABLE_SIZE) {
250 pfrac -= TABLE_SIZE;
251 phase++;
256 enum {
257 NUM_XSANKE,
258 NUM_YSANKE,
259 NUM_XADD,
260 NUM_YADD,
261 NUM_XDIST,
262 NUM_YDIST,
264 NUM_LAST
267 struct counter {
268 char *what;
269 int num;
272 struct counter values[]={
273 {"xsanke", 1},
274 {"ysanke", 1},
275 {"xadd", 1},
276 {"yadd", 2},
277 {"xdist", -4},
278 {"ydist", -6},
281 #if CONFIG_RTC
283 #define CLOCK_STEP (0xffffffff/60)
284 #define CLOCK_FRAC (0xffffffff%60)
286 #define DIV_MY (0x7ffffffe/RADIUS_MINUTE+1)
287 #define DIV_HY (0x7ffffffe/RADIUS_HOUR+1)
289 #if LCD_WIDTH == 112 && LCD_HEIGHT == 64 /* Archos LCD: non-square pixels */
290 #define DIV_MX (0x7ffffffe/(5*RADIUS_MINUTE/4)+1)
291 #define DIV_HX (0x7ffffffe/(5*RADIUS_HOUR/4)+1)
292 #else /* Square pixels */
293 #define DIV_MX DIV_MY
294 #define DIV_HX DIV_HY
295 #endif
297 static int xminute[60], yminute[60];
298 static int xhour[60], yhour[60];
300 static void init_clock(void)
302 int i;
303 int pfrac;
304 unsigned long phase;
305 long sin, cos;
307 phase = pfrac = 0;
309 for (i = 0; i < 60; i++) {
310 sin = fsincos(phase, &cos);
311 xminute[i] = LCD_WIDTH/2 + sin / DIV_MX;
312 yminute[i] = LCD_HEIGHT/2 - cos / DIV_MY;
313 xhour[i] = LCD_WIDTH/2 + sin / DIV_HX;
314 yhour[i] = LCD_HEIGHT/2 - cos / DIV_HY;
316 phase += CLOCK_STEP;
317 pfrac += CLOCK_FRAC;
318 if (pfrac >= 60) {
319 pfrac -= 60;
320 phase++;
325 static void addclock(void)
327 int i;
328 int hour;
329 int minute;
331 struct tm* current_time = rb->get_time();
332 hour = current_time->tm_hour;
333 minute = current_time->tm_min;
335 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2,
336 xminute[minute], yminute[minute]);
338 hour = (hour % 12) * 5 + minute / 12;
340 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour[hour], yhour[hour]);
342 /* draw a circle */
343 for(i = 1; i < 60; i += 3)
344 rb->lcd_drawline(xminute[i], yminute[i],
345 xminute[(i+1)%60], yminute[(i+1)%60]);
347 #endif /* CONFIG_RTC */
349 #if LCD_DEPTH > 1
350 static const unsigned face_colors[] =
352 #ifdef HAVE_LCD_COLOR
353 LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
354 #else
355 LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
356 #endif
358 #endif
360 static int scrollit(void)
362 int b;
363 unsigned int y=100;
364 unsigned int yy;
365 int x = LCD_WIDTH;
366 int xx;
367 unsigned int i;
368 unsigned int textpos=0;
370 char* rock="Rockbox! Pure pleasure. Pure fun. Oooh. What fun! ;-) ";
371 unsigned int rocklen = rb->strlen(rock);
372 int letter;
374 rb->lcd_clear_display();
375 while(1)
377 b = rb->button_get_w_tmo(HZ/10);
378 switch(b)
380 #ifdef BOUNCE_RC_QUIT
381 case BOUNCE_RC_QUIT :
382 #endif
383 case BOUNCE_QUIT :
384 return 0;
385 case BOUNCE_MODE :
386 return 1;
387 default:
388 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
389 return -1;
391 rb->lcd_clear_display();
392 #if CONFIG_RTC
393 addclock();
394 #endif
396 for(i=0, yy=y, xx=x; xx < LCD_WIDTH; i++) {
397 letter = rock[(i+textpos) % rocklen ];
398 #if LCD_DEPTH > 1
399 rb->lcd_set_foreground(face_colors[letter % 3]);
400 #endif
401 rb->lcd_mono_bitmap(char_gen_12x16[letter-0x20],
402 xx, ytable[yy % TABLE_SIZE],
403 LETTER_WIDTH, LETTER_HEIGHT);
404 yy += YADD;
405 xx += LETTER_WIDTH;
407 #if LCD_DEPTH > 1
408 rb->lcd_set_foreground(LCD_BLACK);
409 #endif
410 rb->lcd_update();
412 x-= XSPEED;
414 if(x < -LETTER_WIDTH) {
415 x += LETTER_WIDTH;
416 y += YADD;
417 textpos++;
420 y+=YSPEED;
424 static int loopit(void)
426 int b;
427 unsigned int y=100;
428 unsigned int x=100;
429 unsigned int yy,xx;
430 unsigned int i;
431 unsigned int ysanke=0;
432 unsigned int xsanke=0;
434 char* rock="ROCKbox";
435 unsigned int rocklen = rb->strlen(rock);
437 int show=0;
438 int timeout=0;
439 char buffer[30];
441 rb->lcd_clear_display();
442 while(1)
444 b = rb->button_get_w_tmo(HZ/10);
445 if ( b == BOUNCE_QUIT )
446 return 0;
448 if ( b == BOUNCE_MODE )
449 return 1;
451 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
452 return -1;
454 if ( b != BUTTON_NONE )
455 timeout=20;
457 y+= speed[ysanke&15] + values[NUM_YADD].num;
458 x+= speed[xsanke&15] + values[NUM_XADD].num;
460 rb->lcd_clear_display();
461 #if CONFIG_RTC
462 addclock();
463 #endif
464 if(timeout) {
465 switch(b) {
466 case BUTTON_LEFT:
467 case BUTTON_LEFT|BUTTON_REPEAT:
468 values[show].num--;
469 break;
470 case BUTTON_RIGHT:
471 case BUTTON_RIGHT|BUTTON_REPEAT:
472 values[show].num++;
473 break;
474 case BOUNCE_UP:
475 case BOUNCE_UP|BUTTON_REPEAT:
476 if(++show == NUM_LAST)
477 show=0;
478 break;
479 case BOUNCE_DOWN:
480 case BOUNCE_DOWN|BUTTON_REPEAT:
481 if(--show < 0)
482 show=NUM_LAST-1;
483 break;
485 rb->snprintf(buffer, 30, "%s: %d",
486 values[show].what, values[show].num);
487 rb->lcd_putsxy(0, LCD_HEIGHT - 8, (unsigned char *)buffer);
488 timeout--;
490 for(i=0, yy=y, xx=x;
491 i<rocklen;
492 i++, yy+=values[NUM_YDIST].num, xx+=values[NUM_XDIST].num)
493 rb->lcd_mono_bitmap(char_gen_12x16[rock[i]-0x20],
494 xtable[xx % TABLE_SIZE],
495 ytable[yy % TABLE_SIZE],
496 LETTER_WIDTH, LETTER_HEIGHT);
497 rb->lcd_update();
499 ysanke+= values[NUM_YSANKE].num;
500 xsanke+= values[NUM_XSANKE].num;
505 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
507 int w, h;
508 char *off = "[Off] to stop";
510 (void)(parameter);
511 rb = api;
513 rb->lcd_setfont(FONT_SYSFIXED);
514 rb->lcd_clear_display();
516 /* Get horizontel centering for text */
517 rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h);
518 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2,
519 (unsigned char *)SS_TITLE);
521 /* Get horizontel centering for text */
522 rb->lcd_getstringsize((unsigned char *)off, &w, &h);
523 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h,
524 (unsigned char *)off);
526 rb->lcd_update();
527 rb->sleep(HZ);
528 rb->lcd_set_drawmode(DRMODE_FG);
529 init_tables();
530 #if CONFIG_RTC
531 init_clock();
532 #endif
534 do {
535 h = loopit();
536 if (h > 0)
537 h = scrollit();
538 } while(h > 0);
540 rb->lcd_set_drawmode(DRMODE_SOLID);
541 rb->lcd_setfont(FONT_UI);
543 return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;