Fix some quotation marks. Thanks to Alexander Levin for pointing it out.
[Rockbox.git] / apps / plugins / mosaique.c
blob8163685366d2786863b006542a783e30df41f448
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Itai Shaked
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 "playergfx.h"
22 PLUGIN_HEADER
24 #ifdef HAVE_LCD_BITMAP
25 #define MYLCD(fn) rb->lcd_ ## fn
26 #define GFX_X (LCD_WIDTH/2-1)
27 #define GFX_Y (LCD_HEIGHT/2-1)
28 #if LCD_WIDTH != LCD_HEIGHT
29 #define GFX_WIDTH GFX_X
30 #define GFX_HEIGHT GFX_Y
31 #else
32 #define GFX_WIDTH GFX_X
33 #define GFX_HEIGHT (4*GFX_Y/5)
34 #endif
35 #else
36 #define MYLCD(fn) pgfx_ ## fn
37 #define GFX_X 9
38 #define GFX_Y 6
39 #define GFX_WIDTH 9
40 #define GFX_HEIGHT 6
41 #endif
43 /* variable button definitions */
44 #if CONFIG_KEYPAD == RECORDER_PAD
45 #define MOSAIQUE_QUIT BUTTON_OFF
46 #define MOSAIQUE_SPEED BUTTON_F1
47 #define MOSAIQUE_RESTART BUTTON_PLAY
49 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
50 #define MOSAIQUE_QUIT BUTTON_OFF
51 #define MOSAIQUE_SPEED BUTTON_F1
52 #define MOSAIQUE_RESTART BUTTON_SELECT
54 #elif CONFIG_KEYPAD == PLAYER_PAD
55 #define MOSAIQUE_QUIT BUTTON_STOP
56 #define MOSAIQUE_SPEED BUTTON_MENU
57 #define MOSAIQUE_RESTART BUTTON_PLAY
59 #elif CONFIG_KEYPAD == ONDIO_PAD
60 #define MOSAIQUE_QUIT BUTTON_OFF
61 #define MOSAIQUE_SPEED BUTTON_MENU
62 #define MOSAIQUE_RESTART BUTTON_RIGHT
64 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
65 (CONFIG_KEYPAD == IRIVER_H300_PAD)
66 #define MOSAIQUE_QUIT BUTTON_OFF
67 #define MOSAIQUE_SPEED BUTTON_MODE
68 #define MOSAIQUE_RESTART BUTTON_ON
70 #define MOSAIQUE_RC_QUIT BUTTON_RC_STOP
72 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
73 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
74 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
75 #define MOSAIQUE_QUIT BUTTON_MENU
76 #define MOSAIQUE_SPEED BUTTON_SELECT
77 #define MOSAIQUE_RESTART BUTTON_PLAY
79 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
80 #define MOSAIQUE_QUIT BUTTON_PLAY
81 #define MOSAIQUE_SPEED BUTTON_MODE
82 #define MOSAIQUE_RESTART BUTTON_SELECT
84 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
85 #define MOSAIQUE_QUIT BUTTON_POWER
86 #define MOSAIQUE_SPEED BUTTON_SELECT
87 #define MOSAIQUE_RESTART BUTTON_PLAY
89 #elif CONFIG_KEYPAD == GIGABEAT_PAD
90 #define MOSAIQUE_QUIT BUTTON_POWER
91 #define MOSAIQUE_SPEED BUTTON_A
92 #define MOSAIQUE_RESTART BUTTON_SELECT
94 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
95 (CONFIG_KEYPAD == SANSA_C200_PAD)
96 #define MOSAIQUE_QUIT BUTTON_POWER
97 #define MOSAIQUE_SPEED BUTTON_DOWN
98 #define MOSAIQUE_RESTART BUTTON_SELECT
100 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
101 #define MOSAIQUE_QUIT BUTTON_POWER
102 #define MOSAIQUE_SPEED BUTTON_FF
103 #define MOSAIQUE_RESTART BUTTON_PLAY
105 #elif CONFIG_KEYPAD == MROBE500_PAD
106 #define MOSAIQUE_QUIT BUTTON_POWER
107 #define MOSAIQUE_SPEED BUTTON_RC_FF
108 #define MOSAIQUE_RESTART BUTTON_RC_PLAY
110 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
111 #define MOSAIQUE_QUIT BUTTON_BACK
112 #define MOSAIQUE_SPEED BUTTON_SELECT
113 #define MOSAIQUE_RESTART BUTTON_MENU
115 #elif CONFIG_KEYPAD == MROBE100_PAD
116 #define MOSAIQUE_QUIT BUTTON_POWER
117 #define MOSAIQUE_SPEED BUTTON_DISPLAY
118 #define MOSAIQUE_RESTART BUTTON_SELECT
120 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
121 #define MOSAIQUE_QUIT BUTTON_RC_REC
122 #define MOSAIQUE_SPEED BUTTON_RC_MENU
123 #define MOSAIQUE_RESTART BUTTON_RC_PLAY
125 #elif CONFIG_KEYPAD == COWOND2_PAD
126 #define MOSAIQUE_QUIT BUTTON_POWER
127 #define MOSAIQUE_SPEED BUTTON_RIGHT
128 #define MOSAIQUE_RESTART BUTTON_MENU
130 #else
131 #error No keymap defined!
132 #endif
134 enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
136 int button;
137 int timer = 10;
138 int x=0;
139 int y=0;
140 int sx = 3;
141 int sy = 3;
142 struct plugin_api* rb = api;
143 (void)parameter;
145 #ifdef HAVE_LCD_CHARCELLS
146 if (!pgfx_init(rb, 4, 2))
148 rb->splash(HZ*2, "Old LCD :(");
149 return PLUGIN_OK;
151 pgfx_display(3, 0);
152 #endif
153 MYLCD(clear_display)();
154 MYLCD(set_drawmode)(DRMODE_COMPLEMENT);
155 while (1) {
157 x+=sx;
158 if (x>GFX_WIDTH)
160 x = 2*GFX_WIDTH-x;
161 sx=-sx;
164 if (x<0)
166 x = -x;
167 sx = -sx;
170 y+=sy;
171 if (y>GFX_HEIGHT)
173 y = 2*GFX_HEIGHT-y;
174 sy=-sy;
177 if (y<0)
179 y = -y;
180 sy = -sy;
183 MYLCD(fillrect)(GFX_X-x, GFX_Y-y, 2*x+1, 1);
184 MYLCD(fillrect)(GFX_X-x, GFX_Y+y, 2*x+1, 1);
185 MYLCD(fillrect)(GFX_X-x, GFX_Y-y+1, 1, 2*y-1);
186 MYLCD(fillrect)(GFX_X+x, GFX_Y-y+1, 1, 2*y-1);
187 MYLCD(update)();
189 rb->sleep(HZ/timer);
191 button = rb->button_get(false);
192 switch (button)
194 #ifdef MOSAIQUE_RC_QUIT
195 case MOSAIQUE_RC_QUIT:
196 #endif
197 case MOSAIQUE_QUIT:
198 MYLCD(set_drawmode)(DRMODE_SOLID);
199 #ifdef HAVE_LCD_CHARCELLS
200 pgfx_release();
201 #endif
202 return PLUGIN_OK;
204 case MOSAIQUE_SPEED:
205 timer = timer+5;
206 if (timer>20)
207 timer=5;
208 break;
210 case MOSAIQUE_RESTART:
212 sx = rb->rand() % (GFX_HEIGHT/2) + 1;
213 sy = rb->rand() % (GFX_HEIGHT/2) + 1;
214 x=0;
215 y=0;
216 MYLCD(clear_display)();
217 break;
220 default:
221 if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
223 MYLCD(set_drawmode)(DRMODE_SOLID);
224 #ifdef HAVE_LCD_CHARCELLS
225 pgfx_release();
226 #endif
227 return PLUGIN_USB_CONNECTED;
229 break;