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"
25 #include "lib/display_text.h"
30 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
32 #define QUIT BUTTON_OFF
33 #define LEFT BUTTON_LEFT
34 #define RIGHT BUTTON_RIGHT
35 #define SELECT BUTTON_SELECT
37 #define DOWN BUTTON_DOWN
39 #define RC_QUIT BUTTON_RC_STOP
42 #elif CONFIG_KEYPAD == ONDIO_PAD
44 #define QUIT BUTTON_OFF
45 #define LEFT BUTTON_LEFT
46 #define RIGHT BUTTON_RIGHT
47 #define SELECT BUTTON_MENU
49 #define DOWN BUTTON_DOWN
52 #elif CONFIG_KEYPAD == RECORDER_PAD
54 #define QUIT BUTTON_OFF
55 #define LEFT BUTTON_LEFT
56 #define RIGHT BUTTON_RIGHT
57 #define SELECT BUTTON_PLAY
59 #define DOWN BUTTON_DOWN
62 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
64 #define QUIT BUTTON_OFF
65 #define LEFT BUTTON_LEFT
66 #define RIGHT BUTTON_RIGHT
67 #define SELECT BUTTON_SELECT
69 #define DOWN BUTTON_DOWN
72 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
73 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
74 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
76 #define QUIT BUTTON_MENU
77 #define LEFT BUTTON_LEFT
78 #define RIGHT BUTTON_RIGHT
79 #define SELECT BUTTON_SELECT
80 #define UP BUTTON_SCROLL_BACK
81 #define DOWN BUTTON_SCROLL_FWD
83 #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
84 #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
87 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
89 #define QUIT BUTTON_POWER
90 #define LEFT BUTTON_LEFT
91 #define RIGHT BUTTON_RIGHT
92 #define SELECT BUTTON_SELECT
94 #define DOWN BUTTON_DOWN
97 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
99 #define QUIT BUTTON_POWER
100 #define LEFT BUTTON_LEFT
101 #define RIGHT BUTTON_RIGHT
102 #define SELECT BUTTON_PLAY
104 #define DOWN BUTTON_DOWN
107 #elif (CONFIG_KEYPAD == SANSA_E200_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_FUZE_PAD)
122 #define QUIT (BUTTON_HOME|BUTTON_REPEAT)
123 #define LEFT BUTTON_LEFT
124 #define RIGHT BUTTON_RIGHT
125 #define SELECT BUTTON_SELECT
126 #define UP BUTTON_SCROLL_BACK
127 #define DOWN BUTTON_SCROLL_FWD
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
137 #define QUIT BUTTON_POWER
138 #define LEFT BUTTON_LEFT
139 #define RIGHT BUTTON_RIGHT
140 #define ALTLEFT BUTTON_VOL_DOWN
141 #define ALTRIGHT BUTTON_VOL_UP
142 #define SELECT BUTTON_SELECT
144 #define DOWN BUTTON_DOWN
147 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
149 #define QUIT BUTTON_POWER
150 #define LEFT BUTTON_LEFT
151 #define RIGHT BUTTON_RIGHT
152 #define SELECT BUTTON_PLAY
153 #define UP BUTTON_SCROLL_UP
154 #define DOWN BUTTON_SCROLL_DOWN
156 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
158 #define QUIT BUTTON_BACK
159 #define LEFT BUTTON_LEFT
160 #define RIGHT BUTTON_RIGHT
161 #define SELECT BUTTON_SELECT
163 #define DOWN BUTTON_DOWN
165 #elif (CONFIG_KEYPAD == MROBE100_PAD)
167 #define QUIT BUTTON_POWER
168 #define LEFT BUTTON_LEFT
169 #define RIGHT BUTTON_RIGHT
170 #define SELECT BUTTON_SELECT
172 #define DOWN BUTTON_DOWN
174 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
176 #define QUIT BUTTON_RC_REC
177 #define LEFT BUTTON_RC_REW
178 #define RIGHT BUTTON_RC_FF
179 #define SELECT BUTTON_RC_PLAY
180 #define UP BUTTON_RC_VOL_UP
181 #define DOWN BUTTON_RC_VOL_DOWN
183 #define RC_QUIT BUTTON_REC
185 #elif CONFIG_KEYPAD == COWOND2_PAD
186 #define QUIT BUTTON_POWER
188 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
190 #define QUIT BUTTON_BACK
191 #define LEFT BUTTON_LEFT
192 #define RIGHT BUTTON_RIGHT
193 #define SELECT BUTTON_SELECT
195 #define DOWN BUTTON_DOWN
197 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
199 #define QUIT BUTTON_POWER
200 #define LEFT BUTTON_LEFT
201 #define RIGHT BUTTON_RIGHT
202 #define SELECT BUTTON_SELECT
204 #define DOWN BUTTON_DOWN
206 #elif CONFIG_KEYPAD == ONDAVX747_PAD
207 #define QUIT BUTTON_POWER
208 #define LEFT BUTTON_VOL_DOWN
209 #define RIGHT BUTTON_VOL_UP
210 #define SELECT BUTTON_MENU
212 #elif CONFIG_KEYPAD == MROBE500_PAD
213 #define QUIT BUTTON_POWER
216 #error No keymap defined!
219 #ifdef HAVE_TOUCHSCREEN
221 #define LEFT BUTTON_MIDLEFT
224 #define RIGHT BUTTON_MIDRIGHT
227 #define SELECT BUTTON_CENTER
230 #define UP BUTTON_TOPMIDDLE
233 #define DOWN BUTTON_BOTTOMMIDDLE
237 #ifndef SCROLL_FWD /* targets without scroll wheel*/
238 #define SCROLL_FWD(x) (0)
239 #define SCROLL_BACK(x) (0)
255 #include "pluginbitmaps/brickmania_pads.h"
256 #include "pluginbitmaps/brickmania_bricks.h"
257 #include "pluginbitmaps/brickmania_powerups.h"
258 #include "pluginbitmaps/brickmania_ball.h"
259 #include "pluginbitmaps/brickmania_menu_items.h"
260 #include "pluginbitmaps/brickmania_gameover.h"
262 #define PAD_WIDTH BMPWIDTH_brickmania_pads
263 #define PAD_HEIGHT (BMPHEIGHT_brickmania_pads/3)
264 #define BRICK_HEIGHT (BMPHEIGHT_brickmania_bricks/7)
265 #define BRICK_WIDTH BMPWIDTH_brickmania_bricks
266 #define LEFTMARGIN ((LCD_WIDTH-10*BRICK_WIDTH)/2)
267 #define POWERUP_HEIGHT (BMPHEIGHT_brickmania_powerups/7)
268 #define POWERUP_WIDTH BMPWIDTH_brickmania_powerups
269 #define BALL BMPHEIGHT_brickmania_ball
270 #define HALFBALL ((BALL+1)/2)
271 #define MENU_ITEMXOFS ((LCD_WIDTH - BMPWIDTH_brickmania_menu_items)/2)
272 #define MENU_ITEMHEIGHT (BMPHEIGHT_brickmania_menu_items/9)
273 #define MENU_ITEMWIDTH BMPWIDTH_brickmania_menu_items
274 #define GAMEOVER_WIDTH BMPWIDTH_brickmania_gameover
275 #define GAMEOVER_HEIGHT BMPHEIGHT_brickmania_gameover
277 #if LCD_DEPTH > 1 /* currently no background bmp for mono screens */
278 #include "pluginbitmaps/brickmania_menu_bg.h"
279 #define MENU_BGHEIGHT BMPHEIGHT_brickmania_menu_bg
280 #define MENU_BGWIDTH BMPWIDTH_brickmania_menu_bg
283 #ifdef HAVE_LCD_COLOR /* currently no transparency for non-colour */
284 #include "pluginbitmaps/brickmania_break.h"
287 #if ((LCD_WIDTH == 320) || (LCD_WIDTH == 400)) && (LCD_HEIGHT == 240)
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
297 #define BMPYOFS_start 110
298 #define HIGHSCORE_XPOS 57
299 #define HIGHSCORE_YPOS 88
301 #define STRINGPOS_FINISH 140
302 #define STRINGPOS_CONGRATS 157
303 #define STRINGPOS_NAVI 150
304 #define STRINGPOS_FLIP 150
306 #elif (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176)
308 /* The time (in ms) for one iteration through the game loop - decrease this
309 to speed up the game - note that current_tick is (currently) only accurate
314 /* Offsets for LCDS > 220x176 */
316 #define GAMESCREEN_HEIGHT 176
319 #define XOFS ((LCD_WIDTH-220)/BRICK_WIDTH/2)*BRICK_WIDTH
320 #define YOFS ((LCD_HEIGHT-176)/BRICK_HEIGHT/2)*BRICK_HEIGHT
322 #define BMPYOFS_start (78+YOFS)
323 #define HIGHSCORE_XPOS (17+XOFS)
324 #define HIGHSCORE_YPOS (56+YOFS)
326 #define STRINGPOS_FINISH 140
327 #define STRINGPOS_CONGRATS 157
328 #define STRINGPOS_NAVI 150
329 #define STRINGPOS_FLIP 150
331 #elif (LCD_WIDTH == 160) && (LCD_HEIGHT == 128)
332 /* The time (in ms) for one iteration through the game loop - decrease this
333 to speed up the game - note that current_tick is (currently) only accurate
341 #define BMPYOFS_start 58
343 #define BMPYOFS_start 66
345 #define HIGHSCORE_XPOS 10
346 #define HIGHSCORE_YPOS 38
348 #define STRINGPOS_FINISH 110
349 #define STRINGPOS_CONGRATS 100
350 #define STRINGPOS_NAVI 100
351 #define STRINGPOS_FLIP 100
353 #elif (LCD_WIDTH == 132) && (LCD_HEIGHT == 80)
355 /* The time (in ms) for one iteration through the game loop - decrease this
356 to speed up the game - note that current_tick is (currently) only accurate
363 #define BMPYOFS_start 30
364 #define HIGHSCORE_XPOS 68
365 #define HIGHSCORE_YPOS 8
367 #define STRINGPOS_FINISH 55
368 #define STRINGPOS_CONGRATS 45
369 #define STRINGPOS_NAVI 60
370 #define STRINGPOS_FLIP 60
372 #elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 128)
374 /* The time (in ms) for one iteration through the game loop - decrease this
375 to speed up the game - note that current_tick is (currently) only accurate
380 #define GAMESCREEN_HEIGHT 100
383 #define BMPYOFS_start 70
384 #define HIGHSCORE_XPOS 8
385 #define HIGHSCORE_YPOS 36
387 #define STRINGPOS_FINISH 55
388 #define STRINGPOS_CONGRATS 45
389 #define STRINGPOS_NAVI 60
390 #define STRINGPOS_FLIP 60
393 #elif (LCD_WIDTH == 138) && (LCD_HEIGHT == 110)
394 /* The time (in ms) for one iteration through the game loop - decrease this
395 to speed up the game - note that current_tick is (currently) only accurate
402 #define BMPYOFS_start 51
403 #define HIGHSCORE_XPOS 73
404 #define HIGHSCORE_YPOS 25
406 #define STRINGPOS_FINISH 54
407 #define STRINGPOS_CONGRATS 44
408 #define STRINGPOS_NAVI 44
409 #define STRINGPOS_FLIP 44
412 #elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 96)
413 /* The time (in ms) for one iteration through the game loop - decrease this
414 to speed up the game - note that current_tick is (currently) only accurate
421 #define BMPYOFS_start 42
422 #define HIGHSCORE_XPOS 65
423 #define HIGHSCORE_YPOS 25
425 #define STRINGPOS_FINISH 54
426 #define STRINGPOS_CONGRATS 44
427 #define STRINGPOS_NAVI 44
428 #define STRINGPOS_FLIP 44
430 /* Archos / Sansa Clip / Sansa m200 */
431 #elif ((LCD_WIDTH == 112) | (LCD_WIDTH == 128)) && (LCD_HEIGHT == 64)
432 /* The time (in ms) for one iteration through the game loop - decrease this
433 to speed up the game - note that current_tick is (currently) only accurate
440 #define BMPYOFS_start 22
441 #define HIGHSCORE_XPOS 0
442 #define HIGHSCORE_YPOS 0
444 #define STRINGPOS_FINISH 54
445 #define STRINGPOS_CONGRATS 44
446 #define STRINGPOS_NAVI 44
447 #define STRINGPOS_FLIP 44
450 #elif (LCD_WIDTH == 176) && (LCD_HEIGHT >= 132) && (LCD_DEPTH==16)
451 /* The time (in ms) for one iteration through the game loop - decrease this
452 to speed up the game - note that current_tick is (currently) only accurate
458 #define GAMESCREEN_HEIGHT 132
461 #define BMPYOFS_start 58
462 #define HIGHSCORE_XPOS 7
463 #define HIGHSCORE_YPOS 36
465 #define STRINGPOS_FINISH 110
466 #define STRINGPOS_CONGRATS 110
467 #define STRINGPOS_NAVI 100
468 #define STRINGPOS_FLIP 100
471 #error Unsupported LCD Size
475 #ifndef GAMESCREEN_HEIGHT
476 #define GAMESCREEN_HEIGHT LCD_HEIGHT
479 /* calculate menu item offsets from the first defined and the height*/
480 #define BMPYOFS_resume (BMPYOFS_start + MENU_ITEMHEIGHT)
481 #define BMPYOFS_help (BMPYOFS_start + 2*MENU_ITEMHEIGHT)
482 #define BMPYOFS_quit (BMPYOFS_start + 3*MENU_ITEMHEIGHT)
484 /*calculate paddle y-position */
485 #if GAMESCREEN_HEIGHT >= 128
486 #define PAD_POS_Y GAMESCREEN_HEIGHT -PAD_HEIGHT - 2
488 #define PAD_POS_Y GAMESCREEN_HEIGHT -PAD_HEIGHT - 1
492 #ifdef HAVE_TOUCHSCREEN
493 #include "lib/touchscreen.h"
495 static struct ts_mapping main_menu_items
[4] =
497 {MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
},
498 {MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
},
499 {MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
},
500 {MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
, MENU_ITEMHEIGHT
}
502 static struct ts_mappings main_menu
= {main_menu_items
, 4};
508 static unsigned char levels
[29][8][10] = {
510 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
511 {0x2,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x2},
512 {0x0,0x2,0x1,0x0,0x0,0x0,0x0,0x1,0x2,0x0},
513 {0x0,0x0,0x2,0x1,0x0,0x0,0x1,0x2,0x0,0x0},
514 {0x0,0x0,0x0,0x2,0x1,0x1,0x2,0x0,0x0,0x0},
515 {0x7,0x0,0x0,0x7,0x2,0x2,0x7,0x0,0x0,0x7},
516 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
517 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
520 {0x0,0x0,0x7,0x7,0x1,0x1,0x7,0x7,0x0,0x0},
521 {0x0,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x0},
522 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
523 {0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1},
524 {0x1,0x1,0x2,0x1,0x0,0x0,0x1,0x2,0x1,0x1},
525 {0x1,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x2,0x1},
526 {0x0,0x1,0x2,0x0,0x0,0x0,0x0,0x2,0x1,0x0},
527 {0x0,0x0,0x1,0x2,0x2,0x2,0x2,0x1,0x0,0x0}
530 {0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
531 {0x3,0x23,0x23,0x3,0x0,0x0,0x2,0x22,0x22,0x2},
532 {0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
533 {0x0,0x0,0x0,0x0,0x37,0x37,0x0,0x0,0x0,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0x1,0x0,0x1,0x1,0x0,0x1,0x2,0x2}
679 {/* level 18 (Tetris) by ts-x */
680 {0x0,0x2,0x0,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
681 {0x0,0x2,0x7,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
682 {0x2,0x2,0x7,0x0,0x3,0x4,0x0,0x6,0x2,0x2},
683 {0x2,0x2,0x7,0x7,0x3,0x4,0x0,0x6,0x2,0x2},
684 {0x2,0x1,0x7,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
685 {0x2,0x1,0x0,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
686 {0x1,0x1,0x1,0x7,0x3,0x0,0x6,0x6,0x5,0x5},
687 {0x1,0x1,0x1,0x0,0x3,0x0,0x6,0x6,0x5,0x5}
689 { /* level 19 (Stalactites) by ts-x */
690 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
691 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
692 {0x5,0x0,0x6,0x3,0x4,0x7,0x5,0x0,0x1,0x2},
693 {0x5,0x2,0x6,0x3,0x4,0x0,0x5,0x3,0x1,0x2},
694 {0x5,0x0,0x6,0x0,0x4,0x7,0x5,0x0,0x1,0x0},
695 {0x5,0x0,0x0,0x3,0x4,0x0,0x0,0x0,0x1,0x2},
696 {0x0,0x0,0x6,0x0,0x0,0x0,0x5,0x0,0x0,0x0},
697 {0x5,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x1,0x0}
699 { /* level 20 (Maze) by ts-x */
700 {0x1,0x1,0x21,0x1,0x1,0x1,0x1,0x1,0x1,0x21},
701 {0x1,0x0,0x0,0x3,0x0,0x0,0x3,0x1,0x31,0x1},
702 {0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x0,0x1},
703 {0x21,0x0,0x21,0x3,0x0,0x3,0x0,0x3,0x0,0x2},
704 {0x1,0x0,0x1,0x21,0x0,0x12,0x0,0x0,0x0,0x0},
705 {0x31,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x3,0x0},
706 {0x1,0x0,0x1,0x0,0x1,0x1,0x31,0x1,0x1,0x2},
707 {0x22,0x0,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x21}
709 { /* level 21 (Dentist) by ts-x */
710 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0},
711 {0x2,0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x2,0x2},
712 {0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x2},
713 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x2},
714 {0x2,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x0,0x2},
715 {0x2,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x2},
716 {0x2,0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x2,0x2},
717 {0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0}
719 { /* level 22 (Spider) by ts-x */
720 {0x31,0x3,0x1,0x1,0x0,0x0,0x1,0x1,0x3,0x31},
721 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
722 {0x33,0x1,0x1,0x36,0x1,0x1,0x36,0x1,0x1,0x33},
723 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
724 {0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x0,0x0},
725 {0x21,0x3,0x1,0x21,0x2,0x2,0x21,0x1,0x3,0x21},
726 {0x0,0x0,0x0,0x1,0x21,0x1,0x1,0x0,0x0,0x0},
727 {0x3,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x3}
729 { /* level 23 (Pool) by ts-x */
730 {0x0,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x7,0x0},
731 {0x0,0x0,0x5,0x0,0x2,0x0,0x0,0x0,0x2,0x0},
732 {0x7,0x3,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x7},
733 {0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x5,0x0,0x7},
734 {0x7,0x0,0x4,0x0,0x0,0x3,0x0,0x0,0x0,0x7},
735 {0x7,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x4,0x7},
736 {0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
737 {0x0,0x7,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x0}
739 { /* level 24 (Vorbis Fish) by ts-x */
740 {0x0,0x0,0x4,0x4,0x5,0x5,0x5,0x0,0x0,0x5},
741 {0x0,0x4,0x6,0x4,0x4,0x5,0x5,0x5,0x0,0x5},
742 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x5,0x5,0x5},
743 {0x5,0x6,0x0,0x6,0x4,0x4,0x4,0x4,0x5,0x5},
744 {0x0,0x5,0x6,0x4,0x4,0x5,0x5,0x4,0x5,0x0},
745 {0x5,0x5,0x4,0x4,0x5,0x5,0x5,0x4,0x5,0x5},
746 {0x5,0x4,0x4,0x4,0x5,0x5,0x4,0x4,0x5,0x5},
747 {0x0,0x0,0x4,0x4,0x4,0x4,0x4,0x5,0x0,0x5}
749 {/* level 25 (Rainbow) by ts-x */
750 {0x0,0x4,0x1,0x0,0x0,0x0,0x0,0x1,0x4,0x0},
751 {0x24,0x1,0x3,0x1,0x0,0x0,0x21,0x3,0x1,0x24},
752 {0x1,0x23,0x5,0x3,0x1,0x21,0x3,0x5,0x3,0x21},
753 {0x3,0x5,0x6,0x5,0x3,0x3,0x5,0x6,0x5,0x3},
754 {0x5,0x6,0x7,0x6,0x5,0x5,0x6,0x7,0x6,0x5},
755 {0x6,0x7,0x2,0x27,0x6,0x6,0x27,0x2,0x7,0x6},
756 {0x7,0x2,0x0,0x2,0x27,0x27,0x2,0x0,0x2,0x7},
757 {0x32,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x32}
759 { /* level 26 (Bowtie) by ts-x */
760 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5},
761 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
762 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
763 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
764 {0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
765 {0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
766 {0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
767 {0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5}
769 { /* level 27 (Frog) by ts-x */
770 {0x0,0x5,0x25,0x0,0x0,0x0,0x0,0x25,0x5,0x0},
771 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
772 {0x25,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x25},
773 {0x5,0x0,0x3,0x0,0x6,0x6,0x0,0x3,0x0,0x5},
774 {0x5,0x0,0x31,0x0,0x6,0x6,0x0,0x31,0x0,0x5},
775 {0x5,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x5},
776 {0x5,0x5,0x5,0x35,0x0,0x0,0x35,0x5,0x5,0x5},
777 {0x0,0x25,0x5,0x0,0x4,0x4,0x0,0x5,0x25,0x0}
779 { /* level 28 (DigDug) by ts-x */
780 {0x35,0x5,0x5,0x25,0x0,0x25,0x25,0x5,0x5,0x35},
781 {0x6,0x0,0x0,0x6,0x0,0x6,0x6,0x0,0x0,0x6},
782 {0x7,0x0,0x37,0x37,0x0,0x37,0x37,0x7,0x0,0x7},
783 {0x7,0x0,0x7,0x0,0x0,0x0,0x7,0x7,0x7,0x7},
784 {0x4,0x4,0x4,0x24,0x0,0x24,0x4,0x0,0x0,0x4},
785 {0x4,0x4,0x0,0x0,0x0,0x4,0x4,0x0,0x4,0x4},
786 {0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4},
787 {0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1}
790 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
791 {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0},
792 {0x22,0x0,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0},
793 {0x22,0x22,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0},
794 {0x22,0x22,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0},
795 {0x22,0x0,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0},
796 {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0},
797 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
803 int x
[MAX_BALLS
],y
[MAX_BALLS
];
805 int start_game
,con_game
;
807 int score
=0,vscore
=0;
808 bool flip_sides
=false;
810 int brick_on_board
=0;
813 typedef struct cube
{
824 typedef struct balls
{
834 balls ball
[MAX_BALLS
];
836 typedef struct sfire
{
844 #define MAX_POINTS 200000 /* i dont think it needs to be more */
845 static struct configdata config
[] =
847 {TYPE_INT
, 0, MAX_POINTS
, { .int_p
= &highscore
}, "highscore", NULL
}
850 void int_game(int new_game
)
854 pad_pos_x
=LCD_WIDTH
/2-PAD_WIDTH
/2;
856 for(i
=0;i
<MAX_BALLS
;i
++) {
861 ball
[i
].pos_y
=PAD_POS_Y
-BALL
;
862 ball
[i
].pos_x
=pad_pos_x
+(PAD_WIDTH
/2)-2;
878 brick
[i
*10+j
].poweruse
=(levels
[cur_level
][i
][j
]==0?0:1);
882 brick
[i
*10+j
].power
=rb
->rand()%25;
883 /* +8 make the game with less powerups */
885 brick
[i
*10+j
].hits
=levels
[cur_level
][i
][j
]>=10?
886 levels
[cur_level
][i
][j
]/16-1:0;
887 brick
[i
*10+j
].hiteffect
=0;
888 brick
[i
*10+j
].powertop
=TOPMARGIN
+i
*BRICK_HEIGHT
+BRICK_HEIGHT
;
889 brick
[i
*10+j
].used
=(levels
[cur_level
][i
][j
]==0?0:1);
890 brick
[i
*10+j
].color
=(levels
[cur_level
][i
][j
]>=10?
891 levels
[cur_level
][i
][j
]%16:
892 levels
[cur_level
][i
][j
])-1;
893 if (levels
[cur_level
][i
][j
]!=0)
902 /* sleep timer counting the score */
903 void sleep (int secs
)
913 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
914 rb
->lcd_getstringsize(s
, &sw
, &w
);
915 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
916 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
918 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 2, s
);
920 rb
->lcd_update_rect(0,0,LCD_WIDTH
,w
+2);
923 count
=*rb
->current_tick
+HZ
*secs
;
924 if (*rb
->current_tick
>=count
)
932 #define HIGH_SCORE "brickmania.score"
933 #define MENU_LENGTH 4
934 int game_menu(int when
)
938 rb
->lcd_clear_display();
939 #if LCD_DEPTH > 1 /* currently no background bmp for mono screens */
940 rb
->lcd_bitmap(brickmania_menu_bg
, 0, 0, MENU_BGWIDTH
, MENU_BGHEIGHT
);
943 for(i
=0;i
<MENU_LENGTH
;i
++) {
944 #ifdef HAVE_LCD_COLOR
946 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
947 MENU_ITEMHEIGHT
* BM_SEL_START
, MENU_ITEMWIDTH
,
948 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
951 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
952 MENU_ITEMHEIGHT
* BM_START
, MENU_ITEMWIDTH
,
953 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
958 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
959 MENU_ITEMHEIGHT
* BM_SEL_RESUME
, MENU_ITEMWIDTH
,
960 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
963 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
964 MENU_ITEMHEIGHT
* BM_RESUME
, MENU_ITEMWIDTH
,
965 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
969 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
970 MENU_ITEMHEIGHT
* BM_NO_RESUME
, MENU_ITEMWIDTH
,
971 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
977 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
978 MENU_ITEMHEIGHT
* BM_SEL_HELP
, MENU_ITEMWIDTH
,
979 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
982 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
983 MENU_ITEMHEIGHT
* BM_HELP
, MENU_ITEMWIDTH
,
984 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
988 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
989 MENU_ITEMHEIGHT
* BM_SEL_QUIT
, MENU_ITEMWIDTH
,
990 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
993 rb
->lcd_bitmap_transparent_part(brickmania_menu_items
, 0,
994 MENU_ITEMHEIGHT
* BM_QUIT
, MENU_ITEMWIDTH
,
995 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
999 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1000 MENU_ITEMHEIGHT
* BM_SEL_START
, MENU_ITEMWIDTH
,
1001 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
1004 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1005 MENU_ITEMHEIGHT
* BM_START
, MENU_ITEMWIDTH
,
1006 MENU_ITEMXOFS
, BMPYOFS_start
, MENU_ITEMWIDTH
,
1011 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1012 MENU_ITEMHEIGHT
* BM_SEL_RESUME
, MENU_ITEMWIDTH
,
1013 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
1016 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1017 MENU_ITEMHEIGHT
* BM_RESUME
, MENU_ITEMWIDTH
,
1018 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
1022 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1023 MENU_ITEMHEIGHT
* BM_NO_RESUME
, MENU_ITEMWIDTH
,
1024 MENU_ITEMXOFS
, BMPYOFS_resume
, MENU_ITEMWIDTH
,
1030 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1031 MENU_ITEMHEIGHT
* BM_SEL_HELP
, MENU_ITEMWIDTH
,
1032 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
1035 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1036 MENU_ITEMHEIGHT
* BM_HELP
, MENU_ITEMWIDTH
,
1037 MENU_ITEMXOFS
, BMPYOFS_help
, MENU_ITEMWIDTH
,
1041 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1042 MENU_ITEMHEIGHT
* BM_SEL_QUIT
, MENU_ITEMWIDTH
,
1043 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
1046 rb
->lcd_bitmap_part(brickmania_menu_items
, 0,
1047 MENU_ITEMHEIGHT
* BM_QUIT
, MENU_ITEMWIDTH
,
1048 MENU_ITEMXOFS
, BMPYOFS_quit
, MENU_ITEMWIDTH
,
1052 rb
->lcd_set_drawmode(DRMODE_FG
);
1054 #ifdef HAVE_LCD_COLOR
1055 rb
->lcd_set_background(LCD_RGBPACK(0,0,140));
1056 rb
->lcd_set_foreground(LCD_WHITE
);
1058 rb
->lcd_putsxy(HIGHSCORE_XPOS
, HIGHSCORE_YPOS
, "High Score");
1059 rb
->snprintf(str
, sizeof(str
), "%d", highscore
);
1060 rb
->lcd_getstringsize("High Score", &sw
, NULL
);
1061 rb
->lcd_getstringsize(str
, &w
, NULL
);
1062 rb
->lcd_putsxy(HIGHSCORE_XPOS
+sw
/2-w
/2, HIGHSCORE_YPOS
+9, str
);
1063 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1067 button
= rb
->button_get(true);
1068 #ifdef HAVE_TOUCHSCREEN
1069 if(button
& BUTTON_TOUCHSCREEN
)
1071 unsigned int result
= touchscreen_map(&main_menu
, rb
->button_get_data() >> 16, rb
->button_get_data() & 0xffff);
1072 if(result
!= (unsigned)-1 && button
& BUTTON_REL
)
1074 if(cur
== (signed)result
)
1082 case UP
| BUTTON_REPEAT
:
1084 cur
= MENU_LENGTH
-1;
1087 if (when
==0 && cur
==1) {
1093 case DOWN
| BUTTON_REPEAT
:
1094 if (cur
==MENU_LENGTH
-1)
1098 if (when
==0 && cur
==1) {
1109 } else if (cur
==1 && when
==1) {
1111 } else if (cur
==2) {
1113 } else if (cur
==3) {
1125 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
1137 #define WORDS (sizeof help_text / sizeof (char*))
1138 static char* help_text
[] = {
1139 "BrickMania", "", "Aim", "",
1140 "Destroy", "all", "the", "bricks", "by", "bouncing",
1141 "the", "ball", "of", "them", "using", "the", "paddle.", "", "",
1143 "< & >", "Move", "the", "paddle", "",
1144 #if CONFIG_KEYPAD == ONDIO_PAD
1146 #elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1148 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
1153 "Releases", "the", "ball/", "Fire!", "",
1154 #if CONFIG_KEYPAD == IAUDIO_M3_PAD
1156 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
1157 (CONFIG_KEYPAD == CREATIVEZVM_PAD)
1159 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
1160 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
1161 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
1163 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
1164 (CONFIG_KEYPAD == IRIVER_H300_PAD) || \
1165 (CONFIG_KEYPAD == ONDIO_PAD) || \
1166 (CONFIG_KEYPAD == RECORDER_PAD) || \
1167 (CONFIG_KEYPAD == ARCHOS_AV300_PAD)
1172 "Opens", "menu/", "Quit", "", "",
1174 "N", "Normal:", "returns", "paddle", "to", "normal", "",
1175 "D", "DIE!:", "loses", "a", "life", "",
1176 "L", "Life:", "gains", "a", "life/", "power", "up", "",
1177 "F", "Fire:", "allows", "you", "to", "shoot", "bricks", "",
1178 "G", "Glue:", "ball", "sticks", "to", "paddle", "",
1179 "B", "Ball:", "generates", "another", "ball", "",
1180 "FL", "Flip:", "flips", "left /", "right", "movement",
1182 static struct style_text formation
[]={
1183 { 0, TEXT_CENTER
|TEXT_UNDERLINE
},
1197 #ifdef HAVE_LCD_COLOR
1198 rb
->lcd_set_background(LCD_BLACK
);
1199 rb
->lcd_set_foreground(LCD_WHITE
);
1202 rb
->lcd_setfont(FONT_UI
);
1203 if (display_text(WORDS
, help_text
, formation
, NULL
))
1206 button
= rb
->button_get(true);
1207 if ( rb
->default_event_handler( button
) == SYS_USB_CONNECTED
)
1209 } while( ( button
== BUTTON_NONE
)
1210 || ( button
& (BUTTON_REL
|BUTTON_REPEAT
) ) );
1211 rb
->lcd_setfont(FONT_SYSFIXED
);
1215 int pad_check(int ballxc
, int mode
, int pon
,int ballnum
)
1217 /* pon: positive(1) or negative(0) */
1225 if (ball
[ballnum
].x
> 0)
1232 int fire_space(void)
1236 if (fire
[t
].top
+7 < 0)
1244 int j
,i
,k
,bricky
,brickx
;
1246 int sec_count
=0,num_count
=10;
1249 switch(game_menu(0)) {
1267 /* Convert CYCLETIME (in ms) to HZ */
1268 end
= *rb
->current_tick
+ (CYCLETIME
* HZ
) / 1000;
1271 #ifdef HAVE_LCD_COLOR
1272 rb
->lcd_set_background(LCD_BLACK
);
1273 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1274 rb
->lcd_clear_display();
1275 rb
->lcd_set_background(LCD_BLACK
);
1276 #if LCD_HEIGHT > GAMESCREEN_HEIGHT
1277 rb
->lcd_set_foreground(rb
->global_settings
->bg_color
);
1278 rb
->lcd_fillrect(0, GAMESCREEN_HEIGHT
, LCD_WIDTH
,
1279 LCD_HEIGHT
- GAMESCREEN_HEIGHT
);
1281 rb
->lcd_set_foreground(LCD_WHITE
);
1283 rb
->lcd_clear_display();
1287 if (*rb
->current_tick
>=sec_count
) {
1288 sec_count
=*rb
->current_tick
+HZ
;
1294 rb
->snprintf(s
, sizeof(s
), "%d", num_count
);
1295 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1296 rb
->lcd_putsxy(LCD_WIDTH
/2-2, STRINGPOS_FLIP
, s
);
1299 /* write life num */
1300 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1301 rb
->snprintf(s
, sizeof(s
), "L:%d", life
);
1302 rb
->lcd_putsxy(0, 0, s
);
1304 rb
->snprintf(s
, sizeof(s
), "Life: %d", life
);
1305 rb
->lcd_putsxy(2, 2, s
);
1308 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1309 rb
->snprintf(s
, sizeof(s
), "L%d", cur_level
+1);
1310 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1311 rb
->lcd_putsxy(LCD_WIDTH
-sw
, 0, s
);
1313 rb
->snprintf(s
, sizeof(s
), "Level %d", cur_level
+1);
1314 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1315 rb
->lcd_putsxy(LCD_WIDTH
-sw
-2, 2, s
);
1318 if (vscore
<score
) vscore
++;
1319 rb
->snprintf(s
, sizeof(s
), "%d", vscore
);
1320 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1321 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1322 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 0, s
);
1324 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, 2, s
);
1328 if (con_game
== 1 && start_game
!=1) {
1329 #if CONFIG_KEYPAD == ONDIO_PAD
1330 rb
->snprintf(s
, sizeof(s
), "MENU To Continue");
1331 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
1332 rb
->snprintf(s
, sizeof(s
), "Press NAVI To Continue");
1333 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
1334 rb
->snprintf(s
, sizeof(s
), "PLAY To Continue");
1336 rb
->snprintf(s
, sizeof(s
), "Press SELECT To Continue");
1338 rb
->lcd_getstringsize(s
, &sw
, NULL
);
1339 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_NAVI
, s
);
1341 sec_count
=*rb
->current_tick
+HZ
;
1345 for(i
=0;i
<used_balls
;i
++)
1346 rb
->lcd_bitmap(brickmania_ball
,ball
[i
].pos_x
, ball
[i
].pos_y
,
1349 if (brick_on_board
==0)
1352 /* if the pad is fire */
1353 for(i
=0;i
<=30;i
++) {
1354 if (fire
[i
].top
+7>0) {
1357 rb
->lcd_vline(fire
[i
].left
, fire
[i
].top
, fire
[i
].top
+7);
1362 for (i
=0;i
<=7;i
++) {
1363 for (j
=0;j
<=9;j
++) {
1364 if (brick
[i
*10+j
].power
<7) {
1365 if (brick
[i
*10+j
].poweruse
==2) {
1367 brick
[i
*10+j
].powertop
+=2;
1368 rb
->lcd_bitmap_part(brickmania_powerups
,0,
1369 POWERUP_HEIGHT
*brick
[i
*10+j
1372 LEFTMARGIN
+j
*BRICK_WIDTH
+
1375 brick
[i
*10+j
].powertop
,
1381 if ((pad_pos_x
<LEFTMARGIN
+j
*BRICK_WIDTH
+5 &&
1382 pad_pos_x
+PAD_WIDTH
>LEFTMARGIN
+j
*BRICK_WIDTH
+5) &&
1383 brick
[i
*10+j
].powertop
+6>=PAD_POS_Y
&&
1384 brick
[i
*10+j
].poweruse
==2) {
1385 switch(brick
[i
*10+j
].power
) {
1404 for(k
=0;k
<used_balls
;k
++)
1410 for(k
=0;k
<used_balls
;k
++)
1416 sec_count
=*rb
->current_tick
+HZ
;
1418 flip_sides
=!flip_sides
;
1423 ball
[used_balls
-1].x
= rb
->rand()%1 == 0 ?
1425 ball
[used_balls
-1].y
= -4;
1428 brick
[i
*10+j
].poweruse
=1;
1431 if (brick
[i
*10+j
].powertop
>PAD_POS_Y
)
1432 brick
[i
*10+j
].poweruse
=1;
1434 brickx
=LEFTMARGIN
+j
*BRICK_WIDTH
;
1435 bricky
=TOPMARGIN
+i
*BRICK_HEIGHT
;
1437 for (k
=0;k
<=30;k
++) {
1438 if (fire
[k
].top
+7>0) {
1439 if (brick
[i
*10+j
].used
==1 &&
1440 (fire
[k
].left
+1 >= brickx
&&
1441 fire
[k
].left
+1 <= brickx
+BRICK_WIDTH
) &&
1442 (bricky
+BRICK_HEIGHT
>fire
[k
].top
)) {
1445 if (brick
[i
*10+j
].hits
> 0) {
1446 brick
[i
*10+j
].hits
--;
1447 brick
[i
*10+j
].hiteffect
++;
1451 brick
[i
*10+j
].used
=0;
1452 if (brick
[i
*10+j
].power
!=10)
1453 brick
[i
*10+j
].poweruse
=2;
1461 if (brick
[i
*10+j
].used
==1) {
1462 rb
->lcd_bitmap_part(brickmania_bricks
,0,
1463 BRICK_HEIGHT
*brick
[i
*10+j
].color
,
1465 LEFTMARGIN
+j
*BRICK_WIDTH
,
1466 TOPMARGIN
+i
*BRICK_HEIGHT
,
1467 BRICK_WIDTH
, BRICK_HEIGHT
);
1468 #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
1469 if (brick
[i
*10+j
].hiteffect
>0)
1470 rb
->lcd_bitmap_transparent_part(brickmania_break
,
1472 BRICK_HEIGHT
*brick
[i
*10+j
].hiteffect
,
1474 LEFTMARGIN
+j
*BRICK_WIDTH
,
1475 TOPMARGIN
+i
*BRICK_HEIGHT
,
1481 for(k
=0;k
<used_balls
;k
++) {
1482 if (ball
[k
].pos_y
<160) {
1483 if (brick
[i
*10+j
].used
==1) {
1484 if ((ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
>=
1486 ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
<=
1487 brickx
+BRICK_WIDTH
) &&
1488 ((bricky
-4<ball
[k
].pos_y
+BALL
&&
1489 bricky
>ball
[k
].pos_y
+BALL
) ||
1490 (bricky
+4>ball
[k
].pos_y
+BALL
+BALL
&&
1491 bricky
<ball
[k
].pos_y
+BALL
+BALL
)) &&
1493 ball
[k
].tempy
=bricky
-ball
[k
].pos_y
-BALL
;
1495 else if ((ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
>=
1497 ball
[k
].pos_x
+ball
[k
].x
+HALFBALL
<=
1498 brickx
+BRICK_WIDTH
) &&
1499 ((bricky
+BRICK_HEIGHT
+4>ball
[k
].pos_y
&&
1500 bricky
+BRICK_HEIGHT
<ball
[k
].pos_y
) ||
1501 (bricky
+BRICK_HEIGHT
-4<ball
[k
].pos_y
-BALL
&&
1502 bricky
+BRICK_HEIGHT
>ball
[k
].pos_y
-BALL
)) &&
1505 -(ball
[k
].pos_y
-(bricky
+BRICK_HEIGHT
));
1508 if ((ball
[k
].pos_y
+HALFBALL
>=
1510 ball
[k
].pos_y
+HALFBALL
<=
1511 bricky
+BRICK_HEIGHT
) &&
1512 ((brickx
-4<ball
[k
].pos_x
+BALL
&&
1513 brickx
>ball
[k
].pos_x
+BALL
) ||
1514 (brickx
+4>ball
[k
].pos_x
+BALL
+BALL
&&
1515 brickx
<ball
[k
].pos_x
+BALL
+BALL
)) &&
1517 ball
[k
].tempx
=brickx
-ball
[k
].pos_x
-BALL
;
1519 else if ((ball
[k
].pos_y
+ball
[k
].y
+HALFBALL
>=
1521 ball
[k
].pos_y
+ball
[k
].y
+HALFBALL
<=
1522 bricky
+BRICK_HEIGHT
) &&
1523 ((brickx
+BRICK_WIDTH
+4>ball
[k
].pos_x
&&
1524 brickx
+BRICK_WIDTH
<ball
[k
].pos_x
) ||
1525 (brickx
+BRICK_WIDTH
-4<ball
[k
].pos_x
-
1527 brickx
+BRICK_WIDTH
>ball
[k
].pos_x
-
1528 BALL
)) && (ball
[k
].x
<0)) {
1530 -(ball
[k
].pos_x
-(brickx
+BRICK_WIDTH
));
1533 if ((ball
[k
].pos_x
+HALFBALL
>= brickx
&&
1534 ball
[k
].pos_x
+HALFBALL
<=
1535 brickx
+BRICK_WIDTH
) &&
1536 ((bricky
+BRICK_HEIGHT
==ball
[k
].pos_y
) ||
1537 (bricky
+BRICK_HEIGHT
-6<=ball
[k
].pos_y
&&
1538 bricky
+BRICK_HEIGHT
>ball
[k
].pos_y
)) &&
1539 (ball
[k
].y
<0)) { /* bottom line */
1540 if (brick
[i
*10+j
].hits
> 0) {
1541 brick
[i
*10+j
].hits
--;
1542 brick
[i
*10+j
].hiteffect
++;
1546 brick
[i
*10+j
].used
=0;
1547 if (brick
[i
*10+j
].power
!=10)
1548 brick
[i
*10+j
].poweruse
=2;
1551 ball
[k
].y
= ball
[k
].y
*-1;
1553 else if ((ball
[k
].pos_x
+HALFBALL
>= brickx
&&
1554 ball
[k
].pos_x
+HALFBALL
<=
1555 brickx
+BRICK_WIDTH
) &&
1556 ((bricky
==ball
[k
].pos_y
+BALL
) ||
1557 (bricky
+6>=ball
[k
].pos_y
+BALL
&&
1558 bricky
<ball
[k
].pos_y
+BALL
)) &&
1559 (ball
[k
].y
>0)) { /* top line */
1560 if (brick
[i
*10+j
].hits
> 0) {
1561 brick
[i
*10+j
].hits
--;
1562 brick
[i
*10+j
].hiteffect
++;
1566 brick
[i
*10+j
].used
=0;
1567 if (brick
[i
*10+j
].power
!=10)
1568 brick
[i
*10+j
].poweruse
=2;
1571 ball
[k
].y
= ball
[k
].y
*-1;
1574 if ((ball
[k
].pos_y
+HALFBALL
>= bricky
&&
1575 ball
[k
].pos_y
+HALFBALL
<=
1576 bricky
+BRICK_HEIGHT
) &&
1577 ((brickx
==ball
[k
].pos_x
+BALL
) ||
1578 (brickx
+6>=ball
[k
].pos_x
+BALL
&&
1579 brickx
<ball
[k
].pos_x
+BALL
)) &&
1580 (ball
[k
].x
> 0)) { /* left line */
1581 if (brick
[i
*10+j
].hits
> 0) {
1582 brick
[i
*10+j
].hits
--;
1583 brick
[i
*10+j
].hiteffect
++;
1587 brick
[i
*10+j
].used
=0;
1588 if (brick
[i
*10+j
].power
!=10)
1589 brick
[i
*10+j
].poweruse
=2;
1591 ball
[k
].x
= ball
[k
].x
*-1;
1594 else if ((ball
[k
].pos_y
+HALFBALL
>= bricky
&&
1595 ball
[k
].pos_y
+HALFBALL
<=
1596 bricky
+BRICK_HEIGHT
) &&
1597 ((brickx
+BRICK_WIDTH
==
1599 (brickx
+BRICK_WIDTH
-6<=
1603 (ball
[k
].x
< 0)) { /* Right line */
1604 if (brick
[i
*10+j
].hits
> 0) {
1605 brick
[i
*10+j
].hits
--;
1606 brick
[i
*10+j
].hiteffect
++;
1610 brick
[i
*10+j
].used
=0;
1611 if (brick
[i
*10+j
].power
!=10)
1612 brick
[i
*10+j
].poweruse
=2;
1615 ball
[k
].x
= ball
[k
].x
*-1;
1618 if (brick
[i
*10+j
].used
==0) {
1629 rb
->lcd_bitmap_part(brickmania_pads
,0,pad_type
*PAD_HEIGHT
,
1630 PAD_WIDTH
,pad_pos_x
, PAD_POS_Y
, PAD_WIDTH
,
1633 for(k
=0;k
<used_balls
;k
++) {
1635 if ((ball
[k
].pos_x
>= pad_pos_x
&&
1636 ball
[k
].pos_x
<= pad_pos_x
+PAD_WIDTH
) &&
1637 (PAD_POS_Y
-4<ball
[k
].pos_y
+BALL
&&
1638 PAD_POS_Y
>ball
[k
].pos_y
+BALL
) && (ball
[k
].y
>0))
1639 ball
[k
].tempy
=PAD_POS_Y
-ball
[k
].pos_y
-BALL
;
1640 else if ((4>ball
[k
].pos_y
&& 0<ball
[k
].pos_y
) &&
1642 ball
[k
].tempy
=-ball
[k
].pos_y
;
1643 if ((LCD_WIDTH
-4<ball
[k
].pos_x
+BALL
&&
1644 LCD_WIDTH
>ball
[k
].pos_x
+BALL
) && (ball
[k
].x
>0))
1645 ball
[k
].tempx
=LCD_WIDTH
-ball
[k
].pos_x
-BALL
;
1646 else if ((4>ball
[k
].pos_x
&& 0<ball
[k
].pos_x
) &&
1648 ball
[k
].tempx
=-ball
[k
].pos_x
;
1651 if (ball
[k
].pos_y
<= 0)
1652 ball
[k
].y
= ball
[k
].y
*-1;
1654 else if (ball
[k
].pos_y
+BALL
>= GAMESCREEN_HEIGHT
) {
1657 ball
[k
].pos_x
= ball
[used_balls
].pos_x
;
1658 ball
[k
].pos_y
= ball
[used_balls
].pos_y
;
1659 ball
[k
].y
= ball
[used_balls
].y
;
1660 ball
[k
].tempy
= ball
[used_balls
].tempy
;
1661 ball
[k
].x
= ball
[used_balls
].x
;
1662 ball
[k
].tempx
= ball
[used_balls
].tempx
;
1663 ball
[k
].glue
= ball
[used_balls
].glue
;
1665 ball
[used_balls
].x
=0;
1666 ball
[used_balls
].y
=0;
1667 ball
[used_balls
].tempy
=0;
1668 ball
[used_balls
].tempx
=0;
1669 ball
[used_balls
].pos_y
=PAD_POS_Y
-BALL
;
1670 ball
[used_balls
].pos_x
=pad_pos_x
+(PAD_WIDTH
/2)-2;
1683 /* left line ,right line */
1684 if ((ball
[k
].pos_x
<= 0) ||
1685 (ball
[k
].pos_x
+BALL
>= LCD_WIDTH
)) {
1686 ball
[k
].x
= ball
[k
].x
*-1;
1687 ball
[k
].pos_x
= ball
[k
].pos_x
<= 0 ? 0 : LCD_WIDTH
-BALL
;
1690 if ((ball
[k
].pos_y
+BALL
>= PAD_POS_Y
&&
1691 (ball
[k
].pos_x
>= pad_pos_x
&&
1692 ball
[k
].pos_x
<= pad_pos_x
+PAD_WIDTH
)) &&
1693 start_game
!= 1 && !ball
[k
].glue
) {
1695 if ((ball
[k
].pos_x
+HALFBALL
>= pad_pos_x
&&
1696 ball
[k
].pos_x
+HALFBALL
<=
1697 pad_pos_x
+(PAD_WIDTH
/2/4)) ||
1698 (ball
[k
].pos_x
+HALFBALL
>=
1699 pad_pos_x
+(PAD_WIDTH
-(PAD_WIDTH
/2/4)) &&
1700 ball
[k
].pos_x
+HALFBALL
<= pad_pos_x
+PAD_WIDTH
)) {
1703 if (ball
[k
].pos_x
!= 0 &&
1704 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1705 ball
[k
].x
= pad_check(6,0,ball
[k
].pos_x
+2<=
1706 pad_pos_x
+(PAD_WIDTH
/2)?
1710 else if ((ball
[k
].pos_x
+HALFBALL
>=
1711 pad_pos_x
+(PAD_WIDTH
/2/4) &&
1712 ball
[k
].pos_x
+HALFBALL
<=
1713 pad_pos_x
+2*(PAD_WIDTH
/2/4)) ||
1714 (ball
[k
].pos_x
+HALFBALL
>=
1715 pad_pos_x
+(PAD_WIDTH
-2*(PAD_WIDTH
/2/4)) &&
1716 ball
[k
].pos_x
+HALFBALL
<=
1717 pad_pos_x
+(PAD_WIDTH
-(PAD_WIDTH
/2/4)) )) {
1720 if (ball
[k
].pos_x
!= 0 &&
1721 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1722 ball
[k
].x
= pad_check(4,0,ball
[k
].pos_x
+2<=
1723 pad_pos_x
+(PAD_WIDTH
/2)?
1727 else if ((ball
[k
].pos_x
+HALFBALL
>=
1728 pad_pos_x
+2*(PAD_WIDTH
/2/4) &&
1729 ball
[k
].pos_x
+HALFBALL
<=
1730 pad_pos_x
+3*(PAD_WIDTH
/2/4)) ||
1732 pad_pos_x
+(PAD_WIDTH
-3*(PAD_WIDTH
/2/4)) &&
1734 pad_pos_x
+ ((PAD_WIDTH
/2)-2*(PAD_WIDTH
/2/4)) )) {
1737 if (ball
[k
].pos_x
!= 0 &&
1738 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1739 ball
[k
].x
= pad_check(3,0,ball
[k
].pos_x
+2<=
1740 pad_pos_x
+(PAD_WIDTH
/2)?
1744 else if ((ball
[k
].pos_x
+HALFBALL
>=
1745 pad_pos_x
+3*(PAD_WIDTH
/2/4) &&
1746 ball
[k
].pos_x
+HALFBALL
<=
1747 pad_pos_x
+4*(PAD_WIDTH
/2/4)-2) ||
1748 (ball
[k
].pos_x
+2 >= pad_pos_x
+(PAD_WIDTH
/2+2) &&
1750 pad_pos_x
+(PAD_WIDTH
-3*(PAD_WIDTH
/2/4)) )) {
1753 if (ball
[k
].pos_x
!= 0 &&
1754 ball
[k
].pos_x
+BALL
!=LCD_WIDTH
)
1755 ball
[k
].x
= pad_check(2,1,0,k
);
1763 if (!ball
[k
].glue
) {
1764 ball
[k
].pos_x
+=ball
[k
].tempx
!=0?ball
[k
].tempx
:ball
[k
].x
;
1765 ball
[k
].pos_y
+=ball
[k
].tempy
!=0?ball
[k
].tempy
:ball
[k
].y
;
1771 if (ball
[k
].pos_y
+5 >= PAD_POS_Y
&&
1772 (pad_type
==1 && !ball
[k
].glue
) &&
1773 (ball
[k
].pos_x
>= pad_pos_x
&&
1774 ball
[k
].pos_x
<= pad_pos_x
+PAD_WIDTH
)) {
1776 ball
[k
].pos_y
=PAD_POS_Y
-BALL
;
1783 if (brick_on_board
< 0) {
1784 if (cur_level
+1<levels_num
) {
1791 rb
->lcd_getstringsize("Congratulations!", &sw
, NULL
);
1792 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_CONGRATS
,
1793 "Congratulations!");
1794 #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1795 rb
->lcd_getstringsize("No more levels", &sw
, NULL
);
1796 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_FINISH
,
1799 rb
->lcd_getstringsize("You have finished the game!",
1801 rb
->lcd_putsxy(LCD_WIDTH
/2-sw
/2, STRINGPOS_FINISH
,
1802 "You have finished the game!");
1806 if (score
>highscore
) {
1809 rb
->splash(HZ
*2, "New High Score");
1819 int move_button
,button
;
1820 int button_right
,button_left
;
1821 button
=rb
->button_get(false);
1823 #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN)
1824 /* FIXME: Should probably check remote hold here */
1825 if (rb
->button_hold())
1829 #ifdef HAVE_TOUCHSCREEN
1830 if(button
& BUTTON_TOUCHSCREEN
)
1832 short touch_x
, touch_y
;
1833 touch_x
= rb
->button_get_data() >> 16;
1834 touch_y
= rb
->button_get_data() & 0xffff;
1835 if(touch_y
>= PAD_POS_Y
&& touch_y
<= PAD_POS_Y
+PAD_HEIGHT
)
1837 pad_pos_x
+= (flip_sides
? -1 : 1) * ( (touch_x
-pad_pos_x
-PAD_WIDTH
/2) / 4 );
1841 else if(pad_pos_x
+PAD_WIDTH
> LCD_WIDTH
)
1842 pad_pos_x
= LCD_WIDTH
-PAD_WIDTH
;
1843 for(k
=0;k
<used_balls
;k
++)
1844 if ((start_game
==1 || ball
[k
].glue
))
1845 ball
[k
].pos_x
= pad_pos_x
+PAD_WIDTH
/2;
1848 if(button
& BUTTON_REL
)
1854 move_button
=rb
->button_status();
1856 button_right
=((move_button
& RIGHT
) || (move_button
& ALTRIGHT
));
1857 button_left
=((move_button
& LEFT
) || (move_button
& ALTLEFT
));
1859 button_right
=((move_button
& RIGHT
) || (SCROLL_FWD(button
)));
1860 button_left
=((move_button
& LEFT
) || (SCROLL_BACK(button
)));
1862 if ((con_game
== 1 && start_game
!=1) && (button_right
|| button_left
))
1864 if ((button_right
&& flip_sides
==false) ||
1865 (button_left
&& flip_sides
==true)) {
1866 if (pad_pos_x
+8+PAD_WIDTH
> LCD_WIDTH
) {
1867 for(k
=0;k
<used_balls
;k
++)
1868 if (start_game
==1 || ball
[k
].glue
)
1869 ball
[k
].pos_x
+=LCD_WIDTH
-pad_pos_x
-PAD_WIDTH
;
1870 pad_pos_x
+=LCD_WIDTH
-pad_pos_x
-PAD_WIDTH
;
1873 for(k
=0;k
<used_balls
;k
++)
1874 if ((start_game
==1 || ball
[k
].glue
))
1879 else if ((button_left
&& flip_sides
==false) ||
1880 (button_right
&& flip_sides
==true)) {
1881 if (pad_pos_x
-8 < 0) {
1882 for(k
=0;k
<used_balls
;k
++)
1883 if (start_game
==1 || ball
[k
].glue
)
1884 ball
[k
].pos_x
-=pad_pos_x
;
1885 pad_pos_x
-=pad_pos_x
;
1888 for(k
=0;k
<used_balls
;k
++)
1889 if (start_game
==1 || ball
[k
].glue
)
1894 #ifdef HAVE_TOUCHSCREEN
1902 if (start_game
==1 && con_game
!=1 && pad_type
!=1) {
1903 for(k
=0;k
<used_balls
;k
++) {
1905 ball
[k
].x
=pad_pos_x
+(PAD_WIDTH
/2)-2>=
1910 else if (pad_type
==1) {
1911 for(k
=0;k
<used_balls
;k
++) {
1914 else if (start_game
==1) {
1920 if (start_game
!=1 && con_game
==1) {
1924 } else if (pad_type
==2 && con_game
!=1) {
1927 fire
[tfire
].top
=PAD_POS_Y
-7;
1928 fire
[tfire
].left
=pad_pos_x
+1;
1930 fire
[tfire
].top
=PAD_POS_Y
-7;
1931 fire
[tfire
].left
=pad_pos_x
+PAD_WIDTH
-1;
1932 } else if (con_game
==1 && start_game
!=1) {
1933 for(k
=0;k
<used_balls
;k
++) {
1945 switch(game_menu(1)) {
1952 for(k
=0;k
<used_balls
;k
++)
1953 if (ball
[k
].x
!=0 && ball
[k
].y
!=0)
1968 for(k
=0;k
<used_balls
;k
++) {
1980 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
1986 #ifdef HAVE_LCD_COLOR
1987 rb
->lcd_bitmap_transparent(brickmania_gameover
,
1988 (LCD_WIDTH
- GAMEOVER_WIDTH
)/2,
1989 (GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
1990 GAMEOVER_WIDTH
,GAMEOVER_HEIGHT
);
1991 #else /* greyscale and mono */
1992 rb
->lcd_bitmap(brickmania_gameover
,(LCD_WIDTH
- GAMEOVER_WIDTH
)/2,
1993 (GAMESCREEN_HEIGHT
- GAMEOVER_HEIGHT
)/2,
1994 GAMEOVER_WIDTH
,GAMEOVER_HEIGHT
);
1997 if (score
>highscore
) {
2000 rb
->splash(HZ
*2, "New High Score");
2005 for(k
=0;k
<used_balls
;k
++) {
2012 if (end
> *rb
->current_tick
)
2013 rb
->sleep(end
-*rb
->current_tick
);
2019 /* this is the plugin entry point */
2020 enum plugin_status
plugin_start(const void* parameter
)
2024 rb
->lcd_setfont(FONT_SYSFIXED
);
2026 rb
->lcd_set_backdrop(NULL
);
2028 /* Turn off backlight timeout */
2029 backlight_force_on(); /* backlight control in lib/helper.c */
2031 rb
->srand( *rb
->current_tick
);
2033 configfile_load(HIGH_SCORE
,config
,1,0);
2035 /* now go ahead and have fun! */
2036 while (game_loop()!=1);
2038 configfile_save(HIGH_SCORE
,config
,1,0);
2040 /* Restore user's original backlight setting */
2041 rb
->lcd_setfont(FONT_UI
);
2042 /* Turn on backlight timeout (revert to settings) */
2043 backlight_use_settings(); /* backlight control in lib/helper.c */