summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ferrare <kevin@rockbox.org>2007-07-25 09:38:55 +0000
committerKevin Ferrare <kevin@rockbox.org>2007-07-25 09:38:55 +0000
commitac017781e02e361074fd4da3b3eeb14745f79f03 (patch)
treeec3ce8eb8001b5d0d6822292ed443797b6ae1103
parent9b8925e56de605e22aff3700d1cd13c70814b25f (diff)
downloadrockbox-ac017781e02e361074fd4da3b3eeb14745f79f03.tar.gz
rockbox-ac017781e02e361074fd4da3b3eeb14745f79f03.zip
Ported the archos player's jackpot plugin to bitmaps LCD (still need some neat bitmaps), multi screen support for jackpot plugin and iriverify
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13978 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c1
-rw-r--r--apps/plugin.h2
-rw-r--r--apps/plugins/SOURCES2
-rw-r--r--apps/plugins/bitmaps/native/SOURCES3
-rw-r--r--apps/plugins/bitmaps/native/jackpot_slots.30x420x1.bmpbin0 -> 1742 bytes
-rw-r--r--apps/plugins/bitmaps/remote_native/SOURCES3
-rw-r--r--apps/plugins/bitmaps/remote_native/jackpot_slots_remote.15x210x1.bmpbin0 -> 902 bytes
-rw-r--r--apps/plugins/iriverify.c16
-rw-r--r--apps/plugins/jackpot.c523
-rw-r--r--apps/screen_access.c1
-rw-r--r--apps/screen_access.h1
11 files changed, 314 insertions, 238 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index f61e799186..5c849e31db 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -87,6 +87,7 @@ static const struct plugin_api rockbox_api = {
87 lcd_icon, 87 lcd_icon,
88 lcd_double_height, 88 lcd_double_height,
89#else 89#else
90 screen_clear_area,
90 lcd_set_drawmode, 91 lcd_set_drawmode,
91 lcd_get_drawmode, 92 lcd_get_drawmode,
92 lcd_setfont, 93 lcd_setfont,
diff --git a/apps/plugin.h b/apps/plugin.h
index 9adefc176b..36ad3ba42b 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -154,6 +154,8 @@ struct plugin_api {
154 void (*lcd_icon)(int icon, bool enable); 154 void (*lcd_icon)(int icon, bool enable);
155 void (*lcd_double_height)(bool on); 155 void (*lcd_double_height)(bool on);
156#else 156#else
157 void (*screen_clear_area)(struct screen * display, int xstart, int ystart,
158 int width, int height);
157 void (*lcd_set_drawmode)(int mode); 159 void (*lcd_set_drawmode)(int mode);
158 int (*lcd_get_drawmode)(void); 160 int (*lcd_get_drawmode)(void);
159 void (*lcd_setfont)(int font); 161 void (*lcd_setfont)(int font);
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 14f4d552d1..7915465df4 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -5,6 +5,7 @@ credits.c
5cube.c 5cube.c
6dict.c 6dict.c
7firmware_flash.c 7firmware_flash.c
8jackpot.c
8logo.c 9logo.c
9mosaique.c 10mosaique.c
10properties.c 11properties.c
@@ -110,7 +111,6 @@ rocklife.c
110 111
111#ifdef HAVE_LCD_CHARCELLS /* Player model only */ 112#ifdef HAVE_LCD_CHARCELLS /* Player model only */
112euroconverter.c 113euroconverter.c
113jackpot.c
114nim.c 114nim.c
115#endif /* HAVE_LCD_CHARCELLS */ 115#endif /* HAVE_LCD_CHARCELLS */
116 116
diff --git a/apps/plugins/bitmaps/native/SOURCES b/apps/plugins/bitmaps/native/SOURCES
index 00a6e3ab30..50866cb183 100644
--- a/apps/plugins/bitmaps/native/SOURCES
+++ b/apps/plugins/bitmaps/native/SOURCES
@@ -56,6 +56,9 @@ brickmania_powerups.176x132x16.bmp
56brickmania_break.176x132x16.bmp 56brickmania_break.176x132x16.bmp
57#endif 57#endif
58 58
59/* Jackpot */
60jackpot_slots.30x420x1.bmp
61
59/* Bubbles */ 62/* Bubbles */
60#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) 63#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
61bubbles_emblem.112x64x1.bmp 64bubbles_emblem.112x64x1.bmp
diff --git a/apps/plugins/bitmaps/native/jackpot_slots.30x420x1.bmp b/apps/plugins/bitmaps/native/jackpot_slots.30x420x1.bmp
new file mode 100644
index 0000000000..5ba8c10c41
--- /dev/null
+++ b/apps/plugins/bitmaps/native/jackpot_slots.30x420x1.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/remote_native/SOURCES b/apps/plugins/bitmaps/remote_native/SOURCES
index c59aab6107..d59621d686 100644
--- a/apps/plugins/bitmaps/remote_native/SOURCES
+++ b/apps/plugins/bitmaps/remote_native/SOURCES
@@ -1,3 +1,6 @@
1#if defined(SIMULATOR) && defined(__APPLE__) 1#if defined(SIMULATOR) && defined(__APPLE__)
2osx.dummy.bmp 2osx.dummy.bmp
3#endif 3#endif
4
5/* Jackpot */
6jackpot_slots_remote.15x210x1.bmp
diff --git a/apps/plugins/bitmaps/remote_native/jackpot_slots_remote.15x210x1.bmp b/apps/plugins/bitmaps/remote_native/jackpot_slots_remote.15x210x1.bmp
new file mode 100644
index 0000000000..5137d7d3dc
--- /dev/null
+++ b/apps/plugins/bitmaps/remote_native/jackpot_slots_remote.15x210x1.bmp
Binary files differ
diff --git a/apps/plugins/iriverify.c b/apps/plugins/iriverify.c
index 135cee36bd..b578cf7e0c 100644
--- a/apps/plugins/iriverify.c
+++ b/apps/plugins/iriverify.c
@@ -134,7 +134,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
134{ 134{
135 char *buf; 135 char *buf;
136 int rc; 136 int rc;
137 137 int i;
138 filename = (char *)parameter; 138 filename = (char *)parameter;
139 139
140 rb = api; 140 rb = api;
@@ -143,31 +143,31 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
143 143
144 stringbuffer = buf; 144 stringbuffer = buf;
145 145
146 rb->lcd_clear_display(); 146 FOR_NB_SCREENS(i)
147 rb->screens[i]->clear_display();
147 rb->splash(0, "Converting..."); 148 rb->splash(0, "Converting...");
148 149
149 rc = read_buffer(0); 150 rc = read_buffer(0);
151 FOR_NB_SCREENS(i)
152 rb->screens[i]->clear_display();
150 if(rc == 0) { 153 if(rc == 0) {
151 rb->lcd_clear_display();
152 rb->splash(0, "Writing..."); 154 rb->splash(0, "Writing...");
153 rc = write_file(); 155 rc = write_file();
154 156
157 FOR_NB_SCREENS(i)
158 rb->screens[i]->clear_display();
155 if(rc < 0) { 159 if(rc < 0) {
156 rb->lcd_clear_display();
157 rb->splash(HZ, "Can't write file: %d", rc); 160 rb->splash(HZ, "Can't write file: %d", rc);
158 } else { 161 } else {
159 rb->lcd_clear_display();
160 rb->splash(HZ, "Done"); 162 rb->splash(HZ, "Done");
161 } 163 }
162 } else { 164 } else {
163 if(rc < 0) { 165 if(rc < 0) {
164 rb->lcd_clear_display();
165 rb->splash(HZ, "Can't read file: %d", rc); 166 rb->splash(HZ, "Can't read file: %d", rc);
166 } else { 167 } else {
167 rb->lcd_clear_display();
168 rb->splash(HZ, "The file is too big"); 168 rb->splash(HZ, "The file is too big");
169 } 169 }
170 } 170 }
171 171
172 return PLUGIN_OK; 172 return PLUGIN_OK;
173} 173}
diff --git a/apps/plugins/jackpot.c b/apps/plugins/jackpot.c
index b0a6265311..144e94917e 100644
--- a/apps/plugins/jackpot.c
+++ b/apps/plugins/jackpot.c
@@ -1,13 +1,13 @@
1/*************************************************************************** 1/***************************************************************************
2 * __________ __ ___. 2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2003 Pierre Delore 10 * Copyright (C) 2007 Copyright Kévin Ferrare based on work by Pierre Delore
11 * 11 *
12 * All files in this archive are subject to the GNU General Public License. 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. 13 * See the file COPYING in the source tree root for full license agreement.
@@ -16,271 +16,336 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19/*
20History:
21* V1.0: 21/07/03
22 First version with a dirty definition of the patterns.
23* V1.1: 24/07/03
24 Clean definition of the patterns.
25 Init message change
26*/
27
28#include "plugin.h"
29 19
30#ifdef HAVE_LCD_CHARCELLS 20#include "plugin.h"
21#include "pluginlib_actions.h"
31 22
32PLUGIN_HEADER 23PLUGIN_HEADER
33 24
34/* Jackpot game for the player */ 25const struct button_mapping* plugin_contexts[]={generic_actions};
26#define NB_PICTURES 9
27#define NB_SLOTS 3
35 28
36static unsigned char pattern[]={ 29#ifdef HAVE_LCD_CHARCELLS
37 0x00, 0x0A, 0x1F, 0x1F, 0x1F, 0x0e, 0x04, /* (+00)Coeur */ 30#define PICTURE_ROTATION_STEPS 7
38 0x00, 0x04, 0x0E, 0x1F, 0x1F, 0x04, 0x0E, /* (+07)Pique */ 31static unsigned char jackpot_slots_patterns[]={
39 0x00, 0x04, 0x0E, 0x1F, 0x0E, 0x04, 0x00, /* (+14)Carreau */ 32 0x00, 0x0A, 0x1F, 0x1F, 0x1F, 0x0e, 0x04, /* (+00)Heart */
40 0x00, 0x15, 0x0E, 0x1F, 0x0E, 0x15, 0x00, /* (+21)Treffle */ 33 0x00, 0x04, 0x0E, 0x1F, 0x1F, 0x04, 0x0E, /* (+07)Spade */
41 0x03, 0x04, 0x0e, 0x1F, 0x1F, 0x1F, 0x0e, /* (+28)Cerise */ 34 0x00, 0x04, 0x0E, 0x1F, 0x0E, 0x04, 0x00, /* (+14)Diamond */
42 0x00, 0x04, 0x04, 0x1F, 0x04, 0x0E, 0x1F, /* (+35)Carreau */ 35 0x00, 0x15, 0x0E, 0x1F, 0x0E, 0x15, 0x00, /* (+21)Club */
43 0x04, 0x0E, 0x15, 0x04, 0x0A, 0x0A, 0x11, /* (+42)Homme */ 36 0x03, 0x04, 0x0e, 0x1F, 0x1F, 0x1F, 0x0e, /* (+28)Cherry */
44 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, /* (+49)Carre */ 37 0x00, 0x04, 0x04, 0x1F, 0x04, 0x0E, 0x1F, /* (+35)Cross */
38 0x04, 0x0E, 0x15, 0x04, 0x0A, 0x0A, 0x11, /* (+42)Man */
39 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, /* (+49)Square */
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* (+56)Empty */ 40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* (+56)Empty */
46 0x00, 0x0A, 0x1F, 0x1F, 0x1F, 0x0e, 0x04 /* (+63)Coeur */ 41 0x00, 0x0A, 0x1F, 0x1F, 0x1F, 0x0e, 0x04 /* (+63)Heart */
42};
43static unsigned long char_patterns[NB_SLOTS];
44#else /* bitmaps LCDs */
45
46#define PICTURE_HEIGHT (BMPHEIGHT_jackpot_slots/(NB_PICTURES+1))
47#if NB_SCREENS==1
48#define PICTURE_ROTATION_STEPS PICTURE_HEIGHT
49#else
50#define REMOTE_PICTURE_HEIGHT (BMPHEIGHT_jackpot_slots_remote/(NB_PICTURES+1))
51#define PICTURE_ROTATION_STEPS (REMOTE_PICTURE_HEIGHT*PICTURE_HEIGHT)
52#endif
53
54struct jackpot_picture{
55 const fb_data* data;
56 int width;
57 int height;
58};
59
60/* FIXME: would be nice to have better graphics ... */
61#include "jackpot_slots.h"
62#if NB_SCREENS==2
63#include "jackpot_slots_remote.h"
64#endif
65
66const struct jackpot_picture jackpot_pictures[]={
67 {
68 jackpot_slots,
69 BMPWIDTH_jackpot_slots,
70 PICTURE_HEIGHT
71 },
72#if NB_SCREENS==2
73 {
74 jackpot_slots_remote,
75 BMPWIDTH_jackpot_slots_remote,
76 REMOTE_PICTURE_HEIGHT
77 }
78#endif
47}; 79};
48 80
49static unsigned char str[12]; /*Containt the first line*/ 81#endif /* HAVE_LCD_CHARCELLS */
50static unsigned long h1,h2,h3; /*Handle for the pattern*/
51 82
52/* here is a global api struct pointer. while not strictly necessary,
53 it's nice not to have to pass the api pointer in all function calls
54 in the plugin */
55static struct plugin_api* rb; 83static struct plugin_api* rb;
56 84
57/*Display the first line*/ 85struct jackpot
58static void display_first_line(int g)
59{ 86{
60 rb->snprintf(str,sizeof(str),"[ ]$%d",g); 87 /* A slot can display "NB_PICTURES" pictures
61 rb->lcd_puts(0,0,str); 88 A picture is moving up, it can take PICTURE_ROTATION_STEPS
89 to move a single picture completely.
90 So values in slot_state are comprised between
91 0 and NB_PICTURES*PICTURE_ROTATION_STEPS
92 */
93 int slot_state[NB_SLOTS];
94 /*
95 The real state of the picture in pixels on each screen
96 Different from slot_state because of the synchronised
97 rotation between different sized bitmaps on remote and main screen
98 */
99 int state_y[NB_SCREENS][NB_SLOTS];
100 int money;
101};
62 102
63 rb->lcd_putc(1,0, h1); 103#ifdef HAVE_LCD_CHARCELLS
64 rb->lcd_putc(2,0, h2); 104void patterns_init(struct screen* display)
65 rb->lcd_putc(3,0, h3); 105{
106 int i;
107 for(i=0;i<NB_SLOTS;i++)
108 char_patterns[i]=display->get_locked_pattern();
66} 109}
67 110
68/*Call when the program exit*/ 111void patterns_deinit(struct screen* display)
69static void jackpot_exit(void *parameter)
70{ 112{
71 (void)parameter; 113 /* Restore the old pattern */
72 114 int i;
73 /* Restore the old pattern (i don't find another way to do this. Any 115 for(i=0;i<NB_SLOTS;i++)
74 idea?) */ 116 display->unlock_pattern(char_patterns[i]);
75 rb->lcd_unlock_pattern(h1);
76 rb->lcd_unlock_pattern(h2);
77 rb->lcd_unlock_pattern(h3);
78
79 /* Clear the screen */
80 rb->lcd_clear_display();
81 rb->lcd_update();
82} 117}
118#endif /* HAVE_LCD_CHARCELLS */
83 119
84 120/*Call when the program exit*/
85/* this is the plugin entry point */ 121void jackpot_exit(void *parameter)
86enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
87{ 122{
88 int i,button,w,j;
89 int s[3];
90 int n[3];
91 int g=20;
92 bool exit=false;
93 bool go;
94
95 /* if you don't use the parameter, you can do like
96 this to avoid the compiler warning about it */
97 (void)parameter; 123 (void)parameter;
124#ifdef HAVE_LCD_CHARCELLS
125 patterns_deinit(rb->screens[SCREEN_MAIN]);
126#endif /* HAVE_LCD_CHARCELLS */
127}
98 128
99 /* if you are using a global api pointer, don't forget to copy it! 129void jackpot_init(struct jackpot* game)
100 otherwise you will get lovely "I04: IllInstr" errors... :-) */ 130{
101 rb = api; 131 int i,j;
102 rb->srand(*rb->current_tick); 132 game->money=20;
133 for(i=0;i<NB_SLOTS;i++){
134 game->slot_state[i]=(rb->rand()%NB_PICTURES)*PICTURE_ROTATION_STEPS;
135 FOR_NB_SCREENS(j)
136 game->state_y[j][i]=-1;
137 }
138}
103 139
104 /*Get the pattern handle*/ 140int jackpot_get_result(struct jackpot* game)
105 h1=rb->lcd_get_locked_pattern(); 141{
106 h2=rb->lcd_get_locked_pattern(); 142 int i=NB_SLOTS-1;
107 h3=rb->lcd_get_locked_pattern(); 143 int multiple=1;
144 int result=0;
145 for(;i>=0;i--)
146 {
147 result+=game->slot_state[i]*multiple/PICTURE_ROTATION_STEPS;
148 multiple*=10;
149 }
150 return(result);
151}
108 152
109 /*Init message*/ 153int jackpot_get_gain(struct jackpot* game)
110 rb->lcd_define_pattern(h1, pattern); 154{
111 rb->lcd_define_pattern(h2, pattern+7); 155 switch (jackpot_get_result(game))
112 rb->lcd_define_pattern(h3, pattern+28); 156 {
157 case 111 : return(20);
158 case 000 : return(15);
159 case 333 : return(10);
160 case 222 : return(8);
161 case 555 : return(5);
162 case 777 : return(4);
163 case 251 : return(4);
164 case 510 : return(4);
165 case 686 : return(3);
166 case 585 : return(3);
167 case 282 : return(3);
168 case 484 : return(3);
169 case 787 : return(2);
170 case 383 : return(2);
171 case 80 : return(2);
172 }
173 return(0);
174}
113 175
114 rb->lcd_puts(0,0," Jackpot "); 176void jackpot_display_slot_machine(struct jackpot* game, struct screen* display)
115 rb->lcd_putc(0,0,h1); rb->lcd_putc(1,0,h2); 177{
116 rb->lcd_putc(9,0,h2); rb->lcd_putc(10,0,h1); 178 char str[20];
117 rb->lcd_puts(0,1," V1.1 "); 179 int i;
118 rb->lcd_putc(1,1,h3); rb->lcd_putc(9,1,h3); 180 bool changes=false;
119 rb->lcd_update(); 181#ifdef HAVE_LCD_CHARCELLS
120 rb->sleep(HZ*2); 182 display->putc(0, 0, '[');
183#else
184 const struct jackpot_picture* picture=
185 &(jackpot_pictures[display->screen_type]);
186 int pos_x=(display->width-NB_SLOTS*(picture->width+1))/2;
187 int pos_y=(display->height-(picture->height))/2;
188#endif /* HAVE_LCD_CHARCELLS */
189 for(i=0;i<NB_SLOTS;i++)
190 {
191#ifdef HAVE_LCD_CHARCELLS
192 /* the only charcell lcd is 7 pixel high */
193 int state_y=(game->slot_state[i]*7)/PICTURE_ROTATION_STEPS;
194#else
195 int state_y=
196 (picture->height*game->slot_state[i])/PICTURE_ROTATION_STEPS;
197#endif /* HAVE_LCD_CHARCELLS */
198 int previous_state_y=game->state_y[display->screen_type][i];
199 if(state_y==previous_state_y)
200 continue;/*no need to update the picture
201 as it's the same as previous displayed one*/
202 changes=true;
203 game->state_y[display->screen_type][i]=state_y;
204#ifdef HAVE_LCD_CHARCELLS
205 char* current_pattern=&(jackpot_slots_patterns[state_y]);
206 display->define_pattern(char_patterns[i],
207 current_pattern);
208 display->putc(i+1, 0, char_patterns[i]);
209#else
210 display->bitmap_part(
211 picture->data,
212 /*slice into picture->data */
213 0, state_y,
214 picture->width,
215 /* Position on the screen */
216 pos_x, pos_y, picture->width, picture->height
217 );
218 pos_x+=(picture->width+1);
219#endif
220 }
221 if(changes){
222#ifdef HAVE_LCD_CHARCELLS
223 rb->snprintf(str,sizeof(str),"$%d", game->money);
224 display->putc(++i, 0, ']');
225 display->puts(++i, 0, str);
226#else
227 rb->snprintf(str,sizeof(str),"money : $%d", game->money);
228 display->puts(0, 0, str);
229#endif
230 display->update();
231 }
232}
121 233
122 /*First display*/
123 rb->lcd_clear_display();
124 rb->snprintf(str,sizeof(str),"[ ]$%d",g);
125 rb->lcd_puts(0,0,str);
126 rb->lcd_puts_scroll(0,1,"PLAY to begin");
127 rb->lcd_update();
128 234
129 /*Empty the event queue*/ 235void jackpot_info_message(struct screen* display, char* message)
130 rb->button_clear_queue(); 236{
237#ifdef HAVE_LCD_CHARCELLS
238 display->puts_scroll(0,1,message);
239#else
240 int xpos, ypos;
241 int message_height, message_width;
242 display->getstringsize(message, &message_width, &message_height);
243 xpos=(display->width-message_width)/2;
244 ypos=display->height-message_height;
245 rb->screen_clear_area(display, 0, ypos, display->width, message_height);
246 display->putsxy(xpos,ypos,message);
247 display->update();
248#endif /* HAVE_LCD_CHARCELLS */
249}
131 250
132 /* Define the start pattern */ 251void jackpot_print_turn_result(struct jackpot* game,
133 s[0]=(rb->rand()%9)*7; 252 int gain, struct screen* display)
134 s[1]=(rb->rand()%9)*7; 253{
135 s[2]=(rb->rand()%9)*7; 254 char str[20];
255 if (gain==0)
256 {
257 jackpot_info_message(display, "None ...");
258 if (game->money<=0)
259 jackpot_info_message(display, "You lose...STOP to quit");
260 }
261 else
262 {
263 rb->snprintf(str,sizeof(str),"You win %d$",gain);
264 jackpot_info_message(display, str);
265 }
266 display->update();
267}
136 268
137 /*Main loop*/ 269void jackpot_play_turn(struct jackpot* game)
138 while (!exit) 270{
271 /* How many pattern? */
272 int nb_turns[NB_SLOTS];
273 int i,d,gain,turns_remaining=0;
274 if(game->money<=0)
275 return;
276 game->money--;
277 for(i=0;i<NB_SLOTS;i++)
278 {
279 nb_turns[i]=(rb->rand()%15+5)*PICTURE_ROTATION_STEPS;
280 turns_remaining+=nb_turns[i];
281 }
282 FOR_NB_SCREENS(d)
139 { 283 {
140 /*Keyboard loop*/ 284 rb->screens[d]->clear_display();
141 go=false; 285 jackpot_info_message(rb->screens[d],"Good luck");
142 while (!go) 286 }
287 /* Jackpot Animation */
288 while(turns_remaining>0)
289 {
290 for(i=0;i<NB_SLOTS;i++)
143 { 291 {
144 button = rb->button_get(true); 292 if(nb_turns[i]>0)
145 switch ( button )
146 { 293 {
147 case BUTTON_STOP|BUTTON_REL: 294 nb_turns[i]--;
148 exit = true; 295 game->slot_state[i]++;
149 go = true; 296 if(game->slot_state[i]>=PICTURE_ROTATION_STEPS*NB_PICTURES)
150 break; 297 game->slot_state[i]=0;
151 298 turns_remaining--;
152 case BUTTON_PLAY|BUTTON_REL:
153 exit = false;
154 if (g>0)
155 {
156 go = true;
157 g--;
158 }
159 break;
160
161 default:
162 if (rb->default_event_handler_ex(button, jackpot_exit,
163 NULL) == SYS_USB_CONNECTED)
164 return PLUGIN_USB_CONNECTED;
165 break;
166 } 299 }
167 } 300 }
301 FOR_NB_SCREENS(d)
302 jackpot_display_slot_machine(game, rb->screens[d]);
303 rb->sleep(7*HZ/(24*PICTURE_ROTATION_STEPS));
304 }
305 gain=jackpot_get_gain(game);
306 if(gain!=0)
307 game->money+=gain;
308 FOR_NB_SCREENS(d)
309 jackpot_print_turn_result(game, gain, rb->screens[d]);
310}
168 311
169 /*Clear the Second line*/ 312enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
170 rb->lcd_puts_scroll(0,1,"Good luck"); 313{
171 rb->lcd_update(); 314 rb = api;
315 int action, i;
316 struct jackpot game;
317 (void)parameter;
318 rb->srand(*rb->current_tick);
319#ifdef HAVE_LCD_CHARCELLS
320 patterns_init(rb->screens[SCREEN_MAIN]);
321#endif /* HAVE_LCD_CHARCELLS */
322 jackpot_init(&game);
172 323
173 /*GO !!!!*/ 324 FOR_NB_SCREENS(i){
174 if ( go && !exit ) 325 rb->screens[i]->clear_display();
326 jackpot_display_slot_machine(&game, rb->screens[i]);
327 }
328 /*Empty the event queue*/
329 rb->button_clear_queue();
330 while (true)
331 {
332 action = pluginlib_getaction(rb, TIMEOUT_BLOCK,
333 plugin_contexts, 1);
334 switch ( action )
175 { 335 {
176 /* How many pattern? */ 336 case PLA_QUIT:
177 n[0]=(rb->rand()%15+5)*7; 337 return PLUGIN_OK;
178 n[1]=(rb->rand()%15+5)*7; 338 case PLA_FIRE:
179 n[2]=(rb->rand()%15+5)*7; 339 jackpot_play_turn(&game);
340 break;
180 341
181 display_first_line(g); 342 default:
182 /* Jackpot Animation */ 343 if (rb->default_event_handler_ex(action, jackpot_exit, NULL)
183 while((n[0]>=0) || (n[1]>=0) || (n[2]>=0)) 344 == SYS_USB_CONNECTED)
184 { 345 return PLUGIN_USB_CONNECTED;
185 if (n[0]>=0) 346 break;
186 rb->lcd_define_pattern(h1, pattern+s[0]);
187 if (n[1]>=0)
188 rb->lcd_define_pattern(h2, pattern+s[1]);
189 if (n[2]>=0)
190 rb->lcd_define_pattern(h3, pattern+s[2]);
191 rb->sleep(HZ/24);
192 rb->lcd_putc(1,0, h1);
193 rb->lcd_putc(2,0, h2);
194 rb->lcd_putc(3,0, h3);
195 rb->lcd_update();
196 for(i=0;i<3;i++)
197 {
198 if (n[i]>=0)
199 {
200 n[i]--;
201 s[i]++;
202 if (s[i]>=63)
203 s[i]=0;
204 }
205 }
206 }
207
208 /* You won? */
209 s[0]--;
210 s[1]--;
211 s[2]--;
212 w=(s[0]/7)*100+(s[1]/7)*10+(s[2]/7);
213
214 j=0;
215 switch (w)
216 {
217 case 111 :
218 j=20;
219 break;
220 case 000 :
221 j=15;
222 break;
223 case 333 :
224 j=10;
225 break;
226 case 222 :
227 j=8;
228 break;
229 case 555 :
230 j=5;
231 break;
232 case 777 :
233 j=4;
234 break;
235 case 251 :
236 j=4;
237 break;
238 case 510 :
239 j=4;
240 break;
241 case 686 :
242 j=3;
243 break;
244 case 585 :
245 j=3;
246 break;
247 case 282 :
248 j=3;
249 break;
250 case 484 :
251 j=3;
252 break;
253 case 787 :
254 j=2;
255 break;
256 case 383 :
257 j=2;
258 break;
259 case 80 :
260 j=2;
261 break;
262 }
263 if (j==0)
264 {
265 rb->lcd_puts(0,1,"None...");
266 if (g<=0)
267 rb->lcd_puts_scroll(0,1,"You lose...STOP to quit");
268 }
269 else
270 {
271 g+=j;
272 display_first_line(g);
273 rb->snprintf(str,sizeof(str),"You win %d$",j);
274 rb->lcd_puts(0,1,str);
275 }
276 rb->lcd_update();
277 } 347 }
278 } 348 }
279
280 /* This is the end */
281 jackpot_exit(NULL); 349 jackpot_exit(NULL);
282 /* Bye */
283 return PLUGIN_OK; 350 return PLUGIN_OK;
284} 351}
285
286#endif
diff --git a/apps/screen_access.c b/apps/screen_access.c
index d6ca938439..2d2013ec2a 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -174,6 +174,7 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
174 screen->putc=&lcd_putc; 174 screen->putc=&lcd_putc;
175 screen->get_locked_pattern=&lcd_get_locked_pattern; 175 screen->get_locked_pattern=&lcd_get_locked_pattern;
176 screen->define_pattern=&lcd_define_pattern; 176 screen->define_pattern=&lcd_define_pattern;
177 screen->unlock_pattern=&lcd_unlock_pattern;
177 screen->icon=&lcd_icon; 178 screen->icon=&lcd_icon;
178#endif /* HAVE_LCD_CHARCELLS */ 179#endif /* HAVE_LCD_CHARCELLS */
179 180
diff --git a/apps/screen_access.h b/apps/screen_access.h
index 1fd74046e6..967bd55c02 100644
--- a/apps/screen_access.h
+++ b/apps/screen_access.h
@@ -119,6 +119,7 @@ struct screen
119 void (*icon)(int icon, bool enable); 119 void (*icon)(int icon, bool enable);
120 unsigned long (*get_locked_pattern)(void); 120 unsigned long (*get_locked_pattern)(void);
121 void (*define_pattern)(unsigned long ucs, const char *pattern); 121 void (*define_pattern)(unsigned long ucs, const char *pattern);
122 void (*unlock_pattern)(unsigned long ucs);
122#endif 123#endif
123 void (*init)(void); 124 void (*init)(void);
124 void (*putsxy)(int x, int y, const unsigned char *str); 125 void (*putsxy)(int x, int y, const unsigned char *str);