Add platform file for Ipod 1G / 2G. Now only the front image is missing for building...
[Rockbox.git] / apps / plugins / bounce.c
blobeac6933815abacf1997b89f6af65f28018d532e9
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_UP
81 #define BOUNCE_DOWN BUTTON_SCROLL_DOWN
82 #define BOUNCE_QUIT BUTTON_POWER
83 #define BOUNCE_MODE BUTTON_SELECT
85 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
86 #define BOUNCE_UP BUTTON_SCROLL_UP
87 #define BOUNCE_DOWN BUTTON_SCROLL_DOWN
88 #define BOUNCE_QUIT BUTTON_POWER
89 #define BOUNCE_MODE BUTTON_PLAY
91 #endif
93 static struct plugin_api* rb;
95 #define LETTER_WIDTH 11
96 #define LETTER_HEIGHT 16
98 const unsigned char char_gen_12x16[][22] =
100 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
101 { 0x00,0x00,0x00,0x7c,0xff,0xff,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00 },
102 { 0x00,0x00,0x3c,0x3c,0x00,0x00,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
103 { 0x00,0x10,0x90,0xf0,0x7e,0x1e,0x90,0xf0,0x7e,0x1e,0x10,0x02,0x1e,0x1f,0x03,0x02,0x1e,0x1f,0x03,0x02,0x00,0x00 },
104 { 0x00,0x78,0xfc,0xcc,0xff,0xff,0xcc,0xcc,0x88,0x00,0x00,0x00,0x04,0x0c,0x0c,0x3f,0x3f,0x0c,0x0f,0x07,0x00,0x00 },
105 { 0x00,0x38,0x38,0x38,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x38,0x38,0x38,0x00 },
106 { 0x00,0x00,0xb8,0xfc,0xc6,0xe2,0x3e,0x1c,0x00,0x00,0x00,0x00,0x1f,0x3f,0x31,0x21,0x37,0x1e,0x1c,0x36,0x22,0x00 },
107 { 0x00,0x00,0x00,0x27,0x3f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
108 { 0x00,0x00,0xf0,0xfc,0xfe,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x0f,0x1f,0x38,0x20,0x20,0x00,0x00,0x00 },
109 { 0x00,0x00,0x01,0x01,0x07,0xfe,0xfc,0xf0,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x38,0x1f,0x0f,0x03,0x00,0x00,0x00 },
110 { 0x00,0x98,0xb8,0xe0,0xf8,0xf8,0xe0,0xb8,0x98,0x00,0x00,0x00,0x0c,0x0e,0x03,0x0f,0x0f,0x03,0x0e,0x0c,0x00,0x00 },
111 { 0x00,0x80,0x80,0x80,0xf0,0xf0,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x0f,0x0f,0x01,0x01,0x01,0x00,0x00 },
112 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xf8,0x78,0x00,0x00,0x00,0x00,0x00 },
113 { 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00 },
114 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00 },
115 { 0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x18,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00 },
116 { 0xf8,0xfe,0x06,0x03,0x83,0xc3,0x63,0x33,0x1e,0xfe,0xf8,0x07,0x1f,0x1e,0x33,0x31,0x30,0x30,0x30,0x18,0x1f,0x07 },
117 { 0x00,0x00,0x0c,0x0c,0x0e,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x3f,0x3f,0x30,0x30,0x30,0x00 },
118 { 0x1c,0x1e,0x07,0x03,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x30,0x38,0x3c,0x3e,0x37,0x33,0x31,0x30,0x30,0x30,0x30 },
119 { 0x0c,0x0e,0x07,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e,0x3c,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0e },
120 { 0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x07,0xff,0xff,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x3f,0x3f,0x03,0x03 },
121 { 0x3f,0x7f,0x63,0x63,0x63,0x63,0x63,0x63,0xe3,0xc3,0x83,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f },
122 { 0xc0,0xf0,0xf8,0xdc,0xce,0xc7,0xc3,0xc3,0xc3,0x80,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
123 { 0x03,0x03,0x03,0x03,0x03,0x03,0xc3,0xf3,0x3f,0x0f,0x03,0x00,0x00,0x00,0x30,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00 },
124 { 0x00,0xbc,0xfe,0xe7,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
125 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xfc,0x00,0x00,0x30,0x30,0x30,0x38,0x1c,0x0e,0x07,0x03,0x00 },
126 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00 },
127 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xfc,0x7c,0x00,0x00,0x00,0x00,0x00 },
128 { 0x00,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00,0x00 },
129 { 0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00 },
130 { 0x00,0x03,0x07,0x0e,0x1c,0x38,0xf0,0xe0,0xc0,0x00,0x00,0x00,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00 },
131 { 0x1c,0x1e,0x07,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x00,0x00 },
132 { 0xf8,0xfe,0x07,0xf3,0xfb,0x1b,0xfb,0xfb,0x07,0xfe,0xf8,0x0f,0x1f,0x18,0x33,0x37,0x36,0x37,0x37,0x36,0x03,0x01 },
133 { 0x00,0x00,0xe0,0xfc,0x1f,0x1f,0xfc,0xe0,0x00,0x00,0x00,0x38,0x3f,0x07,0x06,0x06,0x06,0x06,0x07,0x3f,0x38,0x00 },
134 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
135 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x03,0x07,0x0e,0x0c,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x38,0x1c,0x0c,0x00 },
136 { 0xff,0xff,0x03,0x03,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
137 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
138 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
139 { 0xf0,0xfc,0x0e,0x07,0x03,0xc3,0xc3,0xc3,0xc7,0xc6,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
140 { 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
141 { 0x00,0x00,0x03,0x03,0xff,0xff,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
142 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x0e,0x1e,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
143 { 0xff,0xff,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x3f,0x3f,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00 },
144 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
145 { 0xff,0xff,0x1e,0x78,0xe0,0xe0,0x78,0x1e,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x01,0x01,0x00,0x00,0x3f,0x3f,0x00 },
146 { 0xff,0xff,0x0e,0x38,0xf0,0xc0,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x03,0x07,0x1c,0x3f,0x3f,0x00 },
147 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
148 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00 },
149 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x36,0x3e,0x1c,0x3f,0x33,0x00 },
150 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x03,0x07,0x0f,0x1d,0x38,0x30,0x00 },
151 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc7,0x8e,0x0c,0x00,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
152 { 0x00,0x03,0x03,0x03,0xff,0xff,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
153 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x07,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
154 { 0x07,0x3f,0xf8,0xc0,0x00,0x00,0xc0,0xf8,0x3f,0x07,0x00,0x00,0x00,0x01,0x0f,0x3e,0x3e,0x0f,0x01,0x00,0x00,0x00 },
155 { 0xff,0xff,0x00,0x00,0x80,0x80,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x1c,0x06,0x03,0x03,0x06,0x1c,0x3f,0x3f,0x00 },
156 { 0x03,0x0f,0x1c,0x30,0xe0,0xe0,0x30,0x1c,0x0f,0x03,0x00,0x30,0x3c,0x0e,0x03,0x01,0x01,0x03,0x0e,0x3c,0x30,0x00 },
157 { 0x03,0x0f,0x3c,0xf0,0xc0,0xc0,0xf0,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
158 { 0x03,0x03,0x03,0x03,0xc3,0xe3,0x33,0x1f,0x0f,0x03,0x00,0x30,0x3c,0x3e,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x00 },
159 { 0x00,0x00,0xff,0xff,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
160 { 0x0e,0x1c,0x38,0x70,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x18 },
161 { 0x00,0x00,0x03,0x03,0x03,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00,0x00,0x00 },
162 { 0x60,0x70,0x38,0x1c,0x0e,0x07,0x0e,0x1c,0x38,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
163 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },
164 { 0x00,0x00,0x00,0x00,0x3e,0x7e,0x4e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
165 { 0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x1c,0x3e,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x3f,0x00 },
166 { 0xff,0xff,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
167 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x18,0x08,0x00 },
168 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0xe0,0xc0,0xff,0xff,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
169 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x3b,0x33,0x33,0x33,0x33,0x33,0x13,0x01,0x00 },
170 { 0xc0,0xc0,0xfc,0xfe,0xc7,0xc3,0xc3,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
171 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x03,0xc7,0xce,0xcc,0xcc,0xcc,0xcc,0xe6,0x7f,0x3f,0x00 },
172 { 0xff,0xff,0xc0,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00 },
173 { 0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
174 { 0x00,0x00,0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x60,0xe0,0xc0,0xc0,0xff,0x7f,0x00,0x00,0x00 },
175 { 0x00,0xff,0xff,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x00,0x00,0x3f,0x3f,0x03,0x07,0x0f,0x1c,0x38,0x30,0x00,0x00 },
176 { 0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
177 { 0xe0,0xc0,0xe0,0xe0,0xc0,0xc0,0xe0,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00 },
178 { 0x00,0xe0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
179 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
180 { 0xe0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0xff,0xff,0x0c,0x18,0x18,0x18,0x18,0x1c,0x0f,0x07,0x00 },
181 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x07,0x0f,0x1c,0x18,0x18,0x18,0x18,0x0c,0xff,0xff,0x00 },
182 { 0x00,0xe0,0xe0,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
183 { 0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x11,0x33,0x33,0x33,0x33,0x33,0x3f,0x1e,0x00,0x00,0x00 },
184 { 0x60,0x60,0xfe,0xfe,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
185 { 0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x18,0x3f,0x3f,0x00 },
186 { 0x60,0xe0,0x80,0x00,0x00,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x01,0x07,0x1e,0x38,0x38,0x1e,0x07,0x01,0x00,0x00 },
187 { 0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x07,0x1f,0x38,0x1c,0x0f,0x0f,0x1c,0x38,0x1f,0x07,0x00 },
188 { 0x60,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x30,0x38,0x1d,0x0f,0x07,0x0f,0x1d,0x38,0x30,0x00,0x00 },
189 { 0x00,0x60,0xe0,0x80,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00,0x00,0x81,0xe7,0x7e,0x1e,0x07,0x01,0x00,0x00,0x00 },
190 { 0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,0x20,0x00,0x00,0x30,0x38,0x3c,0x36,0x33,0x31,0x30,0x30,0x30,0x00,0x00 },
191 { 0x00,0x80,0xc0,0xfc,0x7e,0x07,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x01,0x1f,0x3f,0x70,0x60,0x60,0x60,0x00,0x00 },
192 { 0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
193 { 0x00,0x03,0x03,0x03,0x07,0x7e,0xfc,0xc0,0x80,0x00,0x00,0x00,0x60,0x60,0x60,0x70,0x3f,0x1f,0x01,0x00,0x00,0x00 },
194 { 0x10,0x18,0x0c,0x04,0x0c,0x18,0x10,0x18,0x0c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
195 { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00 }
198 static signed char speed[]={
199 1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1,
202 #if LCD_WIDTH > LCD_HEIGHT /* landscape LCD */
204 #define TABLE_SIZE LCD_HEIGHT
205 #define RADIUS_MINUTE (3*LCD_HEIGHT/8)
206 #define RADIUS_HOUR (LCD_HEIGHT/4)
208 #else /* portrait (or square) LCD */
210 #define TABLE_SIZE LCD_WIDTH
211 #define RADIUS_MINUTE (3*LCD_WIDTH/8)
212 #define RADIUS_HOUR (LCD_WIDTH/4)
214 #endif /* LCD orientation */
216 #define RADIUS_X ((LCD_WIDTH-LETTER_WIDTH)/2)
217 #define RADIUS_Y ((LCD_HEIGHT-LETTER_HEIGHT)/2)
219 #define PHASE_STEP (0xffffffff/TABLE_SIZE)
220 #define PHASE_FRAC (0xffffffff%TABLE_SIZE)
221 #define DIV_X (0x7ffffffe/RADIUS_X+1)
222 #define DIV_Y (0x7ffffffe/RADIUS_Y+1)
224 static int xtable[TABLE_SIZE];
225 static int ytable[TABLE_SIZE];
227 static void init_tables(void)
229 int i;
230 int pfrac;
231 unsigned long phase;
232 long sin;
234 phase = pfrac = 0;
236 for (i = 0; i < TABLE_SIZE; i++) {
237 sin = fsincos(phase, NULL);
238 xtable[i] = RADIUS_X + sin / DIV_X;
239 ytable[i] = RADIUS_Y + sin / DIV_Y;
241 phase += PHASE_STEP;
242 pfrac += PHASE_FRAC;
243 if (pfrac >= TABLE_SIZE) {
244 pfrac -= TABLE_SIZE;
245 phase++;
250 enum {
251 NUM_XSANKE,
252 NUM_YSANKE,
253 NUM_XADD,
254 NUM_YADD,
255 NUM_XDIST,
256 NUM_YDIST,
258 NUM_LAST
261 struct counter {
262 char *what;
263 int num;
266 struct counter values[]={
267 {"xsanke", 1},
268 {"ysanke", 1},
269 {"xadd", 1},
270 {"yadd", 2},
271 {"xdist", -4},
272 {"ydist", -6},
275 #if CONFIG_RTC
277 #define CLOCK_STEP (0xffffffff/60)
278 #define CLOCK_FRAC (0xffffffff%60)
280 #define DIV_MY (0x7ffffffe/RADIUS_MINUTE+1)
281 #define DIV_HY (0x7ffffffe/RADIUS_HOUR+1)
283 #if LCD_WIDTH == 112 && LCD_HEIGHT == 64 /* Archos LCD: non-square pixels */
284 #define DIV_MX (0x7ffffffe/(5*RADIUS_MINUTE/4)+1)
285 #define DIV_HX (0x7ffffffe/(5*RADIUS_HOUR/4)+1)
286 #else /* Square pixels */
287 #define DIV_MX DIV_MY
288 #define DIV_HX DIV_HY
289 #endif
291 static int xminute[60], yminute[60];
292 static int xhour[60], yhour[60];
294 static void init_clock(void)
296 int i;
297 int pfrac;
298 unsigned long phase;
299 long sin, cos;
301 phase = pfrac = 0;
303 for (i = 0; i < 60; i++) {
304 sin = fsincos(phase, &cos);
305 xminute[i] = LCD_WIDTH/2 + sin / DIV_MX;
306 yminute[i] = LCD_HEIGHT/2 - cos / DIV_MY;
307 xhour[i] = LCD_WIDTH/2 + sin / DIV_HX;
308 yhour[i] = LCD_HEIGHT/2 - cos / DIV_HY;
310 phase += CLOCK_STEP;
311 pfrac += CLOCK_FRAC;
312 if (pfrac >= 60) {
313 pfrac -= 60;
314 phase++;
319 static void addclock(void)
321 int i;
322 int hour;
323 int minute;
325 struct tm* current_time = rb->get_time();
326 hour = current_time->tm_hour;
327 minute = current_time->tm_min;
329 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2,
330 xminute[minute], yminute[minute]);
332 hour = (hour % 12) * 5 + minute / 12;
334 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour[hour], yhour[hour]);
336 /* draw a circle */
337 for(i = 1; i < 60; i += 3)
338 rb->lcd_drawline(xminute[i], yminute[i],
339 xminute[(i+1)%60], yminute[(i+1)%60]);
341 #endif /* CONFIG_RTC */
343 #if LCD_DEPTH > 1
344 static const unsigned face_colors[] =
346 #ifdef HAVE_LCD_COLOR
347 LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
348 #else
349 LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
350 #endif
352 #endif
354 static int scrollit(void)
356 int b;
357 unsigned int y=100;
358 unsigned int yy;
359 int x = LCD_WIDTH;
360 int xx;
361 unsigned int i;
362 unsigned int textpos=0;
364 char* rock="Rockbox! Pure pleasure. Pure fun. Oooh. What fun! ;-) ";
365 unsigned int rocklen = rb->strlen(rock);
366 int letter;
368 rb->lcd_clear_display();
369 while(1)
371 b = rb->button_get_w_tmo(HZ/10);
372 switch(b)
374 #ifdef BOUNCE_RC_QUIT
375 case BOUNCE_RC_QUIT :
376 #endif
377 case BOUNCE_QUIT :
378 return 0;
379 case BOUNCE_MODE :
380 return 1;
381 default:
382 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
383 return -1;
385 rb->lcd_clear_display();
386 #if CONFIG_RTC
387 addclock();
388 #endif
390 for(i=0, yy=y, xx=x; xx < LCD_WIDTH; i++) {
391 letter = rock[(i+textpos) % rocklen ];
392 #if LCD_DEPTH > 1
393 rb->lcd_set_foreground(face_colors[letter % 3]);
394 #endif
395 rb->lcd_mono_bitmap(char_gen_12x16[letter-0x20],
396 xx, ytable[yy % TABLE_SIZE],
397 LETTER_WIDTH, LETTER_HEIGHT);
398 yy += YADD;
399 xx += LETTER_WIDTH;
401 #if LCD_DEPTH > 1
402 rb->lcd_set_foreground(LCD_BLACK);
403 #endif
404 rb->lcd_update();
406 x-= XSPEED;
408 if(x < -LETTER_WIDTH) {
409 x += LETTER_WIDTH;
410 y += YADD;
411 textpos++;
414 y+=YSPEED;
418 static int loopit(void)
420 int b;
421 unsigned int y=100;
422 unsigned int x=100;
423 unsigned int yy,xx;
424 unsigned int i;
425 unsigned int ysanke=0;
426 unsigned int xsanke=0;
428 char* rock="ROCKbox";
429 unsigned int rocklen = rb->strlen(rock);
431 int show=0;
432 int timeout=0;
433 char buffer[30];
435 rb->lcd_clear_display();
436 while(1)
438 b = rb->button_get_w_tmo(HZ/10);
439 if ( b == BOUNCE_QUIT )
440 return 0;
442 if ( b == BOUNCE_MODE )
443 return 1;
445 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
446 return -1;
448 if ( b != BUTTON_NONE )
449 timeout=20;
451 y+= speed[ysanke&15] + values[NUM_YADD].num;
452 x+= speed[xsanke&15] + values[NUM_XADD].num;
454 rb->lcd_clear_display();
455 #if CONFIG_RTC
456 addclock();
457 #endif
458 if(timeout) {
459 switch(b) {
460 case BUTTON_LEFT:
461 case BUTTON_LEFT|BUTTON_REPEAT:
462 values[show].num--;
463 break;
464 case BUTTON_RIGHT:
465 case BUTTON_RIGHT|BUTTON_REPEAT:
466 values[show].num++;
467 break;
468 case BOUNCE_UP:
469 case BOUNCE_UP|BUTTON_REPEAT:
470 if(++show == NUM_LAST)
471 show=0;
472 break;
473 case BOUNCE_DOWN:
474 case BOUNCE_DOWN|BUTTON_REPEAT:
475 if(--show < 0)
476 show=NUM_LAST-1;
477 break;
479 rb->snprintf(buffer, 30, "%s: %d",
480 values[show].what, values[show].num);
481 rb->lcd_putsxy(0, LCD_HEIGHT - 8, (unsigned char *)buffer);
482 timeout--;
484 for(i=0, yy=y, xx=x;
485 i<rocklen;
486 i++, yy+=values[NUM_YDIST].num, xx+=values[NUM_XDIST].num)
487 rb->lcd_mono_bitmap(char_gen_12x16[rock[i]-0x20],
488 xtable[xx % TABLE_SIZE],
489 ytable[yy % TABLE_SIZE],
490 LETTER_WIDTH, LETTER_HEIGHT);
491 rb->lcd_update();
493 ysanke+= values[NUM_YSANKE].num;
494 xsanke+= values[NUM_XSANKE].num;
499 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
501 int w, h;
502 char *off = "[Off] to stop";
504 (void)(parameter);
505 rb = api;
507 rb->lcd_setfont(FONT_SYSFIXED);
508 rb->lcd_clear_display();
510 /* Get horizontel centering for text */
511 rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h);
512 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2,
513 (unsigned char *)SS_TITLE);
515 /* Get horizontel centering for text */
516 rb->lcd_getstringsize((unsigned char *)off, &w, &h);
517 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h,
518 (unsigned char *)off);
520 rb->lcd_update();
521 rb->sleep(HZ);
522 rb->lcd_set_drawmode(DRMODE_FG);
523 init_tables();
524 #if CONFIG_RTC
525 init_clock();
526 #endif
528 do {
529 h = loopit();
530 if (h > 0)
531 h = scrollit();
532 } while(h > 0);
534 rb->lcd_set_drawmode(DRMODE_SOLID);
535 rb->lcd_setfont(FONT_UI);
537 return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;