1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 **************************************************************************/
20 #include "playergfx.h"
22 #ifdef HAVE_LCD_BITMAP
23 #define NUM_PARTICLES (LCD_WIDTH * LCD_HEIGHT / 72)
24 #define SNOW_HEIGHT LCD_HEIGHT
25 #define SNOW_WIDTH LCD_WIDTH
26 #define MYLCD(fn) rb->lcd_ ## fn
28 #define NUM_PARTICLES 10
29 #define SNOW_HEIGHT 14
31 #define MYLCD(fn) pgfx_ ## fn
34 /* variable button definitions */
35 #if CONFIG_KEYPAD == PLAYER_PAD
36 #define SNOW_QUIT BUTTON_STOP
37 #elif (CONFIG_KEYPAD == IPOD_4G_PAD)
38 #define SNOW_QUIT BUTTON_MENU
39 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
40 #define SNOW_QUIT BUTTON_PLAY
42 #define SNOW_QUIT BUTTON_OFF
45 static short particles
[NUM_PARTICLES
][2];
46 static struct plugin_api
* rb
;
48 #ifdef HAVE_LCD_BITMAP
51 static const unsigned char flake
[] = {0x0a,0x04,0x1f,0x04,0x0a};
54 static const unsigned char flake
[] = {0x02,0x07,0x02};
58 static bool particle_exists(int particle
)
60 if (particles
[particle
][0]>=0 && particles
[particle
][1]>=0 &&
61 particles
[particle
][0]<SNOW_WIDTH
&& particles
[particle
][1]<SNOW_HEIGHT
)
67 static int create_particle(void)
71 for (i
=0; i
<NUM_PARTICLES
; i
++) {
72 if (!particle_exists(i
)) {
73 particles
[i
][0]=(rb
->rand()%SNOW_WIDTH
);
81 static void snow_move(void)
88 for (i
=0; i
<NUM_PARTICLES
; i
++) {
89 if (particle_exists(i
)) {
90 MYLCD(set_drawmode
)(DRMODE_SOLID
|DRMODE_INVERSEVID
);
91 #ifdef HAVE_LCD_BITMAP
92 rb
->lcd_fillrect(particles
[i
][0],particles
[i
][1],
93 FLAKE_WIDTH
,FLAKE_WIDTH
);
95 pgfx_drawpixel(particles
[i
][0],particles
[i
][1]);
97 MYLCD(set_drawmode
)(DRMODE_SOLID
);
98 #ifdef HAVE_REMOTE_LCD
99 if (particles
[i
][0] <= LCD_REMOTE_WIDTH
100 && particles
[i
][1] <= LCD_REMOTE_HEIGHT
) {
101 rb
->lcd_remote_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
102 rb
->lcd_remote_fillrect(particles
[i
][0],particles
[i
][1],
103 FLAKE_WIDTH
,FLAKE_WIDTH
);
104 rb
->lcd_remote_set_drawmode(DRMODE_SOLID
);
107 switch ((rb
->rand()%7)) {
123 if (particle_exists(i
))
124 #ifdef HAVE_LCD_BITMAP
125 rb
->lcd_mono_bitmap(flake
,particles
[i
][0],particles
[i
][1],
126 FLAKE_WIDTH
,FLAKE_WIDTH
);
128 pgfx_drawpixel(particles
[i
][0],particles
[i
][1]);
130 #ifdef HAVE_REMOTE_LCD
131 if (particles
[i
][0] <= LCD_REMOTE_WIDTH
132 && particles
[i
][1] <= LCD_REMOTE_HEIGHT
) {
133 rb
->lcd_remote_bitmap(flake
,particles
[i
][0],particles
[i
][1],
134 FLAKE_WIDTH
,FLAKE_WIDTH
);
142 static void snow_init(void)
146 for (i
=0; i
<NUM_PARTICLES
; i
++) {
150 #ifdef HAVE_LCD_CHARCELLS
151 pgfx_display(0, 0); /* display three times */
155 MYLCD(clear_display
)();
156 #ifdef HAVE_REMOTE_LCD
157 rb
->lcd_remote_clear_display();
161 enum plugin_status
plugin_start(struct plugin_api
* api
, void* parameter
)
164 TEST_PLUGIN_API(api
);
168 #ifdef HAVE_LCD_CHARCELLS
169 if (!pgfx_init(rb
, 4, 2))
171 rb
->splash(HZ
*2, true, "Old LCD :(");
179 #ifdef HAVE_REMOTE_LCD
180 rb
->lcd_remote_update();
184 button
= rb
->button_get(false);
186 if (button
== SNOW_QUIT
)
188 #ifdef HAVE_LCD_CHARCELLS
194 if (rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
196 #ifdef HAVE_LCD_CHARCELLS
199 return PLUGIN_USB_CONNECTED
;