diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-05-16 17:12:07 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-05-16 17:12:07 +0000 |
commit | 732ef1e157d4b8a611e9ab4c7de799d1db36c729 (patch) | |
tree | 9769de0be5340643e710430afce9f0f75dab5209 /apps | |
parent | ba5618a2531decc23488f25f28663581f5ba36ca (diff) | |
download | rockbox-732ef1e157d4b8a611e9ab4c7de799d1db36c729.tar.gz rockbox-732ef1e157d4b8a611e9ab4c7de799d1db36c729.zip |
Use a struct for the necessary status variables for rockblox. Will make dumping the status easier for the upcoming resume addition.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20966 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/rockblox.c | 165 |
1 files changed, 96 insertions, 69 deletions
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index 119632dc38..696ba2f84d 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c | |||
@@ -586,11 +586,24 @@ extern const fb_data rockblox_background[]; | |||
586 | % %%% % | 586 | % %%% % |
587 | */ | 587 | */ |
588 | 588 | ||
589 | |||
590 | static bool gameover = false; | ||
591 | /* c=current f=figure o=orientation n=next */ | 589 | /* c=current f=figure o=orientation n=next */ |
592 | static int lines = 0, level = 0, score = 0, cx, cy, cf, co, nf; | 590 | static struct _rockblox_status |
593 | static short board[BOARD_HEIGHT][BOARD_WIDTH]; /* 20 rows of 10 blocks */ | 591 | { |
592 | int gameover; | ||
593 | int lines; | ||
594 | int level; | ||
595 | int score; | ||
596 | int cx; | ||
597 | int cy; | ||
598 | int cf; | ||
599 | int co; | ||
600 | int nf; | ||
601 | short board[BOARD_HEIGHT][BOARD_WIDTH]; /* 20 rows of 10 blocks */ | ||
602 | } rockblox_status; | ||
603 | |||
604 | /* prototypes */ | ||
605 | static void draw_next_block(void); | ||
606 | static void new_block(void); | ||
594 | 607 | ||
595 | #ifdef HAVE_SCROLLWHEEL | 608 | #ifdef HAVE_SCROLLWHEEL |
596 | int wheel_events = 0, last_wheel_event = 0; | 609 | int wheel_events = 0, last_wheel_event = 0; |
@@ -705,6 +718,7 @@ figures[BLOCKS_NUM] = { | |||
705 | /* Rockbox File System only supports full filenames inc dir */ | 718 | /* Rockbox File System only supports full filenames inc dir */ |
706 | #define HIGH_SCORE PLUGIN_GAMES_DIR "/rockblox.score" | 719 | #define HIGH_SCORE PLUGIN_GAMES_DIR "/rockblox.score" |
707 | #define MAX_HIGH_SCORES 5 | 720 | #define MAX_HIGH_SCORES 5 |
721 | |||
708 | /* Default High Scores... */ | 722 | /* Default High Scores... */ |
709 | struct highscore Highest[MAX_HIGH_SCORES]; | 723 | struct highscore Highest[MAX_HIGH_SCORES]; |
710 | 724 | ||
@@ -720,7 +734,7 @@ static void init_board (void) | |||
720 | int i, j; | 734 | int i, j; |
721 | for (i = 0; i < BOARD_WIDTH; i++) | 735 | for (i = 0; i < BOARD_WIDTH; i++) |
722 | for (j = 0; j < BOARD_HEIGHT; j++) | 736 | for (j = 0; j < BOARD_HEIGHT; j++) |
723 | board[j][i] = EMPTY_BLOCK; | 737 | rockblox_status.board[j][i] = EMPTY_BLOCK; |
724 | } | 738 | } |
725 | 739 | ||
726 | /* show the score, level and lines */ | 740 | /* show the score, level and lines */ |
@@ -733,16 +747,17 @@ static void show_details (void) | |||
733 | rb->lcd_set_foreground (LCD_BLACK); | 747 | rb->lcd_set_foreground (LCD_BLACK); |
734 | rb->lcd_set_background (LCD_WHITE); | 748 | rb->lcd_set_background (LCD_WHITE); |
735 | #endif | 749 | #endif |
736 | rb->snprintf (str, sizeof (str), "%d", score); | 750 | rb->snprintf (str, sizeof (str), "%d", rockblox_status.score); |
737 | rb->lcd_putsxy (LABEL_X, SCORE_Y, str); | 751 | rb->lcd_putsxy (LABEL_X, SCORE_Y, str); |
738 | rb->snprintf (str, sizeof (str), "%d", level); | 752 | rb->snprintf (str, sizeof (str), "%d", rockblox_status.level); |
739 | rb->lcd_putsxy (LEVEL_X, LEVEL_Y, str); | 753 | rb->lcd_putsxy (LEVEL_X, LEVEL_Y, str); |
740 | rb->snprintf (str, sizeof (str), "%d", lines); | 754 | rb->snprintf (str, sizeof (str), "%d", rockblox_status.lines); |
741 | rb->lcd_putsxy (LINES_X, LINES_Y, str); | 755 | rb->lcd_putsxy (LINES_X, LINES_Y, str); |
742 | #else /* HAVE_LCD_CHARCELLS */ | 756 | #else /* HAVE_LCD_CHARCELLS */ |
743 | rb->snprintf (str, sizeof (str), "L%d/%d", level, lines); | 757 | rb->snprintf (str, sizeof (str), "L%d/%d", rockblox_status.level, |
758 | rockblox_status.lines); | ||
744 | rb->lcd_puts (5, 0, str); | 759 | rb->lcd_puts (5, 0, str); |
745 | rb->snprintf (str, sizeof (str), "S%d", score); | 760 | rb->snprintf (str, sizeof (str), "S%d", rockblox_status.score); |
746 | rb->lcd_puts (5, 1, str); | 761 | rb->lcd_puts (5, 1, str); |
747 | #endif | 762 | #endif |
748 | } | 763 | } |
@@ -755,7 +770,7 @@ static void show_highscores (void) | |||
755 | 770 | ||
756 | for (i = MAX_HIGH_SCORES-1; i>=0; i--) | 771 | for (i = MAX_HIGH_SCORES-1; i>=0; i--) |
757 | { | 772 | { |
758 | rb->snprintf (str, sizeof (str), "%06d" _SPACE "L%1d", Highest[i].score, Highest[i].level); | 773 | rb->snprintf (str, sizeof (str), "%06d" _SPACE "L%1d",Highest[i].score, Highest[i].level); |
759 | rb->lcd_putsxy (HIGH_LABEL_X, HIGH_SCORE_Y + (10 * ((MAX_HIGH_SCORES-1) - i)), str); | 774 | rb->lcd_putsxy (HIGH_LABEL_X, HIGH_SCORE_Y + (10 * ((MAX_HIGH_SCORES-1) - i)), str); |
760 | } | 775 | } |
761 | } | 776 | } |
@@ -763,13 +778,15 @@ static void show_highscores (void) | |||
763 | 778 | ||
764 | static void init_rockblox (void) | 779 | static void init_rockblox (void) |
765 | { | 780 | { |
766 | highscore_update(score, level, Highest, MAX_HIGH_SCORES); | 781 | highscore_update(rockblox_status.score, rockblox_status.level, Highest, |
782 | MAX_HIGH_SCORES); | ||
783 | |||
784 | rockblox_status.level = 1; | ||
785 | rockblox_status.lines = 0; | ||
786 | rockblox_status.score = 0; | ||
787 | rockblox_status.nf = t_rand (BLOCKS_NUM); | ||
788 | rockblox_status.gameover = false; | ||
767 | 789 | ||
768 | level = 1; | ||
769 | lines = 0; | ||
770 | score = 0; | ||
771 | gameover = false; | ||
772 | nf = t_rand (BLOCKS_NUM); | ||
773 | init_board (); | 790 | init_board (); |
774 | #ifdef HAVE_LCD_BITMAP | 791 | #ifdef HAVE_LCD_BITMAP |
775 | rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT); | 792 | rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT); |
@@ -849,7 +866,7 @@ static void refresh_board (void) | |||
849 | 866 | ||
850 | for (i = 0; i < BOARD_WIDTH; i++) | 867 | for (i = 0; i < BOARD_WIDTH; i++) |
851 | for (j = 0; j < BOARD_HEIGHT; j++) { | 868 | for (j = 0; j < BOARD_HEIGHT; j++) { |
852 | block = board[j][i]; | 869 | block = rockblox_status.board[j][i]; |
853 | if (block != EMPTY_BLOCK) { | 870 | if (block != EMPTY_BLOCK) { |
854 | #ifdef HAVE_LCD_BITMAP | 871 | #ifdef HAVE_LCD_BITMAP |
855 | #if LCD_DEPTH >= 2 | 872 | #if LCD_DEPTH >= 2 |
@@ -886,17 +903,21 @@ static void refresh_board (void) | |||
886 | } | 903 | } |
887 | 904 | ||
888 | for (i = 0; i < 4; i++) { | 905 | for (i = 0; i < 4; i++) { |
889 | x = getRelativeX (cf, i, co) + cx; | 906 | x = getRelativeX (rockblox_status.cf, i, rockblox_status.co) |
890 | y = getRelativeY (cf, i, co) + cy; | 907 | + rockblox_status.cx; |
908 | y = getRelativeY (rockblox_status.cf, i, rockblox_status.co) | ||
909 | + rockblox_status.cy; | ||
891 | #ifdef HAVE_LCD_BITMAP | 910 | #ifdef HAVE_LCD_BITMAP |
892 | #if LCD_DEPTH >= 2 | 911 | #if LCD_DEPTH >= 2 |
893 | rb->lcd_set_foreground (figures[cf].color[1]); /* middle drawing */ | 912 | /* middle drawing */ |
913 | rb->lcd_set_foreground (figures[rockblox_status.cf].color[1]); | ||
894 | #endif | 914 | #endif |
895 | rb->lcd_fillrect (BOARD_X + x * BLOCK_WIDTH, | 915 | rb->lcd_fillrect (BOARD_X + x * BLOCK_WIDTH, |
896 | BOARD_Y + y * BLOCK_HEIGHT, | 916 | BOARD_Y + y * BLOCK_HEIGHT, |
897 | BLOCK_WIDTH, BLOCK_HEIGHT); | 917 | BLOCK_WIDTH, BLOCK_HEIGHT); |
898 | #if LCD_DEPTH >= 2 | 918 | #if LCD_DEPTH >= 2 |
899 | rb->lcd_set_foreground (figures[cf].color[0]); /* light drawing */ | 919 | /* light drawing */ |
920 | rb->lcd_set_foreground (figures[rockblox_status.cf].color[0]); | ||
900 | #endif | 921 | #endif |
901 | rb->lcd_vline (BOARD_X + x * BLOCK_WIDTH, BOARD_Y + y * BLOCK_HEIGHT, | 922 | rb->lcd_vline (BOARD_X + x * BLOCK_WIDTH, BOARD_Y + y * BLOCK_HEIGHT, |
902 | BOARD_Y + (y + 1) * BLOCK_HEIGHT - 2); | 923 | BOARD_Y + (y + 1) * BLOCK_HEIGHT - 2); |
@@ -904,7 +925,8 @@ static void refresh_board (void) | |||
904 | BOARD_X + (x + 1) * BLOCK_WIDTH - 2, | 925 | BOARD_X + (x + 1) * BLOCK_WIDTH - 2, |
905 | BOARD_Y + y * BLOCK_HEIGHT); | 926 | BOARD_Y + y * BLOCK_HEIGHT); |
906 | #if LCD_DEPTH >= 2 | 927 | #if LCD_DEPTH >= 2 |
907 | rb->lcd_set_foreground (figures[cf].color[2]); /* shadow drawing */ | 928 | /* shadow drawing */ |
929 | rb->lcd_set_foreground (figures[rockblox_status.cf].color[2]); | ||
908 | #endif | 930 | #endif |
909 | rb->lcd_vline (BOARD_X + (x + 1) * BLOCK_WIDTH - 1, | 931 | rb->lcd_vline (BOARD_X + (x + 1) * BLOCK_WIDTH - 1, |
910 | BOARD_Y + y * BLOCK_HEIGHT + 1, | 932 | BOARD_Y + y * BLOCK_HEIGHT + 1, |
@@ -923,10 +945,11 @@ static bool canMoveTo (int x, int y, int newOrientation) | |||
923 | { | 945 | { |
924 | int i, rx, ry; | 946 | int i, rx, ry; |
925 | for (i = 0; i < 4; i++) { | 947 | for (i = 0; i < 4; i++) { |
926 | ry = getRelativeY (cf, i, newOrientation) + y; | 948 | ry = getRelativeY (rockblox_status.cf, i, newOrientation) + y; |
927 | rx = getRelativeX (cf, i, newOrientation) + x; | 949 | rx = getRelativeX (rockblox_status.cf, i, newOrientation) + x; |
928 | if ((rx < 0 || rx >= BOARD_WIDTH) || | 950 | if ((rx < 0 || rx >= BOARD_WIDTH) || |
929 | (ry < 0 || ry >= BOARD_HEIGHT) || (board[ry][rx] != EMPTY_BLOCK)) | 951 | (ry < 0 || ry >= BOARD_HEIGHT) || |
952 | (rockblox_status.board[ry][rx] != EMPTY_BLOCK)) | ||
930 | return false; | 953 | return false; |
931 | } | 954 | } |
932 | return true; | 955 | return true; |
@@ -967,17 +990,17 @@ static void draw_next_block (void) | |||
967 | 990 | ||
968 | /* draw the figure */ | 991 | /* draw the figure */ |
969 | for (i = 0; i < 4; i++) { | 992 | for (i = 0; i < 4; i++) { |
970 | rx = getRelativeX (nf, i, 0) + 2; | 993 | rx = getRelativeX (rockblox_status.nf, i, 0) + 2; |
971 | ry = getRelativeY (nf, i, 0) + 2; | 994 | ry = getRelativeY (rockblox_status.nf, i, 0) + 2; |
972 | #ifdef HAVE_LCD_BITMAP | 995 | #ifdef HAVE_LCD_BITMAP |
973 | #if LCD_DEPTH >= 2 | 996 | #if LCD_DEPTH >= 2 |
974 | rb->lcd_set_foreground (figures[nf].color[1]); /* middle drawing */ | 997 | rb->lcd_set_foreground (figures[rockblox_status.nf].color[1]); /* middle drawing */ |
975 | #endif | 998 | #endif |
976 | rb->lcd_fillrect (PREVIEW_X + rx * BLOCK_WIDTH, | 999 | rb->lcd_fillrect (PREVIEW_X + rx * BLOCK_WIDTH, |
977 | PREVIEW_Y + ry * BLOCK_HEIGHT, | 1000 | PREVIEW_Y + ry * BLOCK_HEIGHT, |
978 | BLOCK_WIDTH, BLOCK_HEIGHT); | 1001 | BLOCK_WIDTH, BLOCK_HEIGHT); |
979 | #if LCD_DEPTH >= 2 | 1002 | #if LCD_DEPTH >= 2 |
980 | rb->lcd_set_foreground (figures[nf].color[0]); /* light drawing */ | 1003 | rb->lcd_set_foreground (figures[rockblox_status.nf].color[0]); /* light drawing */ |
981 | #endif | 1004 | #endif |
982 | rb->lcd_vline (PREVIEW_X + rx * BLOCK_WIDTH, | 1005 | rb->lcd_vline (PREVIEW_X + rx * BLOCK_WIDTH, |
983 | PREVIEW_Y + ry * BLOCK_HEIGHT, | 1006 | PREVIEW_Y + ry * BLOCK_HEIGHT, |
@@ -986,7 +1009,7 @@ static void draw_next_block (void) | |||
986 | PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 2, | 1009 | PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 2, |
987 | PREVIEW_Y + ry * BLOCK_HEIGHT); | 1010 | PREVIEW_Y + ry * BLOCK_HEIGHT); |
988 | #if LCD_DEPTH >= 2 | 1011 | #if LCD_DEPTH >= 2 |
989 | rb->lcd_set_foreground (figures[nf].color[2]); /* shadow drawing */ | 1012 | rb->lcd_set_foreground (figures[rockblox_status.nf].color[2]); /* shadow drawing */ |
990 | #endif | 1013 | #endif |
991 | rb->lcd_vline (PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1, | 1014 | rb->lcd_vline (PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1, |
992 | PREVIEW_Y + ry * BLOCK_HEIGHT + 1, | 1015 | PREVIEW_Y + ry * BLOCK_HEIGHT + 1, |
@@ -1004,40 +1027,47 @@ static void draw_next_block (void) | |||
1004 | /* move the block to a relative location */ | 1027 | /* move the block to a relative location */ |
1005 | static void move_block (int x, int y, int o) | 1028 | static void move_block (int x, int y, int o) |
1006 | { | 1029 | { |
1007 | if (canMoveTo (cx + x, cy + y, o)) { | 1030 | if (canMoveTo (rockblox_status.cx + x, rockblox_status.cy + y, o)) { |
1008 | cy += y; | 1031 | rockblox_status.cy += y; |
1009 | cx += x; | 1032 | rockblox_status.cx += x; |
1010 | co = o; | 1033 | rockblox_status.co = o; |
1011 | } | 1034 | } |
1012 | } | 1035 | } |
1013 | 1036 | ||
1014 | /* try to add a new block to play with (return true if gameover) */ | 1037 | /* try to add a new block to play with (return true if gameover) */ |
1015 | static void new_block (void) | 1038 | static void new_block (void) |
1016 | { | 1039 | { |
1017 | cy = 1; | 1040 | rockblox_status.cy = 1; |
1018 | cx = 5; | 1041 | rockblox_status.cx = 5; |
1019 | cf = nf; | 1042 | rockblox_status.cf = rockblox_status.nf; |
1020 | co = 0; /* start at the same orientation all time */ | 1043 | rockblox_status.co = 0; /* start at the same orientation all time */ |
1021 | nf = t_rand (BLOCKS_NUM); | 1044 | rockblox_status.nf = t_rand (BLOCKS_NUM); |
1022 | gameover = !canMoveTo (cx, cy, co); | 1045 | rockblox_status.gameover = !canMoveTo (rockblox_status.cx, |
1046 | rockblox_status.cy, rockblox_status.co); | ||
1023 | 1047 | ||
1024 | draw_next_block (); | 1048 | draw_next_block (); |
1025 | } | 1049 | } |
1026 | 1050 | ||
1027 | 1051 | ||
1028 | /* check for filled lines and do what necessary */ | 1052 | /* check for filled rockblox_status.lines and do what necessary */ |
1029 | static int check_lines (void) | 1053 | static int check_lines (void) |
1054 | |||
1030 | { | 1055 | { |
1031 | int i, j, y; | 1056 | int i, j, y; |
1032 | int rockblox = 0; | 1057 | int rockblox = 0; |
1033 | 1058 | ||
1034 | for (j = 0; j < BOARD_HEIGHT; j++) { | 1059 | for (j = 0; j < BOARD_HEIGHT; j++) { |
1035 | for (i = 0; ((i < BOARD_WIDTH) && (board[j][i] != EMPTY_BLOCK)); i++); | 1060 | for (i = 0; ((i < BOARD_WIDTH) && |
1061 | (rockblox_status.board[j][i] != EMPTY_BLOCK)); i++); | ||
1036 | if (i == BOARD_WIDTH) { /* woo hoo, we have a line */ | 1062 | if (i == BOARD_WIDTH) { /* woo hoo, we have a line */ |
1037 | rockblox++; | 1063 | rockblox++; |
1038 | for (y = j; y > 0; y--) | 1064 | for (y = j; y > 0; y--) |
1065 | { | ||
1039 | for (i = 0; i < BOARD_WIDTH; i++) | 1066 | for (i = 0; i < BOARD_WIDTH; i++) |
1040 | board[y][i] = board[y - 1][i]; /* fall line */ | 1067 | { /* fall line */ |
1068 | rockblox_status.board[y][i] = rockblox_status.board[y - 1][i]; | ||
1069 | } | ||
1070 | } | ||
1041 | } | 1071 | } |
1042 | } | 1072 | } |
1043 | 1073 | ||
@@ -1049,20 +1079,20 @@ static void move_down (void) | |||
1049 | { | 1079 | { |
1050 | int l, i, rx, ry; | 1080 | int l, i, rx, ry; |
1051 | 1081 | ||
1052 | if (!canMoveTo (cx, cy + 1, co)) { | 1082 | if (!canMoveTo (rockblox_status.cx, rockblox_status.cy + 1, rockblox_status.co)) { |
1053 | /* save figure to board */ | 1083 | /* save figure to board */ |
1054 | for (i = 0; i < 4; i++) { | 1084 | for (i = 0; i < 4; i++) { |
1055 | rx = getRelativeX (cf, i, co) + cx; | 1085 | rx = getRelativeX (rockblox_status.cf, i, rockblox_status.co) + rockblox_status.cx; |
1056 | ry = getRelativeY (cf, i, co) + cy; | 1086 | ry = getRelativeY (rockblox_status.cf, i, rockblox_status.co) + rockblox_status.cy; |
1057 | board[ry][rx] = cf; | 1087 | rockblox_status.board[ry][rx] = rockblox_status.cf; |
1058 | } | 1088 | } |
1059 | /* check if formed some lines */ | 1089 | /* check if formed some lines */ |
1060 | l = check_lines (); | 1090 | l = check_lines (); |
1061 | if (l) { | 1091 | if (l) { |
1062 | /* the original scoring from "http://en.wikipedia.org/wiki/Rockblox" */ | 1092 | /* the original scoring from "http://en.wikipedia.org/wiki/Rockblox" */ |
1063 | score += scoring[l - 1] * level; | 1093 | rockblox_status.score += scoring[l - 1] * rockblox_status.level; |
1064 | lines += l; | 1094 | rockblox_status.lines += l; |
1065 | level = (int) lines / 10 + 1; | 1095 | rockblox_status.level = (int) rockblox_status.lines / 10 + 1; |
1066 | } | 1096 | } |
1067 | 1097 | ||
1068 | /* show details */ | 1098 | /* show details */ |
@@ -1071,14 +1101,14 @@ static void move_down (void) | |||
1071 | /* generate a new figure */ | 1101 | /* generate a new figure */ |
1072 | new_block (); | 1102 | new_block (); |
1073 | } else | 1103 | } else |
1074 | move_block (0, 1, co); | 1104 | move_block (0, 1, rockblox_status.co); |
1075 | } | 1105 | } |
1076 | 1106 | ||
1077 | static int rockblox_loop (void) | 1107 | static int rockblox_loop (void) |
1078 | { | 1108 | { |
1079 | int button; | 1109 | int button; |
1080 | int lastbutton = BUTTON_NONE; | 1110 | int lastbutton = BUTTON_NONE; |
1081 | long next_down_tick = *rb->current_tick + level_speed(level); | 1111 | long next_down_tick = *rb->current_tick + level_speed(rockblox_status.level); |
1082 | 1112 | ||
1083 | new_block (); | 1113 | new_block (); |
1084 | 1114 | ||
@@ -1126,7 +1156,7 @@ static int rockblox_loop (void) | |||
1126 | /* if it's enabled, go ahead and rotate.. */ | 1156 | /* if it's enabled, go ahead and rotate.. */ |
1127 | if(wheel_enabled) | 1157 | if(wheel_enabled) |
1128 | #endif | 1158 | #endif |
1129 | move_block (0, 0, (co + 1) % figures[cf].max_or); | 1159 | move_block (0, 0, (rockblox_status.co + 1) % figures[rockblox_status.cf].max_or); |
1130 | break; | 1160 | break; |
1131 | 1161 | ||
1132 | case ROCKBLOX_ROTATE_LEFT: | 1162 | case ROCKBLOX_ROTATE_LEFT: |
@@ -1138,29 +1168,29 @@ static int rockblox_loop (void) | |||
1138 | if(wheel_enabled) | 1168 | if(wheel_enabled) |
1139 | #endif | 1169 | #endif |
1140 | move_block (0, 0, | 1170 | move_block (0, 0, |
1141 | (co + figures[cf].max_or - | 1171 | (rockblox_status.co + figures[rockblox_status.cf].max_or - |
1142 | 1) % figures[cf].max_or); | 1172 | 1) % figures[rockblox_status.cf].max_or); |
1143 | break; | 1173 | break; |
1144 | 1174 | ||
1145 | #ifdef ROCKBLOX_ROTATE_RIGHT2 | 1175 | #ifdef ROCKBLOX_ROTATE_RIGHT2 |
1146 | case ROCKBLOX_ROTATE_RIGHT2: | 1176 | case ROCKBLOX_ROTATE_RIGHT2: |
1147 | move_block (0, 0, (co + 1) % figures[cf].max_or); | 1177 | move_block (0, 0, (rockblox_status.co + 1) % figures[rockblox_status.cf].max_or); |
1148 | break; | 1178 | break; |
1149 | #endif | 1179 | #endif |
1150 | 1180 | ||
1151 | case ROCKBLOX_DOWN: | 1181 | case ROCKBLOX_DOWN: |
1152 | case ROCKBLOX_DOWN | BUTTON_REPEAT: | 1182 | case ROCKBLOX_DOWN | BUTTON_REPEAT: |
1153 | move_block (0, 1, co); | 1183 | move_block (0, 1, rockblox_status.co); |
1154 | break; | 1184 | break; |
1155 | 1185 | ||
1156 | case ROCKBLOX_RIGHT: | 1186 | case ROCKBLOX_RIGHT: |
1157 | case ROCKBLOX_RIGHT | BUTTON_REPEAT: | 1187 | case ROCKBLOX_RIGHT | BUTTON_REPEAT: |
1158 | move_block (1, 0, co); | 1188 | move_block (1, 0, rockblox_status.co); |
1159 | break; | 1189 | break; |
1160 | 1190 | ||
1161 | case ROCKBLOX_LEFT: | 1191 | case ROCKBLOX_LEFT: |
1162 | case ROCKBLOX_LEFT | BUTTON_REPEAT: | 1192 | case ROCKBLOX_LEFT | BUTTON_REPEAT: |
1163 | move_block (-1, 0, co); | 1193 | move_block (-1, 0, rockblox_status.co); |
1164 | break; | 1194 | break; |
1165 | 1195 | ||
1166 | case ROCKBLOX_DROP: | 1196 | case ROCKBLOX_DROP: |
@@ -1168,8 +1198,8 @@ static int rockblox_loop (void) | |||
1168 | if (lastbutton != ROCKBLOX_DROP_PRE) | 1198 | if (lastbutton != ROCKBLOX_DROP_PRE) |
1169 | break; | 1199 | break; |
1170 | #endif | 1200 | #endif |
1171 | while (canMoveTo (cx, cy + 1, co)) | 1201 | while (canMoveTo (rockblox_status.cx, rockblox_status.cy + 1, rockblox_status.co)) |
1172 | move_block (0, 1, co); | 1202 | move_block (0, 1, rockblox_status.co); |
1173 | break; | 1203 | break; |
1174 | #ifdef ROCKBLOX_RESTART | 1204 | #ifdef ROCKBLOX_RESTART |
1175 | case ROCKBLOX_RESTART: | 1205 | case ROCKBLOX_RESTART: |
@@ -1215,20 +1245,19 @@ static int rockblox_loop (void) | |||
1215 | 1245 | ||
1216 | if (TIME_AFTER(*rb->current_tick, next_down_tick)) { | 1246 | if (TIME_AFTER(*rb->current_tick, next_down_tick)) { |
1217 | move_down (); | 1247 | move_down (); |
1218 | next_down_tick += level_speed(level); | 1248 | next_down_tick += level_speed(rockblox_status.level); |
1219 | if (TIME_AFTER(*rb->current_tick, next_down_tick)) | 1249 | if (TIME_AFTER(*rb->current_tick, next_down_tick)) |
1220 | /* restart time "raster" when we had to wait longer than usual | 1250 | /* restart time "raster" when we had to wait longer than usual |
1221 | * (pause, game restart etc) */ | 1251 | * (pause, game restart etc) */ |
1222 | next_down_tick = *rb->current_tick + level_speed(level); | 1252 | next_down_tick = *rb->current_tick + level_speed(rockblox_status.level); |
1223 | } | 1253 | } |
1224 | 1254 | ||
1225 | if (gameover) { | 1255 | if (rockblox_status.gameover) { |
1226 | #if LCD_DEPTH >= 2 | 1256 | #if LCD_DEPTH >= 2 |
1227 | rb->lcd_set_foreground (LCD_BLACK); | 1257 | rb->lcd_set_foreground (LCD_BLACK); |
1228 | #endif | 1258 | #endif |
1229 | rb->splash (HZ * 2, "Game Over"); | 1259 | rb->splash (HZ * 2, "Game Over"); |
1230 | init_rockblox (); | 1260 | init_rockblox (); |
1231 | new_block (); | ||
1232 | } | 1261 | } |
1233 | 1262 | ||
1234 | refresh_board (); | 1263 | refresh_board (); |
@@ -1267,9 +1296,7 @@ enum plugin_status plugin_start (const void *parameter) | |||
1267 | init_rockblox (); | 1296 | init_rockblox (); |
1268 | ret = rockblox_loop (); | 1297 | ret = rockblox_loop (); |
1269 | 1298 | ||
1270 | #ifdef HAVE_LCD_BITMAP | 1299 | #ifndef HAVE_LCD_BITMAP |
1271 | rb->lcd_setfont (FONT_UI); | ||
1272 | #else | ||
1273 | pgfx_release(); | 1300 | pgfx_release(); |
1274 | #endif | 1301 | #endif |
1275 | /* Save user's HighScore */ | 1302 | /* Save user's HighScore */ |