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"
23 #include "lib/mylcd.h"
24 #include "lib/pluginlib_actions.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
31 #define NUM_PARTICLES 10
32 #define SNOW_HEIGHT 14
36 static const struct button_mapping
*plugin_contexts
[] = { pla_main_ctx
};
39 #define SNOW_QUIT PLA_EXIT
40 #define SNOW_QUIT2 PLA_CANCEL
42 static short particles
[NUM_PARTICLES
][2];
44 #ifdef HAVE_LCD_BITMAP
47 static const unsigned char flake
[] = {0x0a,0x04,0x1f,0x04,0x0a};
50 static const unsigned char flake
[] = {0x02,0x07,0x02};
54 static bool particle_exists(int particle
)
56 if (particles
[particle
][0]>=0 && particles
[particle
][1]>=0 &&
57 particles
[particle
][0]<SNOW_WIDTH
&& particles
[particle
][1]<SNOW_HEIGHT
)
63 static int create_particle(void)
67 for (i
=0; i
<NUM_PARTICLES
; i
++) {
68 if (!particle_exists(i
)) {
69 particles
[i
][0]=(rb
->rand()%SNOW_WIDTH
);
77 static void snow_move(void)
84 for (i
=0; i
<NUM_PARTICLES
; i
++) {
85 if (particle_exists(i
)) {
86 mylcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
87 #ifdef HAVE_LCD_BITMAP
88 rb
->lcd_fillrect(particles
[i
][0],particles
[i
][1],
89 FLAKE_WIDTH
,FLAKE_WIDTH
);
91 pgfx_drawpixel(particles
[i
][0],particles
[i
][1]);
93 mylcd_set_drawmode(DRMODE_SOLID
);
94 #ifdef HAVE_REMOTE_LCD
95 if (particles
[i
][0] <= LCD_REMOTE_WIDTH
96 && particles
[i
][1] <= LCD_REMOTE_HEIGHT
) {
97 rb
->lcd_remote_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
98 rb
->lcd_remote_fillrect(particles
[i
][0],particles
[i
][1],
99 FLAKE_WIDTH
,FLAKE_WIDTH
);
100 rb
->lcd_remote_set_drawmode(DRMODE_SOLID
);
103 switch ((rb
->rand()%7)) {
119 if (particle_exists(i
))
120 #ifdef HAVE_LCD_BITMAP
121 rb
->lcd_mono_bitmap(flake
,particles
[i
][0],particles
[i
][1],
122 FLAKE_WIDTH
,FLAKE_WIDTH
);
124 pgfx_drawpixel(particles
[i
][0],particles
[i
][1]);
126 #ifdef HAVE_REMOTE_LCD
127 if (particles
[i
][0] <= LCD_REMOTE_WIDTH
128 && particles
[i
][1] <= LCD_REMOTE_HEIGHT
) {
129 rb
->lcd_remote_mono_bitmap(flake
,particles
[i
][0],particles
[i
][1],
130 FLAKE_WIDTH
,FLAKE_WIDTH
);
138 static void snow_init(void)
142 for (i
=0; i
<NUM_PARTICLES
; i
++) {
146 #ifdef HAVE_LCD_CHARCELLS
147 pgfx_display(0, 0); /* display three times */
151 mylcd_clear_display();
152 #ifdef HAVE_REMOTE_LCD
153 rb
->lcd_remote_clear_display();
157 enum plugin_status
plugin_start(const void* parameter
)
162 #ifdef HAVE_LCD_CHARCELLS
163 if (!pgfx_init(4, 2))
165 rb
->splash(HZ
*2, "Old LCD :(");
169 #ifdef HAVE_LCD_COLOR
170 rb
->lcd_clear_display();
171 rb
->lcd_set_foreground(LCD_WHITE
);
172 rb
->lcd_set_background(LCD_DEFAULT_BG
);
178 #ifdef HAVE_REMOTE_LCD
179 rb
->lcd_remote_update();
183 /*We get button from PLA this way */
184 button
= pluginlib_getaction(TIMEOUT_NOBLOCK
, plugin_contexts
,
185 ARRAYLEN(plugin_contexts
));
187 if ((button
== SNOW_QUIT
) || (button
== SNOW_QUIT2
))
189 #ifdef HAVE_LCD_CHARCELLS
195 if (rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
197 #ifdef HAVE_LCD_CHARCELLS
200 return PLUGIN_USB_CONNECTED
;