Prepare new maemo release
[maemo-rb.git] / apps / plugins / bounce.c
blobece8440e53df3cd77d1297199916a3c7fa036ef5
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"
24 #include "lib/pluginlib_actions.h"
27 #define SS_TITLE "Bouncer"
29 #define YSPEED 2
30 #define XSPEED 3
31 #define YADD -4
33 /* this set the context to use with PLA */
34 static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
36 /* We set button maping with PLA */
37 #define BOUNCE_UP PLA_UP
38 #define BOUNCE_UP_REPEAT PLA_UP_REPEAT
39 #define BOUNCE_DOWN PLA_DOWN
40 #define BOUNCE_DOWN_REPEAT PLA_DOWN_REPEAT
42 #ifdef HAVE_SCROLLWHEEL
43 #define BOUNCE_LEFT PLA_SCROLL_BACK
44 #define BOUNCE_LEFT_REPEAT PLA_SCROLL_BACK_REPEAT
45 #define BOUNCE_RIGHT PLA_SCROLL_FWD
46 #define BOUNCE_RIGHT_REPEAT PLA_SCROLL_FWD_REPEAT
47 #else
48 #define BOUNCE_LEFT PLA_LEFT
49 #define BOUNCE_LEFT_REPEAT PLA_LEFT_REPEAT
50 #define BOUNCE_RIGHT PLA_RIGHT
51 #define BOUNCE_RIGHT_REPEAT PLA_RIGHT_REPEAT
52 #endif
54 #define BOUNCE_QUIT PLA_EXIT
55 #define BOUNCE_QUIT2 PLA_CANCEL
56 #define BOUNCE_MODE PLA_SELECT
58 #define LETTER_WIDTH 11
59 #define LETTER_HEIGHT 16
61 const unsigned char char_gen_12x16[][22] =
63 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
64 { 0x00,0x00,0x00,0x7c,0xff,0xff,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00 },
65 { 0x00,0x00,0x3c,0x3c,0x00,0x00,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
66 { 0x00,0x10,0x90,0xf0,0x7e,0x1e,0x90,0xf0,0x7e,0x1e,0x10,0x02,0x1e,0x1f,0x03,0x02,0x1e,0x1f,0x03,0x02,0x00,0x00 },
67 { 0x00,0x78,0xfc,0xcc,0xff,0xff,0xcc,0xcc,0x88,0x00,0x00,0x00,0x04,0x0c,0x0c,0x3f,0x3f,0x0c,0x0f,0x07,0x00,0x00 },
68 { 0x00,0x38,0x38,0x38,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x38,0x38,0x38,0x00 },
69 { 0x00,0x00,0xb8,0xfc,0xc6,0xe2,0x3e,0x1c,0x00,0x00,0x00,0x00,0x1f,0x3f,0x31,0x21,0x37,0x1e,0x1c,0x36,0x22,0x00 },
70 { 0x00,0x00,0x00,0x27,0x3f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
71 { 0x00,0x00,0xf0,0xfc,0xfe,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x0f,0x1f,0x38,0x20,0x20,0x00,0x00,0x00 },
72 { 0x00,0x00,0x01,0x01,0x07,0xfe,0xfc,0xf0,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x38,0x1f,0x0f,0x03,0x00,0x00,0x00 },
73 { 0x00,0x98,0xb8,0xe0,0xf8,0xf8,0xe0,0xb8,0x98,0x00,0x00,0x00,0x0c,0x0e,0x03,0x0f,0x0f,0x03,0x0e,0x0c,0x00,0x00 },
74 { 0x00,0x80,0x80,0x80,0xf0,0xf0,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x0f,0x0f,0x01,0x01,0x01,0x00,0x00 },
75 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xf8,0x78,0x00,0x00,0x00,0x00,0x00 },
76 { 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00 },
77 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00 },
78 { 0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x18,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00 },
79 { 0xf8,0xfe,0x06,0x03,0x83,0xc3,0x63,0x33,0x1e,0xfe,0xf8,0x07,0x1f,0x1e,0x33,0x31,0x30,0x30,0x30,0x18,0x1f,0x07 },
80 { 0x00,0x00,0x0c,0x0c,0x0e,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x3f,0x3f,0x30,0x30,0x30,0x00 },
81 { 0x1c,0x1e,0x07,0x03,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x30,0x38,0x3c,0x3e,0x37,0x33,0x31,0x30,0x30,0x30,0x30 },
82 { 0x0c,0x0e,0x07,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e,0x3c,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0e },
83 { 0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x07,0xff,0xff,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x3f,0x3f,0x03,0x03 },
84 { 0x3f,0x7f,0x63,0x63,0x63,0x63,0x63,0x63,0xe3,0xc3,0x83,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f },
85 { 0xc0,0xf0,0xf8,0xdc,0xce,0xc7,0xc3,0xc3,0xc3,0x80,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
86 { 0x03,0x03,0x03,0x03,0x03,0x03,0xc3,0xf3,0x3f,0x0f,0x03,0x00,0x00,0x00,0x30,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00 },
87 { 0x00,0xbc,0xfe,0xe7,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
88 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xfc,0x00,0x00,0x30,0x30,0x30,0x38,0x1c,0x0e,0x07,0x03,0x00 },
89 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00 },
90 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xfc,0x7c,0x00,0x00,0x00,0x00,0x00 },
91 { 0x00,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00,0x00 },
92 { 0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00 },
93 { 0x00,0x03,0x07,0x0e,0x1c,0x38,0xf0,0xe0,0xc0,0x00,0x00,0x00,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00 },
94 { 0x1c,0x1e,0x07,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x00,0x00 },
95 { 0xf8,0xfe,0x07,0xf3,0xfb,0x1b,0xfb,0xfb,0x07,0xfe,0xf8,0x0f,0x1f,0x18,0x33,0x37,0x36,0x37,0x37,0x36,0x03,0x01 },
96 { 0x00,0x00,0xe0,0xfc,0x1f,0x1f,0xfc,0xe0,0x00,0x00,0x00,0x38,0x3f,0x07,0x06,0x06,0x06,0x06,0x07,0x3f,0x38,0x00 },
97 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
98 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x03,0x07,0x0e,0x0c,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x38,0x1c,0x0c,0x00 },
99 { 0xff,0xff,0x03,0x03,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
100 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
101 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
102 { 0xf0,0xfc,0x0e,0x07,0x03,0xc3,0xc3,0xc3,0xc7,0xc6,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
103 { 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
104 { 0x00,0x00,0x03,0x03,0xff,0xff,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
105 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x0e,0x1e,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
106 { 0xff,0xff,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x3f,0x3f,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00 },
107 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
108 { 0xff,0xff,0x1e,0x78,0xe0,0xe0,0x78,0x1e,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x01,0x01,0x00,0x00,0x3f,0x3f,0x00 },
109 { 0xff,0xff,0x0e,0x38,0xf0,0xc0,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x03,0x07,0x1c,0x3f,0x3f,0x00 },
110 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
111 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00 },
112 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x36,0x3e,0x1c,0x3f,0x33,0x00 },
113 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x03,0x07,0x0f,0x1d,0x38,0x30,0x00 },
114 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc7,0x8e,0x0c,0x00,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
115 { 0x00,0x03,0x03,0x03,0xff,0xff,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
116 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x07,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
117 { 0x07,0x3f,0xf8,0xc0,0x00,0x00,0xc0,0xf8,0x3f,0x07,0x00,0x00,0x00,0x01,0x0f,0x3e,0x3e,0x0f,0x01,0x00,0x00,0x00 },
118 { 0xff,0xff,0x00,0x00,0x80,0x80,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x1c,0x06,0x03,0x03,0x06,0x1c,0x3f,0x3f,0x00 },
119 { 0x03,0x0f,0x1c,0x30,0xe0,0xe0,0x30,0x1c,0x0f,0x03,0x00,0x30,0x3c,0x0e,0x03,0x01,0x01,0x03,0x0e,0x3c,0x30,0x00 },
120 { 0x03,0x0f,0x3c,0xf0,0xc0,0xc0,0xf0,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
121 { 0x03,0x03,0x03,0x03,0xc3,0xe3,0x33,0x1f,0x0f,0x03,0x00,0x30,0x3c,0x3e,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x00 },
122 { 0x00,0x00,0xff,0xff,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
123 { 0x0e,0x1c,0x38,0x70,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x18 },
124 { 0x00,0x00,0x03,0x03,0x03,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00,0x00,0x00 },
125 { 0x60,0x70,0x38,0x1c,0x0e,0x07,0x0e,0x1c,0x38,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
126 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },
127 { 0x00,0x00,0x00,0x00,0x3e,0x7e,0x4e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
128 { 0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x1c,0x3e,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x3f,0x00 },
129 { 0xff,0xff,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
130 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x18,0x08,0x00 },
131 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0xe0,0xc0,0xff,0xff,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
132 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x3b,0x33,0x33,0x33,0x33,0x33,0x13,0x01,0x00 },
133 { 0xc0,0xc0,0xfc,0xfe,0xc7,0xc3,0xc3,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
134 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x03,0xc7,0xce,0xcc,0xcc,0xcc,0xcc,0xe6,0x7f,0x3f,0x00 },
135 { 0xff,0xff,0xc0,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00 },
136 { 0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
137 { 0x00,0x00,0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x60,0xe0,0xc0,0xc0,0xff,0x7f,0x00,0x00,0x00 },
138 { 0x00,0xff,0xff,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x00,0x00,0x3f,0x3f,0x03,0x07,0x0f,0x1c,0x38,0x30,0x00,0x00 },
139 { 0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
140 { 0xe0,0xc0,0xe0,0xe0,0xc0,0xc0,0xe0,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00 },
141 { 0x00,0xe0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
142 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
143 { 0xe0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0xff,0xff,0x0c,0x18,0x18,0x18,0x18,0x1c,0x0f,0x07,0x00 },
144 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x07,0x0f,0x1c,0x18,0x18,0x18,0x18,0x0c,0xff,0xff,0x00 },
145 { 0x00,0xe0,0xe0,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
146 { 0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x11,0x33,0x33,0x33,0x33,0x33,0x3f,0x1e,0x00,0x00,0x00 },
147 { 0x60,0x60,0xfe,0xfe,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
148 { 0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x18,0x3f,0x3f,0x00 },
149 { 0x60,0xe0,0x80,0x00,0x00,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x01,0x07,0x1e,0x38,0x38,0x1e,0x07,0x01,0x00,0x00 },
150 { 0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x07,0x1f,0x38,0x1c,0x0f,0x0f,0x1c,0x38,0x1f,0x07,0x00 },
151 { 0x60,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x30,0x38,0x1d,0x0f,0x07,0x0f,0x1d,0x38,0x30,0x00,0x00 },
152 { 0x00,0x60,0xe0,0x80,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00,0x00,0x81,0xe7,0x7e,0x1e,0x07,0x01,0x00,0x00,0x00 },
153 { 0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,0x20,0x00,0x00,0x30,0x38,0x3c,0x36,0x33,0x31,0x30,0x30,0x30,0x00,0x00 },
154 { 0x00,0x80,0xc0,0xfc,0x7e,0x07,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x01,0x1f,0x3f,0x70,0x60,0x60,0x60,0x00,0x00 },
155 { 0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
156 { 0x00,0x03,0x03,0x03,0x07,0x7e,0xfc,0xc0,0x80,0x00,0x00,0x00,0x60,0x60,0x60,0x70,0x3f,0x1f,0x01,0x00,0x00,0x00 },
157 { 0x10,0x18,0x0c,0x04,0x0c,0x18,0x10,0x18,0x0c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
158 { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00 }
161 static signed char speed[]={
162 1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1,
165 #if LCD_WIDTH > LCD_HEIGHT /* landscape LCD */
167 #define TABLE_SIZE LCD_HEIGHT
168 #define RADIUS_MINUTE (3*LCD_HEIGHT/8)
169 #define RADIUS_HOUR (LCD_HEIGHT/4)
171 #else /* portrait (or square) LCD */
173 #define TABLE_SIZE LCD_WIDTH
174 #define RADIUS_MINUTE (3*LCD_WIDTH/8)
175 #define RADIUS_HOUR (LCD_WIDTH/4)
177 #endif /* LCD orientation */
179 #define RADIUS_X ((LCD_WIDTH-LETTER_WIDTH)/2)
180 #define RADIUS_Y ((LCD_HEIGHT-LETTER_HEIGHT)/2)
182 #define PHASE_STEP (0xffffffff/TABLE_SIZE)
183 #define PHASE_FRAC (0xffffffff%TABLE_SIZE)
184 #define DIV_X (0x7ffffffe/RADIUS_X+1)
185 #define DIV_Y (0x7ffffffe/RADIUS_Y+1)
187 static int xtable[TABLE_SIZE];
188 static int ytable[TABLE_SIZE];
190 static void init_tables(void)
192 int i;
193 int pfrac;
194 unsigned long phase;
195 long sin;
197 phase = pfrac = 0;
199 for (i = 0; i < TABLE_SIZE; i++) {
200 sin = fp_sincos(phase, NULL);
201 xtable[i] = RADIUS_X + sin / DIV_X;
202 ytable[i] = RADIUS_Y + sin / DIV_Y;
204 phase += PHASE_STEP;
205 pfrac += PHASE_FRAC;
206 if (pfrac >= TABLE_SIZE) {
207 pfrac -= TABLE_SIZE;
208 phase++;
213 enum {
214 NUM_XSANKE,
215 NUM_YSANKE,
216 NUM_XADD,
217 NUM_YADD,
218 NUM_XDIST,
219 NUM_YDIST,
221 NUM_LAST
224 struct counter {
225 char *what;
226 int num;
229 struct counter values[]={
230 {"xsanke", 1},
231 {"ysanke", 1},
232 {"xadd", 1},
233 {"yadd", 2},
234 {"xdist", -4},
235 {"ydist", -6},
238 #if CONFIG_RTC
240 #define CLOCK_STEP (0xffffffff/60)
241 #define CLOCK_FRAC (0xffffffff%60)
243 #define DIV_MY (0x7ffffffe/RADIUS_MINUTE+1)
244 #define DIV_HY (0x7ffffffe/RADIUS_HOUR+1)
246 #if LCD_WIDTH == 112 && LCD_HEIGHT == 64 /* Archos LCD: non-square pixels */
247 #define DIV_MX (0x7ffffffe/(5*RADIUS_MINUTE/4)+1)
248 #define DIV_HX (0x7ffffffe/(5*RADIUS_HOUR/4)+1)
249 #else /* Square pixels */
250 #define DIV_MX DIV_MY
251 #define DIV_HX DIV_HY
252 #endif
254 static int xminute[60], yminute[60];
255 static int xhour[60], yhour[60];
257 static void init_clock(void)
259 int i;
260 int pfrac;
261 unsigned long phase;
262 long sin, cos;
264 phase = pfrac = 0;
266 for (i = 0; i < 60; i++) {
267 sin = fp_sincos(phase, &cos);
268 xminute[i] = LCD_WIDTH/2 + sin / DIV_MX;
269 yminute[i] = LCD_HEIGHT/2 - cos / DIV_MY;
270 xhour[i] = LCD_WIDTH/2 + sin / DIV_HX;
271 yhour[i] = LCD_HEIGHT/2 - cos / DIV_HY;
273 phase += CLOCK_STEP;
274 pfrac += CLOCK_FRAC;
275 if (pfrac >= 60) {
276 pfrac -= 60;
277 phase++;
282 static void addclock(void)
284 int i;
285 int hour;
286 int minute;
288 struct tm* current_time = rb->get_time();
289 hour = current_time->tm_hour;
290 minute = current_time->tm_min;
292 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2,
293 xminute[minute], yminute[minute]);
295 hour = (hour % 12) * 5 + minute / 12;
297 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour[hour], yhour[hour]);
299 /* draw a circle */
300 for(i = 1; i < 60; i += 3)
301 rb->lcd_drawline(xminute[i], yminute[i],
302 xminute[(i+1)%60], yminute[(i+1)%60]);
304 #endif /* CONFIG_RTC */
306 #if LCD_DEPTH > 1
307 static const unsigned face_colors[] =
309 #ifdef HAVE_LCD_COLOR
310 LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
311 #else
312 LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
313 #endif
315 #endif
317 static int scrollit(void)
319 int b;
320 unsigned int y=100;
321 unsigned int yy;
322 int x = LCD_WIDTH;
323 int xx;
324 unsigned int i;
325 unsigned int textpos=0;
327 char* rock="Rockbox! Pure pleasure. Pure fun. Oooh. What fun! ;-) ";
328 unsigned int rocklen = rb->strlen(rock);
329 int letter;
330 #if LCD_DEPTH > 1
331 unsigned prev_color;
332 #endif
334 rb->lcd_clear_display();
335 while(1)
337 b = pluginlib_getaction(HZ/10, plugin_contexts,
338 ARRAYLEN(plugin_contexts));
339 switch(b)
341 case BOUNCE_QUIT :
342 case BOUNCE_QUIT2 :
343 return 0;
344 case BOUNCE_MODE :
345 return 1;
346 default:
347 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
348 return -1;
350 rb->lcd_clear_display();
351 #if CONFIG_RTC
352 addclock();
353 #endif
355 #if LCD_DEPTH > 1
356 prev_color = rb->lcd_get_foreground();
357 #endif
359 for(i=0, yy=y, xx=x; xx < LCD_WIDTH; i++) {
360 letter = rock[(i+textpos) % rocklen ];
361 #if LCD_DEPTH > 1
362 rb->lcd_set_foreground(face_colors[letter % 3]);
363 #endif
364 rb->lcd_mono_bitmap(char_gen_12x16[letter-0x20],
365 xx, ytable[yy % TABLE_SIZE],
366 LETTER_WIDTH, LETTER_HEIGHT);
367 yy += YADD;
368 xx += LETTER_WIDTH;
370 #if LCD_DEPTH > 1
371 rb->lcd_set_foreground(prev_color);
372 #endif
373 rb->lcd_update();
375 x-= XSPEED;
377 if(x < -LETTER_WIDTH) {
378 x += LETTER_WIDTH;
379 y += YADD;
380 textpos++;
383 y+=YSPEED;
387 static int loopit(void)
389 int b;
390 unsigned int y=100;
391 unsigned int x=100;
392 unsigned int yy,xx;
393 unsigned int i;
394 unsigned int ysanke=0;
395 unsigned int xsanke=0;
397 char* rock="ROCKbox";
398 unsigned int rocklen = rb->strlen(rock);
400 int show=0;
401 int timeout=0;
403 rb->lcd_clear_display();
404 while(1)
406 b = pluginlib_getaction(HZ/10, plugin_contexts,
407 ARRAYLEN(plugin_contexts));
408 if (( b == BOUNCE_QUIT ) || ( b == BOUNCE_QUIT2 ))
409 return 0;
411 if ( b == BOUNCE_MODE )
412 return 1;
414 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
415 return -1;
417 if ( b != BUTTON_NONE )
418 timeout=20;
420 y+= speed[ysanke&15] + values[NUM_YADD].num;
421 x+= speed[xsanke&15] + values[NUM_XADD].num;
423 rb->lcd_clear_display();
424 #if CONFIG_RTC
425 addclock();
426 #endif
427 if(timeout) {
428 switch(b) {
429 case BOUNCE_LEFT:
430 case BOUNCE_LEFT_REPEAT:
431 values[show].num--;
432 break;
433 case BOUNCE_RIGHT:
434 case BOUNCE_RIGHT_REPEAT:
435 values[show].num++;
436 break;
437 case BOUNCE_UP:
438 case BOUNCE_UP_REPEAT:
439 if(++show == NUM_LAST)
440 show=0;
441 break;
442 case BOUNCE_DOWN:
443 case BOUNCE_DOWN_REPEAT:
444 if(--show < 0)
445 show=NUM_LAST-1;
446 break;
448 rb->lcd_putsxyf(0, LCD_HEIGHT - 8, "%s: %d",
449 values[show].what, values[show].num);
450 timeout--;
452 for(i=0, yy=y, xx=x;
453 i<rocklen;
454 i++, yy+=values[NUM_YDIST].num, xx+=values[NUM_XDIST].num)
455 rb->lcd_mono_bitmap(char_gen_12x16[rock[i]-0x20],
456 xtable[xx % TABLE_SIZE],
457 ytable[yy % TABLE_SIZE],
458 LETTER_WIDTH, LETTER_HEIGHT);
459 rb->lcd_update();
461 ysanke+= values[NUM_YSANKE].num;
462 xsanke+= values[NUM_XSANKE].num;
467 enum plugin_status plugin_start(const void* parameter)
469 int w, h;
470 char *off = "[Off] to stop";
472 (void)(parameter);
474 rb->lcd_setfont(FONT_SYSFIXED);
475 rb->lcd_clear_display();
477 /* Get horizontel centering for text */
478 rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h);
479 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2,
480 (unsigned char *)SS_TITLE);
482 /* Get horizontel centering for text */
483 rb->lcd_getstringsize((unsigned char *)off, &w, &h);
484 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h,
485 (unsigned char *)off);
487 rb->lcd_update();
488 rb->sleep(HZ);
489 rb->lcd_set_drawmode(DRMODE_FG);
490 init_tables();
491 #if CONFIG_RTC
492 init_clock();
493 #endif
495 do {
496 h = loopit();
497 if (h > 0)
498 h = scrollit();
499 } while(h > 0);
501 rb->lcd_set_drawmode(DRMODE_SOLID);
502 rb->lcd_setfont(FONT_UI);
504 return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;