1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005, 2006 Ben Basha (Paprica)
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #include "lib/configfile.h" /* Part of libplugin */
24 #include "lib/helper.h"
29 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
31 #define QUIT BUTTON_OFF
32 #define LEFT BUTTON_LEFT
33 #define RIGHT BUTTON_RIGHT
34 #define SELECT BUTTON_SELECT
36 #define DOWN BUTTON_DOWN
38 #define RC_QUIT BUTTON_RC_STOP
41 #elif CONFIG_KEYPAD == ONDIO_PAD
43 #define QUIT BUTTON_OFF
44 #define LEFT BUTTON_LEFT
45 #define RIGHT BUTTON_RIGHT
46 #define SELECT BUTTON_MENU
48 #define DOWN BUTTON_DOWN
51 #elif CONFIG_KEYPAD == RECORDER_PAD
53 #define QUIT BUTTON_OFF
54 #define LEFT BUTTON_LEFT
55 #define RIGHT BUTTON_RIGHT
56 #define SELECT BUTTON_PLAY
58 #define DOWN BUTTON_DOWN
61 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
63 #define QUIT BUTTON_OFF
64 #define LEFT BUTTON_LEFT
65 #define RIGHT BUTTON_RIGHT
66 #define SELECT BUTTON_SELECT
68 #define DOWN BUTTON_DOWN
71 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
72 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
73 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
75 #define QUIT BUTTON_MENU
76 #define LEFT BUTTON_LEFT
77 #define RIGHT BUTTON_RIGHT
78 #define SELECT BUTTON_SELECT
79 #define UP BUTTON_SCROLL_BACK
80 #define DOWN BUTTON_SCROLL_FWD
82 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
83 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
86 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
88 #define QUIT BUTTON_POWER
89 #define LEFT BUTTON_LEFT
90 #define RIGHT BUTTON_RIGHT
91 #define SELECT BUTTON_SELECT
93 #define DOWN BUTTON_DOWN
96 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
98 #define QUIT BUTTON_POWER
99 #define LEFT BUTTON_LEFT
100 #define RIGHT BUTTON_RIGHT
101 #define SELECT BUTTON_PLAY
103 #define DOWN BUTTON_DOWN
106 #elif CONFIG_KEYPAD == SANSA_E200_PAD
108 #define QUIT BUTTON_POWER
109 #define LEFT BUTTON_LEFT
110 #define RIGHT BUTTON_RIGHT
111 #define SELECT BUTTON_SELECT
112 #define UP BUTTON_SCROLL_BACK
113 #define DOWN BUTTON_SCROLL_FWD
115 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
116 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
119 #elif CONFIG_KEYPAD == SANSA_C200_PAD
121 #define QUIT BUTTON_POWER
122 #define LEFT BUTTON_LEFT
123 #define RIGHT BUTTON_RIGHT
124 #define ALTLEFT BUTTON_VOL_DOWN
125 #define ALTRIGHT BUTTON_VOL_UP
126 #define SELECT BUTTON_SELECT
128 #define DOWN BUTTON_DOWN
131 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
133 #define QUIT BUTTON_POWER
134 #define LEFT BUTTON_LEFT
135 #define RIGHT BUTTON_RIGHT
136 #define SELECT BUTTON_PLAY
137 #define UP BUTTON_SCROLL_UP
138 #define DOWN BUTTON_SCROLL_DOWN
140 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
142 #define QUIT BUTTON_BACK
143 #define LEFT BUTTON_LEFT
144 #define RIGHT BUTTON_RIGHT
145 #define SELECT BUTTON_SELECT
147 #define DOWN BUTTON_DOWN
149 #elif (CONFIG_KEYPAD == MROBE100_PAD)
151 #define QUIT BUTTON_POWER
152 #define LEFT BUTTON_LEFT
153 #define RIGHT BUTTON_RIGHT
154 #define SELECT BUTTON_SELECT
156 #define DOWN BUTTON_DOWN
158 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
160 #define QUIT BUTTON_RC_REC
161 #define LEFT BUTTON_RC_REW
162 #define RIGHT BUTTON_RC_FF
163 #define SELECT BUTTON_RC_PLAY
164 #define UP BUTTON_RC_VOL_UP
165 #define DOWN BUTTON_RC_VOL_DOWN
167 #define RC_QUIT BUTTON_REC
169 #elif CONFIG_KEYPAD == COWOND2_PAD
170 #define QUIT BUTTON_POWER
173 #error No keymap defined!
176 #ifdef HAVE_TOUCHSCREEN
178 #define LEFT BUTTON_MIDLEFT
181 #define RIGHT BUTTON_MIDRIGHT
184 #define SELECT BUTTON_CENTER
187 #define UP BUTTON_TOPMIDDLE
190 #define DOWN BUTTON_BOTTOMMIDDLE
194 #ifndef SCROLL_FWD /* targets without scroll wheel*/
195 #define SCROLL_FWD(x) (0)
196 #define SCROLL_BACK(x) (0)
200 static const struct plugin_api
* rb
;
214 #include "pluginbitmaps/brickmania_pads.h"
215 #include "pluginbitmaps/brickmania_bricks.h"
216 #include "pluginbitmaps/brickmania_powerups.h"
217 #include "pluginbitmaps/brickmania_ball.h"
218 #include "pluginbitmaps/brickmania_menu_items.h"
219 #include "pluginbitmaps/brickmania_gameover.h"
221 #define PAD_WIDTH BMPWIDTH_brickmania_pads
222 #define PAD_HEIGHT (BMPHEIGHT_brickmania_pads/3)
223 #define BRICK_HEIGHT (BMPHEIGHT_brickmania_bricks/7)
224 #define BRICK_WIDTH BMPWIDTH_brickmania_bricks
225 #define LEFTMARGIN ((LCD_WIDTH-10*BRICK_WIDTH)/2)
226 #define POWERUP_HEIGHT (BMPHEIGHT_brickmania_powerups/7)
227 #define POWERUP_WIDTH BMPWIDTH_brickmania_powerups
228 #define BALL BMPHEIGHT_brickmania_ball
229 #define HALFBALL ((BALL+1)/2)
230 #define MENU_ITEMXOFS ((LCD_WIDTH - BMPWIDTH_brickmania_menu_items)/2)
231 #define MENU_ITEMHEIGHT (BMPHEIGHT_brickmania_menu_items/9)
232 #define MENU_ITEMWIDTH BMPWIDTH_brickmania_menu_items
233 #define GAMEOVER_WIDTH BMPWIDTH_brickmania_gameover
234 #define GAMEOVER_HEIGHT BMPHEIGHT_brickmania_gameover
236 #if LCD_DEPTH > 1 /* currently no background bmp for mono screens */
237 #include "pluginbitmaps/brickmania_menu_bg.h"
238 #define MENU_BGHEIGHT BMPHEIGHT_brickmania_menu_bg
239 #define MENU_BGWIDTH BMPWIDTH_brickmania_menu_bg
242 #ifdef HAVE_LCD_COLOR /* currently no transparency for non-colour */
243 #include "pluginbitmaps/brickmania_break.h"
246 #if (LCD_WIDTH == 320) && (LCD_HEIGHT == 240)
248 /* The time (in ms) for one iteration through the game loop - decrease this
249 to speed up the game - note that current_tick is (currently) only accurate
256 #define BMPYOFS_start 110
257 #define HIGHSCORE_XPOS 57
258 #define HIGHSCORE_YPOS 88
260 #define STRINGPOS_FINISH 140
261 #define STRINGPOS_CONGRATS 157
262 #define STRINGPOS_NAVI 150
263 #define STRINGPOS_FLIP 150
265 #elif (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176)
267 /* The time (in ms) for one iteration through the game loop - decrease this
268 to speed up the game - note that current_tick is (currently) only accurate
273 /* Offsets for LCDS > 220x176 */
275 #define GAMESCREEN_HEIGHT 176
278 #define XOFS ((LCD_WIDTH-220)/BRICK_WIDTH/2)*BRICK_WIDTH
279 #define YOFS ((LCD_HEIGHT-176)/BRICK_HEIGHT/2)*BRICK_HEIGHT
281 #define BMPYOFS_start (78+YOFS)
282 #define HIGHSCORE_XPOS (17+XOFS)
283 #define HIGHSCORE_YPOS (56+YOFS)
285 #define STRINGPOS_FINISH 140
286 #define STRINGPOS_CONGRATS 157
287 #define STRINGPOS_NAVI 150
288 #define STRINGPOS_FLIP 150
290 #elif (LCD_WIDTH == 160) && (LCD_HEIGHT == 128)
291 /* The time (in ms) for one iteration through the game loop - decrease this
292 to speed up the game - note that current_tick is (currently) only accurate
300 #define BMPYOFS_start 58
302 #define BMPYOFS_start 66
304 #define HIGHSCORE_XPOS 10
305 #define HIGHSCORE_YPOS 38
307 #define STRINGPOS_FINISH 110
308 #define STRINGPOS_CONGRATS 100
309 #define STRINGPOS_NAVI 100
310 #define STRINGPOS_FLIP 100
312 #elif (LCD_WIDTH == 132) && (LCD_HEIGHT == 80)
314 /* The time (in ms) for one iteration through the game loop - decrease this
315 to speed up the game - note that current_tick is (currently) only accurate
322 #define BMPYOFS_start 30
323 #define HIGHSCORE_XPOS 68
324 #define HIGHSCORE_YPOS 8
326 #define STRINGPOS_FINISH 55
327 #define STRINGPOS_CONGRATS 45
328 #define STRINGPOS_NAVI 60
329 #define STRINGPOS_FLIP 60
331 #elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 128)
333 /* The time (in ms) for one iteration through the game loop - decrease this
334 to speed up the game - note that current_tick is (currently) only accurate
339 #define GAMESCREEN_HEIGHT 100
342 #define BMPYOFS_start 70
343 #define HIGHSCORE_XPOS 8
344 #define HIGHSCORE_YPOS 36
346 #define STRINGPOS_FINISH 55
347 #define STRINGPOS_CONGRATS 45
348 #define STRINGPOS_NAVI 60
349 #define STRINGPOS_FLIP 60
352 #elif (LCD_WIDTH == 138) && (LCD_HEIGHT == 110)
353 /* The time (in ms) for one iteration through the game loop - decrease this
354 to speed up the game - note that current_tick is (currently) only accurate
361 #define BMPYOFS_start 51
362 #define HIGHSCORE_XPOS 73
363 #define HIGHSCORE_YPOS 25
365 #define STRINGPOS_FINISH 54
366 #define STRINGPOS_CONGRATS 44
367 #define STRINGPOS_NAVI 44
368 #define STRINGPOS_FLIP 44
371 #elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 96)
372 /* The time (in ms) for one iteration through the game loop - decrease this
373 to speed up the game - note that current_tick is (currently) only accurate
380 #define BMPYOFS_start 42
381 #define HIGHSCORE_XPOS 65
382 #define HIGHSCORE_YPOS 25
384 #define STRINGPOS_FINISH 54
385 #define STRINGPOS_CONGRATS 44
386 #define STRINGPOS_NAVI 44
387 #define STRINGPOS_FLIP 44
390 #elif (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
391 /* The time (in ms) for one iteration through the game loop - decrease this
392 to speed up the game - note that current_tick is (currently) only accurate
399 #define BMPYOFS_start 22
400 #define HIGHSCORE_XPOS 0
401 #define HIGHSCORE_YPOS 0
403 #define STRINGPOS_FINISH 54
404 #define STRINGPOS_CONGRATS 44
405 #define STRINGPOS_NAVI 44
406 #define STRINGPOS_FLIP 44
409 #elif (LCD_WIDTH == 176) && (LCD_HEIGHT >= 132) && (LCD_DEPTH==16)
410 /* The time (in ms) for one iteration through the game loop - decrease this
411 to speed up the game - note that current_tick is (currently) only accurate
417 #define GAMESCREEN_HEIGHT 132
420 #define BMPYOFS_start 58
421 #define HIGHSCORE_XPOS 7
422 #define HIGHSCORE_YPOS 36
424 #define STRINGPOS_FINISH 110
425 #define STRINGPOS_CONGRATS 110
426 #define STRINGPOS_NAVI 100
427 #define STRINGPOS_FLIP 100
430 #error Unsupported LCD Size
434 #ifndef GAMESCREEN_HEIGHT
435 #define GAMESCREEN_HEIGHT LCD_HEIGHT
438 /* calculate menu item offsets from the first defined and the height*/
439 #define BMPYOFS_resume (BMPYOFS_start + MENU_ITEMHEIGHT)
440 #define BMPYOFS_help (BMPYOFS_start + 2*MENU_ITEMHEIGHT)
441 #define BMPYOFS_quit (BMPYOFS_start + 3*MENU_ITEMHEIGHT)
443 /*calculate paddle y-position */
444 #if GAMESCREEN_HEIGHT >= 128
445 #define PAD_POS_Y GAMESCREEN_HEIGHT -PAD_HEIGHT - 2
447 #define PAD_POS_Y GAMESCREEN_HEIGHT -PAD_HEIGHT - 1
451 #ifdef HAVE_TOUCHSCREEN
452 #include "lib/touchscreen.h"
454 static struct ts_mapping main_menu_items
[4] =
456 {MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
},
457 {MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
},
458 {MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
},
459 {MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
}
461 static struct ts_mappings main_menu
= {main_menu_items
, 4};
467 static unsigned char levels
[29][8][10] = {
469 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
470 {0x2,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x2},
471 {0x0,0x2,0x1,0x0,0x0,0x0,0x0,0x1,0x2,0x0},
472 {0x0,0x0,0x2,0x1,0x0,0x0,0x1,0x2,0x0,0x0},
473 {0x0,0x0,0x0,0x2,0x1,0x1,0x2,0x0,0x0,0x0},
474 {0x7,0x0,0x0,0x7,0x2,0x2,0x7,0x0,0x0,0x7},
475 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
476 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
479 {0x0,0x0,0x7,0x7,0x1,0x1,0x7,0x7,0x0,0x0},
480 {0x0,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x0},
481 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
482 {0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1},
483 {0x1,0x1,0x2,0x1,0x0,0x0,0x1,0x2,0x1,0x1},
484 {0x1,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x2,0x1},
485 {0x0,0x1,0x2,0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
658 { /* level 20 (Maze) by ts-x */
659 {0x1,0x1,0x21,0x1,0x1,0x1,0x1,0x1,0x1,0x21},
660 {0x1,0x0,0x0,0x3,0x0,0x0,0x3,0x1,0x31,0x1},
661 {0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x0,0x1},
662 {0x21,0x0,0x21,0x3,0x0,0x3,0x0,0x3,0x0,0x2},
663 {0x1,0x0,0x1,0x21,0x0,0x12,0x0,0x0,0x0,0x0},
664 {0x31,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x3,0x0},
665 {0x1,0x0,0x1,0x0,0x1,0x1,0x31,0x1,0x1,0x2},
666 {0x22,0x0,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x21}
668 { /* level 21 (Dentist) by ts-x */
669 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
670 {0x2,0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x2,0x2},
671 {0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x2},
672 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x2},
673 {0x2,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x0,0x2},
674 {0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x2},
675 {0x2,0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x2,0x2},
676 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0}
678 { /* level 22 (Spider) by ts-x */
679 {0x31,0x3,0x1,0x1,0x0,0x0,0x1,0x1,0x3,0x31},
680 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
681 {0x33,0x1,0x1,0x36,0x1,0x1,0x36,0x1,0x1,0x33},
682 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
683 {0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x0,0x0},
684 {0x21,0x3,0x1,0x21,0x2,0x2,0x21,0x1,0x3,0x21},
685 {0x0,0x0,0x0,0x1,0x21,0x1,0x1,0x0,0x0,0x0},
686 {0x3,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x3}
688 { /* level 23 (Pool) by ts-x */
689 {0x0,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x7,0x0},
690 {0x0,0x0,0x5,0x0,0x2,0x0,0x0,0x0,0x2,0x0},
691 {0x7,0x3,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x7},
692 {0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x5,0x0,0x7},
693 {0x7,0x0,0x4,0x0,0x0,0x3,0x0,0x0,0x0,0x7},
694 {0x7,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x4,0x7},
695 {0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
696 {0x0,0x7,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x0}
698 { /* level 24 (Vorbis Fish) by ts-x */
699 {0x0,0x0,0x4,0x4,0x5,0x5,0x5,0x0,0x0,0x5},
700 {0x0,0x4,0x6,0x4,0x4,0x5,0x5,0x5,0x0,0x5},
701 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x5,0x5,0x5},
702 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x4,0x5,0x5},
703 {0x0,0x5,0x6,0x4,0x4,0x5,0x5,0x4,0x5,0x0},
704 {0x5,0x5,0x4,0x4,0x5,0x5,0x5,0x4,0x5,0x5},
705 {0x5,0x4,0x4,0x4,0x5,0x5,0x4,0x4,0x5,0x5},
706 {0x0,0x0,0x4,0x4,0x4,0x4,0x4,0x5,0x0,0x5}
708 {/* level 25 (Rainbow) by ts-x */
709 {0x0,0x4,0x1,0x0,0x0,0x0,0x0,0x1,0x4,0x0},
710 {0x24,0x1,0x3,0x1,0x0,0x0,0x21,0x3,0x1,0x24},
711 {0x1,0x23,0x5,0x3,0x1,0x21,0x3,0x5,0x3,0x21},
712 {0x3,0x5,0x6,0x5,0x3,0x3,0x5,0x6,0x5,0x3},
713 {0x5,0x6,0x7,0x6,0x5,0x5,0x6,0x7,0x6,0x5},
714 {0x6,0x7,0x2,0x27,0x6,0x6,0x27,0x2,0x7,0x6},
715 {0x7,0x2,0x0,0x2,0x27,0x27,0x2,0x0,0x2,0x7},
716 {0x32,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x32}
718 { /* level 26 (Bowtie) by ts-x */
719 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5},
720 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
721 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
722 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
723 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
724 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
725 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
726 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5}
728 { /* level 27 (Frog) by ts-x */
729 {0x0,0x5,0x25,0x0,0x0,0x0,0x0,0x25,0x5,0x0},
730 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
731 {0x25,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x25},
732 {0x5,0x0,0x3,0x0,0x6,0x6,0x0,0x3,0x0,0x5},
733 {0x5,0x0,0x31,0x0,0x6,0x6,0x0,0x31,0x0,0x5},
734 {0x5,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x5},
735 {0x5,0x5,0x5,0x35,0x0,0x0,0x35,0x5,0x5,0x5},
736 {0x0,0x25,0x5,0x0,0x4,0x4,0x0,0x5,0x25,0x0}
738 { /* level 28 (DigDug) by ts-x */
739 {0x35,0x5,0x5,0x25,0x0,0x25,0x25,0x5,0x5,0x35},
740 {0x6,0x0,0x0,0x6,0x0,0x6,0x6,0x0,0x0,0x6},
741 {0x7,0x0,0x37,0x37,0x0,0x37,0x37,0x7,0x0,0x7},
742 {0x7,0x0,0x7,0x0,0x0,0x0,0x7,0x7,0x7,0x7},
743 {0x4,0x4,0x4,0x24,0x0,0x24,0x4,0x0,0x0,0x4},
744 {0x4,0x4,0x0,0x0,0x0,0x4,0x4,0x0,0x4,0x4},
745 {0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4},
746 {0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1}
749 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
750 {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0},
751 {0x22,0x0,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0},
752 {0x22,0x22,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0},
753 {0x22,0x22,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0},
754 {0x22,0x0,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0},
755 {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0},
756 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
762 int x
[MAX_BALLS
],y
[MAX_BALLS
];
764 int start_game
,con_game
;
766 int score
=0,vscore
=0;
767 bool flip_sides
=false;
769 int brick_on_board
=0;
772 typedef struct cube
{
783 typedef struct balls
{
793 balls ball
[MAX_BALLS
];
795 typedef struct sfire
{
803 #define MAX_POINTS 200000 /* i dont think it needs to be more */
804 static struct configdata config
[] =
806 {TYPE_INT
, 0, MAX_POINTS
, &highscore
, "highscore", NULL
, NULL
}
809 void int_game(int new_game
)
813 pad_pos_x
=LCD_WIDTH
/2-PAD_WIDTH
/2;
815 for(i
=0;i
<MAX_BALLS
;i
++) {
820 ball
[i
].pos_y
=PAD_POS_Y
-BALL
;
821 ball
[i
].pos_x
=pad_pos_x
+(PAD_WIDTH
/2)-2;
837 brick
[i
*10+j
].poweruse
=(levels
[cur_level
][i
][j
]==0?0:1);
841 brick
[i
*10+j
].power
=rb
->rand()%25;
842 /* +8 make the game with less powerups */
844 brick
[i
*10+j
].hits
=levels
[cur_level
][i
][j
]>=10?
845 levels
[cur_level
][i
][j
]/16-1:0;
846 brick
[i
*10+j
].hiteffect
=0;
847 brick
[i
*10+j
].powertop
=TOPMARGIN
+i
*BRICK_HEIGHT
+BRICK_HEIGHT
;
848 brick
[i
*10+j
].used
=(levels
[cur_level
][i
][j
]==0?0:1);
849 brick
[i
*10+j
].color
=(levels
[cur_level
][i
][j
]>=10?
850 levels
[cur_level
][i
][j
]%16:
851 levels
[cur_level
][i
][j
])-1;
852 if (levels
[cur_level
][i
][j
]!=0)
861 /* sleep timer counting the score */
862 void sleep (int secs
)
872 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
873 rb
->lcd_getstringsize(s
, &sw
, &w
);
874 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
875 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
877 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 2, s
);
879 rb
->lcd_update_rect(0,0,LCD_WIDTH
,w
+2);
882 count
=*rb
->current_tick
+HZ
*secs
;
883 if (*rb
->current_tick
>=count
)
891 #define HIGH_SCORE "brickmania.score"
892 #define MENU_LENGTH 4
893 int game_menu(int when
)
897 rb
->lcd_clear_display();
898 #if LCD_DEPTH > 1 /* currently no background bmp for mono screens */
899 rb
->lcd_bitmap(brickmania_menu_bg
, 0, 0, MENU_BGWIDTH
, MENU_BGHEIGHT
);
902 for(i
=0;i
<MENU_LENGTH
;i
++) {
903 #ifdef HAVE_LCD_COLOR
905 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
906 MENU_ITEMHEIGHT
* BM_SEL_START
, MENU_ITEMWIDTH
,
907 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
910 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
911 MENU_ITEMHEIGHT
* BM_START
, MENU_ITEMWIDTH
,
912 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
917 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
918 MENU_ITEMHEIGHT
* BM_SEL_RESUME
, MENU_ITEMWIDTH
,
919 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
922 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
923 MENU_ITEMHEIGHT
* BM_RESUME
, MENU_ITEMWIDTH
,
924 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
928 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
929 MENU_ITEMHEIGHT
* BM_NO_RESUME
, MENU_ITEMWIDTH
,
930 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
936 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
937 MENU_ITEMHEIGHT
* BM_SEL_HELP
, MENU_ITEMWIDTH
,
938 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
941 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
942 MENU_ITEMHEIGHT
* BM_HELP
, MENU_ITEMWIDTH
,
943 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
947 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
948 MENU_ITEMHEIGHT
* BM_SEL_QUIT
, MENU_ITEMWIDTH
,
949 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
952 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
953 MENU_ITEMHEIGHT
* BM_QUIT
, MENU_ITEMWIDTH
,
954 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
958 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
959 MENU_ITEMHEIGHT
* BM_SEL_START
, MENU_ITEMWIDTH
,
960 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
963 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
964 MENU_ITEMHEIGHT
* BM_START
, MENU_ITEMWIDTH
,
965 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
970 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
971 MENU_ITEMHEIGHT
* BM_SEL_RESUME
, MENU_ITEMWIDTH
,
972 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
975 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
976 MENU_ITEMHEIGHT
* BM_RESUME
, MENU_ITEMWIDTH
,
977 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
981 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
982 MENU_ITEMHEIGHT
* BM_NO_RESUME
, MENU_ITEMWIDTH
,
983 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
989 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
990 MENU_ITEMHEIGHT
* BM_SEL_HELP
, MENU_ITEMWIDTH
,
991 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
994 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
995 MENU_ITEMHEIGHT
* BM_HELP
, MENU_ITEMWIDTH
,
996 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
1000 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1001 MENU_ITEMHEIGHT
* BM_SEL_QUIT
, MENU_ITEMWIDTH
,
1002 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
1005 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1006 MENU_ITEMHEIGHT
* BM_QUIT
, MENU_ITEMWIDTH
,
1007 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
1011 rb
->lcd_set_drawmode(DRMODE_FG
);
1013 #ifdef HAVE_LCD_COLOR
1014 rb
->lcd_set_background(LCD_RGBPACK(0,0,140));
1015 rb
->lcd_set_foreground(LCD_WHITE
);
1017 rb
->lcd_putsxy(HIGHSCORE_XPOS
, HIGHSCORE_YPOS
, "High Score");
1018 rb
->snprintf(str
, sizeof(str
), "%d", highscore
);
1019 rb
->lcd_getstringsize("High Score", &sw
, NULL
);
1020 rb
->lcd_getstringsize(str
, &w
, NULL
);
1021 rb
->lcd_putsxy(HIGHSCORE_XPOS
+sw
/2-w
/2, HIGHSCORE_YPOS
+9, str
);
1022 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1026 button
= rb
->button_get(true);
1027 #ifdef HAVE_TOUCHSCREEN
1028 if(button
& BUTTON_TOUCHSCREEN
)
1030 unsigned int result
= touchscreen_map(&main_menu
, rb
->button_get_data() >> 16, rb
->button_get_data() & 0xffff);
1031 if(result
!= (unsigned)-1 && button
& BUTTON_REL
)
1033 if(cur
== (signed)result
)
1041 case UP
| BUTTON_REPEAT
:
1043 cur
= MENU_LENGTH
-1;
1046 if (when
==0 && cur
==1) {
1052 case DOWN
| BUTTON_REPEAT
:
1053 if (cur
==MENU_LENGTH
-1)
1057 if (when
==0 && cur
==1) {
1068 } else if (cur
==1 && when
==1) {
1070 } else if (cur
==2) {
1072 } else if (cur
==3) {
1084 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
1097 /* set the maximum x and y in the helpscreen
1098 dont forget to update, if you change text */
1103 #ifdef HAVE_LCD_COLOR
1104 rb
->lcd_set_background(LCD_BLACK
);
1105 rb
->lcd_clear_display();
1106 rb
->lcd_set_background(LCD_BLACK
);
1107 rb
->lcd_set_foreground(LCD_WHITE
);
1109 rb
->lcd_clear_display();
1112 rb
->lcd_getstringsize("BrickMania", &w
, &h
);
1113 rb
->lcd_putsxy(LCD_WIDTH
/2-w
/2+xoffset
, 1+yoffset
, "BrickMania");
1115 #ifdef HAVE_LCD_COLOR
1116 rb
->lcd_set_foreground(LCD_RGBPACK(245,0,0));
1117 rb
->lcd_putsxy(1+xoffset
, 1*(h
+2)+yoffset
,"Aim");
1118 rb
->lcd_set_foreground(LCD_WHITE
);
1120 rb
->lcd_putsxy(1+xoffset
, 1*(h
+2)+yoffset
,"Aim");
1122 rb
->lcd_putsxy(1+xoffset
, 2*(h
+2)+yoffset
,
1123 "destroy all the bricks by bouncing");
1124 rb
->lcd_putsxy(1+xoffset
, 3*(h
+2)+yoffset
,
1125 "the ball of them using the paddle.");
1126 #ifdef HAVE_LCD_COLOR
1127 rb
->lcd_set_foreground(LCD_RGBPACK(245,0,0));
1128 rb
->lcd_putsxy(1+xoffset
, 5*(h
+2)+yoffset
,"Controls");
1129 rb
->lcd_set_foreground(LCD_WHITE
);
1131 rb
->lcd_putsxy(1+xoffset
, 5*(h
+2)+yoffset
,"Controls");
1133 rb
->lcd_putsxy(1+xoffset
, 6*(h
+2)+yoffset
,"< & > Move the paddle");
1134 #if CONFIG_KEYPAD == ONDIO_PAD
1135 rb
->lcd_putsxy(1+xoffset
, 7*(h
+2)+yoffset
,
1136 "MENU Releases the ball/Fire!");
1137 #elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1138 rb
->lcd_putsxy(1+xoffset
, 7*(h
+2)+yoffset
,
1139 "PLAY Releases the ball/Fire!");
1140 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
1141 rb
->lcd_putsxy(1+xoffset
, 7*(h
+2)+yoffset
,
1142 "NAVI Releases the ball/Fire!");
1144 rb
->lcd_putsxy(1+xoffset
, 7*(h
+2)+yoffset
,
1145 "SELECT Releases the ball/Fire!");
1147 #if CONFIG_KEYPAD == IAUDIO_M3_PAD
1148 rb
->lcd_putsxy(1+xoffset
, 8*(h
+2)+yoffset
, "REC Opens menu/Quit");
1150 rb
->lcd_putsxy(1+xoffset
, 8*(h
+2)+yoffset
, "STOP Opens menu/Quit");
1152 #ifdef HAVE_LCD_COLOR
1153 rb
->lcd_set_foreground(LCD_RGBPACK(245,0,0));
1154 rb
->lcd_putsxy(1+xoffset
, 10*(h
+2)+yoffset
, "Specials");
1155 rb
->lcd_set_foreground(LCD_WHITE
);
1157 rb
->lcd_putsxy(1+xoffset
, 10*(h
+2)+yoffset
, "Specials");
1159 rb
->lcd_putsxy(1+xoffset
, 11*(h
+2)+yoffset
,
1160 "N Normal:returns paddle to normal");
1161 rb
->lcd_putsxy(1+xoffset
, 12*(h
+2)+yoffset
, "D DIE!:loses a life");
1162 rb
->lcd_putsxy(1+xoffset
, 13*(h
+2)+yoffset
,
1163 "L Life:gains a life/power up");
1164 rb
->lcd_putsxy(1+xoffset
, 14*(h
+2)+yoffset
,
1165 "F Fire:allows you to shoot bricks");
1166 rb
->lcd_putsxy(1+xoffset
, 15*(h
+2)+yoffset
,
1167 "G Glue:ball sticks to paddle");
1168 rb
->lcd_putsxy(1+xoffset
, 16*(h
+2)+yoffset
,
1169 "B Ball:generates another ball");
1170 rb
->lcd_putsxy(1+xoffset
, 17*(h
+2)+yoffset
,
1171 "FL Flip:flips left / right movement");
1174 button
=rb
->button_get(true);
1179 #ifdef HAVE_TOUCHSCREEN
1180 case BUTTON_TOUCHSCREEN
:
1183 switch (game_menu(when
)) {
1203 case LEFT
| BUTTON_REPEAT
:
1206 case ALTLEFT
| BUTTON_REPEAT
:
1212 case RIGHT
| BUTTON_REPEAT
:
1215 case ALTRIGHT
| BUTTON_REPEAT
:
1217 if(xoffset
+maxX
> LCD_WIDTH
)
1221 case UP
| BUTTON_REPEAT
:
1226 case DOWN
| BUTTON_REPEAT
:
1227 if(yoffset
+maxY
> LCD_HEIGHT
)
1232 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
1240 int pad_check(int ballxc
, int mode
, int pon
,int ballnum
)
1242 /* pon: positive(1) or negative(0) */
1250 if (ball
[ballnum
].x
> 0)
1257 int fire_space(void)
1261 if (fire
[t
].top
+7 < 0)
1269 int j
,i
,k
,bricky
,brickx
;
1271 int sec_count
=0,num_count
=10;
1274 rb
->srand( *rb
->current_tick
);
1276 configfile_init(rb
);
1277 configfile_load(HIGH_SCORE
,config
,1,0);
1279 switch(game_menu(0)) {
1289 if (help(0) == 1) return 1;
1297 /* Convert CYCLETIME (in ms) to HZ */
1298 end
= *rb
->current_tick
+ (CYCLETIME
* HZ
) / 1000;
1301 #ifdef HAVE_LCD_COLOR
1302 rb
->lcd_set_background(LCD_BLACK
);
1303 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1304 rb
->lcd_clear_display();
1305 rb
->lcd_set_background(LCD_BLACK
);
1306 #if LCD_HEIGHT > GAMESCREEN_HEIGHT
1307 rb
->lcd_set_foreground(rb
->global_settings
->bg_color
);
1308 rb
->lcd_fillrect(0, GAMESCREEN_HEIGHT
, LCD_WIDTH
,
1309 LCD_HEIGHT
- GAMESCREEN_HEIGHT
);
1311 rb
->lcd_set_foreground(LCD_WHITE
);
1313 rb
->lcd_clear_display();
1317 if (*rb
->current_tick
>=sec_count
) {
1318 sec_count
=*rb
->current_tick
+HZ
;
1324 rb
->snprintf(s
, sizeof(s
), "%d", num_count
);
1325 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1326 rb
->lcd_putsxy(LCD_WIDTH
/2-2, STRINGPOS_FLIP
, s
);
1329 /* write life num */
1330 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1331 rb
->snprintf(s
, sizeof(s
), "L:%d", life
);
1332 rb
->lcd_putsxy(0, 0, s
);
1334 rb
->snprintf(s
, sizeof(s
), "Life: %d", life
);
1335 rb
->lcd_putsxy(2, 2, s
);
1338 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1339 rb
->snprintf(s
, sizeof(s
), "L%d", cur_level
+1);
1340 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1341 rb
->lcd_putsxy(LCD_WIDTH
-sw
, 0, s
);
1343 rb
->snprintf(s
, sizeof(s
), "Level %d", cur_level
+1);
1344 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1345 rb
->lcd_putsxy(LCD_WIDTH
-sw
-2, 2, s
);
1348 if (vscore
<score
) vscore
++;
1349 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
1350 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1351 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1352 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
1354 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 2, s
);
1358 if (con_game
== 1 && start_game
!=1) {
1359 #if CONFIG_KEYPAD == ONDIO_PAD
1360 rb
->snprintf(s
, sizeof(s
), "MENU To Continue");
1361 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
1362 rb
->snprintf(s
, sizeof(s
), "Press NAVI To Continue");
1363 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
1364 rb
->snprintf(s
, sizeof(s
), "PLAY To Continue");
1366 rb
->snprintf(s
, sizeof(s
), "Press SELECT To Continue");
1368 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1369 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_NAVI
, s
);
1371 sec_count
=*rb
->current_tick
+HZ
;
1375 for(i
=0;i
<used_balls
;i
++)
1376 rb
->lcd_bitmap(brickmania_ball
,ball
[i
].pos_x
, ball
[i
].pos_y
,
1379 if (brick_on_board
==0)
1382 /* if the pad is fire */
1383 for(i
=0;i
<=30;i
++) {
1384 if (fire
[i
].top
+7>0) {
1387 rb
->lcd_vline(fire
[i
].left
, fire
[i
].top
, fire
[i
].top
+7);
1392 for (i
=0;i
<=7;i
++) {
1393 for (j
=0;j
<=9;j
++) {
1394 if (brick
[i
*10+j
].power
<7) {
1395 if (brick
[i
*10+j
].poweruse
==2) {
1397 brick
[i
*10+j
].powertop
+=2;
1398 rb
->lcd_bitmap_part(brickmania_powerups
,0,
1399 POWERUP_HEIGHT
*brick
[i
*10+j
1402 LEFTMARGIN
+j
*BRICK_WIDTH
+
1405 brick
[i
*10+j
].powertop
,
1411 if ((pad_pos_x
<LEFTMARGIN
+j
*BRICK_WIDTH
+5 &&
1412 pad_pos_x
+PAD_WIDTH
>LEFTMARGIN
+j
*BRICK_WIDTH
+5) &&
1413 brick
[i
*10+j
].powertop
+6>=PAD_POS_Y
&&
1414 brick
[i
*10+j
].poweruse
==2) {
1415 switch(brick
[i
*10+j
].power
) {
1434 for(k
=0;k
<used_balls
;k
++)
1440 for(k
=0;k
<used_balls
;k
++)
1446 sec_count
=*rb
->current_tick
+HZ
;
1448 flip_sides
=!flip_sides
;
1453 ball
[used_balls
-1].x
= rb
->rand()%1 == 0 ?
1455 ball
[used_balls
-1].y
= -4;
1458 brick
[i
*10+j
].poweruse
=1;
1461 if (brick
[i
*10+j
].powertop
>PAD_POS_Y
)
1462 brick
[i
*10+j
].poweruse
=1;
1464 brickx
=LEFTMARGIN
+j
*BRICK_WIDTH
;
1465 bricky
=TOPMARGIN
+i
*BRICK_HEIGHT
;
1467 for (k
=0;k
<=30;k
++) {
1468 if (fire
[k
].top
+7>0) {
1469 if (brick
[i
*10+j
].used
==1 &&
1470 (fire
[k
].left
+1 >= brickx
&&
1471 fire
[k
].left
+1 <= brickx
+BRICK_WIDTH
) &&
1472 (bricky
+BRICK_HEIGHT
>fire
[k
].top
)) {
1475 if (brick
[i
*10+j
].hits
> 0) {
1476 brick
[i
*10+j
].hits
--;
1477 brick
[i
*10+j
].hiteffect
++;
1481 brick
[i
*10+j
].used
=0;
1482 if (brick
[i
*10+j
].power
!=10)
1483 brick
[i
*10+j
].poweruse
=2;
1491 if (brick
[i
*10+j
].used
==1) {
1492 rb
->lcd_bitmap_part(brickmania_bricks
,0,
1493 BRICK_HEIGHT
*brick
[i
*10+j
].color
,
1495 LEFTMARGIN
+j
*BRICK_WIDTH
,
1496 TOPMARGIN
+i
*BRICK_HEIGHT
,
1497 BRICK_WIDTH
, BRICK_HEIGHT
);
1498 #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
1499 if (brick
[i
*10+j
].hiteffect
>0)
1500 rb
->lcd_bitmap_transparent_part(brickmania_break
,
1502 BRICK_HEIGHT
*brick
[i
*10+j
].hiteffect
,
1504 LEFTMARGIN
+j
*BRICK_WIDTH
,
1505 TOPMARGIN
+i
*BRICK_HEIGHT
,
1511 for(k
=0;k
<used_balls
;k
++) {
1512 if (ball
[k
].pos_y
<160) {
1513 if (brick
[i
*10+j
].used
==1) {
1514 if ((ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
>=
1516 ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
<=
1517 brickx
+BRICK_WIDTH
) &&
1518 ((bricky
-4<ball
[k
].pos_y
+BALL
&&
1519 bricky
>ball
[k
].pos_y
+BALL
) ||
1520 (bricky
+4>ball
[k
].pos_y
+BALL
+BALL
&&
1521 bricky
<ball
[k
].pos_y
+BALL
+BALL
)) &&
1523 ball
[k
].tempy
=bricky
-ball
[k
].pos_y
-BALL
;
1525 else if ((ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
>=
1527 ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
<=
1528 brickx
+BRICK_WIDTH
) &&
1529 ((bricky
+BRICK_HEIGHT
+4>ball
[k
].pos_y
&&
1530 bricky
+BRICK_HEIGHT
<ball
[k
].pos_y
) ||
1531 (bricky
+BRICK_HEIGHT
-4<ball
[k
].pos_y
-BALL
&&
1532 bricky
+BRICK_HEIGHT
>ball
[k
].pos_y
-BALL
)) &&
1535 -(ball
[k
].pos_y
-(bricky
+BRICK_HEIGHT
));
1538 if ((ball
[k
].pos_y
+HALFBALL
>=
1540 ball
[k
].pos_y
+HALFBALL
<=
1541 bricky
+BRICK_HEIGHT
) &&
1542 ((brickx
-4<ball
[k
].pos_x
+BALL
&&
1543 brickx
>ball
[k
].pos_x
+BALL
) ||
1544 (brickx
+4>ball
[k
].pos_x
+BALL
+BALL
&&
1545 brickx
<ball
[k
].pos_x
+BALL
+BALL
)) &&
1547 ball
[k
].tempx
=brickx
-ball
[k
].pos_x
-BALL
;
1549 else if ((ball
[k
].pos_y
+ball
[k
].y
+HALFBALL
>=
1551 ball
[k
].pos_y
+ball
[k
].y
+HALFBALL
<=
1552 bricky
+BRICK_HEIGHT
) &&
1553 ((brickx
+BRICK_WIDTH
+4>ball
[k
].pos_x
&&
1554 brickx
+BRICK_WIDTH
<ball
[k
].pos_x
) ||
1555 (brickx
+BRICK_WIDTH
-4<ball
[k
].pos_x
-
1557 brickx
+BRICK_WIDTH
>ball
[k
].pos_x
-
1558 BALL
)) && (ball
[k
].x
<0)) {
1560 -(ball
[k
].pos_x
-(brickx
+BRICK_WIDTH
));
1563 if ((ball
[k
].pos_x
+HALFBALL
>= brickx
&&
1564 ball
[k
].pos_x
+HALFBALL
<=
1565 brickx
+BRICK_WIDTH
) &&
1566 ((bricky
+BRICK_HEIGHT
==ball
[k
].pos_y
) ||
1567 (bricky
+BRICK_HEIGHT
-6<=ball
[k
].pos_y
&&
1568 bricky
+BRICK_HEIGHT
>ball
[k
].pos_y
)) &&
1569 (ball
[k
].y
<0)) { /* bottom line */
1570 if (brick
[i
*10+j
].hits
> 0) {
1571 brick
[i
*10+j
].hits
--;
1572 brick
[i
*10+j
].hiteffect
++;
1576 brick
[i
*10+j
].used
=0;
1577 if (brick
[i
*10+j
].power
!=10)
1578 brick
[i
*10+j
].poweruse
=2;
1581 ball
[k
].y
= ball
[k
].y
*-1;
1583 else if ((ball
[k
].pos_x
+HALFBALL
>= brickx
&&
1584 ball
[k
].pos_x
+HALFBALL
<=
1585 brickx
+BRICK_WIDTH
) &&
1586 ((bricky
==ball
[k
].pos_y
+BALL
) ||
1587 (bricky
+6>=ball
[k
].pos_y
+BALL
&&
1588 bricky
<ball
[k
].pos_y
+BALL
)) &&
1589 (ball
[k
].y
>0)) { /* top line */
1590 if (brick
[i
*10+j
].hits
> 0) {
1591 brick
[i
*10+j
].hits
--;
1592 brick
[i
*10+j
].hiteffect
++;
1596 brick
[i
*10+j
].used
=0;
1597 if (brick
[i
*10+j
].power
!=10)
1598 brick
[i
*10+j
].poweruse
=2;
1601 ball
[k
].y
= ball
[k
].y
*-1;
1604 if ((ball
[k
].pos_y
+HALFBALL
>= bricky
&&
1605 ball
[k
].pos_y
+HALFBALL
<=
1606 bricky
+BRICK_HEIGHT
) &&
1607 ((brickx
==ball
[k
].pos_x
+BALL
) ||
1608 (brickx
+6>=ball
[k
].pos_x
+BALL
&&
1609 brickx
<ball
[k
].pos_x
+BALL
)) &&
1610 (ball
[k
].x
> 0)) { /* left line */
1611 if (brick
[i
*10+j
].hits
> 0) {
1612 brick
[i
*10+j
].hits
--;
1613 brick
[i
*10+j
].hiteffect
++;
1617 brick
[i
*10+j
].used
=0;
1618 if (brick
[i
*10+j
].power
!=10)
1619 brick
[i
*10+j
].poweruse
=2;
1621 ball
[k
].x
= ball
[k
].x
*-1;
1624 else if ((ball
[k
].pos_y
+HALFBALL
>= bricky
&&
1625 ball
[k
].pos_y
+HALFBALL
<=
1626 bricky
+BRICK_HEIGHT
) &&
1627 ((brickx
+BRICK_WIDTH
==
1629 (brickx
+BRICK_WIDTH
-6<=
1633 (ball
[k
].x
< 0)) { /* Right line */
1634 if (brick
[i
*10+j
].hits
> 0) {
1635 brick
[i
*10+j
].hits
--;
1636 brick
[i
*10+j
].hiteffect
++;
1640 brick
[i
*10+j
].used
=0;
1641 if (brick
[i
*10+j
].power
!=10)
1642 brick
[i
*10+j
].poweruse
=2;
1645 ball
[k
].x
= ball
[k
].x
*-1;
1648 if (brick
[i
*10+j
].used
==0) {
1659 rb
->lcd_bitmap_part(brickmania_pads
,0,pad_type
*PAD_HEIGHT
,
1660 PAD_WIDTH
,pad_pos_x
, PAD_POS_Y
, PAD_WIDTH
,
1663 for(k
=0;k
<used_balls
;k
++) {
1665 if ((ball
[k
].pos_x
>= pad_pos_x
&&
1666 ball
[k
].pos_x
<= pad_pos_x
+PAD_WIDTH
) &&
1667 (PAD_POS_Y
-4<ball
[k
].pos_y
+BALL
&&
1668 PAD_POS_Y
>ball
[k
].pos_y
+BALL
) && (ball
[k
].y
>0))
1669 ball
[k
].tempy
=PAD_POS_Y
-ball
[k
].pos_y
-BALL
;
1670 else if ((4>ball
[k
].pos_y
&& 0<ball
[k
].pos_y
) &&
1672 ball
[k
].tempy
=-ball
[k
].pos_y
;
1673 if ((LCD_WIDTH
-4<ball
[k
].pos_x
+BALL
&&
1674 LCD_WIDTH
>ball
[k
].pos_x
+BALL
) && (ball
[k
].x
>0))
1675 ball
[k
].tempx
=LCD_WIDTH
-ball
[k
].pos_x
-BALL
;
1676 else if ((4>ball
[k
].pos_x
&& 0<ball
[k
].pos_x
) &&
1678 ball
[k
].tempx
=-ball
[k
].pos_x
;
1681 if (ball
[k
].pos_y
<= 0)
1682 ball
[k
].y
= ball
[k
].y
*-1;
1684 else if (ball
[k
].pos_y
+BALL
>= GAMESCREEN_HEIGHT
) {
1687 ball
[k
].pos_x
= ball
[used_balls
].pos_x
;
1688 ball
[k
].pos_y
= ball
[used_balls
].pos_y
;
1689 ball
[k
].y
= ball
[used_balls
].y
;
1690 ball
[k
].tempy
= ball
[used_balls
].tempy
;
1691 ball
[k
].x
= ball
[used_balls
].x
;
1692 ball
[k
].tempx
= ball
[used_balls
].tempx
;
1693 ball
[k
].glue
= ball
[used_balls
].glue
;
1695 ball
[used_balls
].x
=0;
1696 ball
[used_balls
].y
=0;
1697 ball
[used_balls
].tempy
=0;
1698 ball
[used_balls
].tempx
=0;
1699 ball
[used_balls
].pos_y
=PAD_POS_Y
-BALL
;
1700 ball
[used_balls
].pos_x
=pad_pos_x
+(PAD_WIDTH
/2)-2;
1713 /* left line ,right line */
1714 if ((ball
[k
].pos_x
<= 0) ||
1715 (ball
[k
].pos_x
+BALL
>= LCD_WIDTH
)) {
1716 ball
[k
].x
= ball
[k
].x
*-1;
1717 ball
[k
].pos_x
= ball
[k
].pos_x
<= 0 ? 0 : LCD_WIDTH
-BALL
;
1720 if ((ball
[k
].pos_y
+BALL
>= PAD_POS_Y
&&
1721 (ball
[k
].pos_x
>= pad_pos_x
&&
1722 ball
[k
].pos_x
<= pad_pos_x
+PAD_WIDTH
)) &&
1723 start_game
!= 1 && !ball
[k
].glue
) {
1725 if ((ball
[k
].pos_x
+HALFBALL
>= pad_pos_x
&&
1726 ball
[k
].pos_x
+HALFBALL
<=
1727 pad_pos_x
+(PAD_WIDTH
/2/4)) ||
1728 (ball
[k
].pos_x
+HALFBALL
>=
1729 pad_pos_x
+(PAD_WIDTH
-(PAD_WIDTH
/2/4)) &&
1730 ball
[k
].pos_x
+HALFBALL
<= pad_pos_x
+PAD_WIDTH
)) {
1733 if (ball
[k
].pos_x
!= 0 &&
1734 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1735 ball
[k
].x
= pad_check(6,0,ball
[k
].pos_x
+2<=
1736 pad_pos_x
+(PAD_WIDTH
/2)?
1740 else if ((ball
[k
].pos_x
+HALFBALL
>=
1741 pad_pos_x
+(PAD_WIDTH
/2/4) &&
1742 ball
[k
].pos_x
+HALFBALL
<=
1743 pad_pos_x
+2*(PAD_WIDTH
/2/4)) ||
1744 (ball
[k
].pos_x
+HALFBALL
>=
1745 pad_pos_x
+(PAD_WIDTH
-2*(PAD_WIDTH
/2/4)) &&
1746 ball
[k
].pos_x
+HALFBALL
<=
1747 pad_pos_x
+(PAD_WIDTH
-(PAD_WIDTH
/2/4)) )) {
1750 if (ball
[k
].pos_x
!= 0 &&
1751 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1752 ball
[k
].x
= pad_check(4,0,ball
[k
].pos_x
+2<=
1753 pad_pos_x
+(PAD_WIDTH
/2)?
1757 else if ((ball
[k
].pos_x
+HALFBALL
>=
1758 pad_pos_x
+2*(PAD_WIDTH
/2/4) &&
1759 ball
[k
].pos_x
+HALFBALL
<=
1760 pad_pos_x
+3*(PAD_WIDTH
/2/4)) ||
1762 pad_pos_x
+(PAD_WIDTH
-3*(PAD_WIDTH
/2/4)) &&
1764 pad_pos_x
+ ((PAD_WIDTH
/2)-2*(PAD_WIDTH
/2/4)) )) {
1767 if (ball
[k
].pos_x
!= 0 &&
1768 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1769 ball
[k
].x
= pad_check(3,0,ball
[k
].pos_x
+2<=
1770 pad_pos_x
+(PAD_WIDTH
/2)?
1774 else if ((ball
[k
].pos_x
+HALFBALL
>=
1775 pad_pos_x
+3*(PAD_WIDTH
/2/4) &&
1776 ball
[k
].pos_x
+HALFBALL
<=
1777 pad_pos_x
+4*(PAD_WIDTH
/2/4)-2) ||
1778 (ball
[k
].pos_x
+2 >= pad_pos_x
+(PAD_WIDTH
/2+2) &&
1780 pad_pos_x
+(PAD_WIDTH
-3*(PAD_WIDTH
/2/4)) )) {
1783 if (ball
[k
].pos_x
!= 0 &&
1784 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1785 ball
[k
].x
= pad_check(2,1,0,k
);
1793 if (!ball
[k
].glue
) {
1794 ball
[k
].pos_x
+=ball
[k
].tempx
!=0?ball
[k
].tempx
:ball
[k
].x
;
1795 ball
[k
].pos_y
+=ball
[k
].tempy
!=0?ball
[k
].tempy
:ball
[k
].y
;
1801 if (ball
[k
].pos_y
+5 >= PAD_POS_Y
&&
1802 (pad_type
==1 && !ball
[k
].glue
) &&
1803 (ball
[k
].pos_x
>= pad_pos_x
&&
1804 ball
[k
].pos_x
<= pad_pos_x
+PAD_WIDTH
)) {
1806 ball
[k
].pos_y
=PAD_POS_Y
-BALL
;
1813 if (brick_on_board
< 0) {
1814 if (cur_level
+1<levels_num
) {
1821 rb
->lcd_getstringsize("Congratulations!", &sw
, NULL
);
1822 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_CONGRATS
,
1823 "Congratulations!");
1824 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1825 rb
->lcd_getstringsize("No more levels", &sw
, NULL
);
1826 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_FINISH
,
1829 rb
->lcd_getstringsize("You have finished the game!",
1831 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_FINISH
,
1832 "You have finished the game!");
1836 if (score
>highscore
) {
1839 rb
->splash(HZ
*2, "New High Score");
1845 switch(game_menu(0)) {
1855 if (help(0)==1) return 1;
1864 int move_button
,button
;
1865 int button_right
,button_left
;
1866 button
=rb
->button_get(false);
1868 #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN)
1869 /* FIXME: Should probably check remote hold here */
1870 if (rb
->button_hold())
1874 #ifdef HAVE_TOUCHSCREEN
1875 if(button
& BUTTON_TOUCHSCREEN
)
1877 short touch_x
, touch_y
;
1878 touch_x
= rb
->button_get_data() >> 16;
1879 touch_y
= rb
->button_get_data() & 0xffff;
1880 if(touch_y
>= PAD_POS_Y
&& touch_y
<= PAD_POS_Y
+PAD_HEIGHT
)
1882 pad_pos_x
+= (flip_sides
? -1 : 1) * ( (touch_x
-pad_pos_x
-PAD_WIDTH
/2) / 4 );
1886 else if(pad_pos_x
+PAD_WIDTH
> LCD_WIDTH
)
1887 pad_pos_x
= LCD_WIDTH
-PAD_WIDTH
;
1888 for(k
=0;k
<used_balls
;k
++)
1889 if ((start_game
==1 || ball
[k
].glue
))
1890 ball
[k
].pos_x
= pad_pos_x
+PAD_WIDTH
/2;
1893 if(button
& BUTTON_REL
)
1899 move_button
=rb
->button_status();
1901 button_right
=((move_button
& RIGHT
) || (move_button
& ALTRIGHT
));
1902 button_left
=((move_button
& LEFT
) || (move_button
& ALTLEFT
));
1904 button_right
=((move_button
& RIGHT
) || (SCROLL_FWD(button
)));
1905 button_left
=((move_button
& LEFT
) || (SCROLL_BACK(button
)));
1907 if ((con_game
== 1 && start_game
!=1) && (button_right
|| button_left
))
1909 if ((button_right
&& flip_sides
==false) ||
1910 (button_left
&& flip_sides
==true)) {
1911 if (pad_pos_x
+8+PAD_WIDTH
> LCD_WIDTH
) {
1912 for(k
=0;k
<used_balls
;k
++)
1913 if (start_game
==1 || ball
[k
].glue
)
1914 ball
[k
].pos_x
+=LCD_WIDTH
-pad_pos_x
-PAD_WIDTH
;
1915 pad_pos_x
+=LCD_WIDTH
-pad_pos_x
-PAD_WIDTH
;
1918 for(k
=0;k
<used_balls
;k
++)
1919 if ((start_game
==1 || ball
[k
].glue
))
1924 else if ((button_left
&& flip_sides
==false) ||
1925 (button_right
&& flip_sides
==true)) {
1926 if (pad_pos_x
-8 < 0) {
1927 for(k
=0;k
<used_balls
;k
++)
1928 if (start_game
==1 || ball
[k
].glue
)
1929 ball
[k
].pos_x
-=pad_pos_x
;
1930 pad_pos_x
-=pad_pos_x
;
1933 for(k
=0;k
<used_balls
;k
++)
1934 if (start_game
==1 || ball
[k
].glue
)
1939 #ifdef HAVE_TOUCHSCREEN
1947 if (start_game
==1 && con_game
!=1 && pad_type
!=1) {
1948 for(k
=0;k
<used_balls
;k
++) {
1950 ball
[k
].x
=pad_pos_x
+(PAD_WIDTH
/2)-2>=
1955 else if (pad_type
==1) {
1956 for(k
=0;k
<used_balls
;k
++) {
1959 else if (start_game
==1) {
1965 if (start_game
!=1 && con_game
==1) {
1969 } else if (pad_type
==2 && con_game
!=1) {
1972 fire
[tfire
].top
=PAD_POS_Y
-7;
1973 fire
[tfire
].left
=pad_pos_x
+1;
1975 fire
[tfire
].top
=PAD_POS_Y
-7;
1976 fire
[tfire
].left
=pad_pos_x
+PAD_WIDTH
-1;
1977 } else if (con_game
==1 && start_game
!=1) {
1978 for(k
=0;k
<used_balls
;k
++) {
1989 switch(game_menu(1)) {
1996 for(k
=0;k
<used_balls
;k
++)
1997 if (ball
[k
].x
!=0 && ball
[k
].y
!=0)
2009 for(k
=0;k
<used_balls
;k
++) {
2021 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
2027 #ifdef HAVE_LCD_COLOR
2028 rb
->lcd_bitmap_transparent(brickmania_gameover
,
2029 (LCD_WIDTH
- GAMEOVER_WIDTH
)/2,
2030 (GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2031 GAMEOVER_WIDTH
,GAMEOVER_HEIGHT
);
2032 #else /* greyscale and mono */
2033 rb
->lcd_bitmap(brickmania_gameover
,(LCD_WIDTH
- GAMEOVER_WIDTH
)/2,
2034 (GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2035 GAMEOVER_WIDTH
,GAMEOVER_HEIGHT
);
2038 if (score
>highscore
) {
2041 rb
->splash(HZ
*2, "New High Score");
2046 for(k
=0;k
<used_balls
;k
++) {
2051 switch(game_menu(0)) {
2069 if (end
> *rb
->current_tick
)
2070 rb
->sleep(end
-*rb
->current_tick
);
2076 /* this is the plugin entry point */
2077 enum plugin_status
plugin_start(const struct plugin_api
* api
, const void* parameter
)
2082 rb
->lcd_setfont(FONT_SYSFIXED
);
2084 rb
->lcd_set_backdrop(NULL
);
2086 /* Turn off backlight timeout */
2087 backlight_force_on(rb
); /* backlight control in lib/helper.c */
2089 /* now go ahead and have fun! */
2090 while (game_loop()!=1);
2092 configfile_save(HIGH_SCORE
,config
,1,0);
2094 /* Restore user's original backlight setting */
2095 rb
->lcd_setfont(FONT_UI
);
2096 /* Turn on backlight timeout (revert to settings) */
2097 backlight_use_settings(rb
); /* backlight control in lib/helper.c */