diff options
Diffstat (limited to 'apps/plugins/jackpot.c')
-rw-r--r-- | apps/plugins/jackpot.c | 523 |
1 files changed, 294 insertions, 229 deletions
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 | /* | ||
20 | History: | ||
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 | ||
32 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
33 | 24 | ||
34 | /* Jackpot game for the player */ | 25 | const struct button_mapping* plugin_contexts[]={generic_actions}; |
26 | #define NB_PICTURES 9 | ||
27 | #define NB_SLOTS 3 | ||
35 | 28 | ||
36 | static 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 */ | 31 | static 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 | }; | ||
43 | static 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 | |||
54 | struct 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 | |||
66 | const 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 | ||
49 | static unsigned char str[12]; /*Containt the first line*/ | 81 | #endif /* HAVE_LCD_CHARCELLS */ |
50 | static 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 */ | ||
55 | static struct plugin_api* rb; | 83 | static struct plugin_api* rb; |
56 | 84 | ||
57 | /*Display the first line*/ | 85 | struct jackpot |
58 | static 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); | 104 | void 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*/ | 111 | void patterns_deinit(struct screen* display) |
69 | static 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 */ | 121 | void jackpot_exit(void *parameter) |
86 | enum 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! | 129 | void 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*/ | 140 | int 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*/ | 153 | int 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 "); | 176 | void 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*/ | 235 | void 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 */ | 251 | void 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*/ | 269 | void 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*/ | 312 | enum 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 | ||