1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005, 2006 Ben Basha (Paprica)
11 * Copyright (C) 2009 Karl Kurbjun
12 * check_lines is based off an explanation and expanded math presented by Paul
13 * Bourke: http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
26 #include "lib/configfile.h"
27 #include "lib/display_text.h"
28 #include "lib/helper.h"
29 #include "lib/highscore.h"
30 #include "lib/playback_control.h"
32 #include "pluginbitmaps/brickmania_pads.h"
33 #include "pluginbitmaps/brickmania_short_pads.h"
34 #include "pluginbitmaps/brickmania_long_pads.h"
35 #include "pluginbitmaps/brickmania_bricks.h"
36 #include "pluginbitmaps/brickmania_powerups.h"
37 #include "pluginbitmaps/brickmania_ball.h"
38 #include "pluginbitmaps/brickmania_gameover.h"
40 #ifdef HAVE_LCD_COLOR /* currently no transparency for non-colour */
41 #include "pluginbitmaps/brickmania_break.h"
53 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
54 (CONFIG_KEYPAD == IRIVER_H300_PAD)
55 #define CONTINUE_TEXT "Press NAVI To Continue"
56 #define QUIT BUTTON_OFF
57 #define LEFT BUTTON_LEFT
58 #define RIGHT BUTTON_RIGHT
59 #define SELECT BUTTON_SELECT
61 #define DOWN BUTTON_DOWN
62 #define RC_QUIT BUTTON_RC_STOP
64 #elif CONFIG_KEYPAD == ONDIO_PAD
65 #define CONTINUE_TEXT "MENU To Continue"
66 #define QUIT BUTTON_OFF
67 #define LEFT BUTTON_LEFT
68 #define RIGHT BUTTON_RIGHT
69 #define SELECT BUTTON_MENU
71 #define DOWN BUTTON_DOWN
73 #elif CONFIG_KEYPAD == RECORDER_PAD
74 #define QUIT BUTTON_OFF
75 #define LEFT BUTTON_LEFT
76 #define RIGHT BUTTON_RIGHT
77 #define SELECT BUTTON_PLAY
79 #define DOWN BUTTON_DOWN
81 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
82 #define QUIT BUTTON_OFF
83 #define LEFT BUTTON_LEFT
84 #define RIGHT BUTTON_RIGHT
85 #define SELECT BUTTON_SELECT
87 #define DOWN BUTTON_DOWN
89 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
90 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
91 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
92 #define QUIT BUTTON_MENU
93 #define LEFT BUTTON_LEFT
94 #define RIGHT BUTTON_RIGHT
95 #define SELECT BUTTON_SELECT
96 #define UP BUTTON_SCROLL_BACK
97 #define DOWN BUTTON_SCROLL_FWD
98 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
99 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
101 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
102 #define QUIT BUTTON_POWER
103 #define LEFT BUTTON_LEFT
104 #define RIGHT BUTTON_RIGHT
105 #define SELECT BUTTON_SELECT
107 #define DOWN BUTTON_DOWN
109 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
110 #define QUIT BUTTON_POWER
111 #define LEFT BUTTON_LEFT
112 #define RIGHT BUTTON_RIGHT
113 #define SELECT BUTTON_PLAY
115 #define DOWN BUTTON_DOWN
117 #elif (CONFIG_KEYPAD == SANSA_E200_PAD)
118 #define QUIT BUTTON_POWER
119 #define LEFT BUTTON_LEFT
120 #define RIGHT BUTTON_RIGHT
121 #define SELECT BUTTON_SELECT
123 #define DOWN BUTTON_DOWN
124 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
125 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
128 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
129 #define QUIT (BUTTON_HOME|BUTTON_REPEAT)
130 #define LEFT BUTTON_LEFT
131 #define RIGHT BUTTON_RIGHT
132 #define SELECT BUTTON_SELECT
134 #define DOWN BUTTON_DOWN
136 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
137 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
140 #elif CONFIG_KEYPAD == SANSA_C200_PAD || \
141 CONFIG_KEYPAD == SANSA_CLIP_PAD || \
142 CONFIG_KEYPAD == SANSA_M200_PAD
143 #define QUIT BUTTON_POWER
144 #define LEFT BUTTON_LEFT
145 #define RIGHT BUTTON_RIGHT
146 #define ALTLEFT BUTTON_VOL_DOWN
147 #define ALTRIGHT BUTTON_VOL_UP
148 #define SELECT BUTTON_SELECT
150 #define DOWN BUTTON_DOWN
152 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
153 #define QUIT BUTTON_POWER
154 #define LEFT BUTTON_LEFT
155 #define RIGHT BUTTON_RIGHT
156 #define SELECT BUTTON_PLAY
157 #define UP BUTTON_SCROLL_UP
158 #define DOWN BUTTON_SCROLL_DOWN
160 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
161 #define QUIT BUTTON_BACK
162 #define LEFT BUTTON_LEFT
163 #define RIGHT BUTTON_RIGHT
164 #define SELECT BUTTON_SELECT
166 #define DOWN BUTTON_DOWN
168 #elif (CONFIG_KEYPAD == MROBE100_PAD)
169 #define QUIT BUTTON_POWER
170 #define LEFT BUTTON_LEFT
171 #define RIGHT BUTTON_RIGHT
172 #define SELECT BUTTON_SELECT
174 #define DOWN BUTTON_DOWN
176 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
177 #define CONTINUE_TEXT "PLAY To Continue"
178 #define QUIT BUTTON_RC_REC
179 #define LEFT BUTTON_RC_REW
180 #define RIGHT BUTTON_RC_FF
181 #define SELECT BUTTON_RC_PLAY
182 #define UP BUTTON_RC_VOL_UP
183 #define DOWN BUTTON_RC_VOL_DOWN
184 #define RC_QUIT BUTTON_REC
186 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
187 #define QUIT BUTTON_BACK
188 #define LEFT BUTTON_LEFT
189 #define RIGHT BUTTON_RIGHT
190 #define SELECT BUTTON_SELECT
192 #define DOWN BUTTON_DOWN
194 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
195 #define QUIT BUTTON_POWER
196 #define LEFT BUTTON_LEFT
197 #define RIGHT BUTTON_RIGHT
198 #define SELECT BUTTON_SELECT
200 #define DOWN BUTTON_DOWN
202 #elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
203 #define QUIT BUTTON_POWER
204 #define LEFT BUTTON_PREV
205 #define RIGHT BUTTON_NEXT
206 #define SELECT BUTTON_PLAY
208 #define DOWN BUTTON_DOWN
210 #elif CONFIG_KEYPAD == COWON_D2_PAD
211 #define CONTINUE_TEXT "MENU To Continue"
212 #define QUIT BUTTON_POWER
213 #define LEFT BUTTON_MINUS
214 #define RIGHT BUTTON_PLUS
215 #define SELECT BUTTON_MENU
217 #elif CONFIG_KEYPAD == ONDAVX747_PAD
218 #define QUIT BUTTON_POWER
219 #define LEFT BUTTON_VOL_DOWN
220 #define RIGHT BUTTON_VOL_UP
221 #define SELECT BUTTON_MENU
222 #elif CONFIG_KEYPAD == ONDAVX777_PAD
223 #define QUIT BUTTON_POWER
225 #elif CONFIG_KEYPAD == MROBE500_PAD
226 #define QUIT BUTTON_POWER
228 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
229 #define QUIT BUTTON_FFWD
230 #define SELECT BUTTON_PLAY
231 #define LEFT BUTTON_LEFT
232 #define RIGHT BUTTON_RIGHT
234 #define DOWN BUTTON_DOWN
236 #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
237 #define QUIT BUTTON_REC
238 #define LEFT BUTTON_PREV
239 #define RIGHT BUTTON_NEXT
240 #define ALTLEFT BUTTON_MENU
241 #define ALTRIGHT BUTTON_PLAY
242 #define SELECT BUTTON_OK
244 #define DOWN BUTTON_DOWN
247 #error No keymap defined!
250 #ifdef HAVE_TOUCHSCREEN
252 #define ALTLEFT BUTTON_BOTTOMLEFT
254 #define LEFT BUTTON_BOTTOMLEFT
257 #define ALTRIGHT BUTTON_BOTTOMRIGHT
259 #define RIGHT BUTTON_BOTTOMRIGHT
262 #define ALTSELECT BUTTON_CENTER
264 #define SELECT BUTTON_CENTER
267 #define UP BUTTON_TOPMIDDLE
270 #define DOWN BUTTON_BOTTOMMIDDLE
274 /* Continue text is used as a string later when the game is paused. This allows
275 * targets to specify their own text if needed.
277 #if !defined(CONTINUE_TEXT)
278 #define CONTINUE_TEXT "Press SELECT To Continue"
281 #ifndef SCROLL_FWD /* targets without scroll wheel*/
282 #define SCROLL_FWD(x) (0)
283 #define SCROLL_BACK(x) (0)
289 * Geometric dimensions
293 /* If there are three fractional bits, the smallest screen size that will scale
294 * properly is 28x22. If you have a smaller screen increase the fractional
295 * precision. If you have a precision of 4 the smallest screen size would be
296 * 14x11. Note though that this will decrease the maximum resolution due to
297 * the line intersection tests. These defines are used for all of the fixed
298 * point calculations/conversions.
300 #define FIXED3(x) ((x)<<3)
301 #define FIXED3_MUL(x, y) ((long long)((x)*(y))>>3)
302 #define FIXED3_DIV(x, y) (((x)<<3)/(y))
303 #define INT3(x) ((x)>>3)
305 #define GAMESCREEN_WIDTH FIXED3(LCD_WIDTH)
306 #define GAMESCREEN_HEIGHT FIXED3(LCD_HEIGHT)
308 #define PAD_WIDTH FIXED3(BMPWIDTH_brickmania_pads)
309 #define PAD_HEIGHT FIXED3(BMPHEIGHT_brickmania_pads/3)
310 #define SHORT_PAD_WIDTH FIXED3(BMPWIDTH_brickmania_short_pads)
311 #define LONG_PAD_WIDTH FIXED3(BMPWIDTH_brickmania_long_pads)
312 #define BRICK_HEIGHT FIXED3(BMPHEIGHT_brickmania_bricks/7)
313 #define BRICK_WIDTH FIXED3(BMPWIDTH_brickmania_bricks)
314 #define LEFTMARGIN ((GAMESCREEN_WIDTH-10*BRICK_WIDTH)/2)
315 #define POWERUP_WIDTH FIXED3(BMPWIDTH_brickmania_powerups)
316 #define BALL FIXED3(BMPHEIGHT_brickmania_ball)
317 #define HALFBALL (BALL / 2)
318 #define PAD_POS_Y (GAMESCREEN_HEIGHT - PAD_HEIGHT - 1)
319 #define ON_PAD_POS_Y (PAD_POS_Y - HALFBALL)
321 #define GAMEOVER_WIDTH FIXED3(BMPWIDTH_brickmania_gameover)
322 #define GAMEOVER_HEIGHT FIXED3(BMPHEIGHT_brickmania_gameover)
324 #define TOPMARGIN MAX(BRICK_HEIGHT, FIXED3(8))
326 #define STRINGPOS_FINISH (GAMESCREEN_HEIGHT - (GAMESCREEN_HEIGHT / 6))
327 #define STRINGPOS_CONGRATS (STRINGPOS_FINISH - 20)
328 #define STRINGPOS_NAVI (STRINGPOS_FINISH - 10)
329 #define STRINGPOS_FLIP (STRINGPOS_FINISH - 10)
338 /* Brickmania was originally designed for the H300, other targets should scale
339 * the speed up/down as needed based on the screen height.
341 #define SPEED_SCALE_H(y) FIXED3_DIV(GAMESCREEN_HEIGHT, FIXED3(176)/(y) )
342 #define SPEED_SCALE_W(x) FIXED3_DIV(GAMESCREEN_WIDTH, FIXED3(220)/(x) )
344 /* These are all used as ball speeds depending on where the ball hit the
347 * Note that all of these speeds (including pad, power, and fire)
348 * could be made variable and could be raised to be much higher to add
349 * additional difficulty to the game. The line intersection tests allow this
350 * to be drastically increased without the collision detection failing
353 #define SPEED_1Q_X SPEED_SCALE_W( 6)
354 #define SPEED_1Q_Y SPEED_SCALE_H(-2)
356 #define SPEED_2Q_X SPEED_SCALE_W( 4)
357 #define SPEED_2Q_Y SPEED_SCALE_H(-3)
359 #define SPEED_3Q_X SPEED_SCALE_W( 3)
360 #define SPEED_3Q_Y SPEED_SCALE_H(-4)
362 #define SPEED_4Q_X SPEED_SCALE_W( 2)
363 #define SPEED_4Q_Y SPEED_SCALE_H(-4)
365 /* This is used to determine the speed of the paddle */
366 #define SPEED_PAD SPEED_SCALE_W( 8)
368 /* This defines the speed that the powerups drop */
369 #define SPEED_POWER SPEED_SCALE_H( 2)
371 /* This defines the speed that the shot moves */
372 #define SPEED_FIRE SPEED_SCALE_H( 4)
373 #define FIRE_LENGTH SPEED_SCALE_H( 7)
382 /* The time ms for one iteration through the game loop - decrease this to speed
383 * up the game - note that current_tick is (currently) only accurate to 10ms.
385 #define CYCLETIME 30 /* ms */
387 #define FLIP_SIDES_DELAY 10 /* seconds */
396 #define SCORE_BALL_HIT_BRICK 2
397 #define SCORE_BALL_DEMOLISHED_BRICK 8
398 #define SCORE_FIRE_HIT_BRICK 13
399 #define SCORE_LEVEL_COMPLETED 100
400 #define SCORE_POWER_LIFE_GAIN 50
401 #define SCORE_POWER_PADDLE_STICKY 34
402 #define SCORE_POWER_PADDLE_SHOOTER 47
403 #define SCORE_POWER_PADDLE_NORMAL 23
404 #define SCORE_POWER_FLIP 23
405 #define SCORE_POWER_EXTRA_BALL 23
406 #define SCORE_POWER_LONG_PADDLE 23
417 #define MAX_POWERS 10
426 #define CONFIG_FILE_NAME "brickmania.cfg"
427 #define SAVE_FILE PLUGIN_GAMES_DIR "/brickmania.save"
428 #define SCORE_FILE PLUGIN_GAMES_DIR "/brickmania.score"
438 #define NUM_BRICKS_ROWS 8
439 #define NUM_BRICKS_COLS 10
441 /* change to however many levels there are, i.e. how many arrays there are total */
442 #define NUM_LEVELS 40
444 /* change the first number in [ ] to however many levels there are */
445 static unsigned char levels
[NUM_LEVELS
][NUM_BRICKS_ROWS
][NUM_BRICKS_COLS
] =
446 /* You can set up new levels with the level editor
447 ( http://plugbox.rockbox-lounge.com/brickmania.htm ).
448 With 0x1, it refers to the first brick in the bitmap, 0x2 would refer to the
449 second, ect., 0x0 leaves a empty space. If you add a 2 before the 2nd number,
450 it will take two hits to break, and 3 hits if you add a 3. That is 0x24, will
451 result with the fourth brick being displayed and having take 2 hits to break.
452 You could do the same with the 3, just replace the 2 with a 3 for it to take
453 three hits to break it apart. */
456 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
457 {0x2,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x2},
458 {0x0,0x2,0x1,0x0,0x0,0x0,0x0,0x1,0x2,0x0},
459 {0x0,0x0,0x2,0x1,0x0,0x0,0x1,0x2,0x0,0x0},
460 {0x0,0x0,0x0,0x2,0x1,0x1,0x2,0x0,0x0,0x0},
461 {0x7,0x0,0x0,0x7,0x2,0x2,0x7,0x0,0x0,0x7},
462 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
463 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
466 {0x0,0x0,0x7,0x7,0x1,0x1,0x7,0x7,0x0,0x0},
467 {0x0,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x0},
468 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
469 {0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1},
470 {0x1,0x1,0x2,0x1,0x0,0x0,0x1,0x2,0x1,0x1},
471 {0x1,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x2,0x1},
472 {0x0,0x1,0x2,0x0,0x0,0x0,0x0,0x2,0x1,0x0},
473 {0x0,0x0,0x1,0x2,0x2,0x2,0x2,0x1,0x0,0x0}
476 {0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
477 {0x3,0x23,0x23,0x3,0x0,0x0,0x2,0x22,0x22,0x2},
478 {0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
479 {0x0,0x0,0x0,0x0,0x37,0x37,0x0,0x0,0x0,0x0},
480 {0x0,0x0,0x0,0x0,0x37,0x37,0x0,0x0,0x0,0x0},
481 {0x5,0x5,0x5,0x5,0x0,0x0,0x6,0x6,0x6,0x6},
482 {0x5,0x25,0x25,0x5,0x0,0x0,0x6,0x26,0x26,0x6},
483 {0x5,0x5,0x5,0x5,0x0,0x0,0x6,0x6,0x6,0x6}
486 {0x0,0x0,0x0,0x27,0x27,0x27,0x27,0x0,0x0,0x0},
487 {0x0,0x0,0x0,0x27,0x7,0x7,0x27,0x0,0x0,0x0},
488 {0x22,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x22},
489 {0x22,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x22},
490 {0x26,0x6,0x0,0x2,0x2,0x2,0x2,0x0,0x6,0x26},
491 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
492 {0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0},
493 {0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1}
496 {0x1,0x0,0x2,0x2,0x0,0x3,0x3,0x0,0x4,0x4},
497 {0x0,0x2,0x2,0x0,0x3,0x3,0x0,0x4,0x4,0x0},
498 {0x2,0x2,0x0,0x3,0x3,0x0,0x4,0x4,0x0,0x5},
499 {0x2,0x0,0x3,0x3,0x0,0x4,0x4,0x0,0x5,0x5},
500 {0x0,0x33,0x3,0x0,0x4,0x4,0x0,0x5,0x5,0x0},
501 {0x3,0x33,0x0,0x4,0x4,0x0,0x5,0x5,0x0,0x36},
502 {0x3,0x0,0x4,0x4,0x0,0x5,0x5,0x0,0x6,0x36},
503 {0x0,0x24,0x24,0x0,0x25,0x25,0x0,0x26,0x26,0x0}
506 {0x0,0x1,0x3,0x7,0x7,0x7,0x7,0x3,0x1,0x0},
507 {0x3,0x1,0x3,0x7,0x0,0x0,0x7,0x3,0x1,0x3},
508 {0x3,0x1,0x3,0x7,0x7,0x7,0x7,0x3,0x1,0x3},
509 {0x0,0x0,0x0,0x2,0x2,0x2,0x2,0x0,0x0,0x0},
510 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
511 {0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x5},
512 {0x0,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x0},
513 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
516 {0x0,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x0},
517 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
518 {0x6,0x0,0x0,0x2,0x2,0x2,0x2,0x0,0x0,0x6},
519 {0x6,0x0,0x0,0x2,0x2,0x2,0x2,0x0,0x0,0x6},
520 {0x6,0x6,0x6,0x0,0x0,0x0,0x0,0x6,0x6,0x6},
521 {0x0,0x0,0x0,0x1,0x1,0x1,0x1,0x0,0x0,0x0},
522 {0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0},
523 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
526 {0x0,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x0},
527 {0x0,0x0,0x0,0x4,0x0,0x0,0x4,0x0,0x0,0x0},
528 {0x6,0x6,0x0,0x2,0x32,0x32,0x2,0x0,0x6,0x6},
529 {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x0},
530 {0x0,0x6,0x6,0x0,0x0,0x0,0x0,0x6,0x6,0x0},
531 {0x0,0x0,0x0,0x5,0x25,0x25,0x5,0x0,0x0,0x0},
532 {0x0,0x5,0x5,0x25,0x5,0x5,0x25,0x5,0x5,0x0},
533 {0x5,0x5,0x25,0x5,0x5,0x5,0x5,0x25,0x5,0x5}
536 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2},
537 {0x2,0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x2},
538 {0x2,0x0,0x3,0x0,0x1,0x1,0x0,0x3,0x0,0x2},
539 {0x2,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x2},
540 {0x2,0x0,0x1,0x0,0x3,0x3,0x0,0x1,0x0,0x2},
541 {0x2,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x2},
542 {0x2,0x2,0x0,0x0,0x1,0x1,0x0,0x0,0x2,0x2},
543 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2}
546 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
547 {0x0,0x5,0x0,0x5,0x0,0x5,0x0,0x5,0x0,0x5},
548 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
549 {0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0},
550 {0x0,0x0,0x0,0x4,0x1,0x1,0x4,0x0,0x0,0x0},
551 {0x0,0x0,0x3,0x4,0x1,0x1,0x4,0x3,0x0,0x0},
552 {0x0,0x2,0x3,0x4,0x1,0x1,0x4,0x3,0x2,0x0},
553 {0x1,0x2,0x3,0x4,0x1,0x1,0x4,0x3,0x2,0x1}
556 {0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3},
557 {0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x2},
558 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2},
559 {0x2,0x0,0x0,0x0,0x7,0x7,0x0,0x0,0x0,0x2},
560 {0x2,0x0,0x0,0x7,0x7,0x7,0x7,0x0,0x0,0x2},
561 {0x0,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x0},
562 {0x0,0x2,0x0,0x1,0x0,0x0,0x1,0x0,0x2,0x0},
563 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5}
566 {0x2,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x2},
567 {0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1},
568 {0x1,0x1,0x1,0x0,0x1,0x1,0x0,0x1,0x1,0x1},
569 {0x0,0x1,0x0,0x1,0x6,0x6,0x1,0x0,0x1,0x0},
570 {0x0,0x0,0x1,0x1,0x6,0x6,0x1,0x1,0x0,0x0},
571 {0x1,0x1,0x1,0x7,0x0,0x0,0x7,0x1,0x1,0x1},
572 {0x1,0x1,0x7,0x1,0x0,0x0,0x1,0x7,0x1,0x1},
573 {0x2,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x2,0x2}
576 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2},
577 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2},
578 {0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x2},
579 {0x2,0x0,0x2,0x3,0x3,0x3,0x3,0x3,0x0,0x2},
580 {0x2,0x0,0x2,0x4,0x4,0x4,0x4,0x4,0x0,0x2},
581 {0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2},
582 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
583 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2}
586 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
587 {0x4,0x4,0x4,0x4,0x2,0x2,0x4,0x4,0x4,0x4},
588 {0x4,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x4},
589 {0x4,0x0,0x0,0x2,0x3,0x3,0x2,0x0,0x0,0x4},
590 {0x4,0x0,0x2,0x23,0x3,0x3,0x23,0x2,0x0,0x4},
591 {0x4,0x0,0x2,0x22,0x2,0x2,0x22,0x2,0x0,0x4},
592 {0x4,0x0,0x6,0x21,0x5,0x5,0x21,0x6,0x0,0x4},
593 {0x4,0x6,0x1,0x1,0x5,0x5,0x1,0x1,0x6,0x4}
596 {0x4,0x4,0x4,0x4,0x4,0x3,0x3,0x3,0x3,0x3},
597 {0x2,0x2,0x1,0x1,0x1,0x1,0x1,0x5,0x0,0x0},
598 {0x2,0x2,0x1,0x1,0x1,0x0,0x1,0x6,0x0,0x0},
599 {0x2,0x1,0x1,0x2,0x1,0x1,0x1,0x5,0x0,0x0},
600 {0x2,0x1,0x2,0x2,0x2,0x1,0x1,0x6,0x0,0x0},
601 {0x2,0x1,0x2,0x2,0x2,0x1,0x3,0x5,0x3,0x0},
602 {0x2,0x1,0x1,0x2,0x1,0x1,0x1,0x6,0x0,0x0},
603 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2}
605 {/* level 16 (Rockbox) by ts-x */
606 {0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x5,0x0,0x5},
607 {0x2,0x0,0x3,0x0,0x3,0x4,0x0,0x5,0x5,0x0},
608 {0x2,0x0,0x3,0x3,0x3,0x4,0x4,0x5,0x0,0x5},
609 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
610 {0x6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
611 {0x7,0x7,0x7,0x1,0x1,0x1,0x2,0x0,0x2,0x0},
612 {0x7,0x0,0x7,0x1,0x0,0x1,0x0,0x2,0x0,0x0},
613 {0x7,0x7,0x7,0x1,0x1,0x1,0x2,0x0,0x2,0x0}
615 {/* level 17 (Alien) by ts-x */
616 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
617 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2},
618 {0x1,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x1},
619 {0x2,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x2},
620 {0x1,0x0,0x1,0x2,0x2,0x2,0x2,0x1,0x0,0x1},
621 {0x2,0x0,0x0,0x1,0x2,0x2,0x1,0x0,0x0,0x2},
622 {0x2,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x2},
623 {0x2,0x2,0x1,0x0,0x1,0x1,0x0,0x1,0x2,0x2}
625 {/* level 18 (Tetris) by ts-x */
626 {0x0,0x2,0x0,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
627 {0x0,0x2,0x7,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
628 {0x2,0x2,0x7,0x0,0x3,0x4,0x0,0x6,0x2,0x2},
629 {0x2,0x2,0x7,0x7,0x3,0x4,0x0,0x6,0x2,0x2},
630 {0x2,0x1,0x7,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
631 {0x2,0x1,0x0,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
632 {0x1,0x1,0x1,0x7,0x3,0x0,0x6,0x6,0x5,0x5},
633 {0x1,0x1,0x1,0x0,0x3,0x0,0x6,0x6,0x5,0x5}
635 { /* level 19 (Stalactites) by ts-x */
636 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
637 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
638 {0x5,0x0,0x6,0x3,0x4,0x7,0x5,0x0,0x1,0x2},
639 {0x5,0x2,0x6,0x3,0x4,0x0,0x5,0x3,0x1,0x2},
640 {0x5,0x0,0x6,0x0,0x4,0x7,0x5,0x0,0x1,0x0},
641 {0x5,0x0,0x0,0x3,0x4,0x0,0x0,0x0,0x1,0x2},
642 {0x0,0x0,0x6,0x0,0x0,0x0,0x5,0x0,0x0,0x0},
643 {0x5,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x1,0x0}
645 { /* level 20 (Maze) by ts-x */
646 {0x1,0x1,0x21,0x1,0x1,0x1,0x1,0x1,0x1,0x21},
647 {0x1,0x0,0x0,0x3,0x0,0x0,0x3,0x1,0x31,0x1},
648 {0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x0,0x1},
649 {0x21,0x0,0x21,0x3,0x0,0x3,0x0,0x3,0x0,0x2},
650 {0x1,0x0,0x1,0x21,0x0,0x12,0x0,0x0,0x0,0x0},
651 {0x31,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x3,0x0},
652 {0x1,0x0,0x1,0x0,0x1,0x1,0x31,0x1,0x1,0x2},
653 {0x22,0x0,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x21}
655 { /* level 21 (Dentist) by ts-x */
656 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
657 {0x2,0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x2,0x2},
658 {0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x2},
659 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x2},
660 {0x2,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x0,0x2},
661 {0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x2},
662 {0x2,0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x2,0x2},
663 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0}
665 { /* level 22 (Spider) by ts-x */
666 {0x31,0x3,0x1,0x1,0x0,0x0,0x1,0x1,0x3,0x31},
667 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
668 {0x33,0x1,0x1,0x36,0x1,0x1,0x36,0x1,0x1,0x33},
669 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
670 {0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x0,0x0},
671 {0x21,0x3,0x1,0x21,0x2,0x2,0x21,0x1,0x3,0x21},
672 {0x0,0x0,0x0,0x1,0x21,0x1,0x1,0x0,0x0,0x0},
673 {0x3,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x3}
675 { /* level 23 (Pool) by ts-x */
676 {0x0,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x7,0x0},
677 {0x0,0x0,0x5,0x0,0x2,0x0,0x0,0x0,0x2,0x0},
678 {0x7,0x3,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x7},
679 {0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x5,0x0,0x7},
680 {0x7,0x0,0x4,0x0,0x0,0x3,0x0,0x0,0x0,0x7},
681 {0x7,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x4,0x7},
682 {0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
683 {0x0,0x7,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x0}
685 { /* level 24 (Vorbis Fish) by ts-x */
686 {0x0,0x0,0x4,0x4,0x5,0x5,0x5,0x0,0x0,0x5},
687 {0x0,0x4,0x6,0x4,0x4,0x5,0x5,0x5,0x0,0x5},
688 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x5,0x5,0x5},
689 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x4,0x5,0x5},
690 {0x0,0x5,0x6,0x4,0x4,0x5,0x5,0x4,0x5,0x0},
691 {0x5,0x5,0x4,0x4,0x5,0x5,0x5,0x4,0x5,0x5},
692 {0x5,0x4,0x4,0x4,0x5,0x5,0x4,0x4,0x5,0x5},
693 {0x0,0x0,0x4,0x4,0x4,0x4,0x4,0x5,0x0,0x5}
695 {/* level 25 (Rainbow) by ts-x */
696 {0x0,0x4,0x1,0x0,0x0,0x0,0x0,0x1,0x4,0x0},
697 {0x24,0x1,0x3,0x1,0x0,0x0,0x21,0x3,0x1,0x24},
698 {0x1,0x23,0x5,0x3,0x1,0x21,0x3,0x5,0x3,0x21},
699 {0x3,0x5,0x6,0x5,0x3,0x3,0x5,0x6,0x5,0x3},
700 {0x5,0x6,0x7,0x6,0x5,0x5,0x6,0x7,0x6,0x5},
701 {0x6,0x7,0x2,0x27,0x6,0x6,0x27,0x2,0x7,0x6},
702 {0x7,0x2,0x0,0x2,0x27,0x27,0x2,0x0,0x2,0x7},
703 {0x32,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x32}
705 { /* level 26 (Bowtie) by ts-x */
706 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5},
707 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
708 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
709 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
710 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
711 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
712 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
713 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5}
715 { /* level 27 (Frog) by ts-x */
716 {0x0,0x5,0x25,0x0,0x0,0x0,0x0,0x25,0x5,0x0},
717 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
718 {0x25,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x25},
719 {0x5,0x0,0x3,0x0,0x6,0x6,0x0,0x3,0x0,0x5},
720 {0x5,0x0,0x31,0x0,0x6,0x6,0x0,0x31,0x0,0x5},
721 {0x5,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x5},
722 {0x5,0x5,0x5,0x35,0x0,0x0,0x35,0x5,0x5,0x5},
723 {0x0,0x25,0x5,0x0,0x4,0x4,0x0,0x5,0x25,0x0}
725 { /* level 28 (DigDug) by ts-x */
726 {0x35,0x5,0x5,0x25,0x0,0x25,0x25,0x5,0x5,0x35},
727 {0x6,0x0,0x0,0x6,0x0,0x6,0x6,0x0,0x0,0x6},
728 {0x7,0x0,0x37,0x37,0x0,0x37,0x37,0x7,0x0,0x7},
729 {0x7,0x0,0x7,0x0,0x0,0x0,0x7,0x7,0x7,0x7},
730 {0x4,0x4,0x4,0x24,0x0,0x24,0x4,0x0,0x0,0x4},
731 {0x4,0x4,0x0,0x0,0x0,0x4,0x4,0x0,0x4,0x4},
732 {0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4},
733 {0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1}
735 { /* level 29 UK Flag by Seth Opgenorth */
736 {0x32,0x0,0x3,0x3,0x2,0x2,0x3,0x3,0x0,0x32},
737 {0x0,0x2,0x0,0x3,0x32,0x22,0x33,0x0,0x32,0x0},
738 {0x33,0x0,0x22,0x0,0x2,0x2,0x0,0x2,0x0,0x33},
739 {0x22,0x32,0x2,0x2,0x2,0x2,0x2,0x2,0x22,0x2},
740 {0x3,0x0,0x0,0x32,0x22,0x2,0x2,0x0,0x0,0x3},
741 {0x23,0x0,0x32,0x0,0x32,0x2,0x0,0x2,0x0,0x3},
742 {0x0,0x2,0x0,0x3,0x2,0x2,0x3,0x0,0x22,0x0},
743 {0x32,0x0,0x3,0x23,0x2,0x2,0x23,0x33,0x0,0x32}
745 { /* level 30 Win-Logo by Seth Opgenorth */
746 {0x0,0x0,0x0,0x22,0x0,0x0,0x0,0x0,0x0,0x0},
747 {0x0,0x0,0x32,0x2,0x2,0x25,0x0,0x5,0x0,0x0},
748 {0x0,0x0,0x2,0x22,0x2,0x5,0x5,0x35,0x0,0x0},
749 {0x0,0x0,0x2,0x1,0x2,0x5,0x5,0x25,0x0,0x0},
750 {0x0,0x0,0x21,0x1,0x1,0x36,0x7,0x26,0x0,0x0},
751 {0x0,0x0,0x1,0x1,0x1,0x6,0x6,0x6,0x0,0x0},
752 {0x0,0x0,0x21,0x0,0x21,0x6,0x6,0x26,0x0,0x0},
753 {0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x0,0x0}
755 { /* level 31 Color wave/V by Seth Opgenorth */
756 {0x25,0x34,0x2,0x31,0x33,0x23,0x1,0x2,0x34,0x5},
757 {0x3,0x5,0x24,0x2,0x1,0x1,0x2,0x4,0x5,0x3},
758 {0x1,0x3,0x5,0x4,0x2,0x2,0x4,0x5,0x3,0x1},
759 {0x2,0x1,0x33,0x35,0x4,0x4,0x5,0x33,0x1,0x22},
760 {0x31,0x22,0x1,0x3,0x5,0x25,0x3,0x1,0x2,0x31},
761 {0x3,0x1,0x2,0x1,0x3,0x3,0x1,0x2,0x21,0x3},
762 {0x5,0x23,0x1,0x32,0x1,0x1,0x2,0x1,0x3,0x5},
763 {0x4,0x35,0x3,0x1,0x2,0x22,0x31,0x3,0x5,0x4}
765 { /* level 32 Sweedish Flag by Seth Opgenorth */
766 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
767 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
768 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
769 {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36},
770 {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36},
771 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
772 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
773 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3}
775 { /* level 33 Color Pyramid by Seth Opgenorth */
776 {0x0,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x0},
777 {0x0,0x0,0x0,0x4,0x24,0x4,0x24,0x0,0x0,0x0},
778 {0x0,0x0,0x23,0x3,0x3,0x3,0x23,0x3,0x0,0x0},
779 {0x0,0x0,0x25,0x5,0x25,0x35,0x5,0x35,0x0,0x0},
780 {0x0,0x36,0x6,0x6,0x6,0x6,0x26,0x6,0x6,0x0},
781 {0x0,0x7,0x7,0x7,0x7,0x25,0x27,0x7,0x27,0x0},
782 {0x2,0x2,0x22,0x2,0x2,0x2,0x22,0x2,0x2,0x2},
783 {0x21,0x1,0x1,0x31,0x1,0x21,0x1,0x1,0x31,0x1}
785 { /* level 34 Rhombus by Seth Opgenorth */
786 {0x0,0x0,0x0,0x0,0x3,0x33,0x0,0x0,0x0,0x0},
787 {0x0,0x0,0x0,0x3,0x32,0x22,0x23,0x0,0x0,0x0},
788 {0x0,0x0,0x3,0x2,0x24,0x4,0x2,0x23,0x0,0x0},
789 {0x26,0x3,0x2,0x4,0x5,0x5,0x4,0x22,0x3,0x6},
790 {0x36,0x3,0x2,0x34,0x5,0x5,0x4,0x2,0x3,0x36},
791 {0x0,0x0,0x3,0x2,0x4,0x34,0x2,0x23,0x0,0x0},
792 {0x0,0x0,0x0,0x23,0x2,0x2,0x3,0x0,0x0,0x0},
793 {0x0,0x0,0x0,0x0,0x3,0x33,0x0,0x0,0x0,0x0}
795 { /* level 35 PacMan Ghost by Seth Opgenorth */
796 {0x0,0x0,0x0,0x0,0x2,0x32,0x2,0x0,0x0,0x0},
797 {0x0,0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x0,0x0},
798 {0x0,0x0,0x2,0x24,0x4,0x2,0x4,0x4,0x32,0x0},
799 {0x0,0x0,0x2,0x24,0x0,0x22,0x24,0x0,0x22,0x0},
800 {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
801 {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
802 {0x0,0x0,0x2,0x32,0x2,0x2,0x22,0x2,0x32,0x0},
803 {0x0,0x0,0x0,0x22,0x0,0x32,0x0,0x22,0x0,0x0}
805 { /* level 36 Star by Seth Opgenorth */
806 {0x3,0x4,0x3,0x4,0x6,0x24,0x3,0x24,0x3,0x0},
807 {0x24,0x0,0x0,0x6,0x6,0x6,0x0,0x0,0x4,0x0},
808 {0x3,0x26,0x6,0x2,0x6,0x2,0x6,0x26,0x23,0x0},
809 {0x4,0x0,0x6,0x6,0x36,0x6,0x6,0x0,0x4,0x0},
810 {0x3,0x0,0x0,0x26,0x6,0x26,0x0,0x0,0x33,0x0},
811 {0x34,0x0,0x6,0x6,0x0,0x6,0x6,0x0,0x4,0x0},
812 {0x3,0x26,0x6,0x0,0x0,0x0,0x6,0x6,0x3,0x0},
813 {0x4,0x3,0x4,0x23,0x24,0x3,0x4,0x33,0x4,0x0}
815 { /* level 37 It's 8-Bit by Seth Opgenorth */
816 {0x26,0x26,0x6,0x6,0x5,0x6,0x26,0x6,0x26,0x6},
817 {0x2,0x2,0x22,0x3,0x3,0x0,0x0,0x0,0x4,0x0},
818 {0x2,0x0,0x2,0x33,0x3,0x3,0x5,0x0,0x24,0x0},
819 {0x32,0x2,0x2,0x33,0x0,0x23,0x0,0x4,0x4,0x4},
820 {0x2,0x22,0x2,0x3,0x3,0x0,0x5,0x4,0x4,0x24},
821 {0x2,0x0,0x2,0x23,0x0,0x3,0x25,0x0,0x4,0x0},
822 {0x22,0x2,0x2,0x3,0x23,0x0,0x5,0x0,0x4,0x0},
823 {0x6,0x26,0x6,0x36,0x6,0x36,0x6,0x6,0x6,0x6}
825 { /* level 38 Linux by Seth Opgenorth */
826 {0x27,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
827 {0x7,0x0,0x0,0x0,0x33,0x0,0x23,0x0,0x0,0x0},
828 {0x7,0x32,0x0,0x0,0x3,0x0,0x23,0x6,0x0,0x6},
829 {0x37,0x0,0x0,0x0,0x23,0x0,0x3,0x6,0x0,0x26},
830 {0x7,0x22,0x24,0x0,0x3,0x33,0x3,0x0,0x26,0x0},
831 {0x37,0x22,0x24,0x24,0x4,0x0,0x0,0x0,0x26,0x0},
832 {0x7,0x2,0x4,0x0,0x4,0x0,0x0,0x6,0x0,0x26},
833 {0x7,0x27,0x4,0x0,0x34,0x0,0x0,0x6,0x0,0x26}
835 { /* level 39 Colorful Squares by Seth Opgenorth*/
836 {0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0},
837 {0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0},
838 {0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0},
839 {0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0},
840 {0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0},
841 {0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0},
842 {0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0},
843 {0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0}
846 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
847 {0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0},
848 {0x32,0x0,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0},
849 {0x32,0x32,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0},
850 {0x32,0x32,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0},
851 {0x32,0x0,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0},
852 {0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0},
853 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
866 POWER_TYPE_LIFE_GAIN
= 0,
867 POWER_TYPE_LIFE_LOSS
,
868 POWER_TYPE_PADDLE_STICKY
,
869 POWER_TYPE_PADDLE_SHOOTER
,
870 POWER_TYPE_PADDLE_NORMAL
,
871 POWER_TYPE_PADDLE_FLIP
,
872 POWER_TYPE_EXTRA_BALL
,
873 POWER_TYPE_PADDLE_LONG
,
874 POWER_TYPE_PADDLE_SHORT
,
878 #define POWERUP_HEIGHT FIXED3(BMPHEIGHT_brickmania_powerups/NUMBER_OF_POWERUPS)
879 /* Increasing this value makes the game with less powerups */
880 #define POWER_RAND (NUMBER_OF_POWERUPS + 15)
882 enum difficulty_options
897 PADDLE_TYPE_NORMAL
= 0,
913 bool used
; /* Is the brick still in play? */
915 int hits
; /* How many hits can this brick take? */
921 /* pos_x and y store the current center position of the ball */
924 /* tempx and tempy store an absolute position the ball should be in. If
925 * they are equal to 0, they are not used when positioning the ball.
929 /* speedx and speedy store the current speed of the ball */
932 bool glue
; /* Is the ball stuck to the paddle? */
937 int top
; /* This stores the fire y position, it is a fixed point num */
938 int x_pos
; /* This stores the fire x position, it is a whole number */
943 int top
; /* This stores the powerup y position, it is a fixed point num */
944 int x_pos
; /* This stores the (middle of) powerup x position, it is a whole number */
945 enum power_types type
; /* This stores the powerup type */
962 struct point top_left
;
963 struct point bottom_right
;
972 static enum game_state game_state
= ST_READY
;
973 static int pad_pos_x
;
975 static int score
=0,vscore
=0;
976 static bool flip_sides
=false;
978 static int brick_on_board
=0;
979 static int used_balls
=1;
980 static int used_fires
=0;
981 static int used_powers
=0;
982 static int difficulty
= NORMAL
;
983 static int pad_width
;
984 static int flip_sides_delay
;
985 static bool resume
= false;
986 static bool resume_file
= false;
987 static struct brick brick
[NUM_BRICKS_ROWS
][NUM_BRICKS_COLS
];
988 static struct ball ball
[MAX_BALLS
];
989 static struct fire fire
[MAX_FIRES
];
990 static struct power power
[MAX_POWERS
];
991 static enum paddle_type paddle_type
;
993 static struct configdata config
[] =
995 {TYPE_INT
, 0, 1, { .int_p
= &difficulty
}, "difficulty", NULL
},
998 static struct highscore highscores
[NUM_SCORES
];
1009 * This is based off an explanation and expanded math presented by Paul Bourke:
1010 * http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
1012 * It takes two lines as inputs and returns 1 if they intersect, 0 if they do
1013 * not. hitp returns the point where the two lines intersected.
1015 * This function expects fixed point inputs with a precision of 3. When a
1016 * collision occurs hitp is updated with a fixed point location (precision 3)
1017 * where the collision happened. The internal calculations are fixed
1018 * point with a 7 bit fractional precision.
1020 * If you choose 10 bits of precision a screen size of about 640x480 is the
1021 * largest this can go. 7 bits allows for an accurate intersection calculation
1022 * with a line length of about 64 and a rougher line lenght of 128 which is
1023 * larger than any target currently needs (the pad is the longest line and it
1024 * only needs an accuracy of 2^4 at most to figure out which section of the pad
1025 * the ball hit). A precision of 7 gives breathing room for larger screens.
1026 * Longer line sizes that need accurate intersection points will need more
1027 * precision, but will decrease the maximum screen resolution.
1031 static int check_lines(struct line
*line1
, struct line
*line2
,
1035 * This code is based on the solution of these two input equations:
1036 * Pa = P1 + ua (P2-P1)
1037 * Pb = P3 + ub (P4-P3)
1039 * Where line one is composed of points P1 and P2 and line two is composed
1040 * of points P3 and P4.
1042 * ua/b is the fractional value you can multiply the x and y legs of the
1043 * triangle formed by each line to find a point on the line.
1045 * The two equations can be expanded to their x/y components:
1046 * Pa.x = p1.x + ua(p2.x - p1.x)
1047 * Pa.y = p1.y + ua(p2.y - p1.y)
1049 * Pb.x = p3.x + ub(p4.x - p3.x)
1050 * Pb.y = p3.y + ub(p4.y - p3.y)
1052 * When Pa.x == Pb.x and Pa.y == Pb.y the lines intersect so you can come
1053 * up with two equations (one for x and one for y):
1055 * p1.x + ua(p2.x - p1.x) = p3.x + ub(p4.x - p3.x)
1056 * p1.y + ua(p2.y - p1.y) = p3.y + ub(p4.y - p3.y)
1058 * ua and ub can then be individually solved for. This results in the
1059 * equations used in the following code.
1062 /* Denominator for ua and ub are the same so store this calculation */
1063 int d
= FIXED3_MUL((line2
->p2
.y
- line2
->p1
.y
),(line1
->p2
.x
-line1
->p1
.x
))
1064 -FIXED3_MUL((line2
->p2
.x
- line2
->p1
.x
),(line1
->p2
.y
-line1
->p1
.y
));
1066 /* n_a and n_b are calculated as seperate values for readability */
1067 int n_a
= FIXED3_MUL((line2
->p2
.x
- line2
->p1
.x
),(line1
->p1
.y
-line2
->p1
.y
))
1068 -FIXED3_MUL((line2
->p2
.y
- line2
->p1
.y
),(line1
->p1
.x
-line2
->p1
.x
));
1070 int n_b
= FIXED3_MUL((line1
->p2
.x
- line1
->p1
.x
),(line1
->p1
.y
-line2
->p1
.y
))
1071 -FIXED3_MUL((line1
->p2
.y
- line1
->p1
.y
),(line1
->p1
.x
-line2
->p1
.x
));
1073 /* Make sure there is not a division by zero - this also indicates that
1074 * the lines are parallel.
1076 * If n_a and n_b were both equal to zero the lines would be on top of each
1077 * other (coincidental). This check is not done because it is not
1078 * necessary for this implementation (the parallel check accounts for this).
1083 /* Calculate the intermediate fractional point that the lines potentially
1086 int ua
= (n_a
<< LINE_PREC
)/d
;
1087 int ub
= (n_b
<< LINE_PREC
)/d
;
1089 /* The fractional point will be between 0 and 1 inclusive if the lines
1090 * intersect. If the fractional calculation is larger than 1 or smaller
1091 * than 0 the lines would need to be longer to intersect.
1093 if(ua
>=0 && ua
<= (1<<LINE_PREC
) && ub
>= 0 && ub
<= (1<<LINE_PREC
))
1095 hitp
->x
= line1
->p1
.x
+ ((ua
* (line1
->p2
.x
- line1
->p1
.x
))>>LINE_PREC
);
1096 hitp
->y
= line1
->p1
.y
+ ((ua
* (line1
->p2
.y
- line1
->p1
.y
))>>LINE_PREC
);
1103 static int check_rect(struct line
*line
, struct rect
*rect
,
1104 enum intersection intersection
, struct point
*hitp
)
1108 switch (intersection
)
1110 case INTERSECTION_TOP
:
1112 edge
.p1
.x
= rect
->top_left
.x
;
1113 edge
.p1
.y
= rect
->top_left
.y
;
1115 edge
.p2
.x
= rect
->bottom_right
.x
;
1116 edge
.p2
.y
= rect
->top_left
.y
;
1120 case INTERSECTION_BOTTOM
:
1122 edge
.p1
.x
= rect
->top_left
.x
;
1123 edge
.p1
.y
= rect
->bottom_right
.y
;
1125 edge
.p2
.x
= rect
->bottom_right
.x
;
1126 edge
.p2
.y
= rect
->bottom_right
.y
;
1130 case INTERSECTION_LEFT
:
1132 edge
.p1
.x
= rect
->top_left
.x
;
1133 edge
.p1
.y
= rect
->top_left
.y
;
1135 edge
.p2
.x
= rect
->top_left
.x
;
1136 edge
.p2
.y
= rect
->bottom_right
.y
;
1140 case INTERSECTION_RIGHT
:
1142 edge
.p1
.x
= rect
->bottom_right
.x
;
1143 edge
.p1
.y
= rect
->top_left
.y
;
1145 edge
.p2
.x
= rect
->bottom_right
.x
;
1146 edge
.p2
.y
= rect
->bottom_right
.y
;
1150 case INTERSECTION_ALL
: /* Test hit on all edges */
1152 return (check_rect(line
, rect
, INTERSECTION_TOP
, hitp
) ||
1153 check_rect(line
, rect
, INTERSECTION_BOTTOM
, hitp
) ||
1154 check_rect(line
, rect
, INTERSECTION_LEFT
, hitp
) ||
1155 check_rect(line
, rect
, INTERSECTION_RIGHT
, hitp
));
1159 return check_lines(line
, &edge
, hitp
);
1162 static void brickmania_init_game(bool new_game
)
1166 pad_pos_x
= GAMESCREEN_WIDTH
/2 - PAD_WIDTH
/2;
1168 for(i
=0;i
<MAX_BALLS
;i
++)
1174 ball
[i
].pos_y
= ON_PAD_POS_Y
;
1175 ball
[i
].pos_x
= GAMESCREEN_WIDTH
/2;
1176 ball
[i
].glue
= false;
1182 game_state
= ST_READY
;
1183 paddle_type
= PADDLE_TYPE_NORMAL
;
1184 pad_width
= PAD_WIDTH
;
1186 flip_sides_delay
= FLIP_SIDES_DELAY
;
1190 /* add one life per achieved level */
1191 if (difficulty
==EASY
&& life
<2) {
1192 score
+=SCORE_LEVEL_COMPLETED
;
1197 for(i
=0;i
<NUM_BRICKS_ROWS
;i
++) {
1198 for(j
=0;j
<NUM_BRICKS_COLS
;j
++) {
1200 brick
[i
][j
].hits
=levels
[level
][i
][j
]>=10?
1201 levels
[level
][i
][j
]/16-1:0;
1202 brick
[i
][j
].hiteffect
=0;
1203 brick
[i
][j
].used
=!(levels
[level
][i
][j
]==0);
1204 brick
[i
][j
].color
=(levels
[level
][i
][j
]>=10?
1205 levels
[level
][i
][j
]%16:
1206 levels
[level
][i
][j
])-1;
1207 if (levels
[level
][i
][j
]!=0)
1214 static void brickmania_loadgame(void)
1220 /* open game file */
1221 fd
= rb
->open(SAVE_FILE
, O_RDONLY
);
1224 /* read in saved game */
1225 if((rb
->read(fd
, &pad_pos_x
, sizeof(pad_pos_x
)) <= 0) ||
1226 (rb
->read(fd
, &life
, sizeof(life
)) <= 0) ||
1227 (rb
->read(fd
, &game_state
, sizeof(game_state
)) <= 0) ||
1228 (rb
->read(fd
, &paddle_type
, sizeof(paddle_type
)) <= 0) ||
1229 (rb
->read(fd
, &score
, sizeof(score
)) <= 0) ||
1230 (rb
->read(fd
, &flip_sides
, sizeof(flip_sides
)) <= 0) ||
1231 (rb
->read(fd
, &level
, sizeof(level
)) <= 0) ||
1232 (rb
->read(fd
, &brick_on_board
, sizeof(brick_on_board
)) <= 0) ||
1233 (rb
->read(fd
, &used_balls
, sizeof(used_balls
)) <= 0) ||
1234 (rb
->read(fd
, &used_fires
, sizeof(used_fires
)) <= 0) ||
1235 (rb
->read(fd
, &used_powers
, sizeof(used_powers
)) <= 0) ||
1236 (rb
->read(fd
, &pad_width
, sizeof(pad_width
)) <= 0) ||
1237 (rb
->read(fd
, &flip_sides_delay
, sizeof(flip_sides_delay
)) <= 0) ||
1238 (rb
->read(fd
, &brick
, sizeof(brick
)) <= 0) ||
1239 (rb
->read(fd
, &ball
, sizeof(ball
)) <= 0) ||
1240 (rb
->read(fd
, &fire
, sizeof(fire
)) <= 0) ||
1241 (rb
->read(fd
, &power
, sizeof(power
)) <= 0))
1243 rb
->splash(HZ
/2, "Failed to load game");
1256 static void brickmania_savegame(void)
1260 /* write out the game state to the save file */
1261 fd
= rb
->open(SAVE_FILE
, O_WRONLY
|O_CREAT
);
1264 if ((rb
->write(fd
, &pad_pos_x
, sizeof(pad_pos_x
)) <= 0) ||
1265 (rb
->write(fd
, &life
, sizeof(life
)) <= 0) ||
1266 (rb
->write(fd
, &game_state
, sizeof(game_state
)) <= 0) ||
1267 (rb
->write(fd
, &paddle_type
, sizeof(paddle_type
)) <= 0) ||
1268 (rb
->write(fd
, &score
, sizeof(score
)) <= 0) ||
1269 (rb
->write(fd
, &flip_sides
, sizeof(flip_sides
)) <= 0) ||
1270 (rb
->write(fd
, &level
, sizeof(level
)) <= 0) ||
1271 (rb
->write(fd
, &brick_on_board
, sizeof(brick_on_board
)) <= 0) ||
1272 (rb
->write(fd
, &used_balls
, sizeof(used_balls
)) <= 0) ||
1273 (rb
->write(fd
, &used_fires
, sizeof(used_fires
)) <= 0) ||
1274 (rb
->write(fd
, &used_powers
, sizeof(used_powers
)) <= 0) ||
1275 (rb
->write(fd
, &pad_width
, sizeof(pad_width
)) <= 0) ||
1276 (rb
->write(fd
, &flip_sides_delay
, sizeof(flip_sides_delay
)) <= 0) ||
1277 (rb
->write(fd
, &brick
, sizeof(brick
)) <= 0) ||
1278 (rb
->write(fd
, &ball
, sizeof(ball
)) <= 0) ||
1279 (rb
->write(fd
, &fire
, sizeof(fire
)) <= 0) ||
1280 (rb
->write(fd
, &power
, sizeof(power
)) <= 0))
1283 rb
->remove(SAVE_FILE
);
1284 rb
->splash(HZ
/2, "Failed to save game");
1291 /* brickmania_sleep timer counting the score */
1292 static void brickmania_sleep(int secs
)
1302 count
= *rb
->current_tick
+ HZ
*secs
;
1303 if ( (TIME_AFTER(*rb
->current_tick
, count
)) && (vscore
== score
) )
1312 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
1313 rb
->lcd_getstringsize(s
, &sw
, &w
);
1314 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
1315 rb
->lcd_update_rect(0,0,LCD_WIDTH
,w
+2);
1321 static int brickmania_help(void)
1323 static char *help_text
[] = {
1324 "Brickmania", "", "Aim", "",
1325 "Destroy", "all", "the", "bricks", "by", "bouncing",
1326 "the", "ball", "of", "them", "using", "the", "paddle.", "", "",
1328 #if CONFIG_KEYPAD == COWON_D2_PAD
1333 "Moves", "the", "paddle", "",
1334 #if CONFIG_KEYPAD == ONDIO_PAD
1336 #elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1338 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
1340 #elif CONFIG_KEYPAD == COWON_D2_PAD
1345 "Releases", "the", "ball/Fire!", "",
1346 #if CONFIG_KEYPAD == IAUDIO_M3_PAD
1348 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
1349 (CONFIG_KEYPAD == CREATIVEZVM_PAD)
1351 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
1352 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
1353 (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
1354 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
1356 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
1357 (CONFIG_KEYPAD == IRIVER_H300_PAD) || \
1358 (CONFIG_KEYPAD == ONDIO_PAD) || \
1359 (CONFIG_KEYPAD == RECORDER_PAD) || \
1360 (CONFIG_KEYPAD == ARCHOS_AV300_PAD)
1365 "Returns", "to", "menu", "", "",
1367 "N", "Normal:", "returns", "paddle", "to", "normal", "",
1368 "D", "DIE!:", "loses", "a", "life", "",
1369 "L", "Life:", "gains", "a", "life/power", "up", "",
1370 "F", "Fire:", "allows", "you", "to", "shoot", "bricks", "",
1371 "G", "Glue:", "ball", "sticks", "to", "paddle", "",
1372 "B", "Ball:", "generates", "another", "ball", "",
1373 "FL", "Flip:", "flips", "left / right", "movement", "",
1374 "<->", "or", "<E>:", "enlarges", "the", "paddle", "",
1375 ">-<", "or", ">S<:", "shrinks", "the", "paddle", "",
1377 static struct style_text formation
[]={
1378 { 0, TEXT_CENTER
|TEXT_UNDERLINE
},
1392 rb
->lcd_setfont(FONT_UI
);
1393 #ifdef HAVE_LCD_COLOR
1394 rb
->lcd_set_background(LCD_BLACK
);
1395 rb
->lcd_set_foreground(LCD_WHITE
);
1397 if (display_text(ARRAYLEN(help_text
), help_text
, formation
, NULL
, true))
1399 rb
->lcd_setfont(FONT_SYSFIXED
);
1404 static int brickmania_menu_cb(int action
, const struct menu_item_ex
*this_item
)
1406 int i
= ((intptr_t)this_item
);
1407 if(action
== ACTION_REQUEST_MENUITEM
1408 && !resume
&& (i
==0 || i
==6))
1409 return ACTION_EXIT_MENUITEM
;
1413 static int brickmania_menu(void)
1417 static struct opt_items options
[] = {
1422 #ifdef HAVE_TOUCHSCREEN
1423 /* Entering Menu, set the touchscreen to the global setting */
1424 rb
->touchscreen_set_mode(rb
->global_settings
->touch_mode
);
1427 MENUITEM_STRINGLIST(main_menu
, "Brickmania Menu", brickmania_menu_cb
,
1428 "Resume Game", "Start New Game",
1429 "Difficulty", "Help", "High Scores",
1431 "Quit without Saving", "Quit");
1433 rb
->button_clear_queue();
1435 switch (rb
->do_menu(&main_menu
, &selected
, NULL
, false)) {
1437 if(game_state
!=ST_READY
)
1438 game_state
= ST_PAUSE
;
1440 rb
->remove(SAVE_FILE
);
1447 brickmania_init_game(true);
1450 rb
->set_option("Difficulty", &difficulty
, INT
,
1454 if (brickmania_help())
1458 highscore_show(-1, highscores
, NUM_SCORES
, true);
1461 if (playback_control(NULL
))
1468 rb
->splash(HZ
*1, "Saving game ...");
1469 brickmania_savegame();
1472 case MENU_ATTACHED_USB
:
1478 #ifdef HAVE_TOUCHSCREEN
1479 rb
->touchscreen_set_mode(TOUCHSCREEN_POINT
);
1483 static void brick_hit(int i
, int j
)
1485 if(!brick
[i
][j
].used
)
1488 /* if this is a crackable brick hits starts as
1491 if (brick
[i
][j
].hits
> 0) {
1493 brick
[i
][j
].hiteffect
++;
1494 score
+=SCORE_BALL_HIT_BRICK
;
1497 brick
[i
][j
].used
=false;
1498 if (used_powers
<MAX_POWERS
)
1500 int ran
= rb
->rand()%POWER_RAND
;
1502 if (ran
<NUMBER_OF_POWERUPS
)
1504 power
[used_powers
].top
= TOPMARGIN
+ i
*BRICK_HEIGHT
;
1505 power
[used_powers
].x_pos
= LEFTMARGIN
+ j
*BRICK_WIDTH
+
1507 power
[used_powers
].type
= ran
;
1512 score
+=SCORE_BALL_DEMOLISHED_BRICK
;
1516 static int brickmania_game_loop(void)
1524 /* pad_rect used for powerup/ball checks */
1525 struct rect pad_rect
;
1526 /* This is used for various lines that are checked (ball and powerup) */
1527 struct line misc_line
;
1529 /* This stores the point that the two lines intersected in a test */
1530 struct point pt_hit
;
1532 if (brickmania_menu()) {
1536 resume_file
= false;
1538 #ifdef HAVE_LCD_COLOR
1539 rb
->lcd_set_background(LCD_BLACK
);
1540 rb
->lcd_set_foreground(LCD_WHITE
);
1541 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1542 rb
->lcd_clear_display();
1546 /* Convert CYCLETIME (in ms) to HZ */
1547 end
= *rb
->current_tick
+ (CYCLETIME
* HZ
) / 1000;
1550 rb
->lcd_clear_display();
1554 if (TIME_AFTER(*rb
->current_tick
, sec_count
))
1556 sec_count
=*rb
->current_tick
+HZ
;
1557 if (flip_sides_delay
!=0)
1562 rb
->snprintf(s
, sizeof(s
), "%d", flip_sides_delay
);
1563 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1564 rb
->lcd_putsxy(LCD_WIDTH
/2-2, INT3(STRINGPOS_FLIP
), s
);
1567 /* write life num */
1568 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1569 rb
->snprintf(s
, sizeof(s
), "L:%d", life
);
1571 rb
->snprintf(s
, sizeof(s
), "Life: %d", life
);
1573 rb
->lcd_putsxy(0, 0, s
);
1575 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1576 rb
->snprintf(s
, sizeof(s
), "L%d", level
+1);
1578 rb
->snprintf(s
, sizeof(s
), "Level %d", level
+1);
1581 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1582 rb
->lcd_putsxy(LCD_WIDTH
-sw
, 0, s
);
1584 if (vscore
<score
) vscore
++;
1585 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
1586 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1587 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
1590 if (game_state
== ST_PAUSE
)
1592 rb
->snprintf(s
, sizeof(s
), CONTINUE_TEXT
);
1593 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1594 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_NAVI
), s
);
1596 sec_count
=*rb
->current_tick
+HZ
;
1600 for(i
=0;i
<used_balls
;i
++)
1601 rb
->lcd_bitmap(brickmania_ball
,
1602 INT3(ball
[i
].pos_x
- HALFBALL
),
1603 INT3(ball
[i
].pos_y
- HALFBALL
),
1604 INT3(BALL
), INT3(BALL
));
1606 if (brick_on_board
==0)
1609 /* Setup the pad line-later used in intersection test */
1610 pad_rect
.top_left
.x
= pad_pos_x
;
1611 pad_rect
.top_left
.y
= PAD_POS_Y
;
1613 pad_rect
.bottom_right
.x
= pad_pos_x
+ pad_width
;
1614 pad_rect
.bottom_right
.y
= PAD_POS_Y
+ PAD_HEIGHT
;
1616 if (game_state
!=ST_PAUSE
)
1618 /* move the fires */
1619 for(k
=0;k
<used_fires
;k
++)
1621 fire
[k
].top
-= SPEED_FIRE
;
1622 if (fire
[k
].top
< 0)
1625 fire
[k
].top
= fire
[used_fires
].top
;
1626 fire
[k
].x_pos
= fire
[used_fires
].x_pos
;
1629 else if (fire
[k
].x_pos
>= LEFTMARGIN
&&
1630 fire
[k
].x_pos
< LEFTMARGIN
+ NUM_BRICKS_COLS
* BRICK_WIDTH
)
1632 j
= (fire
[k
].x_pos
- LEFTMARGIN
) / BRICK_WIDTH
;
1633 for (i
=NUM_BRICKS_ROWS
-1;i
>=0;i
--)
1636 if (brick
[i
][j
].used
)
1638 score
+= SCORE_FIRE_HIT_BRICK
;
1641 fire
[k
].top
= fire
[used_fires
].top
;
1642 fire
[k
].x_pos
= fire
[used_fires
].x_pos
;
1646 if (TOPMARGIN
+ i
*BRICK_HEIGHT
<=fire
[k
].top
)
1652 /* move and handle the powerups */
1653 for (k
=0;k
<used_powers
;k
++)
1655 int remove_power
= 0;
1657 power
[k
].top
+= SPEED_POWER
;
1659 if (power
[k
].top
> PAD_POS_Y
)
1661 /* power hit bottom */
1666 /* Use misc_line to check if the center of the powerup
1669 misc_line
.p1
.x
= power
[k
].x_pos
;
1670 misc_line
.p1
.y
= power
[k
].top
;
1672 misc_line
.p2
= misc_line
.p1
;
1673 misc_line
.p2
.y
+= SPEED_POWER
;
1675 /* Check if the powerup will hit the paddle */
1676 if (check_rect(&misc_line
, &pad_rect
, INTERSECTION_ALL
,
1680 /* power hit paddle */
1682 switch(power
[k
].type
)
1684 case POWER_TYPE_LIFE_GAIN
:
1686 score
+= SCORE_POWER_LIFE_GAIN
;
1688 case POWER_TYPE_LIFE_LOSS
:
1692 brickmania_init_game(false);
1693 brickmania_sleep(2);
1696 case POWER_TYPE_PADDLE_STICKY
:
1697 score
+= SCORE_POWER_PADDLE_STICKY
;
1698 paddle_type
= PADDLE_TYPE_STICKY
;
1700 case POWER_TYPE_PADDLE_SHOOTER
:
1701 score
+= SCORE_POWER_PADDLE_SHOOTER
;
1702 paddle_type
= PADDLE_TYPE_SHOOTER
;
1703 for(i
=0;i
<used_balls
;i
++)
1706 case POWER_TYPE_PADDLE_NORMAL
:
1707 score
+= SCORE_POWER_PADDLE_NORMAL
;
1708 paddle_type
= PADDLE_TYPE_NORMAL
;
1709 for(i
=0;i
<used_balls
;i
++)
1712 pad_pos_x
+= (pad_width
-PAD_WIDTH
)/2;
1713 pad_width
= PAD_WIDTH
;
1715 case POWER_TYPE_PADDLE_FLIP
:
1716 score
+= SCORE_POWER_FLIP
;
1717 sec_count
= *rb
->current_tick
+HZ
;
1718 flip_sides_delay
= FLIP_SIDES_DELAY
;
1721 case POWER_TYPE_EXTRA_BALL
:
1722 score
+= SCORE_POWER_EXTRA_BALL
;
1723 if(used_balls
<MAX_BALLS
)
1726 if(rb
->rand()%2 == 0)
1727 ball
[used_balls
].speedx
=-SPEED_4Q_X
;
1729 ball
[used_balls
].speedx
= SPEED_4Q_X
;
1730 ball
[used_balls
].speedy
= SPEED_4Q_Y
;
1731 /* Ball is not glued */
1732 ball
[used_balls
].glue
= false;
1736 case POWER_TYPE_PADDLE_LONG
:
1737 score
+=SCORE_POWER_LONG_PADDLE
;
1738 if (pad_width
==PAD_WIDTH
)
1740 pad_width
= LONG_PAD_WIDTH
;
1741 pad_pos_x
-= (LONG_PAD_WIDTH
-
1744 else if (pad_width
==SHORT_PAD_WIDTH
)
1746 pad_width
= PAD_WIDTH
;
1747 pad_pos_x
-=(PAD_WIDTH
-
1752 else if(pad_pos_x
+ pad_width
>
1754 pad_pos_x
= GAMESCREEN_WIDTH
-pad_width
;
1756 case POWER_TYPE_PADDLE_SHORT
:
1757 if (pad_width
==PAD_WIDTH
)
1759 pad_width
=SHORT_PAD_WIDTH
;
1760 pad_pos_x
+=(PAD_WIDTH
-
1763 else if (pad_width
==LONG_PAD_WIDTH
)
1765 pad_width
=PAD_WIDTH
;
1766 pad_pos_x
+=(LONG_PAD_WIDTH
-PAD_WIDTH
)/2;
1777 if (k
!= used_powers
)
1779 power
[k
].top
= power
[used_powers
].top
;
1780 power
[k
].x_pos
= power
[used_powers
].x_pos
;
1781 power
[k
].type
= power
[used_powers
].type
;
1789 /* draw the fires */
1790 for(k
=0;k
<used_fires
;k
++)
1792 rb
->lcd_vline(INT3(fire
[k
].x_pos
), INT3(fire
[k
].top
),
1793 INT3(fire
[k
].top
+ FIRE_LENGTH
));
1796 /* draw the powerups */
1797 for(k
=0;k
<used_powers
;k
++)
1799 rb
->lcd_bitmap_part(brickmania_powerups
,0,
1800 INT3(POWERUP_HEIGHT
)*power
[k
].type
,
1801 STRIDE(SCREEN_MAIN
, BMPWIDTH_brickmania_powerups
,
1802 BMPHEIGHT_brickmania_powerups
),
1803 INT3(power
[k
].x_pos
- (POWERUP_WIDTH
>> 1)),
1804 INT3(power
[k
].top
), INT3(POWERUP_WIDTH
),
1805 INT3(POWERUP_HEIGHT
));
1808 /* handle all of the bricks */
1809 for (i
=0; i
<NUM_BRICKS_ROWS
; i
++)
1811 for (j
=0; j
<NUM_BRICKS_COLS
;j
++)
1815 /* The brick is a brick, but it may or may not be in use */
1816 if(brick
[i
][j
].used
)
1818 struct rect brick_rect
;
1820 brickx
= LEFTMARGIN
+ j
*BRICK_WIDTH
;
1821 bricky
= TOPMARGIN
+ i
*BRICK_HEIGHT
;
1823 brick_rect
.top_left
.x
= brickx
;
1824 brick_rect
.top_left
.y
= bricky
;
1826 brick_rect
.bottom_right
.x
= brickx
+ BRICK_WIDTH
;
1827 brick_rect
.bottom_right
.y
= bricky
+ BRICK_HEIGHT
;
1829 /* Draw the brick */
1830 rb
->lcd_bitmap_part(brickmania_bricks
,0,
1831 INT3(BRICK_HEIGHT
)*brick
[i
][j
].color
,
1832 STRIDE( SCREEN_MAIN
,
1833 BMPWIDTH_brickmania_bricks
,
1834 BMPHEIGHT_brickmania_bricks
),
1837 INT3(BRICK_WIDTH
), INT3(BRICK_HEIGHT
) );
1839 #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
1840 if (brick
[i
][j
].hiteffect
> 0)
1841 rb
->lcd_bitmap_transparent_part(brickmania_break
,0,
1842 INT3(BRICK_HEIGHT
)*brick
[i
][j
].hiteffect
,
1843 STRIDE( SCREEN_MAIN
,
1844 BMPWIDTH_brickmania_break
,
1845 BMPHEIGHT_brickmania_break
),
1848 INT3(BRICK_WIDTH
), INT3(BRICK_HEIGHT
) );
1851 /* Check if any balls collided with the brick */
1852 for(k
=0; k
<used_balls
; k
++)
1856 /* Setup the ball path to describe the current ball
1857 * position and the line it makes to its next
1860 misc_line
.p1
.x
= ball
[k
].pos_x
;
1861 misc_line
.p1
.y
= ball
[k
].pos_y
;
1863 misc_line
.p2
.x
= ball
[k
].pos_x
+ ball
[k
].speedx
;
1864 misc_line
.p2
.y
= ball
[k
].pos_y
+ ball
[k
].speedy
;
1866 /* Check to see if the ball and the bottom hit. If
1867 * the ball is moving down we don't want to
1868 * include the bottom line intersection.
1870 * The order that the sides are checked matters.
1872 * Note that tempx/tempy store the next position
1873 * that the ball should be drawn.
1875 if (ball
[k
].speedy
<= 0 && check_rect(&misc_line
,
1876 &brick_rect
, INTERSECTION_BOTTOM
, &pt_hit
))
1878 ball
[k
].speedy
= -ball
[k
].speedy
;
1881 /* Check the top, if the ball is moving up dont
1882 * count it as a hit.
1884 else if (ball
[k
].speedy
> 0 && check_rect(&misc_line
,
1885 &brick_rect
, INTERSECTION_TOP
, &pt_hit
))
1887 ball
[k
].speedy
= -ball
[k
].speedy
;
1890 /* Check the left side of the brick */
1891 else if (check_rect(&misc_line
, &brick_rect
,
1892 INTERSECTION_LEFT
, &pt_hit
))
1894 ball
[k
].speedx
= -ball
[k
].speedx
;
1897 /* Check the right side of the brick */
1898 else if (check_rect(&misc_line
, &brick_rect
,
1899 INTERSECTION_RIGHT
, &pt_hit
))
1901 ball
[k
].speedx
= -ball
[k
].speedx
;
1907 ball
[k
].tempy
= pt_hit
.y
;
1908 ball
[k
].tempx
= pt_hit
.x
;
1917 /* draw the paddle according to the PAD_WIDTH */
1918 if( pad_width
== PAD_WIDTH
) /* Normal width */
1920 rb
->lcd_bitmap_part(
1922 0, paddle_type
*INT3(PAD_HEIGHT
),
1923 STRIDE( SCREEN_MAIN
, BMPWIDTH_brickmania_pads
,
1924 BMPHEIGHT_brickmania_pads
),
1925 INT3(pad_pos_x
), INT3(PAD_POS_Y
),
1926 INT3(pad_width
), INT3(PAD_HEIGHT
) );
1928 else if( pad_width
== LONG_PAD_WIDTH
) /* Long Pad */
1930 rb
->lcd_bitmap_part(
1931 brickmania_long_pads
,
1932 0,paddle_type
*INT3(PAD_HEIGHT
),
1933 STRIDE( SCREEN_MAIN
, BMPWIDTH_brickmania_long_pads
,
1934 BMPHEIGHT_brickmania_long_pads
),
1935 INT3(pad_pos_x
), INT3(PAD_POS_Y
),
1936 INT3(pad_width
), INT3(PAD_HEIGHT
) );
1938 else /* Short pad */
1940 rb
->lcd_bitmap_part(
1941 brickmania_short_pads
,
1942 0,paddle_type
*INT3(PAD_HEIGHT
),
1943 STRIDE( SCREEN_MAIN
, BMPWIDTH_brickmania_short_pads
,
1944 BMPHEIGHT_brickmania_short_pads
),
1945 INT3(pad_pos_x
), INT3(PAD_POS_Y
),
1946 INT3(pad_width
), INT3(PAD_HEIGHT
) );
1949 /* If the game is not paused continue */
1950 if (game_state
!=ST_PAUSE
)
1952 /* Loop through all of the balls in play */
1953 for(k
=0;k
<used_balls
;k
++)
1955 struct line screen_edge
;
1957 /* Describe the ball movement for the edge collision detection */
1958 misc_line
.p1
.x
= ball
[k
].pos_x
;
1959 misc_line
.p1
.y
= ball
[k
].pos_y
;
1961 misc_line
.p2
.x
= ball
[k
].pos_x
+ ball
[k
].speedx
;
1962 misc_line
.p2
.y
= ball
[k
].pos_y
+ ball
[k
].speedy
;
1964 /* Did the Ball hit the top of the screen? */
1965 screen_edge
.p1
.x
= 0;
1966 screen_edge
.p1
.y
= 0;
1968 screen_edge
.p2
.x
= GAMESCREEN_WIDTH
;
1969 screen_edge
.p2
.y
= 0;
1970 /* the test for pos_y prevents the ball from bouncing back
1971 * from _over_ the top to infinity on some rare cases */
1972 if (ball
[k
].pos_y
> 0 &&
1973 check_lines(&misc_line
, &screen_edge
, &pt_hit
))
1975 ball
[k
].tempy
= pt_hit
.y
+ 1;
1976 ball
[k
].tempx
= pt_hit
.x
;
1977 /* Reverse the direction */
1978 ball
[k
].speedy
= -ball
[k
].speedy
;
1981 /* Player missed the ball and hit bottom of screen */
1982 if (ball
[k
].pos_y
>= GAMESCREEN_HEIGHT
)
1984 /* Player had balls to spare, so handle the removal */
1987 /* decrease number of balls in play */
1989 /* Replace removed ball with the last ball */
1990 ball
[k
].pos_x
= ball
[used_balls
].pos_x
;
1991 ball
[k
].pos_y
= ball
[used_balls
].pos_y
;
1992 ball
[k
].speedy
= ball
[used_balls
].speedy
;
1993 ball
[k
].tempy
= ball
[used_balls
].tempy
;
1994 ball
[k
].speedx
= ball
[used_balls
].speedx
;
1995 ball
[k
].tempx
= ball
[used_balls
].tempx
;
1996 ball
[k
].glue
= ball
[used_balls
].glue
;
1998 /* Reset the last ball that was removed */
1999 ball
[used_balls
].speedx
=0;
2000 ball
[used_balls
].speedy
=0;
2001 ball
[used_balls
].tempy
=0;
2002 ball
[used_balls
].tempx
=0;
2003 ball
[used_balls
].pos_y
=ON_PAD_POS_Y
;
2004 ball
[used_balls
].pos_x
=pad_pos_x
+(pad_width
/2)-2;
2011 /* Player lost a life */
2015 /* No lives left reset game */
2016 brickmania_init_game(false);
2017 brickmania_sleep(2);
2018 rb
->button_clear_queue();
2023 if (game_state
!= ST_READY
&& !ball
[k
].glue
)
2025 /* Check if the ball hit the left side */
2026 screen_edge
.p1
.x
= 0;
2027 screen_edge
.p1
.y
= 0;
2029 screen_edge
.p2
.x
= 0;
2030 screen_edge
.p2
.y
= GAMESCREEN_HEIGHT
;
2031 if (check_lines(&misc_line
, &screen_edge
, &pt_hit
))
2033 /* Reverse direction */
2034 ball
[k
].speedx
= -ball
[k
].speedx
;
2036 /* Re-position ball in gameboard */
2037 ball
[k
].tempy
= pt_hit
.y
;
2041 /* Check if the ball hit the right side */
2042 screen_edge
.p1
.x
= GAMESCREEN_WIDTH
;
2043 screen_edge
.p1
.y
= 0;
2045 screen_edge
.p2
.x
= GAMESCREEN_WIDTH
;
2046 screen_edge
.p2
.y
= GAMESCREEN_HEIGHT
;
2047 if (check_lines(&misc_line
, &screen_edge
, &pt_hit
))
2049 /* Reverse direction */
2050 ball
[k
].speedx
= -ball
[k
].speedx
;
2052 /* Re-position ball in gameboard */
2053 ball
[k
].tempy
= pt_hit
.y
;
2054 ball
[k
].tempx
= GAMESCREEN_WIDTH
- FIXED3(1);
2057 /* Did the ball hit the paddle? Depending on where the ball
2058 * Hit set the x/y speed appropriately.
2060 if(check_rect(&misc_line
, &pad_rect
, INTERSECTION_TOP
,
2063 /* Re-position ball based on collision */
2064 ball
[k
].tempy
= ON_PAD_POS_Y
;
2065 ball
[k
].tempx
= pt_hit
.x
;
2067 /* Calculate the ball position relative to the paddle width */
2068 int ball_repos
= pt_hit
.x
- pad_pos_x
;
2069 /* If the ball hits the right half of paddle, x speed
2070 * should be positive, if it hits the left half it
2071 * should be negative.
2073 int x_direction
= -1;
2075 /* Comparisons are done with respect to 1/2 pad_width */
2076 if(ball_repos
> pad_width
/2)
2078 /* flip the relative position */
2079 ball_repos
-= ((ball_repos
- pad_width
/2) << 1);
2080 /* Ball hit the right half so X speed calculations
2081 * should be positive.
2086 /* Figure out where the ball hit relative to 1/2 pad
2087 * and in divisions of 4.
2089 ball_repos
= ball_repos
/ (pad_width
/2/4);
2093 /* Ball hit the outer edge of the paddle */
2095 ball
[k
].speedy
= SPEED_1Q_Y
;
2096 ball
[k
].speedx
= SPEED_1Q_X
* x_direction
;
2098 /* Ball hit the next fourth of the paddle */
2100 ball
[k
].speedy
= SPEED_2Q_Y
;
2101 ball
[k
].speedx
= SPEED_2Q_X
* x_direction
;
2103 /* Ball hit the third fourth of the paddle */
2105 ball
[k
].speedy
= SPEED_3Q_Y
;
2106 ball
[k
].speedx
= SPEED_3Q_X
* x_direction
;
2108 /* Ball hit the fourth fourth of the paddle or dead
2113 ball
[k
].speedy
= SPEED_4Q_Y
;
2114 /* Since this is the middle we don't want to
2115 * force the ball in a different direction.
2116 * Just keep it going in the same direction
2117 * with a specific speed.
2119 if(ball
[k
].speedx
> 0)
2121 ball
[k
].speedx
= SPEED_4Q_X
;
2125 ball
[k
].speedx
= -SPEED_4Q_X
;
2130 ball
[k
].speedy
= SPEED_4Q_Y
;
2134 if(paddle_type
== PADDLE_TYPE_STICKY
)
2136 ball
[k
].speedy
= -ball
[k
].speedy
;
2139 /* X location should not be forced since that is moved with the paddle. The Y
2140 * position should be forced to keep the ball at the paddle.
2143 ball
[k
].tempy
= ON_PAD_POS_Y
;
2148 /* Update the ball position */
2152 ball
[k
].pos_x
= ball
[k
].tempx
;
2154 ball
[k
].pos_x
+= ball
[k
].speedx
;
2157 ball
[k
].pos_y
= ball
[k
].tempy
;
2159 ball
[k
].pos_y
+= ball
[k
].speedy
;
2169 if (brick_on_board
< 0)
2171 if (level
+1<NUM_LEVELS
)
2174 if (difficulty
==NORMAL
)
2175 score
+=SCORE_LEVEL_COMPLETED
;
2176 brickmania_init_game(true);
2177 brickmania_sleep(2);
2178 rb
->button_clear_queue();
2182 rb
->lcd_getstringsize("Congratulations!", &sw
, NULL
);
2183 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_CONGRATS
),
2184 "Congratulations!");
2185 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
2186 rb
->lcd_getstringsize("No more levels", &sw
, NULL
);
2187 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_FINISH
),
2190 rb
->lcd_getstringsize("You have finished the game!",
2192 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_FINISH
),
2193 "You have finished the game!");
2197 brickmania_sleep(2);
2202 int button
=rb
->button_get(false);
2203 int move_button
= rb
->button_status();
2205 #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN)
2206 /* FIXME: Should probably check remote hold here */
2207 if (rb
->button_hold())
2211 #ifdef HAVE_TOUCHSCREEN
2212 if( move_button
& BUTTON_TOUCHSCREEN
)
2215 short touch_x
, touch_y
;
2216 rb
->button_status_wdata(&data
);
2217 touch_x
= FIXED3(data
>> 16);
2218 touch_y
= FIXED3(data
& 0xffff);
2222 pad_pos_x
= GAMESCREEN_WIDTH
- (touch_x
+ pad_width
/2);
2226 pad_pos_x
= (touch_x
- pad_width
/2);
2231 else if(pad_pos_x
+ pad_width
> GAMESCREEN_WIDTH
)
2232 pad_pos_x
= GAMESCREEN_WIDTH
-pad_width
;
2233 for(k
=0; k
<used_balls
; k
++)
2234 if (game_state
==ST_READY
|| ball
[k
].glue
)
2235 ball
[k
].pos_x
= pad_pos_x
+ pad_width
/2;
2240 int button_right
, button_left
;
2242 button_right
= move_button
& (RIGHT
| ALTRIGHT
);
2243 button_left
= move_button
& (LEFT
| ALTLEFT
);
2245 button_right
=((move_button
& RIGHT
)|| SCROLL_FWD(button
));
2246 button_left
=((move_button
& LEFT
) ||SCROLL_BACK(button
));
2248 if ((game_state
==ST_PAUSE
) && (button_right
|| button_left
))
2250 if ((button_right
&& !flip_sides
) ||
2251 (button_left
&& flip_sides
))
2253 if (pad_pos_x
+SPEED_PAD
+pad_width
> GAMESCREEN_WIDTH
)
2255 for(k
=0;k
<used_balls
;k
++)
2256 if (game_state
==ST_READY
|| ball
[k
].glue
)
2257 ball
[k
].pos_x
+= GAMESCREEN_WIDTH
-pad_pos_x
-
2259 pad_pos_x
+= GAMESCREEN_WIDTH
- pad_pos_x
- pad_width
;
2262 for(k
=0;k
<used_balls
;k
++)
2263 if ((game_state
==ST_READY
|| ball
[k
].glue
))
2264 ball
[k
].pos_x
+=SPEED_PAD
;
2265 pad_pos_x
+=SPEED_PAD
;
2268 else if ((button_left
&& !flip_sides
) ||
2269 (button_right
&& flip_sides
))
2271 if (pad_pos_x
-SPEED_PAD
< 0)
2273 for(k
=0;k
<used_balls
;k
++)
2274 if (game_state
==ST_READY
|| ball
[k
].glue
)
2275 ball
[k
].pos_x
-=pad_pos_x
;
2276 pad_pos_x
-= pad_pos_x
;
2280 for(k
=0;k
<used_balls
;k
++)
2281 if (game_state
==ST_READY
|| ball
[k
].glue
)
2282 ball
[k
].pos_x
-=SPEED_PAD
;
2283 pad_pos_x
-=SPEED_PAD
;
2290 #if defined(HAVE_TOUCHSCREEN)
2291 case (BUTTON_REL
| BUTTON_TOUCHSCREEN
):
2298 if (game_state
==ST_READY
)
2300 /* Initialize used balls starting speed */
2301 for(k
=0 ; k
< used_balls
; k
++)
2303 ball
[k
].speedy
= SPEED_4Q_Y
;
2304 if(pad_pos_x
+ (pad_width
/2) >= GAMESCREEN_WIDTH
/2)
2306 ball
[k
].speedx
= SPEED_4Q_X
;
2310 ball
[k
].speedx
= -SPEED_4Q_X
;
2313 game_state
=ST_START
;
2315 else if (game_state
==ST_PAUSE
)
2317 game_state
=ST_START
;
2319 else if (paddle_type
== PADDLE_TYPE_STICKY
)
2321 for(k
=0;k
<used_balls
;k
++)
2326 ball
[k
].speedy
= -ball
[k
].speedy
;
2330 else if (paddle_type
== PADDLE_TYPE_SHOOTER
)
2332 if (used_fires
< MAX_FIRES
)
2334 fire
[used_fires
].top
= PAD_POS_Y
- FIRE_LENGTH
;
2335 fire
[used_fires
].x_pos
= pad_pos_x
+ 1; /* Add 1 for edge */
2338 if (used_fires
< MAX_FIRES
)
2340 fire
[used_fires
].top
= PAD_POS_Y
- FIRE_LENGTH
;
2341 fire
[used_fires
].x_pos
= pad_pos_x
+ pad_width
- 1; /* Sub1 edge*/
2355 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
2362 #ifdef HAVE_LCD_COLOR
2363 rb
->lcd_bitmap_transparent(brickmania_gameover
,
2364 (LCD_WIDTH
- INT3(GAMEOVER_WIDTH
))/2,
2365 INT3(GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2366 INT3(GAMEOVER_WIDTH
),INT3(GAMEOVER_HEIGHT
));
2367 #else /* greyscale and mono */
2368 rb
->lcd_bitmap(brickmania_gameover
,(LCD_WIDTH
-
2369 INT3(GAMEOVER_WIDTH
))/2,
2370 INT3(GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2371 INT3(GAMEOVER_WIDTH
),INT3(GAMEOVER_HEIGHT
) );
2374 brickmania_sleep(2);
2378 /* Game always needs to yield for other threads */
2381 /* Sleep for a bit if there is time to spare */
2382 if (TIME_BEFORE(*rb
->current_tick
, end
))
2383 rb
->sleep(end
-*rb
->current_tick
);
2388 /* this is the plugin entry point */
2389 enum plugin_status
plugin_start(const void* parameter
)
2392 int last_difficulty
;
2394 highscore_load(SCORE_FILE
, highscores
, NUM_SCORES
);
2395 configfile_load(CONFIG_FILE_NAME
,config
,1,0);
2396 last_difficulty
= difficulty
;
2398 #ifdef HAVE_TOUCHSCREEN
2399 rb
->touchscreen_set_mode(TOUCHSCREEN_POINT
);
2402 rb
->lcd_setfont(FONT_SYSFIXED
);
2404 rb
->lcd_set_backdrop(NULL
);
2406 /* Turn off backlight timeout */
2407 backlight_force_on(); /* backlight control in lib/helper.c */
2409 /* now go ahead and have fun! */
2410 rb
->srand( *rb
->current_tick
);
2411 brickmania_loadgame();
2412 resume_file
= resume
;
2413 while(!brickmania_game_loop())
2417 int position
= highscore_update(score
, level
+1, "",
2418 highscores
, NUM_SCORES
);
2422 rb
->splash(HZ
*2, "New High Score");
2423 highscore_show(position
, highscores
, NUM_SCORES
, true);
2427 brickmania_sleep(3);
2432 highscore_save(SCORE_FILE
, highscores
, NUM_SCORES
);
2433 if(last_difficulty
!= difficulty
)
2434 configfile_save(CONFIG_FILE_NAME
,config
,1,0);
2435 /* Restore user's original backlight setting */
2436 rb
->lcd_setfont(FONT_UI
);
2437 /* Turn on backlight timeout (revert to settings) */
2438 backlight_use_settings(); /* backlight control in lib/helper.c */