summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/SOURCES2
-rw-r--r--apps/plugins/bitmaps/native/SOURCES51
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.12x12x16.bmpbin0 -> 3078 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.14x14.bmpbin4366 -> 0 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.14x14x16.bmpbin0 -> 4366 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.4x4x1.bmpbin0 -> 174 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.5x5x16.bmpbin0 -> 614 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.5x5x2.bmpbin0 -> 350 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.6x6.bmpbin894 -> 0 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.6x6x1.bmpbin0 -> 230 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.6x6x16.bmpbin0 -> 894 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.6x6x2.bmpbin894 -> 406 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.7x7x16.bmpbin0 -> 1230 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.9x9.bmpbin1818 -> 0 bytes
-rw-r--r--apps/plugins/bitmaps/native/sokoban_tiles.9x9x16.bmpbin0 -> 1818 bytes
-rw-r--r--apps/plugins/sokoban.c160
16 files changed, 93 insertions, 120 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 92884a9..58543c0 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -76,9 +76,7 @@ sliding_puzzle.c
snake.c
snake2.c
solitaire.c
-#ifndef SANSA_C200
sokoban.c
-#endif
star.c
starfield.c
#if CONFIG_LCD == LCD_SSD1815
diff --git a/apps/plugins/bitmaps/native/SOURCES b/apps/plugins/bitmaps/native/SOURCES
index 74b57b3..6762e74 100644
--- a/apps/plugins/bitmaps/native/SOURCES
+++ b/apps/plugins/bitmaps/native/SOURCES
@@ -437,22 +437,45 @@ snake2_bottom.160x128x2.bmp
#endif
/* Sokoban*/
+/* biggest tilesize: 20 columns x 16 rows + stat box need to fit (minimum)
+* allow clipping of up to 4 pixels in favour of using a bigger tilesize
+* stat box width of 32 in horizontal & height of 25 pixels in vertical layout
+* currently the horizontal layout fits best on all wider than high displays
+ */
+
+#if LCD_WIDTH > LCD_HEIGHT
+#define SOKOBAN_TILESIZE ((LCD_WIDTH + 4 -32)/20)
+#else
+#define SOKOBAN_TILESIZE ((LCD_WIDTH + 4)/20)
+#endif
+
#ifdef HAVE_LCD_COLOR
-#if (LCD_HEIGHT >= 224) && (LCD_WIDTH >= 312) || \
- (LCD_HEIGHT >= 249) && (LCD_WIDTH >= 280)
-sokoban_tiles.14x14.bmp
-#elif (LCD_HEIGHT >= 144) && (LCD_WIDTH >= 212) || \
- (LCD_HEIGHT >= 169) && (LCD_WIDTH >= 180-4)
-sokoban_tiles.9x9.bmp
-#elif (LCD_HEIGHT >= 96 && LCD_WIDTH >= 152) || \
- (LCD_HEIGHT >= 121 && LCD_WIDTH >= 120)
-sokoban_tiles.6x6.bmp
-#endif
-#elif LCD_DEPTH >= 2 && \
- ((LCD_HEIGHT >= 96 && LCD_WIDTH >= 152) || \
- (LCD_HEIGHT >= 121 && LCD_WIDTH >= 120))
+#if SOKOBAN_TILESIZE >= 14
+sokoban_tiles.14x14x16.bmp
+#elif SOKOBAN_TILESIZE >= 12
+sokoban_tiles.12x12x16.bmp
+#elif SOKOBAN_TILESIZE >= 9
+sokoban_tiles.9x9x16.bmp
+#elif SOKOBAN_TILESIZE >= 7
+sokoban_tiles.7x7x16.bmp
+#elif SOKOBAN_TILESIZE >= 6
+sokoban_tiles.6x6x16.bmp
+#elif SOKOBAN_TILESIZE >= 5
+sokoban_tiles.5x5x16.bmp
+#endif /* tilesize */
+#elif LCD_DEPTH > 1 /*greyscale */
+#if SOKOBAN_TILESIZE >= 6
sokoban_tiles.6x6x2.bmp
-#endif
+#elif SOKOBAN_TILESIZE >= 5
+sokoban_tiles.5x5x2.bmp
+#endif /* tilesize */
+#else /* mono */
+#if SOKOBAN_TILESIZE >= 6
+sokoban_tiles.6x6x1.bmp
+#elif SOKOBAN_TILESIZE >= 4
+sokoban_tiles.4x4x1.bmp
+#endif /* tilesize */
+#endif /* HAVE_COLOR */
/* Solitaire and Blackjack */
#ifdef HAVE_LCD_COLOR
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.12x12x16.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.12x12x16.bmp
new file mode 100644
index 0000000..8ac740b
--- /dev/null
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.12x12x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.14x14.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.14x14.bmp
deleted file mode 100644
index 47dc548..0000000
--- a/apps/plugins/bitmaps/native/sokoban_tiles.14x14.bmp
+++ /dev/null
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.14x14x16.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.14x14x16.bmp
new file mode 100644
index 0000000..5dc2ebe
--- /dev/null
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.14x14x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.4x4x1.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.4x4x1.bmp
new file mode 100644
index 0000000..b5a79aa
--- /dev/null
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.4x4x1.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.5x5x16.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.5x5x16.bmp
new file mode 100644
index 0000000..57bc1ac
--- /dev/null
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.5x5x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.5x5x2.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.5x5x2.bmp
new file mode 100644
index 0000000..d68f78d
--- /dev/null
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.5x5x2.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.6x6.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.6x6.bmp
deleted file mode 100644
index 38c0457..0000000
--- a/apps/plugins/bitmaps/native/sokoban_tiles.6x6.bmp
+++ /dev/null
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.6x6x1.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.6x6x1.bmp
new file mode 100644
index 0000000..fdebba6
--- /dev/null
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.6x6x1.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.6x6x16.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.6x6x16.bmp
new file mode 100644
index 0000000..0c47663
--- /dev/null
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.6x6x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.6x6x2.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.6x6x2.bmp
index ccf184d..034783d 100644
--- a/apps/plugins/bitmaps/native/sokoban_tiles.6x6x2.bmp
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.6x6x2.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.7x7x16.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.7x7x16.bmp
new file mode 100644
index 0000000..ca8bc88
--- /dev/null
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.7x7x16.bmp
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.9x9.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.9x9.bmp
deleted file mode 100644
index 9675db8..0000000
--- a/apps/plugins/bitmaps/native/sokoban_tiles.9x9.bmp
+++ /dev/null
Binary files differ
diff --git a/apps/plugins/bitmaps/native/sokoban_tiles.9x9x16.bmp b/apps/plugins/bitmaps/native/sokoban_tiles.9x9x16.bmp
new file mode 100644
index 0000000..3d63b08
--- /dev/null
+++ b/apps/plugins/bitmaps/native/sokoban_tiles.9x9x16.bmp
Binary files differ
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index bc5bf42..9459f1e 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -22,53 +22,30 @@
#include "plugin.h"
#include "lib/playback_control.h"
-#ifdef HAVE_LCD_BITMAP
-
PLUGIN_HEADER
-#if LCD_DEPTH >= 2 && ((LCD_HEIGHT >= 96 && LCD_WIDTH >= 152) || \
- (LCD_HEIGHT >= 121 && LCD_WIDTH >= 120))
-extern const fb_data sokoban_tiles[];
-#endif
-
#define SOKOBAN_TITLE "Sokoban"
#define SOKOBAN_LEVELS_FILE PLUGIN_GAMES_DIR "/sokoban.levels"
#define SOKOBAN_SAVE_FILE PLUGIN_GAMES_DIR "/sokoban.save"
#define SOKOBAN_SAVE_FOLDER "/games"
-/* Magnify is the number of pixels for each block.
+#include "sokoban_tiles.h"
+#define SOKOBAN_TILESIZE BMPWIDTH_sokoban_tiles
+/* SOKOBAN_TILESIZE is the number of pixels for each block.
* Set dynamically so all targets can support levels
* that fill their entire screen, less the stat box.
* 16 rows & 20 cols minimum */
-#if (LCD_HEIGHT >= 224) && (LCD_WIDTH >= 320)
-#define MAGNIFY 14
-#define ROWS (LCD_HEIGHT/MAGNIFY)
-#define COLS ((LCD_WIDTH-40)/MAGNIFY)
-#elif (LCD_HEIGHT >= 249) && (LCD_WIDTH >= 280)
-#define MAGNIFY 14
-#define ROWS ((LCD_HEIGHT-25)/MAGNIFY)
-#define COLS (LCD_WIDTH/MAGNIFY)
-#elif (LCD_HEIGHT >= 144) && (LCD_WIDTH >= 220)
-#define MAGNIFY 9
-#define ROWS (LCD_HEIGHT/MAGNIFY)
-#define COLS ((LCD_WIDTH-40)/MAGNIFY)
-#elif (LCD_HEIGHT >= 169) && (LCD_WIDTH+4 >= 180) /* plus 4 for sansa */
-#define MAGNIFY 9
-#define ROWS ((LCD_HEIGHT-25)/MAGNIFY)
-#define COLS ((LCD_WIDTH+4)/MAGNIFY)
-#elif (LCD_HEIGHT >= 96) && (LCD_WIDTH >= 160)
-#define MAGNIFY 6
-#define ROWS (LCD_HEIGHT/MAGNIFY)
-#define COLS ((LCD_WIDTH-40)/MAGNIFY)
-#elif (LCD_HEIGHT >= 121) && (LCD_WIDTH >= 120)
-#define MAGNIFY 6
-#define ROWS ((LCD_HEIGHT-25)/MAGNIFY)
-#define COLS (LCD_WIDTH/MAGNIFY)
+#if LCD_WIDTH > LCD_HEIGHT /* horizontal layout*/
+#define ROWS (LCD_HEIGHT/SOKOBAN_TILESIZE)
+#if (LCD_WIDTH+4) >= (20*SOKOBAN_TILESIZE+40) /* wide or narrow stats box */
+#define COLS ((LCD_WIDTH-40)/SOKOBAN_TILESIZE)
#else
-#define MAGNIFY 4
-#define ROWS 16
-#define COLS 20
+#define COLS ((LCD_WIDTH-32)/SOKOBAN_TILESIZE)
+#endif
+#else /* vertical layout*/
+#define ROWS ((LCD_HEIGHT-25)/SOKOBAN_TILESIZE)
+#define COLS (LCD_WIDTH/SOKOBAN_TILESIZE)
#endif
/* Use either all but 16k of the plugin buffer for level data
@@ -233,6 +210,22 @@ extern const fb_data sokoban_tiles[];
#define BUTTON_SAVE BUTTON_SELECT
#define BUTTON_SAVE_NAME "SELECT"
+#elif CONFIG_KEYPAD == SANSA_C200_PAD
+#define SOKOBAN_LEFT BUTTON_LEFT
+#define SOKOBAN_RIGHT BUTTON_RIGHT
+#define SOKOBAN_UP BUTTON_UP
+#define SOKOBAN_DOWN BUTTON_DOWN
+#define SOKOBAN_MENU BUTTON_POWER
+#define SOKOBAN_UNDO_PRE BUTTON_SELECT
+#define SOKOBAN_UNDO (BUTTON_SELECT | BUTTON_REL)
+#define SOKOBAN_REDO BUTTON_REC
+#define SOKOBAN_LEVEL_DOWN BUTTON_VOL_DOWN
+#define SOKOBAN_LEVEL_REPEAT (BUTTON_SELECT | BUTTON_RIGHT)
+#define SOKOBAN_LEVEL_UP BUTTON_VOL_UP
+#define SOKOBAN_PAUSE BUTTON_SELECT
+#define BUTTON_SAVE BUTTON_SELECT
+#define BUTTON_SAVE_NAME "SELECT"
+
#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
#define SOKOBAN_LEFT BUTTON_LEFT
#define SOKOBAN_RIGHT BUTTON_RIGHT
@@ -797,15 +790,7 @@ static void update_screen(void)
int c, r;
int rows, cols;
-#if LCD_DEPTH < 2 || ((LCD_HEIGHT < 96 || LCD_WIDTH < 152) && \
- (LCD_HEIGHT < 121 || LCD_WIDTH < 120))
- int i, j;
- int max = MAGNIFY - 1;
- int middle = max/2;
- int ldelta = (middle + 1)/2;
-#endif
-
-#if LCD_WIDTH - (COLS*MAGNIFY) < 32
+#if LCD_WIDTH - (COLS*SOKOBAN_TILESIZE) < 32
#define STAT_HEIGHT 25
#define STAT_X (LCD_WIDTH - 120)/2
#define STAT_Y (LCD_HEIGHT - STAT_HEIGHT)
@@ -825,10 +810,10 @@ static void update_screen(void)
rb->lcd_drawrect(STAT_X + 37, STAT_Y, 39, STAT_HEIGHT);
rb->lcd_drawrect(STAT_X + 75, STAT_Y, 45, STAT_HEIGHT);
#else
-#if LCD_WIDTH - (COLS*MAGNIFY) > 40
+#if LCD_WIDTH - (COLS*SOKOBAN_TILESIZE) > 40
#define STAT_X (LCD_WIDTH - 40)
#else
-#define STAT_X COLS*MAGNIFY
+#define STAT_X COLS*SOKOBAN_TILESIZE
#endif
#if LCD_HEIGHT >= 70
#define STAT_Y (LCD_HEIGHT - 70)/2
@@ -861,87 +846,56 @@ static void update_screen(void)
/* load the board to the screen */
for (rows = 0; rows < ROWS; rows++) {
for (cols = 0; cols < COLS; cols++) {
- c = cols*MAGNIFY +
- (BOARD_WIDTH - current_info.level.width*MAGNIFY)/2;
- r = rows*MAGNIFY +
- (BOARD_HEIGHT - current_info.level.height*MAGNIFY)/2;
+ c = cols*SOKOBAN_TILESIZE +
+ (BOARD_WIDTH - current_info.level.width*SOKOBAN_TILESIZE)/2;
+ r = rows*SOKOBAN_TILESIZE +
+ (BOARD_HEIGHT - current_info.level.height*SOKOBAN_TILESIZE)/2;
switch(current_info.board[rows][cols]) {
case 'X': /* blank space outside of level */
break;
-#if LCD_DEPTH >= 2 && ((LCD_HEIGHT >= 96 && LCD_WIDTH >= 152) || \
- (LCD_HEIGHT >= 121 && LCD_WIDTH >= 120))
case ' ': /* floor */
- rb->lcd_bitmap_part(sokoban_tiles, 0, 0*MAGNIFY, MAGNIFY,
- c, r, MAGNIFY, MAGNIFY);
+ rb->lcd_bitmap_part(sokoban_tiles, 0, 0*SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE, c, r, SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE);
break;
case '#': /* wall */
- rb->lcd_bitmap_part(sokoban_tiles, 0, 1*MAGNIFY, MAGNIFY,
- c, r, MAGNIFY, MAGNIFY);
+ rb->lcd_bitmap_part(sokoban_tiles, 0, 1*SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE, c, r, SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE);
break;
case '$': /* box */
- rb->lcd_bitmap_part(sokoban_tiles, 0, 2*MAGNIFY, MAGNIFY,
- c, r, MAGNIFY, MAGNIFY);
+ rb->lcd_bitmap_part(sokoban_tiles, 0, 2*SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE, c, r, SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE);
break;
case '*': /* box on goal */
- rb->lcd_bitmap_part(sokoban_tiles, 0, 3*MAGNIFY, MAGNIFY,
- c, r, MAGNIFY, MAGNIFY);
+ rb->lcd_bitmap_part(sokoban_tiles, 0, 3*SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE, c, r, SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE);
break;
case '.': /* goal */
- rb->lcd_bitmap_part(sokoban_tiles, 0, 4*MAGNIFY, MAGNIFY,
- c, r, MAGNIFY, MAGNIFY);
+ rb->lcd_bitmap_part(sokoban_tiles, 0, 4*SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE, c, r, SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE);
break;
case '@': /* player */
- rb->lcd_bitmap_part(sokoban_tiles, 0, 5*MAGNIFY, MAGNIFY,
- c, r, MAGNIFY, MAGNIFY);
- break;
-
- case '+': /* player on goal */
- rb->lcd_bitmap_part(sokoban_tiles, 0, 6*MAGNIFY, MAGNIFY,
- c, r, MAGNIFY, MAGNIFY);
- break;
-#else
- case '#': /* wall */
- for (i = c; i < c + MAGNIFY; i++)
- for (j = r; j < r + MAGNIFY; j++)
- if ((i ^ j) & 1)
- rb->lcd_drawpixel(i, j);
- break;
-
- case '$': /* box */
- rb->lcd_drawrect(c, r, MAGNIFY, MAGNIFY);
+ rb->lcd_bitmap_part(sokoban_tiles, 0, 5*SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE, c, r, SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE);
break;
- case '*': /* box on goal */
- rb->lcd_drawrect(c, r, MAGNIFY, MAGNIFY);
- rb->lcd_drawrect(c + MAGNIFY/2 - 1, r + MAGNIFY/2 - 1,
- MAGNIFY/2, MAGNIFY/2);
- break;
-
- case '.': /* goal */
- rb->lcd_drawrect(c + MAGNIFY/2 - 1, r + MAGNIFY/2 - 1,
- MAGNIFY/2, MAGNIFY/2);
- break;
-
- case '@': /* player */
case '+': /* player on goal */
- rb->lcd_drawline(c, r + middle, c + max, r + middle);
- rb->lcd_drawline(c + middle, r, c + middle,
- r + max - ldelta);
- rb->lcd_drawline(c + max - middle, r, c + max - middle,
- r + max - ldelta);
- rb->lcd_drawline(c + middle, r + max - ldelta,
- c + middle - ldelta, r + max);
- rb->lcd_drawline(c + max - middle, r + max - ldelta,
- c + max - middle + ldelta, r + max);
+ rb->lcd_bitmap_part(sokoban_tiles, 0, 6*SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE, c, r, SOKOBAN_TILESIZE,
+ SOKOBAN_TILESIZE);
break;
-#endif
}
}
}
@@ -1617,5 +1571,3 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
return sokoban_loop();
}
-
-#endif