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"
34 /* If there are three fractional bits, the smallest screen size that will scale
35 * properly is 28x22. If you have a smaller screen increase the fractional
36 * precision. If you have a precision of 4 the smallest screen size would be
37 * 14x11. Note though that this will decrease the maximum resolution due to
38 * the line intersection tests. These defines are used for all of the fixed
39 * point calculations/conversions.
41 #define FIXED3(x) ((x)<<3)
42 #define FIXED3_MUL(x, y) ((long long)((x)*(y))>>3)
43 #define FIXED3_DIV(x, y) (((x)<<3)/(y))
44 #define INT3(x) ((x)>>3)
46 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
47 (CONFIG_KEYPAD == IRIVER_H300_PAD)
48 #define CONTINUE_TEXT "Press NAVI To Continue"
49 #define QUIT BUTTON_OFF
50 #define LEFT BUTTON_LEFT
51 #define RIGHT BUTTON_RIGHT
52 #define SELECT BUTTON_SELECT
54 #define DOWN BUTTON_DOWN
55 #define RC_QUIT BUTTON_RC_STOP
57 #elif CONFIG_KEYPAD == ONDIO_PAD
58 #define CONTINUE_TEXT "MENU To Continue"
59 #define QUIT BUTTON_OFF
60 #define LEFT BUTTON_LEFT
61 #define RIGHT BUTTON_RIGHT
62 #define SELECT BUTTON_MENU
64 #define DOWN BUTTON_DOWN
66 #elif CONFIG_KEYPAD == RECORDER_PAD
67 #define QUIT BUTTON_OFF
68 #define LEFT BUTTON_LEFT
69 #define RIGHT BUTTON_RIGHT
70 #define SELECT BUTTON_PLAY
72 #define DOWN BUTTON_DOWN
74 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
75 #define QUIT BUTTON_OFF
76 #define LEFT BUTTON_LEFT
77 #define RIGHT BUTTON_RIGHT
78 #define SELECT BUTTON_SELECT
80 #define DOWN BUTTON_DOWN
82 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
83 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
84 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
85 #define QUIT BUTTON_MENU
86 #define LEFT BUTTON_LEFT
87 #define RIGHT BUTTON_RIGHT
88 #define SELECT BUTTON_SELECT
89 #define UP BUTTON_SCROLL_BACK
90 #define DOWN BUTTON_SCROLL_FWD
91 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
92 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
94 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
95 #define QUIT BUTTON_POWER
96 #define LEFT BUTTON_LEFT
97 #define RIGHT BUTTON_RIGHT
98 #define SELECT BUTTON_SELECT
100 #define DOWN BUTTON_DOWN
102 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
103 #define QUIT BUTTON_POWER
104 #define LEFT BUTTON_LEFT
105 #define RIGHT BUTTON_RIGHT
106 #define SELECT BUTTON_PLAY
108 #define DOWN BUTTON_DOWN
110 #elif (CONFIG_KEYPAD == SANSA_E200_PAD)
111 #define QUIT BUTTON_POWER
112 #define LEFT BUTTON_LEFT
113 #define RIGHT BUTTON_RIGHT
114 #define SELECT BUTTON_SELECT
116 #define DOWN BUTTON_DOWN
117 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
118 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
121 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
122 #define QUIT (BUTTON_HOME|BUTTON_REPEAT)
123 #define LEFT BUTTON_LEFT
124 #define RIGHT BUTTON_RIGHT
125 #define SELECT BUTTON_SELECT
127 #define DOWN BUTTON_DOWN
129 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
130 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
133 #elif CONFIG_KEYPAD == SANSA_C200_PAD || \
134 CONFIG_KEYPAD == SANSA_CLIP_PAD || \
135 CONFIG_KEYPAD == SANSA_M200_PAD
136 #define QUIT BUTTON_POWER
137 #define LEFT BUTTON_LEFT
138 #define RIGHT BUTTON_RIGHT
139 #define ALTLEFT BUTTON_VOL_DOWN
140 #define ALTRIGHT BUTTON_VOL_UP
141 #define SELECT BUTTON_SELECT
143 #define DOWN BUTTON_DOWN
145 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
146 #define QUIT BUTTON_POWER
147 #define LEFT BUTTON_LEFT
148 #define RIGHT BUTTON_RIGHT
149 #define SELECT BUTTON_PLAY
150 #define UP BUTTON_SCROLL_UP
151 #define DOWN BUTTON_SCROLL_DOWN
153 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
154 #define QUIT BUTTON_BACK
155 #define LEFT BUTTON_LEFT
156 #define RIGHT BUTTON_RIGHT
157 #define SELECT BUTTON_SELECT
159 #define DOWN BUTTON_DOWN
161 #elif (CONFIG_KEYPAD == MROBE100_PAD)
162 #define QUIT BUTTON_POWER
163 #define LEFT BUTTON_LEFT
164 #define RIGHT BUTTON_RIGHT
165 #define SELECT BUTTON_SELECT
167 #define DOWN BUTTON_DOWN
169 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
170 #define CONTINUE_TEXT "PLAY To Continue"
171 #define QUIT BUTTON_RC_REC
172 #define LEFT BUTTON_RC_REW
173 #define RIGHT BUTTON_RC_FF
174 #define SELECT BUTTON_RC_PLAY
175 #define UP BUTTON_RC_VOL_UP
176 #define DOWN BUTTON_RC_VOL_DOWN
177 #define RC_QUIT BUTTON_REC
179 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
180 #define QUIT BUTTON_BACK
181 #define LEFT BUTTON_LEFT
182 #define RIGHT BUTTON_RIGHT
183 #define SELECT BUTTON_SELECT
185 #define DOWN BUTTON_DOWN
187 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
188 #define QUIT BUTTON_POWER
189 #define LEFT BUTTON_LEFT
190 #define RIGHT BUTTON_RIGHT
191 #define SELECT BUTTON_SELECT
193 #define DOWN BUTTON_DOWN
195 #elif CONFIG_KEYPAD == COWOND2_PAD
196 #define QUIT BUTTON_POWER
198 #elif CONFIG_KEYPAD == ONDAVX747_PAD
199 #define QUIT BUTTON_POWER
200 #define LEFT BUTTON_VOL_DOWN
201 #define RIGHT BUTTON_VOL_UP
202 #define SELECT BUTTON_MENU
203 #elif CONFIG_KEYPAD == ONDAVX777_PAD
204 #define QUIT BUTTON_POWER
206 #elif CONFIG_KEYPAD == MROBE500_PAD
207 #define QUIT BUTTON_POWER
209 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
210 #define QUIT BUTTON_FFWD
211 #define SELECT BUTTON_PLAY
212 #define LEFT BUTTON_LEFT
213 #define RIGHT BUTTON_RIGHT
215 #define DOWN BUTTON_DOWN
219 #error No keymap defined!
222 #ifdef HAVE_TOUCHSCREEN
224 #define LEFT BUTTON_BOTTOMLEFT
227 #define RIGHT BUTTON_BOTTOMRIGHT
230 #define SELECT BUTTON_CENTER
233 #define UP BUTTON_TOPMIDDLE
236 #define DOWN BUTTON_BOTTOMMIDDLE
240 /* Continue text is used as a string later when the game is paused. This allows
241 * targets to specify their own text if needed.
243 #if !defined(CONTINUE_TEXT)
244 #define CONTINUE_TEXT "Press SELECT To Continue"
247 #ifndef SCROLL_FWD /* targets without scroll wheel*/
248 #define SCROLL_FWD(x) (0)
249 #define SCROLL_BACK(x) (0)
252 #include "pluginbitmaps/brickmania_pads.h"
253 #include "pluginbitmaps/brickmania_short_pads.h"
254 #include "pluginbitmaps/brickmania_long_pads.h"
255 #include "pluginbitmaps/brickmania_bricks.h"
256 #include "pluginbitmaps/brickmania_powerups.h"
257 #include "pluginbitmaps/brickmania_ball.h"
258 #include "pluginbitmaps/brickmania_gameover.h"
260 #define GAMESCREEN_WIDTH FIXED3(LCD_WIDTH)
262 #if LCD_WIDTH<=LCD_HEIGHT
263 /* Maintain a 4/3 ratio (width/height) */
264 #define GAMESCREEN_HEIGHT (GAMESCREEN_WIDTH * 3 / 4)
266 #define GAMESCREEN_HEIGHT FIXED3(LCD_HEIGHT)
269 #define PAD_WIDTH FIXED3(BMPWIDTH_brickmania_pads)
270 #define PAD_HEIGHT FIXED3(BMPHEIGHT_brickmania_pads/3)
271 #define SHORT_PAD_WIDTH FIXED3(BMPWIDTH_brickmania_short_pads)
272 #define LONG_PAD_WIDTH FIXED3(BMPWIDTH_brickmania_long_pads)
273 #define BRICK_HEIGHT FIXED3(BMPHEIGHT_brickmania_bricks/7)
274 #define BRICK_WIDTH FIXED3(BMPWIDTH_brickmania_bricks)
275 #define LEFTMARGIN ((GAMESCREEN_WIDTH-10*BRICK_WIDTH)/2)
276 #define NUMBER_OF_POWERUPS 9
277 #define POWERUP_HEIGHT FIXED3(BMPHEIGHT_brickmania_powerups/NUMBER_OF_POWERUPS)
278 #define POWERUP_WIDTH FIXED3(BMPWIDTH_brickmania_powerups)
279 #define BALL FIXED3(BMPHEIGHT_brickmania_ball)
280 #define HALFBALL (BALL / 2)
282 #define GAMEOVER_WIDTH FIXED3(BMPWIDTH_brickmania_gameover)
283 #define GAMEOVER_HEIGHT FIXED3(BMPHEIGHT_brickmania_gameover)
285 #ifdef HAVE_LCD_COLOR /* currently no transparency for non-colour */
286 #include "pluginbitmaps/brickmania_break.h"
289 /* The time (in ms) for one iteration through the game loop - decrease this
290 * to speed up the game - note that current_tick is (currently) only accurate
295 #define TOPMARGIN MAX(BRICK_HEIGHT, FIXED3(8))
297 #define STRINGPOS_FINISH (GAMESCREEN_HEIGHT - (GAMESCREEN_HEIGHT / 6))
298 #define STRINGPOS_CONGRATS (STRINGPOS_FINISH - 20)
299 #define STRINGPOS_NAVI (STRINGPOS_FINISH - 10)
300 #define STRINGPOS_FLIP (STRINGPOS_FINISH - 10)
302 /* Brickmania was originally designed for the H300, other targets should scale
303 * the speed up/down as needed based on the screen height.
305 #define SPEED_SCALE_H(y) FIXED3_DIV(GAMESCREEN_HEIGHT, FIXED3(176)/(y) )
306 #define SPEED_SCALE_W(x) FIXED3_DIV(GAMESCREEN_WIDTH, FIXED3(220)/(x) )
308 /* These are all used as ball speeds depending on where the ball hit the
311 * Note that all of these speeds (including pad, power, and fire)
312 * could be made variable and could be raised to be much higher to add
313 * additional difficulty to the game. The line intersection tests allow this
314 * to be drastically increased without the collision detection failing
317 #define SPEED_1Q_X SPEED_SCALE_W( 6)
318 #define SPEED_1Q_Y SPEED_SCALE_H(-2)
320 #define SPEED_2Q_X SPEED_SCALE_W( 4)
321 #define SPEED_2Q_Y SPEED_SCALE_H(-3)
323 #define SPEED_3Q_X SPEED_SCALE_W( 3)
324 #define SPEED_3Q_Y SPEED_SCALE_H(-4)
326 #define SPEED_4Q_X SPEED_SCALE_W( 2)
327 #define SPEED_4Q_Y SPEED_SCALE_H(-4)
329 /* This is used to determine the speed of the paddle */
330 #define SPEED_PAD SPEED_SCALE_W( 8)
332 /* This defines the speed that the powerups drop */
333 #define SPEED_POWER SPEED_SCALE_H( 2)
335 /* This defines the speed that the shot moves */
336 #define SPEED_FIRE SPEED_SCALE_H( 4)
337 #define FIRE_LENGTH SPEED_SCALE_H( 7)
339 /*calculate paddle y-position */
340 #define PAD_POS_Y (GAMESCREEN_HEIGHT - PAD_HEIGHT - 1)
342 /* change to however many levels there are, i.e. how many arrays there are total */
345 /* change the first number in [ ] to however many levels there are (levels_num) */
346 static unsigned char levels
[40][8][10] =
347 /* You can set up new levels with the level editor
348 ( http://plugbox.rockbox-lounge.com/brickmania.htm ).
349 With 0x1, it refers to the first brick in the bitmap, 0x2 would refer to the
350 second, ect., 0x0 leaves a empty space. If you add a 2 before the 2nd number,
351 it will take two hits to break, and 3 hits if you add a 3. That is 0x24, will
352 result with the fourth brick being displayed and having take 2 hits to break.
353 You could do the same with the 3, just replace the 2 with a 3 for it to take
354 three hits to break it apart. */
357 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
358 {0x2,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x2},
359 {0x0,0x2,0x1,0x0,0x0,0x0,0x0,0x1,0x2,0x0},
360 {0x0,0x0,0x2,0x1,0x0,0x0,0x1,0x2,0x0,0x0},
361 {0x0,0x0,0x0,0x2,0x1,0x1,0x2,0x0,0x0,0x0},
362 {0x7,0x0,0x0,0x7,0x2,0x2,0x7,0x0,0x0,0x7},
363 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
364 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
367 {0x0,0x0,0x7,0x7,0x1,0x1,0x7,0x7,0x0,0x0},
368 {0x0,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x0},
369 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
370 {0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1},
371 {0x1,0x1,0x2,0x1,0x0,0x0,0x1,0x2,0x1,0x1},
372 {0x1,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x2,0x1},
373 {0x0,0x1,0x2,0x0,0x0,0x0,0x0,0x2,0x1,0x0},
374 {0x0,0x0,0x1,0x2,0x2,0x2,0x2,0x1,0x0,0x0}
377 {0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
378 {0x3,0x23,0x23,0x3,0x0,0x0,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
522 {0x2,0x0,0x0,0x1,0x2,0x2,0x1,0x0,0x0,0x2},
523 {0x2,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x2},
524 {0x2,0x2,0x1,0x0,0x1,0x1,0x0,0x1,0x2,0x2}
526 {/* level 18 (Tetris) by ts-x */
527 {0x0,0x2,0x0,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
528 {0x0,0x2,0x7,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
529 {0x2,0x2,0x7,0x0,0x3,0x4,0x0,0x6,0x2,0x2},
530 {0x2,0x2,0x7,0x7,0x3,0x4,0x0,0x6,0x2,0x2},
531 {0x2,0x1,0x7,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
532 {0x2,0x1,0x0,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
533 {0x1,0x1,0x1,0x7,0x3,0x0,0x6,0x6,0x5,0x5},
534 {0x1,0x1,0x1,0x0,0x3,0x0,0x6,0x6,0x5,0x5}
536 { /* level 19 (Stalactites) by ts-x */
537 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
538 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
539 {0x5,0x0,0x6,0x3,0x4,0x7,0x5,0x0,0x1,0x2},
540 {0x5,0x2,0x6,0x3,0x4,0x0,0x5,0x3,0x1,0x2},
541 {0x5,0x0,0x6,0x0,0x4,0x7,0x5,0x0,0x1,0x0},
542 {0x5,0x0,0x0,0x3,0x4,0x0,0x0,0x0,0x1,0x2},
543 {0x0,0x0,0x6,0x0,0x0,0x0,0x5,0x0,0x0,0x0},
544 {0x5,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x1,0x0}
546 { /* level 20 (Maze) by ts-x */
547 {0x1,0x1,0x21,0x1,0x1,0x1,0x1,0x1,0x1,0x21},
548 {0x1,0x0,0x0,0x3,0x0,0x0,0x3,0x1,0x31,0x1},
549 {0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x0,0x1},
550 {0x21,0x0,0x21,0x3,0x0,0x3,0x0,0x3,0x0,0x2},
551 {0x1,0x0,0x1,0x21,0x0,0x12,0x0,0x0,0x0,0x0},
552 {0x31,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x3,0x0},
553 {0x1,0x0,0x1,0x0,0x1,0x1,0x31,0x1,0x1,0x2},
554 {0x22,0x0,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x21}
556 { /* level 21 (Dentist) by ts-x */
557 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
558 {0x2,0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x2,0x2},
559 {0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x2},
560 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x2},
561 {0x2,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x0,0x2},
562 {0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x2},
563 {0x2,0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x2,0x2},
564 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0}
566 { /* level 22 (Spider) by ts-x */
567 {0x31,0x3,0x1,0x1,0x0,0x0,0x1,0x1,0x3,0x31},
568 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
569 {0x33,0x1,0x1,0x36,0x1,0x1,0x36,0x1,0x1,0x33},
570 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
571 {0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x0,0x0},
572 {0x21,0x3,0x1,0x21,0x2,0x2,0x21,0x1,0x3,0x21},
573 {0x0,0x0,0x0,0x1,0x21,0x1,0x1,0x0,0x0,0x0},
574 {0x3,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x3}
576 { /* level 23 (Pool) by ts-x */
577 {0x0,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x7,0x0},
578 {0x0,0x0,0x5,0x0,0x2,0x0,0x0,0x0,0x2,0x0},
579 {0x7,0x3,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x7},
580 {0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x5,0x0,0x7},
581 {0x7,0x0,0x4,0x0,0x0,0x3,0x0,0x0,0x0,0x7},
582 {0x7,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x4,0x7},
583 {0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
584 {0x0,0x7,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x0}
586 { /* level 24 (Vorbis Fish) by ts-x */
587 {0x0,0x0,0x4,0x4,0x5,0x5,0x5,0x0,0x0,0x5},
588 {0x0,0x4,0x6,0x4,0x4,0x5,0x5,0x5,0x0,0x5},
589 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x5,0x5,0x5},
590 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x4,0x5,0x5},
591 {0x0,0x5,0x6,0x4,0x4,0x5,0x5,0x4,0x5,0x0},
592 {0x5,0x5,0x4,0x4,0x5,0x5,0x5,0x4,0x5,0x5},
593 {0x5,0x4,0x4,0x4,0x5,0x5,0x4,0x4,0x5,0x5},
594 {0x0,0x0,0x4,0x4,0x4,0x4,0x4,0x5,0x0,0x5}
596 {/* level 25 (Rainbow) by ts-x */
597 {0x0,0x4,0x1,0x0,0x0,0x0,0x0,0x1,0x4,0x0},
598 {0x24,0x1,0x3,0x1,0x0,0x0,0x21,0x3,0x1,0x24},
599 {0x1,0x23,0x5,0x3,0x1,0x21,0x3,0x5,0x3,0x21},
600 {0x3,0x5,0x6,0x5,0x3,0x3,0x5,0x6,0x5,0x3},
601 {0x5,0x6,0x7,0x6,0x5,0x5,0x6,0x7,0x6,0x5},
602 {0x6,0x7,0x2,0x27,0x6,0x6,0x27,0x2,0x7,0x6},
603 {0x7,0x2,0x0,0x2,0x27,0x27,0x2,0x0,0x2,0x7},
604 {0x32,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x32}
606 { /* level 26 (Bowtie) by ts-x */
607 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5},
608 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
609 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
610 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
611 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
612 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
613 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
614 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5}
616 { /* level 27 (Frog) by ts-x */
617 {0x0,0x5,0x25,0x0,0x0,0x0,0x0,0x25,0x5,0x0},
618 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
619 {0x25,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x25},
620 {0x5,0x0,0x3,0x0,0x6,0x6,0x0,0x3,0x0,0x5},
621 {0x5,0x0,0x31,0x0,0x6,0x6,0x0,0x31,0x0,0x5},
622 {0x5,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x5},
623 {0x5,0x5,0x5,0x35,0x0,0x0,0x35,0x5,0x5,0x5},
624 {0x0,0x25,0x5,0x0,0x4,0x4,0x0,0x5,0x25,0x0}
626 { /* level 28 (DigDug) by ts-x */
627 {0x35,0x5,0x5,0x25,0x0,0x25,0x25,0x5,0x5,0x35},
628 {0x6,0x0,0x0,0x6,0x0,0x6,0x6,0x0,0x0,0x6},
629 {0x7,0x0,0x37,0x37,0x0,0x37,0x37,0x7,0x0,0x7},
630 {0x7,0x0,0x7,0x0,0x0,0x0,0x7,0x7,0x7,0x7},
631 {0x4,0x4,0x4,0x24,0x0,0x24,0x4,0x0,0x0,0x4},
632 {0x4,0x4,0x0,0x0,0x0,0x4,0x4,0x0,0x4,0x4},
633 {0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4},
634 {0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1}
636 { /* level 29 UK Flag by Seth Opgenorth */
637 {0x32,0x0,0x3,0x3,0x2,0x2,0x3,0x3,0x0,0x32},
638 {0x0,0x2,0x0,0x3,0x32,0x22,0x33,0x0,0x32,0x0},
639 {0x33,0x0,0x22,0x0,0x2,0x2,0x0,0x2,0x0,0x33},
640 {0x22,0x32,0x2,0x2,0x2,0x2,0x2,0x2,0x22,0x2},
641 {0x3,0x0,0x0,0x32,0x22,0x2,0x2,0x0,0x0,0x3},
642 {0x23,0x0,0x32,0x0,0x32,0x2,0x0,0x2,0x0,0x3},
643 {0x0,0x2,0x0,0x3,0x2,0x2,0x3,0x0,0x22,0x0},
644 {0x32,0x0,0x3,0x23,0x2,0x2,0x23,0x33,0x0,0x32}
646 { /* level 30 Win-Logo by Seth Opgenorth */
647 {0x0,0x0,0x0,0x22,0x0,0x0,0x0,0x0,0x0,0x0},
648 {0x0,0x0,0x32,0x2,0x2,0x25,0x0,0x5,0x0,0x0},
649 {0x0,0x0,0x2,0x22,0x2,0x5,0x5,0x35,0x0,0x0},
650 {0x0,0x0,0x2,0x1,0x2,0x5,0x5,0x25,0x0,0x0},
651 {0x0,0x0,0x21,0x1,0x1,0x36,0x7,0x26,0x0,0x0},
652 {0x0,0x0,0x1,0x1,0x1,0x6,0x6,0x6,0x0,0x0},
653 {0x0,0x0,0x21,0x0,0x21,0x6,0x6,0x26,0x0,0x0},
654 {0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x0,0x0}
656 { /* level 31 Color wave/V by Seth Opgenorth */
657 {0x25,0x34,0x2,0x31,0x33,0x23,0x1,0x2,0x34,0x5},
658 {0x3,0x5,0x24,0x2,0x1,0x1,0x2,0x4,0x5,0x3},
659 {0x1,0x3,0x5,0x4,0x2,0x2,0x4,0x5,0x3,0x1},
660 {0x2,0x1,0x33,0x35,0x4,0x4,0x5,0x33,0x1,0x22},
661 {0x31,0x22,0x1,0x3,0x5,0x25,0x3,0x1,0x2,0x31},
662 {0x3,0x1,0x2,0x1,0x3,0x3,0x1,0x2,0x21,0x3},
663 {0x5,0x23,0x1,0x32,0x1,0x1,0x2,0x1,0x3,0x5},
664 {0x4,0x35,0x3,0x1,0x2,0x22,0x31,0x3,0x5,0x4}
666 { /* level 32 Sweedish Flag by Seth Opgenorth */
667 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
668 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
669 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
670 {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36},
671 {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36},
672 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
673 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
674 {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3}
676 { /* level 33 Color Pyramid by Seth Opgenorth */
677 {0x0,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x0},
678 {0x0,0x0,0x0,0x4,0x24,0x4,0x24,0x0,0x0,0x0},
679 {0x0,0x0,0x23,0x3,0x3,0x3,0x23,0x3,0x0,0x0},
680 {0x0,0x0,0x25,0x5,0x25,0x35,0x5,0x35,0x0,0x0},
681 {0x0,0x36,0x6,0x6,0x6,0x6,0x26,0x6,0x6,0x0},
682 {0x0,0x7,0x7,0x7,0x7,0x25,0x27,0x7,0x27,0x0},
683 {0x2,0x2,0x22,0x2,0x2,0x2,0x22,0x2,0x2,0x2},
684 {0x21,0x1,0x1,0x31,0x1,0x21,0x1,0x1,0x31,0x1}
686 { /* level 34 Rhombus by Seth Opgenorth */
687 {0x0,0x0,0x0,0x0,0x3,0x33,0x0,0x0,0x0,0x0},
688 {0x0,0x0,0x0,0x3,0x32,0x22,0x23,0x0,0x0,0x0},
689 {0x0,0x0,0x3,0x2,0x24,0x4,0x2,0x23,0x0,0x0},
690 {0x26,0x3,0x2,0x4,0x5,0x5,0x4,0x22,0x3,0x6},
691 {0x36,0x3,0x2,0x34,0x5,0x5,0x4,0x2,0x3,0x36},
692 {0x0,0x0,0x3,0x2,0x4,0x34,0x2,0x23,0x0,0x0},
693 {0x0,0x0,0x0,0x23,0x2,0x2,0x3,0x0,0x0,0x0},
694 {0x0,0x0,0x0,0x0,0x3,0x33,0x0,0x0,0x0,0x0}
696 { /* level 35 PacMan Ghost by Seth Opgenorth */
697 {0x0,0x0,0x0,0x0,0x2,0x32,0x2,0x0,0x0,0x0},
698 {0x0,0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x0,0x0},
699 {0x0,0x0,0x2,0x24,0x4,0x2,0x4,0x4,0x32,0x0},
700 {0x0,0x0,0x2,0x24,0x0,0x22,0x24,0x0,0x22,0x0},
701 {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
702 {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
703 {0x0,0x0,0x2,0x32,0x2,0x2,0x22,0x2,0x32,0x0},
704 {0x0,0x0,0x0,0x22,0x0,0x32,0x0,0x22,0x0,0x0}
706 { /* level 36 Star by Seth Opgenorth */
707 {0x3,0x4,0x3,0x4,0x6,0x24,0x3,0x24,0x3,0x0},
708 {0x24,0x0,0x0,0x6,0x6,0x6,0x0,0x0,0x4,0x0},
709 {0x3,0x26,0x6,0x2,0x6,0x2,0x6,0x26,0x23,0x0},
710 {0x4,0x0,0x6,0x6,0x36,0x6,0x6,0x0,0x4,0x0},
711 {0x3,0x0,0x0,0x26,0x6,0x26,0x0,0x0,0x33,0x0},
712 {0x34,0x0,0x6,0x6,0x0,0x6,0x6,0x0,0x4,0x0},
713 {0x3,0x26,0x6,0x0,0x0,0x0,0x6,0x6,0x3,0x0},
714 {0x4,0x3,0x4,0x23,0x24,0x3,0x4,0x33,0x4,0x0}
716 { /* level 37 It's 8-Bit by Seth Opgenorth */
717 {0x26,0x26,0x6,0x6,0x5,0x6,0x26,0x6,0x26,0x6},
718 {0x2,0x2,0x22,0x3,0x3,0x0,0x0,0x0,0x4,0x0},
719 {0x2,0x0,0x2,0x33,0x3,0x3,0x5,0x0,0x24,0x0},
720 {0x32,0x2,0x2,0x33,0x0,0x23,0x0,0x4,0x4,0x4},
721 {0x2,0x22,0x2,0x3,0x3,0x0,0x5,0x4,0x4,0x24},
722 {0x2,0x0,0x2,0x23,0x0,0x3,0x25,0x0,0x4,0x0},
723 {0x22,0x2,0x2,0x3,0x23,0x0,0x5,0x0,0x4,0x0},
724 {0x6,0x26,0x6,0x36,0x6,0x36,0x6,0x6,0x6,0x6}
726 { /* level 38 Linux by Seth Opgenorth */
727 {0x27,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
728 {0x7,0x0,0x0,0x0,0x33,0x0,0x23,0x0,0x0,0x0},
729 {0x7,0x32,0x0,0x0,0x3,0x0,0x23,0x6,0x0,0x6},
730 {0x37,0x0,0x0,0x0,0x23,0x0,0x3,0x6,0x0,0x26},
731 {0x7,0x22,0x24,0x0,0x3,0x33,0x3,0x0,0x26,0x0},
732 {0x37,0x22,0x24,0x24,0x4,0x0,0x0,0x0,0x26,0x0},
733 {0x7,0x2,0x4,0x0,0x4,0x0,0x0,0x6,0x0,0x26},
734 {0x7,0x27,0x4,0x0,0x34,0x0,0x0,0x6,0x0,0x26}
736 { /* level 39 Colorful Squares by Seth Opgenorth*/
737 {0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0},
738 {0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0},
739 {0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0},
740 {0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0},
741 {0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0},
742 {0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0},
743 {0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0},
744 {0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0}
747 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
748 {0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0},
749 {0x32,0x0,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0},
750 {0x32,0x32,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0},
751 {0x32,0x32,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0},
752 {0x32,0x0,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0},
753 {0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0},
754 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
760 enum difficulty_options
{
766 enum { ST_READY
, ST_START
, ST_PAUSE
} game_state
= ST_READY
;
774 int score
=0,vscore
=0;
775 bool flip_sides
=false;
777 int brick_on_board
=0;
779 int difficulty
= NORMAL
;
783 bool resume_file
= false;
787 int powertop
; /* Stores the powerup Y top pos, it is a fixed point num */
788 int power
; /* What powerup is in the brick? */
789 bool poweruse
; /* Stores whether a powerup is falling or not */
790 bool used
; /* Is the brick still in play? */
792 int hits
; /* How many hits can this brick take? */
799 /* pos_x and y store the current position of the ball */
802 /* Tempx and tempy store an absolute position the ball should be in. If
803 * they are equal to 0, they are not used when positioning the ball.
807 /* x and y store the current speed of the ball */
810 bool glue
; /* Is the ball stuck to the paddle? */
813 balls ball
[MAX_BALLS
];
815 typedef struct sfire
{
816 int top
; /* This stores the fire y position, it is a fixed point num */
817 int x_pos
; /* This stores the fire x position, it is a whole number */
821 #define CONFIG_FILE_NAME "brickmania.cfg"
822 #define SAVE_FILE PLUGIN_GAMES_DIR "/brickmania.save"
823 #define HIGH_SCORE PLUGIN_GAMES_DIR "/brickmania.score"
826 static struct configdata config
[] = {
827 {TYPE_INT
, 0, 1, { .int_p
= &difficulty
}, "difficulty", NULL
},
830 struct highscore highest
[NUM_SCORES
];
846 * This is based off an explanation and expanded math presented by Paul Bourke:
847 * http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
849 * It takes two lines as inputs and returns 1 if they intersect, 0 if they do
850 * not. hitp returns the point where the two lines intersected.
852 * This function expects fixed point inputs with a precision of 3. When a
853 * collision occurs hitp is updated with a fixed point location (precision 3)
854 * where the collision happened. The internal calculations are fixed
855 * point with a 7 bit fractional precision.
857 * If you choose 10 bits of precision a screen size of about 640x480 is the
858 * largest this can go. 7 bits allows for an accurate intersection calculation
859 * with a line length of about 64 and a rougher line lenght of 128 which is
860 * larger than any target currently needs (the pad is the longest line and it
861 * only needs an accuracy of 2^4 at most to figure out which section of the pad
862 * the ball hit). A precision of 7 gives breathing room for larger screens.
863 * Longer line sizes that need accurate intersection points will need more
864 * precision, but will decrease the maximum screen resolution.
868 int check_lines(line
*line1
, line
*line2
, point
*hitp
)
871 * This code is based on the solution of these two input equations:
872 * Pa = P1 + ua (P2-P1)
873 * Pb = P3 + ub (P4-P3)
875 * Where line one is composed of points P1 and P2 and line two is composed
876 * of points P3 and P4.
878 * ua/b is the fractional value you can multiply the x and y legs of the
879 * triangle formed by each line to find a point on the line.
881 * The two equations can be expanded to their x/y components:
882 * Pa.x = p1.x + ua(p2.x - p1.x)
883 * Pa.y = p1.y + ua(p2.y - p1.y)
885 * Pb.x = p3.x + ub(p4.x - p3.x)
886 * Pb.y = p3.y + ub(p4.y - p3.y)
888 * When Pa.x == Pb.x and Pa.y == Pb.y the lines intersect so you can come
889 * up with two equations (one for x and one for y):
891 * p1.x + ua(p2.x - p1.x) = p3.x + ub(p4.x - p3.x)
892 * p1.y + ua(p2.y - p1.y) = p3.y + ub(p4.y - p3.y)
894 * ua and ub can then be individually solved for. This results in the
895 * equations used in the following code.
898 /* Denominator for ua and ub are the same so store this calculation */
899 int d
= FIXED3_MUL((line2
->p2
.y
- line2
->p1
.y
),(line1
->p2
.x
-line1
->p1
.x
))
900 -FIXED3_MUL((line2
->p2
.x
- line2
->p1
.x
),(line1
->p2
.y
-line1
->p1
.y
));
902 /* n_a and n_b are calculated as seperate values for readability */
903 int n_a
= FIXED3_MUL((line2
->p2
.x
- line2
->p1
.x
),(line1
->p1
.y
-line2
->p1
.y
))
904 -FIXED3_MUL((line2
->p2
.y
- line2
->p1
.y
),(line1
->p1
.x
-line2
->p1
.x
));
906 int n_b
= FIXED3_MUL((line1
->p2
.x
- line1
->p1
.x
),(line1
->p1
.y
-line2
->p1
.y
))
907 -FIXED3_MUL((line1
->p2
.y
- line1
->p1
.y
),(line1
->p1
.x
-line2
->p1
.x
));
909 /* Make sure there is not a division by zero - this also indicates that
910 * the lines are parallel.
912 * If n_a and n_b were both equal to zero the lines would be on top of each
913 * other (coincidental). This check is not done because it is not
914 * necessary for this implementation (the parallel check accounts for this).
919 /* Calculate the intermediate fractional point that the lines potentially
922 int ua
= (n_a
<< LINE_PREC
)/d
;
923 int ub
= (n_b
<< LINE_PREC
)/d
;
925 /* The fractional point will be between 0 and 1 inclusive if the lines
926 * intersect. If the fractional calculation is larger than 1 or smaller
927 * than 0 the lines would need to be longer to intersect.
929 if(ua
>=0 && ua
<= (1<<LINE_PREC
) && ub
>= 0 && ub
<= (1<<LINE_PREC
))
931 hitp
->x
= line1
->p1
.x
+ ((ua
* (line1
->p2
.x
- line1
->p1
.x
))>>LINE_PREC
);
932 hitp
->y
= line1
->p1
.y
+ ((ua
* (line1
->p2
.y
- line1
->p1
.y
))>>LINE_PREC
);
938 static void brickmania_init_game(bool new_game
)
942 pad_pos_x
= GAMESCREEN_WIDTH
/2 - PAD_WIDTH
/2;
944 for(i
=0;i
<MAX_BALLS
;i
++)
950 ball
[i
].pos_y
= PAD_POS_Y
- BALL
;
951 ball
[i
].pos_x
= GAMESCREEN_WIDTH
/2 - HALFBALL
;
952 ball
[i
].glue
= false;
956 game_state
= ST_READY
;
958 pad_width
= PAD_WIDTH
;
964 /* add one life per achieved level */
965 if (difficulty
==EASY
&& life
<2) {
972 /* No fire should be active */
979 brick
[bnum
].poweruse
= false;
981 brick
[bnum
].power
=rb
->rand()%25;
982 /* +8 make the game with less powerups */
984 brick
[bnum
].hits
=levels
[level
][i
][j
]>=10?
985 levels
[level
][i
][j
]/16-1:0;
986 brick
[bnum
].hiteffect
=0;
987 brick
[bnum
].powertop
= TOPMARGIN
+ i
*BRICK_HEIGHT
;
988 brick
[bnum
].used
=!(levels
[level
][i
][j
]==0);
989 brick
[bnum
].color
=(levels
[level
][i
][j
]>=10?
990 levels
[level
][i
][j
]%16:
991 levels
[level
][i
][j
])-1;
992 if (levels
[level
][i
][j
]!=0)
999 static void brickmania_loadgame(void)
1005 /* open game file */
1006 fd
= rb
->open(SAVE_FILE
, O_RDONLY
);
1009 /* read in saved game */
1011 if(rb
->read(fd
, &pad_pos_x
, sizeof(pad_pos_x
)) <= 0) break;
1012 if(rb
->read(fd
, &life
, sizeof(life
)) <= 0) break;
1013 if(rb
->read(fd
, &game_state
, sizeof(game_state
)) <= 0) break;
1014 if(rb
->read(fd
, &pad_type
, sizeof(pad_type
)) <= 0) break;
1015 if(rb
->read(fd
, &score
, sizeof(score
)) <= 0) break;
1016 if(rb
->read(fd
, &flip_sides
, sizeof(flip_sides
)) <= 0) break;
1017 if(rb
->read(fd
, &level
, sizeof(level
)) <= 0) break;
1018 if(rb
->read(fd
, &brick_on_board
, sizeof(brick_on_board
)) <= 0) break;
1019 if(rb
->read(fd
, &used_balls
, sizeof(used_balls
)) <= 0) break;
1020 if(rb
->read(fd
, &pad_width
, sizeof(pad_width
)) <= 0) break;
1021 if(rb
->read(fd
, &num_count
, sizeof(num_count
)) <= 0) break;
1022 if(rb
->read(fd
, &brick
, sizeof(brick
)) <= 0) break;
1023 if(rb
->read(fd
, &ball
, sizeof(ball
)) <= 0) break;
1024 if(rb
->read(fd
, &fire
, sizeof(fire
)) <= 0) break;
1035 static void brickmania_savegame(void)
1039 /* write out the game state to the save file */
1040 fd
= rb
->open(SAVE_FILE
, O_WRONLY
|O_CREAT
);
1041 rb
->write(fd
, &pad_pos_x
, sizeof(pad_pos_x
));
1042 rb
->write(fd
, &life
, sizeof(life
));
1043 rb
->write(fd
, &game_state
, sizeof(game_state
));
1044 rb
->write(fd
, &pad_type
, sizeof(pad_type
));
1045 rb
->write(fd
, &score
, sizeof(score
));
1046 rb
->write(fd
, &flip_sides
, sizeof(flip_sides
));
1047 rb
->write(fd
, &level
, sizeof(level
));
1048 rb
->write(fd
, &brick_on_board
, sizeof(brick_on_board
));
1049 rb
->write(fd
, &used_balls
, sizeof(used_balls
));
1050 rb
->write(fd
, &pad_width
, sizeof(pad_width
));
1051 rb
->write(fd
, &num_count
, sizeof(num_count
));
1052 rb
->write(fd
, &brick
, sizeof(brick
));
1053 rb
->write(fd
, &ball
, sizeof(ball
));
1054 rb
->write(fd
, &fire
, sizeof(fire
));
1058 /* brickmania_sleep timer counting the score */
1059 static void brickmania_sleep(int secs
)
1069 count
= *rb
->current_tick
+ HZ
*secs
;
1070 if ( (TIME_AFTER(*rb
->current_tick
, count
)) && (vscore
== score
) )
1079 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
1080 rb
->lcd_getstringsize(s
, &sw
, &w
);
1081 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
1082 rb
->lcd_update_rect(0,0,LCD_WIDTH
,w
+2);
1088 static int brickmania_help(void)
1090 #define WORDS (sizeof help_text / sizeof (char*))
1091 static char *help_text
[] = {
1092 "Brickmania", "", "Aim", "",
1093 "Destroy", "all", "the", "bricks", "by", "bouncing",
1094 "the", "ball", "of", "them", "using", "the", "paddle.", "", "",
1096 "< & >", "Moves", "the", "paddle", "",
1097 #if CONFIG_KEYPAD == ONDIO_PAD
1099 #elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1101 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
1106 "Releases", "the", "ball/Fire!", "",
1107 #if CONFIG_KEYPAD == IAUDIO_M3_PAD
1109 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
1110 (CONFIG_KEYPAD == CREATIVEZVM_PAD)
1112 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
1113 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
1114 (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
1115 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
1117 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
1118 (CONFIG_KEYPAD == IRIVER_H300_PAD) || \
1119 (CONFIG_KEYPAD == ONDIO_PAD) || \
1120 (CONFIG_KEYPAD == RECORDER_PAD) || \
1121 (CONFIG_KEYPAD == ARCHOS_AV300_PAD)
1126 "Returns", "to", "menu", "", "",
1128 "N", "Normal:", "returns", "paddle", "to", "normal", "",
1129 "D", "DIE!:", "loses", "a", "life", "",
1130 "L", "Life:", "gains", "a", "life/power", "up", "",
1131 "F", "Fire:", "allows", "you", "to", "shoot", "bricks", "",
1132 "G", "Glue:", "ball", "sticks", "to", "paddle", "",
1133 "B", "Ball:", "generates", "another", "ball", "",
1134 "FL", "Flip:", "flips", "left / right", "movement", "",
1135 "<->", "or", "<E>:", "enlarges", "the", "paddle", "",
1136 ">-<", "or", ">S<:", "shrinks", "the", "paddle", "",
1138 static struct style_text formation
[]={
1139 { 0, TEXT_CENTER
|TEXT_UNDERLINE
},
1154 rb
->lcd_setfont(FONT_UI
);
1155 #ifdef HAVE_LCD_COLOR
1156 rb
->lcd_set_background(LCD_BLACK
);
1157 rb
->lcd_set_foreground(LCD_WHITE
);
1160 if (display_text(WORDS
, help_text
, formation
, NULL
))
1163 button
= rb
->button_get(true);
1164 if (rb
->default_event_handler(button
) == SYS_USB_CONNECTED
) {
1167 } while( ( button
== BUTTON_NONE
)
1168 || ( button
& (BUTTON_REL
|BUTTON_REPEAT
) ) );
1169 rb
->lcd_setfont(FONT_SYSFIXED
);
1173 static int brickmania_menu_cb(int action
, const struct menu_item_ex
*this_item
)
1175 int i
= ((intptr_t)this_item
);
1176 if(action
== ACTION_REQUEST_MENUITEM
1177 && !resume
&& (i
==0 || i
==6))
1178 return ACTION_EXIT_MENUITEM
;
1182 static int brickmania_menu(void)
1186 static struct opt_items options
[] = {
1191 #ifdef HAVE_TOUCHSCREEN
1192 /* Entering Menu, set the touchscreen to the global setting */
1193 rb
->touchscreen_set_mode(rb
->global_settings
->touch_mode
);
1196 MENUITEM_STRINGLIST(main_menu
, "Brickmania Menu", brickmania_menu_cb
,
1197 "Resume Game", "Start New Game",
1198 "Difficulty", "Help", "High Scores",
1200 "Quit without Saving", "Quit");
1202 rb
->button_clear_queue();
1204 switch (rb
->do_menu(&main_menu
, &selected
, NULL
, false)) {
1206 if(game_state
!=ST_READY
)
1207 game_state
= ST_PAUSE
;
1209 rb
->remove(SAVE_FILE
);
1216 brickmania_init_game(true);
1219 rb
->set_option("Difficulty", &difficulty
, INT
,
1223 if (brickmania_help())
1227 highscore_show(NUM_SCORES
, highest
, NUM_SCORES
, true);
1230 if (playback_control(NULL
))
1237 rb
->splash(HZ
*1, "Saving game ...");
1238 brickmania_savegame();
1241 case MENU_ATTACHED_USB
:
1247 #ifdef HAVE_TOUCHSCREEN
1248 rb
->touchscreen_set_mode(TOUCHSCREEN_POINT
);
1252 /* Find an unused fire position */
1253 static int brickmania_find_empty_fire(void)
1257 if (fire
[t
].top
< 0)
1263 void brick_hit(int brick_number
)
1265 if(!brick
[brick_number
].used
)
1268 /* if this is a crackable brick hits starts as
1271 if (brick
[brick_number
].hits
> 0) {
1272 brick
[brick_number
].hits
--;
1273 brick
[brick_number
].hiteffect
++;
1277 brick
[brick_number
].used
=false;
1278 /* Was there a powerup on the brick? */
1279 if (brick
[brick_number
].power
<NUMBER_OF_POWERUPS
) {
1280 /* Activate the powerup */
1281 brick
[brick_number
].poweruse
= true;
1288 static int brickmania_game_loop(void)
1296 /* pad_line used for powerup/ball checks */
1298 /* This is used for various lines that are checked (ball and powerup) */
1301 /* This stores the point that the two lines intersected in a test */
1304 if (brickmania_menu()) {
1308 resume_file
= false;
1310 #ifdef HAVE_LCD_COLOR
1311 rb
->lcd_set_background(LCD_BLACK
);
1312 rb
->lcd_set_foreground(LCD_WHITE
);
1313 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1314 rb
->lcd_clear_display();
1318 /* Convert CYCLETIME (in ms) to HZ */
1319 end
= *rb
->current_tick
+ (CYCLETIME
* HZ
) / 1000;
1322 rb
->lcd_clear_display();
1326 if (TIME_AFTER(*rb
->current_tick
, sec_count
))
1328 sec_count
=*rb
->current_tick
+HZ
;
1334 rb
->snprintf(s
, sizeof(s
), "%d", num_count
);
1335 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1336 rb
->lcd_putsxy(LCD_WIDTH
/2-2, INT3(STRINGPOS_FLIP
), s
);
1339 /* write life num */
1340 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1341 rb
->snprintf(s
, sizeof(s
), "L:%d", life
);
1343 rb
->snprintf(s
, sizeof(s
), "Life: %d", life
);
1345 rb
->lcd_putsxy(0, 0, s
);
1347 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1348 rb
->snprintf(s
, sizeof(s
), "L%d", level
+1);
1350 rb
->snprintf(s
, sizeof(s
), "Level %d", level
+1);
1353 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1354 rb
->lcd_putsxy(LCD_WIDTH
-sw
, 0, s
);
1356 if (vscore
<score
) vscore
++;
1357 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
1358 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1359 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
1362 if (game_state
== ST_PAUSE
)
1364 rb
->snprintf(s
, sizeof(s
), CONTINUE_TEXT
);
1365 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1366 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_NAVI
), s
);
1368 sec_count
=*rb
->current_tick
+HZ
;
1372 for(i
=0;i
<used_balls
;i
++)
1373 rb
->lcd_bitmap(brickmania_ball
, INT3(ball
[i
].pos_x
),
1374 INT3(ball
[i
].pos_y
), INT3(BALL
), INT3(BALL
));
1376 if (brick_on_board
==0)
1379 /* if the pad is fire */
1382 /* If the projectile is active (>0 inactive) */
1383 if (fire
[i
].top
>= 0)
1385 if (game_state
!=ST_PAUSE
)
1386 fire
[i
].top
-= SPEED_FIRE
;
1387 /* Draw the projectile */
1388 rb
->lcd_vline( INT3(fire
[i
].x_pos
), INT3(fire
[i
].top
),
1389 INT3(fire
[i
].top
+ FIRE_LENGTH
));
1393 /* Setup the pad line-later used in intersection test */
1394 pad_line
.p1
.x
= pad_pos_x
;
1395 pad_line
.p1
.y
= PAD_POS_Y
;
1397 pad_line
.p2
.x
= pad_pos_x
+ pad_width
;
1398 pad_line
.p2
.y
= PAD_POS_Y
;
1400 /* handle all of the bricks */
1401 for (i
=0; i
<=7; i
++)
1403 for (j
=0; j
<=9 ;j
++)
1408 /* This brick is not really a brick, it is a powerup if
1409 * poweruse is set. Perform appropriate powerup checks.
1411 if(brick
[bnum
].poweruse
)
1413 brickx
= LEFTMARGIN
+ j
*BRICK_WIDTH
+
1414 (BRICK_WIDTH
- POWERUP_WIDTH
) / 2;
1416 /* Update powertop if the game is not paused */
1417 if (game_state
!=ST_PAUSE
)
1418 brick
[bnum
].powertop
+=SPEED_POWER
;
1420 /* Draw the powerup */
1421 rb
->lcd_bitmap_part(brickmania_powerups
,0,
1422 INT3(POWERUP_HEIGHT
)*brick
[bnum
].power
,
1423 STRIDE( SCREEN_MAIN
,
1424 BMPWIDTH_brickmania_powerups
,
1425 BMPHEIGHT_brickmania_powerups
),
1427 INT3(brick
[bnum
].powertop
),
1428 INT3(POWERUP_WIDTH
),
1429 INT3(POWERUP_HEIGHT
) );
1431 /* Use misc_line to check if the center of the powerup
1434 misc_line
.p1
.x
= brickx
+ (POWERUP_WIDTH
>> 1);
1435 misc_line
.p1
.y
= brick
[bnum
].powertop
+ POWERUP_HEIGHT
;
1437 misc_line
.p2
.x
= brickx
+ (POWERUP_WIDTH
>> 1);
1438 misc_line
.p2
.y
= SPEED_POWER
+ brick
[bnum
].powertop
+
1441 /* Check if the powerup will hit the paddle */
1442 if ( check_lines(&misc_line
, &pad_line
, &pt_hit
) )
1444 switch(brick
[bnum
].power
) {
1445 case 0: /* Extra Life */
1449 case 1: /* Loose a life */
1453 brickmania_init_game(false);
1454 brickmania_sleep(2);
1457 case 2: /* Make the paddle sticky */
1461 case 3: /* Give the paddle shooter */
1464 for(k
=0;k
<used_balls
;k
++)
1467 case 4: /* Normal brick */
1470 for(k
=0;k
<used_balls
;k
++)
1474 pad_pos_x
+= (pad_width
-PAD_WIDTH
)/2;
1475 pad_width
= PAD_WIDTH
;
1477 case 5: /* Flip the paddle */
1479 sec_count
= *rb
->current_tick
+HZ
;
1483 case 6: /* Extra Ball */
1485 if(used_balls
<MAX_BALLS
)
1488 if(rb
->rand()%2 == 0)
1489 ball
[used_balls
].speedx
=-SPEED_4Q_X
;
1491 ball
[used_balls
].speedx
= SPEED_4Q_X
;
1493 ball
[used_balls
].speedy
= SPEED_4Q_Y
;
1495 /* Ball is not glued */
1496 ball
[used_balls
].glue
= false;
1500 case 7: /* Long paddle */
1502 if (pad_width
==PAD_WIDTH
)
1504 pad_width
= LONG_PAD_WIDTH
;
1505 pad_pos_x
-= (LONG_PAD_WIDTH
-
1508 else if (pad_width
==SHORT_PAD_WIDTH
)
1510 pad_width
= PAD_WIDTH
;
1511 pad_pos_x
-=(PAD_WIDTH
-
1517 else if(pad_pos_x
+ pad_width
>
1519 pad_pos_x
= GAMESCREEN_WIDTH
-pad_width
;
1521 case 8: /* Short Paddle */
1522 if (pad_width
==PAD_WIDTH
)
1524 pad_width
=SHORT_PAD_WIDTH
;
1525 pad_pos_x
+=(PAD_WIDTH
-
1528 else if (pad_width
==LONG_PAD_WIDTH
)
1530 pad_width
=PAD_WIDTH
;
1531 pad_pos_x
+=(LONG_PAD_WIDTH
-PAD_WIDTH
)/2;
1535 /* Disable the powerup (it was picked up) */
1536 brick
[bnum
].poweruse
= false;
1539 if (brick
[bnum
].powertop
>PAD_POS_Y
)
1541 /* Disable the powerup (it was missed) */
1542 brick
[bnum
].poweruse
= false;
1545 /* The brick is a brick, but it may or may not be in use */
1546 else if(brick
[bnum
].used
)
1548 /* these lines are used to describe the brick */
1549 line bot_brick
, top_brick
, left_brick
, rght_brick
;
1550 brickx
= LEFTMARGIN
+ j
*BRICK_WIDTH
;
1552 /* Describe the brick for later collision checks */
1553 /* Setup the bottom of the brick */
1554 bot_brick
.p1
.x
= brickx
;
1555 bot_brick
.p1
.y
= brick
[bnum
].powertop
+ BRICK_HEIGHT
;
1557 bot_brick
.p2
.x
= brickx
+ BRICK_WIDTH
;
1558 bot_brick
.p2
.y
= brick
[bnum
].powertop
+ BRICK_HEIGHT
;
1560 /* Setup the top of the brick */
1561 top_brick
.p1
.x
= brickx
;
1562 top_brick
.p1
.y
= brick
[bnum
].powertop
;
1564 top_brick
.p2
.x
= brickx
+ BRICK_WIDTH
;
1565 top_brick
.p2
.y
= brick
[bnum
].powertop
;
1567 /* Setup the left of the brick */
1568 left_brick
.p1
.x
= brickx
;
1569 left_brick
.p1
.y
= brick
[bnum
].powertop
;
1571 left_brick
.p2
.x
= brickx
;
1572 left_brick
.p2
.y
= brick
[bnum
].powertop
+ BRICK_HEIGHT
;
1574 /* Setup the right of the brick */
1575 rght_brick
.p1
.x
= brickx
+ BRICK_WIDTH
;
1576 rght_brick
.p1
.y
= brick
[bnum
].powertop
;
1578 rght_brick
.p2
.x
= brickx
+ BRICK_WIDTH
;
1579 rght_brick
.p2
.y
= brick
[bnum
].powertop
+ BRICK_HEIGHT
;
1581 /* Check if any of the active fires hit a brick */
1582 if (pad_type
== SHOOTER
)
1586 /* Use misc_line to check if fire hit brick */
1587 misc_line
.p1
.x
= fire
[k
].x_pos
;
1588 misc_line
.p1
.y
= fire
[k
].top
;
1590 misc_line
.p2
.x
= fire
[k
].x_pos
;
1591 misc_line
.p2
.y
= fire
[k
].top
+ SPEED_FIRE
;
1593 /* If the fire hit the brick take care of it */
1594 if (fire
[k
].top
> 0 &&
1595 check_lines(&misc_line
, &bot_brick
,
1599 /* De-activate the fire */
1606 /* Draw the brick */
1607 rb
->lcd_bitmap_part(brickmania_bricks
,0,
1608 INT3(BRICK_HEIGHT
)*brick
[bnum
].color
,
1609 STRIDE( SCREEN_MAIN
,
1610 BMPWIDTH_brickmania_bricks
,
1611 BMPHEIGHT_brickmania_bricks
),
1613 INT3(brick
[bnum
].powertop
),
1614 INT3(BRICK_WIDTH
), INT3(BRICK_HEIGHT
) );
1616 #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
1617 if (brick
[bnum
].hiteffect
> 0)
1618 rb
->lcd_bitmap_transparent_part(brickmania_break
,0,
1619 INT3(BRICK_HEIGHT
)*brick
[bnum
].hiteffect
,
1620 STRIDE( SCREEN_MAIN
,
1621 BMPWIDTH_brickmania_break
,
1622 BMPHEIGHT_brickmania_break
),
1624 INT3(brick
[bnum
].powertop
),
1625 INT3(BRICK_WIDTH
), INT3(BRICK_HEIGHT
) );
1628 /* Check if any balls collided with the brick */
1629 for(k
=0; k
<used_balls
; k
++)
1631 /* Setup the ball path to describe the current ball
1632 * position and the line it makes to its next
1635 misc_line
.p1
.x
= ball
[k
].pos_x
+ HALFBALL
;
1636 misc_line
.p1
.y
= ball
[k
].pos_y
+ HALFBALL
;
1638 misc_line
.p2
.x
= ball
[k
].pos_x
+ ball
[k
].speedx
1640 misc_line
.p2
.y
= ball
[k
].pos_y
+ ball
[k
].speedy
1643 /* Check to see if the ball and the bottom hit. If
1644 * the ball is moving down we don't want to
1645 * include the bottom line intersection.
1647 * The order that the sides are checked matters.
1649 * Note that tempx/tempy store the next position
1650 * that the ball should be drawn.
1652 if(ball
[k
].speedy
<= 0 &&
1653 check_lines(&misc_line
, &bot_brick
, &pt_hit
))
1655 ball
[k
].speedy
= -ball
[k
].speedy
;
1656 ball
[k
].tempy
= pt_hit
.y
+ HALFBALL
;
1657 ball
[k
].tempx
= pt_hit
.x
- HALFBALL
;
1660 /* Check the top, if the ball is moving up dont
1661 * count it as a hit.
1663 else if(ball
[k
].speedy
> 0 &&
1664 check_lines(&misc_line
, &top_brick
, &pt_hit
))
1666 ball
[k
].speedy
= -ball
[k
].speedy
;
1667 ball
[k
].tempy
= pt_hit
.y
- HALFBALL
;
1668 ball
[k
].tempx
= pt_hit
.x
- HALFBALL
;
1671 /* Check the left side of the brick */
1673 check_lines(&misc_line
, &left_brick
, &pt_hit
))
1675 ball
[k
].speedx
= -ball
[k
].speedx
;
1676 ball
[k
].tempy
= pt_hit
.y
- HALFBALL
;
1677 ball
[k
].tempx
= pt_hit
.x
- HALFBALL
;
1680 /* Check the right side of the brick */
1682 check_lines(&misc_line
, &rght_brick
, &pt_hit
))
1684 ball
[k
].speedx
= -ball
[k
].speedx
;
1685 ball
[k
].tempy
= pt_hit
.y
- HALFBALL
;
1686 ball
[k
].tempx
= pt_hit
.x
+ HALFBALL
;
1695 /* draw the paddle according to the PAD_WIDTH */
1696 if( pad_width
== PAD_WIDTH
) /* Normal width */
1698 rb
->lcd_bitmap_part(
1700 0, pad_type
*INT3(PAD_HEIGHT
),
1701 STRIDE( SCREEN_MAIN
, BMPWIDTH_brickmania_pads
,
1702 BMPHEIGHT_brickmania_pads
),
1703 INT3(pad_pos_x
), INT3(PAD_POS_Y
),
1704 INT3(pad_width
), INT3(PAD_HEIGHT
) );
1706 else if( pad_width
== LONG_PAD_WIDTH
) /* Long Pad */
1708 rb
->lcd_bitmap_part(
1709 brickmania_long_pads
,
1710 0,pad_type
*INT3(PAD_HEIGHT
),
1711 STRIDE( SCREEN_MAIN
, BMPWIDTH_brickmania_long_pads
,
1712 BMPHEIGHT_brickmania_long_pads
),
1713 INT3(pad_pos_x
), INT3(PAD_POS_Y
),
1714 INT3(pad_width
), INT3(PAD_HEIGHT
) );
1716 else /* Short pad */
1718 rb
->lcd_bitmap_part(
1719 brickmania_short_pads
,
1720 0,pad_type
*INT3(PAD_HEIGHT
),
1721 STRIDE( SCREEN_MAIN
, BMPWIDTH_brickmania_short_pads
,
1722 BMPHEIGHT_brickmania_short_pads
),
1723 INT3(pad_pos_x
), INT3(PAD_POS_Y
),
1724 INT3(pad_width
), INT3(PAD_HEIGHT
) );
1727 /* If the game is not paused continue */
1728 if (game_state
!=ST_PAUSE
)
1730 /* Loop through all of the balls in play */
1731 for(k
=0;k
<used_balls
;k
++)
1733 /* Did the Ball hit the top of the screen? */
1734 if (ball
[k
].pos_y
<= 0)
1736 /* Reverse the direction */
1737 ball
[k
].speedy
= -ball
[k
].speedy
;
1739 /* Player missed the ball and hit bottom of screen */
1740 else if (ball
[k
].pos_y
+HALFBALL
>= GAMESCREEN_HEIGHT
)
1742 /* Player had balls to spare, so handle the removal */
1745 /* decrease number of balls in play */
1747 /* Replace removed ball with the last ball */
1748 ball
[k
].pos_x
= ball
[used_balls
].pos_x
;
1749 ball
[k
].pos_y
= ball
[used_balls
].pos_y
;
1750 ball
[k
].speedy
= ball
[used_balls
].speedy
;
1751 ball
[k
].tempy
= ball
[used_balls
].tempy
;
1752 ball
[k
].speedx
= ball
[used_balls
].speedx
;
1753 ball
[k
].tempx
= ball
[used_balls
].tempx
;
1754 ball
[k
].glue
= ball
[used_balls
].glue
;
1756 /* Reset the last ball that was removed */
1757 ball
[used_balls
].speedx
=0;
1758 ball
[used_balls
].speedy
=0;
1759 ball
[used_balls
].tempy
=0;
1760 ball
[used_balls
].tempx
=0;
1761 ball
[used_balls
].pos_y
=PAD_POS_Y
-BALL
;
1762 ball
[used_balls
].pos_x
=pad_pos_x
+(pad_width
/2)-2;
1769 /* Player lost a life */
1773 /* No lives left reset game */
1774 brickmania_init_game(false);
1775 brickmania_sleep(2);
1776 rb
->button_clear_queue();
1781 /* Check if the ball hit the left or right side */
1782 if ( (ball
[k
].pos_x
< 0) ||
1783 (ball
[k
].pos_x
+BALL
> GAMESCREEN_WIDTH
) )
1785 /* Reverse direction */
1786 ball
[k
].speedx
= -ball
[k
].speedx
;
1787 /* Re-position ball in gameboard */
1788 if(ball
[k
].pos_x
<= 0)
1794 ball
[k
].pos_x
= GAMESCREEN_WIDTH
-BALL
;
1798 /* Setup the ball path to describe the current ball
1799 * position and the line it makes to its next
1801 misc_line
.p1
.x
= ball
[k
].pos_x
+ HALFBALL
;
1802 misc_line
.p1
.y
= ball
[k
].pos_y
+ HALFBALL
;
1804 misc_line
.p2
.x
= ball
[k
].pos_x
+ ball
[k
].speedx
+ HALFBALL
;
1805 misc_line
.p2
.y
= ball
[k
].pos_y
+ ball
[k
].speedy
+ HALFBALL
;
1807 /* Did the ball hit the paddle? Depending on where the ball
1808 * Hit set the x/y speed appropriately.
1810 if( game_state
!=ST_READY
&& !ball
[k
].glue
&&
1811 check_lines(&misc_line
, &pad_line
, &pt_hit
) )
1813 /* Position the ball relative to the paddle width */
1814 int ball_repos
= pt_hit
.x
- pad_pos_x
;
1815 /* If the ball hits the right half of paddle, x speed
1816 * should be positive, if it hits the left half it
1817 * should be negative.
1819 int x_direction
= -1;
1821 /* Comparisons are done with respect to 1/2 pad_width */
1822 if(ball_repos
> pad_width
/2)
1824 /* flip the relative position */
1825 ball_repos
-= ((ball_repos
- pad_width
/2) << 1);
1826 /* Ball hit the right half so X speed calculations
1827 * should be positive.
1832 /* Figure out where the ball hit relative to 1/2 pad
1833 * and in divisions of 4.
1835 ball_repos
= ball_repos
/ (pad_width
/2/4);
1839 /* Ball hit the outer edge of the paddle */
1841 ball
[k
].speedy
= SPEED_1Q_Y
;
1842 ball
[k
].speedx
= SPEED_1Q_X
* x_direction
;
1844 /* Ball hit the next fourth of the paddle */
1846 ball
[k
].speedy
= SPEED_2Q_Y
;
1847 ball
[k
].speedx
= SPEED_2Q_X
* x_direction
;
1849 /* Ball hit the third fourth of the paddle */
1851 ball
[k
].speedy
= SPEED_3Q_Y
;
1852 ball
[k
].speedx
= SPEED_3Q_X
* x_direction
;
1854 /* Ball hit the fourth fourth of the paddle or dead
1859 ball
[k
].speedy
= SPEED_4Q_Y
;
1860 /* Since this is the middle we don't want to
1861 * force the ball in a different direction.
1862 * Just keep it going in the same direction
1863 * with a specific speed.
1865 if(ball
[k
].speedx
> 0)
1867 ball
[k
].speedx
= SPEED_4Q_X
;
1871 ball
[k
].speedx
= -SPEED_4Q_X
;
1876 ball
[k
].speedy
= SPEED_4Q_Y
;
1880 if(pad_type
== STICKY
)
1882 ball
[k
].speedy
= -ball
[k
].speedy
;
1884 ball
[k
].tempy
= pt_hit
.y
- BALL
;
1888 /* Update the ball position */
1892 ball
[k
].pos_x
= ball
[k
].tempx
;
1894 ball
[k
].pos_x
+= ball
[k
].speedx
;
1897 ball
[k
].pos_y
= ball
[k
].tempy
;
1899 ball
[k
].pos_y
+= ball
[k
].speedy
;
1909 if (brick_on_board
< 0)
1911 if (level
+1<levels_num
)
1914 if (difficulty
==NORMAL
)
1916 brickmania_init_game(true);
1917 brickmania_sleep(2);
1918 rb
->button_clear_queue();
1922 rb
->lcd_getstringsize("Congratulations!", &sw
, NULL
);
1923 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_CONGRATS
),
1924 "Congratulations!");
1925 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1926 rb
->lcd_getstringsize("No more levels", &sw
, NULL
);
1927 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_FINISH
),
1930 rb
->lcd_getstringsize("You have finished the game!",
1932 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, INT3(STRINGPOS_FINISH
),
1933 "You have finished the game!");
1937 brickmania_sleep(2);
1942 int button
=rb
->button_get(false);
1943 int move_button
= rb
->button_status();
1945 #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN)
1946 /* FIXME: Should probably check remote hold here */
1947 if (rb
->button_hold())
1951 #ifdef HAVE_TOUCHSCREEN
1952 if( move_button
& BUTTON_TOUCHSCREEN
)
1955 short touch_x
, touch_y
;
1956 rb
->button_status_wdata(&data
);
1957 touch_x
= FIXED3(data
>> 16);
1958 touch_y
= FIXED3(data
& 0xffff);
1962 pad_pos_x
= GAMESCREEN_WIDTH
- (touch_x
+ pad_width
/2);
1966 pad_pos_x
= (touch_x
- pad_width
/2);
1971 else if(pad_pos_x
+ pad_width
> GAMESCREEN_WIDTH
)
1972 pad_pos_x
= GAMESCREEN_WIDTH
-pad_width
;
1973 for(k
=0; k
<used_balls
; k
++)
1974 if (game_state
==ST_READY
|| ball
[k
].glue
)
1975 ball
[k
].pos_x
= pad_pos_x
+ pad_width
/2 - HALFBALL
;
1980 int button_right
, button_left
;
1982 button_right
= move_button
& (RIGHT
| ALTRIGHT
);
1983 button_left
= move_button
& (LEFT
| ALTLEFT
);
1985 button_right
=((move_button
& RIGHT
)|| SCROLL_FWD(move_button
));
1986 button_left
=((move_button
& LEFT
) ||SCROLL_BACK(move_button
));
1988 if ((game_state
==ST_PAUSE
) && (button_right
|| button_left
))
1990 if ((button_right
&& !flip_sides
) ||
1991 (button_left
&& flip_sides
))
1993 if (pad_pos_x
+SPEED_PAD
+pad_width
> GAMESCREEN_WIDTH
)
1995 for(k
=0;k
<used_balls
;k
++)
1996 if (game_state
==ST_READY
|| ball
[k
].glue
)
1997 ball
[k
].pos_x
+= GAMESCREEN_WIDTH
-pad_pos_x
-
1999 pad_pos_x
+= GAMESCREEN_WIDTH
- pad_pos_x
- pad_width
;
2002 for(k
=0;k
<used_balls
;k
++)
2003 if ((game_state
==ST_READY
|| ball
[k
].glue
))
2004 ball
[k
].pos_x
+=SPEED_PAD
;
2005 pad_pos_x
+=SPEED_PAD
;
2008 else if ((button_left
&& !flip_sides
) ||
2009 (button_right
&& flip_sides
))
2011 if (pad_pos_x
-SPEED_PAD
< 0)
2013 for(k
=0;k
<used_balls
;k
++)
2014 if (game_state
==ST_READY
|| ball
[k
].glue
)
2015 ball
[k
].pos_x
-=pad_pos_x
;
2016 pad_pos_x
-= pad_pos_x
;
2020 for(k
=0;k
<used_balls
;k
++)
2021 if (game_state
==ST_READY
|| ball
[k
].glue
)
2022 ball
[k
].pos_x
-=SPEED_PAD
;
2023 pad_pos_x
-=SPEED_PAD
;
2030 #if defined(HAVE_TOUCHSCREEN)
2031 case (BUTTON_REL
| BUTTON_TOUCHSCREEN
):
2035 if (game_state
==ST_READY
)
2037 /* Initialize used balls starting speed */
2038 for(k
=0 ; k
< used_balls
; k
++)
2040 ball
[k
].speedy
= SPEED_4Q_Y
;
2041 if(pad_pos_x
+ (pad_width
/2) >= GAMESCREEN_WIDTH
/2)
2043 ball
[k
].speedx
= SPEED_4Q_X
;
2047 ball
[k
].speedx
= -SPEED_4Q_X
;
2050 game_state
=ST_START
;
2052 else if (game_state
==ST_PAUSE
)
2054 game_state
=ST_START
;
2056 else if (pad_type
== STICKY
)
2058 for(k
=0;k
<used_balls
;k
++)
2063 ball
[k
].speedy
= -ball
[k
].speedy
;
2067 else if (pad_type
== SHOOTER
)
2069 k
=brickmania_find_empty_fire();
2070 fire
[k
].top
=PAD_POS_Y
- FIRE_LENGTH
;
2071 fire
[k
].x_pos
= pad_pos_x
+ 1; /* Add 1 for edge */
2073 k
=brickmania_find_empty_fire();
2074 fire
[k
].top
=PAD_POS_Y
- FIRE_LENGTH
;
2075 fire
[k
].x_pos
= pad_pos_x
+ pad_width
-1; /* Sub1 edge*/
2087 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
2094 #ifdef HAVE_LCD_COLOR
2095 rb
->lcd_bitmap_transparent(brickmania_gameover
,
2096 (LCD_WIDTH
- INT3(GAMEOVER_WIDTH
))/2,
2097 INT3(GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2098 INT3(GAMEOVER_WIDTH
),INT3(GAMEOVER_HEIGHT
));
2099 #else /* greyscale and mono */
2100 rb
->lcd_bitmap(brickmania_gameover
,(LCD_WIDTH
-
2101 INT3(GAMEOVER_WIDTH
))/2,
2102 INT3(GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2103 INT3(GAMEOVER_WIDTH
),INT3(GAMEOVER_HEIGHT
) );
2106 brickmania_sleep(2);
2110 /* Game always needs to yield for other threads */
2113 /* Sleep for a bit if there is time to spare */
2114 if (TIME_BEFORE(*rb
->current_tick
, end
))
2115 rb
->sleep(end
-*rb
->current_tick
);
2120 /* this is the plugin entry point */
2121 enum plugin_status
plugin_start(const void* parameter
)
2124 int last_difficulty
;
2126 highscore_load(HIGH_SCORE
,highest
,NUM_SCORES
);
2127 configfile_load(CONFIG_FILE_NAME
,config
,1,0);
2128 last_difficulty
= difficulty
;
2130 #ifdef HAVE_TOUCHSCREEN
2131 rb
->touchscreen_set_mode(TOUCHSCREEN_POINT
);
2134 rb
->lcd_setfont(FONT_SYSFIXED
);
2136 rb
->lcd_set_backdrop(NULL
);
2138 /* Turn off backlight timeout */
2139 backlight_force_on(); /* backlight control in lib/helper.c */
2141 /* now go ahead and have fun! */
2142 rb
->srand( *rb
->current_tick
);
2143 brickmania_loadgame();
2144 resume_file
= resume
;
2145 while(!brickmania_game_loop())
2149 int position
= highscore_update(score
, level
+1, "", highest
,
2153 rb
->splash(HZ
*2, "New High Score");
2158 highscore_show(position
, highest
, NUM_SCORES
, true);
2162 brickmania_sleep(3);
2167 highscore_save(HIGH_SCORE
,highest
,NUM_SCORES
);
2168 if(last_difficulty
!= difficulty
)
2169 configfile_save(CONFIG_FILE_NAME
,config
,1,0);
2170 /* Restore user's original backlight setting */
2171 rb
->lcd_setfont(FONT_UI
);
2172 /* Turn on backlight timeout (revert to settings) */
2173 backlight_use_settings(); /* backlight control in lib/helper.c */