summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/xobox.c134
1 files changed, 85 insertions, 49 deletions
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c
index f0b1553aa9..7038ee0bb6 100644
--- a/apps/plugins/xobox.c
+++ b/apps/plugins/xobox.c
@@ -909,37 +909,6 @@ static inline void move_board (void)
909 } 909 }
910} 910}
911 911
912/* the main menu */
913static int game_menu (void)
914{
915 MENUITEM_STRINGLIST(menu, "XOBOX Menu", NULL, "Start New Game",
916 "Speed","Difficulty","Playback Control","Quit");
917 int selection = 0;
918#ifdef HAVE_LCD_COLOR
919 rb->lcd_set_foreground (rb->global_settings->fg_color);
920 rb->lcd_set_background (rb->global_settings->bg_color);
921#elif LCD_DEPTH>=2
922 rb->lcd_set_foreground(LCD_BLACK);
923 rb->lcd_set_background(LCD_WHITE);
924#endif
925 for (;;) {
926 rb->do_menu(&menu,&selection, NULL, false);
927 if (selection==1)
928 rb->set_int ("Speed", "", UNIT_INT, &speed, NULL, 1, 1, 10, NULL);
929 else if (selection==2)
930 rb->set_int ("Difficulty", "", UNIT_INT, &difficulty, NULL,
931 5, 50, 95, NULL);
932 else if (selection==3)
933 playback_control (NULL);
934 else
935 break;
936 }
937 if (selection != MENU_START) {
938 selection = MENU_QUIT;
939 }
940 return selection;
941}
942
943/* init game's variables */ 912/* init game's variables */
944static void init_game (void) 913static void init_game (void)
945{ 914{
@@ -948,19 +917,98 @@ static void init_game (void)
948 player.lives = 3; 917 player.lives = 3;
949 player.gameover = false; 918 player.gameover = false;
950 player.drawing = false; 919 player.drawing = false;
951 rb->lcd_setfont(FONT_SYSFIXED);
952 init_board (); 920 init_board ();
953 refresh_board (); 921 refresh_board ();
954 rb->splash (HZ * 2, "Ready?"); 922 rb->splash (HZ * 2, "Ready?");
955} 923}
956 924
925/* the main menu */
926static int xobox_menu(bool ingame)
927{
928 rb->button_clear_queue();
929 int choice = 0;
930 if (ingame) {
931 MENUITEM_STRINGLIST (main_menu, "Xobox Menu", NULL,
932 "Resume Game",
933 "Restart Level",
934 "Speed",
935 "Difficult",
936 "Playback Control",
937 "Quit");
938
939 while (true) {
940 choice = rb->do_menu(&main_menu, &choice, NULL, false);
941 switch (choice) {
942 case 0:
943 return 0;
944 case 1:
945 init_game ();
946 return 0;
947 case 2:
948 rb->set_int ("Speed", "", UNIT_INT, &speed, NULL, 1, 1, 10, NULL);
949 break;
950 case 3:
951 rb->set_int ("Difficulty", "", UNIT_INT, &difficulty, NULL,
952 5, 50, 95, NULL);
953 break;
954 case 4:
955 playback_control(NULL);
956 break;
957 case 5:
958 return 1;
959 case MENU_ATTACHED_USB:
960 return 1;
961 default:
962 break;
963 }
964 }
965 }
966 else {
967 MENUITEM_STRINGLIST (main_menu, "Xobox Menu", NULL,
968 "Start Game",
969 "Speed",
970 "Difficult",
971 "Playback Control",
972 "Quit");
973
974 while (true) {
975 choice = rb->do_menu(&main_menu, &choice, NULL, false);
976 switch (choice) {
977 case 0:
978 init_game ();
979 return 0;
980 case 1:
981 rb->set_int ("Speed", "", UNIT_INT, &speed, NULL, 1, 1, 10, NULL);
982 break;
983 case 2:
984 rb->set_int ("Difficulty", "", UNIT_INT, &difficulty, NULL,
985 5, 50, 95, NULL);
986 break;
987 case 3:
988 playback_control(NULL);
989 break;
990 case 4:
991 return 1;
992 case MENU_ATTACHED_USB:
993 return 1;
994 default:
995 break;
996 }
997 }
998 }
999}
1000
957/* general keypad handler loop */ 1001/* general keypad handler loop */
958static int xobox_loop (void) 1002static int xobox_loop (void)
959{ 1003{
960 int button = 0, ret; 1004 int button = 0;
961 bool pause = false; 1005 bool pause = false;
962 int end; 1006 int end;
963 1007
1008 if (xobox_menu(false)==1) {
1009 return PLUGIN_OK;
1010 }
1011
964 while (!quit) { 1012 while (!quit) {
965 end = *rb->current_tick + ((11-speed)*HZ)/100; 1013 end = *rb->current_tick + ((11-speed)*HZ)/100;
966 1014
@@ -995,13 +1043,8 @@ static int xobox_loop (void)
995 rb->splash (HZ, "Paused"); 1043 rb->splash (HZ, "Paused");
996 break; 1044 break;
997 case QUIT: 1045 case QUIT:
998 ret = game_menu (); 1046 if (xobox_menu(true)==1) {
999 if (ret == MENU_START)
1000 init_game ();
1001 else
1002 {
1003 quit = true; 1047 quit = true;
1004 continue;
1005 } 1048 }
1006 break; 1049 break;
1007 default: 1050 default:
@@ -1015,11 +1058,9 @@ static int xobox_loop (void)
1015 } 1058 }
1016 if (player.gameover) { 1059 if (player.gameover) {
1017 rb->splash (HZ, "Game Over!"); 1060 rb->splash (HZ, "Game Over!");
1018 ret = game_menu (); 1061 if (xobox_menu(false)==1) {
1019 if (ret == MENU_START)
1020 init_game ();
1021 else
1022 quit = true; 1062 quit = true;
1063 }
1023 } 1064 }
1024 1065
1025 if (end > *rb->current_tick) 1066 if (end > *rb->current_tick)
@@ -1046,13 +1087,8 @@ enum plugin_status plugin_start (const void *parameter)
1046 /* Turn off backlight timeout */ 1087 /* Turn off backlight timeout */
1047 backlight_force_on(); /* backlight control in lib/helper.c */ 1088 backlight_force_on(); /* backlight control in lib/helper.c */
1048 1089
1049 quit = false;
1050
1051 randomize (); 1090 randomize ();
1052 if (game_menu () == MENU_START) { 1091 ret = xobox_loop ();
1053 init_game ();
1054 ret = xobox_loop ();
1055 }
1056 1092
1057 /* Turn on backlight timeout (revert to settings) */ 1093 /* Turn on backlight timeout (revert to settings) */
1058 backlight_use_settings(); /* backlight control in lib/helper.c */ 1094 backlight_use_settings(); /* backlight control in lib/helper.c */