1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 **************************************************************************/
22 #include "lib/playergfx.h"
26 #ifdef HAVE_LCD_BITMAP
27 #define NUM_PARTICLES (LCD_WIDTH * LCD_HEIGHT / 72)
28 #define SNOW_HEIGHT LCD_HEIGHT
29 #define SNOW_WIDTH LCD_WIDTH
30 #define MYLCD(fn) rb->lcd_ ## fn
32 #define NUM_PARTICLES 10
33 #define SNOW_HEIGHT 14
35 #define MYLCD(fn) pgfx_ ## fn
38 /* variable button definitions */
39 #if CONFIG_KEYPAD == PLAYER_PAD
40 #define SNOW_QUIT BUTTON_STOP
41 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
42 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
43 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
44 #define SNOW_QUIT BUTTON_MENU
45 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
46 #define SNOW_QUIT BUTTON_PLAY
47 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
48 #define SNOW_QUIT BUTTON_POWER
49 #elif CONFIG_KEYPAD == GIGABEAT_PAD
50 #define SNOW_QUIT BUTTON_POWER
51 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
52 (CONFIG_KEYPAD == SANSA_C200_PAD)
53 #define SNOW_QUIT BUTTON_POWER
54 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
55 #define SNOW_QUIT BUTTON_POWER
56 #elif CONFIG_KEYPAD == MROBE500_PAD
57 #define SNOW_QUIT BUTTON_POWER
58 #elif CONFIG_KEYPAD == MROBE100_PAD
59 #define SNOW_QUIT BUTTON_POWER
60 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
61 #define SNOW_QUIT BUTTON_BACK
62 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
63 #define SNOW_QUIT BUTTON_REC
64 #define SNOW_RC_QUIT BUTTON_RC_REC
65 #elif CONFIG_KEYPAD == COWOND2_PAD
66 #define SNOW_QUIT BUTTON_POWER
67 #elif CONFIG_KEYPAD == IAUDIO67_PAD
68 #define SNOW_QUIT BUTTON_POWER
70 #define SNOW_QUIT BUTTON_OFF
71 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
72 #define SNOW_RC_QUIT BUTTON_RC_STOP
76 static short particles
[NUM_PARTICLES
][2];
77 static const struct plugin_api
* rb
;
79 #ifdef HAVE_LCD_BITMAP
82 static const unsigned char flake
[] = {0x0a,0x04,0x1f,0x04,0x0a};
85 static const unsigned char flake
[] = {0x02,0x07,0x02};
89 static bool particle_exists(int particle
)
91 if (particles
[particle
][0]>=0 && particles
[particle
][1]>=0 &&
92 particles
[particle
][0]<SNOW_WIDTH
&& particles
[particle
][1]<SNOW_HEIGHT
)
98 static int create_particle(void)
102 for (i
=0; i
<NUM_PARTICLES
; i
++) {
103 if (!particle_exists(i
)) {
104 particles
[i
][0]=(rb
->rand()%SNOW_WIDTH
);
112 static void snow_move(void)
119 for (i
=0; i
<NUM_PARTICLES
; i
++) {
120 if (particle_exists(i
)) {
121 MYLCD(set_drawmode
)(DRMODE_SOLID
|DRMODE_INVERSEVID
);
122 #ifdef HAVE_LCD_BITMAP
123 rb
->lcd_fillrect(particles
[i
][0],particles
[i
][1],
124 FLAKE_WIDTH
,FLAKE_WIDTH
);
126 pgfx_drawpixel(particles
[i
][0],particles
[i
][1]);
128 MYLCD(set_drawmode
)(DRMODE_SOLID
);
129 #ifdef HAVE_REMOTE_LCD
130 if (particles
[i
][0] <= LCD_REMOTE_WIDTH
131 && particles
[i
][1] <= LCD_REMOTE_HEIGHT
) {
132 rb
->lcd_remote_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
133 rb
->lcd_remote_fillrect(particles
[i
][0],particles
[i
][1],
134 FLAKE_WIDTH
,FLAKE_WIDTH
);
135 rb
->lcd_remote_set_drawmode(DRMODE_SOLID
);
138 switch ((rb
->rand()%7)) {
154 if (particle_exists(i
))
155 #ifdef HAVE_LCD_BITMAP
156 rb
->lcd_mono_bitmap(flake
,particles
[i
][0],particles
[i
][1],
157 FLAKE_WIDTH
,FLAKE_WIDTH
);
159 pgfx_drawpixel(particles
[i
][0],particles
[i
][1]);
161 #ifdef HAVE_REMOTE_LCD
162 if (particles
[i
][0] <= LCD_REMOTE_WIDTH
163 && particles
[i
][1] <= LCD_REMOTE_HEIGHT
) {
164 rb
->lcd_remote_mono_bitmap(flake
,particles
[i
][0],particles
[i
][1],
165 FLAKE_WIDTH
,FLAKE_WIDTH
);
173 static void snow_init(void)
177 for (i
=0; i
<NUM_PARTICLES
; i
++) {
181 #ifdef HAVE_LCD_CHARCELLS
182 pgfx_display(0, 0); /* display three times */
186 MYLCD(clear_display
)();
187 #ifdef HAVE_REMOTE_LCD
188 rb
->lcd_remote_clear_display();
192 enum plugin_status
plugin_start(const struct plugin_api
* api
, const void* parameter
)
198 #ifdef HAVE_LCD_CHARCELLS
199 if (!pgfx_init(rb
, 4, 2))
201 rb
->splash(HZ
*2, "Old LCD :(");
205 #ifdef HAVE_LCD_COLOR
206 rb
->lcd_clear_display();
207 rb
->lcd_set_foreground(LCD_WHITE
);
208 rb
->lcd_set_background(LCD_DEFAULT_BG
);
214 #ifdef HAVE_REMOTE_LCD
215 rb
->lcd_remote_update();
219 button
= rb
->button_get(false);
221 if (button
== SNOW_QUIT
223 || button
== SNOW_RC_QUIT
227 #ifdef HAVE_LCD_CHARCELLS
233 if (rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
235 #ifdef HAVE_LCD_CHARCELLS
238 return PLUGIN_USB_CONNECTED
;