summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZakk Roberts <midk@rockbox.org>2006-05-23 03:33:02 +0000
committerZakk Roberts <midk@rockbox.org>2006-05-23 03:33:02 +0000
commit74d86f719de4fe157d646fea17514b10edac5254 (patch)
tree1e2c921066d68ad05b8123d872a284fd2704911f
parenta86919ae2966af11c6b484a81caf5dc9c95d3e09 (diff)
downloadrockbox-74d86f719de4fe157d646fea17514b10edac5254.tar.gz
rockbox-74d86f719de4fe157d646fea17514b10edac5254.zip
Assorted changes by Mikael Magnusson and I. * When moving through filled space, stop moving at any edge. * Changed background color to a more standard lightish blue. * Use user's font in the menu unless it's too big. * iPods: Use scroll wheel in menu instead of Menu/Play being Up/Down. * Exit button no longer always completely quits the plugin; returns you to the menu if you're in a game, or quits if you're at the menu. * A couple other little things.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9975 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/xobox.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c
index e99ad246aa..bf339caba5 100644
--- a/apps/plugins/xobox.c
+++ b/apps/plugins/xobox.c
@@ -39,10 +39,12 @@ PLUGIN_HEADER
39#define RIGHT BUTTON_RIGHT 39#define RIGHT BUTTON_RIGHT
40#define PAUSE BUTTON_SELECT 40#define PAUSE BUTTON_SELECT
41#define SELECT BUTTON_SELECT 41#define SELECT BUTTON_SELECT
42#define MENU_UP BUTTON_SCROLL_FWD
43#define MENU_DOWN BUTTON_SCROLL_BACK
42#define UP BUTTON_MENU 44#define UP BUTTON_MENU
43#define DOWN BUTTON_PLAY 45#define DOWN BUTTON_PLAY
44 46
45#elif CONFIG_KEYPAD == IAUDIO_X5_PAD 47#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
46 48
47#define QUIT BUTTON_POWER 49#define QUIT BUTTON_POWER
48#define LEFT BUTTON_LEFT 50#define LEFT BUTTON_LEFT
@@ -95,10 +97,10 @@ PLUGIN_HEADER
95#define BOARD_Y (LCD_HEIGHT-BOARD_H*CUBE_SIZE)/2 97#define BOARD_Y (LCD_HEIGHT-BOARD_H*CUBE_SIZE)/2
96 98
97#ifdef HAVE_LCD_COLOR 99#ifdef HAVE_LCD_COLOR
98#define CLR_RED LCD_RGBPACK(255,0,0) /* used to imply danger */ 100#define CLR_RED LCD_RGBPACK(255,0,0) /* used to imply danger */
99#define CLR_BLUE LCD_RGBPACK(0,0,128) /* used for menu selection */ 101#define CLR_BLUE LCD_RGBPACK(0,0,128) /* used for menu selection */
100#define CLR_CYAN LCD_RGBPACK(0,128,128) /* used for frame and filling */ 102#define CLR_CYAN LCD_RGBPACK(125, 145, 180) /* used for frame and filling */
101#define PLR_COL LCD_WHITE /* color used for the player */ 103#define PLR_COL LCD_WHITE /* color used for the player */
102#else 104#else
103#define CLR_RED LCD_DARKGRAY /* used to imply danger */ 105#define CLR_RED LCD_DARKGRAY /* used to imply danger */
104#define CLR_BLUE LCD_BLACK /* used for menu selection */ 106#define CLR_BLUE LCD_BLACK /* used for menu selection */
@@ -194,7 +196,7 @@ static bool push (struct pos *p)
194static void emptyStack (void) 196static void emptyStack (void)
195{ 197{
196 stackPointer = 0; 198 stackPointer = 0;
197 /* int x, y; 199 /* int x, y;
198 while(pop(&x, &y)); */ 200 while(pop(&x, &y)); */
199} 201}
200 202
@@ -454,7 +456,7 @@ static void complete_trail (int fill)
454 boardcopy[div (qixes[i].y - BOARD_Y, CUBE_SIZE)][div 456 boardcopy[div (qixes[i].y - BOARD_Y, CUBE_SIZE)][div
455 (qixes[i].x - BOARD_X, 457 (qixes[i].x - BOARD_X,
456 CUBE_SIZE)] = QIX; 458 CUBE_SIZE)] = QIX;
457 459
458 for (j = 1; j < BOARD_H - 1; j++) 460 for (j = 1; j < BOARD_H - 1; j++)
459 for (i = 0; i < BOARD_W - 0; i++) 461 for (i = 0; i < BOARD_W - 0; i++)
460 if (board[j][i] != FILLED) { 462 if (board[j][i] != FILLED) {
@@ -653,6 +655,10 @@ static inline void move_board (void)
653 /* start drawing */ 655 /* start drawing */
654 player.drawing = true; 656 player.drawing = true;
655 board[newj][newi] = TRAIL; 657 board[newj][newi] = TRAIL;
658 /* if the block after next is empty and we're moving onto filled, stop */
659 } else if ((board[newj][newi] == FILLED)
660 && (board[newj + newj-player.j][newi + newi-player.i] == EMPTIED)) {
661 player.move = MOVE_NO;
656 } 662 }
657 player.i = newi; 663 player.i = newi;
658 player.j = newj; 664 player.j = newj;
@@ -665,7 +671,7 @@ static inline void move_board (void)
665 player.level++; 671 player.level++;
666 init_board (); 672 init_board ();
667 refresh_board (); 673 refresh_board ();
668 rb->splash (HZ * 2, true, "READY?"); 674 rb->splash (HZ * 2, true, "Ready?");
669 } 675 }
670} 676}
671 677
@@ -675,32 +681,46 @@ static inline void move_board (void)
675#define MENU_QUIT 1 681#define MENU_QUIT 1
676static int game_menu (void) 682static int game_menu (void)
677{ 683{
678 static char menu[MAIN_MENU_SIZE][15] = { 684 static char menu[MAIN_MENU_SIZE][15] = {
679 "Start New Game", 685 "Start New Game",
680 "Quit" 686 "Quit"
681 }; 687 };
682 688
683 int button, selection = 0, sw, sh, i; 689 int button, selection = 0, sw, sh, i;
684 bool quit = false; 690 bool quit = false;
685 rb->lcd_getstringsize ("A", NULL, &sh); 691
686 rb->lcd_getstringsize ("XOBOX", &sw, NULL); 692 rb->lcd_setfont(FONT_UI);
693 rb->lcd_getstringsize("A", &sw, &sh);
694 if(sw*20 > LCD_WIDTH || sh*4 > LCD_HEIGHT)
695 rb->lcd_setfont(FONT_SYSFIXED);
696
697 rb->lcd_getstringsize ("XOBOX", &sw, &sh);
687 sh++; 698 sh++;
688 rb->lcd_set_background (LCD_WHITE); 699 rb->lcd_set_background (LCD_WHITE);
700 rb->lcd_set_foreground (LCD_BLACK);
689 rb->lcd_clear_display (); 701 rb->lcd_clear_display ();
690 rb->lcd_putsxy (LCD_WIDTH / 2 - sw / 2, 2, "XOBOX"); 702 rb->lcd_putsxy (LCD_WIDTH / 2 - sw / 2, 2, "XOBOX");
691 while (!quit) { 703 while (!quit) {
692 for (i = 0; i < MAIN_MENU_SIZE; i++) { 704 for (i = 0; i < MAIN_MENU_SIZE; i++) {
693 rb->lcd_set_foreground ((i == selection ? LCD_WHITE : LCD_BLACK)); 705 rb->lcd_set_foreground ((i == selection ? LCD_WHITE : LCD_BLACK));
694 rb->lcd_set_background ((i == selection ? CLR_BLUE : LCD_WHITE)); 706 rb->lcd_set_background ((i == selection ? CLR_BLUE : LCD_WHITE));
695 rb->lcd_putsxy (9, sh + 4 + i * sh, menu[i]); 707 rb->lcd_putsxy (10, sh + 4 + i * sh, menu[i]);
696 } 708 }
697 rb->lcd_update (); 709 rb->lcd_update ();
698 button = rb->button_get (true); 710 button = rb->button_get (true);
699 switch (button) { 711 switch (button) {
712#ifdef MENU_UP
713 case MENU_UP:
714#else
700 case UP: 715 case UP:
716#endif
701 selection = (selection + MAIN_MENU_SIZE - 1) % MAIN_MENU_SIZE; 717 selection = (selection + MAIN_MENU_SIZE - 1) % MAIN_MENU_SIZE;
702 break; 718 break;
719#ifdef MENU_UP
720 case MENU_DOWN:
721#else
703 case DOWN: 722 case DOWN:
723#endif
704 selection = (selection + 1) % MAIN_MENU_SIZE; 724 selection = (selection + 1) % MAIN_MENU_SIZE;
705 break; 725 break;
706 case SELECT: 726 case SELECT:
@@ -724,9 +744,10 @@ static void init_game (void)
724 player.lives = 3; 744 player.lives = 3;
725 player.gameover = false; 745 player.gameover = false;
726 player.drawing = false; 746 player.drawing = false;
747 rb->lcd_setfont(FONT_SYSFIXED);
727 init_board (); 748 init_board ();
728 refresh_board (); 749 refresh_board ();
729 rb->splash (HZ * 2, true, "READY?"); 750 rb->splash (HZ * 2, true, "Ready?");
730} 751}
731 752
732/* general keypad handler loop */ 753/* general keypad handler loop */
@@ -755,11 +776,14 @@ static int xobox_loop (void)
755 case PAUSE: 776 case PAUSE:
756 pause = !pause; 777 pause = !pause;
757 if (pause) 778 if (pause)
758 rb->splash (HZ, true, "PAUSED"); 779 rb->splash (HZ, true, "Paused");
759 break; 780 break;
760 case QUIT: 781 case QUIT:
761 quit = true; 782 ret = game_menu ();
762 return PLUGIN_OK; 783 if (ret == MENU_START)
784 init_game ();
785 else
786 quit = true;
763 break; 787 break;
764 default: 788 default:
765 if (rb->default_event_handler (button) == SYS_USB_CONNECTED) 789 if (rb->default_event_handler (button) == SYS_USB_CONNECTED)
@@ -771,7 +795,7 @@ static int xobox_loop (void)
771 refresh_board (); 795 refresh_board ();
772 } 796 }
773 if (player.gameover) { 797 if (player.gameover) {
774 rb->splash (HZ, true, "GAME OVER"); 798 rb->splash (HZ, true, "Game Over!");
775 ret = game_menu (); 799 ret = game_menu ();
776 if (ret == MENU_START) 800 if (ret == MENU_START)
777 init_game (); 801 init_game ();
@@ -791,8 +815,7 @@ static int xobox_loop (void)
791/* plugin main procedure */ 815/* plugin main procedure */
792enum plugin_status plugin_start (struct plugin_api *api, void *parameter) 816enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
793{ 817{
794 int ret; 818 int ret = PLUGIN_OK;
795
796 819
797 (void) parameter; 820 (void) parameter;
798 rb = api; 821 rb = api;
@@ -803,8 +826,6 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
803 if (rb->global_settings->backlight_timeout > 0) 826 if (rb->global_settings->backlight_timeout > 0)
804 rb->backlight_set_timeout (1); 827 rb->backlight_set_timeout (1);
805 828
806 ret = PLUGIN_OK;
807
808 randomize (); 829 randomize ();
809 if (game_menu () == MENU_START) { 830 if (game_menu () == MENU_START) {
810 init_game (); 831 init_game ();