summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/SOURCES6
-rw-r--r--apps/plugins/lib/playergfx.c6
-rw-r--r--apps/plugins/lib/playergfx.h1
-rw-r--r--apps/plugins/rockblox.c132
4 files changed, 103 insertions, 42 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index a157adb06a..d2ccf81f62 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -9,6 +9,9 @@ firmware_flash.c
9logo.c 9logo.c
10metronome.c 10metronome.c
11mosaique.c 11mosaique.c
12#if (LCD_WIDTH != 240) && ((LCD_WIDTH != 128) || (LCD_HEIGHT != 64))
13rockblox.c
14#endif
12rockbox_flash.c 15rockbox_flash.c
13search.c 16search.c
14snow.c 17snow.c
@@ -56,9 +59,6 @@ solitaire.c
56sokoban.c 59sokoban.c
57star.c 60star.c
58starfield.c 61starfield.c
59#if (LCD_WIDTH != 240) && ((LCD_WIDTH != 128) || (LCD_HEIGHT != 64))
60rockblox.c
61#endif
62#if CONFIG_LCD == LCD_SSD1815 62#if CONFIG_LCD == LCD_SSD1815
63video.c 63video.c
64#endif 64#endif
diff --git a/apps/plugins/lib/playergfx.c b/apps/plugins/lib/playergfx.c
index b6e7ccfc64..1df7a3be4c 100644
--- a/apps/plugins/lib/playergfx.c
+++ b/apps/plugins/lib/playergfx.c
@@ -85,6 +85,12 @@ void pgfx_display(int cx, int cy)
85 pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]); 85 pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]);
86} 86}
87 87
88void pgfx_display_block(int cx, int cy, int x, int y)
89{
90 pgfx_rb->lcd_putc(cx, cy, gfx_chars[char_height * x + y]);
91}
92
93
88/*** Update functions ***/ 94/*** Update functions ***/
89 95
90void pgfx_update(void) 96void pgfx_update(void)
diff --git a/apps/plugins/lib/playergfx.h b/apps/plugins/lib/playergfx.h
index 198d98e4ad..5f49831609 100644
--- a/apps/plugins/lib/playergfx.h
+++ b/apps/plugins/lib/playergfx.h
@@ -29,6 +29,7 @@
29bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight); 29bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight);
30void pgfx_release(void); 30void pgfx_release(void);
31void pgfx_display(int cx, int cy); 31void pgfx_display(int cx, int cy);
32void pgfx_display_block(int cx, int cy, int x, int y);
32void pgfx_update(void); 33void pgfx_update(void);
33 34
34void pgfx_set_drawmode(int mode); 35void pgfx_set_drawmode(int mode);
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c
index 1277b328c2..3bdae489f3 100644
--- a/apps/plugins/rockblox.c
+++ b/apps/plugins/rockblox.c
@@ -20,13 +20,10 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21#include "plugin.h" 21#include "plugin.h"
22#include "highscore.h" 22#include "highscore.h"
23 23#include "playergfx.h"
24#ifdef HAVE_LCD_BITMAP
25 24
26PLUGIN_HEADER 25PLUGIN_HEADER
27 26
28extern const fb_data rockblox_background[];
29
30#if (CONFIG_KEYPAD == IPOD_3G_PAD) || \ 27#if (CONFIG_KEYPAD == IPOD_3G_PAD) || \
31 (CONFIG_KEYPAD == IPOD_4G_PAD) 28 (CONFIG_KEYPAD == IPOD_4G_PAD)
32 29
@@ -66,6 +63,17 @@ extern const fb_data rockblox_background[];
66#define ROCKBLOX_DROP BUTTON_ON 63#define ROCKBLOX_DROP BUTTON_ON
67#define ROCKBLOX_RESTART BUTTON_F1 64#define ROCKBLOX_RESTART BUTTON_F1
68 65
66#elif CONFIG_KEYPAD == PLAYER_PAD
67
68#define ROCKBLOX_OFF BUTTON_STOP
69#define ROCKBLOX_ROTATE_RIGHT BUTTON_PLAY
70#define ROCKBLOX_ROTATE_LEFT (BUTTON_ON|BUTTON_PLAY)
71#define ROCKBLOX_DOWN BUTTON_MENU
72#define ROCKBLOX_LEFT BUTTON_LEFT
73#define ROCKBLOX_RIGHT BUTTON_RIGHT
74#define ROCKBLOX_DROP_PRE BUTTON_ON
75#define ROCKBLOX_DROP (BUTTON_ON|BUTTON_REL)
76
69#elif CONFIG_KEYPAD == ONDIO_PAD 77#elif CONFIG_KEYPAD == ONDIO_PAD
70 78
71#define ROCKBLOX_OFF BUTTON_OFF 79#define ROCKBLOX_OFF BUTTON_OFF
@@ -101,10 +109,13 @@ extern const fb_data rockblox_background[];
101 109
102#endif 110#endif
103 111
104#define BLOCKS_NUM 7 112#define BLOCKS_NUM 7
105#define EMPTY_BLOCK 7 113#define EMPTY_BLOCK 7
106 114
107#define BOARD_WIDTH 10 115#define BOARD_WIDTH 10
116
117#ifdef HAVE_LCD_BITMAP
118
108#define BOARD_HEIGHT 20 119#define BOARD_HEIGHT 20
109 120
110#if (LCD_WIDTH == 320) && (LCD_HEIGHT == 240) 121#if (LCD_WIDTH == 320) && (LCD_HEIGHT == 240)
@@ -201,10 +212,27 @@ extern const fb_data rockblox_background[];
201 212
202#endif 213#endif
203 214
204/* Pictures */ 215#ifndef LEVEL_X
205#ifdef HAVE_LCD_COLOR 216#define LEVEL_X LABEL_X
206#define SPLASH_SCREEN PLUGIN_DIR "/rockblox/splash.bmp" 217#endif
207#define PIC_SCREEN PLUGIN_DIR "/rockblox/screen.bmp" 218
219#define MYLCD(fn) rb->lcd_ ## fn
220
221extern const fb_data rockblox_background[];
222
223#else /* HAVE_LCD_CHARCELLS */
224
225#define BOARD_HEIGHT 14
226
227#define BLOCK_WIDTH 1
228#define BLOCK_HEIGHT 1
229#define BOARD_X 5
230#define BOARD_Y 0
231#define PREVIEW_X 15
232#define PREVIEW_Y 1
233
234#define MYLCD(fn) pgfx_ ## fn
235
208#endif 236#endif
209 237
210/* <<Explanation on Rockblox shapes>> 238/* <<Explanation on Rockblox shapes>>
@@ -251,8 +279,12 @@ int wheel_events = 0, last_wheel_event = 0;
251bool wheel_enabled = false; 279bool wheel_enabled = false;
252#endif 280#endif
253 281
254static const short scoring[4] = { /* scoring for each number of lines */ 282static const short scoring[4] = { /* scoring for each number of lines */
283#if BOARD_HEIGHT == 20
255 40 /* single */ , 100 /* double */ , 300 /* triple */ , 1200 /* rockblox */ 284 40 /* single */ , 100 /* double */ , 300 /* triple */ , 1200 /* rockblox */
285#elif BOARD_HEIGHT == 14 /* Player special values */
286 60 /* single */ , 150 /* double */ , 500 /* triple */ , 2000 /* rockblox */
287#endif
256}; 288};
257 289
258struct figure 290struct figure
@@ -371,6 +403,8 @@ static void init_board (void)
371static void show_details (void) 403static void show_details (void)
372{ 404{
373 char str[25]; /* for strings */ 405 char str[25]; /* for strings */
406
407#ifdef HAVE_LCD_BITMAP
374#if LCD_DEPTH >= 2 408#if LCD_DEPTH >= 2
375 rb->lcd_set_foreground (LCD_BLACK); 409 rb->lcd_set_foreground (LCD_BLACK);
376 rb->lcd_set_background (LCD_WHITE); 410 rb->lcd_set_background (LCD_WHITE);
@@ -378,13 +412,15 @@ static void show_details (void)
378 rb->snprintf (str, sizeof (str), "%d", score); 412 rb->snprintf (str, sizeof (str), "%d", score);
379 rb->lcd_putsxy (LABEL_X, SCORE_Y, str); 413 rb->lcd_putsxy (LABEL_X, SCORE_Y, str);
380 rb->snprintf (str, sizeof (str), "%d", level); 414 rb->snprintf (str, sizeof (str), "%d", level);
381#ifdef LEVEL_X
382 rb->lcd_putsxy (LEVEL_X, LEVEL_Y, str); 415 rb->lcd_putsxy (LEVEL_X, LEVEL_Y, str);
383#else
384 rb->lcd_putsxy (LABEL_X, LEVEL_Y, str);
385#endif
386 rb->snprintf (str, sizeof (str), "%d", lines); 416 rb->snprintf (str, sizeof (str), "%d", lines);
387 rb->lcd_putsxy (LABEL_X, LINES_Y, str); 417 rb->lcd_putsxy (LABEL_X, LINES_Y, str);
418#else /* HAVE_LCD_CHARCELLS */
419 rb->snprintf (str, sizeof (str), "L%d/%d", level, lines);
420 rb->lcd_puts (5, 0, str);
421 rb->snprintf (str, sizeof (str), "S%d", score);
422 rb->lcd_puts (5, 1, str);
423#endif
388} 424}
389 425
390static void init_rockblox (void) 426static void init_rockblox (void)
@@ -395,7 +431,17 @@ static void init_rockblox (void)
395 gameover = false; 431 gameover = false;
396 nf = t_rand (BLOCKS_NUM); 432 nf = t_rand (BLOCKS_NUM);
397 init_board (); 433 init_board ();
434#ifdef HAVE_LCD_BITMAP
398 rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT); 435 rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT);
436#else /* HAVE_LCD_CHARCELLS */
437 pgfx_display (0, 0);
438 pgfx_display_block (3, 0, 3, 1);
439 pgfx_display_block (4, 0, 3, 0);
440 pgfx_clear_display();
441 pgfx_fillrect (3, 0, 2, 14);
442 pgfx_fillrect (15, 7, 2, 7);
443 pgfx_update();
444#endif
399 show_details (); 445 show_details ();
400} 446}
401 447
@@ -444,33 +490,21 @@ static void refresh_board (void)
444#if LCD_DEPTH >= 2 490#if LCD_DEPTH >= 2
445 rb->lcd_set_foreground (LCD_BLACK); 491 rb->lcd_set_foreground (LCD_BLACK);
446#elif LCD_DEPTH == 1 492#elif LCD_DEPTH == 1
447 rb->lcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID); 493 MYLCD(set_drawmode) (DRMODE_SOLID | DRMODE_INVERSEVID);
448#endif 494#endif
449 495
450 rb->lcd_fillrect (BOARD_X, 1, BOARD_WIDTH * BLOCK_WIDTH, BOARD_Y); 496 MYLCD(fillrect) (BOARD_X, BOARD_Y, BOARD_WIDTH * BLOCK_WIDTH,
497 BOARD_HEIGHT * BLOCK_HEIGHT);
451 498
452#if LCD_DEPTH == 1 499#if LCD_DEPTH == 1
453 rb->lcd_set_drawmode (DRMODE_SOLID); 500 MYLCD(set_drawmode) (DRMODE_SOLID);
454#endif 501#endif
455 502
456 for (i = 0; i < BOARD_WIDTH; i++) 503 for (i = 0; i < BOARD_WIDTH; i++)
457 for (j = 0; j < BOARD_HEIGHT; j++) { 504 for (j = 0; j < BOARD_HEIGHT; j++) {
458 block = board[j][i]; 505 block = board[j][i];
459 if (block == EMPTY_BLOCK) { 506 if (block != EMPTY_BLOCK) {
460#if LCD_DEPTH >= 2 507#ifdef HAVE_LCD_BITMAP
461 rb->lcd_set_foreground (LCD_BLACK);
462#elif LCD_DEPTH == 1
463 rb->lcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID);
464#endif
465
466 rb->lcd_fillrect (BOARD_X + i * BLOCK_WIDTH,
467 BOARD_Y + j * BLOCK_HEIGHT, BLOCK_WIDTH,
468 BLOCK_HEIGHT);
469
470#if LCD_DEPTH == 1
471 rb->lcd_set_drawmode (DRMODE_SOLID);
472#endif
473 } else {
474#if LCD_DEPTH >= 2 508#if LCD_DEPTH >= 2
475 /* middle drawing */ 509 /* middle drawing */
476 rb->lcd_set_foreground (figures[block].color[1]); 510 rb->lcd_set_foreground (figures[block].color[1]);
@@ -498,12 +532,16 @@ static void refresh_board (void)
498 rb->lcd_hline (BOARD_X + i * BLOCK_WIDTH + 1, 532 rb->lcd_hline (BOARD_X + i * BLOCK_WIDTH + 1,
499 BOARD_X + (i + 1) * BLOCK_WIDTH - 1, 533 BOARD_X + (i + 1) * BLOCK_WIDTH - 1,
500 BOARD_Y + (j + 1) * BLOCK_HEIGHT - 1); 534 BOARD_Y + (j + 1) * BLOCK_HEIGHT - 1);
535#else /* HAVE_LCD_CHARCELLS */
536 pgfx_drawpixel (BOARD_X + i, BOARD_Y + j);
537#endif
501 } 538 }
502 } 539 }
503 540
504 for (i = 0; i < 4; i++) { 541 for (i = 0; i < 4; i++) {
505 x = getRelativeX (cf, i, co) + cx; 542 x = getRelativeX (cf, i, co) + cx;
506 y = getRelativeY (cf, i, co) + cy; 543 y = getRelativeY (cf, i, co) + cy;
544#ifdef HAVE_LCD_BITMAP
507#if LCD_DEPTH >= 2 545#if LCD_DEPTH >= 2
508 rb->lcd_set_foreground (figures[cf].color[1]); /* middle drawing */ 546 rb->lcd_set_foreground (figures[cf].color[1]); /* middle drawing */
509#endif 547#endif
@@ -527,8 +565,11 @@ static void refresh_board (void)
527 rb->lcd_hline (BOARD_X + x * BLOCK_WIDTH + 1, 565 rb->lcd_hline (BOARD_X + x * BLOCK_WIDTH + 1,
528 BOARD_X + (x + 1) * BLOCK_WIDTH - 1, 566 BOARD_X + (x + 1) * BLOCK_WIDTH - 1,
529 BOARD_Y + (y + 1) * BLOCK_HEIGHT - 1); 567 BOARD_Y + (y + 1) * BLOCK_HEIGHT - 1);
568#else /* HAVE_LCD_CHARCELLS */
569 pgfx_drawpixel (BOARD_X + x, BOARD_Y + y);
570#endif
530 } 571 }
531 rb->lcd_update (); 572 MYLCD(update) ();
532} 573}
533 574
534static bool canMoveTo (int x, int y, int newOrientation) 575static bool canMoveTo (int x, int y, int newOrientation)
@@ -552,14 +593,14 @@ static void draw_next_block (void)
552#if LCD_DEPTH >= 2 593#if LCD_DEPTH >= 2
553 rb->lcd_set_foreground (LCD_BLACK); 594 rb->lcd_set_foreground (LCD_BLACK);
554#elif LCD_DEPTH == 1 595#elif LCD_DEPTH == 1
555 rb->lcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID); 596 MYLCD(set_drawmode) (DRMODE_SOLID | DRMODE_INVERSEVID);
556#endif 597#endif
557 598
558 /* 4x4 */ 599 /* 4x4 */
559 rb->lcd_fillrect (PREVIEW_X, PREVIEW_Y, BLOCK_WIDTH * 4, BLOCK_HEIGHT * 4); 600 MYLCD(fillrect) (PREVIEW_X, PREVIEW_Y, BLOCK_WIDTH * 4, BLOCK_HEIGHT * 4);
560 601
561#if LCD_DEPTH == 1 602#if LCD_DEPTH == 1
562 rb->lcd_set_drawmode (DRMODE_SOLID); 603 MYLCD(set_drawmode) (DRMODE_SOLID);
563#endif 604#endif
564 605
565 /* draw the lightgray rectangles */ 606 /* draw the lightgray rectangles */
@@ -581,6 +622,7 @@ static void draw_next_block (void)
581 for (i = 0; i < 4; i++) { 622 for (i = 0; i < 4; i++) {
582 rx = getRelativeX (nf, i, 0) + 2; 623 rx = getRelativeX (nf, i, 0) + 2;
583 ry = getRelativeY (nf, i, 0) + 2; 624 ry = getRelativeY (nf, i, 0) + 2;
625#ifdef HAVE_LCD_BITMAP
584#if LCD_DEPTH >= 2 626#if LCD_DEPTH >= 2
585 rb->lcd_set_foreground (figures[nf].color[1]); /* middle drawing */ 627 rb->lcd_set_foreground (figures[nf].color[1]); /* middle drawing */
586#endif 628#endif
@@ -605,6 +647,9 @@ static void draw_next_block (void)
605 rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH + 1, 647 rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH + 1,
606 PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1, 648 PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1,
607 PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1); 649 PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1);
650#else /* HAVE_LCD_CHARCELLS */
651 pgfx_drawpixel (PREVIEW_X + rx, PREVIEW_Y + ry);
652#endif
608 } 653 }
609 654
610} 655}
@@ -851,7 +896,15 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
851 896
852 rb->srand (*rb->current_tick); 897 rb->srand (*rb->current_tick);
853 898
899#ifdef HAVE_LCD_BITMAP
854 rb->lcd_setfont (FONT_SYSFIXED); 900 rb->lcd_setfont (FONT_SYSFIXED);
901#else
902 if (!pgfx_init(rb, 4, 2))
903 {
904 rb->splash(HZ*2, true, "Old LCD :(");
905 return PLUGIN_OK;
906 }
907#endif
855 /* Permanently enable the backlight (unless the user has turned it off) */ 908 /* Permanently enable the backlight (unless the user has turned it off) */
856 if (rb->global_settings->backlight_timeout > 0) 909 if (rb->global_settings->backlight_timeout > 0)
857 rb->backlight_set_timeout (1); 910 rb->backlight_set_timeout (1);
@@ -859,12 +912,13 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
859 init_rockblox (); 912 init_rockblox ();
860 ret = rockblox_loop (); 913 ret = rockblox_loop ();
861 914
862 /* Lets use the default font */ 915#ifdef HAVE_LCD_BITMAP
863 rb->lcd_setfont (FONT_UI); 916 rb->lcd_setfont (FONT_UI);
917#else
918 pgfx_release();
919#endif
864 /* Restore user's original backlight setting */ 920 /* Restore user's original backlight setting */
865 rb->backlight_set_timeout (rb->global_settings->backlight_timeout); 921 rb->backlight_set_timeout (rb->global_settings->backlight_timeout);
866 922
867 return ret; 923 return ret;
868} 924}
869
870#endif