diff options
author | Björn Stenberg <bjorn@haxx.se> | 2003-06-29 16:33:04 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2003-06-29 16:33:04 +0000 |
commit | ba371fb595affd68c823926b85718d1d613dc7d3 (patch) | |
tree | cfda303d0603d623cdb12f3928905d3ae02f1d87 /apps/plugins/snow.c | |
parent | 9bcbe3fd723d23a709873a0855f27b86bc5c96f1 (diff) | |
download | rockbox-ba371fb595affd68c823926b85718d1d613dc7d3.tar.gz rockbox-ba371fb595affd68c823926b85718d1d613dc7d3.zip |
Added plugin loader. Moved games, demos and the text viewer to loadable plugins. Copy your *.rock files to /.rockbox/rocks/
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3769 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/snow.c')
-rw-r--r-- | apps/plugins/snow.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/apps/plugins/snow.c b/apps/plugins/snow.c new file mode 100644 index 0000000000..df9966eb38 --- /dev/null +++ b/apps/plugins/snow.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Itai Shaked | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | **************************************************************************/ | ||
19 | #include "plugin.h" | ||
20 | |||
21 | #ifdef HAVE_LCD_BITMAP | ||
22 | |||
23 | #define NUM_PARTICLES 100 | ||
24 | |||
25 | static short particles[NUM_PARTICLES][2]; | ||
26 | static struct plugin_api* rb; | ||
27 | |||
28 | static bool particle_exists(int particle) | ||
29 | { | ||
30 | if (particles[particle][0]>=0 && particles[particle][1]>=0 && | ||
31 | particles[particle][0]<112 && particles[particle][1]<64) | ||
32 | return true; | ||
33 | else | ||
34 | return false; | ||
35 | } | ||
36 | |||
37 | static int create_particle(void) | ||
38 | { | ||
39 | int i; | ||
40 | |||
41 | for (i=0; i<NUM_PARTICLES; i++) { | ||
42 | if (!particle_exists(i)) { | ||
43 | particles[i][0]=(rb->rand()%112); | ||
44 | particles[i][1]=0; | ||
45 | return i; | ||
46 | } | ||
47 | } | ||
48 | return -1; | ||
49 | } | ||
50 | |||
51 | static void snow_move(void) | ||
52 | { | ||
53 | int i; | ||
54 | |||
55 | if (!(rb->rand()%2)) | ||
56 | create_particle(); | ||
57 | |||
58 | for (i=0; i<NUM_PARTICLES; i++) { | ||
59 | if (particle_exists(i)) { | ||
60 | rb->lcd_clearpixel(particles[i][0],particles[i][1]); | ||
61 | switch ((rb->rand()%7)) { | ||
62 | case 0: | ||
63 | particles[i][0]++; | ||
64 | break; | ||
65 | |||
66 | case 1: | ||
67 | particles[i][0]--; | ||
68 | break; | ||
69 | |||
70 | case 2: | ||
71 | break; | ||
72 | |||
73 | default: | ||
74 | particles[i][1]++; | ||
75 | break; | ||
76 | } | ||
77 | if (particle_exists(i)) | ||
78 | rb->lcd_drawpixel(particles[i][0],particles[i][1]); | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | |||
83 | static void snow_init(void) | ||
84 | { | ||
85 | int i; | ||
86 | |||
87 | for (i=0; i<NUM_PARTICLES; i++) { | ||
88 | particles[i][0]=-1; | ||
89 | particles[i][1]=-1; | ||
90 | } | ||
91 | rb->lcd_clear_display(); | ||
92 | } | ||
93 | |||
94 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | ||
95 | { | ||
96 | TEST_PLUGIN_API(api); | ||
97 | (void)(parameter); | ||
98 | rb = api; | ||
99 | |||
100 | snow_init(); | ||
101 | while (1) { | ||
102 | snow_move(); | ||
103 | rb->lcd_update(); | ||
104 | rb->sleep(HZ/20); | ||
105 | |||
106 | if (rb->button_get(false) == BUTTON_OFF) | ||
107 | return false; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | #endif | ||