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
246 #elif CONFIG_KEYPAD == MPIO_HD200_PAD
247 #define QUIT (BUTTON_REC|BUTTON_PLAY)
248 #define LEFT BUTTON_VOL_DOWN
249 #define RIGHT BUTTON_VOL_UP
250 #define SELECT BUTTON_SELECT
251 #define UP BUTTON_PREV
252 #define DOWN BUTTON_NEXT
255 #error No keymap defined!
258 #ifdef HAVE_TOUCHSCREEN
260 #define ALTLEFT BUTTON_BOTTOMLEFT
262 #define LEFT BUTTON_BOTTOMLEFT
265 #define ALTRIGHT BUTTON_BOTTOMRIGHT
267 #define RIGHT BUTTON_BOTTOMRIGHT
270 #define ALTSELECT BUTTON_CENTER
272 #define SELECT BUTTON_CENTER
275 #define UP BUTTON_TOPMIDDLE
278 #define DOWN BUTTON_BOTTOMMIDDLE
282 /* Continue text is used as a string later when the game is paused. This allows
283 * targets to specify their own text if needed.
285 #if !defined(CONTINUE_TEXT)
286 #define CONTINUE_TEXT "Press SELECT To Continue"
289 #ifndef SCROLL_FWD /* targets without scroll wheel*/
290 #define SCROLL_FWD(x) (0)
291 #define SCROLL_BACK(x) (0)
295 #define NUM_BRICKS_ROWS 8
296 #define NUM_BRICKS_COLS 10
300 * Geometric dimensions
304 /* If there are three fractional bits, the smallest screen size that will scale
305 * properly is 28x22. If you have a smaller screen increase the fractional
306 * precision. If you have a precision of 4 the smallest screen size would be
307 * 14x11. Note though that this will decrease the maximum resolution due to
308 * the line intersection tests. These defines are used for all of the fixed
309 * point calculations/conversions.
311 #define FIXED3(x) ((x)<<3)
312 #define FIXED3_MUL(x, y) ((long long)((x)*(y))>>3)
313 #define FIXED3_DIV(x, y) (((x)<<3)/(y))
314 #define INT3(x) ((x)>>3)
316 #define GAMESCREEN_WIDTH FIXED3(LCD_WIDTH)
317 #define GAMESCREEN_HEIGHT FIXED3(LCD_HEIGHT)
319 #define PAD_WIDTH FIXED3(BMPWIDTH_brickmania_pads)
320 #define PAD_HEIGHT FIXED3(BMPHEIGHT_brickmania_pads/3)
321 #define SHORT_PAD_WIDTH FIXED3(BMPWIDTH_brickmania_short_pads)
322 #define LONG_PAD_WIDTH FIXED3(BMPWIDTH_brickmania_long_pads)
323 #define BRICK_HEIGHT FIXED3(BMPHEIGHT_brickmania_bricks/7)
324 #define BRICK_WIDTH FIXED3(BMPWIDTH_brickmania_bricks)
325 #define LEFTMARGIN ((GAMESCREEN_WIDTH-NUM_BRICKS_COLS*BRICK_WIDTH)/2)
326 #define POWERUP_WIDTH FIXED3(BMPWIDTH_brickmania_powerups)
327 #define BALL FIXED3(BMPHEIGHT_brickmania_ball)
328 #define HALFBALL (BALL / 2)
329 #define PAD_POS_Y (GAMESCREEN_HEIGHT - PAD_HEIGHT - 1)
330 #define ON_PAD_POS_Y (PAD_POS_Y - HALFBALL)
332 #define GAMEOVER_WIDTH FIXED3(BMPWIDTH_brickmania_gameover)
333 #define GAMEOVER_HEIGHT FIXED3(BMPHEIGHT_brickmania_gameover)
335 #define TOPMARGIN MAX(BRICK_HEIGHT, FIXED3(8))
337 #define STRINGPOS_FINISH (GAMESCREEN_HEIGHT - (GAMESCREEN_HEIGHT / 6))
338 #define STRINGPOS_NAVI (STRINGPOS_FINISH - 10)
339 #define STRINGPOS_FLIP (STRINGPOS_FINISH - 10)
348 /* Brickmania was originally designed for the H300, other targets should scale
349 * the speed up/down as needed based on the screen height.
351 #define SPEED_SCALE_H(y) FIXED3_DIV(GAMESCREEN_HEIGHT, FIXED3(176)/(y) )
352 #define SPEED_SCALE_W(x) FIXED3_DIV(GAMESCREEN_WIDTH, FIXED3(220)/(x) )
354 /* These are all used as ball speeds depending on where the ball hit the
357 * Note that all of these speeds (including pad, power, and fire)
358 * could be made variable and could be raised to be much higher to add
359 * additional difficulty to the game. The line intersection tests allow this
360 * to be drastically increased without the collision detection failing
363 #define SPEED_1Q_X SPEED_SCALE_W( 6)
364 #define SPEED_1Q_Y SPEED_SCALE_H(-2)
366 #define SPEED_2Q_X SPEED_SCALE_W( 4)
367 #define SPEED_2Q_Y SPEED_SCALE_H(-3)
369 #define SPEED_3Q_X SPEED_SCALE_W( 3)
370 #define SPEED_3Q_Y SPEED_SCALE_H(-4)
372 #define SPEED_4Q_X SPEED_SCALE_W( 2)
373 #define SPEED_4Q_Y SPEED_SCALE_H(-4)
375 /* This is used to determine the speed of the paddle */
376 #define SPEED_PAD SPEED_SCALE_W( 8)
378 /* This defines the speed that the powerups drop */
379 #define SPEED_POWER SPEED_SCALE_H( 2)
381 /* This defines the speed that the shot moves */
382 #define SPEED_FIRE SPEED_SCALE_H( 4)
383 #define FIRE_LENGTH SPEED_SCALE_H( 7)
392 /* The time ms for one iteration through the game loop - decrease this to speed
393 * up the game - note that current_tick is (currently) only accurate to 10ms.
395 #define CYCLETIME 30 /* ms */
397 #define FLIP_SIDES_DELAY 10 /* seconds */
406 #define SCORE_BALL_HIT_BRICK 2
407 #define SCORE_BALL_DEMOLISHED_BRICK 8
408 #define SCORE_FIRE_HIT_BRICK 13
409 #define SCORE_LEVEL_COMPLETED 100
410 #define SCORE_POWER_LIFE_GAIN 50
411 #define SCORE_POWER_PADDLE_STICKY 34
412 #define SCORE_POWER_PADDLE_SHOOTER 47
413 #define SCORE_POWER_PADDLE_NORMAL 23
414 #define SCORE_POWER_FLIP 23
415 #define SCORE_POWER_EXTRA_BALL 23
416 #define SCORE_POWER_LONG_PADDLE 23
427 #define MAX_POWERS 10
436 #define CONFIG_FILE_NAME "brickmania.cfg"
437 #define SAVE_FILE PLUGIN_GAMES_DIR "/brickmania.save"
438 #define SCORE_FILE PLUGIN_GAMES_DIR "/brickmania.score"
448 /* change to however many levels there are, i.e. how many arrays there are total */
449 #define NUM_LEVELS 40
451 /* change the first number in [ ] to however many levels there are */
452 static unsigned char levels
[NUM_LEVELS
][NUM_BRICKS_ROWS
][NUM_BRICKS_COLS
] =
453 /* You can set up new levels with the level editor
454 ( http://plugbox.rockbox-lounge.com/brickmania.htm ).
455 With 0x1, it refers to the first brick in the bitmap, 0x2 would refer to the
456 second, ect., 0x0 leaves a empty space. If you add a 2 before the 2nd number,
457 it will take two hits to break, and 3 hits if you add a 3. That is 0x24, will
458 result with the fourth brick being displayed and having take 2 hits to break.
459 You could do the same with the 3, just replace the 2 with a 3 for it to take
460 three hits to break it apart. */
463 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
464 {0x2,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x2},
465 {0x0,0x2,0x1,0x0,0x0,0x0,0x0,0x1,0x2,0x0},
466 {0x0,0x0,0x2,0x1,0x0,0x0,0x1,0x2,0x0,0x0},
467 {0x0,0x0,0x0,0x2,0x1,0x1,0x2,0x0,0x0,0x0},
468 {0x7,0x0,0x0,0x7,0x2,0x2,0x7,0x0,0x0,0x7},
469 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
470 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
473 {0x0,0x0,0x7,0x7,0x1,0x1,0x7,0x7,0x0,0x0},
474 {0x0,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x0},
475 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
476 {0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1},
477 {0x1,0x1,0x2,0x1,0x0,0x0,0x1,0x2,0x1,0x1},
478 {0x1,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x2,0x1},
479 {0x0,0x1,0x2,0x0,0x0,0x0,0x0,0x2,0x1,0x0},
480 {0x0,0x0,0x1,0x2,0x2,0x2,0x2,0x1,0x0,0x0}
483 {0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
484 {0x3,0x23,0x23,0x3,0x0,0x0,0x2,0x22,0x22,0x2},
485 {0x3,0x3,0x3,0x3,0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x0,0x2},
629 {0x2,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x2},
630 {0x2,0x2,0x1,0x0,0x1,0x1,0x0,0x1,0x2,0x2}
632 {/* level 18 (Tetris) by ts-x */
633 {0x0,0x2,0x0,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
634 {0x0,0x2,0x7,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
635 {0x2,0x2,0x7,0x0,0x3,0x4,0x0,0x6,0x2,0x2},
636 {0x2,0x2,0x7,0x7,0x3,0x4,0x0,0x6,0x2,0x2},
637 {0x2,0x1,0x7,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
638 {0x2,0x1,0x0,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
639 {0x1,0x1,0x1,0x7,0x3,0x0,0x6,0x6,0x5,0x5},
640 {0x1,0x1,0x1,0x0,0x3,0x0,0x6,0x6,0x5,0x5}
642 { /* level 19 (Stalactites) by ts-x */
643 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
644 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
645 {0x5,0x0,0x6,0x3,0x4,0x7,0x5,0x0,0x1,0x2},
646 {0x5,0x2,0x6,0x3,0x4,0x0,0x5,0x3,0x1,0x2},
647 {0x5,0x0,0x6,0x0,0x4,0x7,0x5,0x0,0x1,0x0},
648 {0x5,0x0,0x0,0x3,0x4,0x0,0x0,0x0,0x1,0x2},
649 {0x0,0x0,0x6,0x0,0x0,0x0,0x5,0x0,0x0,0x0},
650 {0x5,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x1,0x0}
652 { /* level 20 (Maze) by ts-x */
653 {0x1,0x1,0x21,0x1,0x1,0x1,0x1,0x1,0x1,0x21},
654 {0x1,0x0,0x0,0x3,0x0,0x0,0x3,0x1,0x31,0x1},
655 {0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x0,0x1},
656 {0x21,0x0,0x21,0x3,0x0,0x3,0x0,0x3,0x0,0x2},
657 {0x1,0x0,0x1,0x21,0x0,0x12,0x0,0x0,0x0,0x0},
658 {0x31,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x3,0x0},
659 {0x1,0x0,0x1,0x0,0x1,0x1,0x31,0x1,0x1,0x2},
660 {0x22,0x0,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x21}
662 { /* level 21 (Dentist) by ts-x */
663 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
664 {0x2,0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x2,0x2},
665 {0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x2},
666 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x2},
667 {0x2,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x0,0x2},
668 {0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x2},
669 {0x2,0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x2,0x2},
670 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0}
672 { /* level 22 (Spider) by ts-x */
673 {0x31,0x3,0x1,0x1,0x0,0x0,0x1,0x1,0x3,0x31},
674 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
675 {0x33,0x1,0x1,0x36,0x1,0x1,0x36,0x1,0x1,0x33},
676 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
677 {0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x0,0x0},
678 {0x21,0x3,0x1,0x21,0x2,0x2,0x21,0x1,0x3,0x21},
679 {0x0,0x0,0x0,0x1,0x21,0x1,0x1,0x0,0x0,0x0},
680 {0x3,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x3}
682 { /* level 23 (Pool) by ts-x */
683 {0x0,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x7,0x0},
684 {0x0,0x0,0x5,0x0,0x2,0x0,0x0,0x0,0x2,0x0},
685 {0x7,0x3,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x7},
686 {0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x5,0x0,0x7},
687 {0x7,0x0,0x4,0x0,0x0,0x3,0x0,0x0,0x0,0x7},
688 {0x7,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x4,0x7},
689 {0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
690 {0x0,0x7,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x0}
692 { /* level 24 (Vorbis Fish) by ts-x */
693 {0x0,0x0,0x4,0x4,0x5,0x5,0x5,0x0,0x0,0x5},
694 {0x0,0x4,0x6,0x4,0x4,0x5,0x5,0x5,0x0,0x5},
695 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x5,0x5,0x5},
696 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x4,0x5,0x5},
697 {0x0,0x5,0x6,0x4,0x4,0x5,0x5,0x4,0x5,0x0},
698 {0x5,0x5,0x4,0x4,0x5,0x5,0x5,0x4,0x5,0x5},
699 {0x5,0x4,0x4,0x4,0x5,0x5,0x4,0x4,0x5,0x5},
700 {0x0,0x0,0x4,0x4,0x4,0x4,0x4,0x5,0x0,0x5}
702 {/* level 25 (Rainbow) by ts-x */
703 {0x0,0x4,0x1,0x0,0x0,0x0,0x0,0x1,0x4,0x0},
704 {0x24,0x1,0x3,0x1,0x0,0x0,0x21,0x3,0x1,0x24},
705 {0x1,0x23,0x5,0x3,0x1,0x21,0x3,0x5,0x3,0x21},
706 {0x3,0x5,0x6,0x5,0x3,0x3,0x5,0x6,0x5,0x3},
707 {0x5,0x6,0x7,0x6,0x5,0x5,0x6,0x7,0x6,0x5},
708 {0x6,0x7,0x2,0x27,0x6,0x6,0x27,0x2,0x7,0x6},
709 {0x7,0x2,0x0,0x2,0x27,0x27,0x2,0x0,0x2,0x7},
710 {0x32,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x32}
712 { /* level 26 (Bowtie) by ts-x */
713 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5},
714 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
715 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
716 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
717 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
718 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
719 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
720 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5}
722 { /* level 27 (Frog) by ts-x */
723 {0x0,0x5,0x25,0x0,0x0,0x0,0x0,0x25,0x5,0x0},
724 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
725 {0x25,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x25},
726 {0x5,0x0,0x3,0x0,0x6,0x6,0x0,0x3,0x0,0x5},
727 {0x5,0x0,0x31,0x0,0x6,0x6,0x0,0x31,0x0,0x5},
728 {0x5,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x5},
729 {0x5,0x5,0x5,0x35,0x0,0x0,0x35,0x5,0x5,0x5},
730 {0x0,0x25,0x5,0x0,0x4,0x4,0x0,0x5,0x25,0x0}
732 { /* level 28 (DigDug) by ts-x */
733 {0x35,0x5,0x5,0x25,0x0,0x25,0x25,0x5,0x5,0x35},
734 {0x6,0x0,0x0,0x6,0x0,0x6,0x6,0x0,0x0,0x6},
735 {0x7,0x0,0x37,0x37,0x0,0x37,0x37,0x7,0x0,0x7},
736 {0x7,0x0,0x7,0x0,0x0,0x0,0x7,0x7,0x7,0x7},
737 {0x4,0x4,0x4,0x24,0x0,0x24,0x4,0x0,0x0,0x4},
738 {0x4,0x4,0x0,0x0,0x0,0x4,0x4,0x0,0x4,0x4},
739 {0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4},
740 {0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1}
742 { /* level 29 UK Flag by Seth Opgenorth */
743 {0x32,0x0,0x3,0x3,0x2,0x2,0x3,0x3,0x0,0x32},
744 {0x0,0x2,0x0,0x3,0x32,0x22,0x33,0x0,0x32,0x0},
745 {0x33,0x0,0x22,0x0,0x2,0x2,0x0,0x2,0x0,0x33},
746 {0x22,0x32,0x2,0x2,0x2,0x2,0x2,0x2,0x22,0x2},
747 {0x3,0x0,0x0,0x32,0x22,0x2,0x2,0x0,0x0,0x3},
748 {0x23,0x0,0x32,0x0,0x32,0x2,0x0,0x2,0x0,0x3},
749 {0x0,0x2,0x0,0x3,0x2,0x2,0x3,0x0,0x22,0x0},
750 {0x32,0x0,0x3,0x23,0x2,0x2,0x23,0x33,0x0,0x32}
752 { /* level 30 Win-Logo by Seth Opgenorth */
753 {0x0,0x0,0x0,0x22,0x0,0x0,0x0,0x0,0x0,0x0},
754 {0x0,0x0,0x32,0x2,0x2,0x25,0x0,0x5,0x0,0x0},
755 {0x0,0x0,0x2,0x22,0x2,0x5,0x5,0x35,0x0,0x0},
756 {0x0,0x0,0x2,0x1,0x2,0x5,0x5,0x25,0x0,0x0},
757 {0x0,0x0,0x21,0x1,0x1,0x36,0x7,0x26,0x0,0x0},
758 {0x0,0x0,0x1,0x1,0x1,0x6,0x6,0x6,0x0,0x0},
759 {0x0,0x0,0x21,0x0,0x21,0x6,0x6,0x26,0x0,0x0},
760 {0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x0,0x0}
762 { /* level 31 Color wave/V by Seth Opgenorth */
763 {0x25,0x34,0x2,0x31,0x33,0x23,0x1,0x2,0x34,0x5},
764 {0x3,0x5,0x24,0x2,0x1,0x1,0x2,0x4,0x5,0x3},
765 {0x1,0x3,0x5,0x4,0x2,0x2,0x4,0x5,0x3,0x1},
766 {0x2,0x1,0x33,0x35,0x4,0x4,0x5,0x33,0x1,0x22},
767 {0x31,0x22,0x1,0x3,0x5,0x25,0x3,0x1,0x2,0x31},
768 {0x3,0x1,0x2,0x1,0x3,0x3,0x1,0x2,0x21,0x3},
769 {0x5,0x23,0x1,0x32,0x1,0x1,0x2,0x1,0x3,0x5},
770 {0x4,0x35,0x3,0x1,0x2,0x22,0x31,0x3,0x5,0x4}
772 { /* level 32 Sweedish Flag by Seth Opgenorth */
773 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
774 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
775 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
776 {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36},
777 {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36},
778 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
779 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
780 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3}
782 { /* level 33 Color Pyramid by Seth Opgenorth */
783 {0x0,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x0},
784 {0x0,0x0,0x0,0x4,0x24,0x4,0x24,0x0,0x0,0x0},
785 {0x0,0x0,0x23,0x3,0x3,0x3,0x23,0x3,0x0,0x0},
786 {0x0,0x0,0x25,0x5,0x25,0x35,0x5,0x35,0x0,0x0},
787 {0x0,0x36,0x6,0x6,0x6,0x6,0x26,0x6,0x6,0x0},
788 {0x0,0x7,0x7,0x7,0x7,0x25,0x27,0x7,0x27,0x0},
789 {0x2,0x2,0x22,0x2,0x2,0x2,0x22,0x2,0x2,0x2},
790 {0x21,0x1,0x1,0x31,0x1,0x21,0x1,0x1,0x31,0x1}
792 { /* level 34 Rhombus by Seth Opgenorth */
793 {0x0,0x0,0x0,0x0,0x3,0x33,0x0,0x0,0x0,0x0},
794 {0x0,0x0,0x0,0x3,0x32,0x22,0x23,0x0,0x0,0x0},
795 {0x0,0x0,0x3,0x2,0x24,0x4,0x2,0x23,0x0,0x0},
796 {0x26,0x3,0x2,0x4,0x5,0x5,0x4,0x22,0x3,0x6},
797 {0x36,0x3,0x2,0x34,0x5,0x5,0x4,0x2,0x3,0x36},
798 {0x0,0x0,0x3,0x2,0x4,0x34,0x2,0x23,0x0,0x0},
799 {0x0,0x0,0x0,0x23,0x2,0x2,0x3,0x0,0x0,0x0},
800 {0x0,0x0,0x0,0x0,0x3,0x33,0x0,0x0,0x0,0x0}
802 { /* level 35 PacMan Ghost by Seth Opgenorth */
803 {0x0,0x0,0x0,0x0,0x2,0x32,0x2,0x0,0x0,0x0},
804 {0x0,0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x0,0x0},
805 {0x0,0x0,0x2,0x24,0x4,0x2,0x4,0x4,0x32,0x0},
806 {0x0,0x0,0x2,0x24,0x0,0x22,0x24,0x0,0x22,0x0},
807 {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
808 {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
809 {0x0,0x0,0x2,0x32,0x2,0x2,0x22,0x2,0x32,0x0},
810 {0x0,0x0,0x0,0x22,0x0,0x32,0x0,0x22,0x0,0x0}
812 { /* level 36 Star by Seth Opgenorth */
813 {0x3,0x4,0x3,0x4,0x6,0x24,0x3,0x24,0x3,0x0},
814 {0x24,0x0,0x0,0x6,0x6,0x6,0x0,0x0,0x4,0x0},
815 {0x3,0x26,0x6,0x2,0x6,0x2,0x6,0x26,0x23,0x0},
816 {0x4,0x0,0x6,0x6,0x36,0x6,0x6,0x0,0x4,0x0},
817 {0x3,0x0,0x0,0x26,0x6,0x26,0x0,0x0,0x33,0x0},
818 {0x34,0x0,0x6,0x6,0x0,0x6,0x6,0x0,0x4,0x0},
819 {0x3,0x26,0x6,0x0,0x0,0x0,0x6,0x6,0x3,0x0},
820 {0x4,0x3,0x4,0x23,0x24,0x3,0x4,0x33,0x4,0x0}
822 { /* level 37 It's 8-Bit by Seth Opgenorth */
823 {0x26,0x26,0x6,0x6,0x5,0x6,0x26,0x6,0x26,0x6},
824 {0x2,0x2,0x22,0x3,0x3,0x0,0x0,0x0,0x4,0x0},
825 {0x2,0x0,0x2,0x33,0x3,0x3,0x5,0x0,0x24,0x0},
826 {0x32,0x2,0x2,0x33,0x0,0x23,0x0,0x4,0x4,0x4},
827 {0x2,0x22,0x2,0x3,0x3,0x0,0x5,0x4,0x4,0x24},
828 {0x2,0x0,0x2,0x23,0x0,0x3,0x25,0x0,0x4,0x0},
829 {0x22,0x2,0x2,0x3,0x23,0x0,0x5,0x0,0x4,0x0},
830 {0x6,0x26,0x6,0x36,0x6,0x36,0x6,0x6,0x6,0x6}
832 { /* level 38 Linux by Seth Opgenorth */
833 {0x27,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
834 {0x7,0x0,0x0,0x0,0x33,0x0,0x23,0x0,0x0,0x0},
835 {0x7,0x32,0x0,0x0,0x3,0x0,0x23,0x6,0x0,0x6},
836 {0x37,0x0,0x0,0x0,0x23,0x0,0x3,0x6,0x0,0x26},
837 {0x7,0x22,0x24,0x0,0x3,0x33,0x3,0x0,0x26,0x0},
838 {0x37,0x22,0x24,0x24,0x4,0x0,0x0,0x0,0x26,0x0},
839 {0x7,0x2,0x4,0x0,0x4,0x0,0x0,0x6,0x0,0x26},
840 {0x7,0x27,0x4,0x0,0x34,0x0,0x0,0x6,0x0,0x26}
842 { /* level 39 Colorful Squares by Seth Opgenorth*/
843 {0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0},
844 {0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0},
845 {0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0},
846 {0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0},
847 {0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0},
848 {0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0},
849 {0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0},
850 {0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0}
853 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
854 {0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0},
855 {0x32,0x0,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0},
856 {0x32,0x32,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0},
857 {0x32,0x32,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0},
858 {0x32,0x0,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0},
859 {0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0},
860 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
873 POWER_TYPE_LIFE_GAIN
= 0,
874 POWER_TYPE_LIFE_LOSS
,
875 POWER_TYPE_PADDLE_STICKY
,
876 POWER_TYPE_PADDLE_SHOOTER
,
877 POWER_TYPE_PADDLE_NORMAL
,
878 POWER_TYPE_PADDLE_FLIP
,
879 POWER_TYPE_EXTRA_BALL
,
880 POWER_TYPE_PADDLE_LONG
,
881 POWER_TYPE_PADDLE_SHORT
,
885 #define POWERUP_HEIGHT FIXED3(BMPHEIGHT_brickmania_powerups/NUMBER_OF_POWERUPS)
886 /* Increasing this value makes the game with less powerups */
887 #define POWER_RAND (NUMBER_OF_POWERUPS + 15)
889 enum difficulty_options
904 PADDLE_TYPE_NORMAL
= 0,
920 bool used
; /* Is the brick still in play? */
922 int hits
; /* How many hits can this brick take? */
928 /* pos_x and y store the current center position of the ball */
931 /* tempx and tempy store an absolute position the ball should be in. If
932 * they are equal to 0, they are not used when positioning the ball.
936 /* speedx and speedy store the current speed of the ball */
939 bool glue
; /* Is the ball stuck to the paddle? */
944 int top
; /* This stores the fire y position, it is a fixed point num */
945 int x_pos
; /* This stores the fire x position, it is a whole number */
950 int top
; /* This stores the powerup y position, it is a fixed point num */
951 int x_pos
; /* This stores the (middle of) powerup x position, it is a whole number */
952 enum power_types type
; /* This stores the powerup type */
969 struct point top_left
;
970 struct point bottom_right
;
979 static enum game_state game_state
;
980 static int pad_pos_x
;
982 static int score
,vscore
;
983 static bool flip_sides
;
985 static int brick_on_board
;
986 static int used_balls
;
987 static int used_fires
;
988 static int used_powers
;
989 static int difficulty
= NORMAL
;
990 static int pad_width
;
991 static int flip_sides_delay
;
992 static bool resume
= false;
993 static bool resume_file
= false;
994 static struct brick brick
[NUM_BRICKS_ROWS
][NUM_BRICKS_COLS
];
995 static struct ball ball
[MAX_BALLS
];
996 static struct fire fire
[MAX_FIRES
];
997 static struct power power
[MAX_POWERS
];
998 static enum paddle_type paddle_type
;
1000 static struct configdata config
[] =
1002 {TYPE_INT
, 0, 1, { .int_p
= &difficulty
}, "difficulty", NULL
},
1005 static struct highscore highscores
[NUM_SCORES
];
1016 * This is based off an explanation and expanded math presented by Paul Bourke:
1017 * http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
1019 * It takes two lines as inputs and returns 1 if they intersect, 0 if they do
1020 * not. hitp returns the point where the two lines intersected.
1022 * This function expects fixed point inputs with a precision of 3. When a
1023 * collision occurs hitp is updated with a fixed point location (precision 3)
1024 * where the collision happened. The internal calculations are fixed
1025 * point with a 7 bit fractional precision.
1027 * If you choose 10 bits of precision a screen size of about 640x480 is the
1028 * largest this can go. 7 bits allows for an accurate intersection calculation
1029 * with a line length of about 64 and a rougher line lenght of 128 which is
1030 * larger than any target currently needs (the pad is the longest line and it
1031 * only needs an accuracy of 2^4 at most to figure out which section of the pad
1032 * the ball hit). A precision of 7 gives breathing room for larger screens.
1033 * Longer line sizes that need accurate intersection points will need more
1034 * precision, but will decrease the maximum screen resolution.
1038 static int check_lines(struct line
*line1
, struct line
*line2
,
1042 * This code is based on the solution of these two input equations:
1043 * Pa = P1 + ua (P2-P1)
1044 * Pb = P3 + ub (P4-P3)
1046 * Where line one is composed of points P1 and P2 and line two is composed
1047 * of points P3 and P4.
1049 * ua/b is the fractional value you can multiply the x and y legs of the
1050 * triangle formed by each line to find a point on the line.
1052 * The two equations can be expanded to their x/y components:
1053 * Pa.x = p1.x + ua(p2.x - p1.x)
1054 * Pa.y = p1.y + ua(p2.y - p1.y)
1056 * Pb.x = p3.x + ub(p4.x - p3.x)
1057 * Pb.y = p3.y + ub(p4.y - p3.y)
1059 * When Pa.x == Pb.x and Pa.y == Pb.y the lines intersect so you can come
1060 * up with two equations (one for x and one for y):
1062 * p1.x + ua(p2.x - p1.x) = p3.x + ub(p4.x - p3.x)
1063 * p1.y + ua(p2.y - p1.y) = p3.y + ub(p4.y - p3.y)
1065 * ua and ub can then be individually solved for. This results in the
1066 * equations used in the following code.
1069 /* Denominator for ua and ub are the same so store this calculation */
1070 int d
= FIXED3_MUL((line2
->p2
.y
- line2
->p1
.y
),(line1
->p2
.x
-line1
->p1
.x
))
1071 -FIXED3_MUL((line2
->p2
.x
- line2
->p1
.x
),(line1
->p2
.y
-line1
->p1
.y
));
1073 /* n_a and n_b are calculated as seperate values for readability */
1074 int n_a
= FIXED3_MUL((line2
->p2
.x
- line2
->p1
.x
),(line1
->p1
.y
-line2
->p1
.y
))
1075 -FIXED3_MUL((line2
->p2
.y
- line2
->p1
.y
),(line1
->p1
.x
-line2
->p1
.x
));
1077 int n_b
= FIXED3_MUL((line1
->p2
.x
- line1
->p1
.x
),(line1
->p1
.y
-line2
->p1
.y
))
1078 -FIXED3_MUL((line1
->p2
.y
- line1
->p1
.y
),(line1
->p1
.x
-line2
->p1
.x
));
1080 /* Make sure there is not a division by zero - this also indicates that
1081 * the lines are parallel.
1083 * If n_a and n_b were both equal to zero the lines would be on top of each
1084 * other (coincidental). This check is not done because it is not
1085 * necessary for this implementation (the parallel check accounts for this).
1090 /* Calculate the intermediate fractional point that the lines potentially
1093 int ua
= (n_a
<< LINE_PREC
)/d
;
1094 int ub
= (n_b
<< LINE_PREC
)/d
;
1096 /* The fractional point will be between 0 and 1 inclusive if the lines
1097 * intersect. If the fractional calculation is larger than 1 or smaller
1098 * than 0 the lines would need to be longer to intersect.
1100 if(ua
>=0 && ua
<= (1<<LINE_PREC
) && ub
>= 0 && ub
<= (1<<LINE_PREC
))
1102 hitp
->x
= line1
->p1
.x
+ ((ua
* (line1
->p2
.x
- line1
->p1
.x
))>>LINE_PREC
);
1103 hitp
->y
= line1
->p1
.y
+ ((ua
* (line1
->p2
.y
- line1
->p1
.y
))>>LINE_PREC
);
1110 static int check_rect(struct line
*line
, struct rect
*rect
,
1111 enum intersection intersection
, struct point
*hitp
)
1115 switch (intersection
)
1117 case INTERSECTION_TOP
:
1119 edge
.p1
.x
= rect
->top_left
.x
;
1120 edge
.p1
.y
= rect
->top_left
.y
;
1122 edge
.p2
.x
= rect
->bottom_right
.x
;
1123 edge
.p2
.y
= rect
->top_left
.y
;
1127 case INTERSECTION_BOTTOM
:
1129 edge
.p1
.x
= rect
->top_left
.x
;
1130 edge
.p1
.y
= rect
->bottom_right
.y
;
1132 edge
.p2
.x
= rect
->bottom_right
.x
;
1133 edge
.p2
.y
= rect
->bottom_right
.y
;
1137 case INTERSECTION_LEFT
:
1139 edge
.p1
.x
= rect
->top_left
.x
;
1140 edge
.p1
.y
= rect
->top_left
.y
;
1142 edge
.p2
.x
= rect
->top_left
.x
;
1143 edge
.p2
.y
= rect
->bottom_right
.y
;
1147 case INTERSECTION_RIGHT
:
1149 edge
.p1
.x
= rect
->bottom_right
.x
;
1150 edge
.p1
.y
= rect
->top_left
.y
;
1152 edge
.p2
.x
= rect
->bottom_right
.x
;
1153 edge
.p2
.y
= rect
->bottom_right
.y
;
1157 case INTERSECTION_ALL
: /* Test hit on all edges */
1159 return (check_rect(line
, rect
, INTERSECTION_TOP
, hitp
) ||
1160 check_rect(line
, rect
, INTERSECTION_BOTTOM
, hitp
) ||
1161 check_rect(line
, rect
, INTERSECTION_LEFT
, hitp
) ||
1162 check_rect(line
, rect
, INTERSECTION_RIGHT
, hitp
));
1166 return check_lines(line
, &edge
, hitp
);
1169 static void brickmania_init_game(bool new_game
)
1173 pad_pos_x
= GAMESCREEN_WIDTH
/2 - PAD_WIDTH
/2;
1175 for(i
=0;i
<MAX_BALLS
;i
++)
1181 ball
[i
].pos_y
= ON_PAD_POS_Y
;
1182 ball
[i
].pos_x
= GAMESCREEN_WIDTH
/2;
1183 ball
[i
].glue
= false;
1189 game_state
= ST_READY
;
1190 paddle_type
= PADDLE_TYPE_NORMAL
;
1191 pad_width
= PAD_WIDTH
;
1193 flip_sides_delay
= FLIP_SIDES_DELAY
;
1197 /* add one life per achieved level */
1198 if (difficulty
==EASY
&& life
<2) {
1199 score
+=SCORE_LEVEL_COMPLETED
;
1204 for(i
=0;i
<NUM_BRICKS_ROWS
;i
++) {
1205 for(j
=0;j
<NUM_BRICKS_COLS
;j
++) {
1207 brick
[i
][j
].hits
=levels
[level
][i
][j
]>=10?
1208 levels
[level
][i
][j
]/16-1:0;
1209 brick
[i
][j
].hiteffect
=0;
1210 brick
[i
][j
].used
=!(levels
[level
][i
][j
]==0);
1211 brick
[i
][j
].color
=(levels
[level
][i
][j
]>=10?
1212 levels
[level
][i
][j
]%16:
1213 levels
[level
][i
][j
])-1;
1214 if (levels
[level
][i
][j
]!=0)
1221 static void brickmania_loadgame(void)
1227 /* open game file */
1228 fd
= rb
->open(SAVE_FILE
, O_RDONLY
);
1231 /* read in saved game */
1232 if((rb
->read(fd
, &pad_pos_x
, sizeof(pad_pos_x
)) <= 0) ||
1233 (rb
->read(fd
, &life
, sizeof(life
)) <= 0) ||
1234 (rb
->read(fd
, &game_state
, sizeof(game_state
)) <= 0) ||
1235 (rb
->read(fd
, &paddle_type
, sizeof(paddle_type
)) <= 0) ||
1236 (rb
->read(fd
, &score
, sizeof(score
)) <= 0) ||
1237 (rb
->read(fd
, &flip_sides
, sizeof(flip_sides
)) <= 0) ||
1238 (rb
->read(fd
, &level
, sizeof(level
)) <= 0) ||
1239 (rb
->read(fd
, &brick_on_board
, sizeof(brick_on_board
)) <= 0) ||
1240 (rb
->read(fd
, &used_balls
, sizeof(used_balls
)) <= 0) ||
1241 (rb
->read(fd
, &used_fires
, sizeof(used_fires
)) <= 0) ||
1242 (rb
->read(fd
, &used_powers
, sizeof(used_powers
)) <= 0) ||
1243 (rb
->read(fd
, &pad_width
, sizeof(pad_width
)) <= 0) ||
1244 (rb
->read(fd
, &flip_sides_delay
, sizeof(flip_sides_delay
)) <= 0) ||
1245 (rb
->read(fd
, &brick
, sizeof(brick
)) <= 0) ||
1246 (rb
->read(fd
, &ball
, sizeof(ball
)) <= 0) ||
1247 (rb
->read(fd
, &fire
, sizeof(fire
)) <= 0) ||
1248 (rb
->read(fd
, &power
, sizeof(power
)) <= 0))
1250 rb
->splash(HZ
/2, "Failed to load game");
1263 static void brickmania_savegame(void)
1267 /* write out the game state to the save file */
1268 fd
= rb
->open(SAVE_FILE
, O_WRONLY
|O_CREAT
, 0666);
1271 if ((rb
->write(fd
, &pad_pos_x
, sizeof(pad_pos_x
)) <= 0) ||
1272 (rb
->write(fd
, &life
, sizeof(life
)) <= 0) ||
1273 (rb
->write(fd
, &game_state
, sizeof(game_state
)) <= 0) ||
1274 (rb
->write(fd
, &paddle_type
, sizeof(paddle_type
)) <= 0) ||
1275 (rb
->write(fd
, &score
, sizeof(score
)) <= 0) ||
1276 (rb
->write(fd
, &flip_sides
, sizeof(flip_sides
)) <= 0) ||
1277 (rb
->write(fd
, &level
, sizeof(level
)) <= 0) ||
1278 (rb
->write(fd
, &brick_on_board
, sizeof(brick_on_board
)) <= 0) ||
1279 (rb
->write(fd
, &used_balls
, sizeof(used_balls
)) <= 0) ||
1280 (rb
->write(fd
, &used_fires
, sizeof(used_fires
)) <= 0) ||
1281 (rb
->write(fd
, &used_powers
, sizeof(used_powers
)) <= 0) ||
1282 (rb
->write(fd
, &pad_width
, sizeof(pad_width
)) <= 0) ||
1283 (rb
->write(fd
, &flip_sides_delay
, sizeof(flip_sides_delay
)) <= 0) ||
1284 (rb
->write(fd
, &brick
, sizeof(brick
)) <= 0) ||
1285 (rb
->write(fd
, &ball
, sizeof(ball
)) <= 0) ||
1286 (rb
->write(fd
, &fire
, sizeof(fire
)) <= 0) ||
1287 (rb
->write(fd
, &power
, sizeof(power
)) <= 0))
1290 rb
->remove(SAVE_FILE
);
1291 rb
->splash(HZ
/2, "Failed to save game");
1298 /* brickmania_sleep timer counting the score */
1299 static void brickmania_sleep(int secs
)
1309 count
= *rb
->current_tick
+ HZ
*secs
;
1310 if ( (TIME_AFTER(*rb
->current_tick
, count
)) && (vscore
== score
) )
1319 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
1320 rb
->lcd_getstringsize(s
, &sw
, &w
);
1321 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
1322 rb
->lcd_update_rect(0,0,LCD_WIDTH
,w
+2);
1328 static int brickmania_help(void)
1330 static char *help_text
[] = {
1331 "Brickmania", "", "Aim", "",
1332 "Destroy", "all", "the", "bricks", "by", "bouncing",
1333 "the", "ball", "of", "them", "using", "the", "paddle.", "", "",
1335 #if CONFIG_KEYPAD == COWON_D2_PAD
1340 "Moves", "the", "paddle", "",
1341 #if CONFIG_KEYPAD == ONDIO_PAD
1343 #elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1345 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
1347 #elif CONFIG_KEYPAD == COWON_D2_PAD
1352 "Releases", "the", "ball/Fire!", "",
1353 #if CONFIG_KEYPAD == IAUDIO_M3_PAD
1355 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
1356 (CONFIG_KEYPAD == CREATIVEZVM_PAD)
1358 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
1359 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
1360 (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
1361 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
1363 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
1364 (CONFIG_KEYPAD == IRIVER_H300_PAD) || \
1365 (CONFIG_KEYPAD == ONDIO_PAD) || \
1366 (CONFIG_KEYPAD == RECORDER_PAD) || \
1367 (CONFIG_KEYPAD == ARCHOS_AV300_PAD)
1372 "Returns", "to", "menu", "", "",
1374 "N", "Normal:", "returns", "paddle", "to", "normal", "",
1375 "D", "DIE!:", "loses", "a", "life", "",
1376 "L", "Life:", "gains", "a", "life/power", "up", "",
1377 "F", "Fire:", "allows", "you", "to", "shoot", "bricks", "",
1378 "G", "Glue:", "ball", "sticks", "to", "paddle", "",
1379 "B", "Ball:", "generates", "another", "ball", "",
1380 "FL", "Flip:", "flips", "left / right", "movement", "",
1381 "<->", "or", "<E>:", "enlarges", "the", "paddle", "",
1382 ">-<", "or", ">S<:", "shrinks", "the", "paddle", "",
1384 static struct style_text formation
[]={
1385 { 0, TEXT_CENTER
|TEXT_UNDERLINE
},
1399 rb
->lcd_setfont(FONT_UI
);
1400 #ifdef HAVE_LCD_COLOR
1401 rb
->lcd_set_background(LCD_BLACK
);
1402 rb
->lcd_set_foreground(LCD_WHITE
);
1404 if (display_text(ARRAYLEN(help_text
), help_text
, formation
, NULL
, true))
1406 rb
->lcd_setfont(FONT_SYSFIXED
);
1411 static int brickmania_menu_cb(int action
, const struct menu_item_ex
*this_item
)
1413 int i
= ((intptr_t)this_item
);
1414 if(action
== ACTION_REQUEST_MENUITEM
1415 && !resume
&& (i
==0 || i
==6))
1416 return ACTION_EXIT_MENUITEM
;
1420 static int brickmania_menu(void)
1424 static struct opt_items options
[] = {
1429 #ifdef HAVE_TOUCHSCREEN
1430 /* Entering Menu, set the touchscreen to the global setting */
1431 rb
->touchscreen_set_mode(rb
->global_settings
->touch_mode
);
1434 MENUITEM_STRINGLIST(main_menu
, "Brickmania Menu", brickmania_menu_cb
,
1435 "Resume Game", "Start New Game",
1436 "Difficulty", "Help", "High Scores",
1438 "Quit without Saving", "Quit");
1440 rb
->button_clear_queue();
1442 switch (rb
->do_menu(&main_menu
, &selected
, NULL
, false)) {
1444 if(game_state
!=ST_READY
)
1445 game_state
= ST_PAUSE
;
1447 rb
->remove(SAVE_FILE
);
1454 brickmania_init_game(true);
1457 rb
->set_option("Difficulty", &difficulty
, INT
,
1461 if (brickmania_help())
1465 highscore_show(-1, highscores
, NUM_SCORES
, true);
1468 if (playback_control(NULL
))
1475 rb
->splash(HZ
*1, "Saving game ...");
1476 brickmania_savegame();
1479 case MENU_ATTACHED_USB
:
1485 #ifdef HAVE_TOUCHSCREEN
1486 rb
->touchscreen_set_mode(TOUCHSCREEN_POINT
);
1490 static void brick_hit(int i
, int j
)
1492 if(!brick
[i
][j
].used
)
1495 /* if this is a crackable brick hits starts as
1498 if (brick
[i
][j
].hits
> 0) {
1500 brick
[i
][j
].hiteffect
++;
1501 score
+=SCORE_BALL_HIT_BRICK
;
1504 brick
[i
][j
].used
=false;
1505 if (used_powers
<MAX_POWERS
)
1507 int ran
= rb
->rand()%POWER_RAND
;
1509 if (ran
<NUMBER_OF_POWERUPS
)
1511 power
[used_powers
].top
= TOPMARGIN
+ i
*BRICK_HEIGHT
;
1512 power
[used_powers
].x_pos
= LEFTMARGIN
+ j
*BRICK_WIDTH
+
1514 power
[used_powers
].type
= ran
;
1519 score
+=SCORE_BALL_DEMOLISHED_BRICK
;
1523 static int brickmania_game_loop(void)
1531 /* pad_rect used for powerup/ball checks */
1532 struct rect pad_rect
;
1533 /* This is used for various lines that are checked (ball and powerup) */
1534 struct line misc_line
;
1536 /* This stores the point that the two lines intersected in a test */
1537 struct point pt_hit
;
1539 if (brickmania_menu()) {
1543 resume_file
= false;
1545 #ifdef HAVE_LCD_COLOR
1546 rb
->lcd_set_background(LCD_BLACK
);
1547 rb
->lcd_set_foreground(LCD_WHITE
);
1548 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1549 rb
->lcd_clear_display();
1553 /* Convert CYCLETIME (in ms) to HZ */
1554 end
= *rb
->current_tick
+ (CYCLETIME
* HZ
) / 1000;
1557 rb
->lcd_clear_display();
1561 if (TIME_AFTER(*rb
->current_tick
, sec_count
))
1563 sec_count
=*rb
->current_tick
+HZ
;
1564 if (flip_sides_delay
> 1)
1569 rb
->snprintf(s
, sizeof(s
), "%d", flip_sides_delay
);
1570 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1571 rb
->lcd_putsxy(LCD_WIDTH
/2-2, INT3(STRINGPOS_FLIP
), s
);
1574 /* write life num */
1575 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1576 rb
->snprintf(s
, sizeof(s
), "L:%d", life
);
1578 rb
->snprintf(s
, sizeof(s
), "Life: %d", life
);
1580 rb
->lcd_putsxy(0, 0, s
);
1582 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1583 rb
->snprintf(s
, sizeof(s
), "L%d", level
+1);
1585 rb
->snprintf(s
, sizeof(s
), "Level %d", level
+1);
1588 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1589 rb
->lcd_putsxy(LCD_WIDTH
-sw
, 0, s
);
1591 if (vscore
<score
) vscore
++;
1592 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
1593 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1594 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
1597 if (game_state
== ST_PAUSE
)
1599 rb
->snprintf(s
, sizeof(s
), CONTINUE_TEXT
);
1600 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1601 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_NAVI
), s
);
1603 sec_count
=*rb
->current_tick
+HZ
;
1607 for(i
=0;i
<used_balls
;i
++)
1608 rb
->lcd_bitmap(brickmania_ball
,
1609 INT3(ball
[i
].pos_x
- HALFBALL
),
1610 INT3(ball
[i
].pos_y
- HALFBALL
),
1611 INT3(BALL
), INT3(BALL
));
1613 if (brick_on_board
==0)
1616 /* Setup the pad line-later used in intersection test */
1617 pad_rect
.top_left
.x
= pad_pos_x
;
1618 pad_rect
.top_left
.y
= PAD_POS_Y
;
1620 pad_rect
.bottom_right
.x
= pad_pos_x
+ pad_width
;
1621 pad_rect
.bottom_right
.y
= PAD_POS_Y
+ PAD_HEIGHT
;
1623 if (game_state
!=ST_PAUSE
)
1625 /* move the fires */
1626 for(k
=0;k
<used_fires
;k
++)
1628 fire
[k
].top
-= SPEED_FIRE
;
1629 if (fire
[k
].top
< 0)
1632 fire
[k
].top
= fire
[used_fires
].top
;
1633 fire
[k
].x_pos
= fire
[used_fires
].x_pos
;
1636 else if (fire
[k
].x_pos
>= LEFTMARGIN
&&
1637 fire
[k
].x_pos
< LEFTMARGIN
+ NUM_BRICKS_COLS
* BRICK_WIDTH
)
1639 j
= (fire
[k
].x_pos
- LEFTMARGIN
) / BRICK_WIDTH
;
1640 for (i
=NUM_BRICKS_ROWS
-1;i
>=0;i
--)
1642 if (TOPMARGIN
+ i
*BRICK_HEIGHT
<=fire
[k
].top
)
1644 if (brick
[i
][j
].used
)
1646 score
+= SCORE_FIRE_HIT_BRICK
;
1649 fire
[k
].top
= fire
[used_fires
].top
;
1650 fire
[k
].x_pos
= fire
[used_fires
].x_pos
;
1658 /* move and handle the powerups */
1659 for (k
=0;k
<used_powers
;k
++)
1661 int remove_power
= 0;
1663 power
[k
].top
+= SPEED_POWER
;
1665 if (power
[k
].top
> PAD_POS_Y
)
1667 /* power hit bottom */
1672 /* Use misc_line to check if the center of the powerup
1675 misc_line
.p1
.x
= power
[k
].x_pos
;
1676 misc_line
.p1
.y
= power
[k
].top
;
1678 misc_line
.p2
= misc_line
.p1
;
1679 misc_line
.p2
.y
+= SPEED_POWER
;
1681 /* Check if the powerup will hit the paddle */
1682 if (check_rect(&misc_line
, &pad_rect
, INTERSECTION_ALL
,
1686 /* power hit paddle */
1688 switch(power
[k
].type
)
1690 case POWER_TYPE_LIFE_GAIN
:
1692 score
+= SCORE_POWER_LIFE_GAIN
;
1694 case POWER_TYPE_LIFE_LOSS
:
1698 brickmania_init_game(false);
1699 brickmania_sleep(2);
1702 case POWER_TYPE_PADDLE_STICKY
:
1703 score
+= SCORE_POWER_PADDLE_STICKY
;
1704 paddle_type
= PADDLE_TYPE_STICKY
;
1706 case POWER_TYPE_PADDLE_SHOOTER
:
1707 score
+= SCORE_POWER_PADDLE_SHOOTER
;
1708 paddle_type
= PADDLE_TYPE_SHOOTER
;
1709 for(i
=0;i
<used_balls
;i
++)
1712 case POWER_TYPE_PADDLE_NORMAL
:
1713 score
+= SCORE_POWER_PADDLE_NORMAL
;
1714 paddle_type
= PADDLE_TYPE_NORMAL
;
1715 for(i
=0;i
<used_balls
;i
++)
1718 pad_pos_x
+= (pad_width
-PAD_WIDTH
)/2;
1719 pad_width
= PAD_WIDTH
;
1721 case POWER_TYPE_PADDLE_FLIP
:
1722 score
+= SCORE_POWER_FLIP
;
1723 sec_count
= *rb
->current_tick
+HZ
;
1724 flip_sides_delay
= FLIP_SIDES_DELAY
;
1727 case POWER_TYPE_EXTRA_BALL
:
1728 score
+= SCORE_POWER_EXTRA_BALL
;
1729 if(used_balls
<MAX_BALLS
)
1732 if(rb
->rand()%2 == 0)
1733 ball
[used_balls
].speedx
=-SPEED_4Q_X
;
1735 ball
[used_balls
].speedx
= SPEED_4Q_X
;
1736 ball
[used_balls
].speedy
= SPEED_4Q_Y
;
1737 /* Ball is not glued */
1738 ball
[used_balls
].glue
= false;
1742 case POWER_TYPE_PADDLE_LONG
:
1743 score
+=SCORE_POWER_LONG_PADDLE
;
1744 if (pad_width
==PAD_WIDTH
)
1746 pad_width
= LONG_PAD_WIDTH
;
1747 pad_pos_x
-= (LONG_PAD_WIDTH
-
1750 else if (pad_width
==SHORT_PAD_WIDTH
)
1752 pad_width
= PAD_WIDTH
;
1753 pad_pos_x
-=(PAD_WIDTH
-
1758 else if(pad_pos_x
+ pad_width
>
1760 pad_pos_x
= GAMESCREEN_WIDTH
-pad_width
;
1762 case POWER_TYPE_PADDLE_SHORT
:
1763 if (pad_width
==PAD_WIDTH
)
1765 pad_width
=SHORT_PAD_WIDTH
;
1766 pad_pos_x
+=(PAD_WIDTH
-
1769 else if (pad_width
==LONG_PAD_WIDTH
)
1771 pad_width
=PAD_WIDTH
;
1772 pad_pos_x
+=(LONG_PAD_WIDTH
-PAD_WIDTH
)/2;
1783 if (k
!= used_powers
)
1785 power
[k
].top
= power
[used_powers
].top
;
1786 power
[k
].x_pos
= power
[used_powers
].x_pos
;
1787 power
[k
].type
= power
[used_powers
].type
;
1795 /* draw the fires */
1796 for(k
=0;k
<used_fires
;k
++)
1798 rb
->lcd_vline(INT3(fire
[k
].x_pos
), INT3(fire
[k
].top
),
1799 INT3(fire
[k
].top
+ FIRE_LENGTH
));
1802 /* draw the powerups */
1803 for(k
=0;k
<used_powers
;k
++)
1805 rb
->lcd_bitmap_part(brickmania_powerups
,0,
1806 INT3(POWERUP_HEIGHT
)*power
[k
].type
,
1807 STRIDE(SCREEN_MAIN
, BMPWIDTH_brickmania_powerups
,
1808 BMPHEIGHT_brickmania_powerups
),
1809 INT3(power
[k
].x_pos
- (POWERUP_WIDTH
>> 1)),
1810 INT3(power
[k
].top
), INT3(POWERUP_WIDTH
),
1811 INT3(POWERUP_HEIGHT
));
1814 /* handle all of the bricks */
1815 for (i
=0; i
<NUM_BRICKS_ROWS
; i
++)
1817 for (j
=0; j
<NUM_BRICKS_COLS
;j
++)
1821 /* The brick is a brick, but it may or may not be in use */
1822 if(brick
[i
][j
].used
)
1824 struct rect brick_rect
;
1826 brickx
= LEFTMARGIN
+ j
*BRICK_WIDTH
;
1827 bricky
= TOPMARGIN
+ i
*BRICK_HEIGHT
;
1829 brick_rect
.top_left
.x
= brickx
;
1830 brick_rect
.top_left
.y
= bricky
;
1832 brick_rect
.bottom_right
.x
= brickx
+ BRICK_WIDTH
;
1833 brick_rect
.bottom_right
.y
= bricky
+ BRICK_HEIGHT
;
1835 /* Draw the brick */
1836 rb
->lcd_bitmap_part(brickmania_bricks
,0,
1837 INT3(BRICK_HEIGHT
)*brick
[i
][j
].color
,
1838 STRIDE( SCREEN_MAIN
,
1839 BMPWIDTH_brickmania_bricks
,
1840 BMPHEIGHT_brickmania_bricks
),
1843 INT3(BRICK_WIDTH
), INT3(BRICK_HEIGHT
) );
1845 #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
1846 if (brick
[i
][j
].hiteffect
> 0)
1847 rb
->lcd_bitmap_transparent_part(brickmania_break
,0,
1848 INT3(BRICK_HEIGHT
)*brick
[i
][j
].hiteffect
,
1849 STRIDE( SCREEN_MAIN
,
1850 BMPWIDTH_brickmania_break
,
1851 BMPHEIGHT_brickmania_break
),
1854 INT3(BRICK_WIDTH
), INT3(BRICK_HEIGHT
) );
1857 /* Check if any balls collided with the brick */
1858 for(k
=0; k
<used_balls
; k
++)
1862 /* Setup the ball path to describe the current ball
1863 * position and the line it makes to its next
1866 misc_line
.p1
.x
= ball
[k
].pos_x
;
1867 misc_line
.p1
.y
= ball
[k
].pos_y
;
1869 misc_line
.p2
.x
= ball
[k
].pos_x
+ ball
[k
].speedx
;
1870 misc_line
.p2
.y
= ball
[k
].pos_y
+ ball
[k
].speedy
;
1872 /* Check to see if the ball and the bottom hit. If
1873 * the ball is moving down we don't want to
1874 * include the bottom line intersection.
1876 * The order that the sides are checked matters.
1878 * Note that tempx/tempy store the next position
1879 * that the ball should be drawn.
1881 if (ball
[k
].speedy
<= 0 && check_rect(&misc_line
,
1882 &brick_rect
, INTERSECTION_BOTTOM
, &pt_hit
))
1884 ball
[k
].speedy
= -ball
[k
].speedy
;
1887 /* Check the top, if the ball is moving up dont
1888 * count it as a hit.
1890 else if (ball
[k
].speedy
> 0 && check_rect(&misc_line
,
1891 &brick_rect
, INTERSECTION_TOP
, &pt_hit
))
1893 ball
[k
].speedy
= -ball
[k
].speedy
;
1896 /* Check the left side of the brick */
1897 else if (check_rect(&misc_line
, &brick_rect
,
1898 INTERSECTION_LEFT
, &pt_hit
))
1900 ball
[k
].speedx
= -ball
[k
].speedx
;
1903 /* Check the right side of the brick */
1904 else if (check_rect(&misc_line
, &brick_rect
,
1905 INTERSECTION_RIGHT
, &pt_hit
))
1907 ball
[k
].speedx
= -ball
[k
].speedx
;
1913 ball
[k
].tempy
= pt_hit
.y
;
1914 ball
[k
].tempx
= pt_hit
.x
;
1924 /* draw the paddle according to the PAD_WIDTH */
1925 if( pad_width
== PAD_WIDTH
) /* Normal width */
1927 rb
->lcd_bitmap_part(
1929 0, paddle_type
*INT3(PAD_HEIGHT
),
1930 STRIDE( SCREEN_MAIN
, BMPWIDTH_brickmania_pads
,
1931 BMPHEIGHT_brickmania_pads
),
1932 INT3(pad_pos_x
), INT3(PAD_POS_Y
),
1933 INT3(pad_width
), INT3(PAD_HEIGHT
) );
1935 else if( pad_width
== LONG_PAD_WIDTH
) /* Long Pad */
1937 rb
->lcd_bitmap_part(
1938 brickmania_long_pads
,
1939 0,paddle_type
*INT3(PAD_HEIGHT
),
1940 STRIDE( SCREEN_MAIN
, BMPWIDTH_brickmania_long_pads
,
1941 BMPHEIGHT_brickmania_long_pads
),
1942 INT3(pad_pos_x
), INT3(PAD_POS_Y
),
1943 INT3(pad_width
), INT3(PAD_HEIGHT
) );
1945 else /* Short pad */
1947 rb
->lcd_bitmap_part(
1948 brickmania_short_pads
,
1949 0,paddle_type
*INT3(PAD_HEIGHT
),
1950 STRIDE( SCREEN_MAIN
, BMPWIDTH_brickmania_short_pads
,
1951 BMPHEIGHT_brickmania_short_pads
),
1952 INT3(pad_pos_x
), INT3(PAD_POS_Y
),
1953 INT3(pad_width
), INT3(PAD_HEIGHT
) );
1956 /* If the game is not paused continue */
1957 if (game_state
!=ST_PAUSE
)
1959 /* Loop through all of the balls in play */
1960 for(k
=0;k
<used_balls
;k
++)
1962 struct line screen_edge
;
1964 /* Describe the ball movement for the edge collision detection */
1965 misc_line
.p1
.x
= ball
[k
].pos_x
;
1966 misc_line
.p1
.y
= ball
[k
].pos_y
;
1968 misc_line
.p2
.x
= ball
[k
].pos_x
+ ball
[k
].speedx
;
1969 misc_line
.p2
.y
= ball
[k
].pos_y
+ ball
[k
].speedy
;
1971 /* Did the Ball hit the top of the screen? */
1972 screen_edge
.p1
.x
= 0;
1973 screen_edge
.p1
.y
= 0;
1975 screen_edge
.p2
.x
= GAMESCREEN_WIDTH
;
1976 screen_edge
.p2
.y
= 0;
1977 /* the test for pos_y prevents the ball from bouncing back
1978 * from _over_ the top to infinity on some rare cases */
1979 if (ball
[k
].pos_y
> 0 &&
1980 check_lines(&misc_line
, &screen_edge
, &pt_hit
))
1982 ball
[k
].tempy
= pt_hit
.y
+ 1;
1983 ball
[k
].tempx
= pt_hit
.x
;
1984 /* Reverse the direction */
1985 ball
[k
].speedy
= -ball
[k
].speedy
;
1988 /* Player missed the ball and hit bottom of screen */
1989 if (ball
[k
].pos_y
>= GAMESCREEN_HEIGHT
)
1991 /* Player had balls to spare, so handle the removal */
1994 /* decrease number of balls in play */
1996 /* Replace removed ball with the last ball */
1997 ball
[k
].pos_x
= ball
[used_balls
].pos_x
;
1998 ball
[k
].pos_y
= ball
[used_balls
].pos_y
;
1999 ball
[k
].speedy
= ball
[used_balls
].speedy
;
2000 ball
[k
].tempy
= ball
[used_balls
].tempy
;
2001 ball
[k
].speedx
= ball
[used_balls
].speedx
;
2002 ball
[k
].tempx
= ball
[used_balls
].tempx
;
2003 ball
[k
].glue
= ball
[used_balls
].glue
;
2005 /* Reset the last ball that was removed */
2006 ball
[used_balls
].speedx
=0;
2007 ball
[used_balls
].speedy
=0;
2008 ball
[used_balls
].tempy
=0;
2009 ball
[used_balls
].tempx
=0;
2010 ball
[used_balls
].pos_y
=ON_PAD_POS_Y
;
2011 ball
[used_balls
].pos_x
=pad_pos_x
+(pad_width
/2)-HALFBALL
;
2018 /* Player lost a life */
2022 /* No lives left reset game */
2023 brickmania_init_game(false);
2024 brickmania_sleep(2);
2025 rb
->button_clear_queue();
2030 if (game_state
!= ST_READY
&& !ball
[k
].glue
)
2032 /* Check if the ball hit the left side */
2033 screen_edge
.p1
.x
= 0;
2034 screen_edge
.p1
.y
= 0;
2036 screen_edge
.p2
.x
= 0;
2037 screen_edge
.p2
.y
= GAMESCREEN_HEIGHT
;
2038 if (check_lines(&misc_line
, &screen_edge
, &pt_hit
))
2040 /* Reverse direction */
2041 ball
[k
].speedx
= abs(ball
[k
].speedx
);
2043 /* Re-position ball in gameboard */
2044 ball
[k
].tempy
= pt_hit
.y
;
2048 /* Check if the ball hit the right side */
2049 screen_edge
.p1
.x
= GAMESCREEN_WIDTH
;
2050 screen_edge
.p1
.y
= 0;
2052 screen_edge
.p2
.x
= GAMESCREEN_WIDTH
;
2053 screen_edge
.p2
.y
= GAMESCREEN_HEIGHT
;
2054 if (check_lines(&misc_line
, &screen_edge
, &pt_hit
))
2056 /* Reverse direction */
2057 ball
[k
].speedx
= -abs(ball
[k
].speedx
);
2059 /* Re-position ball in gameboard */
2060 ball
[k
].tempy
= pt_hit
.y
;
2061 ball
[k
].tempx
= GAMESCREEN_WIDTH
- FIXED3(1);
2064 /* Did the ball hit the paddle? Depending on where the ball
2065 * Hit set the x/y speed appropriately.
2067 if(check_rect(&misc_line
, &pad_rect
, INTERSECTION_TOP
,
2070 /* Re-position ball based on collision */
2071 ball
[k
].tempy
= ON_PAD_POS_Y
;
2072 ball
[k
].tempx
= pt_hit
.x
;
2074 /* Calculate the ball position relative to the paddle width */
2075 int ball_repos
= pt_hit
.x
- pad_pos_x
;
2076 /* If the ball hits the right half of paddle, x speed
2077 * should be positive, if it hits the left half it
2078 * should be negative.
2080 int x_direction
= -1;
2082 /* Comparisons are done with respect to 1/2 pad_width */
2083 if(ball_repos
> pad_width
/2)
2085 /* flip the relative position */
2086 ball_repos
-= ((ball_repos
- pad_width
/2) << 1);
2087 /* Ball hit the right half so X speed calculations
2088 * should be positive.
2093 /* Figure out where the ball hit relative to 1/2 pad
2094 * and in divisions of 4.
2096 ball_repos
= ball_repos
/ (pad_width
/2/4);
2100 /* Ball hit the outer edge of the paddle */
2102 ball
[k
].speedy
= SPEED_1Q_Y
;
2103 ball
[k
].speedx
= SPEED_1Q_X
* x_direction
;
2105 /* Ball hit the next fourth of the paddle */
2107 ball
[k
].speedy
= SPEED_2Q_Y
;
2108 ball
[k
].speedx
= SPEED_2Q_X
* x_direction
;
2110 /* Ball hit the third fourth of the paddle */
2112 ball
[k
].speedy
= SPEED_3Q_Y
;
2113 ball
[k
].speedx
= SPEED_3Q_X
* x_direction
;
2115 /* Ball hit the fourth fourth of the paddle or dead
2120 ball
[k
].speedy
= SPEED_4Q_Y
;
2121 /* Since this is the middle we don't want to
2122 * force the ball in a different direction.
2123 * Just keep it going in the same direction
2124 * with a specific speed.
2126 if(ball
[k
].speedx
> 0)
2128 ball
[k
].speedx
= SPEED_4Q_X
;
2132 ball
[k
].speedx
= -SPEED_4Q_X
;
2137 ball
[k
].speedy
= SPEED_4Q_Y
;
2141 if(paddle_type
== PADDLE_TYPE_STICKY
)
2143 ball
[k
].speedy
= -ball
[k
].speedy
;
2146 /* X location should not be forced since that is moved with the paddle. The Y
2147 * position should be forced to keep the ball at the paddle.
2150 ball
[k
].tempy
= ON_PAD_POS_Y
;
2155 /* Update the ball position */
2159 ball
[k
].pos_x
= ball
[k
].tempx
;
2161 ball
[k
].pos_x
+= ball
[k
].speedx
;
2164 ball
[k
].pos_y
= ball
[k
].tempy
;
2166 ball
[k
].pos_y
+= ball
[k
].speedy
;
2176 if (brick_on_board
< 0)
2178 if (level
+1<NUM_LEVELS
)
2181 if (difficulty
==NORMAL
)
2182 score
+=SCORE_LEVEL_COMPLETED
;
2183 brickmania_init_game(true);
2184 brickmania_sleep(2);
2185 rb
->button_clear_queue();
2189 rb
->lcd_getstringsize("Congratulations!", &sw
, &sh
);
2190 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_FINISH
) - 2 * sh
,
2191 "Congratulations!");
2192 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
2193 rb
->lcd_getstringsize("No more levels", &sw
, NULL
);
2194 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_FINISH
),
2197 rb
->lcd_getstringsize("You have finished the game!",
2199 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_FINISH
),
2200 "You have finished the game!");
2204 brickmania_sleep(2);
2209 int button
=rb
->button_get(false);
2210 int move_button
= rb
->button_status();
2212 #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN)
2213 /* FIXME: Should probably check remote hold here */
2214 if (rb
->button_hold())
2218 #ifdef HAVE_TOUCHSCREEN
2219 if( move_button
& BUTTON_TOUCHSCREEN
)
2222 short touch_x
, touch_y
;
2223 rb
->button_status_wdata(&data
);
2224 touch_x
= FIXED3(data
>> 16);
2225 touch_y
= FIXED3(data
& 0xffff);
2229 pad_pos_x
= GAMESCREEN_WIDTH
- (touch_x
+ pad_width
/2);
2233 pad_pos_x
= (touch_x
- pad_width
/2);
2238 else if(pad_pos_x
+ pad_width
> GAMESCREEN_WIDTH
)
2239 pad_pos_x
= GAMESCREEN_WIDTH
-pad_width
;
2240 for(k
=0; k
<used_balls
; k
++)
2241 if (game_state
==ST_READY
|| ball
[k
].glue
)
2242 ball
[k
].pos_x
= pad_pos_x
+ pad_width
/2;
2247 int button_right
, button_left
;
2249 button_right
= move_button
& (RIGHT
| ALTRIGHT
);
2250 button_left
= move_button
& (LEFT
| ALTLEFT
);
2252 button_right
=((move_button
& RIGHT
)|| SCROLL_FWD(button
));
2253 button_left
=((move_button
& LEFT
) ||SCROLL_BACK(button
));
2255 if ((game_state
==ST_PAUSE
) && (button_right
|| button_left
))
2258 if (button_left
|| button_right
)
2262 if ((button_right
&& !flip_sides
) ||
2263 (button_left
&& flip_sides
))
2265 if (pad_pos_x
+SPEED_PAD
+pad_width
> GAMESCREEN_WIDTH
)
2266 dx
= GAMESCREEN_WIDTH
- pad_pos_x
- pad_width
;
2270 else if ((button_left
&& !flip_sides
) ||
2271 (button_right
&& flip_sides
))
2273 if (pad_pos_x
-SPEED_PAD
< 0)
2280 for(k
=0;k
<used_balls
;k
++)
2282 if (game_state
==ST_READY
|| ball
[k
].glue
)
2286 if (ball
[k
].pos_x
< HALFBALL
)
2287 ball
[k
].pos_x
= HALFBALL
;
2288 else if (ball
[k
].pos_x
> GAMESCREEN_WIDTH
- HALFBALL
)
2289 ball
[k
].pos_x
= GAMESCREEN_WIDTH
- HALFBALL
;
2297 #if defined(HAVE_TOUCHSCREEN)
2298 case (BUTTON_REL
| BUTTON_TOUCHSCREEN
):
2305 if (game_state
==ST_READY
)
2307 /* Initialize used balls starting speed */
2308 for(k
=0 ; k
< used_balls
; k
++)
2310 ball
[k
].speedy
= SPEED_4Q_Y
;
2311 if(pad_pos_x
+ (pad_width
/2) >= GAMESCREEN_WIDTH
/2)
2313 ball
[k
].speedx
= SPEED_4Q_X
;
2317 ball
[k
].speedx
= -SPEED_4Q_X
;
2320 game_state
=ST_START
;
2322 else if (game_state
==ST_PAUSE
)
2324 game_state
=ST_START
;
2326 else if (paddle_type
== PADDLE_TYPE_STICKY
)
2328 for(k
=0;k
<used_balls
;k
++)
2333 ball
[k
].speedy
= -ball
[k
].speedy
;
2337 else if (paddle_type
== PADDLE_TYPE_SHOOTER
)
2339 if (used_fires
< MAX_FIRES
)
2341 fire
[used_fires
].top
= PAD_POS_Y
- FIRE_LENGTH
;
2342 fire
[used_fires
].x_pos
= pad_pos_x
+ 1; /* Add 1 for edge */
2345 if (used_fires
< MAX_FIRES
)
2347 fire
[used_fires
].top
= PAD_POS_Y
- FIRE_LENGTH
;
2348 fire
[used_fires
].x_pos
= pad_pos_x
+ pad_width
- 1; /* Sub1 edge*/
2362 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
2369 #ifdef HAVE_LCD_COLOR
2370 rb
->lcd_bitmap_transparent(brickmania_gameover
,
2371 (LCD_WIDTH
- INT3(GAMEOVER_WIDTH
))/2,
2372 INT3(GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2373 INT3(GAMEOVER_WIDTH
),INT3(GAMEOVER_HEIGHT
));
2374 #else /* greyscale and mono */
2375 rb
->lcd_bitmap(brickmania_gameover
,(LCD_WIDTH
-
2376 INT3(GAMEOVER_WIDTH
))/2,
2377 INT3(GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2378 INT3(GAMEOVER_WIDTH
),INT3(GAMEOVER_HEIGHT
) );
2381 brickmania_sleep(2);
2385 /* Game always needs to yield for other threads */
2388 /* Sleep for a bit if there is time to spare */
2389 if (TIME_BEFORE(*rb
->current_tick
, end
))
2390 rb
->sleep(end
-*rb
->current_tick
);
2395 /* this is the plugin entry point */
2396 enum plugin_status
plugin_start(const void* parameter
)
2399 int last_difficulty
;
2401 highscore_load(SCORE_FILE
, highscores
, NUM_SCORES
);
2402 configfile_load(CONFIG_FILE_NAME
,config
,1,0);
2403 last_difficulty
= difficulty
;
2405 #ifdef HAVE_TOUCHSCREEN
2406 rb
->touchscreen_set_mode(TOUCHSCREEN_POINT
);
2409 rb
->lcd_setfont(FONT_SYSFIXED
);
2411 rb
->lcd_set_backdrop(NULL
);
2413 /* Turn off backlight timeout */
2414 backlight_force_on(); /* backlight control in lib/helper.c */
2416 /* now go ahead and have fun! */
2417 rb
->srand( *rb
->current_tick
);
2418 brickmania_loadgame();
2419 resume_file
= resume
;
2420 while(!brickmania_game_loop())
2424 int position
= highscore_update(score
, level
+1, "",
2425 highscores
, NUM_SCORES
);
2429 rb
->splash(HZ
*2, "New High Score");
2430 highscore_show(position
, highscores
, NUM_SCORES
, true);
2434 brickmania_sleep(3);
2439 highscore_save(SCORE_FILE
, highscores
, NUM_SCORES
);
2440 if(last_difficulty
!= difficulty
)
2441 configfile_save(CONFIG_FILE_NAME
,config
,1,0);
2442 /* Restore user's original backlight setting */
2443 rb
->lcd_setfont(FONT_UI
);
2444 /* Turn on backlight timeout (revert to settings) */
2445 backlight_use_settings(); /* backlight control in lib/helper.c */