diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-11-17 21:03:24 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-11-17 21:03:24 +0000 |
commit | f01563c3820907b750d821c9e961b50378c9c04c (patch) | |
tree | 19a55ad06417d9b2aea272138af9ebf7be6684ec /apps/plugins | |
parent | f8cc3211a60940228dade59436ba7ce2003445a3 (diff) | |
download | rockbox-f01563c3820907b750d821c9e961b50378c9c04c.tar.gz rockbox-f01563c3820907b750d821c9e961b50378c9c04c.zip |
Bejeweled: Changed the tile size for archos recorder/Ondio to 8x10 to account for the non-square LCD aspect.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7936 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/jewels.c | 106 |
1 files changed, 59 insertions, 47 deletions
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c index 5631c4933e..58ad78d7ec 100644 --- a/apps/plugins/jewels.c +++ b/apps/plugins/jewels.c | |||
@@ -78,7 +78,8 @@ | |||
78 | /* Use 16x16 tiles */ | 78 | /* Use 16x16 tiles */ |
79 | 79 | ||
80 | /* size of a tile */ | 80 | /* size of a tile */ |
81 | #define TILE_SZ 16 | 81 | #define TILE_WIDTH 16 |
82 | #define TILE_HEIGHT 16 | ||
82 | 83 | ||
83 | /* number of high scores to save */ | 84 | /* number of high scores to save */ |
84 | #define NUM_SCORES 15 | 85 | #define NUM_SCORES 15 |
@@ -131,29 +132,30 @@ static unsigned char jewel[8][32] = { | |||
131 | /* Use 8x8 tiles */ | 132 | /* Use 8x8 tiles */ |
132 | 133 | ||
133 | /* size of a tile */ | 134 | /* size of a tile */ |
134 | #define TILE_SZ 8 | 135 | #define TILE_WIDTH 10 |
136 | #define TILE_HEIGHT 8 | ||
135 | 137 | ||
136 | /* number of high scores to save */ | 138 | /* number of high scores to save */ |
137 | #define NUM_SCORES 8 | 139 | #define NUM_SCORES 8 |
138 | 140 | ||
139 | /* bitmaps for the jewels */ | 141 | /* bitmaps for the jewels */ |
140 | static unsigned char jewel[8][8] = { | 142 | static unsigned char jewel[8][10] = { |
141 | /* empty */ | 143 | /* empty */ |
142 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | 144 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
143 | /* square */ | 145 | /* square */ |
144 | {0x00, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x00}, | 146 | {0x00, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x00, 0x00}, |
145 | /* plus */ | 147 | /* plus */ |
146 | {0x1c, 0x14, 0x77, 0x41, 0x77, 0x14, 0x1c, 0x00}, | 148 | {0x00, 0x1c, 0x14, 0x77, 0x41, 0x41, 0x77, 0x14, 0x1c, 0x00}, |
147 | /* triangle */ | 149 | /* triangle */ |
148 | {0x60, 0x78, 0x4e, 0x43, 0x4e, 0x78, 0x60, 0x00}, | 150 | {0x60, 0x70, 0x5c, 0x46, 0x43, 0x46, 0x5c, 0x70, 0x60, 0x00}, |
149 | /* diamond */ | 151 | /* diamond */ |
150 | {0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00}, | 152 | {0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x7f, 0x3e, 0x1c, 0x08, 0x00}, |
151 | /* star */ | 153 | /* star */ |
152 | {0x08, 0x68, 0x3c, 0x1f, 0x3c, 0x68, 0x08, 0x00}, | 154 | {0x00, 0x04, 0x6c, 0x3c, 0x1c, 0x1f, 0x3c, 0x6c, 0x04, 0x00}, |
153 | /* circle */ | 155 | /* circle */ |
154 | {0x1c, 0x3e, 0x63, 0x63, 0x63, 0x3e, 0x1c, 0x00}, | 156 | {0x00, 0x1c, 0x3e, 0x63, 0x63, 0x63, 0x63, 0x3e, 0x1c, 0x00}, |
155 | /* heart */ | 157 | /* heart */ |
156 | {0x0e, 0x1f, 0x3e, 0x7c, 0x3e, 0x1f, 0x0e, 0x00} | 158 | {0x06, 0x0f, 0x1f, 0x3e, 0x7c, 0x3e, 0x1f, 0x0f, 0x06, 0x00} |
157 | }; | 159 | }; |
158 | 160 | ||
159 | #else | 161 | #else |
@@ -231,36 +233,37 @@ void bejeweled_drawboard(struct game_context* bj) { | |||
231 | rb->lcd_clear_display(); | 233 | rb->lcd_clear_display(); |
232 | 234 | ||
233 | /* draw separator lines */ | 235 | /* draw separator lines */ |
234 | rb->lcd_vline(BJ_WIDTH*TILE_SZ, 0, LCD_HEIGHT); | 236 | rb->lcd_vline(BJ_WIDTH*TILE_WIDTH, 0, LCD_HEIGHT); |
235 | rb->lcd_hline(BJ_WIDTH*TILE_SZ, LCD_WIDTH, 18); | 237 | rb->lcd_hline(BJ_WIDTH*TILE_WIDTH, LCD_WIDTH, 18); |
236 | rb->lcd_hline(BJ_WIDTH*TILE_SZ, LCD_WIDTH, LCD_HEIGHT-10); | 238 | rb->lcd_hline(BJ_WIDTH*TILE_WIDTH, LCD_WIDTH, LCD_HEIGHT-10); |
237 | 239 | ||
238 | /* draw progress bar */ | 240 | /* draw progress bar */ |
239 | rb->lcd_fillrect(BJ_WIDTH*TILE_SZ+(LCD_WIDTH-BJ_WIDTH*TILE_SZ)/4, | 241 | rb->lcd_fillrect(BJ_WIDTH*TILE_WIDTH+(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/4, |
240 | (LCD_HEIGHT-10)-(((LCD_HEIGHT-10)-18)* | 242 | (LCD_HEIGHT-10)-(((LCD_HEIGHT-10)-18)* |
241 | tempscore/LEVEL_PTS), | 243 | tempscore/LEVEL_PTS), |
242 | (LCD_WIDTH-BJ_WIDTH*TILE_SZ)/2, | 244 | (LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2, |
243 | ((LCD_HEIGHT-10)-18)*tempscore/LEVEL_PTS); | 245 | ((LCD_HEIGHT-10)-18)*tempscore/LEVEL_PTS); |
244 | 246 | ||
245 | /* dispay playing board */ | 247 | /* dispay playing board */ |
246 | for(i=0; i<BJ_HEIGHT-1; i++){ | 248 | for(i=0; i<BJ_HEIGHT-1; i++){ |
247 | for(j=0; j<BJ_WIDTH; j++){ | 249 | for(j=0; j<BJ_WIDTH; j++){ |
248 | rb->lcd_mono_bitmap(jewel[bj->playboard[j][i+1].type], | 250 | rb->lcd_mono_bitmap(jewel[bj->playboard[j][i+1].type], |
249 | j*TILE_SZ, i*TILE_SZ, TILE_SZ, TILE_SZ); | 251 | j*TILE_WIDTH, i*TILE_HEIGHT, |
252 | TILE_WIDTH, TILE_HEIGHT); | ||
250 | } | 253 | } |
251 | } | 254 | } |
252 | 255 | ||
253 | /* print text */ | 256 | /* print text */ |
254 | rb->lcd_getstringsize(title, &w, &h); | 257 | rb->lcd_getstringsize(title, &w, &h); |
255 | rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_SZ)/2-w/2, 1, title); | 258 | rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, 1, title); |
256 | 259 | ||
257 | rb->snprintf(str, 4, "%d", bj->level); | 260 | rb->snprintf(str, 4, "%d", bj->level); |
258 | rb->lcd_getstringsize(str, &w, &h); | 261 | rb->lcd_getstringsize(str, &w, &h); |
259 | rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_SZ)/2-w/2, 10, str); | 262 | rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, 10, str); |
260 | 263 | ||
261 | rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score); | 264 | rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score); |
262 | rb->lcd_getstringsize(str, &w, &h); | 265 | rb->lcd_getstringsize(str, &w, &h); |
263 | rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_SZ)/2-w/2, | 266 | rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, |
264 | LCD_HEIGHT-8, | 267 | LCD_HEIGHT-8, |
265 | str); | 268 | str); |
266 | 269 | ||
@@ -302,7 +305,7 @@ void bejeweled_putjewels(struct game_context* bj){ | |||
302 | if(done) break; | 305 | if(done) break; |
303 | 306 | ||
304 | /* animate falling jewels */ | 307 | /* animate falling jewels */ |
305 | for(k=TILE_SZ/8; k<=TILE_SZ; k+=TILE_SZ/8) { | 308 | for(k=TILE_HEIGHT/8; k<=TILE_HEIGHT; k+=TILE_HEIGHT/8) { |
306 | rb->sleep(HZ/FALL_TIMER); | 309 | rb->sleep(HZ/FALL_TIMER); |
307 | for(i=0; i<BJ_HEIGHT-1; i++) { | 310 | for(i=0; i<BJ_HEIGHT-1; i++) { |
308 | for(j=0; j<BJ_WIDTH; j++) { | 311 | for(j=0; j<BJ_WIDTH; j++) { |
@@ -310,14 +313,14 @@ void bejeweled_putjewels(struct game_context* bj){ | |||
310 | bj->playboard[j][i].type != 0) { | 313 | bj->playboard[j][i].type != 0) { |
311 | /* clear old position */ | 314 | /* clear old position */ |
312 | rb->lcd_mono_bitmap(jewel[0], | 315 | rb->lcd_mono_bitmap(jewel[0], |
313 | j*TILE_SZ, | 316 | j*TILE_WIDTH, |
314 | (i-1)*TILE_SZ+k-2, | 317 | (i-1)*TILE_HEIGHT+k-2, |
315 | TILE_SZ, TILE_SZ); | 318 | TILE_WIDTH, TILE_HEIGHT); |
316 | /* draw new position */ | 319 | /* draw new position */ |
317 | rb->lcd_mono_bitmap(jewel[bj->playboard[j][i].type], | 320 | rb->lcd_mono_bitmap(jewel[bj->playboard[j][i].type], |
318 | j*TILE_SZ, | 321 | j*TILE_WIDTH, |
319 | (i-1)*TILE_SZ+k, | 322 | (i-1)*TILE_HEIGHT+k, |
320 | TILE_SZ, TILE_SZ); | 323 | TILE_WIDTH, TILE_HEIGHT); |
321 | } | 324 | } |
322 | } | 325 | } |
323 | } | 326 | } |
@@ -448,6 +451,7 @@ unsigned int bejeweled_swapjewels(struct game_context* bj, | |||
448 | int x, int y, int direc) { | 451 | int x, int y, int direc) { |
449 | int k; | 452 | int k; |
450 | int horzmod, vertmod; | 453 | int horzmod, vertmod; |
454 | int movelen = 0; | ||
451 | bool undo = false; | 455 | bool undo = false; |
452 | unsigned int points = 0; | 456 | unsigned int points = 0; |
453 | 457 | ||
@@ -468,39 +472,47 @@ unsigned int bejeweled_swapjewels(struct game_context* bj, | |||
468 | vertmod = 0; | 472 | vertmod = 0; |
469 | switch(direc) { | 473 | switch(direc) { |
470 | case SWAP_UP: | 474 | case SWAP_UP: |
471 | vertmod = -1; break; | 475 | vertmod = -1; |
476 | movelen = TILE_HEIGHT; | ||
477 | break; | ||
472 | case SWAP_RIGHT: | 478 | case SWAP_RIGHT: |
473 | horzmod = 1; break; | 479 | horzmod = 1; |
480 | movelen = TILE_WIDTH; | ||
481 | break; | ||
474 | case SWAP_DOWN: | 482 | case SWAP_DOWN: |
475 | vertmod = 1; break; | 483 | vertmod = 1; |
484 | movelen = TILE_HEIGHT; | ||
485 | break; | ||
476 | case SWAP_LEFT: | 486 | case SWAP_LEFT: |
477 | horzmod = -1; break; | 487 | horzmod = -1; |
488 | movelen = TILE_WIDTH; | ||
489 | break; | ||
478 | } | 490 | } |
479 | 491 | ||
480 | while(true) { | 492 | while(true) { |
481 | /* animate swapping jewels */ | 493 | /* animate swapping jewels */ |
482 | for(k=TILE_SZ/8; k<=TILE_SZ; k+=TILE_SZ/8) { | 494 | for(k=TILE_HEIGHT/8; k<=movelen;k+=TILE_HEIGHT/8) { |
483 | rb->sleep(HZ/SWAP_TIMER); | 495 | rb->sleep(HZ/SWAP_TIMER); |
484 | /* clear old position */ | 496 | /* clear old position */ |
485 | rb->lcd_mono_bitmap(jewel[0], | 497 | rb->lcd_mono_bitmap(jewel[0], |
486 | x*TILE_SZ+horzmod*(k-TILE_SZ/8), | 498 | x*TILE_WIDTH+horzmod*(k-TILE_WIDTH/8), |
487 | y*TILE_SZ+vertmod*(k-TILE_SZ/8), | 499 | y*TILE_HEIGHT+vertmod*(k-TILE_HEIGHT/8), |
488 | TILE_SZ, TILE_SZ); | 500 | TILE_WIDTH, TILE_HEIGHT); |
489 | rb->lcd_mono_bitmap(jewel[0], | 501 | rb->lcd_mono_bitmap(jewel[0], |
490 | (x+horzmod)*TILE_SZ+horzmod*(k-TILE_SZ/8)*-1, | 502 | (x+horzmod)*TILE_WIDTH-horzmod*(k-TILE_WIDTH/8), |
491 | (y+vertmod)*TILE_SZ+vertmod*(k-TILE_SZ/8)*-1, | 503 | (y+vertmod)*TILE_HEIGHT-vertmod*(k-TILE_HEIGHT/8), |
492 | TILE_SZ, TILE_SZ); | 504 | TILE_WIDTH, TILE_HEIGHT); |
493 | /* draw new position */ | 505 | /* draw new position */ |
494 | rb->lcd_mono_bitmap(jewel[bj->playboard[x][y+1].type], | 506 | rb->lcd_mono_bitmap(jewel[bj->playboard[x][y+1].type], |
495 | x*TILE_SZ+horzmod*k, | 507 | x*TILE_WIDTH+horzmod*k, |
496 | y*TILE_SZ+vertmod*k, | 508 | y*TILE_HEIGHT+vertmod*k, |
497 | TILE_SZ, TILE_SZ); | 509 | TILE_WIDTH, TILE_HEIGHT); |
498 | rb->lcd_set_drawmode(DRMODE_FG); | 510 | rb->lcd_set_drawmode(DRMODE_FG); |
499 | rb->lcd_mono_bitmap(jewel[bj->playboard | 511 | rb->lcd_mono_bitmap(jewel[bj->playboard |
500 | [x+horzmod][y+1+vertmod].type], | 512 | [x+horzmod][y+1+vertmod].type], |
501 | (x+horzmod)*TILE_SZ+horzmod*k*-1, | 513 | (x+horzmod)*TILE_WIDTH-horzmod*k, |
502 | (y+vertmod)*TILE_SZ+vertmod*k*-1, | 514 | (y+vertmod)*TILE_HEIGHT-vertmod*k, |
503 | TILE_SZ, TILE_SZ); | 515 | TILE_WIDTH, TILE_HEIGHT); |
504 | rb->lcd_set_drawmode(DRMODE_SOLID); | 516 | rb->lcd_set_drawmode(DRMODE_SOLID); |
505 | 517 | ||
506 | rb->lcd_update(); | 518 | rb->lcd_update(); |
@@ -915,12 +927,12 @@ int bejeweled(struct game_context* bj) { | |||
915 | /* display the cursor */ | 927 | /* display the cursor */ |
916 | if(selected) { | 928 | if(selected) { |
917 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | 929 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); |
918 | rb->lcd_fillrect(x*TILE_SZ, y*TILE_SZ, TILE_SZ, TILE_SZ); | 930 | rb->lcd_fillrect(x*TILE_WIDTH, y*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT); |
919 | rb->lcd_set_drawmode(DRMODE_SOLID); | 931 | rb->lcd_set_drawmode(DRMODE_SOLID); |
920 | } else { | 932 | } else { |
921 | rb->lcd_drawrect(x*TILE_SZ, y*TILE_SZ, TILE_SZ, TILE_SZ); | 933 | rb->lcd_drawrect(x*TILE_WIDTH, y*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT); |
922 | } | 934 | } |
923 | rb->lcd_update_rect(x*TILE_SZ, y*TILE_SZ, TILE_SZ, TILE_SZ); | 935 | rb->lcd_update_rect(x*TILE_WIDTH, y*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT); |
924 | 936 | ||
925 | /* handle game button presses */ | 937 | /* handle game button presses */ |
926 | button = rb->button_get(true); | 938 | button = rb->button_get(true); |