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) || \
107 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
109 #define QUIT BUTTON_POWER
110 #define LEFT BUTTON_LEFT
111 #define RIGHT BUTTON_RIGHT
112 #define SELECT BUTTON_SELECT
113 #define UP BUTTON_SCROLL_BACK
114 #define DOWN BUTTON_SCROLL_FWD
116 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
117 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
120 #elif CONFIG_KEYPAD == SANSA_C200_PAD || \
121 CONFIG_KEYPAD == SANSA_CLIP_PAD || \
122 CONFIG_KEYPAD == SANSA_M200_PAD
124 #define QUIT BUTTON_POWER
125 #define LEFT BUTTON_LEFT
126 #define RIGHT BUTTON_RIGHT
127 #define ALTLEFT BUTTON_VOL_DOWN
128 #define ALTRIGHT BUTTON_VOL_UP
129 #define SELECT BUTTON_SELECT
131 #define DOWN BUTTON_DOWN
134 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
136 #define QUIT BUTTON_POWER
137 #define LEFT BUTTON_LEFT
138 #define RIGHT BUTTON_RIGHT
139 #define SELECT BUTTON_PLAY
140 #define UP BUTTON_SCROLL_UP
141 #define DOWN BUTTON_SCROLL_DOWN
143 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
145 #define QUIT BUTTON_BACK
146 #define LEFT BUTTON_LEFT
147 #define RIGHT BUTTON_RIGHT
148 #define SELECT BUTTON_SELECT
150 #define DOWN BUTTON_DOWN
152 #elif (CONFIG_KEYPAD == MROBE100_PAD)
154 #define QUIT BUTTON_POWER
155 #define LEFT BUTTON_LEFT
156 #define RIGHT BUTTON_RIGHT
157 #define SELECT BUTTON_SELECT
159 #define DOWN BUTTON_DOWN
161 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
163 #define QUIT BUTTON_RC_REC
164 #define LEFT BUTTON_RC_REW
165 #define RIGHT BUTTON_RC_FF
166 #define SELECT BUTTON_RC_PLAY
167 #define UP BUTTON_RC_VOL_UP
168 #define DOWN BUTTON_RC_VOL_DOWN
170 #define RC_QUIT BUTTON_REC
172 #elif CONFIG_KEYPAD == COWOND2_PAD
173 #define QUIT BUTTON_POWER
175 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
177 #define QUIT BUTTON_BACK
178 #define LEFT BUTTON_LEFT
179 #define RIGHT BUTTON_RIGHT
180 #define SELECT BUTTON_SELECT
182 #define DOWN BUTTON_DOWN
184 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
186 #define QUIT BUTTON_POWER
187 #define LEFT BUTTON_LEFT
188 #define RIGHT BUTTON_RIGHT
189 #define SELECT BUTTON_SELECT
191 #define DOWN BUTTON_DOWN
194 #error No keymap defined!
197 #ifdef HAVE_TOUCHSCREEN
199 #define LEFT BUTTON_MIDLEFT
202 #define RIGHT BUTTON_MIDRIGHT
205 #define SELECT BUTTON_CENTER
208 #define UP BUTTON_TOPMIDDLE
211 #define DOWN BUTTON_BOTTOMMIDDLE
215 #ifndef SCROLL_FWD /* targets without scroll wheel*/
216 #define SCROLL_FWD(x) (0)
217 #define SCROLL_BACK(x) (0)
233 #include "pluginbitmaps/brickmania_pads.h"
234 #include "pluginbitmaps/brickmania_bricks.h"
235 #include "pluginbitmaps/brickmania_powerups.h"
236 #include "pluginbitmaps/brickmania_ball.h"
237 #include "pluginbitmaps/brickmania_menu_items.h"
238 #include "pluginbitmaps/brickmania_gameover.h"
240 #define PAD_WIDTH BMPWIDTH_brickmania_pads
241 #define PAD_HEIGHT (BMPHEIGHT_brickmania_pads/3)
242 #define BRICK_HEIGHT (BMPHEIGHT_brickmania_bricks/7)
243 #define BRICK_WIDTH BMPWIDTH_brickmania_bricks
244 #define LEFTMARGIN ((LCD_WIDTH-10*BRICK_WIDTH)/2)
245 #define POWERUP_HEIGHT (BMPHEIGHT_brickmania_powerups/7)
246 #define POWERUP_WIDTH BMPWIDTH_brickmania_powerups
247 #define BALL BMPHEIGHT_brickmania_ball
248 #define HALFBALL ((BALL+1)/2)
249 #define MENU_ITEMXOFS ((LCD_WIDTH - BMPWIDTH_brickmania_menu_items)/2)
250 #define MENU_ITEMHEIGHT (BMPHEIGHT_brickmania_menu_items/9)
251 #define MENU_ITEMWIDTH BMPWIDTH_brickmania_menu_items
252 #define GAMEOVER_WIDTH BMPWIDTH_brickmania_gameover
253 #define GAMEOVER_HEIGHT BMPHEIGHT_brickmania_gameover
255 #if LCD_DEPTH > 1 /* currently no background bmp for mono screens */
256 #include "pluginbitmaps/brickmania_menu_bg.h"
257 #define MENU_BGHEIGHT BMPHEIGHT_brickmania_menu_bg
258 #define MENU_BGWIDTH BMPWIDTH_brickmania_menu_bg
261 #ifdef HAVE_LCD_COLOR /* currently no transparency for non-colour */
262 #include "pluginbitmaps/brickmania_break.h"
265 #if (LCD_WIDTH == 320) && (LCD_HEIGHT == 240)
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
275 #define BMPYOFS_start 110
276 #define HIGHSCORE_XPOS 57
277 #define HIGHSCORE_YPOS 88
279 #define STRINGPOS_FINISH 140
280 #define STRINGPOS_CONGRATS 157
281 #define STRINGPOS_NAVI 150
282 #define STRINGPOS_FLIP 150
284 #elif (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176)
286 /* The time (in ms) for one iteration through the game loop - decrease this
287 to speed up the game - note that current_tick is (currently) only accurate
292 /* Offsets for LCDS > 220x176 */
294 #define GAMESCREEN_HEIGHT 176
297 #define XOFS ((LCD_WIDTH-220)/BRICK_WIDTH/2)*BRICK_WIDTH
298 #define YOFS ((LCD_HEIGHT-176)/BRICK_HEIGHT/2)*BRICK_HEIGHT
300 #define BMPYOFS_start (78+YOFS)
301 #define HIGHSCORE_XPOS (17+XOFS)
302 #define HIGHSCORE_YPOS (56+YOFS)
304 #define STRINGPOS_FINISH 140
305 #define STRINGPOS_CONGRATS 157
306 #define STRINGPOS_NAVI 150
307 #define STRINGPOS_FLIP 150
309 #elif (LCD_WIDTH == 160) && (LCD_HEIGHT == 128)
310 /* The time (in ms) for one iteration through the game loop - decrease this
311 to speed up the game - note that current_tick is (currently) only accurate
319 #define BMPYOFS_start 58
321 #define BMPYOFS_start 66
323 #define HIGHSCORE_XPOS 10
324 #define HIGHSCORE_YPOS 38
326 #define STRINGPOS_FINISH 110
327 #define STRINGPOS_CONGRATS 100
328 #define STRINGPOS_NAVI 100
329 #define STRINGPOS_FLIP 100
331 #elif (LCD_WIDTH == 132) && (LCD_HEIGHT == 80)
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
341 #define BMPYOFS_start 30
342 #define HIGHSCORE_XPOS 68
343 #define HIGHSCORE_YPOS 8
345 #define STRINGPOS_FINISH 55
346 #define STRINGPOS_CONGRATS 45
347 #define STRINGPOS_NAVI 60
348 #define STRINGPOS_FLIP 60
350 #elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 128)
352 /* The time (in ms) for one iteration through the game loop - decrease this
353 to speed up the game - note that current_tick is (currently) only accurate
358 #define GAMESCREEN_HEIGHT 100
361 #define BMPYOFS_start 70
362 #define HIGHSCORE_XPOS 8
363 #define HIGHSCORE_YPOS 36
365 #define STRINGPOS_FINISH 55
366 #define STRINGPOS_CONGRATS 45
367 #define STRINGPOS_NAVI 60
368 #define STRINGPOS_FLIP 60
371 #elif (LCD_WIDTH == 138) && (LCD_HEIGHT == 110)
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 51
381 #define HIGHSCORE_XPOS 73
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 == 128) && (LCD_HEIGHT == 96)
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 42
400 #define HIGHSCORE_XPOS 65
401 #define HIGHSCORE_YPOS 25
403 #define STRINGPOS_FINISH 54
404 #define STRINGPOS_CONGRATS 44
405 #define STRINGPOS_NAVI 44
406 #define STRINGPOS_FLIP 44
408 /* Archos / Sansa Clip / Sansa m200 */
409 #elif ((LCD_WIDTH == 112) | (LCD_WIDTH == 128)) && (LCD_HEIGHT == 64)
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
418 #define BMPYOFS_start 22
419 #define HIGHSCORE_XPOS 0
420 #define HIGHSCORE_YPOS 0
422 #define STRINGPOS_FINISH 54
423 #define STRINGPOS_CONGRATS 44
424 #define STRINGPOS_NAVI 44
425 #define STRINGPOS_FLIP 44
428 #elif (LCD_WIDTH == 176) && (LCD_HEIGHT >= 132) && (LCD_DEPTH==16)
429 /* The time (in ms) for one iteration through the game loop - decrease this
430 to speed up the game - note that current_tick is (currently) only accurate
436 #define GAMESCREEN_HEIGHT 132
439 #define BMPYOFS_start 58
440 #define HIGHSCORE_XPOS 7
441 #define HIGHSCORE_YPOS 36
443 #define STRINGPOS_FINISH 110
444 #define STRINGPOS_CONGRATS 110
445 #define STRINGPOS_NAVI 100
446 #define STRINGPOS_FLIP 100
449 #error Unsupported LCD Size
453 #ifndef GAMESCREEN_HEIGHT
454 #define GAMESCREEN_HEIGHT LCD_HEIGHT
457 /* calculate menu item offsets from the first defined and the height*/
458 #define BMPYOFS_resume (BMPYOFS_start + MENU_ITEMHEIGHT)
459 #define BMPYOFS_help (BMPYOFS_start + 2*MENU_ITEMHEIGHT)
460 #define BMPYOFS_quit (BMPYOFS_start + 3*MENU_ITEMHEIGHT)
462 /*calculate paddle y-position */
463 #if GAMESCREEN_HEIGHT >= 128
464 #define PAD_POS_Y GAMESCREEN_HEIGHT -PAD_HEIGHT - 2
466 #define PAD_POS_Y GAMESCREEN_HEIGHT -PAD_HEIGHT - 1
470 #ifdef HAVE_TOUCHSCREEN
471 #include "lib/touchscreen.h"
473 static struct ts_mapping main_menu_items
[4] =
475 {MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
},
476 {MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
},
477 {MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
},
478 {MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
}
480 static struct ts_mappings main_menu
= {main_menu_items
, 4};
486 static unsigned char levels
[29][8][10] = {
488 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
489 {0x2,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x2},
490 {0x0,0x2,0x1,0x0,0x0,0x0,0x0,0x1,0x2,0x0},
491 {0x0,0x0,0x2,0x1,0x0,0x0,0x1,0x2,0x0,0x0},
492 {0x0,0x0,0x0,0x2,0x1,0x1,0x2,0x0,0x0,0x0},
493 {0x7,0x0,0x0,0x7,0x2,0x2,0x7,0x0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x5}
667 { /* level 19 (Stalactites) by ts-x */
668 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
669 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
670 {0x5,0x0,0x6,0x3,0x4,0x7,0x5,0x0,0x1,0x2},
671 {0x5,0x2,0x6,0x3,0x4,0x0,0x5,0x3,0x1,0x2},
672 {0x5,0x0,0x6,0x0,0x4,0x7,0x5,0x0,0x1,0x0},
673 {0x5,0x0,0x0,0x3,0x4,0x0,0x0,0x0,0x1,0x2},
674 {0x0,0x0,0x6,0x0,0x0,0x0,0x5,0x0,0x0,0x0},
675 {0x5,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x1,0x0}
677 { /* level 20 (Maze) by ts-x */
678 {0x1,0x1,0x21,0x1,0x1,0x1,0x1,0x1,0x1,0x21},
679 {0x1,0x0,0x0,0x3,0x0,0x0,0x3,0x1,0x31,0x1},
680 {0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x0,0x1},
681 {0x21,0x0,0x21,0x3,0x0,0x3,0x0,0x3,0x0,0x2},
682 {0x1,0x0,0x1,0x21,0x0,0x12,0x0,0x0,0x0,0x0},
683 {0x31,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x3,0x0},
684 {0x1,0x0,0x1,0x0,0x1,0x1,0x31,0x1,0x1,0x2},
685 {0x22,0x0,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x21}
687 { /* level 21 (Dentist) by ts-x */
688 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
689 {0x2,0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x2,0x2},
690 {0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x2},
691 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x2},
692 {0x2,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x0,0x2},
693 {0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x2},
694 {0x2,0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x2,0x2},
695 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0}
697 { /* level 22 (Spider) by ts-x */
698 {0x31,0x3,0x1,0x1,0x0,0x0,0x1,0x1,0x3,0x31},
699 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
700 {0x33,0x1,0x1,0x36,0x1,0x1,0x36,0x1,0x1,0x33},
701 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
702 {0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x0,0x0},
703 {0x21,0x3,0x1,0x21,0x2,0x2,0x21,0x1,0x3,0x21},
704 {0x0,0x0,0x0,0x1,0x21,0x1,0x1,0x0,0x0,0x0},
705 {0x3,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x3}
707 { /* level 23 (Pool) by ts-x */
708 {0x0,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x7,0x0},
709 {0x0,0x0,0x5,0x0,0x2,0x0,0x0,0x0,0x2,0x0},
710 {0x7,0x3,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x7},
711 {0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x5,0x0,0x7},
712 {0x7,0x0,0x4,0x0,0x0,0x3,0x0,0x0,0x0,0x7},
713 {0x7,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x4,0x7},
714 {0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
715 {0x0,0x7,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x0}
717 { /* level 24 (Vorbis Fish) by ts-x */
718 {0x0,0x0,0x4,0x4,0x5,0x5,0x5,0x0,0x0,0x5},
719 {0x0,0x4,0x6,0x4,0x4,0x5,0x5,0x5,0x0,0x5},
720 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x5,0x5,0x5},
721 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x4,0x5,0x5},
722 {0x0,0x5,0x6,0x4,0x4,0x5,0x5,0x4,0x5,0x0},
723 {0x5,0x5,0x4,0x4,0x5,0x5,0x5,0x4,0x5,0x5},
724 {0x5,0x4,0x4,0x4,0x5,0x5,0x4,0x4,0x5,0x5},
725 {0x0,0x0,0x4,0x4,0x4,0x4,0x4,0x5,0x0,0x5}
727 {/* level 25 (Rainbow) by ts-x */
728 {0x0,0x4,0x1,0x0,0x0,0x0,0x0,0x1,0x4,0x0},
729 {0x24,0x1,0x3,0x1,0x0,0x0,0x21,0x3,0x1,0x24},
730 {0x1,0x23,0x5,0x3,0x1,0x21,0x3,0x5,0x3,0x21},
731 {0x3,0x5,0x6,0x5,0x3,0x3,0x5,0x6,0x5,0x3},
732 {0x5,0x6,0x7,0x6,0x5,0x5,0x6,0x7,0x6,0x5},
733 {0x6,0x7,0x2,0x27,0x6,0x6,0x27,0x2,0x7,0x6},
734 {0x7,0x2,0x0,0x2,0x27,0x27,0x2,0x0,0x2,0x7},
735 {0x32,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x32}
737 { /* level 26 (Bowtie) by ts-x */
738 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5},
739 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
740 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
741 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
742 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
743 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
744 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
745 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5}
747 { /* level 27 (Frog) by ts-x */
748 {0x0,0x5,0x25,0x0,0x0,0x0,0x0,0x25,0x5,0x0},
749 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
750 {0x25,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x25},
751 {0x5,0x0,0x3,0x0,0x6,0x6,0x0,0x3,0x0,0x5},
752 {0x5,0x0,0x31,0x0,0x6,0x6,0x0,0x31,0x0,0x5},
753 {0x5,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x5},
754 {0x5,0x5,0x5,0x35,0x0,0x0,0x35,0x5,0x5,0x5},
755 {0x0,0x25,0x5,0x0,0x4,0x4,0x0,0x5,0x25,0x0}
757 { /* level 28 (DigDug) by ts-x */
758 {0x35,0x5,0x5,0x25,0x0,0x25,0x25,0x5,0x5,0x35},
759 {0x6,0x0,0x0,0x6,0x0,0x6,0x6,0x0,0x0,0x6},
760 {0x7,0x0,0x37,0x37,0x0,0x37,0x37,0x7,0x0,0x7},
761 {0x7,0x0,0x7,0x0,0x0,0x0,0x7,0x7,0x7,0x7},
762 {0x4,0x4,0x4,0x24,0x0,0x24,0x4,0x0,0x0,0x4},
763 {0x4,0x4,0x0,0x0,0x0,0x4,0x4,0x0,0x4,0x4},
764 {0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4},
765 {0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1}
768 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
769 {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0},
770 {0x22,0x0,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0},
771 {0x22,0x22,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0},
772 {0x22,0x22,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0},
773 {0x22,0x0,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0},
774 {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0},
775 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
781 int x
[MAX_BALLS
],y
[MAX_BALLS
];
783 int start_game
,con_game
;
785 int score
=0,vscore
=0;
786 bool flip_sides
=false;
788 int brick_on_board
=0;
791 typedef struct cube
{
802 typedef struct balls
{
812 balls ball
[MAX_BALLS
];
814 typedef struct sfire
{
822 #define MAX_POINTS 200000 /* i dont think it needs to be more */
823 static struct configdata config
[] =
825 {TYPE_INT
, 0, MAX_POINTS
, { .int_p
= &highscore
}, "highscore", NULL
}
828 void int_game(int new_game
)
832 pad_pos_x
=LCD_WIDTH
/2-PAD_WIDTH
/2;
834 for(i
=0;i
<MAX_BALLS
;i
++) {
839 ball
[i
].pos_y
=PAD_POS_Y
-BALL
;
840 ball
[i
].pos_x
=pad_pos_x
+(PAD_WIDTH
/2)-2;
856 brick
[i
*10+j
].poweruse
=(levels
[cur_level
][i
][j
]==0?0:1);
860 brick
[i
*10+j
].power
=rb
->rand()%25;
861 /* +8 make the game with less powerups */
863 brick
[i
*10+j
].hits
=levels
[cur_level
][i
][j
]>=10?
864 levels
[cur_level
][i
][j
]/16-1:0;
865 brick
[i
*10+j
].hiteffect
=0;
866 brick
[i
*10+j
].powertop
=TOPMARGIN
+i
*BRICK_HEIGHT
+BRICK_HEIGHT
;
867 brick
[i
*10+j
].used
=(levels
[cur_level
][i
][j
]==0?0:1);
868 brick
[i
*10+j
].color
=(levels
[cur_level
][i
][j
]>=10?
869 levels
[cur_level
][i
][j
]%16:
870 levels
[cur_level
][i
][j
])-1;
871 if (levels
[cur_level
][i
][j
]!=0)
880 /* sleep timer counting the score */
881 void sleep (int secs
)
891 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
892 rb
->lcd_getstringsize(s
, &sw
, &w
);
893 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
894 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
896 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 2, s
);
898 rb
->lcd_update_rect(0,0,LCD_WIDTH
,w
+2);
901 count
=*rb
->current_tick
+HZ
*secs
;
902 if (*rb
->current_tick
>=count
)
910 #define HIGH_SCORE "brickmania.score"
911 #define MENU_LENGTH 4
912 int game_menu(int when
)
916 rb
->lcd_clear_display();
917 #if LCD_DEPTH > 1 /* currently no background bmp for mono screens */
918 rb
->lcd_bitmap(brickmania_menu_bg
, 0, 0, MENU_BGWIDTH
, MENU_BGHEIGHT
);
921 for(i
=0;i
<MENU_LENGTH
;i
++) {
922 #ifdef HAVE_LCD_COLOR
924 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
925 MENU_ITEMHEIGHT
* BM_SEL_START
, MENU_ITEMWIDTH
,
926 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
929 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
930 MENU_ITEMHEIGHT
* BM_START
, MENU_ITEMWIDTH
,
931 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
936 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
937 MENU_ITEMHEIGHT
* BM_SEL_RESUME
, MENU_ITEMWIDTH
,
938 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
941 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
942 MENU_ITEMHEIGHT
* BM_RESUME
, MENU_ITEMWIDTH
,
943 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
947 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
948 MENU_ITEMHEIGHT
* BM_NO_RESUME
, MENU_ITEMWIDTH
,
949 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
955 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
956 MENU_ITEMHEIGHT
* BM_SEL_HELP
, MENU_ITEMWIDTH
,
957 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
960 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
961 MENU_ITEMHEIGHT
* BM_HELP
, MENU_ITEMWIDTH
,
962 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
966 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
967 MENU_ITEMHEIGHT
* BM_SEL_QUIT
, MENU_ITEMWIDTH
,
968 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
971 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
972 MENU_ITEMHEIGHT
* BM_QUIT
, MENU_ITEMWIDTH
,
973 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
977 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
978 MENU_ITEMHEIGHT
* BM_SEL_START
, MENU_ITEMWIDTH
,
979 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
982 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
983 MENU_ITEMHEIGHT
* BM_START
, MENU_ITEMWIDTH
,
984 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
989 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
990 MENU_ITEMHEIGHT
* BM_SEL_RESUME
, MENU_ITEMWIDTH
,
991 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
994 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
995 MENU_ITEMHEIGHT
* BM_RESUME
, MENU_ITEMWIDTH
,
996 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
1000 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1001 MENU_ITEMHEIGHT
* BM_NO_RESUME
, MENU_ITEMWIDTH
,
1002 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
1008 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1009 MENU_ITEMHEIGHT
* BM_SEL_HELP
, MENU_ITEMWIDTH
,
1010 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
1013 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1014 MENU_ITEMHEIGHT
* BM_HELP
, MENU_ITEMWIDTH
,
1015 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
1019 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1020 MENU_ITEMHEIGHT
* BM_SEL_QUIT
, MENU_ITEMWIDTH
,
1021 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
1024 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1025 MENU_ITEMHEIGHT
* BM_QUIT
, MENU_ITEMWIDTH
,
1026 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
1030 rb
->lcd_set_drawmode(DRMODE_FG
);
1032 #ifdef HAVE_LCD_COLOR
1033 rb
->lcd_set_background(LCD_RGBPACK(0,0,140));
1034 rb
->lcd_set_foreground(LCD_WHITE
);
1036 rb
->lcd_putsxy(HIGHSCORE_XPOS
, HIGHSCORE_YPOS
, "High Score");
1037 rb
->snprintf(str
, sizeof(str
), "%d", highscore
);
1038 rb
->lcd_getstringsize("High Score", &sw
, NULL
);
1039 rb
->lcd_getstringsize(str
, &w
, NULL
);
1040 rb
->lcd_putsxy(HIGHSCORE_XPOS
+sw
/2-w
/2, HIGHSCORE_YPOS
+9, str
);
1041 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1045 button
= rb
->button_get(true);
1046 #ifdef HAVE_TOUCHSCREEN
1047 if(button
& BUTTON_TOUCHSCREEN
)
1049 unsigned int result
= touchscreen_map(&main_menu
, rb
->button_get_data() >> 16, rb
->button_get_data() & 0xffff);
1050 if(result
!= (unsigned)-1 && button
& BUTTON_REL
)
1052 if(cur
== (signed)result
)
1060 case UP
| BUTTON_REPEAT
:
1062 cur
= MENU_LENGTH
-1;
1065 if (when
==0 && cur
==1) {
1071 case DOWN
| BUTTON_REPEAT
:
1072 if (cur
==MENU_LENGTH
-1)
1076 if (when
==0 && cur
==1) {
1087 } else if (cur
==1 && when
==1) {
1089 } else if (cur
==2) {
1091 } else if (cur
==3) {
1103 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
1118 /* set the maximum x and y in the helpscreen
1119 dont forget to update, if you change text */
1124 #ifdef HAVE_LCD_COLOR
1125 rb
->lcd_set_background(LCD_BLACK
);
1126 rb
->lcd_clear_display();
1127 rb
->lcd_set_background(LCD_BLACK
);
1128 rb
->lcd_set_foreground(LCD_WHITE
);
1130 rb
->lcd_clear_display();
1133 rb
->lcd_getstringsize("BrickMania", &w
, &h
);
1134 rb
->lcd_putsxy(LCD_WIDTH
/2-w
/2+xoffset
, 1+yoffset
, "BrickMania");
1136 #ifdef HAVE_LCD_COLOR
1137 rb
->lcd_set_foreground(LCD_RGBPACK(245,0,0));
1138 rb
->lcd_putsxy(1+xoffset
, 1*(h
+2)+yoffset
,"Aim");
1139 rb
->lcd_set_foreground(LCD_WHITE
);
1141 rb
->lcd_putsxy(1+xoffset
, 1*(h
+2)+yoffset
,"Aim");
1143 rb
->lcd_putsxy(1+xoffset
, 2*(h
+2)+yoffset
,
1144 "destroy all the bricks by bouncing");
1145 rb
->lcd_putsxy(1+xoffset
, 3*(h
+2)+yoffset
,
1146 "the ball of them using the paddle.");
1147 #ifdef HAVE_LCD_COLOR
1148 rb
->lcd_set_foreground(LCD_RGBPACK(245,0,0));
1149 rb
->lcd_putsxy(1+xoffset
, 5*(h
+2)+yoffset
,"Controls");
1150 rb
->lcd_set_foreground(LCD_WHITE
);
1152 rb
->lcd_putsxy(1+xoffset
, 5*(h
+2)+yoffset
,"Controls");
1154 rb
->lcd_putsxy(1+xoffset
, 6*(h
+2)+yoffset
,"< & > Move the paddle");
1155 #if CONFIG_KEYPAD == ONDIO_PAD
1156 rb
->lcd_putsxy(1+xoffset
, 7*(h
+2)+yoffset
,
1157 "MENU Releases the ball/Fire!");
1158 #elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1159 rb
->lcd_putsxy(1+xoffset
, 7*(h
+2)+yoffset
,
1160 "PLAY Releases the ball/Fire!");
1161 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
1162 rb
->lcd_putsxy(1+xoffset
, 7*(h
+2)+yoffset
,
1163 "NAVI Releases the ball/Fire!");
1165 rb
->lcd_putsxy(1+xoffset
, 7*(h
+2)+yoffset
,
1166 "SELECT Releases the ball/Fire!");
1168 #if CONFIG_KEYPAD == IAUDIO_M3_PAD
1169 rb
->lcd_putsxy(1+xoffset
, 8*(h
+2)+yoffset
, "REC Opens menu/Quit");
1171 rb
->lcd_putsxy(1+xoffset
, 8*(h
+2)+yoffset
, "STOP Opens menu/Quit");
1173 #ifdef HAVE_LCD_COLOR
1174 rb
->lcd_set_foreground(LCD_RGBPACK(245,0,0));
1175 rb
->lcd_putsxy(1+xoffset
, 10*(h
+2)+yoffset
, "Specials");
1176 rb
->lcd_set_foreground(LCD_WHITE
);
1178 rb
->lcd_putsxy(1+xoffset
, 10*(h
+2)+yoffset
, "Specials");
1180 rb
->lcd_putsxy(1+xoffset
, 11*(h
+2)+yoffset
,
1181 "N Normal:returns paddle to normal");
1182 rb
->lcd_putsxy(1+xoffset
, 12*(h
+2)+yoffset
, "D DIE!:loses a life");
1183 rb
->lcd_putsxy(1+xoffset
, 13*(h
+2)+yoffset
,
1184 "L Life:gains a life/power up");
1185 rb
->lcd_putsxy(1+xoffset
, 14*(h
+2)+yoffset
,
1186 "F Fire:allows you to shoot bricks");
1187 rb
->lcd_putsxy(1+xoffset
, 15*(h
+2)+yoffset
,
1188 "G Glue:ball sticks to paddle");
1189 rb
->lcd_putsxy(1+xoffset
, 16*(h
+2)+yoffset
,
1190 "B Ball:generates another ball");
1191 rb
->lcd_putsxy(1+xoffset
, 17*(h
+2)+yoffset
,
1192 "FL Flip:flips left / right movement");
1195 button
=rb
->button_get(true);
1200 #ifdef HAVE_TOUCHSCREEN
1201 case BUTTON_TOUCHSCREEN
:
1204 switch (game_menu(when
)) {
1224 case LEFT
| BUTTON_REPEAT
:
1227 case ALTLEFT
| BUTTON_REPEAT
:
1233 case RIGHT
| BUTTON_REPEAT
:
1236 case ALTRIGHT
| BUTTON_REPEAT
:
1238 if(xoffset
+maxX
> LCD_WIDTH
)
1242 case UP
| BUTTON_REPEAT
:
1247 case DOWN
| BUTTON_REPEAT
:
1248 if(yoffset
+maxY
> LCD_HEIGHT
)
1253 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
1263 int pad_check(int ballxc
, int mode
, int pon
,int ballnum
)
1265 /* pon: positive(1) or negative(0) */
1273 if (ball
[ballnum
].x
> 0)
1280 int fire_space(void)
1284 if (fire
[t
].top
+7 < 0)
1292 int j
,i
,k
,bricky
,brickx
;
1294 int sec_count
=0,num_count
=10;
1297 rb
->srand( *rb
->current_tick
);
1299 configfile_load(HIGH_SCORE
,config
,1,0);
1301 switch(game_menu(0)) {
1311 if (help(0) == 1) return 1;
1319 /* Convert CYCLETIME (in ms) to HZ */
1320 end
= *rb
->current_tick
+ (CYCLETIME
* HZ
) / 1000;
1323 #ifdef HAVE_LCD_COLOR
1324 rb
->lcd_set_background(LCD_BLACK
);
1325 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1326 rb
->lcd_clear_display();
1327 rb
->lcd_set_background(LCD_BLACK
);
1328 #if LCD_HEIGHT > GAMESCREEN_HEIGHT
1329 rb
->lcd_set_foreground(rb
->global_settings
->bg_color
);
1330 rb
->lcd_fillrect(0, GAMESCREEN_HEIGHT
, LCD_WIDTH
,
1331 LCD_HEIGHT
- GAMESCREEN_HEIGHT
);
1333 rb
->lcd_set_foreground(LCD_WHITE
);
1335 rb
->lcd_clear_display();
1339 if (*rb
->current_tick
>=sec_count
) {
1340 sec_count
=*rb
->current_tick
+HZ
;
1346 rb
->snprintf(s
, sizeof(s
), "%d", num_count
);
1347 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1348 rb
->lcd_putsxy(LCD_WIDTH
/2-2, STRINGPOS_FLIP
, s
);
1351 /* write life num */
1352 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1353 rb
->snprintf(s
, sizeof(s
), "L:%d", life
);
1354 rb
->lcd_putsxy(0, 0, s
);
1356 rb
->snprintf(s
, sizeof(s
), "Life: %d", life
);
1357 rb
->lcd_putsxy(2, 2, s
);
1360 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1361 rb
->snprintf(s
, sizeof(s
), "L%d", cur_level
+1);
1362 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1363 rb
->lcd_putsxy(LCD_WIDTH
-sw
, 0, s
);
1365 rb
->snprintf(s
, sizeof(s
), "Level %d", cur_level
+1);
1366 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1367 rb
->lcd_putsxy(LCD_WIDTH
-sw
-2, 2, s
);
1370 if (vscore
<score
) vscore
++;
1371 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
1372 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1373 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1374 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
1376 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 2, s
);
1380 if (con_game
== 1 && start_game
!=1) {
1381 #if CONFIG_KEYPAD == ONDIO_PAD
1382 rb
->snprintf(s
, sizeof(s
), "MENU To Continue");
1383 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
1384 rb
->snprintf(s
, sizeof(s
), "Press NAVI To Continue");
1385 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
1386 rb
->snprintf(s
, sizeof(s
), "PLAY To Continue");
1388 rb
->snprintf(s
, sizeof(s
), "Press SELECT To Continue");
1390 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1391 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_NAVI
, s
);
1393 sec_count
=*rb
->current_tick
+HZ
;
1397 for(i
=0;i
<used_balls
;i
++)
1398 rb
->lcd_bitmap(brickmania_ball
,ball
[i
].pos_x
, ball
[i
].pos_y
,
1401 if (brick_on_board
==0)
1404 /* if the pad is fire */
1405 for(i
=0;i
<=30;i
++) {
1406 if (fire
[i
].top
+7>0) {
1409 rb
->lcd_vline(fire
[i
].left
, fire
[i
].top
, fire
[i
].top
+7);
1414 for (i
=0;i
<=7;i
++) {
1415 for (j
=0;j
<=9;j
++) {
1416 if (brick
[i
*10+j
].power
<7) {
1417 if (brick
[i
*10+j
].poweruse
==2) {
1419 brick
[i
*10+j
].powertop
+=2;
1420 rb
->lcd_bitmap_part(brickmania_powerups
,0,
1421 POWERUP_HEIGHT
*brick
[i
*10+j
1424 LEFTMARGIN
+j
*BRICK_WIDTH
+
1427 brick
[i
*10+j
].powertop
,
1433 if ((pad_pos_x
<LEFTMARGIN
+j
*BRICK_WIDTH
+5 &&
1434 pad_pos_x
+PAD_WIDTH
>LEFTMARGIN
+j
*BRICK_WIDTH
+5) &&
1435 brick
[i
*10+j
].powertop
+6>=PAD_POS_Y
&&
1436 brick
[i
*10+j
].poweruse
==2) {
1437 switch(brick
[i
*10+j
].power
) {
1456 for(k
=0;k
<used_balls
;k
++)
1462 for(k
=0;k
<used_balls
;k
++)
1468 sec_count
=*rb
->current_tick
+HZ
;
1470 flip_sides
=!flip_sides
;
1475 ball
[used_balls
-1].x
= rb
->rand()%1 == 0 ?
1477 ball
[used_balls
-1].y
= -4;
1480 brick
[i
*10+j
].poweruse
=1;
1483 if (brick
[i
*10+j
].powertop
>PAD_POS_Y
)
1484 brick
[i
*10+j
].poweruse
=1;
1486 brickx
=LEFTMARGIN
+j
*BRICK_WIDTH
;
1487 bricky
=TOPMARGIN
+i
*BRICK_HEIGHT
;
1489 for (k
=0;k
<=30;k
++) {
1490 if (fire
[k
].top
+7>0) {
1491 if (brick
[i
*10+j
].used
==1 &&
1492 (fire
[k
].left
+1 >= brickx
&&
1493 fire
[k
].left
+1 <= brickx
+BRICK_WIDTH
) &&
1494 (bricky
+BRICK_HEIGHT
>fire
[k
].top
)) {
1497 if (brick
[i
*10+j
].hits
> 0) {
1498 brick
[i
*10+j
].hits
--;
1499 brick
[i
*10+j
].hiteffect
++;
1503 brick
[i
*10+j
].used
=0;
1504 if (brick
[i
*10+j
].power
!=10)
1505 brick
[i
*10+j
].poweruse
=2;
1513 if (brick
[i
*10+j
].used
==1) {
1514 rb
->lcd_bitmap_part(brickmania_bricks
,0,
1515 BRICK_HEIGHT
*brick
[i
*10+j
].color
,
1517 LEFTMARGIN
+j
*BRICK_WIDTH
,
1518 TOPMARGIN
+i
*BRICK_HEIGHT
,
1519 BRICK_WIDTH
, BRICK_HEIGHT
);
1520 #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
1521 if (brick
[i
*10+j
].hiteffect
>0)
1522 rb
->lcd_bitmap_transparent_part(brickmania_break
,
1524 BRICK_HEIGHT
*brick
[i
*10+j
].hiteffect
,
1526 LEFTMARGIN
+j
*BRICK_WIDTH
,
1527 TOPMARGIN
+i
*BRICK_HEIGHT
,
1533 for(k
=0;k
<used_balls
;k
++) {
1534 if (ball
[k
].pos_y
<160) {
1535 if (brick
[i
*10+j
].used
==1) {
1536 if ((ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
>=
1538 ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
<=
1539 brickx
+BRICK_WIDTH
) &&
1540 ((bricky
-4<ball
[k
].pos_y
+BALL
&&
1541 bricky
>ball
[k
].pos_y
+BALL
) ||
1542 (bricky
+4>ball
[k
].pos_y
+BALL
+BALL
&&
1543 bricky
<ball
[k
].pos_y
+BALL
+BALL
)) &&
1545 ball
[k
].tempy
=bricky
-ball
[k
].pos_y
-BALL
;
1547 else if ((ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
>=
1549 ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
<=
1550 brickx
+BRICK_WIDTH
) &&
1551 ((bricky
+BRICK_HEIGHT
+4>ball
[k
].pos_y
&&
1552 bricky
+BRICK_HEIGHT
<ball
[k
].pos_y
) ||
1553 (bricky
+BRICK_HEIGHT
-4<ball
[k
].pos_y
-BALL
&&
1554 bricky
+BRICK_HEIGHT
>ball
[k
].pos_y
-BALL
)) &&
1557 -(ball
[k
].pos_y
-(bricky
+BRICK_HEIGHT
));
1560 if ((ball
[k
].pos_y
+HALFBALL
>=
1562 ball
[k
].pos_y
+HALFBALL
<=
1563 bricky
+BRICK_HEIGHT
) &&
1564 ((brickx
-4<ball
[k
].pos_x
+BALL
&&
1565 brickx
>ball
[k
].pos_x
+BALL
) ||
1566 (brickx
+4>ball
[k
].pos_x
+BALL
+BALL
&&
1567 brickx
<ball
[k
].pos_x
+BALL
+BALL
)) &&
1569 ball
[k
].tempx
=brickx
-ball
[k
].pos_x
-BALL
;
1571 else if ((ball
[k
].pos_y
+ball
[k
].y
+HALFBALL
>=
1573 ball
[k
].pos_y
+ball
[k
].y
+HALFBALL
<=
1574 bricky
+BRICK_HEIGHT
) &&
1575 ((brickx
+BRICK_WIDTH
+4>ball
[k
].pos_x
&&
1576 brickx
+BRICK_WIDTH
<ball
[k
].pos_x
) ||
1577 (brickx
+BRICK_WIDTH
-4<ball
[k
].pos_x
-
1579 brickx
+BRICK_WIDTH
>ball
[k
].pos_x
-
1580 BALL
)) && (ball
[k
].x
<0)) {
1582 -(ball
[k
].pos_x
-(brickx
+BRICK_WIDTH
));
1585 if ((ball
[k
].pos_x
+HALFBALL
>= brickx
&&
1586 ball
[k
].pos_x
+HALFBALL
<=
1587 brickx
+BRICK_WIDTH
) &&
1588 ((bricky
+BRICK_HEIGHT
==ball
[k
].pos_y
) ||
1589 (bricky
+BRICK_HEIGHT
-6<=ball
[k
].pos_y
&&
1590 bricky
+BRICK_HEIGHT
>ball
[k
].pos_y
)) &&
1591 (ball
[k
].y
<0)) { /* bottom line */
1592 if (brick
[i
*10+j
].hits
> 0) {
1593 brick
[i
*10+j
].hits
--;
1594 brick
[i
*10+j
].hiteffect
++;
1598 brick
[i
*10+j
].used
=0;
1599 if (brick
[i
*10+j
].power
!=10)
1600 brick
[i
*10+j
].poweruse
=2;
1603 ball
[k
].y
= ball
[k
].y
*-1;
1605 else if ((ball
[k
].pos_x
+HALFBALL
>= brickx
&&
1606 ball
[k
].pos_x
+HALFBALL
<=
1607 brickx
+BRICK_WIDTH
) &&
1608 ((bricky
==ball
[k
].pos_y
+BALL
) ||
1609 (bricky
+6>=ball
[k
].pos_y
+BALL
&&
1610 bricky
<ball
[k
].pos_y
+BALL
)) &&
1611 (ball
[k
].y
>0)) { /* top line */
1612 if (brick
[i
*10+j
].hits
> 0) {
1613 brick
[i
*10+j
].hits
--;
1614 brick
[i
*10+j
].hiteffect
++;
1618 brick
[i
*10+j
].used
=0;
1619 if (brick
[i
*10+j
].power
!=10)
1620 brick
[i
*10+j
].poweruse
=2;
1623 ball
[k
].y
= ball
[k
].y
*-1;
1626 if ((ball
[k
].pos_y
+HALFBALL
>= bricky
&&
1627 ball
[k
].pos_y
+HALFBALL
<=
1628 bricky
+BRICK_HEIGHT
) &&
1629 ((brickx
==ball
[k
].pos_x
+BALL
) ||
1630 (brickx
+6>=ball
[k
].pos_x
+BALL
&&
1631 brickx
<ball
[k
].pos_x
+BALL
)) &&
1632 (ball
[k
].x
> 0)) { /* left line */
1633 if (brick
[i
*10+j
].hits
> 0) {
1634 brick
[i
*10+j
].hits
--;
1635 brick
[i
*10+j
].hiteffect
++;
1639 brick
[i
*10+j
].used
=0;
1640 if (brick
[i
*10+j
].power
!=10)
1641 brick
[i
*10+j
].poweruse
=2;
1643 ball
[k
].x
= ball
[k
].x
*-1;
1646 else if ((ball
[k
].pos_y
+HALFBALL
>= bricky
&&
1647 ball
[k
].pos_y
+HALFBALL
<=
1648 bricky
+BRICK_HEIGHT
) &&
1649 ((brickx
+BRICK_WIDTH
==
1651 (brickx
+BRICK_WIDTH
-6<=
1655 (ball
[k
].x
< 0)) { /* Right line */
1656 if (brick
[i
*10+j
].hits
> 0) {
1657 brick
[i
*10+j
].hits
--;
1658 brick
[i
*10+j
].hiteffect
++;
1662 brick
[i
*10+j
].used
=0;
1663 if (brick
[i
*10+j
].power
!=10)
1664 brick
[i
*10+j
].poweruse
=2;
1667 ball
[k
].x
= ball
[k
].x
*-1;
1670 if (brick
[i
*10+j
].used
==0) {
1681 rb
->lcd_bitmap_part(brickmania_pads
,0,pad_type
*PAD_HEIGHT
,
1682 PAD_WIDTH
,pad_pos_x
, PAD_POS_Y
, PAD_WIDTH
,
1685 for(k
=0;k
<used_balls
;k
++) {
1687 if ((ball
[k
].pos_x
>= pad_pos_x
&&
1688 ball
[k
].pos_x
<= pad_pos_x
+PAD_WIDTH
) &&
1689 (PAD_POS_Y
-4<ball
[k
].pos_y
+BALL
&&
1690 PAD_POS_Y
>ball
[k
].pos_y
+BALL
) && (ball
[k
].y
>0))
1691 ball
[k
].tempy
=PAD_POS_Y
-ball
[k
].pos_y
-BALL
;
1692 else if ((4>ball
[k
].pos_y
&& 0<ball
[k
].pos_y
) &&
1694 ball
[k
].tempy
=-ball
[k
].pos_y
;
1695 if ((LCD_WIDTH
-4<ball
[k
].pos_x
+BALL
&&
1696 LCD_WIDTH
>ball
[k
].pos_x
+BALL
) && (ball
[k
].x
>0))
1697 ball
[k
].tempx
=LCD_WIDTH
-ball
[k
].pos_x
-BALL
;
1698 else if ((4>ball
[k
].pos_x
&& 0<ball
[k
].pos_x
) &&
1700 ball
[k
].tempx
=-ball
[k
].pos_x
;
1703 if (ball
[k
].pos_y
<= 0)
1704 ball
[k
].y
= ball
[k
].y
*-1;
1706 else if (ball
[k
].pos_y
+BALL
>= GAMESCREEN_HEIGHT
) {
1709 ball
[k
].pos_x
= ball
[used_balls
].pos_x
;
1710 ball
[k
].pos_y
= ball
[used_balls
].pos_y
;
1711 ball
[k
].y
= ball
[used_balls
].y
;
1712 ball
[k
].tempy
= ball
[used_balls
].tempy
;
1713 ball
[k
].x
= ball
[used_balls
].x
;
1714 ball
[k
].tempx
= ball
[used_balls
].tempx
;
1715 ball
[k
].glue
= ball
[used_balls
].glue
;
1717 ball
[used_balls
].x
=0;
1718 ball
[used_balls
].y
=0;
1719 ball
[used_balls
].tempy
=0;
1720 ball
[used_balls
].tempx
=0;
1721 ball
[used_balls
].pos_y
=PAD_POS_Y
-BALL
;
1722 ball
[used_balls
].pos_x
=pad_pos_x
+(PAD_WIDTH
/2)-2;
1735 /* left line ,right line */
1736 if ((ball
[k
].pos_x
<= 0) ||
1737 (ball
[k
].pos_x
+BALL
>= LCD_WIDTH
)) {
1738 ball
[k
].x
= ball
[k
].x
*-1;
1739 ball
[k
].pos_x
= ball
[k
].pos_x
<= 0 ? 0 : LCD_WIDTH
-BALL
;
1742 if ((ball
[k
].pos_y
+BALL
>= PAD_POS_Y
&&
1743 (ball
[k
].pos_x
>= pad_pos_x
&&
1744 ball
[k
].pos_x
<= pad_pos_x
+PAD_WIDTH
)) &&
1745 start_game
!= 1 && !ball
[k
].glue
) {
1747 if ((ball
[k
].pos_x
+HALFBALL
>= pad_pos_x
&&
1748 ball
[k
].pos_x
+HALFBALL
<=
1749 pad_pos_x
+(PAD_WIDTH
/2/4)) ||
1750 (ball
[k
].pos_x
+HALFBALL
>=
1751 pad_pos_x
+(PAD_WIDTH
-(PAD_WIDTH
/2/4)) &&
1752 ball
[k
].pos_x
+HALFBALL
<= pad_pos_x
+PAD_WIDTH
)) {
1755 if (ball
[k
].pos_x
!= 0 &&
1756 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1757 ball
[k
].x
= pad_check(6,0,ball
[k
].pos_x
+2<=
1758 pad_pos_x
+(PAD_WIDTH
/2)?
1762 else if ((ball
[k
].pos_x
+HALFBALL
>=
1763 pad_pos_x
+(PAD_WIDTH
/2/4) &&
1764 ball
[k
].pos_x
+HALFBALL
<=
1765 pad_pos_x
+2*(PAD_WIDTH
/2/4)) ||
1766 (ball
[k
].pos_x
+HALFBALL
>=
1767 pad_pos_x
+(PAD_WIDTH
-2*(PAD_WIDTH
/2/4)) &&
1768 ball
[k
].pos_x
+HALFBALL
<=
1769 pad_pos_x
+(PAD_WIDTH
-(PAD_WIDTH
/2/4)) )) {
1772 if (ball
[k
].pos_x
!= 0 &&
1773 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1774 ball
[k
].x
= pad_check(4,0,ball
[k
].pos_x
+2<=
1775 pad_pos_x
+(PAD_WIDTH
/2)?
1779 else if ((ball
[k
].pos_x
+HALFBALL
>=
1780 pad_pos_x
+2*(PAD_WIDTH
/2/4) &&
1781 ball
[k
].pos_x
+HALFBALL
<=
1782 pad_pos_x
+3*(PAD_WIDTH
/2/4)) ||
1784 pad_pos_x
+(PAD_WIDTH
-3*(PAD_WIDTH
/2/4)) &&
1786 pad_pos_x
+ ((PAD_WIDTH
/2)-2*(PAD_WIDTH
/2/4)) )) {
1789 if (ball
[k
].pos_x
!= 0 &&
1790 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1791 ball
[k
].x
= pad_check(3,0,ball
[k
].pos_x
+2<=
1792 pad_pos_x
+(PAD_WIDTH
/2)?
1796 else if ((ball
[k
].pos_x
+HALFBALL
>=
1797 pad_pos_x
+3*(PAD_WIDTH
/2/4) &&
1798 ball
[k
].pos_x
+HALFBALL
<=
1799 pad_pos_x
+4*(PAD_WIDTH
/2/4)-2) ||
1800 (ball
[k
].pos_x
+2 >= pad_pos_x
+(PAD_WIDTH
/2+2) &&
1802 pad_pos_x
+(PAD_WIDTH
-3*(PAD_WIDTH
/2/4)) )) {
1805 if (ball
[k
].pos_x
!= 0 &&
1806 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1807 ball
[k
].x
= pad_check(2,1,0,k
);
1815 if (!ball
[k
].glue
) {
1816 ball
[k
].pos_x
+=ball
[k
].tempx
!=0?ball
[k
].tempx
:ball
[k
].x
;
1817 ball
[k
].pos_y
+=ball
[k
].tempy
!=0?ball
[k
].tempy
:ball
[k
].y
;
1823 if (ball
[k
].pos_y
+5 >= PAD_POS_Y
&&
1824 (pad_type
==1 && !ball
[k
].glue
) &&
1825 (ball
[k
].pos_x
>= pad_pos_x
&&
1826 ball
[k
].pos_x
<= pad_pos_x
+PAD_WIDTH
)) {
1828 ball
[k
].pos_y
=PAD_POS_Y
-BALL
;
1835 if (brick_on_board
< 0) {
1836 if (cur_level
+1<levels_num
) {
1843 rb
->lcd_getstringsize("Congratulations!", &sw
, NULL
);
1844 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_CONGRATS
,
1845 "Congratulations!");
1846 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1847 rb
->lcd_getstringsize("No more levels", &sw
, NULL
);
1848 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_FINISH
,
1851 rb
->lcd_getstringsize("You have finished the game!",
1853 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_FINISH
,
1854 "You have finished the game!");
1858 if (score
>highscore
) {
1861 rb
->splash(HZ
*2, "New High Score");
1867 switch(game_menu(0)) {
1877 if (help(0)==1) return 1;
1886 int move_button
,button
;
1887 int button_right
,button_left
;
1888 button
=rb
->button_get(false);
1890 #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN)
1891 /* FIXME: Should probably check remote hold here */
1892 if (rb
->button_hold())
1896 #ifdef HAVE_TOUCHSCREEN
1897 if(button
& BUTTON_TOUCHSCREEN
)
1899 short touch_x
, touch_y
;
1900 touch_x
= rb
->button_get_data() >> 16;
1901 touch_y
= rb
->button_get_data() & 0xffff;
1902 if(touch_y
>= PAD_POS_Y
&& touch_y
<= PAD_POS_Y
+PAD_HEIGHT
)
1904 pad_pos_x
+= (flip_sides
? -1 : 1) * ( (touch_x
-pad_pos_x
-PAD_WIDTH
/2) / 4 );
1908 else if(pad_pos_x
+PAD_WIDTH
> LCD_WIDTH
)
1909 pad_pos_x
= LCD_WIDTH
-PAD_WIDTH
;
1910 for(k
=0;k
<used_balls
;k
++)
1911 if ((start_game
==1 || ball
[k
].glue
))
1912 ball
[k
].pos_x
= pad_pos_x
+PAD_WIDTH
/2;
1915 if(button
& BUTTON_REL
)
1921 move_button
=rb
->button_status();
1923 button_right
=((move_button
& RIGHT
) || (move_button
& ALTRIGHT
));
1924 button_left
=((move_button
& LEFT
) || (move_button
& ALTLEFT
));
1926 button_right
=((move_button
& RIGHT
) || (SCROLL_FWD(button
)));
1927 button_left
=((move_button
& LEFT
) || (SCROLL_BACK(button
)));
1929 if ((con_game
== 1 && start_game
!=1) && (button_right
|| button_left
))
1931 if ((button_right
&& flip_sides
==false) ||
1932 (button_left
&& flip_sides
==true)) {
1933 if (pad_pos_x
+8+PAD_WIDTH
> LCD_WIDTH
) {
1934 for(k
=0;k
<used_balls
;k
++)
1935 if (start_game
==1 || ball
[k
].glue
)
1936 ball
[k
].pos_x
+=LCD_WIDTH
-pad_pos_x
-PAD_WIDTH
;
1937 pad_pos_x
+=LCD_WIDTH
-pad_pos_x
-PAD_WIDTH
;
1940 for(k
=0;k
<used_balls
;k
++)
1941 if ((start_game
==1 || ball
[k
].glue
))
1946 else if ((button_left
&& flip_sides
==false) ||
1947 (button_right
&& flip_sides
==true)) {
1948 if (pad_pos_x
-8 < 0) {
1949 for(k
=0;k
<used_balls
;k
++)
1950 if (start_game
==1 || ball
[k
].glue
)
1951 ball
[k
].pos_x
-=pad_pos_x
;
1952 pad_pos_x
-=pad_pos_x
;
1955 for(k
=0;k
<used_balls
;k
++)
1956 if (start_game
==1 || ball
[k
].glue
)
1961 #ifdef HAVE_TOUCHSCREEN
1969 if (start_game
==1 && con_game
!=1 && pad_type
!=1) {
1970 for(k
=0;k
<used_balls
;k
++) {
1972 ball
[k
].x
=pad_pos_x
+(PAD_WIDTH
/2)-2>=
1977 else if (pad_type
==1) {
1978 for(k
=0;k
<used_balls
;k
++) {
1981 else if (start_game
==1) {
1987 if (start_game
!=1 && con_game
==1) {
1991 } else if (pad_type
==2 && con_game
!=1) {
1994 fire
[tfire
].top
=PAD_POS_Y
-7;
1995 fire
[tfire
].left
=pad_pos_x
+1;
1997 fire
[tfire
].top
=PAD_POS_Y
-7;
1998 fire
[tfire
].left
=pad_pos_x
+PAD_WIDTH
-1;
1999 } else if (con_game
==1 && start_game
!=1) {
2000 for(k
=0;k
<used_balls
;k
++) {
2011 switch(game_menu(1)) {
2018 for(k
=0;k
<used_balls
;k
++)
2019 if (ball
[k
].x
!=0 && ball
[k
].y
!=0)
2031 for(k
=0;k
<used_balls
;k
++) {
2043 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
2049 #ifdef HAVE_LCD_COLOR
2050 rb
->lcd_bitmap_transparent(brickmania_gameover
,
2051 (LCD_WIDTH
- GAMEOVER_WIDTH
)/2,
2052 (GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2053 GAMEOVER_WIDTH
,GAMEOVER_HEIGHT
);
2054 #else /* greyscale and mono */
2055 rb
->lcd_bitmap(brickmania_gameover
,(LCD_WIDTH
- GAMEOVER_WIDTH
)/2,
2056 (GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
2057 GAMEOVER_WIDTH
,GAMEOVER_HEIGHT
);
2060 if (score
>highscore
) {
2063 rb
->splash(HZ
*2, "New High Score");
2068 for(k
=0;k
<used_balls
;k
++) {
2073 switch(game_menu(0)) {
2091 if (end
> *rb
->current_tick
)
2092 rb
->sleep(end
-*rb
->current_tick
);
2098 /* this is the plugin entry point */
2099 enum plugin_status
plugin_start(const void* parameter
)
2103 rb
->lcd_setfont(FONT_SYSFIXED
);
2105 rb
->lcd_set_backdrop(NULL
);
2107 /* Turn off backlight timeout */
2108 backlight_force_on(); /* backlight control in lib/helper.c */
2110 /* now go ahead and have fun! */
2111 while (game_loop()!=1);
2113 configfile_save(HIGH_SCORE
,config
,1,0);
2115 /* Restore user's original backlight setting */
2116 rb
->lcd_setfont(FONT_UI
);
2117 /* Turn on backlight timeout (revert to settings) */
2118 backlight_use_settings(); /* backlight control in lib/helper.c */