summaryrefslogtreecommitdiff
path: root/apps/plugins/sokoban.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sokoban.c')
-rw-r--r--apps/plugins/sokoban.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index c3d97adfa4..b450e39b54 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -24,6 +24,10 @@
24 24
25PLUGIN_HEADER 25PLUGIN_HEADER
26 26
27#ifdef HAVE_LCD_COLOR
28extern const fb_data sokoban_tiles[];
29#endif
30
27#define SOKOBAN_TITLE "Sokoban" 31#define SOKOBAN_TITLE "Sokoban"
28#define SOKOBAN_TITLE_FONT 2 32#define SOKOBAN_TITLE_FONT 2
29 33
@@ -33,7 +37,7 @@ PLUGIN_HEADER
33#define COLS 20 37#define COLS 20
34/* Use all but 8k of the plugin buffer for board data */ 38/* Use all but 8k of the plugin buffer for board data */
35#define SOKOBAN_LEVEL_SIZE (ROWS*COLS) 39#define SOKOBAN_LEVEL_SIZE (ROWS*COLS)
36#define MAX_BUFFERED_BOARDS (PLUGIN_BUFFER_SIZE - 0x2000)/SOKOBAN_LEVEL_SIZE 40#define MAX_BUFFERED_BOARDS (PLUGIN_BUFFER_SIZE - 0x3000)/SOKOBAN_LEVEL_SIZE
37#define MAX_UNDOS 5 41#define MAX_UNDOS 5
38 42
39/* variable button definitions */ 43/* variable button definitions */
@@ -423,11 +427,14 @@ static void update_screen(void)
423 int rows = 0, cols = 0; 427 int rows = 0, cols = 0;
424 char s[25]; 428 char s[25];
425 429
426#if LCD_HEIGHT == 128 /* magnify is the number of pixels for each block */ 430/* magnify is the number of pixels for each block */
427 int magnify = 6; /* 6 on h1x0, 9 on h3x0, and 4 on everything else */ 431#if LCD_HEIGHT >= 240 /* ipod 5g */
428#elif LCD_HEIGHT >= 176 432 int magnify = 14;
433#elif LCD_HEIGHT >= 176 /* h3x0, ipod color/photo */
429 int magnify = 9; 434 int magnify = 9;
430#else 435#elif LCD_HEIGHT >= 128 /* h1x0, ipod nano */
436 int magnify = 6;
437#else /* other */
431 int magnify = 4; 438 int magnify = 4;
432#endif 439#endif
433 440
@@ -443,9 +450,8 @@ static void update_screen(void)
443 450
444 case '#': /* this is a wall */ 451 case '#': /* this is a wall */
445#if HAVE_LCD_COLOR 452#if HAVE_LCD_COLOR
446 rb->lcd_set_foreground(WALL_COLOR); 453 rb->lcd_bitmap_part( sokoban_tiles, 0, 1*magnify, magnify,
447 rb->lcd_fillrect(c, b, magnify, magnify); 454 c, b, magnify, magnify );
448 rb->lcd_set_foreground(LCD_BLACK);
449#elif LCD_DEPTH > 1 455#elif LCD_DEPTH > 1
450 rb->lcd_set_foreground(MEDIUM_GRAY); 456 rb->lcd_set_foreground(MEDIUM_GRAY);
451 rb->lcd_fillrect(c, b, magnify, magnify); 457 rb->lcd_fillrect(c, b, magnify, magnify);
@@ -463,9 +469,8 @@ static void update_screen(void)
463 469
464 case '.': /* this is a home location */ 470 case '.': /* this is a home location */
465#ifdef HAVE_LCD_COLOR 471#ifdef HAVE_LCD_COLOR
466 rb->lcd_set_foreground(FREE_TARGET_COLOR); 472 rb->lcd_bitmap_part( sokoban_tiles, 0, 4*magnify, magnify,
467 rb->lcd_fillrect(c+(magnify/2)-1, b+(magnify/2)-1, magnify/2, 473 c, b, magnify, magnify );
468 magnify/2);
469#else 474#else
470 rb->lcd_drawrect(c+(magnify/2)-1, b+(magnify/2)-1, magnify/2, 475 rb->lcd_drawrect(c+(magnify/2)-1, b+(magnify/2)-1, magnify/2,
471 magnify/2); 476 magnify/2);
@@ -474,19 +479,22 @@ static void update_screen(void)
474 479
475 case '$': /* this is a box */ 480 case '$': /* this is a box */
476#ifdef HAVE_LCD_COLOR 481#ifdef HAVE_LCD_COLOR
477 rb->lcd_set_foreground(FREE_BLOCK_COLOR); 482 rb->lcd_bitmap_part( sokoban_tiles, 0, 2*magnify, magnify,
478#endif 483 c, b, magnify, magnify );
484#else
479 rb->lcd_drawrect(c, b, magnify, magnify); /* Free boxes are not filled in */ 485 rb->lcd_drawrect(c, b, magnify, magnify); /* Free boxes are not filled in */
486#endif
480 break; 487 break;
481 488
482 case '@': /* this is you */ 489 case '@': /* this is you */
483 { 490 {
491#ifdef HAVE_LCD_COLOR
492 rb->lcd_bitmap_part( sokoban_tiles, 0, 5*magnify, magnify,
493 c, b, magnify, magnify );
494#else
484 int max = magnify - 1; 495 int max = magnify - 1;
485 int middle = max / 2; 496 int middle = max / 2;
486 int ldelta = (middle + 1) / 2; 497 int ldelta = (middle + 1) / 2;
487#ifdef HAVE_LCD_COLOR
488 rb->lcd_set_foreground(CHAR_COLOR);
489#endif
490 rb->lcd_drawline(c, b+middle, c+max, b+middle); 498 rb->lcd_drawline(c, b+middle, c+max, b+middle);
491 rb->lcd_drawline(c+middle, b, c+middle, b+max-ldelta); 499 rb->lcd_drawline(c+middle, b, c+middle, b+max-ldelta);
492 rb->lcd_drawline(c+max-middle, b, 500 rb->lcd_drawline(c+max-middle, b,
@@ -495,26 +503,27 @@ static void update_screen(void)
495 c+middle-ldelta, b+max); 503 c+middle-ldelta, b+max);
496 rb->lcd_drawline(c+max-middle, b+max-ldelta, 504 rb->lcd_drawline(c+max-middle, b+max-ldelta,
497 c+max-middle+ldelta, b+max); 505 c+max-middle+ldelta, b+max);
506#endif
498 } 507 }
499 break; 508 break;
500 509
501 case '%': /* this is a box on a home spot */ 510 case '%': /* this is a box on a home spot */
502 511
503#ifdef HAVE_LCD_COLOR 512#ifdef HAVE_LCD_COLOR
504 rb->lcd_set_foreground(USED_BLOCK_COLOR); 513 rb->lcd_bitmap_part( sokoban_tiles, 0, 3*magnify, magnify,
505 rb->lcd_fillrect(c, b, magnify, magnify); 514 c, b, magnify, magnify );
506#else 515#else
507 rb->lcd_drawrect(c, b, magnify, magnify); 516 rb->lcd_drawrect(c, b, magnify, magnify);
508#endif
509#ifdef HAVE_LCD_COLOR
510 rb->lcd_set_foreground(USED_TARGET_COLOR);
511 rb->lcd_fillrect(c+(magnify/2)-1, b+(magnify/2)-1, magnify/2,
512 magnify/2);
513#else
514 rb->lcd_drawrect(c+(magnify/2)-1, b+(magnify/2)-1, magnify/2, 517 rb->lcd_drawrect(c+(magnify/2)-1, b+(magnify/2)-1, magnify/2,
515 magnify/2); 518 magnify/2);
516#endif 519#endif
517 break; 520 break;
521
522#ifdef HAVE_LCD_COLOR
523 default:
524 rb->lcd_bitmap_part( sokoban_tiles, 0, 0*magnify, magnify,
525 c, b, magnify, magnify );
526#endif
518 } 527 }
519 } 528 }
520 } 529 }