summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/star.c111
1 files changed, 89 insertions, 22 deletions
diff --git a/apps/plugins/star.c b/apps/plugins/star.c
index 0848b3398e..3f55c3171c 100644
--- a/apps/plugins/star.c
+++ b/apps/plugins/star.c
@@ -89,11 +89,11 @@ PLUGIN_HEADER
89#define STAR_QUIT BUTTON_OFF 89#define STAR_QUIT BUTTON_OFF
90#define STAR_UP BUTTON_UP 90#define STAR_UP BUTTON_UP
91#define STAR_DOWN BUTTON_DOWN 91#define STAR_DOWN BUTTON_DOWN
92#define STAR_TOGGLE_CONTROL_PRE BUTTON_MODE 92#define STAR_TOGGLE_CONTROL BUTTON_MODE
93#define STAR_TOGGLE_CONTROL (BUTTON_MODE | BUTTON_REL) 93#define STAR_TOGGLE_CONTROL2 BUTTON_SELECT
94#define STAR_LEVEL_UP (BUTTON_MODE | BUTTON_RIGHT) 94#define STAR_LEVEL_UP (BUTTON_ON | BUTTON_RIGHT)
95#define STAR_LEVEL_DOWN (BUTTON_MODE | BUTTON_LEFT) 95#define STAR_LEVEL_DOWN (BUTTON_ON | BUTTON_LEFT)
96#define STAR_LEVEL_REPEAT (BUTTON_MODE | BUTTON_UP) 96#define STAR_LEVEL_REPEAT (BUTTON_ON | BUTTON_SELECT)
97#define STAR_MENU_RUN BUTTON_RIGHT 97#define STAR_MENU_RUN BUTTON_RIGHT
98#define STAR_MENU_RUN2 BUTTON_SELECT 98#define STAR_MENU_RUN2 BUTTON_SELECT
99 99
@@ -519,7 +519,8 @@ static void star_display_text(char *str, bool waitkey)
519 key = rb->button_get(true); 519 key = rb->button_get(true);
520 switch (key) 520 switch (key)
521 { 521 {
522 case STAR_MENU_RUN: 522 case STAR_QUIT:
523 case BUTTON_LEFT:
523 case STAR_DOWN: 524 case STAR_DOWN:
524 go_on = true; 525 go_on = true;
525 break; 526 break;
@@ -707,7 +708,7 @@ static int star_run_game(void)
707 case STAR_RC_QUIT: 708 case STAR_RC_QUIT:
708#endif 709#endif
709 case STAR_QUIT: 710 case STAR_QUIT:
710 return 0; 711 return -1;
711 712
712 case BUTTON_LEFT: 713 case BUTTON_LEFT:
713 move_x = -1; 714 move_x = -1;
@@ -881,6 +882,68 @@ static int star_run_game(void)
881} 882}
882 883
883/** 884/**
885 * Display the choose level screen.
886 */
887static int star_choose_level(void)
888{
889 int level = current_level;
890 int key = BUTTON_NONE;
891 char str_info[32];
892 int lastkey = BUTTON_NONE;
893
894 while (true)
895 {
896 rb->lcd_clear_display();
897 rb->snprintf(str_info, sizeof(str_info), "Level:%02d / %02d",
898 level,STAR_LEVEL_COUNT);
899 rb->lcd_putsxy(0, 0, str_info);
900 rb->lcd_update();
901 key = rb->button_get(true);
902 switch (key)
903 {
904 case STAR_QUIT:
905 case BUTTON_LEFT:
906 return -1;
907 break;
908
909 case STAR_MENU_RUN:
910#ifdef STAR_MENU_RUN2
911 case STAR_MENU_RUN2:
912#endif
913#ifdef STAR_MENU_RUN3
914 case STAR_MENU_RUN3:
915#endif
916 current_level=level;
917 return star_run_game();
918 break;
919
920 case STAR_UP:
921 case BUTTON_REPEAT | STAR_UP:
922 if(level< STAR_LEVEL_COUNT - 1)
923 level++;
924 break;
925
926 case STAR_DOWN:
927 case BUTTON_REPEAT | STAR_DOWN:
928 if(level> 0)
929 level--;
930 break;
931
932 default:
933 if (rb->default_event_handler(key) == SYS_USB_CONNECTED)
934 {
935 usb_detected = true;
936 return 0;
937 }
938 break;
939 }
940
941 if (key != BUTTON_NONE)
942 lastkey = key;
943 }
944}
945
946/**
884 * Display the choice menu. 947 * Display the choice menu.
885 */ 948 */
886static int star_menu(void) 949static int star_menu(void)
@@ -890,7 +953,8 @@ static int star_menu(void)
890 int i = 0; 953 int i = 0;
891 bool refresh = true; 954 bool refresh = true;
892 char anim_state = 0; 955 char anim_state = 0;
893 unsigned char *menu[4] = {"Start", "Information", "Keys", "Exit"}; 956 unsigned char *menu[5] = {"Play", "Choose Level", "Information",
957 "Keys", "Exit"};
894 int menu_count = sizeof(menu) / sizeof(unsigned char *); 958 int menu_count = sizeof(menu) / sizeof(unsigned char *);
895 int menu_offset_y; 959 int menu_offset_y;
896 int key; 960 int key;
@@ -936,20 +1000,22 @@ static int star_menu(void)
936 int oldforeground = rb->lcd_get_foreground(); 1000 int oldforeground = rb->lcd_get_foreground();
937 rb->lcd_set_foreground(LCD_BLACK); 1001 rb->lcd_set_foreground(LCD_BLACK);
938#endif 1002#endif
939 rb->lcd_fillrect(0, menu_offset_y + char_height * menu_y - 2, 15, char_height + 3); 1003 rb->lcd_fillrect(0,menu_offset_y + char_height * menu_y - 2,
1004 15, char_height + 3);
940#if LCD_DEPTH > 1 1005#if LCD_DEPTH > 1
941 rb->lcd_set_foreground(oldforeground); 1006 rb->lcd_set_foreground(oldforeground);
942#endif 1007#endif
943 } 1008 }
944 break; 1009 break;
945 case STAR_DOWN: 1010 case STAR_DOWN:
946 if (menu_y < 3) { 1011 if (menu_y < menu_count-1) {
947 move_y = 1; 1012 move_y = 1;
948#if LCD_DEPTH > 1 1013#if LCD_DEPTH > 1
949 int oldforeground = rb->lcd_get_foreground(); 1014 int oldforeground = rb->lcd_get_foreground();
950 rb->lcd_set_foreground(LCD_BLACK); 1015 rb->lcd_set_foreground(LCD_BLACK);
951#endif 1016#endif
952 rb->lcd_fillrect(0, menu_offset_y + char_height * menu_y - 1, 15, char_height + 2); 1017 rb->lcd_fillrect(0,menu_offset_y + char_height * menu_y - 1,
1018 15, char_height + 2);
953#if LCD_DEPTH > 1 1019#if LCD_DEPTH > 1
954 rb->lcd_set_foreground(oldforeground); 1020 rb->lcd_set_foreground(oldforeground);
955#endif 1021#endif
@@ -967,11 +1033,12 @@ static int star_menu(void)
967 switch (menu_y) 1033 switch (menu_y)
968 { 1034 {
969 case 0: 1035 case 0:
970 if (!star_run_game()) 1036 star_run_game();
971 return usb_detected ?
972 PLUGIN_USB_CONNECTED : PLUGIN_OK;
973 break; 1037 break;
974 case 1: 1038 case 1:
1039 star_choose_level();
1040 break;
1041 case 2:
975#if LCD_DEPTH > 1 1042#if LCD_DEPTH > 1
976 star_display_text( 1043 star_display_text(
977 "INFO\n\n" 1044 "INFO\n\n"
@@ -988,7 +1055,7 @@ static int star_menu(void)
988 "take \"o\".", true); 1055 "take \"o\".", true);
989#endif 1056#endif
990 break; 1057 break;
991 case 2: 1058 case 3:
992#if CONFIG_KEYPAD == RECORDER_PAD 1059#if CONFIG_KEYPAD == RECORDER_PAD
993 star_display_text("KEYS\n\n" 1060 star_display_text("KEYS\n\n"
994 "[ON] Toggle Ctl.\n" 1061 "[ON] Toggle Ctl.\n"
@@ -1005,11 +1072,11 @@ static int star_menu(void)
1005 "[M >] Next level", true); 1072 "[M >] Next level", true);
1006#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) 1073#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
1007 star_display_text("KEYS\n\n" 1074 star_display_text("KEYS\n\n"
1008 "[A-B] Toggle Ctl\n" 1075 "[MODE/SELECT] Toggle Ctrl\n"
1009 "[OFF] Exit\n" 1076 "[OFF] Exit\n"
1010 "[A-B <] Prev. level\n" 1077 "[ON + LEFT] Prev. level\n"
1011 "[A-B ^] Reset level\n" 1078 "[ON + SELECT] Reset level\n"
1012 "[A-B >] Next level", true); 1079 "[ON + NEXT] Next level", true);
1013#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) 1080#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD)
1014 star_display_text("KEYS\n\n" 1081 star_display_text("KEYS\n\n"
1015 "[SELECT] Toggle Ctl\n" 1082 "[SELECT] Toggle Ctl\n"
@@ -1033,7 +1100,7 @@ static int star_menu(void)
1033 "[PWR+UP] Next level", true); 1100 "[PWR+UP] Next level", true);
1034#endif 1101#endif
1035 break; 1102 break;
1036 case 3: 1103 case 4:
1037 return PLUGIN_OK; 1104 return PLUGIN_OK;
1038 } 1105 }
1039 if (usb_detected) 1106 if (usb_detected)
@@ -1049,11 +1116,11 @@ static int star_menu(void)
1049 for (i = 0 ; i < char_height ; i++) 1116 for (i = 0 ; i < char_height ; i++)
1050 { 1117 {
1051 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 1118 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
1052 rb->lcd_fillrect (2, 30, 7, 4 * 8); 1119 rb->lcd_fillrect (2, menu_offset_y, 8, menu_count * 8);
1053 rb->lcd_set_drawmode(DRMODE_FG); 1120 rb->lcd_set_drawmode(DRMODE_FG);
1054 rb->lcd_mono_bitmap(arrow_bmp[anim_arrow[(anim_state & 0x38) >> 3]], 1121 rb->lcd_mono_bitmap(arrow_bmp[anim_arrow[(anim_state & 0x38) >> 3]],
1055 2, menu_offset_y + menu_y * 8 + move_y * i, 7, 8); 1122 2, menu_offset_y + menu_y * 8 + move_y * i, 7, 8);
1056 rb->lcd_update_rect(2, 30, 8, 4 * 8); 1123 rb->lcd_update_rect(2, menu_offset_y, 8, menu_count * 8);
1057 anim_state++; 1124 anim_state++;
1058 STAR_SLEEP 1125 STAR_SLEEP
1059 } 1126 }