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 "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
68 #define SNOW_QUIT BUTTON_OFF
69 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
70 #define SNOW_RC_QUIT BUTTON_RC_STOP
74 static short particles
[NUM_PARTICLES
][2];
75 static const struct plugin_api
* rb
;
77 #ifdef HAVE_LCD_BITMAP
80 static const unsigned char flake
[] = {0x0a,0x04,0x1f,0x04,0x0a};
83 static const unsigned char flake
[] = {0x02,0x07,0x02};
87 static bool particle_exists(int particle
)
89 if (particles
[particle
][0]>=0 && particles
[particle
][1]>=0 &&
90 particles
[particle
][0]<SNOW_WIDTH
&& particles
[particle
][1]<SNOW_HEIGHT
)
96 static int create_particle(void)
100 for (i
=0; i
<NUM_PARTICLES
; i
++) {
101 if (!particle_exists(i
)) {
102 particles
[i
][0]=(rb
->rand()%SNOW_WIDTH
);
110 static void snow_move(void)
117 for (i
=0; i
<NUM_PARTICLES
; i
++) {
118 if (particle_exists(i
)) {
119 MYLCD(set_drawmode
)(DRMODE_SOLID
|DRMODE_INVERSEVID
);
120 #ifdef HAVE_LCD_BITMAP
121 rb
->lcd_fillrect(particles
[i
][0],particles
[i
][1],
122 FLAKE_WIDTH
,FLAKE_WIDTH
);
124 pgfx_drawpixel(particles
[i
][0],particles
[i
][1]);
126 MYLCD(set_drawmode
)(DRMODE_SOLID
);
127 #ifdef HAVE_REMOTE_LCD
128 if (particles
[i
][0] <= LCD_REMOTE_WIDTH
129 && particles
[i
][1] <= LCD_REMOTE_HEIGHT
) {
130 rb
->lcd_remote_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
131 rb
->lcd_remote_fillrect(particles
[i
][0],particles
[i
][1],
132 FLAKE_WIDTH
,FLAKE_WIDTH
);
133 rb
->lcd_remote_set_drawmode(DRMODE_SOLID
);
136 switch ((rb
->rand()%7)) {
152 if (particle_exists(i
))
153 #ifdef HAVE_LCD_BITMAP
154 rb
->lcd_mono_bitmap(flake
,particles
[i
][0],particles
[i
][1],
155 FLAKE_WIDTH
,FLAKE_WIDTH
);
157 pgfx_drawpixel(particles
[i
][0],particles
[i
][1]);
159 #ifdef HAVE_REMOTE_LCD
160 if (particles
[i
][0] <= LCD_REMOTE_WIDTH
161 && particles
[i
][1] <= LCD_REMOTE_HEIGHT
) {
162 rb
->lcd_remote_mono_bitmap(flake
,particles
[i
][0],particles
[i
][1],
163 FLAKE_WIDTH
,FLAKE_WIDTH
);
171 static void snow_init(void)
175 for (i
=0; i
<NUM_PARTICLES
; i
++) {
179 #ifdef HAVE_LCD_CHARCELLS
180 pgfx_display(0, 0); /* display three times */
184 MYLCD(clear_display
)();
185 #ifdef HAVE_REMOTE_LCD
186 rb
->lcd_remote_clear_display();
190 enum plugin_status
plugin_start(const struct plugin_api
* api
, const void* parameter
)
196 #ifdef HAVE_LCD_CHARCELLS
197 if (!pgfx_init(rb
, 4, 2))
199 rb
->splash(HZ
*2, "Old LCD :(");
203 #ifdef HAVE_LCD_COLOR
204 rb
->lcd_clear_display();
205 rb
->lcd_set_foreground(LCD_WHITE
);
206 rb
->lcd_set_background(LCD_DEFAULT_BG
);
212 #ifdef HAVE_REMOTE_LCD
213 rb
->lcd_remote_update();
217 button
= rb
->button_get(false);
219 if (button
== SNOW_QUIT
221 || button
== SNOW_RC_QUIT
225 #ifdef HAVE_LCD_CHARCELLS
231 if (rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
233 #ifdef HAVE_LCD_CHARCELLS
236 return PLUGIN_USB_CONNECTED
;