fix the last warning
[kugel-rb.git] / apps / plugins / bounce.c
blobf83d99306a941068d274f634127a59ad4b54cdc0
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 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
98 #define BOUNCE_UP BUTTON_UP
99 #define BOUNCE_DOWN BUTTON_DOWN
100 #define BOUNCE_QUIT BUTTON_BACK
101 #define BOUNCE_MODE BUTTON_MENU
103 #elif (CONFIG_KEYPAD == MROBE100_PAD)
104 #define BOUNCE_UP BUTTON_UP
105 #define BOUNCE_DOWN BUTTON_DOWN
106 #define BOUNCE_QUIT BUTTON_POWER
107 #define BOUNCE_MODE BUTTON_DISPLAY
109 #else
110 #error No keymap defined!
111 #endif
113 static struct plugin_api* rb;
115 #define LETTER_WIDTH 11
116 #define LETTER_HEIGHT 16
118 const unsigned char char_gen_12x16[][22] =
120 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
121 { 0x00,0x00,0x00,0x7c,0xff,0xff,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00 },
122 { 0x00,0x00,0x3c,0x3c,0x00,0x00,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
123 { 0x00,0x10,0x90,0xf0,0x7e,0x1e,0x90,0xf0,0x7e,0x1e,0x10,0x02,0x1e,0x1f,0x03,0x02,0x1e,0x1f,0x03,0x02,0x00,0x00 },
124 { 0x00,0x78,0xfc,0xcc,0xff,0xff,0xcc,0xcc,0x88,0x00,0x00,0x00,0x04,0x0c,0x0c,0x3f,0x3f,0x0c,0x0f,0x07,0x00,0x00 },
125 { 0x00,0x38,0x38,0x38,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x38,0x38,0x38,0x00 },
126 { 0x00,0x00,0xb8,0xfc,0xc6,0xe2,0x3e,0x1c,0x00,0x00,0x00,0x00,0x1f,0x3f,0x31,0x21,0x37,0x1e,0x1c,0x36,0x22,0x00 },
127 { 0x00,0x00,0x00,0x27,0x3f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
128 { 0x00,0x00,0xf0,0xfc,0xfe,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x0f,0x1f,0x38,0x20,0x20,0x00,0x00,0x00 },
129 { 0x00,0x00,0x01,0x01,0x07,0xfe,0xfc,0xf0,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x38,0x1f,0x0f,0x03,0x00,0x00,0x00 },
130 { 0x00,0x98,0xb8,0xe0,0xf8,0xf8,0xe0,0xb8,0x98,0x00,0x00,0x00,0x0c,0x0e,0x03,0x0f,0x0f,0x03,0x0e,0x0c,0x00,0x00 },
131 { 0x00,0x80,0x80,0x80,0xf0,0xf0,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x0f,0x0f,0x01,0x01,0x01,0x00,0x00 },
132 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xf8,0x78,0x00,0x00,0x00,0x00,0x00 },
133 { 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00 },
134 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00 },
135 { 0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x18,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00 },
136 { 0xf8,0xfe,0x06,0x03,0x83,0xc3,0x63,0x33,0x1e,0xfe,0xf8,0x07,0x1f,0x1e,0x33,0x31,0x30,0x30,0x30,0x18,0x1f,0x07 },
137 { 0x00,0x00,0x0c,0x0c,0x0e,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x3f,0x3f,0x30,0x30,0x30,0x00 },
138 { 0x1c,0x1e,0x07,0x03,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x30,0x38,0x3c,0x3e,0x37,0x33,0x31,0x30,0x30,0x30,0x30 },
139 { 0x0c,0x0e,0x07,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e,0x3c,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0e },
140 { 0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x07,0xff,0xff,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x3f,0x3f,0x03,0x03 },
141 { 0x3f,0x7f,0x63,0x63,0x63,0x63,0x63,0x63,0xe3,0xc3,0x83,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f },
142 { 0xc0,0xf0,0xf8,0xdc,0xce,0xc7,0xc3,0xc3,0xc3,0x80,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
143 { 0x03,0x03,0x03,0x03,0x03,0x03,0xc3,0xf3,0x3f,0x0f,0x03,0x00,0x00,0x00,0x30,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00 },
144 { 0x00,0xbc,0xfe,0xe7,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
145 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xfc,0x00,0x00,0x30,0x30,0x30,0x38,0x1c,0x0e,0x07,0x03,0x00 },
146 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00 },
147 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xfc,0x7c,0x00,0x00,0x00,0x00,0x00 },
148 { 0x00,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00,0x00 },
149 { 0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00 },
150 { 0x00,0x03,0x07,0x0e,0x1c,0x38,0xf0,0xe0,0xc0,0x00,0x00,0x00,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00 },
151 { 0x1c,0x1e,0x07,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x00,0x00 },
152 { 0xf8,0xfe,0x07,0xf3,0xfb,0x1b,0xfb,0xfb,0x07,0xfe,0xf8,0x0f,0x1f,0x18,0x33,0x37,0x36,0x37,0x37,0x36,0x03,0x01 },
153 { 0x00,0x00,0xe0,0xfc,0x1f,0x1f,0xfc,0xe0,0x00,0x00,0x00,0x38,0x3f,0x07,0x06,0x06,0x06,0x06,0x07,0x3f,0x38,0x00 },
154 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
155 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x03,0x07,0x0e,0x0c,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x38,0x1c,0x0c,0x00 },
156 { 0xff,0xff,0x03,0x03,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
157 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
158 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
159 { 0xf0,0xfc,0x0e,0x07,0x03,0xc3,0xc3,0xc3,0xc7,0xc6,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
160 { 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
161 { 0x00,0x00,0x03,0x03,0xff,0xff,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
162 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x0e,0x1e,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
163 { 0xff,0xff,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x3f,0x3f,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00 },
164 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
165 { 0xff,0xff,0x1e,0x78,0xe0,0xe0,0x78,0x1e,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x01,0x01,0x00,0x00,0x3f,0x3f,0x00 },
166 { 0xff,0xff,0x0e,0x38,0xf0,0xc0,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x03,0x07,0x1c,0x3f,0x3f,0x00 },
167 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
168 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00 },
169 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x36,0x3e,0x1c,0x3f,0x33,0x00 },
170 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x03,0x07,0x0f,0x1d,0x38,0x30,0x00 },
171 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc7,0x8e,0x0c,0x00,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
172 { 0x00,0x03,0x03,0x03,0xff,0xff,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
173 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x07,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
174 { 0x07,0x3f,0xf8,0xc0,0x00,0x00,0xc0,0xf8,0x3f,0x07,0x00,0x00,0x00,0x01,0x0f,0x3e,0x3e,0x0f,0x01,0x00,0x00,0x00 },
175 { 0xff,0xff,0x00,0x00,0x80,0x80,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x1c,0x06,0x03,0x03,0x06,0x1c,0x3f,0x3f,0x00 },
176 { 0x03,0x0f,0x1c,0x30,0xe0,0xe0,0x30,0x1c,0x0f,0x03,0x00,0x30,0x3c,0x0e,0x03,0x01,0x01,0x03,0x0e,0x3c,0x30,0x00 },
177 { 0x03,0x0f,0x3c,0xf0,0xc0,0xc0,0xf0,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
178 { 0x03,0x03,0x03,0x03,0xc3,0xe3,0x33,0x1f,0x0f,0x03,0x00,0x30,0x3c,0x3e,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x00 },
179 { 0x00,0x00,0xff,0xff,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
180 { 0x0e,0x1c,0x38,0x70,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x18 },
181 { 0x00,0x00,0x03,0x03,0x03,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00,0x00,0x00 },
182 { 0x60,0x70,0x38,0x1c,0x0e,0x07,0x0e,0x1c,0x38,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
183 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },
184 { 0x00,0x00,0x00,0x00,0x3e,0x7e,0x4e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
185 { 0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x1c,0x3e,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x3f,0x00 },
186 { 0xff,0xff,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
187 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x18,0x08,0x00 },
188 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0xe0,0xc0,0xff,0xff,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
189 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x3b,0x33,0x33,0x33,0x33,0x33,0x13,0x01,0x00 },
190 { 0xc0,0xc0,0xfc,0xfe,0xc7,0xc3,0xc3,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
191 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x03,0xc7,0xce,0xcc,0xcc,0xcc,0xcc,0xe6,0x7f,0x3f,0x00 },
192 { 0xff,0xff,0xc0,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00 },
193 { 0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
194 { 0x00,0x00,0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x60,0xe0,0xc0,0xc0,0xff,0x7f,0x00,0x00,0x00 },
195 { 0x00,0xff,0xff,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x00,0x00,0x3f,0x3f,0x03,0x07,0x0f,0x1c,0x38,0x30,0x00,0x00 },
196 { 0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
197 { 0xe0,0xc0,0xe0,0xe0,0xc0,0xc0,0xe0,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00 },
198 { 0x00,0xe0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
199 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
200 { 0xe0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0xff,0xff,0x0c,0x18,0x18,0x18,0x18,0x1c,0x0f,0x07,0x00 },
201 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x07,0x0f,0x1c,0x18,0x18,0x18,0x18,0x0c,0xff,0xff,0x00 },
202 { 0x00,0xe0,0xe0,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
203 { 0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x11,0x33,0x33,0x33,0x33,0x33,0x3f,0x1e,0x00,0x00,0x00 },
204 { 0x60,0x60,0xfe,0xfe,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
205 { 0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x18,0x3f,0x3f,0x00 },
206 { 0x60,0xe0,0x80,0x00,0x00,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x01,0x07,0x1e,0x38,0x38,0x1e,0x07,0x01,0x00,0x00 },
207 { 0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x07,0x1f,0x38,0x1c,0x0f,0x0f,0x1c,0x38,0x1f,0x07,0x00 },
208 { 0x60,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x30,0x38,0x1d,0x0f,0x07,0x0f,0x1d,0x38,0x30,0x00,0x00 },
209 { 0x00,0x60,0xe0,0x80,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00,0x00,0x81,0xe7,0x7e,0x1e,0x07,0x01,0x00,0x00,0x00 },
210 { 0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,0x20,0x00,0x00,0x30,0x38,0x3c,0x36,0x33,0x31,0x30,0x30,0x30,0x00,0x00 },
211 { 0x00,0x80,0xc0,0xfc,0x7e,0x07,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x01,0x1f,0x3f,0x70,0x60,0x60,0x60,0x00,0x00 },
212 { 0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
213 { 0x00,0x03,0x03,0x03,0x07,0x7e,0xfc,0xc0,0x80,0x00,0x00,0x00,0x60,0x60,0x60,0x70,0x3f,0x1f,0x01,0x00,0x00,0x00 },
214 { 0x10,0x18,0x0c,0x04,0x0c,0x18,0x10,0x18,0x0c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
215 { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00 }
218 static signed char speed[]={
219 1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1,
222 #if LCD_WIDTH > LCD_HEIGHT /* landscape LCD */
224 #define TABLE_SIZE LCD_HEIGHT
225 #define RADIUS_MINUTE (3*LCD_HEIGHT/8)
226 #define RADIUS_HOUR (LCD_HEIGHT/4)
228 #else /* portrait (or square) LCD */
230 #define TABLE_SIZE LCD_WIDTH
231 #define RADIUS_MINUTE (3*LCD_WIDTH/8)
232 #define RADIUS_HOUR (LCD_WIDTH/4)
234 #endif /* LCD orientation */
236 #define RADIUS_X ((LCD_WIDTH-LETTER_WIDTH)/2)
237 #define RADIUS_Y ((LCD_HEIGHT-LETTER_HEIGHT)/2)
239 #define PHASE_STEP (0xffffffff/TABLE_SIZE)
240 #define PHASE_FRAC (0xffffffff%TABLE_SIZE)
241 #define DIV_X (0x7ffffffe/RADIUS_X+1)
242 #define DIV_Y (0x7ffffffe/RADIUS_Y+1)
244 static int xtable[TABLE_SIZE];
245 static int ytable[TABLE_SIZE];
247 static void init_tables(void)
249 int i;
250 int pfrac;
251 unsigned long phase;
252 long sin;
254 phase = pfrac = 0;
256 for (i = 0; i < TABLE_SIZE; i++) {
257 sin = fsincos(phase, NULL);
258 xtable[i] = RADIUS_X + sin / DIV_X;
259 ytable[i] = RADIUS_Y + sin / DIV_Y;
261 phase += PHASE_STEP;
262 pfrac += PHASE_FRAC;
263 if (pfrac >= TABLE_SIZE) {
264 pfrac -= TABLE_SIZE;
265 phase++;
270 enum {
271 NUM_XSANKE,
272 NUM_YSANKE,
273 NUM_XADD,
274 NUM_YADD,
275 NUM_XDIST,
276 NUM_YDIST,
278 NUM_LAST
281 struct counter {
282 char *what;
283 int num;
286 struct counter values[]={
287 {"xsanke", 1},
288 {"ysanke", 1},
289 {"xadd", 1},
290 {"yadd", 2},
291 {"xdist", -4},
292 {"ydist", -6},
295 #if CONFIG_RTC
297 #define CLOCK_STEP (0xffffffff/60)
298 #define CLOCK_FRAC (0xffffffff%60)
300 #define DIV_MY (0x7ffffffe/RADIUS_MINUTE+1)
301 #define DIV_HY (0x7ffffffe/RADIUS_HOUR+1)
303 #if LCD_WIDTH == 112 && LCD_HEIGHT == 64 /* Archos LCD: non-square pixels */
304 #define DIV_MX (0x7ffffffe/(5*RADIUS_MINUTE/4)+1)
305 #define DIV_HX (0x7ffffffe/(5*RADIUS_HOUR/4)+1)
306 #else /* Square pixels */
307 #define DIV_MX DIV_MY
308 #define DIV_HX DIV_HY
309 #endif
311 static int xminute[60], yminute[60];
312 static int xhour[60], yhour[60];
314 static void init_clock(void)
316 int i;
317 int pfrac;
318 unsigned long phase;
319 long sin, cos;
321 phase = pfrac = 0;
323 for (i = 0; i < 60; i++) {
324 sin = fsincos(phase, &cos);
325 xminute[i] = LCD_WIDTH/2 + sin / DIV_MX;
326 yminute[i] = LCD_HEIGHT/2 - cos / DIV_MY;
327 xhour[i] = LCD_WIDTH/2 + sin / DIV_HX;
328 yhour[i] = LCD_HEIGHT/2 - cos / DIV_HY;
330 phase += CLOCK_STEP;
331 pfrac += CLOCK_FRAC;
332 if (pfrac >= 60) {
333 pfrac -= 60;
334 phase++;
339 static void addclock(void)
341 int i;
342 int hour;
343 int minute;
345 struct tm* current_time = rb->get_time();
346 hour = current_time->tm_hour;
347 minute = current_time->tm_min;
349 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2,
350 xminute[minute], yminute[minute]);
352 hour = (hour % 12) * 5 + minute / 12;
354 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour[hour], yhour[hour]);
356 /* draw a circle */
357 for(i = 1; i < 60; i += 3)
358 rb->lcd_drawline(xminute[i], yminute[i],
359 xminute[(i+1)%60], yminute[(i+1)%60]);
361 #endif /* CONFIG_RTC */
363 #if LCD_DEPTH > 1
364 static const unsigned face_colors[] =
366 #ifdef HAVE_LCD_COLOR
367 LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
368 #else
369 LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
370 #endif
372 #endif
374 static int scrollit(void)
376 int b;
377 unsigned int y=100;
378 unsigned int yy;
379 int x = LCD_WIDTH;
380 int xx;
381 unsigned int i;
382 unsigned int textpos=0;
384 char* rock="Rockbox! Pure pleasure. Pure fun. Oooh. What fun! ;-) ";
385 unsigned int rocklen = rb->strlen(rock);
386 int letter;
388 rb->lcd_clear_display();
389 while(1)
391 b = rb->button_get_w_tmo(HZ/10);
392 switch(b)
394 #ifdef BOUNCE_RC_QUIT
395 case BOUNCE_RC_QUIT :
396 #endif
397 case BOUNCE_QUIT :
398 return 0;
399 case BOUNCE_MODE :
400 return 1;
401 default:
402 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
403 return -1;
405 rb->lcd_clear_display();
406 #if CONFIG_RTC
407 addclock();
408 #endif
410 for(i=0, yy=y, xx=x; xx < LCD_WIDTH; i++) {
411 letter = rock[(i+textpos) % rocklen ];
412 #if LCD_DEPTH > 1
413 rb->lcd_set_foreground(face_colors[letter % 3]);
414 #endif
415 rb->lcd_mono_bitmap(char_gen_12x16[letter-0x20],
416 xx, ytable[yy % TABLE_SIZE],
417 LETTER_WIDTH, LETTER_HEIGHT);
418 yy += YADD;
419 xx += LETTER_WIDTH;
421 #if LCD_DEPTH > 1
422 rb->lcd_set_foreground(LCD_BLACK);
423 #endif
424 rb->lcd_update();
426 x-= XSPEED;
428 if(x < -LETTER_WIDTH) {
429 x += LETTER_WIDTH;
430 y += YADD;
431 textpos++;
434 y+=YSPEED;
438 static int loopit(void)
440 int b;
441 unsigned int y=100;
442 unsigned int x=100;
443 unsigned int yy,xx;
444 unsigned int i;
445 unsigned int ysanke=0;
446 unsigned int xsanke=0;
448 char* rock="ROCKbox";
449 unsigned int rocklen = rb->strlen(rock);
451 int show=0;
452 int timeout=0;
453 char buffer[30];
455 rb->lcd_clear_display();
456 while(1)
458 b = rb->button_get_w_tmo(HZ/10);
459 if ( b == BOUNCE_QUIT )
460 return 0;
462 if ( b == BOUNCE_MODE )
463 return 1;
465 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
466 return -1;
468 if ( b != BUTTON_NONE )
469 timeout=20;
471 y+= speed[ysanke&15] + values[NUM_YADD].num;
472 x+= speed[xsanke&15] + values[NUM_XADD].num;
474 rb->lcd_clear_display();
475 #if CONFIG_RTC
476 addclock();
477 #endif
478 if(timeout) {
479 switch(b) {
480 case BUTTON_LEFT:
481 case BUTTON_LEFT|BUTTON_REPEAT:
482 values[show].num--;
483 break;
484 case BUTTON_RIGHT:
485 case BUTTON_RIGHT|BUTTON_REPEAT:
486 values[show].num++;
487 break;
488 case BOUNCE_UP:
489 case BOUNCE_UP|BUTTON_REPEAT:
490 if(++show == NUM_LAST)
491 show=0;
492 break;
493 case BOUNCE_DOWN:
494 case BOUNCE_DOWN|BUTTON_REPEAT:
495 if(--show < 0)
496 show=NUM_LAST-1;
497 break;
499 rb->snprintf(buffer, 30, "%s: %d",
500 values[show].what, values[show].num);
501 rb->lcd_putsxy(0, LCD_HEIGHT - 8, (unsigned char *)buffer);
502 timeout--;
504 for(i=0, yy=y, xx=x;
505 i<rocklen;
506 i++, yy+=values[NUM_YDIST].num, xx+=values[NUM_XDIST].num)
507 rb->lcd_mono_bitmap(char_gen_12x16[rock[i]-0x20],
508 xtable[xx % TABLE_SIZE],
509 ytable[yy % TABLE_SIZE],
510 LETTER_WIDTH, LETTER_HEIGHT);
511 rb->lcd_update();
513 ysanke+= values[NUM_YSANKE].num;
514 xsanke+= values[NUM_XSANKE].num;
519 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
521 int w, h;
522 char *off = "[Off] to stop";
524 (void)(parameter);
525 rb = api;
527 rb->lcd_setfont(FONT_SYSFIXED);
528 rb->lcd_clear_display();
530 /* Get horizontel centering for text */
531 rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h);
532 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2,
533 (unsigned char *)SS_TITLE);
535 /* Get horizontel centering for text */
536 rb->lcd_getstringsize((unsigned char *)off, &w, &h);
537 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h,
538 (unsigned char *)off);
540 rb->lcd_update();
541 rb->sleep(HZ);
542 rb->lcd_set_drawmode(DRMODE_FG);
543 init_tables();
544 #if CONFIG_RTC
545 init_clock();
546 #endif
548 do {
549 h = loopit();
550 if (h > 0)
551 h = scrollit();
552 } while(h > 0);
554 rb->lcd_set_drawmode(DRMODE_SOLID);
555 rb->lcd_setfont(FONT_UI);
557 return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;