blob: c3cdcad967609cb611ceb6953f9d73c8fa273d47 [file] [log] [blame]
Dave Chapman06e25c82006-01-23 16:00:06 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
Daniel Stenberga26d3152006-03-03 07:24:34 +000010 * Copyright (C) 2005, 2006 Ben Basha (Paprica)
Dave Chapman06e25c82006-01-23 16:00:06 +000011 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Dave Chapman06e25c82006-01-23 16:00:06 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "plugin.h"
23#include "configfile.h" /* Part of libplugin */
Peter D'Hoyecb53e3c2007-08-15 12:42:09 +000024#include "helper.h"
Dave Chapman06e25c82006-01-23 16:00:06 +000025
26PLUGIN_HEADER
27
Dave Chapman553c9e22006-01-27 10:02:13 +000028
Dave Chapman06e25c82006-01-23 16:00:06 +000029#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
30
31#define QUIT BUTTON_OFF
32#define LEFT BUTTON_LEFT
33#define RIGHT BUTTON_RIGHT
34#define SELECT BUTTON_SELECT
35#define UP BUTTON_UP
36#define DOWN BUTTON_DOWN
37
Kevin Ferrare0e027bd2006-06-30 16:43:47 +000038#define RC_QUIT BUTTON_RC_STOP
39
Dave Chapman553c9e22006-01-27 10:02:13 +000040
Ben Bashad330ef72006-02-22 10:34:36 +000041#elif CONFIG_KEYPAD == ONDIO_PAD
42
43#define QUIT BUTTON_OFF
44#define LEFT BUTTON_LEFT
45#define RIGHT BUTTON_RIGHT
46#define SELECT BUTTON_MENU
47#define UP BUTTON_UP
48#define DOWN BUTTON_DOWN
49
Ben Bashad330ef72006-02-22 10:34:36 +000050
51#elif CONFIG_KEYPAD == RECORDER_PAD
52
53#define QUIT BUTTON_OFF
54#define LEFT BUTTON_LEFT
55#define RIGHT BUTTON_RIGHT
56#define SELECT BUTTON_PLAY
57#define UP BUTTON_UP
58#define DOWN BUTTON_DOWN
59
Ben Bashad330ef72006-02-22 10:34:36 +000060
Dave Chapmand64e6262007-01-14 13:48:09 +000061#elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
62
63#define QUIT BUTTON_OFF
64#define LEFT BUTTON_LEFT
65#define RIGHT BUTTON_RIGHT
66#define SELECT BUTTON_SELECT
67#define UP BUTTON_UP
68#define DOWN BUTTON_DOWN
69
Dave Chapmand64e6262007-01-14 13:48:09 +000070
Jens Arnoldb7013222007-07-27 09:57:27 +000071#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
72 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
73 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
Dave Chapman06e25c82006-01-23 16:00:06 +000074
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
81
Dave Chapman553c9e22006-01-27 10:02:13 +000082#define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
83#define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
84
Marianne Arnold2e5f8f52007-12-30 14:56:51 +000085
Marcoen Hirschberg338e2bb2006-02-24 15:42:52 +000086#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
87
Marcoen Hirschberga7168fe2007-05-19 23:38:09 +000088#define QUIT BUTTON_POWER
Marcoen Hirschberg338e2bb2006-02-24 15:42:52 +000089#define LEFT BUTTON_LEFT
90#define RIGHT BUTTON_RIGHT
91#define SELECT BUTTON_SELECT
92#define UP BUTTON_UP
93#define DOWN BUTTON_DOWN
94
Marcoen Hirschberg338e2bb2006-02-24 15:42:52 +000095
Marianne Arnold2e5f8f52007-12-30 14:56:51 +000096#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
Ben Bashad330ef72006-02-22 10:34:36 +000097
98#define QUIT BUTTON_POWER
99#define LEFT BUTTON_LEFT
100#define RIGHT BUTTON_RIGHT
101#define SELECT BUTTON_PLAY
102#define UP BUTTON_UP
103#define DOWN BUTTON_DOWN
104
Daniel Stenberg451f08a2006-08-03 20:40:37 +0000105
Barry Wardell24f4a2a2006-10-26 13:38:09 +0000106#elif CONFIG_KEYPAD == SANSA_E200_PAD
107
Michael Sevakis89700552007-05-22 06:31:44 +0000108#define QUIT BUTTON_POWER
109#define LEFT BUTTON_LEFT
110#define RIGHT BUTTON_RIGHT
Barry Wardell24f4a2a2006-10-26 13:38:09 +0000111#define SELECT BUTTON_SELECT
Jonathan Gordon81ba1462008-01-10 08:08:31 +0000112#define UP BUTTON_SCROLL_BACK
113#define DOWN BUTTON_SCROLL_FWD
Michael Sevakis89700552007-05-22 06:31:44 +0000114
Jonathan Gordon81ba1462008-01-10 08:08:31 +0000115#define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
116#define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
Marianne Arnold0d8fd452008-01-09 21:06:42 +0000117
Barry Wardell24f4a2a2006-10-26 13:38:09 +0000118
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000119#elif CONFIG_KEYPAD == SANSA_C200_PAD
120
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
127#define UP BUTTON_UP
128#define DOWN BUTTON_DOWN
129
130
131#elif CONFIG_KEYPAD == IRIVER_H10_PAD
Daniel Stenberg1e88be52006-08-03 20:17:25 +0000132
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
139
Will Robertson8215b342008-02-17 12:23:02 +0000140#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
141
142#define QUIT BUTTON_BACK
143#define LEFT BUTTON_LEFT
144#define RIGHT BUTTON_RIGHT
145#define SELECT BUTTON_SELECT
146#define UP BUTTON_UP
147#define DOWN BUTTON_DOWN
Ben Bashad330ef72006-02-22 10:34:36 +0000148
Robert Kuklad6c8b572008-03-01 22:55:09 +0000149#elif (CONFIG_KEYPAD == MROBE100_PAD)
150
151#define QUIT BUTTON_POWER
152#define LEFT BUTTON_LEFT
153#define RIGHT BUTTON_RIGHT
154#define SELECT BUTTON_SELECT
155#define UP BUTTON_UP
156#define DOWN BUTTON_DOWN
157
Jens Arnold29361ab2008-03-22 10:24:28 +0000158#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
159
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
166
167#define RC_QUIT BUTTON_REC
168
Rob Purchase554d7ed2008-03-22 22:03:34 +0000169#elif CONFIG_KEYPAD == COWOND2_PAD
Rob Purchase297e0502008-04-27 15:30:19 +0000170#define QUIT BUTTON_POWER
Rob Purchase554d7ed2008-03-22 22:03:34 +0000171
Dave Chapman06e25c82006-01-23 16:00:06 +0000172#else
Robert Kuklad6c8b572008-03-01 22:55:09 +0000173#error No keymap defined!
Dave Chapman06e25c82006-01-23 16:00:06 +0000174#endif
175
Rob Purchase297e0502008-04-27 15:30:19 +0000176#ifdef HAVE_TOUCHPAD
177#ifndef LEFT
178#define LEFT BUTTON_MIDLEFT
179#endif
180#ifndef RIGHT
181#define RIGHT BUTTON_MIDRIGHT
182#endif
183#ifndef SELECT
184#define SELECT BUTTON_CENTER
185#endif
186#ifndef UP
187#define UP BUTTON_TOPMIDDLE
188#endif
189#ifndef DOWN
190#define DOWN BUTTON_BOTTOMMIDDLE
191#endif
192#endif
193
Marianne Arnold0d8fd452008-01-09 21:06:42 +0000194#ifndef SCROLL_FWD /* targets without scroll wheel*/
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000195#define SCROLL_FWD(x) (0)
196#define SCROLL_BACK(x) (0)
197#endif
198
199
Steve Bavin65265772008-05-13 09:57:56 +0000200static const struct plugin_api* rb;
Dave Chapman06e25c82006-01-23 16:00:06 +0000201
Ben Bashad510a6e2006-06-05 20:41:52 +0000202enum menu_items {
203 BM_START,
204 BM_SEL_START,
205 BM_RESUME,
206 BM_SEL_RESUME,
207 BM_NO_RESUME,
208 BM_HELP,
209 BM_SEL_HELP,
210 BM_QUIT,
211 BM_SEL_QUIT,
212};
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000213
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000214#include "brickmania_pads.h"
215#include "brickmania_bricks.h"
216#include "brickmania_powerups.h"
217#include "brickmania_ball.h"
218#include "brickmania_menu_items.h"
219#include "brickmania_gameover.h"
220
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
235
236#if LCD_DEPTH > 1 /* currently no background bmp for mono screens */
237#include "brickmania_menu_bg.h"
238#define MENU_BGHEIGHT BMPHEIGHT_brickmania_menu_bg
239#define MENU_BGWIDTH BMPWIDTH_brickmania_menu_bg
240#endif
241
Jens Arnold29361ab2008-03-22 10:24:28 +0000242#ifdef HAVE_LCD_COLOR /* currently no transparency for non-colour */
243#include "brickmania_break.h"
244#endif
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000245
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000246#if (LCD_WIDTH == 320) && (LCD_HEIGHT == 240)
Ben Bashaa39aeb12006-02-19 21:24:46 +0000247
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000248/* 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
250 to 10ms.
251*/
252#define CYCLETIME 30
Ben Bashaa39aeb12006-02-19 21:24:46 +0000253
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000254#define TOPMARGIN 30
255
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000256#define BMPYOFS_start 110
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000257#define HIGHSCORE_XPOS 57
258#define HIGHSCORE_YPOS 88
259
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000260#define STRINGPOS_FINISH 140
261#define STRINGPOS_CONGRATS 157
262#define STRINGPOS_NAVI 150
263#define STRINGPOS_FLIP 150
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000264
265#elif (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176)
Dave Chapman553c9e22006-01-27 10:02:13 +0000266
Ben Bashaa39aeb12006-02-19 21:24:46 +0000267/* 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
269 to 10ms.
270*/
271#define CYCLETIME 30
Daniel Stenberga26d3152006-03-03 07:24:34 +0000272
Dave Chapman553c9e22006-01-27 10:02:13 +0000273/* Offsets for LCDS > 220x176 */
Nicolas Pennequin5a29fe12007-02-14 22:59:36 +0000274
275#define GAMESCREEN_HEIGHT 176
Ben Bashaa39aeb12006-02-19 21:24:46 +0000276#define TOPMARGIN 30
Dave Chapman06e25c82006-01-23 16:00:06 +0000277
Nicolas Pennequin5a29fe12007-02-14 22:59:36 +0000278#define XOFS ((LCD_WIDTH-220)/BRICK_WIDTH/2)*BRICK_WIDTH
279#define YOFS ((LCD_HEIGHT-176)/BRICK_HEIGHT/2)*BRICK_HEIGHT
280
Dave Chapman553c9e22006-01-27 10:02:13 +0000281#define BMPYOFS_start (78+YOFS)
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000282#define HIGHSCORE_XPOS (17+XOFS)
Dave Chapman553c9e22006-01-27 10:02:13 +0000283#define HIGHSCORE_YPOS (56+YOFS)
284
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000285#define STRINGPOS_FINISH 140
286#define STRINGPOS_CONGRATS 157
287#define STRINGPOS_NAVI 150
288#define STRINGPOS_FLIP 150
Ben Bashaa39aeb12006-02-19 21:24:46 +0000289
Ben Bashad330ef72006-02-22 10:34:36 +0000290#elif (LCD_WIDTH == 160) && (LCD_HEIGHT == 128)
Ben Bashaa39aeb12006-02-19 21:24:46 +0000291/* 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
293 to 10ms.
294*/
295#define CYCLETIME 50
296
Ben Bashaa39aeb12006-02-19 21:24:46 +0000297#define TOPMARGIN 21
298
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000299#if LCD_DEPTH > 2
300#define BMPYOFS_start 58
Ben Bashaf12a5762006-03-24 12:36:47 +0000301#else
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000302#define BMPYOFS_start 66
Ben Bashaf12a5762006-03-24 12:36:47 +0000303#endif
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000304#define HIGHSCORE_XPOS 10
305#define HIGHSCORE_YPOS 38
Ben Bashaa39aeb12006-02-19 21:24:46 +0000306
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000307#define STRINGPOS_FINISH 110
308#define STRINGPOS_CONGRATS 100
309#define STRINGPOS_NAVI 100
310#define STRINGPOS_FLIP 100
311
312#elif (LCD_WIDTH == 132) && (LCD_HEIGHT == 80)
313
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
316 to 10ms.
317*/
318#define CYCLETIME 50
319
320#define TOPMARGIN 10
321
322#define BMPYOFS_start 30
323#define HIGHSCORE_XPOS 68
324#define HIGHSCORE_YPOS 8
325
326#define STRINGPOS_FINISH 55
327#define STRINGPOS_CONGRATS 45
328#define STRINGPOS_NAVI 60
329#define STRINGPOS_FLIP 60
330
331#elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 128)
332
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
335 to 10ms.
336*/
337#define CYCLETIME 50
338
339#define GAMESCREEN_HEIGHT 100
340#define TOPMARGIN 15
341
342#define BMPYOFS_start 70
343#define HIGHSCORE_XPOS 8
Ben Bashaa39aeb12006-02-19 21:24:46 +0000344#define HIGHSCORE_YPOS 36
345
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000346#define STRINGPOS_FINISH 55
347#define STRINGPOS_CONGRATS 45
348#define STRINGPOS_NAVI 60
349#define STRINGPOS_FLIP 60
Dave Chapman553c9e22006-01-27 10:02:13 +0000350
Ben Basha390f1672006-04-11 20:16:05 +0000351/* iPod Mini */
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
355 to 10ms.
356*/
357#define CYCLETIME 50
358
Ben Basha390f1672006-04-11 20:16:05 +0000359#define TOPMARGIN 10
360
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000361#define BMPYOFS_start 51
362#define HIGHSCORE_XPOS 73
363#define HIGHSCORE_YPOS 25
Ben Basha390f1672006-04-11 20:16:05 +0000364
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000365#define STRINGPOS_FINISH 54
366#define STRINGPOS_CONGRATS 44
367#define STRINGPOS_NAVI 44
368#define STRINGPOS_FLIP 44
Ben Basha390f1672006-04-11 20:16:05 +0000369
Jens Arnold29361ab2008-03-22 10:24:28 +0000370/* iAudio M3 */
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
374 to 10ms.
375*/
376#define CYCLETIME 50
Ben Basha390f1672006-04-11 20:16:05 +0000377
Jens Arnold29361ab2008-03-22 10:24:28 +0000378#define TOPMARGIN 10
379
380#define BMPYOFS_start 42
381#define HIGHSCORE_XPOS 65
382#define HIGHSCORE_YPOS 25
383
384#define STRINGPOS_FINISH 54
385#define STRINGPOS_CONGRATS 44
386#define STRINGPOS_NAVI 44
387#define STRINGPOS_FLIP 44
388
389/* Archos */
Ben Bashad330ef72006-02-22 10:34:36 +0000390#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
393 to 10ms.
394*/
395#define CYCLETIME 75
396
Ben Bashad330ef72006-02-22 10:34:36 +0000397#define TOPMARGIN 10
398
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000399#define BMPYOFS_start 22
Ben Bashad330ef72006-02-22 10:34:36 +0000400#define HIGHSCORE_XPOS 0
401#define HIGHSCORE_YPOS 0
402
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000403#define STRINGPOS_FINISH 54
404#define STRINGPOS_CONGRATS 44
405#define STRINGPOS_NAVI 44
406#define STRINGPOS_FLIP 44
Ben Bashad330ef72006-02-22 10:34:36 +0000407
Jonathan Gordon5d173ea2007-04-19 12:14:54 +0000408/* nano and sansa */
409#elif (LCD_WIDTH == 176) && (LCD_HEIGHT >= 132) && (LCD_DEPTH==16)
Ben Basha265d1a02006-02-20 18:56:34 +0000410/* 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
412 to 10ms.
413*/
Jonathan Gordon5d173ea2007-04-19 12:14:54 +0000414
Ben Basha265d1a02006-02-20 18:56:34 +0000415#define CYCLETIME 30
416
Jonathan Gordon5d173ea2007-04-19 12:14:54 +0000417#define GAMESCREEN_HEIGHT 132
Ben Basha265d1a02006-02-20 18:56:34 +0000418#define TOPMARGIN 21
419
Ben Basha265d1a02006-02-20 18:56:34 +0000420#define BMPYOFS_start 58
Ben Basha265d1a02006-02-20 18:56:34 +0000421#define HIGHSCORE_XPOS 7
422#define HIGHSCORE_YPOS 36
423
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000424#define STRINGPOS_FINISH 110
425#define STRINGPOS_CONGRATS 110
426#define STRINGPOS_NAVI 100
427#define STRINGPOS_FLIP 100
Ben Basha265d1a02006-02-20 18:56:34 +0000428
Dave Chapman06e25c82006-01-23 16:00:06 +0000429#else
430#error Unsupported LCD Size
431#endif
432
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000433
434#ifndef GAMESCREEN_HEIGHT
435#define GAMESCREEN_HEIGHT LCD_HEIGHT
436#endif
437
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)
442
443/*calculate paddle y-position */
444#if GAMESCREEN_HEIGHT >= 128
445#define PAD_POS_Y GAMESCREEN_HEIGHT -PAD_HEIGHT - 2
446#else
447#define PAD_POS_Y GAMESCREEN_HEIGHT -PAD_HEIGHT - 1
448#endif
449
450
Maurus Cuelenaere50763d52008-06-09 20:59:55 +0000451#ifdef HAVE_TOUCHPAD
452#include "lib/touchscreen.h"
453
454static struct ts_mapping main_menu_items[4] =
455{
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}
460};
461static struct ts_mappings main_menu = {main_menu_items, 4};
462#endif
463
464
Dave Chapman06e25c82006-01-23 16:00:06 +0000465int levels_num = 29;
Daniel Stenberga26d3152006-03-03 07:24:34 +0000466
Dave Chapman06e25c82006-01-23 16:00:06 +0000467static unsigned char levels[29][8][10] = {
468 { /* level1 */
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}
477 },
478 { /* level2 */
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,0x0,0x0,0x0,0x0,0x2,0x1,0x0},
486 {0x0,0x0,0x1,0x2,0x2,0x2,0x2,0x1,0x0,0x0}
487 },
488 { /* level3 */
489 {0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000490 {0x3,0x23,0x23,0x3,0x0,0x0,0x2,0x22,0x22,0x2},
Dave Chapman06e25c82006-01-23 16:00:06 +0000491 {0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000492 {0x0,0x0,0x0,0x0,0x37,0x37,0x0,0x0,0x0,0x0},
493 {0x0,0x0,0x0,0x0,0x37,0x37,0x0,0x0,0x0,0x0},
Dave Chapman06e25c82006-01-23 16:00:06 +0000494 {0x5,0x5,0x5,0x5,0x0,0x0,0x6,0x6,0x6,0x6},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000495 {0x5,0x25,0x25,0x5,0x0,0x0,0x6,0x26,0x26,0x6},
Dave Chapman06e25c82006-01-23 16:00:06 +0000496 {0x5,0x5,0x5,0x5,0x0,0x0,0x6,0x6,0x6,0x6}
497 },
498 { /* level4 */
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000499 {0x0,0x0,0x0,0x27,0x27,0x27,0x27,0x0,0x0,0x0},
500 {0x0,0x0,0x0,0x27,0x7,0x7,0x27,0x0,0x0,0x0},
501 {0x22,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x22},
502 {0x22,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x22},
503 {0x26,0x6,0x0,0x2,0x2,0x2,0x2,0x0,0x6,0x26},
Dave Chapman06e25c82006-01-23 16:00:06 +0000504 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
505 {0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0},
506 {0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1}
507 },
508 { /* level5 */
509 {0x1,0x0,0x2,0x2,0x0,0x3,0x3,0x0,0x4,0x4},
510 {0x0,0x2,0x2,0x0,0x3,0x3,0x0,0x4,0x4,0x0},
511 {0x2,0x2,0x0,0x3,0x3,0x0,0x4,0x4,0x0,0x5},
512 {0x2,0x0,0x3,0x3,0x0,0x4,0x4,0x0,0x5,0x5},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000513 {0x0,0x33,0x3,0x0,0x4,0x4,0x0,0x5,0x5,0x0},
514 {0x3,0x33,0x0,0x4,0x4,0x0,0x5,0x5,0x0,0x36},
515 {0x3,0x0,0x4,0x4,0x0,0x5,0x5,0x0,0x6,0x36},
516 {0x0,0x24,0x24,0x0,0x25,0x25,0x0,0x26,0x26,0x0}
Dave Chapman06e25c82006-01-23 16:00:06 +0000517 },
518 { /* level6 */
519 {0x0,0x1,0x3,0x7,0x7,0x7,0x7,0x3,0x1,0x0},
520 {0x3,0x1,0x3,0x7,0x0,0x0,0x7,0x3,0x1,0x3},
521 {0x3,0x1,0x3,0x7,0x7,0x7,0x7,0x3,0x1,0x3},
522 {0x0,0x0,0x0,0x2,0x2,0x2,0x2,0x0,0x0,0x0},
523 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
524 {0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x5},
525 {0x0,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x0},
526 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
527 },
528 { /* level7 */
529 {0x0,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x0},
530 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
531 {0x6,0x0,0x0,0x2,0x2,0x2,0x2,0x0,0x0,0x6},
532 {0x6,0x0,0x0,0x2,0x2,0x2,0x2,0x0,0x0,0x6},
533 {0x6,0x6,0x6,0x0,0x0,0x0,0x0,0x6,0x6,0x6},
534 {0x0,0x0,0x0,0x1,0x1,0x1,0x1,0x0,0x0,0x0},
535 {0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0},
536 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
537 },
538 { /* level8 */
539 {0x0,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x0},
540 {0x0,0x0,0x0,0x4,0x0,0x0,0x4,0x0,0x0,0x0},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000541 {0x6,0x6,0x0,0x2,0x32,0x32,0x2,0x0,0x6,0x6},
Dave Chapman06e25c82006-01-23 16:00:06 +0000542 {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x0},
543 {0x0,0x6,0x6,0x0,0x0,0x0,0x0,0x6,0x6,0x0},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000544 {0x0,0x0,0x0,0x5,0x25,0x25,0x5,0x0,0x0,0x0},
545 {0x0,0x5,0x5,0x25,0x5,0x5,0x25,0x5,0x5,0x0},
546 {0x5,0x5,0x25,0x5,0x5,0x5,0x5,0x25,0x5,0x5}
Dave Chapman06e25c82006-01-23 16:00:06 +0000547 },
548 { /* level9 */
549 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2},
550 {0x2,0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x2},
551 {0x2,0x0,0x3,0x0,0x1,0x1,0x0,0x3,0x0,0x2},
552 {0x2,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x2},
553 {0x2,0x0,0x1,0x0,0x3,0x3,0x0,0x1,0x0,0x2},
554 {0x2,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x2},
555 {0x2,0x2,0x0,0x0,0x1,0x1,0x0,0x0,0x2,0x2},
556 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2}
557 },
558 { /* level10 */
559 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
560 {0x0,0x5,0x0,0x5,0x0,0x5,0x0,0x5,0x0,0x5},
561 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
562 {0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0},
563 {0x0,0x0,0x0,0x4,0x1,0x1,0x4,0x0,0x0,0x0},
564 {0x0,0x0,0x3,0x4,0x1,0x1,0x4,0x3,0x0,0x0},
565 {0x0,0x2,0x3,0x4,0x1,0x1,0x4,0x3,0x2,0x0},
566 {0x1,0x2,0x3,0x4,0x1,0x1,0x4,0x3,0x2,0x1}
567 },
568 { /* level11 */
569 {0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3},
570 {0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x2},
571 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2},
572 {0x2,0x0,0x0,0x0,0x7,0x7,0x0,0x0,0x0,0x2},
573 {0x2,0x0,0x0,0x7,0x7,0x7,0x7,0x0,0x0,0x2},
574 {0x0,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x0},
575 {0x0,0x2,0x0,0x1,0x0,0x0,0x1,0x0,0x2,0x0},
576 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5}
577 },
578 { /* level 12 */
579 {0x2,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x2},
580 {0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1},
581 {0x1,0x1,0x1,0x0,0x1,0x1,0x0,0x1,0x1,0x1},
582 {0x0,0x1,0x0,0x1,0x6,0x6,0x1,0x0,0x1,0x0},
583 {0x0,0x0,0x1,0x1,0x6,0x6,0x1,0x1,0x0,0x0},
584 {0x1,0x1,0x1,0x7,0x0,0x0,0x7,0x1,0x1,0x1},
585 {0x1,0x1,0x7,0x1,0x0,0x0,0x1,0x7,0x1,0x1},
586 {0x2,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x2,0x2}
587 },
588 {/* levell13 */
589 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2},
590 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2},
591 {0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x2},
592 {0x2,0x0,0x2,0x3,0x3,0x3,0x3,0x3,0x0,0x2},
593 {0x2,0x0,0x2,0x4,0x4,0x4,0x4,0x4,0x0,0x2},
594 {0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2},
595 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
596 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2}
597 },
598 {/* level14 */
599 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
600 {0x4,0x4,0x4,0x4,0x2,0x2,0x4,0x4,0x4,0x4},
601 {0x4,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x4},
602 {0x4,0x0,0x0,0x2,0x3,0x3,0x2,0x0,0x0,0x4},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000603 {0x4,0x0,0x2,0x23,0x3,0x3,0x23,0x2,0x0,0x4},
604 {0x4,0x0,0x2,0x22,0x2,0x2,0x22,0x2,0x0,0x4},
605 {0x4,0x0,0x6,0x21,0x5,0x5,0x21,0x6,0x0,0x4},
Dave Chapman06e25c82006-01-23 16:00:06 +0000606 {0x4,0x6,0x1,0x1,0x5,0x5,0x1,0x1,0x6,0x4}
607 },
608 {/* level 15 */
609 {0x4,0x4,0x4,0x4,0x4,0x3,0x3,0x3,0x3,0x3},
610 {0x2,0x2,0x1,0x1,0x1,0x1,0x1,0x5,0x0,0x0},
611 {0x2,0x2,0x1,0x1,0x1,0x0,0x1,0x6,0x0,0x0},
612 {0x2,0x1,0x1,0x2,0x1,0x1,0x1,0x5,0x0,0x0},
613 {0x2,0x1,0x2,0x2,0x2,0x1,0x1,0x6,0x0,0x0},
614 {0x2,0x1,0x2,0x2,0x2,0x1,0x3,0x5,0x3,0x0},
615 {0x2,0x1,0x1,0x2,0x1,0x1,0x1,0x6,0x0,0x0},
616 {0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2}
617 },
618 {/* level 16 (Rockbox) by ts-x */
619 {0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x5,0x0,0x5},
620 {0x2,0x0,0x3,0x0,0x3,0x4,0x0,0x5,0x5,0x0},
621 {0x2,0x0,0x3,0x3,0x3,0x4,0x4,0x5,0x0,0x5},
622 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
623 {0x6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
624 {0x7,0x7,0x7,0x1,0x1,0x1,0x2,0x0,0x2,0x0},
625 {0x7,0x0,0x7,0x1,0x0,0x1,0x0,0x2,0x0,0x0},
626 {0x7,0x7,0x7,0x1,0x1,0x1,0x2,0x0,0x2,0x0}
627 },
628 {/* level 17 (Alien) by ts-x */
629 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
630 {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2},
631 {0x1,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x1},
632 {0x2,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x2},
633 {0x1,0x0,0x1,0x2,0x2,0x2,0x2,0x1,0x0,0x1},
634 {0x2,0x0,0x0,0x1,0x2,0x2,0x1,0x0,0x0,0x2},
635 {0x2,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x2},
636 {0x2,0x2,0x1,0x0,0x1,0x1,0x0,0x1,0x2,0x2}
637 },
638 {/* level 18 (Tetris) by ts-x */
639 {0x0,0x2,0x0,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
640 {0x0,0x2,0x7,0x0,0x3,0x4,0x0,0x2,0x2,0x0},
641 {0x2,0x2,0x7,0x0,0x3,0x4,0x0,0x6,0x2,0x2},
642 {0x2,0x2,0x7,0x7,0x3,0x4,0x0,0x6,0x2,0x2},
643 {0x2,0x1,0x7,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
644 {0x2,0x1,0x0,0x7,0x3,0x4,0x4,0x6,0x5,0x5},
645 {0x1,0x1,0x1,0x7,0x3,0x0,0x6,0x6,0x5,0x5},
646 {0x1,0x1,0x1,0x0,0x3,0x0,0x6,0x6,0x5,0x5}
647 },
648 { /* level 19 (Stalactites) by ts-x */
649 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
650 {0x5,0x2,0x6,0x3,0x4,0x7,0x5,0x3,0x1,0x2},
651 {0x5,0x0,0x6,0x3,0x4,0x7,0x5,0x0,0x1,0x2},
652 {0x5,0x2,0x6,0x3,0x4,0x0,0x5,0x3,0x1,0x2},
653 {0x5,0x0,0x6,0x0,0x4,0x7,0x5,0x0,0x1,0x0},
654 {0x5,0x0,0x0,0x3,0x4,0x0,0x0,0x0,0x1,0x2},
655 {0x0,0x0,0x6,0x0,0x0,0x0,0x5,0x0,0x0,0x0},
656 {0x5,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x1,0x0}
657 },
658 { /* level 20 (Maze) by ts-x */
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000659 {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}
Dave Chapman06e25c82006-01-23 16:00:06 +0000667 },
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}
677 },
678 { /* level 22 (Spider) by ts-x */
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000679 {0x31,0x3,0x1,0x1,0x0,0x0,0x1,0x1,0x3,0x31},
Dave Chapman06e25c82006-01-23 16:00:06 +0000680 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000681 {0x33,0x1,0x1,0x36,0x1,0x1,0x36,0x1,0x1,0x33},
Dave Chapman06e25c82006-01-23 16:00:06 +0000682 {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
683 {0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x0,0x0},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000684 {0x21,0x3,0x1,0x21,0x2,0x2,0x21,0x1,0x3,0x21},
685 {0x0,0x0,0x0,0x1,0x21,0x1,0x1,0x0,0x0,0x0},
Dave Chapman06e25c82006-01-23 16:00:06 +0000686 {0x3,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x3}
687 },
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}
697 },
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}
707 },
708 {/* level 25 (Rainbow) by ts-x */
709 {0x0,0x4,0x1,0x0,0x0,0x0,0x0,0x1,0x4,0x0},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000710 {0x24,0x1,0x3,0x1,0x0,0x0,0x21,0x3,0x1,0x24},
711 {0x1,0x23,0x5,0x3,0x1,0x21,0x3,0x5,0x3,0x21},
Dave Chapman06e25c82006-01-23 16:00:06 +0000712 {0x3,0x5,0x6,0x5,0x3,0x3,0x5,0x6,0x5,0x3},
713 {0x5,0x6,0x7,0x6,0x5,0x5,0x6,0x7,0x6,0x5},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000714 {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}
Dave Chapman06e25c82006-01-23 16:00:06 +0000717 },
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}
727 },
728 { /* level 27 (Frog) by ts-x */
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000729 {0x0,0x5,0x25,0x0,0x0,0x0,0x0,0x25,0x5,0x0},
Dave Chapman06e25c82006-01-23 16:00:06 +0000730 {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000731 {0x25,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x25},
Dave Chapman06e25c82006-01-23 16:00:06 +0000732 {0x5,0x0,0x3,0x0,0x6,0x6,0x0,0x3,0x0,0x5},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000733 {0x5,0x0,0x31,0x0,0x6,0x6,0x0,0x31,0x0,0x5},
Dave Chapman06e25c82006-01-23 16:00:06 +0000734 {0x5,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x5},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000735 {0x5,0x5,0x5,0x35,0x0,0x0,0x35,0x5,0x5,0x5},
736 {0x0,0x25,0x5,0x0,0x4,0x4,0x0,0x5,0x25,0x0}
Dave Chapman06e25c82006-01-23 16:00:06 +0000737 },
738 { /* level 28 (DigDug) by ts-x */
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000739 {0x35,0x5,0x5,0x25,0x0,0x25,0x25,0x5,0x5,0x35},
Dave Chapman06e25c82006-01-23 16:00:06 +0000740 {0x6,0x0,0x0,0x6,0x0,0x6,0x6,0x0,0x0,0x6},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000741 {0x7,0x0,0x37,0x37,0x0,0x37,0x37,0x7,0x0,0x7},
Dave Chapman06e25c82006-01-23 16:00:06 +0000742 {0x7,0x0,0x7,0x0,0x0,0x0,0x7,0x7,0x7,0x7},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000743 {0x4,0x4,0x4,0x24,0x0,0x24,0x4,0x0,0x0,0x4},
Dave Chapman06e25c82006-01-23 16:00:06 +0000744 {0x4,0x4,0x0,0x0,0x0,0x4,0x4,0x0,0x4,0x4},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000745 {0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4},
746 {0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1}
Dave Chapman06e25c82006-01-23 16:00:06 +0000747 },
748 { /* TheEnd */
749 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000750 {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},
Dave Chapman06e25c82006-01-23 16:00:06 +0000756 {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
757 }
758};
759
Ben Basha9131c4a2006-02-17 16:02:37 +0000760#define MAX_BALLS 10
761int pad_pos_x;
762int x[MAX_BALLS],y[MAX_BALLS];
Dave Chapman06e25c82006-01-23 16:00:06 +0000763int life;
764int start_game,con_game;
765int pad_type;
Dave Chapman06e25c82006-01-23 16:00:06 +0000766int score=0,vscore=0;
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000767bool flip_sides=false;
Dave Chapman06e25c82006-01-23 16:00:06 +0000768int cur_level=0;
769int brick_on_board=0;
Ben Basha26e598d2006-02-15 17:37:45 +0000770int used_balls=1;
Dave Chapman06e25c82006-01-23 16:00:06 +0000771
772typedef struct cube {
773 int powertop;
774 int power;
775 char poweruse;
776 char used;
777 int color;
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000778 int hits;
Ben Bashadb836012006-02-01 18:25:24 +0000779 int hiteffect;
Dave Chapman06e25c82006-01-23 16:00:06 +0000780} cube;
781cube brick[80];
782
Ben Basha26e598d2006-02-15 17:37:45 +0000783typedef struct balls {
784 int pos_x;
785 int pos_y;
786 int y;
787 int tempy;
788 int x;
789 int tempx;
790 bool glue;
791} balls;
Dave Chapman06e25c82006-01-23 16:00:06 +0000792
Ben Basha26e598d2006-02-15 17:37:45 +0000793balls ball[MAX_BALLS];
Dave Chapman06e25c82006-01-23 16:00:06 +0000794
795typedef struct sfire {
796 int top;
797 int left;
798} sfire;
799sfire fire[30];
800
801
802int highscore;
803#define MAX_POINTS 200000 /* i dont think it needs to be more */
804static struct configdata config[] =
805{
806 {TYPE_INT, 0, MAX_POINTS, &highscore, "highscore", NULL, NULL}
807};
808
Dave Chapman06e25c82006-01-23 16:00:06 +0000809void int_game(int new_game)
810{
811 int i,j;
Daniel Stenberga26d3152006-03-03 07:24:34 +0000812
Dave Chapman06e25c82006-01-23 16:00:06 +0000813 pad_pos_x=LCD_WIDTH/2-PAD_WIDTH/2;
Daniel Stenberga26d3152006-03-03 07:24:34 +0000814
Ben Basha26e598d2006-02-15 17:37:45 +0000815 for(i=0;i<MAX_BALLS;i++) {
816 ball[i].x=0;
817 ball[i].y=0;
818 ball[i].tempy=0;
Daniel Stenberga26d3152006-03-03 07:24:34 +0000819 ball[i].tempx=0;
Ben Basha26e598d2006-02-15 17:37:45 +0000820 ball[i].pos_y=PAD_POS_Y-BALL;
821 ball[i].pos_x=pad_pos_x+(PAD_WIDTH/2)-2;
822 ball[i].glue=false;
823 }
Daniel Stenberga26d3152006-03-03 07:24:34 +0000824
Ben Basha26e598d2006-02-15 17:37:45 +0000825 used_balls=1;
Dave Chapman06e25c82006-01-23 16:00:06 +0000826 start_game =1;
827 con_game =0;
828 pad_type=0;
Ben Basha26e598d2006-02-15 17:37:45 +0000829
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000830 flip_sides=false;
Daniel Stenberga26d3152006-03-03 07:24:34 +0000831
Dave Chapman06e25c82006-01-23 16:00:06 +0000832 if (new_game==1)
Daniel Stenberga26d3152006-03-03 07:24:34 +0000833 brick_on_board=0;
Dave Chapman06e25c82006-01-23 16:00:06 +0000834
Daniel Stenberga26d3152006-03-03 07:24:34 +0000835 for(i=0;i<=7;i++) {
836 for(j=0;j<=9;j++) {
Dave Chapman06e25c82006-01-23 16:00:06 +0000837 brick[i*10+j].poweruse=(levels[cur_level][i][j]==0?0:1);
Daniel Stenberga26d3152006-03-03 07:24:34 +0000838 if (i*10+j<=30)
839 fire[i*10+j].top=-8;
840 if (new_game==1) {
841 brick[i*10+j].power=rb->rand()%25;
842 /* +8 make the game with less powerups */
Dave Chapman06e25c82006-01-23 16:00:06 +0000843
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000844 brick[i*10+j].hits=levels[cur_level][i][j]>=10?
Daniel Stenberga26d3152006-03-03 07:24:34 +0000845 levels[cur_level][i][j]/16-1:0;
Ben Bashadb836012006-02-01 18:25:24 +0000846 brick[i*10+j].hiteffect=0;
Ben Bashaa39aeb12006-02-19 21:24:46 +0000847 brick[i*10+j].powertop=TOPMARGIN+i*BRICK_HEIGHT+BRICK_HEIGHT;
Dave Chapman06e25c82006-01-23 16:00:06 +0000848 brick[i*10+j].used=(levels[cur_level][i][j]==0?0:1);
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +0000849 brick[i*10+j].color=(levels[cur_level][i][j]>=10?
Daniel Stenberga26d3152006-03-03 07:24:34 +0000850 levels[cur_level][i][j]%16:
851 levels[cur_level][i][j])-1;
852 if (levels[cur_level][i][j]!=0)
853 brick_on_board++;
Dave Chapman06e25c82006-01-23 16:00:06 +0000854 }
Daniel Stenberga26d3152006-03-03 07:24:34 +0000855 }
856 }
Dave Chapman06e25c82006-01-23 16:00:06 +0000857}
858
Dave Chapman06e25c82006-01-23 16:00:06 +0000859int sw,i,w;
860
Ben Basha9131c4a2006-02-17 16:02:37 +0000861/* sleep timer counting the score */
Daniel Stenberga26d3152006-03-03 07:24:34 +0000862void sleep (int secs)
863{
864 bool done=false;
865 char s[20];
866 int count=0;
Ben Basha9131c4a2006-02-17 16:02:37 +0000867
Daniel Stenberga26d3152006-03-03 07:24:34 +0000868 while (!done) {
869
870 if (vscore<score) {
871 vscore++;
872 rb->snprintf(s, sizeof(s), "%d", vscore);
873 rb->lcd_getstringsize(s, &sw, &w);
Ben Bashad330ef72006-02-22 10:34:36 +0000874#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
Daniel Stenberga26d3152006-03-03 07:24:34 +0000875 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s);
Ben Bashad330ef72006-02-22 10:34:36 +0000876#else
Daniel Stenberga26d3152006-03-03 07:24:34 +0000877 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 2, s);
Ben Bashad330ef72006-02-22 10:34:36 +0000878#endif
Daniel Stenberga26d3152006-03-03 07:24:34 +0000879 rb->lcd_update_rect(0,0,LCD_WIDTH,w+2);
880 } else {
881 if (count==0)
882 count=*rb->current_tick+HZ*secs;
883 if (*rb->current_tick>=count)
884 done=true;
885 }
886 rb->yield();
887 }
888
Ben Basha9131c4a2006-02-17 16:02:37 +0000889}
890
Hristo Kovachev5a0bb992006-03-21 15:24:25 +0000891#define HIGH_SCORE "brickmania.score"
Ben Basha9131c4a2006-02-17 16:02:37 +0000892#define MENU_LENGTH 4
Dave Chapman06e25c82006-01-23 16:00:06 +0000893int game_menu(int when)
894{
895 int button,cur=0;
896 char str[10];
Daniel Stenberga26d3152006-03-03 07:24:34 +0000897 rb->lcd_clear_display();
Robert Kuklad6c8b572008-03-01 22:55:09 +0000898#if LCD_DEPTH > 1 /* currently no background bmp for mono screens */
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000899 rb->lcd_bitmap(brickmania_menu_bg, 0, 0, MENU_BGWIDTH, MENU_BGHEIGHT);
Daniel Stenberga26d3152006-03-03 07:24:34 +0000900#endif
Dave Chapman06e25c82006-01-23 16:00:06 +0000901 while (true) {
902 for(i=0;i<MENU_LENGTH;i++) {
Ben Bashad510a6e2006-06-05 20:41:52 +0000903#ifdef HAVE_LCD_COLOR
Dave Chapman06e25c82006-01-23 16:00:06 +0000904 if (cur==0)
Ben Bashad510a6e2006-06-05 20:41:52 +0000905 rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000906 MENU_ITEMHEIGHT * BM_SEL_START, MENU_ITEMWIDTH,
907 MENU_ITEMXOFS, BMPYOFS_start, MENU_ITEMWIDTH,
908 MENU_ITEMHEIGHT);
Dave Chapman06e25c82006-01-23 16:00:06 +0000909 else
Ben Bashad510a6e2006-06-05 20:41:52 +0000910 rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000911 MENU_ITEMHEIGHT * BM_START, MENU_ITEMWIDTH,
912 MENU_ITEMXOFS, BMPYOFS_start, MENU_ITEMWIDTH,
913 MENU_ITEMHEIGHT);
Dave Chapman06e25c82006-01-23 16:00:06 +0000914
915 if (when==1) {
916 if (cur==1)
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000917 rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000918 MENU_ITEMHEIGHT * BM_SEL_RESUME, MENU_ITEMWIDTH,
919 MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH,
920 MENU_ITEMHEIGHT);
Dave Chapman06e25c82006-01-23 16:00:06 +0000921 else
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000922 rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000923 MENU_ITEMHEIGHT * BM_RESUME, MENU_ITEMWIDTH,
924 MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH,
925 MENU_ITEMHEIGHT);
Dave Chapman06e25c82006-01-23 16:00:06 +0000926
927 } else {
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000928 rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000929 MENU_ITEMHEIGHT * BM_NO_RESUME, MENU_ITEMWIDTH,
930 MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH,
931 MENU_ITEMHEIGHT);
Dave Chapman06e25c82006-01-23 16:00:06 +0000932 }
933
934
935 if (cur==2)
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000936 rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000937 MENU_ITEMHEIGHT * BM_SEL_HELP, MENU_ITEMWIDTH,
938 MENU_ITEMXOFS, BMPYOFS_help, MENU_ITEMWIDTH,
939 MENU_ITEMHEIGHT);
Dave Chapman06e25c82006-01-23 16:00:06 +0000940 else
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000941 rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000942 MENU_ITEMHEIGHT * BM_HELP, MENU_ITEMWIDTH,
943 MENU_ITEMXOFS, BMPYOFS_help, MENU_ITEMWIDTH,
944 MENU_ITEMHEIGHT);
Dave Chapman06e25c82006-01-23 16:00:06 +0000945
Dave Chapman06e25c82006-01-23 16:00:06 +0000946 if (cur==3)
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000947 rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000948 MENU_ITEMHEIGHT * BM_SEL_QUIT, MENU_ITEMWIDTH,
949 MENU_ITEMXOFS, BMPYOFS_quit, MENU_ITEMWIDTH,
950 MENU_ITEMHEIGHT);
Dave Chapman06e25c82006-01-23 16:00:06 +0000951 else
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000952 rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000953 MENU_ITEMHEIGHT * BM_QUIT, MENU_ITEMWIDTH,
954 MENU_ITEMXOFS, BMPYOFS_quit, MENU_ITEMWIDTH,
955 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +0000956#else
957 if (cur==0)
958 rb->lcd_bitmap_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000959 MENU_ITEMHEIGHT * BM_SEL_START, MENU_ITEMWIDTH,
960 MENU_ITEMXOFS, BMPYOFS_start, MENU_ITEMWIDTH,
961 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +0000962 else
963 rb->lcd_bitmap_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000964 MENU_ITEMHEIGHT * BM_START, MENU_ITEMWIDTH,
965 MENU_ITEMXOFS, BMPYOFS_start, MENU_ITEMWIDTH,
966 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +0000967
968 if (when==1) {
969 if (cur==1)
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000970 rb->lcd_bitmap_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000971 MENU_ITEMHEIGHT * BM_SEL_RESUME, MENU_ITEMWIDTH,
972 MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH,
973 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +0000974 else
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000975 rb->lcd_bitmap_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000976 MENU_ITEMHEIGHT * BM_RESUME, MENU_ITEMWIDTH,
977 MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH,
978 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +0000979
980 } else {
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000981 rb->lcd_bitmap_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000982 MENU_ITEMHEIGHT * BM_NO_RESUME, MENU_ITEMWIDTH,
983 MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH,
984 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +0000985 }
986
987
988 if (cur==2)
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000989 rb->lcd_bitmap_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000990 MENU_ITEMHEIGHT * BM_SEL_HELP, MENU_ITEMWIDTH,
991 MENU_ITEMXOFS, BMPYOFS_help, MENU_ITEMWIDTH,
992 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +0000993 else
Zakk Roberts4bdef7a2007-01-26 06:14:29 +0000994 rb->lcd_bitmap_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +0000995 MENU_ITEMHEIGHT * BM_HELP, MENU_ITEMWIDTH,
996 MENU_ITEMXOFS, BMPYOFS_help, MENU_ITEMWIDTH,
997 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +0000998
999 if (cur==3)
Zakk Roberts4bdef7a2007-01-26 06:14:29 +00001000 rb->lcd_bitmap_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001001 MENU_ITEMHEIGHT * BM_SEL_QUIT, MENU_ITEMWIDTH,
1002 MENU_ITEMXOFS, BMPYOFS_quit, MENU_ITEMWIDTH,
1003 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +00001004 else
Zakk Roberts4bdef7a2007-01-26 06:14:29 +00001005 rb->lcd_bitmap_part(brickmania_menu_items, 0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001006 MENU_ITEMHEIGHT * BM_QUIT, MENU_ITEMWIDTH,
1007 MENU_ITEMXOFS, BMPYOFS_quit, MENU_ITEMWIDTH,
1008 MENU_ITEMHEIGHT);
Ben Bashad510a6e2006-06-05 20:41:52 +00001009#endif
Dave Chapman06e25c82006-01-23 16:00:06 +00001010 }
Ben Basha265d1a02006-02-20 18:56:34 +00001011 rb->lcd_set_drawmode(DRMODE_FG);
Dave Chapman06e25c82006-01-23 16:00:06 +00001012 /* high score */
Ben Bashaa39aeb12006-02-19 21:24:46 +00001013#ifdef HAVE_LCD_COLOR
Dave Chapman06e25c82006-01-23 16:00:06 +00001014 rb->lcd_set_background(LCD_RGBPACK(0,0,140));
1015 rb->lcd_set_foreground(LCD_WHITE);
Ben Bashaa39aeb12006-02-19 21:24:46 +00001016#endif
Dave Chapman553c9e22006-01-27 10:02:13 +00001017 rb->lcd_putsxy(HIGHSCORE_XPOS, HIGHSCORE_YPOS, "High Score");
Dave Chapman06e25c82006-01-23 16:00:06 +00001018 rb->snprintf(str, sizeof(str), "%d", highscore);
1019 rb->lcd_getstringsize("High Score", &sw, NULL);
1020 rb->lcd_getstringsize(str, &w, NULL);
Dave Chapman553c9e22006-01-27 10:02:13 +00001021 rb->lcd_putsxy(HIGHSCORE_XPOS+sw/2-w/2, HIGHSCORE_YPOS+9, str);
Ben Basha265d1a02006-02-20 18:56:34 +00001022 rb->lcd_set_drawmode(DRMODE_SOLID);
Dave Chapman06e25c82006-01-23 16:00:06 +00001023
1024 rb->lcd_update();
1025
1026 button = rb->button_get(true);
Maurus Cuelenaere50763d52008-06-09 20:59:55 +00001027#ifdef HAVE_TOUCHPAD
1028 if(button & BUTTON_TOUCHPAD)
1029 {
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)
1032 {
1033 if(cur == (signed)result)
1034 button = SELECT;
1035 cur = result;
1036 }
1037 }
1038#endif
Daniel Stenberga26d3152006-03-03 07:24:34 +00001039 switch(button) {
Dave Chapman06e25c82006-01-23 16:00:06 +00001040 case UP:
Zakk Robertsa45e8352007-02-21 22:48:44 +00001041 case UP | BUTTON_REPEAT:
Dave Chapman06e25c82006-01-23 16:00:06 +00001042 if (cur==0)
1043 cur = MENU_LENGTH-1;
1044 else
1045 cur--;
1046 if (when==0 && cur==1) {
1047 cur = 0;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001048 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001049 break;
1050
1051 case DOWN:
Zakk Robertsa45e8352007-02-21 22:48:44 +00001052 case DOWN | BUTTON_REPEAT:
Dave Chapman06e25c82006-01-23 16:00:06 +00001053 if (cur==MENU_LENGTH-1)
1054 cur = 0;
1055 else
1056 cur++;
1057 if (when==0 && cur==1) {
1058 cur=2;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001059 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001060 break;
1061
Ben Bashad330ef72006-02-22 10:34:36 +00001062 case RIGHT:
Dave Chapman06e25c82006-01-23 16:00:06 +00001063 case SELECT:
1064 if (cur==0) {
1065 score=0;
1066 vscore=0;
1067 return 0;
1068 } else if (cur==1 && when==1) {
1069 return 1;
1070 } else if (cur==2) {
Daniel Stenberga26d3152006-03-03 07:24:34 +00001071 return 2;
Dave Chapman06e25c82006-01-23 16:00:06 +00001072 } else if (cur==3) {
Daniel Stenberga26d3152006-03-03 07:24:34 +00001073 return 3;
Dave Chapman06e25c82006-01-23 16:00:06 +00001074 }
1075 break;
Kevin Ferrare0e027bd2006-06-30 16:43:47 +00001076#ifdef RC_QUIT
1077 case RC_QUIT:
1078#endif
Dave Chapman06e25c82006-01-23 16:00:06 +00001079 case QUIT:
1080 return 3;
1081 break;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001082
Ben Bashaa39aeb12006-02-19 21:24:46 +00001083 default:
1084 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
1085 return 3;
1086 break;
Dave Chapman06e25c82006-01-23 16:00:06 +00001087 }
1088 }
1089}
1090
1091int help(int when)
1092{
1093 int w,h;
1094 int button;
Ben Bashaa39aeb12006-02-19 21:24:46 +00001095 int xoffset=0;
1096 int yoffset=0;
1097 /* set the maximum x and y in the helpscreen
1098 dont forget to update, if you change text */
Nils Wallméniusd86350c2006-11-02 18:50:08 +00001099 int maxY=180;
1100 int maxX=215;
Dave Chapman06e25c82006-01-23 16:00:06 +00001101
Daniel Stenberga26d3152006-03-03 07:24:34 +00001102 while(true) {
Ben Bashaa39aeb12006-02-19 21:24:46 +00001103#ifdef HAVE_LCD_COLOR
Dave Chapman06e25c82006-01-23 16:00:06 +00001104 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);
Ben Bashaa39aeb12006-02-19 21:24:46 +00001108#else
Daniel Stenberga26d3152006-03-03 07:24:34 +00001109 rb->lcd_clear_display();
Ben Bashaa39aeb12006-02-19 21:24:46 +00001110#endif
Dave Chapman06e25c82006-01-23 16:00:06 +00001111
1112 rb->lcd_getstringsize("BrickMania", &w, &h);
Ben Bashaa39aeb12006-02-19 21:24:46 +00001113 rb->lcd_putsxy(LCD_WIDTH/2-w/2+xoffset, 1+yoffset, "BrickMania");
Dave Chapman06e25c82006-01-23 16:00:06 +00001114
Ben Bashaa39aeb12006-02-19 21:24:46 +00001115#ifdef HAVE_LCD_COLOR
Dave Chapman06e25c82006-01-23 16:00:06 +00001116 rb->lcd_set_foreground(LCD_RGBPACK(245,0,0));
Ben Bashaa39aeb12006-02-19 21:24:46 +00001117 rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim");
Dave Chapman06e25c82006-01-23 16:00:06 +00001118 rb->lcd_set_foreground(LCD_WHITE);
Ben Bashaa39aeb12006-02-19 21:24:46 +00001119#else
1120 rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim");
1121#endif
Daniel Stenberga26d3152006-03-03 07:24:34 +00001122 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.");
Ben Bashaa39aeb12006-02-19 21:24:46 +00001126#ifdef HAVE_LCD_COLOR
Dave Chapman06e25c82006-01-23 16:00:06 +00001127 rb->lcd_set_foreground(LCD_RGBPACK(245,0,0));
Ben Bashaa39aeb12006-02-19 21:24:46 +00001128 rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls");
Dave Chapman06e25c82006-01-23 16:00:06 +00001129 rb->lcd_set_foreground(LCD_WHITE);
Ben Bashaa39aeb12006-02-19 21:24:46 +00001130#else
1131 rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls");
Daniel Stenberga26d3152006-03-03 07:24:34 +00001132#endif
Ben Bashaa39aeb12006-02-19 21:24:46 +00001133 rb->lcd_putsxy(1+xoffset, 6*(h+2)+yoffset,"< & > Move the paddle");
Ben Bashad330ef72006-02-22 10:34:36 +00001134#if CONFIG_KEYPAD == ONDIO_PAD
Daniel Stenberga26d3152006-03-03 07:24:34 +00001135 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,
1136 "MENU Releases the ball/Fire!");
Jens Arnold29361ab2008-03-22 10:24:28 +00001137#elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD)
Daniel Stenberga26d3152006-03-03 07:24:34 +00001138 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,
1139 "PLAY Releases the ball/Fire!");
Ben Bashad330ef72006-02-22 10:34:36 +00001140#elif CONFIG_KEYPAD == IRIVER_H300_PAD
Daniel Stenberga26d3152006-03-03 07:24:34 +00001141 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,
1142 "NAVI Releases the ball/Fire!");
Ben Bashad330ef72006-02-22 10:34:36 +00001143#else
Daniel Stenberga26d3152006-03-03 07:24:34 +00001144 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,
1145 "SELECT Releases the ball/Fire!");
Ben Bashad330ef72006-02-22 10:34:36 +00001146#endif
Jens Arnold29361ab2008-03-22 10:24:28 +00001147#if CONFIG_KEYPAD == IAUDIO_M3_PAD
1148 rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "REC Opens menu/Quit");
1149#else
Daniel Stenberga26d3152006-03-03 07:24:34 +00001150 rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "STOP Opens menu/Quit");
Jens Arnold29361ab2008-03-22 10:24:28 +00001151#endif
Ben Bashaa39aeb12006-02-19 21:24:46 +00001152#ifdef HAVE_LCD_COLOR
Dave Chapman06e25c82006-01-23 16:00:06 +00001153 rb->lcd_set_foreground(LCD_RGBPACK(245,0,0));
Daniel Stenberga26d3152006-03-03 07:24:34 +00001154 rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials");
Dave Chapman06e25c82006-01-23 16:00:06 +00001155 rb->lcd_set_foreground(LCD_WHITE);
Ben Bashaa39aeb12006-02-19 21:24:46 +00001156#else
Daniel Stenberga26d3152006-03-03 07:24:34 +00001157 rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials");
Ben Bashaa39aeb12006-02-19 21:24:46 +00001158#endif
Daniel Stenberga26d3152006-03-03 07:24:34 +00001159 rb->lcd_putsxy(1+xoffset, 11*(h+2)+yoffset,
Nils Wallméniusd86350c2006-11-02 18:50:08 +00001160 "N Normal:returns paddle to normal");
1161 rb->lcd_putsxy(1+xoffset, 12*(h+2)+yoffset, "D DIE!:loses a life");
Daniel Stenberga26d3152006-03-03 07:24:34 +00001162 rb->lcd_putsxy(1+xoffset, 13*(h+2)+yoffset,
Nils Wallméniusd86350c2006-11-02 18:50:08 +00001163 "L Life:gains a life/power up");
Daniel Stenberga26d3152006-03-03 07:24:34 +00001164 rb->lcd_putsxy(1+xoffset, 14*(h+2)+yoffset,
Nils Wallméniusd86350c2006-11-02 18:50:08 +00001165 "F Fire:allows you to shoot bricks");
Daniel Stenberga26d3152006-03-03 07:24:34 +00001166 rb->lcd_putsxy(1+xoffset, 15*(h+2)+yoffset,
Nils Wallméniusd86350c2006-11-02 18:50:08 +00001167 "G Glue:ball sticks to paddle");
Daniel Stenberga26d3152006-03-03 07:24:34 +00001168 rb->lcd_putsxy(1+xoffset, 16*(h+2)+yoffset,
Nils Wallméniusd86350c2006-11-02 18:50:08 +00001169 "B Ball:generates another ball");
1170 rb->lcd_putsxy(1+xoffset, 17*(h+2)+yoffset,
1171 "FL Flip:flips left / right movement");
Dave Chapman06e25c82006-01-23 16:00:06 +00001172 rb->lcd_update();
1173
1174 button=rb->button_get(true);
1175 switch (button) {
Kevin Ferrare0e027bd2006-06-30 16:43:47 +00001176#ifdef RC_QUIT
1177 case RC_QUIT:
1178#endif
Maurus Cuelenaere50763d52008-06-09 20:59:55 +00001179#ifdef HAVE_TOUCHPAD
1180 case BUTTON_TOUCHPAD:
1181#endif
Dave Chapman06e25c82006-01-23 16:00:06 +00001182 case QUIT:
Dave Chapman06e25c82006-01-23 16:00:06 +00001183 switch (game_menu(when)) {
1184 case 0:
1185 cur_level=0;
1186 life=2;
1187 int_game(1);
1188 break;
1189 case 1:
1190 con_game=1;
1191 break;
1192 case 2:
Daniel Stenberga26d3152006-03-03 07:24:34 +00001193 if (help(when)==1)
1194 return 1;
Dave Chapman06e25c82006-01-23 16:00:06 +00001195 break;
1196 case 3:
1197 return 1;
1198 break;
1199 }
Marcoen Hirschbergc296ac52006-02-24 15:13:04 +00001200 return 0;
Dave Chapman06e25c82006-01-23 16:00:06 +00001201 break;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001202 case LEFT:
1203 case LEFT | BUTTON_REPEAT:
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001204#ifdef ALTLEFT
1205 case ALTLEFT:
1206 case ALTLEFT | BUTTON_REPEAT:
1207#endif
Ben Bashaa39aeb12006-02-19 21:24:46 +00001208 if( xoffset<0)
Daniel Stenberga26d3152006-03-03 07:24:34 +00001209 xoffset+=2;
1210 break;
1211 case RIGHT:
Ben Bashaa39aeb12006-02-19 21:24:46 +00001212 case RIGHT | BUTTON_REPEAT:
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001213#ifdef ALTRIGHT
1214 case ALTRIGHT:
1215 case ALTRIGHT | BUTTON_REPEAT:
1216#endif
Ben Bashaa39aeb12006-02-19 21:24:46 +00001217 if(xoffset+maxX > LCD_WIDTH)
Daniel Stenberga26d3152006-03-03 07:24:34 +00001218 xoffset-=2;
1219 break;
1220 case UP:
1221 case UP | BUTTON_REPEAT:
1222 if(yoffset <0)
1223 yoffset+=2;
1224 break;
1225 case DOWN:
1226 case DOWN | BUTTON_REPEAT:
1227 if(yoffset+maxY > LCD_HEIGHT)
1228 yoffset-=2;
1229 break;
Zakk Roberts4bdef7a2007-01-26 06:14:29 +00001230
Ben Bashaa39aeb12006-02-19 21:24:46 +00001231 default:
1232 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
1233 return 1;
1234 break;
Dave Chapman06e25c82006-01-23 16:00:06 +00001235 }
1236 }
Marcoen Hirschbergc296ac52006-02-24 15:13:04 +00001237 return 0;
Dave Chapman06e25c82006-01-23 16:00:06 +00001238}
1239
Daniel Stenberga26d3152006-03-03 07:24:34 +00001240int pad_check(int ballxc, int mode, int pon ,int ballnum)
Dave Chapman06e25c82006-01-23 16:00:06 +00001241{
1242 /* pon: positive(1) or negative(0) */
1243
1244 if (mode==0) {
1245 if (pon == 0)
1246 return -ballxc;
1247 else
1248 return ballxc;
1249 } else {
Ben Basha26e598d2006-02-15 17:37:45 +00001250 if (ball[ballnum].x > 0)
Dave Chapman06e25c82006-01-23 16:00:06 +00001251 return ballxc;
1252 else
1253 return ballxc*-1;
1254 }
1255}
1256
1257int fire_space(void)
1258{
1259 int t;
1260 for(t=0;t<=30;t++)
1261 if (fire[t].top+7 < 0)
1262 return t;
1263
Marcoen Hirschbergc296ac52006-02-24 15:13:04 +00001264 return 0;
Dave Chapman06e25c82006-01-23 16:00:06 +00001265}
1266
Daniel Stenberga26d3152006-03-03 07:24:34 +00001267int game_loop(void)
1268{
Dave Chapman06e25c82006-01-23 16:00:06 +00001269 int j,i,k,bricky,brickx;
Ben Bashad330ef72006-02-22 10:34:36 +00001270 char s[30];
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001271 int sec_count=0,num_count=10;
Dave Chapman553c9e22006-01-27 10:02:13 +00001272 int end;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001273
Dave Chapman06e25c82006-01-23 16:00:06 +00001274 rb->srand( *rb->current_tick );
1275
1276 configfile_init(rb);
1277 configfile_load(HIGH_SCORE,config,1,0);
1278
Daniel Stenberga26d3152006-03-03 07:24:34 +00001279 switch(game_menu(0)) {
Dave Chapman06e25c82006-01-23 16:00:06 +00001280 case 0:
1281 cur_level = 0;
1282 life = 2;
1283 int_game(1);
1284 break;
1285 case 1:
1286 con_game = 1;
1287 break;
1288 case 2:
1289 if (help(0) == 1) return 1;
1290 break;
1291 case 3:
1292 return 1;
1293 break;
1294 }
1295
Dave Chapman553c9e22006-01-27 10:02:13 +00001296 while(true) {
1297 /* Convert CYCLETIME (in ms) to HZ */
1298 end = *rb->current_tick + (CYCLETIME * HZ) / 1000;
1299
Dave Chapman06e25c82006-01-23 16:00:06 +00001300 if (life >= 0) {
Ben Bashaa39aeb12006-02-19 21:24:46 +00001301#ifdef HAVE_LCD_COLOR
Dave Chapman06e25c82006-01-23 16:00:06 +00001302 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);
Jonathan Gordon5d173ea2007-04-19 12:14:54 +00001306#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);
1310#endif
Dave Chapman06e25c82006-01-23 16:00:06 +00001311 rb->lcd_set_foreground(LCD_WHITE);
Ben Bashaa39aeb12006-02-19 21:24:46 +00001312#else
Daniel Stenberga26d3152006-03-03 07:24:34 +00001313 rb->lcd_clear_display();
Ben Bashaa39aeb12006-02-19 21:24:46 +00001314#endif
Daniel Stenberga26d3152006-03-03 07:24:34 +00001315
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001316 if (flip_sides) {
Daniel Stenberga26d3152006-03-03 07:24:34 +00001317 if (*rb->current_tick>=sec_count) {
1318 sec_count=*rb->current_tick+HZ;
1319 if (num_count!=0)
1320 num_count--;
1321 else
1322 flip_sides=false;
1323 }
1324 rb->snprintf(s, sizeof(s), "%d", num_count);
1325 rb->lcd_getstringsize(s, &sw, NULL);
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001326 rb->lcd_putsxy(LCD_WIDTH/2-2, STRINGPOS_FLIP, s);
Daniel Stenberga26d3152006-03-03 07:24:34 +00001327 }
1328
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001329 /* write life num */
Ben Bashad330ef72006-02-22 10:34:36 +00001330#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1331 rb->snprintf(s, sizeof(s), "L:%d", life);
1332 rb->lcd_putsxy(0, 0, s);
1333#else
Dave Chapman06e25c82006-01-23 16:00:06 +00001334 rb->snprintf(s, sizeof(s), "Life: %d", life);
1335 rb->lcd_putsxy(2, 2, s);
Ben Bashad330ef72006-02-22 10:34:36 +00001336#endif
Daniel Stenberga26d3152006-03-03 07:24:34 +00001337
Ben Bashad330ef72006-02-22 10:34:36 +00001338#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);
1342#else
Dave Chapman06e25c82006-01-23 16:00:06 +00001343 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);
Ben Bashad330ef72006-02-22 10:34:36 +00001346#endif
Dave Chapman06e25c82006-01-23 16:00:06 +00001347
Dave Chapman06e25c82006-01-23 16:00:06 +00001348 if (vscore<score) vscore++;
1349 rb->snprintf(s, sizeof(s), "%d", vscore);
1350 rb->lcd_getstringsize(s, &sw, NULL);
Ben Bashad330ef72006-02-22 10:34:36 +00001351#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1352 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s);
1353#else
Dave Chapman06e25c82006-01-23 16:00:06 +00001354 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 2, s);
Ben Bashad330ef72006-02-22 10:34:36 +00001355#endif
Dave Chapman06e25c82006-01-23 16:00:06 +00001356
1357 /* continue game */
1358 if (con_game== 1 && start_game!=1) {
Ben Bashad330ef72006-02-22 10:34:36 +00001359#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");
Jens Arnold29361ab2008-03-22 10:24:28 +00001363#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
1364 rb->snprintf(s, sizeof(s), "PLAY To Continue");
Ben Bashad330ef72006-02-22 10:34:36 +00001365#else
1366 rb->snprintf(s, sizeof(s), "Press SELECT To Continue");
1367#endif
1368 rb->lcd_getstringsize(s, &sw, NULL);
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001369 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_NAVI, s);
Ben Bashad330ef72006-02-22 10:34:36 +00001370
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001371 sec_count=*rb->current_tick+HZ;
Dave Chapman06e25c82006-01-23 16:00:06 +00001372 }
1373
1374 /* draw the ball */
Ben Basha26e598d2006-02-15 17:37:45 +00001375 for(i=0;i<used_balls;i++)
Daniel Stenberga26d3152006-03-03 07:24:34 +00001376 rb->lcd_bitmap(brickmania_ball,ball[i].pos_x, ball[i].pos_y,
1377 BALL, BALL);
Dave Chapman06e25c82006-01-23 16:00:06 +00001378
Daniel Stenberga26d3152006-03-03 07:24:34 +00001379 if (brick_on_board==0)
1380 brick_on_board--;
Dave Chapman06e25c82006-01-23 16:00:06 +00001381
1382 /* if the pad is fire */
1383 for(i=0;i<=30;i++) {
1384 if (fire[i].top+7>0) {
1385 if (con_game!=1)
1386 fire[i].top-=4;
1387 rb->lcd_vline(fire[i].left, fire[i].top, fire[i].top+7);
1388 }
1389 }
1390
1391 /* the bricks */
1392 for (i=0;i<=7;i++) {
1393 for (j=0;j<=9;j++) {
Ben Basha26e598d2006-02-15 17:37:45 +00001394 if (brick[i*10+j].power<7) {
Dave Chapman06e25c82006-01-23 16:00:06 +00001395 if (brick[i*10+j].poweruse==2) {
1396 if (con_game!=1)
1397 brick[i*10+j].powertop+=2;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001398 rb->lcd_bitmap_part(brickmania_powerups,0,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001399 POWERUP_HEIGHT*brick[i*10+j
Daniel Stenberga26d3152006-03-03 07:24:34 +00001400 ].power,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001401 POWERUP_WIDTH,
Daniel Stenberga26d3152006-03-03 07:24:34 +00001402 LEFTMARGIN+j*BRICK_WIDTH+
1403 (BRICK_WIDTH/2-
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001404 POWERUP_WIDTH/2),
Daniel Stenberga26d3152006-03-03 07:24:34 +00001405 brick[i*10+j].powertop,
Marianne Arnold2e5f8f52007-12-30 14:56:51 +00001406 POWERUP_WIDTH,
1407 POWERUP_HEIGHT);
Dave Chapman06e25c82006-01-23 16:00:06 +00001408 }
Daniel Stenberga26d3152006-03-03 07:24:34 +00001409 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001410
Daniel Stenberga26d3152006-03-03 07:24:34 +00001411 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) {
Dave Chapman06e25c82006-01-23 16:00:06 +00001415 switch(brick[i*10+j].power) {
1416 case 0:
1417 life++;
1418 score+=50;
1419 break;
1420 case 1:
1421 life--;
1422 if (life>=0) {
1423 int_game(0);
Ben Basha9131c4a2006-02-17 16:02:37 +00001424 sleep(2);
Dave Chapman06e25c82006-01-23 16:00:06 +00001425 }
1426 break;
1427 case 2:
1428 score+=34;
1429 pad_type=1;
1430 break;
1431 case 3:
1432 score+=47;
1433 pad_type=2;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001434 for(k=0;k<used_balls;k++)
Ben Basha26e598d2006-02-15 17:37:45 +00001435 ball[k].glue=false;
Dave Chapman06e25c82006-01-23 16:00:06 +00001436 break;
1437 case 4:
1438 score+=23;
1439 pad_type=0;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001440 for(k=0;k<used_balls;k++)
Ben Basha26e598d2006-02-15 17:37:45 +00001441 ball[k].glue=false;
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001442 flip_sides=false;
Dave Chapman06e25c82006-01-23 16:00:06 +00001443 break;
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001444 case 5:
Daniel Stenberga26d3152006-03-03 07:24:34 +00001445 score+=23;
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001446 sec_count=*rb->current_tick+HZ;
1447 num_count=10;
1448 flip_sides=!flip_sides;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001449 break;
Ben Basha26e598d2006-02-15 17:37:45 +00001450 case 6:
1451 score+=23;
1452 used_balls++;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001453 ball[used_balls-1].x= rb->rand()%1 == 0 ?
1454 -1 : 1;
Ben Basha26e598d2006-02-15 17:37:45 +00001455 ball[used_balls-1].y= -4;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001456 break;
Dave Chapman06e25c82006-01-23 16:00:06 +00001457 }
Daniel Stenberga26d3152006-03-03 07:24:34 +00001458 brick[i*10+j].poweruse=1;
1459 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001460
Daniel Stenberga26d3152006-03-03 07:24:34 +00001461 if (brick[i*10+j].powertop>PAD_POS_Y)
1462 brick[i*10+j].poweruse=1;
Zakk Roberts4bdef7a2007-01-26 06:14:29 +00001463
Daniel Stenberga26d3152006-03-03 07:24:34 +00001464 brickx=LEFTMARGIN+j*BRICK_WIDTH;
1465 bricky=TOPMARGIN+i*BRICK_HEIGHT;
1466 if (pad_type==2) {
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)) {
1473 score+=13;
1474 fire[k].top=-16;
1475 if (brick[i*10+j].hits > 0) {
1476 brick[i*10+j].hits--;
1477 brick[i*10+j].hiteffect++;
1478 score+=3;
1479 }
1480 else {
1481 brick[i*10+j].used=0;
1482 if (brick[i*10+j].power!=10)
1483 brick[i*10+j].poweruse=2;
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001484 brick_on_board--;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001485 }
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001486 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001487 }
1488 }
1489 }
Zakk Roberts4bdef7a2007-01-26 06:14:29 +00001490
Daniel Stenberga26d3152006-03-03 07:24:34 +00001491 if (brick[i*10+j].used==1) {
1492 rb->lcd_bitmap_part(brickmania_bricks,0,
1493 BRICK_HEIGHT*brick[i*10+j].color,
1494 BRICK_WIDTH,
1495 LEFTMARGIN+j*BRICK_WIDTH,
1496 TOPMARGIN+i*BRICK_HEIGHT,
1497 BRICK_WIDTH, BRICK_HEIGHT);
Ben Bashaa39aeb12006-02-19 21:24:46 +00001498#ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
Daniel Stenberga26d3152006-03-03 07:24:34 +00001499 if (brick[i*10+j].hiteffect>0)
1500 rb->lcd_bitmap_transparent_part(brickmania_break,
1501 0,
1502 BRICK_HEIGHT*brick[i*10+j].hiteffect,
1503 BRICK_WIDTH,
1504 LEFTMARGIN+j*BRICK_WIDTH,
1505 TOPMARGIN+i*BRICK_HEIGHT,
1506 BRICK_WIDTH,
1507 BRICK_HEIGHT);
Ben Bashaa39aeb12006-02-19 21:24:46 +00001508#endif
Daniel Stenberga26d3152006-03-03 07:24:34 +00001509 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001510
Daniel Stenberga26d3152006-03-03 07:24:34 +00001511 for(k=0;k<used_balls;k++) {
Zakk Roberts4bdef7a2007-01-26 06:14:29 +00001512 if (ball[k].pos_y <160) {
Daniel Stenberga26d3152006-03-03 07:24:34 +00001513 if (brick[i*10+j].used==1) {
1514 if ((ball[k].pos_x+ball[k].x+HALFBALL >=
1515 brickx &&
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)) &&
1522 (ball[k].y >0)) {
1523 ball[k].tempy=bricky-ball[k].pos_y-BALL;
Dave Chapman06e25c82006-01-23 16:00:06 +00001524 }
Daniel Stenberga26d3152006-03-03 07:24:34 +00001525 else if ((ball[k].pos_x+ball[k].x+HALFBALL >=
1526 brickx &&
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)) &&
1533 (ball[k].y <0)) {
1534 ball[k].tempy=
1535 -(ball[k].pos_y-(bricky+BRICK_HEIGHT));
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001536 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001537
Daniel Stenberga26d3152006-03-03 07:24:34 +00001538 if ((ball[k].pos_y+HALFBALL >=
1539 bricky &&
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)) &&
1546 (ball[k].x >0)) {
1547 ball[k].tempx=brickx-ball[k].pos_x-BALL;
Linus Nielsen Feltzing3325d992006-01-26 23:31:00 +00001548 }
Daniel Stenberga26d3152006-03-03 07:24:34 +00001549 else if ((ball[k].pos_y+ball[k].y+HALFBALL >=
1550 bricky &&
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-
1556 BALL &&
1557 brickx+BRICK_WIDTH>ball[k].pos_x-
1558 BALL)) && (ball[k].x <0)) {
1559 ball[k].tempx=
1560 -(ball[k].pos_x-(brickx+BRICK_WIDTH));
1561 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001562
Daniel Stenberga26d3152006-03-03 07:24:34 +00001563 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++;
1573 score+=2;
1574 }
1575 else {
1576 brick[i*10+j].used=0;
1577 if (brick[i*10+j].power!=10)
1578 brick[i*10+j].poweruse=2;
1579 }
1580
1581 ball[k].y = ball[k].y*-1;
1582 }
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++;
1593 score+=2;
1594 }
1595 else {
1596 brick[i*10+j].used=0;
1597 if (brick[i*10+j].power!=10)
1598 brick[i*10+j].poweruse=2;
1599 }
1600
1601 ball[k].y = ball[k].y*-1;
1602 }
1603
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++;
1614 score+=2;
1615 }
1616 else {
1617 brick[i*10+j].used=0;
1618 if (brick[i*10+j].power!=10)
1619 brick[i*10+j].poweruse=2;
1620 }
1621 ball[k].x = ball[k].x*-1;
1622
1623 }
1624 else if ((ball[k].pos_y+HALFBALL >= bricky &&
1625 ball[k].pos_y+HALFBALL <=
1626 bricky+BRICK_HEIGHT) &&
1627 ((brickx+BRICK_WIDTH==
1628 ball[k].pos_x) ||
1629 (brickx+BRICK_WIDTH-6<=
1630 ball[k].pos_x &&
1631 brickx+BRICK_WIDTH>
1632 ball[k].pos_x)) &&
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++;
1637 score+=2;
1638 }
1639 else {
1640 brick[i*10+j].used=0;
1641 if (brick[i*10+j].power!=10)
1642 brick[i*10+j].poweruse=2;
1643 }
1644
1645 ball[k].x = ball[k].x*-1;
1646 }
1647
1648 if (brick[i*10+j].used==0) {
1649 brick_on_board--;
1650 score+=8;
1651 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001652 }
1653 }
Daniel Stenberga26d3152006-03-03 07:24:34 +00001654 } /* for k */
Ben Basha26e598d2006-02-15 17:37:45 +00001655 } /* for j */
1656 } /* for i */
Dave Chapman06e25c82006-01-23 16:00:06 +00001657
1658 /* draw the pad */
Daniel Stenberga26d3152006-03-03 07:24:34 +00001659 rb->lcd_bitmap_part(brickmania_pads,0,pad_type*PAD_HEIGHT,
1660 PAD_WIDTH,pad_pos_x, PAD_POS_Y, PAD_WIDTH,
1661 PAD_HEIGHT);
1662
Ben Basha26e598d2006-02-15 17:37:45 +00001663 for(k=0;k<used_balls;k++) {
Daniel Stenberga26d3152006-03-03 07:24:34 +00001664
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))
Ben Basha26e598d2006-02-15 17:37:45 +00001669 ball[k].tempy=PAD_POS_Y-ball[k].pos_y-BALL;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001670 else if ((4>ball[k].pos_y && 0<ball[k].pos_y) &&
1671 (ball[k].y <0))
Ben Basha26e598d2006-02-15 17:37:45 +00001672 ball[k].tempy=-ball[k].pos_y;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001673 if ((LCD_WIDTH-4<ball[k].pos_x+BALL &&
1674 LCD_WIDTH>ball[k].pos_x+BALL) && (ball[k].x >0))
Ben Basha26e598d2006-02-15 17:37:45 +00001675 ball[k].tempx=LCD_WIDTH-ball[k].pos_x-BALL;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001676 else if ((4>ball[k].pos_x && 0<ball[k].pos_x) &&
1677 (ball[k].x <0))
Ben Basha26e598d2006-02-15 17:37:45 +00001678 ball[k].tempx=-ball[k].pos_x;
Dave Chapman06e25c82006-01-23 16:00:06 +00001679
Ben Basha26e598d2006-02-15 17:37:45 +00001680 /* top line */
1681 if (ball[k].pos_y<= 0)
1682 ball[k].y = ball[k].y*-1;
1683 /* bottom line */
Nicolas Pennequin5a29fe12007-02-14 22:59:36 +00001684 else if (ball[k].pos_y+BALL >= GAMESCREEN_HEIGHT) {
Ben Basha26e598d2006-02-15 17:37:45 +00001685 if (used_balls>1) {
1686 used_balls--;
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;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001694
Ben Basha26e598d2006-02-15 17:37:45 +00001695 ball[used_balls].x=0;
1696 ball[used_balls].y=0;
1697 ball[used_balls].tempy=0;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001698 ball[used_balls].tempx=0;
Ben Basha26e598d2006-02-15 17:37:45 +00001699 ball[used_balls].pos_y=PAD_POS_Y-BALL;
1700 ball[used_balls].pos_x=pad_pos_x+(PAD_WIDTH/2)-2;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001701
Ben Basha26e598d2006-02-15 17:37:45 +00001702 k--;
1703 continue;
Dave Chapman06e25c82006-01-23 16:00:06 +00001704 } else {
Ben Basha26e598d2006-02-15 17:37:45 +00001705 life--;
Daniel Stenberga26d3152006-03-03 07:24:34 +00001706 if (life>=0) {
Ben Basha26e598d2006-02-15 17:37:45 +00001707 int_game(0);
Ben Basha9131c4a2006-02-17 16:02:37 +00001708 sleep(2);
Ben Basha26e598d2006-02-15 17:37:45 +00001709 }
Dave Chapman06e25c82006-01-23 16:00:06 +00001710 }
1711 }
Daniel Stenberga26d3152006-03-03 07:24:34 +00001712
Ben Basha26e598d2006-02-15 17:37:45 +00001713 /* left line ,right line */
Daniel Stenberga26d3152006-03-03 07:24:34 +00001714 if ((ball[k].pos_x <= 0) ||
1715 (ball[k].pos_x+BALL >= LCD_WIDTH)) {
Ben Basha26e598d2006-02-15 17:37:45 +00001716 ball[k].x = ball[k].x*-1;
Ben Basha9131c4a2006-02-17 16:02:37 +00001717 ball[k].pos_x = ball[k].pos_x <= 0 ? 0 : LCD_WIDTH-BALL;
1718 }
Ben Bashaa39aeb12006-02-19 21:24:46 +00001719
Daniel Stenberga26d3152006-03-03 07:24:34 +00001720 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) {
Ben Bashaa39aeb12006-02-19 21:24:46 +00001724
Daniel Stenberga26d3152006-03-03 07:24:34 +00001725 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)) {
Zakk Roberts