1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Frederic Dang Ngoc
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifdef HAVE_LCD_BITMAP
26 /* size of a level in file */
27 #define STAR_LEVEL_SIZE ((STAR_WIDTH + 1) * STAR_HEIGHT + 1)
29 /* size of the game board */
34 #define STAR_LEVEL_COUNT 20
36 /* values of object in the board */
41 #define STAR_BLOCK 'x'
43 /* sleep time between two frames */
44 #if (LCD_HEIGHT * LCD_WIDTH >= 70000) && defined(IPOD_ARCH)
45 /* iPod 5G LCD is *slow* */
46 #define STAR_SLEEP rb->yield();
47 #elif (LCD_HEIGHT * LCD_WIDTH >= 30000)
48 #define STAR_SLEEP rb->sleep(0);
50 #define STAR_SLEEP rb->sleep(1);
53 /* value of ball and block control */
54 #define STAR_CONTROL_BALL 0
55 #define STAR_CONTROL_BLOCK 1
57 /* variable button definitions */
58 #if CONFIG_KEYPAD == RECORDER_PAD
59 #define STAR_QUIT BUTTON_OFF
60 #define STAR_LEFT BUTTON_LEFT
61 #define STAR_RIGHT BUTTON_RIGHT
62 #define STAR_UP BUTTON_UP
63 #define STAR_DOWN BUTTON_DOWN
64 #define STAR_TOGGLE_CONTROL BUTTON_ON
65 #define STAR_TOGGLE_CONTROL2 BUTTON_PLAY
66 #define STAR_LEVEL_UP BUTTON_F3
67 #define STAR_LEVEL_DOWN BUTTON_F1
68 #define STAR_LEVEL_REPEAT BUTTON_F2
70 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
71 #define STAR_QUIT BUTTON_OFF
72 #define STAR_LEFT BUTTON_LEFT
73 #define STAR_RIGHT BUTTON_RIGHT
74 #define STAR_UP BUTTON_UP
75 #define STAR_DOWN BUTTON_DOWN
76 #define STAR_TOGGLE_CONTROL BUTTON_ON
77 #define STAR_TOGGLE_CONTROL2 BUTTON_SELECT
78 #define STAR_LEVEL_UP BUTTON_F3
79 #define STAR_LEVEL_DOWN BUTTON_F1
80 #define STAR_LEVEL_REPEAT BUTTON_F2
82 #elif CONFIG_KEYPAD == ONDIO_PAD
83 #define STAR_QUIT BUTTON_OFF
84 #define STAR_LEFT BUTTON_LEFT
85 #define STAR_RIGHT BUTTON_RIGHT
86 #define STAR_UP BUTTON_UP
87 #define STAR_DOWN BUTTON_DOWN
88 #define STAR_TOGGLE_CONTROL_PRE BUTTON_MENU
89 #define STAR_TOGGLE_CONTROL (BUTTON_MENU | BUTTON_REL)
90 #define STAR_LEVEL_UP (BUTTON_MENU | BUTTON_RIGHT)
91 #define STAR_LEVEL_DOWN (BUTTON_MENU | BUTTON_LEFT)
92 #define STAR_LEVEL_REPEAT (BUTTON_MENU | BUTTON_UP)
94 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
95 (CONFIG_KEYPAD == IRIVER_H300_PAD)
96 #define STAR_QUIT BUTTON_OFF
97 #define STAR_LEFT BUTTON_LEFT
98 #define STAR_RIGHT BUTTON_RIGHT
99 #define STAR_UP BUTTON_UP
100 #define STAR_DOWN BUTTON_DOWN
101 #define STAR_TOGGLE_CONTROL BUTTON_MODE
102 #define STAR_TOGGLE_CONTROL2 BUTTON_SELECT
103 #define STAR_LEVEL_UP (BUTTON_ON | BUTTON_RIGHT)
104 #define STAR_LEVEL_DOWN (BUTTON_ON | BUTTON_LEFT)
105 #define STAR_LEVEL_REPEAT (BUTTON_ON | BUTTON_SELECT)
107 #define STAR_RC_QUIT BUTTON_RC_STOP
108 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
109 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
110 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
112 #define STAR_QUIT (BUTTON_SELECT | BUTTON_MENU)
113 #define STAR_LEFT BUTTON_LEFT
114 #define STAR_RIGHT BUTTON_RIGHT
115 #define STAR_UP BUTTON_MENU
116 #define STAR_DOWN BUTTON_PLAY
117 #define STAR_TOGGLE_CONTROL_PRE BUTTON_SELECT
118 #define STAR_TOGGLE_CONTROL (BUTTON_SELECT | BUTTON_REL)
119 #define STAR_LEVEL_UP (BUTTON_SELECT | BUTTON_RIGHT)
120 #define STAR_LEVEL_DOWN (BUTTON_SELECT | BUTTON_LEFT)
121 #define STAR_LEVEL_REPEAT (BUTTON_SELECT | BUTTON_PLAY)
123 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
125 #define STAR_QUIT BUTTON_POWER
126 #define STAR_LEFT BUTTON_LEFT
127 #define STAR_RIGHT BUTTON_RIGHT
128 #define STAR_UP BUTTON_UP
129 #define STAR_DOWN BUTTON_DOWN
130 #define STAR_TOGGLE_CONTROL BUTTON_SELECT
131 #define STAR_LEVEL_UP_PRE BUTTON_REC
132 #define STAR_LEVEL_UP (BUTTON_REC|BUTTON_REL)
133 #define STAR_LEVEL_DOWN_PRE BUTTON_REC
134 #define STAR_LEVEL_DOWN (BUTTON_REC|BUTTON_REPEAT)
135 #define STAR_LEVEL_REPEAT BUTTON_PLAY
137 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
139 #define STAR_QUIT BUTTON_POWER
140 #define STAR_LEFT BUTTON_LEFT
141 #define STAR_RIGHT BUTTON_RIGHT
142 #define STAR_UP BUTTON_UP
143 #define STAR_DOWN BUTTON_DOWN
144 #define STAR_TOGGLE_CONTROL BUTTON_SELECT
145 #define STAR_LEVEL_UP BUTTON_VOL_UP
146 #define STAR_LEVEL_DOWN BUTTON_VOL_DOWN
147 #define STAR_LEVEL_REPEAT BUTTON_A
149 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
150 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
151 (CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
152 (CONFIG_KEYPAD == SANSA_M200_PAD)
154 #define STAR_QUIT BUTTON_POWER
155 #define STAR_LEFT BUTTON_LEFT
156 #define STAR_RIGHT BUTTON_RIGHT
157 #define STAR_UP BUTTON_UP
158 #define STAR_DOWN BUTTON_DOWN
159 #define STAR_TOGGLE_CONTROL BUTTON_SELECT
160 #define STAR_LEVEL_UP (BUTTON_SELECT | BUTTON_RIGHT)
161 #define STAR_LEVEL_DOWN (BUTTON_SELECT | BUTTON_LEFT)
162 #define STAR_LEVEL_REPEAT (BUTTON_SELECT | BUTTON_DOWN)
165 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
167 #define STAR_QUIT (BUTTON_HOME|BUTTON_REPEAT)
168 #define STAR_LEFT BUTTON_LEFT
169 #define STAR_RIGHT BUTTON_RIGHT
170 #define STAR_UP BUTTON_UP
171 #define STAR_DOWN BUTTON_DOWN
172 #define STAR_TOGGLE_CONTROL BUTTON_SELECT
173 #define STAR_LEVEL_UP (BUTTON_SELECT | BUTTON_RIGHT)
174 #define STAR_LEVEL_DOWN (BUTTON_SELECT | BUTTON_LEFT)
175 #define STAR_LEVEL_REPEAT (BUTTON_SELECT | BUTTON_DOWN)
177 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
179 #define STAR_QUIT BUTTON_POWER
180 #define STAR_LEFT BUTTON_LEFT
181 #define STAR_RIGHT BUTTON_RIGHT
182 #define STAR_UP BUTTON_SCROLL_UP
183 #define STAR_DOWN BUTTON_SCROLL_DOWN
184 #define STAR_TOGGLE_CONTROL BUTTON_REW
185 #define STAR_LEVEL_UP (BUTTON_PLAY | BUTTON_SCROLL_UP)
186 #define STAR_LEVEL_DOWN (BUTTON_PLAY | BUTTON_SCROLL_DOWN)
187 #define STAR_LEVEL_REPEAT (BUTTON_PLAY | BUTTON_RIGHT)
189 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
191 #define STAR_QUIT BUTTON_BACK
192 #define STAR_LEFT BUTTON_LEFT
193 #define STAR_RIGHT BUTTON_RIGHT
194 #define STAR_UP BUTTON_UP
195 #define STAR_DOWN BUTTON_DOWN
196 #define STAR_TOGGLE_CONTROL BUTTON_SELECT
197 #define STAR_LEVEL_UP BUTTON_VOL_UP
198 #define STAR_LEVEL_DOWN BUTTON_VOL_DOWN
199 #define STAR_LEVEL_REPEAT BUTTON_MENU
201 #elif (CONFIG_KEYPAD == MROBE100_PAD)
203 #define STAR_QUIT BUTTON_POWER
204 #define STAR_LEFT BUTTON_LEFT
205 #define STAR_RIGHT BUTTON_RIGHT
206 #define STAR_UP BUTTON_UP
207 #define STAR_DOWN BUTTON_DOWN
208 #define STAR_TOGGLE_CONTROL BUTTON_SELECT
209 #define STAR_LEVEL_UP BUTTON_PLAY
210 #define STAR_LEVEL_DOWN BUTTON_MENU
211 #define STAR_LEVEL_REPEAT BUTTON_DISPLAY
213 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
215 #define STAR_QUIT BUTTON_RC_REC
216 #define STAR_LEFT BUTTON_RC_REW
217 #define STAR_RIGHT BUTTON_RC_FF
218 #define STAR_UP BUTTON_RC_VOL_UP
219 #define STAR_DOWN BUTTON_RC_VOL_DOWN
220 #define STAR_TOGGLE_CONTROL BUTTON_RC_MODE
221 #define STAR_LEVEL_UP (BUTTON_RC_PLAY|BUTTON_RC_VOL_UP)
222 #define STAR_LEVEL_DOWN (BUTTON_RC_PLAY|BUTTON_RC_VOL_DOWN)
223 #define STAR_LEVEL_REPEAT (BUTTON_RC_PLAY|BUTTON_RC_MENU)
225 #elif (CONFIG_KEYPAD == COWOND2_PAD)
227 #define STAR_QUIT BUTTON_POWER
228 #define STAR_QUIT_NAME "[POWER]"
230 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
232 #define STAR_QUIT BUTTON_BACK
233 #define STAR_LEFT BUTTON_LEFT
234 #define STAR_RIGHT BUTTON_RIGHT
235 #define STAR_UP BUTTON_UP
236 #define STAR_DOWN BUTTON_DOWN
237 #define STAR_TOGGLE_CONTROL BUTTON_PLAY
238 #define STAR_LEVEL_UP (BUTTON_CUSTOM | BUTTON_UP)
239 #define STAR_LEVEL_DOWN (BUTTON_CUSTOM | BUTTON_DOWN)
240 #define STAR_LEVEL_REPEAT (BUTTON_CUSTOM | BUTTON_RIGHT)
242 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
244 #define STAR_QUIT BUTTON_POWER
245 #define STAR_LEFT BUTTON_LEFT
246 #define STAR_RIGHT BUTTON_RIGHT
247 #define STAR_UP BUTTON_UP
248 #define STAR_DOWN BUTTON_DOWN
249 #define STAR_TOGGLE_CONTROL BUTTON_SELECT
250 #define STAR_LEVEL_UP BUTTON_VOL_UP
251 #define STAR_LEVEL_DOWN BUTTON_VOL_DOWN
252 #define STAR_LEVEL_REPEAT BUTTON_VIEW
254 #elif (CONFIG_KEYPAD == ONDAVX747_PAD)
256 #define STAR_QUIT BUTTON_POWER
257 #define STAR_QUIT_NAME "[POWER]"
259 #elif CONFIG_KEYPAD == MROBE500_PAD
260 #define STAR_QUIT BUTTON_POWER
261 #define STAR_QUIT_NAME "[POWER]"
264 #error No keymap defined!
267 #ifdef HAVE_TOUCHSCREEN
269 //#define STAR_QUIT BUTTON_TOPLEFT
270 //#define STAR_QUIT_NAME "[TOPLEFT]"
273 #define STAR_LEFT BUTTON_MIDLEFT
276 #define STAR_RIGHT BUTTON_MIDRIGHT
279 #define STAR_UP BUTTON_TOPMIDDLE
282 #define STAR_DOWN BUTTON_BOTTOMMIDDLE
284 #ifndef STAR_TOGGLE_CONTROL
285 #define STAR_TOGGLE_CONTROL BUTTON_CENTER
286 #define STAR_TOGGLE_CONTROL_NAME "[CENTER]"
288 #ifndef STAR_LEVEL_UP
289 #define STAR_LEVEL_UP BUTTON_TOPLEFT
290 #define STAR_LEVEL_UP_NAME "[TOPLEFT]"
292 #ifndef STAR_LEVEL_DOWN
293 #define STAR_LEVEL_DOWN BUTTON_BOTTOMLEFT
294 #define STAR_LEVEL_DOWN_NAME "[BOTTOMLEFT]"
296 #ifndef STAR_LEVEL_REPEAT
297 #define STAR_LEVEL_REPEAT BUTTON_BOTTOMRIGHT
298 #define STAR_LEVEL_REPEAT_NAME "[BOTTOMRIGHT]"
302 /* function returns because of USB? */
303 static bool usb_detected
= false;
305 /* position of the ball */
306 static int ball_x
, ball_y
;
308 /* position of the block */
309 static int block_x
, block_y
;
311 /* number of stars to get to finish the level */
312 static int star_count
;
314 /* the object we control : ball or block */
317 /* the current board */
318 static char board
[STAR_HEIGHT
][STAR_WIDTH
];
320 #include "pluginbitmaps/star_tiles.h"
322 #define TILE_WIDTH BMPWIDTH_star_tiles
323 #define TILE_HEIGHT (BMPHEIGHT_star_tiles/5)
324 #define STAR_OFFSET_X ((LCD_WIDTH - STAR_WIDTH * TILE_WIDTH) / 2)
325 #define STAR_OFFSET_Y ((LCD_HEIGHT - STAR_HEIGHT * TILE_HEIGHT - MAX(TILE_HEIGHT, 8)) / 2)
336 static int char_width
= -1;
337 static int char_height
= -1;
339 /* this arrays contains a group of levels loaded into memory */
340 static unsigned char* levels
=
544 void star_display_text(char *str
, bool waitkey
)
549 int current_line
= 0;
550 int first_char_index
= 0;
558 rb
->lcd_clear_display();
560 chars_by_line
= LCD_WIDTH
/ char_width
;
561 lines_by_screen
= LCD_HEIGHT
/ char_height
;
565 ptr_char
= str
+ first_char_index
;
569 while (i
< chars_by_line
)
582 *(ptr_line
++) = *ptr_char
;
584 if (*ptr_char
== '\n' || *ptr_char
== '\0')
590 if (chars_for_line
== 0)
593 line
[chars_for_line
] = '\0';
595 /* test if we have cut a word. If it is the case we don't have to */
597 if (i
== chars_by_line
&& chars_for_line
== chars_by_line
)
598 first_char_index
+= chars_for_line
;
600 first_char_index
+= chars_for_line
+ 1;
602 /* print the line on the screen */
603 rb
->lcd_putsxy(0, current_line
* char_height
, line
);
605 /* if the number of line showed on the screen is equals to the */
606 /* maximum number of line we can show, we wait for a key pressed to */
607 /* clear and show the remaining text. */
609 if (current_line
== lines_by_screen
|| *ptr_char
== '\0')
614 while (waitkey
&& !go_on
)
616 key
= rb
->button_get(true);
626 if (rb
->default_event_handler(key
) == SYS_USB_CONNECTED
)
634 rb
->lcd_clear_display();
636 } while (*ptr_char
!= '\0');
640 * Do a pretty transition from one level to another.
642 static void star_transition_update(void)
644 const int center_x
= LCD_WIDTH
/ 2;
645 const int center_y
= LCD_HEIGHT
/ 2;
648 #if LCD_WIDTH >= LCD_HEIGHT
649 #if defined(IPOD_VIDEO)
654 const int lcd_demi_width
= LCD_WIDTH
/ 2;
657 for (; x
< lcd_demi_width
; x
+=step
)
660 if (var_y
> LCD_WIDTH
)
667 rb
->lcd_update_rect(center_x
- x
, center_y
- y
, x
*2, step
);
668 rb
->lcd_update_rect(center_x
- x
, center_y
+ y
- step
, x
*2, step
);
672 rb
->lcd_update_rect(center_x
- x
, center_y
- y
, step
, y
*2);
673 rb
->lcd_update_rect(center_x
+ x
- step
, center_y
- y
, step
, y
*2);
678 int lcd_demi_height
= LCD_HEIGHT
/ 2;
681 for (; y
< lcd_demi_height
; y
++)
684 if (var_x
> LCD_HEIGHT
)
691 rb
->lcd_update_rect(center_x
- x
, center_y
- y
, x
* 2, 1);
692 rb
->lcd_update_rect(center_x
- x
, center_y
+ y
- 1, x
* 2, 1);
696 rb
->lcd_update_rect(center_x
- x
, center_y
- y
, 1, y
* 2);
697 rb
->lcd_update_rect(center_x
+ x
- 1, center_y
- y
, 1, y
* 2);
706 * Display information board of the current level.
708 static void star_display_board_info(int current_level
)
710 int label_pos_y
, tile_pos_y
;
713 if (TILE_HEIGHT
> char_height
)
715 tile_pos_y
= LCD_HEIGHT
- TILE_HEIGHT
;
716 label_pos_y
= tile_pos_y
+ (TILE_HEIGHT
- char_height
) / 2;
720 label_pos_y
= LCD_HEIGHT
- char_height
;
721 tile_pos_y
= label_pos_y
+ (char_height
- TILE_HEIGHT
) / 2;
724 rb
->snprintf(str_info
, sizeof(str_info
), "L:%02d", current_level
+ 1);
725 rb
->lcd_putsxy(STAR_OFFSET_X
, label_pos_y
, str_info
);
726 rb
->snprintf(str_info
, sizeof(str_info
), "S:%02d", star_count
);
727 rb
->lcd_putsxy(LCD_WIDTH
/2 - 2 * char_width
, label_pos_y
, str_info
);
728 rb
->lcd_putsxy(STAR_OFFSET_X
+ (STAR_WIDTH
-1) * TILE_WIDTH
- 2 * char_width
,
731 rb
->lcd_bitmap_part(star_tiles
, 0, control
== STAR_CONTROL_BALL
?
732 BALL
*TILE_HEIGHT
: BLOCK
*TILE_HEIGHT
, TILE_WIDTH
,
733 STAR_OFFSET_X
+ (STAR_WIDTH
-1) * TILE_WIDTH
,
734 tile_pos_y
, TILE_WIDTH
, TILE_HEIGHT
);
736 rb
->lcd_update_rect(0, MIN(label_pos_y
, tile_pos_y
), LCD_WIDTH
,
737 MAX(TILE_HEIGHT
, char_height
));
742 * Load a level into board array.
744 static int star_load_level(int current_level
)
749 if (current_level
< 0)
751 else if (current_level
> STAR_LEVEL_COUNT
-1)
752 current_level
= STAR_LEVEL_COUNT
-1;
755 ptr_tab
= levels
+ current_level
* STAR_LEVEL_SIZE
;
756 control
= STAR_CONTROL_BALL
;
759 rb
->lcd_clear_display();
761 for (y
= 0 ; y
< STAR_HEIGHT
; y
++)
763 for (x
= 0 ; x
< STAR_WIDTH
; x
++)
765 board
[y
][x
] = *ptr_tab
;
768 # define DRAW_TILE( a ) \
769 rb->lcd_bitmap_part( star_tiles, 0, \
770 a*TILE_HEIGHT, TILE_WIDTH, \
771 STAR_OFFSET_X + x * TILE_WIDTH, \
772 STAR_OFFSET_Y + y * TILE_HEIGHT, \
773 TILE_WIDTH, TILE_HEIGHT);
804 star_display_board_info(current_level
);
805 star_transition_update();
809 static void star_animate_tile(int tile_no
, int start_x
, int start_y
,
810 int delta_x
, int delta_y
)
814 if (delta_x
!= 0) /* horizontal */
816 for (i
= 1 ; i
<= TILE_WIDTH
; i
++)
819 rb
->lcd_bitmap_part(star_tiles
, 0, SPACE
* TILE_HEIGHT
, TILE_WIDTH
,
820 start_x
, start_y
, TILE_WIDTH
, TILE_HEIGHT
);
821 rb
->lcd_bitmap_part(star_tiles
, 0, tile_no
* TILE_HEIGHT
, TILE_WIDTH
,
822 start_x
+ delta_x
* i
, start_y
, TILE_WIDTH
, TILE_HEIGHT
);
823 rb
->lcd_update_rect(start_x
+ delta_x
* i
- (delta_x
>0?1:0),
824 start_y
, TILE_WIDTH
+ 1, TILE_HEIGHT
);
829 for (i
= 1 ; i
<= TILE_HEIGHT
; i
++)
832 rb
->lcd_bitmap_part(star_tiles
, 0, SPACE
* TILE_HEIGHT
, TILE_WIDTH
,
833 start_x
, start_y
, TILE_WIDTH
, TILE_HEIGHT
);
834 rb
->lcd_bitmap_part(star_tiles
, 0, tile_no
* TILE_HEIGHT
, TILE_WIDTH
,
835 start_x
, start_y
+ delta_y
* i
, TILE_WIDTH
, TILE_HEIGHT
);
836 rb
->lcd_update_rect(start_x
, start_y
+ delta_y
* i
- (delta_y
>0?1:0),
837 TILE_WIDTH
, TILE_HEIGHT
+ 1);
845 static int star_run_game(int current_level
)
850 int lastkey
= BUTTON_NONE
;
854 label_offset_y
= LCD_HEIGHT
- char_height
;
856 if (!star_load_level(current_level
))
864 while ((move_x
== 0) && (move_y
== 0))
866 key
= rb
->button_get(true);
891 case STAR_LEVEL_DOWN
:
892 #ifdef STAR_LEVEL_DOWN_PRE
893 if (lastkey
!= STAR_LEVEL_DOWN_PRE
)
896 if (current_level
> 0)
899 star_load_level(current_level
);
903 case STAR_LEVEL_REPEAT
:
904 star_load_level(current_level
);
908 #ifdef STAR_LEVEL_UP_PRE
909 if (lastkey
!= STAR_LEVEL_UP_PRE
)
912 if (current_level
< STAR_LEVEL_COUNT
- 1)
915 star_load_level(current_level
);
919 case STAR_TOGGLE_CONTROL
:
920 #ifdef STAR_TOGGLE_CONTROL_PRE
921 if (lastkey
!= STAR_TOGGLE_CONTROL_PRE
)
924 #ifdef STAR_TOGGLE_CONTROL2
925 case STAR_TOGGLE_CONTROL2
:
927 if (control
== STAR_CONTROL_BALL
)
928 control
= STAR_CONTROL_BLOCK
;
930 control
= STAR_CONTROL_BALL
;
931 star_display_board_info(current_level
);
935 if (rb
->default_event_handler(key
) == SYS_USB_CONNECTED
)
942 if (key
!= BUTTON_NONE
)
946 if (control
== STAR_CONTROL_BALL
)
948 board
[ball_y
][ball_x
] = STAR_VOID
;
949 while ((board
[ball_y
+ move_y
][ball_x
+ move_x
] == STAR_VOID
950 || board
[ball_y
+ move_y
][ball_x
+ move_x
] == STAR_STAR
))
953 star_animate_tile(BALL
, STAR_OFFSET_X
+ ball_x
* TILE_WIDTH
,
954 STAR_OFFSET_Y
+ ball_y
* TILE_HEIGHT
,
959 if (board
[ball_y
][ball_x
] == STAR_STAR
)
961 board
[ball_y
][ball_x
] = STAR_VOID
;
964 star_display_board_info(current_level
);
967 board
[ball_y
][ball_x
] = STAR_BALL
;
971 board
[block_y
][block_x
] = STAR_VOID
;
972 while (board
[block_y
+ move_y
][block_x
+ move_x
] == STAR_VOID
)
974 star_animate_tile(BLOCK
, STAR_OFFSET_X
+ block_x
* TILE_WIDTH
,
975 STAR_OFFSET_Y
+ block_y
* TILE_HEIGHT
,
980 board
[block_y
][block_x
] = STAR_BLOCK
;
986 if (current_level
== STAR_LEVEL_COUNT
)
988 rb
->lcd_clear_display();
989 star_display_text("Congratulations!", true);
992 /* There is no such level as STAR_LEVEL_COUNT so it can't be the
997 star_load_level(current_level
);
1003 * Display the choice menu.
1005 static int star_menu(void)
1007 int selection
, level
=1;
1008 bool menu_quit
= false;
1009 /* get the size of char */
1010 rb
->lcd_getstringsize("a", &char_width
, &char_height
);
1012 MENUITEM_STRINGLIST(menu
,"Star Menu",NULL
,"Play","Choose Level",
1013 "Information","Keys","Quit");
1017 switch(rb
->do_menu(&menu
, &selection
, NULL
, false))
1023 rb
->set_int("Level", "", UNIT_INT
, &level
,
1024 NULL
, 1, 1, STAR_LEVEL_COUNT
, NULL
);
1029 "Take all the stars to go to the next level. "
1030 "You can toggle control with the block to "
1031 "use it as a mobile wall. The block cannot "
1032 "take stars.", true);
1035 #if CONFIG_KEYPAD == RECORDER_PAD
1036 star_display_text("KEYS\n\n"
1037 "[ON] Toggle Ctl.\n"
1039 "[F1] Prev. level\n"
1040 "[F2] Reset level\n"
1041 "[F3] Next level", true);
1042 #elif CONFIG_KEYPAD == ONDIO_PAD
1043 star_display_text("KEYS\n\n"
1044 "[MODE] Toggle Ctl\n"
1046 "[M <] Prev. level\n"
1047 "[M ^] Reset level\n"
1048 "[M >] Next level", true);
1049 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
1050 star_display_text("KEYS\n\n"
1051 "[MODE/NAVI] Toggle Ctrl\n"
1053 "[ON + LEFT] Prev. level\n"
1054 "[ON + NAVI] Reset level\n"
1055 "[ON + RIGHT] Next level", true);
1056 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
1057 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
1058 star_display_text("KEYS\n\n"
1059 "[SELECT] Toggle Ctl\n"
1061 "[S <] Prev. level\n"
1062 "[S + PLAY] Reset level\n"
1063 "[S >] Next level", true);
1064 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
1065 star_display_text("KEYS\n\n"
1066 "[SELECT] Toggle Ctl\n"
1068 "[REC..] Prev. level\n"
1069 "[PLAY] Reset level\n"
1070 "[REC] Next level", true);
1071 #elif CONFIG_KEYPAD == GIGABEAT_PAD
1072 star_display_text("KEYS\n\n"
1073 "[SELECT] Toggle Control\n"
1075 "[VOL DOWN] Prev. level\n"
1077 "[VOL UP] Next level", true);
1078 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
1079 star_display_text("KEYS\n\n"
1080 "[REW] Toggle Ctl\n"
1082 "[PLAY+DOWN] Prev. level\n"
1083 "[PLAY+RIGHT] Reset level\n"
1084 "[PLAY+UP] Next level", true);
1085 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
1086 star_display_text("KEYS\n\n"
1087 "[SELECT] Toggle Control\n"
1089 "[VOL DOWN] Prev. level\n"
1090 "[MENU] Reset level\n"
1091 "[VOL UP] Next level", true);
1093 #ifdef HAVE_TOUCHSCREEN
1094 star_display_text("KEYS\n\n"
1095 STAR_TOGGLE_CONTROL_NAME
" Toggle Control\n"
1096 STAR_QUIT_NAME
" Exit\n"
1097 STAR_LEVEL_DOWN_NAME
" Prev. level\n"
1098 STAR_LEVEL_REPEAT_NAME
" Reset level\n"
1099 STAR_LEVEL_UP_NAME
" Next level", true);
1108 if (selection
== MENU_START
)
1110 rb
->lcd_setfont(FONT_SYSFIXED
);
1111 rb
->lcd_getstringsize("a", &char_width
, &char_height
);
1113 star_run_game(level
);
1121 enum plugin_status
plugin_start(const void* parameter
)
1126 rb
->lcd_set_backdrop(NULL
);
1127 rb
->lcd_set_background( LCD_BLACK
);
1128 rb
->lcd_set_foreground( LCD_WHITE
);
1131 /* display choice menu */