summaryrefslogtreecommitdiff
path: root/apps/plugins/mazezam.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mazezam.c')
-rw-r--r--apps/plugins/mazezam.c64
1 files changed, 46 insertions, 18 deletions
diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c
index ac7e651fbc..92f9def274 100644
--- a/apps/plugins/mazezam.c
+++ b/apps/plugins/mazezam.c
@@ -22,27 +22,51 @@
22#include "plugin.h" 22#include "plugin.h"
23#include "lib/configfile.h" 23#include "lib/configfile.h"
24#include "lib/helper.h" 24#include "lib/helper.h"
25#include "lib/pluginlib_actions.h"
26#include "lib/playback_control.h" 25#include "lib/playback_control.h"
27 26
28/* Include standard plugin macro */ 27/* Include standard plugin macro */
29PLUGIN_HEADER 28PLUGIN_HEADER
30 29
31/* The plugin actions of interest. */ 30#if (CONFIG_KEYPAD == IPOD_4G_PAD) || \
31 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
32# define MAZEZAM_MENU (BUTTON_SELECT | BUTTON_MENU)
33# define MAZEZAM_RIGHT BUTTON_RIGHT
34# define MAZEZAM_LEFT BUTTON_LEFT
35# define MAZEZAM_UP BUTTON_MENU
36# define MAZEZAM_DOWN BUTTON_PLAY
37
38#elif (CONFIG_KEYPAD == IPOD_3G_PAD)
39# define MAZE_QUIT BUTTON_MENU
40# define MAZE_RIGHT BUTTON_RIGHT
41# define MAZE_LEFT BUTTON_LEFT
42# define MAZE_UP BUTTON_SCROLL_BACK
43# define MAZE_DOWN BUTTON_SCROLL_FWD
44
45#elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
46# define MAZEZAM_MENU (BUTTON_HOME | BUTTON_REPEAT)
47# define MAZEZAM_RIGHT BUTTON_RIGHT
48# define MAZEZAM_LEFT BUTTON_LEFT
49# define MAZEZAM_UP BUTTON_UP
50# define MAZEZAM_DOWN BUTTON_DOWN
51
52#elif (CONFIG_KEYPAD == SANSA_E200_PAD)
53# define MAZEZAM_MENU BUTTON_POWER
54# define MAZEZAM_SOLVE BUTTON_SELECT
55# define MAZEZAM_RIGHT BUTTON_RIGHT
56# define MAZEZAM_LEFT BUTTON_LEFT
57# define MAZEZAM_UP BUTTON_UP
58# define MAZEZAM_DOWN BUTTON_DOWN
59
60#else
61# include "lib/pluginlib_actions.h"
62# define MAZEZAM_MENU PLA_QUIT
63# define MAZEZAM_RIGHT PLA_RIGHT
64# define MAZEZAM_LEFT PLA_LEFT
65# define MAZEZAM_UP PLA_UP
66# define MAZEZAM_DOWN PLA_DOWN
32const struct button_mapping *plugin_contexts[] 67const struct button_mapping *plugin_contexts[]
33= {generic_directions, generic_actions}; 68= {generic_directions, generic_actions};
34 69#endif
35/* Use the standard plugin buttons rather than a hard-to-maintain list of
36 * MazezaM specific buttons. */
37#define MAZEZAM_UP PLA_UP
38#define MAZEZAM_UP_REPEAT PLA_UP_REPEAT
39#define MAZEZAM_DOWN PLA_DOWN
40#define MAZEZAM_DOWN_REPEAT PLA_DOWN_REPEAT
41#define MAZEZAM_LEFT PLA_LEFT
42#define MAZEZAM_LEFT_REPEAT PLA_LEFT_REPEAT
43#define MAZEZAM_RIGHT PLA_RIGHT
44#define MAZEZAM_RIGHT_REPEAT PLA_RIGHT_REPEAT
45#define MAZEZAM_MENU PLA_QUIT
46 70
47/* All the text is here */ 71/* All the text is here */
48#define MAZEZAM_TEXT_GAME_OVER "Game Over" 72#define MAZEZAM_TEXT_GAME_OVER "Game Over"
@@ -541,12 +565,16 @@ static void level_loop(struct level_info* li, short* shift, short *x, short *y)
541 while (state >= STATE_IN_LEVEL) { 565 while (state >= STATE_IN_LEVEL) {
542 draw_level(li, shift, *x, *y); 566 draw_level(li, shift, *x, *y);
543 rb->lcd_update(); 567 rb->lcd_update();
568#ifdef __PLUGINLIB_ACTIONS_H__
544 button = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 2); 569 button = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 2);
570#else
571 button = rb->button_get(true);
572#endif
545 blocked = false; 573 blocked = false;
546 574
547 switch (button) { 575 switch (button) {
548 case MAZEZAM_UP: 576 case MAZEZAM_UP:
549 case MAZEZAM_UP_REPEAT: 577 case (MAZEZAM_UP|BUTTON_REPEAT):
550 if ((*y > 0) && (*x >= 0) && (*x < li->width)) { 578 if ((*y > 0) && (*x >= 0) && (*x < li->width)) {
551 for (i = 0; i < li->cd.l_num[*y-1]; i++) 579 for (i = 0; i < li->cd.l_num[*y-1]; i++)
552 blocked = blocked || 580 blocked = blocked ||
@@ -560,7 +588,7 @@ static void level_loop(struct level_info* li, short* shift, short *x, short *y)
560 588
561 589
562 case MAZEZAM_DOWN: 590 case MAZEZAM_DOWN:
563 case MAZEZAM_DOWN_REPEAT: 591 case (MAZEZAM_DOWN|BUTTON_REPEAT):
564 if ((*y < li->height-1) && (*x >= 0) && (*x < li->width)) { 592 if ((*y < li->height-1) && (*x >= 0) && (*x < li->width)) {
565 for (i = 0; i < li->cd.l_num[*y+1]; i++) 593 for (i = 0; i < li->cd.l_num[*y+1]; i++)
566 blocked = blocked || 594 blocked = blocked ||
@@ -572,7 +600,7 @@ static void level_loop(struct level_info* li, short* shift, short *x, short *y)
572 break; 600 break;
573 601
574 case MAZEZAM_LEFT: 602 case MAZEZAM_LEFT:
575 case MAZEZAM_LEFT_REPEAT: 603 case (MAZEZAM_LEFT|BUTTON_REPEAT):
576 if (*x > 0) { 604 if (*x > 0) {
577 for (i = 0; i < li->cd.l_num[*y]; i++) 605 for (i = 0; i < li->cd.l_num[*y]; i++)
578 blocked = blocked || 606 blocked = blocked ||
@@ -587,7 +615,7 @@ static void level_loop(struct level_info* li, short* shift, short *x, short *y)
587 break; 615 break;
588 616
589 case MAZEZAM_RIGHT: 617 case MAZEZAM_RIGHT:
590 case MAZEZAM_RIGHT_REPEAT: 618 case (MAZEZAM_RIGHT|BUTTON_REPEAT):
591 if (*x < li->width-1) { 619 if (*x < li->width-1) {
592 for (i = 0; i < li->cd.l_num[*y]; i++) 620 for (i = 0; i < li->cd.l_num[*y]; i++)
593 blocked = blocked || 621 blocked = blocked ||