MPEGPlayer: Add a second layer of caching to help speed up byte-wise scanning and...
[kugel-rb.git] / apps / plugins / mosaique.c
blob6506c8556097a556ea6a9c5b42f98b81b03de655
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Itai Shaked
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 "lib/playergfx.h"
24 PLUGIN_HEADER
26 #ifdef HAVE_LCD_BITMAP
27 #define MYLCD(fn) rb->lcd_ ## fn
28 #define GFX_X (LCD_WIDTH/2-1)
29 #define GFX_Y (LCD_HEIGHT/2-1)
30 #if LCD_WIDTH != LCD_HEIGHT
31 #define GFX_WIDTH GFX_X
32 #define GFX_HEIGHT GFX_Y
33 #else
34 #define GFX_WIDTH GFX_X
35 #define GFX_HEIGHT (4*GFX_Y/5)
36 #endif
37 #else
38 #define MYLCD(fn) pgfx_ ## fn
39 #define GFX_X 9
40 #define GFX_Y 6
41 #define GFX_WIDTH 9
42 #define GFX_HEIGHT 6
43 #endif
45 /* variable button definitions */
46 #if CONFIG_KEYPAD == RECORDER_PAD
47 #define MOSAIQUE_QUIT BUTTON_OFF
48 #define MOSAIQUE_SPEED BUTTON_F1
49 #define MOSAIQUE_RESTART BUTTON_PLAY
51 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
52 #define MOSAIQUE_QUIT BUTTON_OFF
53 #define MOSAIQUE_SPEED BUTTON_F1
54 #define MOSAIQUE_RESTART BUTTON_SELECT
56 #elif CONFIG_KEYPAD == PLAYER_PAD
57 #define MOSAIQUE_QUIT BUTTON_STOP
58 #define MOSAIQUE_SPEED BUTTON_MENU
59 #define MOSAIQUE_RESTART BUTTON_PLAY
61 #elif CONFIG_KEYPAD == ONDIO_PAD
62 #define MOSAIQUE_QUIT BUTTON_OFF
63 #define MOSAIQUE_SPEED BUTTON_MENU
64 #define MOSAIQUE_RESTART BUTTON_RIGHT
66 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
67 (CONFIG_KEYPAD == IRIVER_H300_PAD)
68 #define MOSAIQUE_QUIT BUTTON_OFF
69 #define MOSAIQUE_SPEED BUTTON_MODE
70 #define MOSAIQUE_RESTART BUTTON_ON
72 #define MOSAIQUE_RC_QUIT BUTTON_RC_STOP
74 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
75 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
76 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
77 #define MOSAIQUE_QUIT BUTTON_MENU
78 #define MOSAIQUE_SPEED BUTTON_SELECT
79 #define MOSAIQUE_RESTART BUTTON_PLAY
81 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
82 #define MOSAIQUE_QUIT BUTTON_PLAY
83 #define MOSAIQUE_SPEED BUTTON_MODE
84 #define MOSAIQUE_RESTART BUTTON_SELECT
86 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
87 #define MOSAIQUE_QUIT BUTTON_POWER
88 #define MOSAIQUE_SPEED BUTTON_SELECT
89 #define MOSAIQUE_RESTART BUTTON_PLAY
91 #elif CONFIG_KEYPAD == GIGABEAT_PAD
92 #define MOSAIQUE_QUIT BUTTON_POWER
93 #define MOSAIQUE_SPEED BUTTON_A
94 #define MOSAIQUE_RESTART BUTTON_SELECT
96 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
97 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
98 (CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
99 (CONFIG_KEYPAD == SANSA_M200_PAD)
100 #define MOSAIQUE_QUIT BUTTON_POWER
101 #define MOSAIQUE_SPEED BUTTON_DOWN
102 #define MOSAIQUE_RESTART BUTTON_SELECT
104 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
105 #define MOSAIQUE_QUIT (BUTTON_HOME|BUTTON_REPEAT)
106 #define MOSAIQUE_SPEED BUTTON_DOWN
107 #define MOSAIQUE_RESTART BUTTON_SELECT
109 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
110 #define MOSAIQUE_QUIT BUTTON_POWER
111 #define MOSAIQUE_SPEED BUTTON_FF
112 #define MOSAIQUE_RESTART BUTTON_PLAY
114 #elif CONFIG_KEYPAD == MROBE500_PAD
115 #define MOSAIQUE_QUIT BUTTON_POWER
117 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
118 #define MOSAIQUE_QUIT BUTTON_BACK
119 #define MOSAIQUE_SPEED BUTTON_SELECT
120 #define MOSAIQUE_RESTART BUTTON_MENU
122 #elif CONFIG_KEYPAD == MROBE100_PAD
123 #define MOSAIQUE_QUIT BUTTON_POWER
124 #define MOSAIQUE_SPEED BUTTON_DISPLAY
125 #define MOSAIQUE_RESTART BUTTON_SELECT
127 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
128 #define MOSAIQUE_QUIT BUTTON_RC_REC
129 #define MOSAIQUE_SPEED BUTTON_RC_MENU
130 #define MOSAIQUE_RESTART BUTTON_RC_PLAY
132 #elif CONFIG_KEYPAD == COWON_D2_PAD
133 #define MOSAIQUE_QUIT BUTTON_POWER
134 #define MOSAIQUE_SPEED BUTTON_MINUS
135 #define MOSAIQUE_RESTART BUTTON_MENU
137 #elif CONFIG_KEYPAD == IAUDIO67_PAD
138 #define MOSAIQUE_QUIT BUTTON_POWER
139 #define MOSAIQUE_SPEED BUTTON_PLAY
140 #define MOSAIQUE_RESTART BUTTON_MENU
142 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
143 #define MOSAIQUE_QUIT BUTTON_BACK
144 #define MOSAIQUE_SPEED BUTTON_SELECT
145 #define MOSAIQUE_RESTART BUTTON_PLAY
147 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
148 #define MOSAIQUE_QUIT BUTTON_POWER
149 #define MOSAIQUE_SPEED BUTTON_VIEW
150 #define MOSAIQUE_RESTART BUTTON_MENU
152 #elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
153 #define MOSAIQUE_QUIT BUTTON_POWER
154 #define MOSAIQUE_SPEED BUTTON_RIGHT
155 #define MOSAIQUE_RESTART BUTTON_MENU
157 #elif CONFIG_KEYPAD == ONDAVX747_PAD
158 #define MOSAIQUE_QUIT BUTTON_POWER
159 #elif CONFIG_KEYPAD == ONDAVX777_PAD
160 #define MOSAIQUE_QUIT BUTTON_POWER
162 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
163 #define MOSAIQUE_QUIT BUTTON_PLAY
164 #define MOSAIQUE_SPEED BUTTON_UP
165 #define MOSAIQUE_RESTART BUTTON_DOWN
167 #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
168 #define MOSAIQUE_QUIT BUTTON_REC
169 #define MOSAIQUE_SPEED BUTTON_PLAY
170 #define MOSAIQUE_RESTART BUTTON_MENU
172 #elif CONFIG_KEYPAD == MPIO_HD200_PAD
173 #define MOSAIQUE_QUIT (BUTTON_REC | BUTTON_PLAY)
174 #define MOSAIQUE_SPEED BUTTON_SELECT
175 #define MOSAIQUE_RESTART BUTTON_PLAY
177 #else
178 #error No keymap defined!
179 #endif
181 #ifdef HAVE_TOUCHSCREEN
182 #ifndef MOSAIQUE_QUIT
183 #define MOSAIQUE_QUIT BUTTON_TOPLEFT
184 #endif
185 #ifndef MOSAIQUE_SPEED
186 #define MOSAIQUE_SPEED BUTTON_MIDRIGHT
187 #endif
188 #ifndef MOSAIQUE_RESTART
189 #define MOSAIQUE_RESTART BUTTON_CENTER
190 #endif
191 #endif
193 enum plugin_status plugin_start(const void* parameter)
195 int button;
196 int timer = 10;
197 int x=0;
198 int y=0;
199 int sx = 3;
200 int sy = 3;
201 (void)parameter;
203 #ifdef HAVE_LCD_CHARCELLS
204 if (!pgfx_init(4, 2))
206 rb->splash(HZ*2, "Old LCD :(");
207 return PLUGIN_OK;
209 pgfx_display(3, 0);
210 #endif
211 MYLCD(clear_display)();
212 MYLCD(set_drawmode)(DRMODE_COMPLEMENT);
213 while (1) {
215 x+=sx;
216 if (x>GFX_WIDTH)
218 x = 2*GFX_WIDTH-x;
219 sx=-sx;
222 if (x<0)
224 x = -x;
225 sx = -sx;
228 y+=sy;
229 if (y>GFX_HEIGHT)
231 y = 2*GFX_HEIGHT-y;
232 sy=-sy;
235 if (y<0)
237 y = -y;
238 sy = -sy;
241 MYLCD(fillrect)(GFX_X-x, GFX_Y-y, 2*x+1, 1);
242 MYLCD(fillrect)(GFX_X-x, GFX_Y+y, 2*x+1, 1);
243 MYLCD(fillrect)(GFX_X-x, GFX_Y-y+1, 1, 2*y-1);
244 MYLCD(fillrect)(GFX_X+x, GFX_Y-y+1, 1, 2*y-1);
245 MYLCD(update)();
247 rb->sleep(HZ/timer);
249 button = rb->button_get(false);
250 switch (button)
252 #ifdef MOSAIQUE_RC_QUIT
253 case MOSAIQUE_RC_QUIT:
254 #endif
255 case MOSAIQUE_QUIT:
256 MYLCD(set_drawmode)(DRMODE_SOLID);
257 #ifdef HAVE_LCD_CHARCELLS
258 pgfx_release();
259 #endif
260 return PLUGIN_OK;
262 case MOSAIQUE_SPEED:
263 timer = timer+5;
264 if (timer>20)
265 timer=5;
266 break;
268 case MOSAIQUE_RESTART:
270 sx = rb->rand() % (GFX_HEIGHT/2) + 1;
271 sy = rb->rand() % (GFX_HEIGHT/2) + 1;
272 x=0;
273 y=0;
274 MYLCD(clear_display)();
275 break;
278 default:
279 if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
281 MYLCD(set_drawmode)(DRMODE_SOLID);
282 #ifdef HAVE_LCD_CHARCELLS
283 pgfx_release();
284 #endif
285 return PLUGIN_USB_CONNECTED;
287 break;