diff options
-rw-r--r-- | apps/plugins/SOURCES | 2 | ||||
-rw-r--r-- | apps/plugins/jewels.c | 161 | ||||
-rw-r--r-- | docs/CREDITS | 1 |
3 files changed, 137 insertions, 27 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 33094d4643..892e127474 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES | |||
@@ -22,12 +22,12 @@ dict.c | |||
22 | 22 | ||
23 | #ifdef HAVE_LCD_BITMAP /* Recorder/Ondio models only */ | 23 | #ifdef HAVE_LCD_BITMAP /* Recorder/Ondio models only */ |
24 | #ifndef HAVE_LCD_COLOR | 24 | #ifndef HAVE_LCD_COLOR |
25 | bejeweled.c | ||
26 | fire.c | 25 | fire.c |
27 | plasma.c | 26 | plasma.c |
28 | solitaire.c | 27 | solitaire.c |
29 | sudoku.c | 28 | sudoku.c |
30 | #endif | 29 | #endif |
30 | bejeweled.c | ||
31 | bounce.c | 31 | bounce.c |
32 | calculator.c | 32 | calculator.c |
33 | chip8.c | 33 | chip8.c |
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c index 58ad78d7ec..5a9d7d3cac 100644 --- a/apps/plugins/jewels.c +++ b/apps/plugins/jewels.c | |||
@@ -23,6 +23,22 @@ | |||
23 | 23 | ||
24 | #ifdef HAVE_LCD_BITMAP | 24 | #ifdef HAVE_LCD_BITMAP |
25 | 25 | ||
26 | /* colors */ | ||
27 | #ifdef HAVE_LCD_COLOR | ||
28 | #define COLOR_BLACK LCD_RGBPACK(0,0,0) | ||
29 | #define COLOR_WHITE LCD_RGBPACK(255,255,255) | ||
30 | #define COLOR_RED LCD_RGBPACK(255,0,0) | ||
31 | #define COLOR_YELLOW LCD_RGBPACK(128,128,0) | ||
32 | #define COLOR_GREEN LCD_RGBPACK(0,255,0) | ||
33 | #define COLOR_BLUE LCD_RGBPACK(0,0,255) | ||
34 | #define COLOR_PINK LCD_RGBPACK(255,0,255) | ||
35 | #define COLOR_PURPLE LCD_RGBPACK(128,0,128) | ||
36 | #define COLOR_ORANGE LCD_RGBPACK(255,128,64) | ||
37 | static unsigned jewel_color[8]={COLOR_BLACK, COLOR_RED, COLOR_ORANGE, | ||
38 | COLOR_PURPLE, COLOR_BLUE, COLOR_YELLOW, | ||
39 | COLOR_GREEN, COLOR_PINK}; | ||
40 | #endif | ||
41 | |||
26 | /* save files */ | 42 | /* save files */ |
27 | #define SCORE_FILE PLUGIN_DIR "/bejeweled.score" | 43 | #define SCORE_FILE PLUGIN_DIR "/bejeweled.score" |
28 | #define SAVE_FILE PLUGIN_DIR "/bejeweled.save" | 44 | #define SAVE_FILE PLUGIN_DIR "/bejeweled.save" |
@@ -53,7 +69,7 @@ | |||
53 | #define BEJEWELED_SELECT BUTTON_SELECT | 69 | #define BEJEWELED_SELECT BUTTON_SELECT |
54 | #define BEJEWELED_RESUME BUTTON_MODE | 70 | #define BEJEWELED_RESUME BUTTON_MODE |
55 | 71 | ||
56 | #elif | 72 | #else |
57 | #error BEJEWELED: Unsupported keypad | 73 | #error BEJEWELED: Unsupported keypad |
58 | #endif | 74 | #endif |
59 | 75 | ||
@@ -71,18 +87,88 @@ | |||
71 | #define LEVEL_PTS 100 | 87 | #define LEVEL_PTS 100 |
72 | 88 | ||
73 | /* sleep time for animations (1/x seconds) */ | 89 | /* sleep time for animations (1/x seconds) */ |
74 | #define FALL_TIMER 30 | 90 | #define FALL_TIMER 50 |
75 | #define SWAP_TIMER 30 | 91 | #define SWAP_TIMER 30 |
76 | 92 | ||
77 | #if (LCD_HEIGHT == 128) && (LCD_WIDTH == 160) | 93 | #if (LCD_HEIGHT == 176) && (LCD_WIDTH == 220) |
78 | /* Use 16x16 tiles */ | 94 | /* use 22x22 tiles */ |
95 | |||
96 | /* size of a tile */ | ||
97 | #define TILE_WIDTH 22 | ||
98 | #define TILE_HEIGHT 22 | ||
99 | |||
100 | /* number of high scores to save */ | ||
101 | #define NUM_SCORES 10 | ||
102 | |||
103 | /* bitmaps for the jewels */ | ||
104 | static unsigned char jewel[8][66] = { | ||
105 | /* empty */ | ||
106 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
107 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
108 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
109 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
110 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
111 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | ||
112 | /* square */ | ||
113 | {0x00, 0x00, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, | ||
114 | 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0x00, 0x00, | ||
115 | 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
116 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, | ||
117 | 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, | ||
118 | 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00}, | ||
119 | /* plus */ | ||
120 | {0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xfe, 0xfe, 0x0e, 0x0e, | ||
121 | 0x0e, 0xfe, 0xfe, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, | ||
122 | 0x00, 0x7f, 0x7f, 0x7f, 0x71, 0x71, 0xf1, 0xf1, 0xf1, 0x00, 0x00, | ||
123 | 0x00, 0xf1, 0xf1, 0xf1, 0x71, 0x71, 0x7f, 0x7f, 0x7f, 0x00, 0x00, | ||
124 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0e, 0x0e, | ||
125 | 0x0e, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | ||
126 | /* triangle */ | ||
127 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xfc, 0x7e, | ||
128 | 0xfc, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
129 | 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xfc, 0x7f, 0x1f, 0x07, 0x01, 0x00, | ||
130 | 0x01, 0x07, 0x1f, 0x7f, 0xfc, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, | ||
131 | 0x00, 0x0c, 0x0f, 0x0f, 0x0f, 0x0f, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, | ||
132 | 0x0e, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f, 0x0f, 0x0f, 0x0c, 0x00, 0x00}, | ||
133 | /* diamond */ | ||
134 | {0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, | ||
135 | 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
136 | 0x00, 0x04, 0x0e, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
137 | 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0e, 0x04, 0x00, 0x00, | ||
138 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, | ||
139 | 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | ||
140 | /* star */ | ||
141 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf8, 0xfe, | ||
142 | 0xf8, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
143 | 0x00, 0x01, 0x03, 0x03, 0x07, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
144 | 0xff, 0xff, 0xff, 0xff, 0x8f, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, | ||
145 | 0x00, 0x00, 0x00, 0x00, 0x0c, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, | ||
146 | 0x00, 0x01, 0x03, 0x07, 0x07, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00}, | ||
147 | /* circle */ | ||
148 | {0x00, 0x80, 0xe0, 0xf0, 0xf8, 0xfc, 0xfc, 0x7e, 0x3e, 0x3e, 0x3e, | ||
149 | 0x3e, 0x3e, 0x7e, 0xfc, 0xfc, 0xf8, 0xf0, 0xe0, 0x80, 0x00, 0x00, | ||
150 | 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xc0, 0x80, 0x80, 0x80, | ||
151 | 0x80, 0x80, 0xc0, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, | ||
152 | 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0f, 0x0f, 0x0f, 0x0f, | ||
153 | 0x0f, 0x0f, 0x0f, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00}, | ||
154 | /* heart */ | ||
155 | {0x00, 0xe0, 0xf8, 0xfc, 0xfe, 0xfe, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, | ||
156 | 0xf0, 0xf8, 0xfc, 0xfe, 0xfe, 0xfe, 0xfc, 0xf8, 0xe0, 0x00, 0x00, | ||
157 | 0x00, 0x03, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
158 | 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x03, 0x00, 0x00, | ||
159 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, | ||
160 | 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} | ||
161 | }; | ||
162 | |||
163 | #elif (LCD_HEIGHT == 128) && (LCD_WIDTH == 160) | ||
164 | /* use 16x16 tiles */ | ||
79 | 165 | ||
80 | /* size of a tile */ | 166 | /* size of a tile */ |
81 | #define TILE_WIDTH 16 | 167 | #define TILE_WIDTH 16 |
82 | #define TILE_HEIGHT 16 | 168 | #define TILE_HEIGHT 16 |
83 | 169 | ||
84 | /* number of high scores to save */ | 170 | /* number of high scores to save */ |
85 | #define NUM_SCORES 15 | 171 | #define NUM_SCORES 10 |
86 | 172 | ||
87 | /* bitmaps for the jewels */ | 173 | /* bitmaps for the jewels */ |
88 | static unsigned char jewel[8][32] = { | 174 | static unsigned char jewel[8][32] = { |
@@ -129,7 +215,7 @@ static unsigned char jewel[8][32] = { | |||
129 | }; | 215 | }; |
130 | 216 | ||
131 | #elif (LCD_HEIGHT == 64) && (LCD_WIDTH == 112) | 217 | #elif (LCD_HEIGHT == 64) && (LCD_WIDTH == 112) |
132 | /* Use 8x8 tiles */ | 218 | /* use 10x8 tiles */ |
133 | 219 | ||
134 | /* size of a tile */ | 220 | /* size of a tile */ |
135 | #define TILE_WIDTH 10 | 221 | #define TILE_WIDTH 10 |
@@ -198,7 +284,7 @@ struct game_context { | |||
198 | /***************************************************************************** | 284 | /***************************************************************************** |
199 | * bejeweled_init() initializes bejeweled data structures. | 285 | * bejeweled_init() initializes bejeweled data structures. |
200 | ******************************************************************************/ | 286 | ******************************************************************************/ |
201 | void bejeweled_init(struct game_context* bj) { | 287 | static void bejeweled_init(struct game_context* bj) { |
202 | /* seed the rand generator */ | 288 | /* seed the rand generator */ |
203 | rb->srand(*rb->current_tick); | 289 | rb->srand(*rb->current_tick); |
204 | 290 | ||
@@ -220,7 +306,7 @@ void bejeweled_init(struct game_context* bj) { | |||
220 | /***************************************************************************** | 306 | /***************************************************************************** |
221 | * bejeweled_drawboard() redraws the entire game board. | 307 | * bejeweled_drawboard() redraws the entire game board. |
222 | ******************************************************************************/ | 308 | ******************************************************************************/ |
223 | void bejeweled_drawboard(struct game_context* bj) { | 309 | static void bejeweled_drawboard(struct game_context* bj) { |
224 | int i, j; | 310 | int i, j; |
225 | int w, h; | 311 | int w, h; |
226 | unsigned int tempscore; | 312 | unsigned int tempscore; |
@@ -233,11 +319,17 @@ void bejeweled_drawboard(struct game_context* bj) { | |||
233 | rb->lcd_clear_display(); | 319 | rb->lcd_clear_display(); |
234 | 320 | ||
235 | /* draw separator lines */ | 321 | /* draw separator lines */ |
322 | #ifdef HAVE_LCD_COLOR | ||
323 | rb->lcd_set_foreground(COLOR_BLACK); | ||
324 | #endif | ||
236 | rb->lcd_vline(BJ_WIDTH*TILE_WIDTH, 0, LCD_HEIGHT); | 325 | rb->lcd_vline(BJ_WIDTH*TILE_WIDTH, 0, LCD_HEIGHT); |
237 | rb->lcd_hline(BJ_WIDTH*TILE_WIDTH, LCD_WIDTH, 18); | 326 | rb->lcd_hline(BJ_WIDTH*TILE_WIDTH, LCD_WIDTH, 18); |
238 | rb->lcd_hline(BJ_WIDTH*TILE_WIDTH, LCD_WIDTH, LCD_HEIGHT-10); | 327 | rb->lcd_hline(BJ_WIDTH*TILE_WIDTH, LCD_WIDTH, LCD_HEIGHT-10); |
239 | 328 | ||
240 | /* draw progress bar */ | 329 | /* draw progress bar */ |
330 | #ifdef HAVE_LCD_COLOR | ||
331 | rb->lcd_set_foreground(COLOR_BLUE); | ||
332 | #endif | ||
241 | rb->lcd_fillrect(BJ_WIDTH*TILE_WIDTH+(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/4, | 333 | rb->lcd_fillrect(BJ_WIDTH*TILE_WIDTH+(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/4, |
242 | (LCD_HEIGHT-10)-(((LCD_HEIGHT-10)-18)* | 334 | (LCD_HEIGHT-10)-(((LCD_HEIGHT-10)-18)* |
243 | tempscore/LEVEL_PTS), | 335 | tempscore/LEVEL_PTS), |
@@ -247,6 +339,9 @@ void bejeweled_drawboard(struct game_context* bj) { | |||
247 | /* dispay playing board */ | 339 | /* dispay playing board */ |
248 | for(i=0; i<BJ_HEIGHT-1; i++){ | 340 | for(i=0; i<BJ_HEIGHT-1; i++){ |
249 | for(j=0; j<BJ_WIDTH; j++){ | 341 | for(j=0; j<BJ_WIDTH; j++){ |
342 | #ifdef HAVE_LCD_COLOR | ||
343 | rb->lcd_set_foreground(jewel_color[bj->playboard[j][i+1].type]); | ||
344 | #endif | ||
250 | rb->lcd_mono_bitmap(jewel[bj->playboard[j][i+1].type], | 345 | rb->lcd_mono_bitmap(jewel[bj->playboard[j][i+1].type], |
251 | j*TILE_WIDTH, i*TILE_HEIGHT, | 346 | j*TILE_WIDTH, i*TILE_HEIGHT, |
252 | TILE_WIDTH, TILE_HEIGHT); | 347 | TILE_WIDTH, TILE_HEIGHT); |
@@ -254,6 +349,9 @@ void bejeweled_drawboard(struct game_context* bj) { | |||
254 | } | 349 | } |
255 | 350 | ||
256 | /* print text */ | 351 | /* print text */ |
352 | #ifdef HAVE_LCD_COLOR | ||
353 | rb->lcd_set_foreground(COLOR_BLACK); | ||
354 | #endif | ||
257 | rb->lcd_getstringsize(title, &w, &h); | 355 | rb->lcd_getstringsize(title, &w, &h); |
258 | rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, 1, title); | 356 | rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, 1, title); |
259 | 357 | ||
@@ -274,7 +372,7 @@ void bejeweled_drawboard(struct game_context* bj) { | |||
274 | * bejeweled_putjewels() makes the jewels fall to fill empty spots and adds | 372 | * bejeweled_putjewels() makes the jewels fall to fill empty spots and adds |
275 | * new random jewels at the empty spots at the top of each row. | 373 | * new random jewels at the empty spots at the top of each row. |
276 | ******************************************************************************/ | 374 | ******************************************************************************/ |
277 | void bejeweled_putjewels(struct game_context* bj){ | 375 | static void bejeweled_putjewels(struct game_context* bj){ |
278 | int i, j, k; | 376 | int i, j, k; |
279 | bool mark, done; | 377 | bool mark, done; |
280 | 378 | ||
@@ -314,8 +412,12 @@ void bejeweled_putjewels(struct game_context* bj){ | |||
314 | /* clear old position */ | 412 | /* clear old position */ |
315 | rb->lcd_mono_bitmap(jewel[0], | 413 | rb->lcd_mono_bitmap(jewel[0], |
316 | j*TILE_WIDTH, | 414 | j*TILE_WIDTH, |
317 | (i-1)*TILE_HEIGHT+k-2, | 415 | (i-1)*TILE_HEIGHT+k-TILE_HEIGHT/8, |
318 | TILE_WIDTH, TILE_HEIGHT); | 416 | TILE_WIDTH, TILE_HEIGHT); |
417 | #ifdef HAVE_LCD_COLOR | ||
418 | rb->lcd_set_foreground(jewel_color | ||
419 | [bj->playboard[j][i].type]); | ||
420 | #endif | ||
319 | /* draw new position */ | 421 | /* draw new position */ |
320 | rb->lcd_mono_bitmap(jewel[bj->playboard[j][i].type], | 422 | rb->lcd_mono_bitmap(jewel[bj->playboard[j][i].type], |
321 | j*TILE_WIDTH, | 423 | j*TILE_WIDTH, |
@@ -354,7 +456,7 @@ void bejeweled_putjewels(struct game_context* bj){ | |||
354 | * bejeweled_clearjewels() finds all the connected rows and columns and | 456 | * bejeweled_clearjewels() finds all the connected rows and columns and |
355 | * calculates and returns the points earned. | 457 | * calculates and returns the points earned. |
356 | ******************************************************************************/ | 458 | ******************************************************************************/ |
357 | unsigned int bejeweled_clearjewels(struct game_context* bj) { | 459 | static unsigned int bejeweled_clearjewels(struct game_context* bj) { |
358 | int i, j; | 460 | int i, j; |
359 | int last, run; | 461 | int last, run; |
360 | unsigned int points = 0; | 462 | unsigned int points = 0; |
@@ -421,7 +523,6 @@ unsigned int bejeweled_clearjewels(struct game_context* bj) { | |||
421 | } | 523 | } |
422 | } | 524 | } |
423 | 525 | ||
424 | bejeweled_drawboard(bj); | ||
425 | return points; | 526 | return points; |
426 | } | 527 | } |
427 | 528 | ||
@@ -429,7 +530,7 @@ unsigned int bejeweled_clearjewels(struct game_context* bj) { | |||
429 | * bejeweled_runboard() runs the board until it settles in a fixed state and | 530 | * bejeweled_runboard() runs the board until it settles in a fixed state and |
430 | * returns points earned. | 531 | * returns points earned. |
431 | ******************************************************************************/ | 532 | ******************************************************************************/ |
432 | unsigned int bejeweled_runboard(struct game_context* bj) { | 533 | static unsigned int bejeweled_runboard(struct game_context* bj) { |
433 | unsigned int points = 0; | 534 | unsigned int points = 0; |
434 | unsigned int ret; | 535 | unsigned int ret; |
435 | 536 | ||
@@ -437,6 +538,7 @@ unsigned int bejeweled_runboard(struct game_context* bj) { | |||
437 | 538 | ||
438 | while((ret = bejeweled_clearjewels(bj)) > 0) { | 539 | while((ret = bejeweled_clearjewels(bj)) > 0) { |
439 | points += ret; | 540 | points += ret; |
541 | bejeweled_drawboard(bj); | ||
440 | bejeweled_putjewels(bj); | 542 | bejeweled_putjewels(bj); |
441 | } | 543 | } |
442 | 544 | ||
@@ -447,8 +549,8 @@ unsigned int bejeweled_runboard(struct game_context* bj) { | |||
447 | * bejeweled_swapjewels() swaps two jewels as long as it results in points and | 549 | * bejeweled_swapjewels() swaps two jewels as long as it results in points and |
448 | * returns points earned. | 550 | * returns points earned. |
449 | ******************************************************************************/ | 551 | ******************************************************************************/ |
450 | unsigned int bejeweled_swapjewels(struct game_context* bj, | 552 | static unsigned int bejeweled_swapjewels(struct game_context* bj, |
451 | int x, int y, int direc) { | 553 | int x, int y, int direc) { |
452 | int k; | 554 | int k; |
453 | int horzmod, vertmod; | 555 | int horzmod, vertmod; |
454 | int movelen = 0; | 556 | int movelen = 0; |
@@ -503,10 +605,17 @@ unsigned int bejeweled_swapjewels(struct game_context* bj, | |||
503 | (y+vertmod)*TILE_HEIGHT-vertmod*(k-TILE_HEIGHT/8), | 605 | (y+vertmod)*TILE_HEIGHT-vertmod*(k-TILE_HEIGHT/8), |
504 | TILE_WIDTH, TILE_HEIGHT); | 606 | TILE_WIDTH, TILE_HEIGHT); |
505 | /* draw new position */ | 607 | /* draw new position */ |
608 | #ifdef HAVE_LCD_COLOR | ||
609 | rb->lcd_set_foreground(jewel_color[bj->playboard[x][y+1].type]); | ||
610 | #endif | ||
506 | rb->lcd_mono_bitmap(jewel[bj->playboard[x][y+1].type], | 611 | rb->lcd_mono_bitmap(jewel[bj->playboard[x][y+1].type], |
507 | x*TILE_WIDTH+horzmod*k, | 612 | x*TILE_WIDTH+horzmod*k, |
508 | y*TILE_HEIGHT+vertmod*k, | 613 | y*TILE_HEIGHT+vertmod*k, |
509 | TILE_WIDTH, TILE_HEIGHT); | 614 | TILE_WIDTH, TILE_HEIGHT); |
615 | #ifdef HAVE_LCD_COLOR | ||
616 | rb->lcd_set_foreground(jewel_color[bj->playboard | ||
617 | [x+horzmod][y+1+vertmod].type]); | ||
618 | #endif | ||
510 | rb->lcd_set_drawmode(DRMODE_FG); | 619 | rb->lcd_set_drawmode(DRMODE_FG); |
511 | rb->lcd_mono_bitmap(jewel[bj->playboard | 620 | rb->lcd_mono_bitmap(jewel[bj->playboard |
512 | [x+horzmod][y+1+vertmod].type], | 621 | [x+horzmod][y+1+vertmod].type], |
@@ -537,7 +646,7 @@ unsigned int bejeweled_swapjewels(struct game_context* bj, | |||
537 | * bejeweled_movesavail() uses pattern matching to see if there are any | 646 | * bejeweled_movesavail() uses pattern matching to see if there are any |
538 | * available move left. | 647 | * available move left. |
539 | ******************************************************************************/ | 648 | ******************************************************************************/ |
540 | bool bejeweled_movesavail(struct game_context* bj) { | 649 | static bool bejeweled_movesavail(struct game_context* bj) { |
541 | int i, j; | 650 | int i, j; |
542 | bool moves = false; | 651 | bool moves = false; |
543 | int mytype; | 652 | int mytype; |
@@ -633,7 +742,7 @@ bool bejeweled_movesavail(struct game_context* bj) { | |||
633 | * bejeweled_nextlevel() advances the game to the next level and returns | 742 | * bejeweled_nextlevel() advances the game to the next level and returns |
634 | * points earned. | 743 | * points earned. |
635 | ******************************************************************************/ | 744 | ******************************************************************************/ |
636 | unsigned int bejeweled_nextlevel(struct game_context* bj) { | 745 | static unsigned int bejeweled_nextlevel(struct game_context* bj) { |
637 | int i, x, y; | 746 | int i, x, y; |
638 | unsigned int points = 0; | 747 | unsigned int points = 0; |
639 | 748 | ||
@@ -641,7 +750,6 @@ unsigned int bejeweled_nextlevel(struct game_context* bj) { | |||
641 | while(bj->score >= LEVEL_PTS) { | 750 | while(bj->score >= LEVEL_PTS) { |
642 | bj->score -= LEVEL_PTS; | 751 | bj->score -= LEVEL_PTS; |
643 | bj->level++; | 752 | bj->level++; |
644 | bejeweled_drawboard(bj); | ||
645 | rb->splash(HZ*2, true, "Level %d", bj->level); | 753 | rb->splash(HZ*2, true, "Level %d", bj->level); |
646 | bejeweled_drawboard(bj); | 754 | bejeweled_drawboard(bj); |
647 | } | 755 | } |
@@ -668,7 +776,7 @@ unsigned int bejeweled_nextlevel(struct game_context* bj) { | |||
668 | * bejeweld_recordscore() inserts a high score into the high scores list and | 776 | * bejeweld_recordscore() inserts a high score into the high scores list and |
669 | * returns the high score position. | 777 | * returns the high score position. |
670 | ******************************************************************************/ | 778 | ******************************************************************************/ |
671 | int bejeweled_recordscore(struct game_context* bj) { | 779 | static int bejeweled_recordscore(struct game_context* bj) { |
672 | int i; | 780 | int i; |
673 | int position = 0; | 781 | int position = 0; |
674 | unsigned short current, temp; | 782 | unsigned short current, temp; |
@@ -696,7 +804,7 @@ unsigned int bejeweled_nextlevel(struct game_context* bj) { | |||
696 | /***************************************************************************** | 804 | /***************************************************************************** |
697 | * bejeweled_loadscores() loads the high scores saved file. | 805 | * bejeweled_loadscores() loads the high scores saved file. |
698 | ******************************************************************************/ | 806 | ******************************************************************************/ |
699 | void bejeweled_loadscores(struct game_context* bj) { | 807 | static void bejeweled_loadscores(struct game_context* bj) { |
700 | int fd; | 808 | int fd; |
701 | 809 | ||
702 | bj->dirty = false; | 810 | bj->dirty = false; |
@@ -720,7 +828,7 @@ void bejeweled_loadscores(struct game_context* bj) { | |||
720 | /***************************************************************************** | 828 | /***************************************************************************** |
721 | * bejeweled_savescores() saves the high scores. | 829 | * bejeweled_savescores() saves the high scores. |
722 | ******************************************************************************/ | 830 | ******************************************************************************/ |
723 | void bejeweled_savescores(struct game_context* bj) { | 831 | static void bejeweled_savescores(struct game_context* bj) { |
724 | int fd; | 832 | int fd; |
725 | 833 | ||
726 | /* write out the high scores to the save file */ | 834 | /* write out the high scores to the save file */ |
@@ -733,7 +841,7 @@ void bejeweled_savescores(struct game_context* bj) { | |||
733 | /***************************************************************************** | 841 | /***************************************************************************** |
734 | * bejeweled_loadgame() loads the saved game and returns load success. | 842 | * bejeweled_loadgame() loads the saved game and returns load success. |
735 | ******************************************************************************/ | 843 | ******************************************************************************/ |
736 | bool bejeweled_loadgame(struct game_context* bj) { | 844 | static bool bejeweled_loadgame(struct game_context* bj) { |
737 | int fd; | 845 | int fd; |
738 | bool loaded = false; | 846 | bool loaded = false; |
739 | 847 | ||
@@ -761,7 +869,7 @@ bool bejeweled_loadgame(struct game_context* bj) { | |||
761 | /***************************************************************************** | 869 | /***************************************************************************** |
762 | * bejeweled_savegame() saves the current game state. | 870 | * bejeweled_savegame() saves the current game state. |
763 | ******************************************************************************/ | 871 | ******************************************************************************/ |
764 | void bejeweled_savegame(struct game_context* bj) { | 872 | static void bejeweled_savegame(struct game_context* bj) { |
765 | int fd; | 873 | int fd; |
766 | 874 | ||
767 | /* write out the game state to the save file */ | 875 | /* write out the game state to the save file */ |
@@ -778,7 +886,7 @@ void bejeweled_savegame(struct game_context* bj) { | |||
778 | * bejeweled_callback() is the default event handler callback which is called | 886 | * bejeweled_callback() is the default event handler callback which is called |
779 | * on usb connect and shutdown. | 887 | * on usb connect and shutdown. |
780 | ******************************************************************************/ | 888 | ******************************************************************************/ |
781 | void bejeweled_callback(void* param) { | 889 | static void bejeweled_callback(void* param) { |
782 | struct game_context* bj = (struct game_context*) param; | 890 | struct game_context* bj = (struct game_context*) param; |
783 | if(bj->dirty) { | 891 | if(bj->dirty) { |
784 | rb->splash(HZ, true, "Saving high scores..."); | 892 | rb->splash(HZ, true, "Saving high scores..."); |
@@ -789,7 +897,7 @@ void bejeweled_callback(void* param) { | |||
789 | /***************************************************************************** | 897 | /***************************************************************************** |
790 | * bejeweled() is the main game subroutine, it returns the final game status. | 898 | * bejeweled() is the main game subroutine, it returns the final game status. |
791 | ******************************************************************************/ | 899 | ******************************************************************************/ |
792 | int bejeweled(struct game_context* bj) { | 900 | static int bejeweled(struct game_context* bj) { |
793 | int i, j; | 901 | int i, j; |
794 | int w, h; | 902 | int w, h; |
795 | int button; | 903 | int button; |
@@ -803,7 +911,7 @@ int bejeweled(struct game_context* bj) { | |||
803 | /* the cursor coordinates */ | 911 | /* the cursor coordinates */ |
804 | int x=0, y=0; | 912 | int x=0, y=0; |
805 | 913 | ||
806 | /* don't resume by deafult */ | 914 | /* don't resume by default */ |
807 | bj->resume = false; | 915 | bj->resume = false; |
808 | 916 | ||
809 | /******************** | 917 | /******************** |
@@ -916,6 +1024,7 @@ int bejeweled(struct game_context* bj) { | |||
916 | bejeweled_drawboard(bj); | 1024 | bejeweled_drawboard(bj); |
917 | bejeweled_putjewels(bj); | 1025 | bejeweled_putjewels(bj); |
918 | bj->score += bejeweled_runboard(bj); | 1026 | bj->score += bejeweled_runboard(bj); |
1027 | if (!bejeweled_movesavail(bj)) return BJ_LOSE; | ||
919 | 1028 | ||
920 | /********************** | 1029 | /********************** |
921 | * play * | 1030 | * play * |
diff --git a/docs/CREDITS b/docs/CREDITS index 0cd8a73ef7..19bf6415a8 100644 --- a/docs/CREDITS +++ b/docs/CREDITS | |||
@@ -142,3 +142,4 @@ Mark Arigo | |||
142 | Magnus Westerlund | 142 | Magnus Westerlund |
143 | Jake Owen | 143 | Jake Owen |
144 | Mustapha Senhaji | 144 | Mustapha Senhaji |
145 | Adam Boot | ||