Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 10 | * Copyright (C) 2005, 2006 Ben Basha (Paprica) |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 16 | * |
| 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'Hoye | cb53e3c | 2007-08-15 12:42:09 +0000 | [diff] [blame] | 24 | #include "helper.h" |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 25 | |
| 26 | PLUGIN_HEADER |
| 27 | |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 28 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 29 | #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 Ferrare | 0e027bd | 2006-06-30 16:43:47 +0000 | [diff] [blame] | 38 | #define RC_QUIT BUTTON_RC_STOP |
| 39 | |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 40 | |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 41 | #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 Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 50 | |
| 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 Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 60 | |
Dave Chapman | d64e626 | 2007-01-14 13:48:09 +0000 | [diff] [blame] | 61 | #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 Chapman | d64e626 | 2007-01-14 13:48:09 +0000 | [diff] [blame] | 70 | |
Jens Arnold | b701322 | 2007-07-27 09:57:27 +0000 | [diff] [blame] | 71 | #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ |
| 72 | (CONFIG_KEYPAD == IPOD_3G_PAD) || \ |
| 73 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 74 | |
| 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 Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 82 | #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD) |
| 83 | #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK) |
| 84 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 85 | |
Marcoen Hirschberg | 338e2bb | 2006-02-24 15:42:52 +0000 | [diff] [blame] | 86 | #elif (CONFIG_KEYPAD == GIGABEAT_PAD) |
| 87 | |
Marcoen Hirschberg | a7168fe | 2007-05-19 23:38:09 +0000 | [diff] [blame] | 88 | #define QUIT BUTTON_POWER |
Marcoen Hirschberg | 338e2bb | 2006-02-24 15:42:52 +0000 | [diff] [blame] | 89 | #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 Hirschberg | 338e2bb | 2006-02-24 15:42:52 +0000 | [diff] [blame] | 95 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 96 | #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 97 | |
| 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 Stenberg | 451f08a | 2006-08-03 20:40:37 +0000 | [diff] [blame] | 105 | |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 106 | #elif CONFIG_KEYPAD == SANSA_E200_PAD |
| 107 | |
Michael Sevakis | 8970055 | 2007-05-22 06:31:44 +0000 | [diff] [blame] | 108 | #define QUIT BUTTON_POWER |
| 109 | #define LEFT BUTTON_LEFT |
| 110 | #define RIGHT BUTTON_RIGHT |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 111 | #define SELECT BUTTON_SELECT |
Jonathan Gordon | 81ba146 | 2008-01-10 08:08:31 +0000 | [diff] [blame] | 112 | #define UP BUTTON_SCROLL_BACK |
| 113 | #define DOWN BUTTON_SCROLL_FWD |
Michael Sevakis | 8970055 | 2007-05-22 06:31:44 +0000 | [diff] [blame] | 114 | |
Jonathan Gordon | 81ba146 | 2008-01-10 08:08:31 +0000 | [diff] [blame] | 115 | #define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD) |
| 116 | #define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK) |
Marianne Arnold | 0d8fd45 | 2008-01-09 21:06:42 +0000 | [diff] [blame] | 117 | |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 118 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 119 | #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 Stenberg | 1e88be5 | 2006-08-03 20:17:25 +0000 | [diff] [blame] | 132 | |
| 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 Robertson | 8215b34 | 2008-02-17 12:23:02 +0000 | [diff] [blame] | 140 | #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 Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 148 | |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 149 | #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 Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 158 | #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 Purchase | 554d7ed | 2008-03-22 22:03:34 +0000 | [diff] [blame] | 169 | #elif CONFIG_KEYPAD == COWOND2_PAD |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 170 | #define QUIT BUTTON_POWER |
Rob Purchase | 554d7ed | 2008-03-22 22:03:34 +0000 | [diff] [blame] | 171 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 172 | #else |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 173 | #error No keymap defined! |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 174 | #endif |
| 175 | |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 176 | #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 Arnold | 0d8fd45 | 2008-01-09 21:06:42 +0000 | [diff] [blame] | 194 | #ifndef SCROLL_FWD /* targets without scroll wheel*/ |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 195 | #define SCROLL_FWD(x) (0) |
| 196 | #define SCROLL_BACK(x) (0) |
| 197 | #endif |
| 198 | |
| 199 | |
Steve Bavin | 6526577 | 2008-05-13 09:57:56 +0000 | [diff] [blame] | 200 | static const struct plugin_api* rb; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 201 | |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 202 | enum 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 Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 213 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 214 | #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 Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 242 | #ifdef HAVE_LCD_COLOR /* currently no transparency for non-colour */ |
| 243 | #include "brickmania_break.h" |
| 244 | #endif |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 245 | |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 246 | #if (LCD_WIDTH == 320) && (LCD_HEIGHT == 240) |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 247 | |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 248 | /* The time (in ms) for one iteration through the game loop - decrease this |
| 249 | to speed up the game - note that current_tick is (currently) only accurate |
| 250 | to 10ms. |
| 251 | */ |
| 252 | #define CYCLETIME 30 |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 253 | |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 254 | #define TOPMARGIN 30 |
| 255 | |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 256 | #define BMPYOFS_start 110 |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 257 | #define HIGHSCORE_XPOS 57 |
| 258 | #define HIGHSCORE_YPOS 88 |
| 259 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 260 | #define STRINGPOS_FINISH 140 |
| 261 | #define STRINGPOS_CONGRATS 157 |
| 262 | #define STRINGPOS_NAVI 150 |
| 263 | #define STRINGPOS_FLIP 150 |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 264 | |
| 265 | #elif (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176) |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 266 | |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 267 | /* The time (in ms) for one iteration through the game loop - decrease this |
| 268 | to speed up the game - note that current_tick is (currently) only accurate |
| 269 | to 10ms. |
| 270 | */ |
| 271 | #define CYCLETIME 30 |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 272 | |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 273 | /* Offsets for LCDS > 220x176 */ |
Nicolas Pennequin | 5a29fe1 | 2007-02-14 22:59:36 +0000 | [diff] [blame] | 274 | |
| 275 | #define GAMESCREEN_HEIGHT 176 |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 276 | #define TOPMARGIN 30 |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 277 | |
Nicolas Pennequin | 5a29fe1 | 2007-02-14 22:59:36 +0000 | [diff] [blame] | 278 | #define XOFS ((LCD_WIDTH-220)/BRICK_WIDTH/2)*BRICK_WIDTH |
| 279 | #define YOFS ((LCD_HEIGHT-176)/BRICK_HEIGHT/2)*BRICK_HEIGHT |
| 280 | |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 281 | #define BMPYOFS_start (78+YOFS) |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 282 | #define HIGHSCORE_XPOS (17+XOFS) |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 283 | #define HIGHSCORE_YPOS (56+YOFS) |
| 284 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 285 | #define STRINGPOS_FINISH 140 |
| 286 | #define STRINGPOS_CONGRATS 157 |
| 287 | #define STRINGPOS_NAVI 150 |
| 288 | #define STRINGPOS_FLIP 150 |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 289 | |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 290 | #elif (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 291 | /* The time (in ms) for one iteration through the game loop - decrease this |
| 292 | to speed up the game - note that current_tick is (currently) only accurate |
| 293 | to 10ms. |
| 294 | */ |
| 295 | #define CYCLETIME 50 |
| 296 | |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 297 | #define TOPMARGIN 21 |
| 298 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 299 | #if LCD_DEPTH > 2 |
| 300 | #define BMPYOFS_start 58 |
Ben Basha | f12a576 | 2006-03-24 12:36:47 +0000 | [diff] [blame] | 301 | #else |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 302 | #define BMPYOFS_start 66 |
Ben Basha | f12a576 | 2006-03-24 12:36:47 +0000 | [diff] [blame] | 303 | #endif |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 304 | #define HIGHSCORE_XPOS 10 |
| 305 | #define HIGHSCORE_YPOS 38 |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 306 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 307 | #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 Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 344 | #define HIGHSCORE_YPOS 36 |
| 345 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 346 | #define STRINGPOS_FINISH 55 |
| 347 | #define STRINGPOS_CONGRATS 45 |
| 348 | #define STRINGPOS_NAVI 60 |
| 349 | #define STRINGPOS_FLIP 60 |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 350 | |
Ben Basha | 390f167 | 2006-04-11 20:16:05 +0000 | [diff] [blame] | 351 | /* 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 Basha | 390f167 | 2006-04-11 20:16:05 +0000 | [diff] [blame] | 359 | #define TOPMARGIN 10 |
| 360 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 361 | #define BMPYOFS_start 51 |
| 362 | #define HIGHSCORE_XPOS 73 |
| 363 | #define HIGHSCORE_YPOS 25 |
Ben Basha | 390f167 | 2006-04-11 20:16:05 +0000 | [diff] [blame] | 364 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 365 | #define STRINGPOS_FINISH 54 |
| 366 | #define STRINGPOS_CONGRATS 44 |
| 367 | #define STRINGPOS_NAVI 44 |
| 368 | #define STRINGPOS_FLIP 44 |
Ben Basha | 390f167 | 2006-04-11 20:16:05 +0000 | [diff] [blame] | 369 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 370 | /* 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 Basha | 390f167 | 2006-04-11 20:16:05 +0000 | [diff] [blame] | 377 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 378 | #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 Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 390 | #elif (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) |
| 391 | /* The time (in ms) for one iteration through the game loop - decrease this |
| 392 | to speed up the game - note that current_tick is (currently) only accurate |
| 393 | to 10ms. |
| 394 | */ |
| 395 | #define CYCLETIME 75 |
| 396 | |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 397 | #define TOPMARGIN 10 |
| 398 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 399 | #define BMPYOFS_start 22 |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 400 | #define HIGHSCORE_XPOS 0 |
| 401 | #define HIGHSCORE_YPOS 0 |
| 402 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 403 | #define STRINGPOS_FINISH 54 |
| 404 | #define STRINGPOS_CONGRATS 44 |
| 405 | #define STRINGPOS_NAVI 44 |
| 406 | #define STRINGPOS_FLIP 44 |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 407 | |
Jonathan Gordon | 5d173ea | 2007-04-19 12:14:54 +0000 | [diff] [blame] | 408 | /* nano and sansa */ |
| 409 | #elif (LCD_WIDTH == 176) && (LCD_HEIGHT >= 132) && (LCD_DEPTH==16) |
Ben Basha | 265d1a0 | 2006-02-20 18:56:34 +0000 | [diff] [blame] | 410 | /* The time (in ms) for one iteration through the game loop - decrease this |
| 411 | to speed up the game - note that current_tick is (currently) only accurate |
| 412 | to 10ms. |
| 413 | */ |
Jonathan Gordon | 5d173ea | 2007-04-19 12:14:54 +0000 | [diff] [blame] | 414 | |
Ben Basha | 265d1a0 | 2006-02-20 18:56:34 +0000 | [diff] [blame] | 415 | #define CYCLETIME 30 |
| 416 | |
Jonathan Gordon | 5d173ea | 2007-04-19 12:14:54 +0000 | [diff] [blame] | 417 | #define GAMESCREEN_HEIGHT 132 |
Ben Basha | 265d1a0 | 2006-02-20 18:56:34 +0000 | [diff] [blame] | 418 | #define TOPMARGIN 21 |
| 419 | |
Ben Basha | 265d1a0 | 2006-02-20 18:56:34 +0000 | [diff] [blame] | 420 | #define BMPYOFS_start 58 |
Ben Basha | 265d1a0 | 2006-02-20 18:56:34 +0000 | [diff] [blame] | 421 | #define HIGHSCORE_XPOS 7 |
| 422 | #define HIGHSCORE_YPOS 36 |
| 423 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 424 | #define STRINGPOS_FINISH 110 |
| 425 | #define STRINGPOS_CONGRATS 110 |
| 426 | #define STRINGPOS_NAVI 100 |
| 427 | #define STRINGPOS_FLIP 100 |
Ben Basha | 265d1a0 | 2006-02-20 18:56:34 +0000 | [diff] [blame] | 428 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 429 | #else |
| 430 | #error Unsupported LCD Size |
| 431 | #endif |
| 432 | |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 433 | |
| 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 Cuelenaere | 50763d5 | 2008-06-09 20:59:55 +0000 | [diff] [blame] | 451 | #ifdef HAVE_TOUCHPAD |
| 452 | #include "lib/touchscreen.h" |
| 453 | |
| 454 | static 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 | }; |
| 461 | static struct ts_mappings main_menu = {main_menu_items, 4}; |
| 462 | #endif |
| 463 | |
| 464 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 465 | int levels_num = 29; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 466 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 467 | static 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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 490 | {0x3,0x23,0x23,0x3,0x0,0x0,0x2,0x22,0x22,0x2}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 491 | {0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 492 | {0x0,0x0,0x0,0x0,0x37,0x37,0x0,0x0,0x0,0x0}, |
| 493 | {0x0,0x0,0x0,0x0,0x37,0x37,0x0,0x0,0x0,0x0}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 494 | {0x5,0x5,0x5,0x5,0x0,0x0,0x6,0x6,0x6,0x6}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 495 | {0x5,0x25,0x25,0x5,0x0,0x0,0x6,0x26,0x26,0x6}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 496 | {0x5,0x5,0x5,0x5,0x0,0x0,0x6,0x6,0x6,0x6} |
| 497 | }, |
| 498 | { /* level4 */ |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 499 | {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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 504 | {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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 513 | {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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 517 | }, |
| 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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 541 | {0x6,0x6,0x0,0x2,0x32,0x32,0x2,0x0,0x6,0x6}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 542 | {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x0}, |
| 543 | {0x0,0x6,0x6,0x0,0x0,0x0,0x0,0x6,0x6,0x0}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 544 | {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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 547 | }, |
| 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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 603 | {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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 606 | {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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 659 | {0x1,0x1,0x21,0x1,0x1,0x1,0x1,0x1,0x1,0x21}, |
| 660 | {0x1,0x0,0x0,0x3,0x0,0x0,0x3,0x1,0x31,0x1}, |
| 661 | {0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x0,0x1}, |
| 662 | {0x21,0x0,0x21,0x3,0x0,0x3,0x0,0x3,0x0,0x2}, |
| 663 | {0x1,0x0,0x1,0x21,0x0,0x12,0x0,0x0,0x0,0x0}, |
| 664 | {0x31,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x3,0x0}, |
| 665 | {0x1,0x0,0x1,0x0,0x1,0x1,0x31,0x1,0x1,0x2}, |
| 666 | {0x22,0x0,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x21} |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 667 | }, |
| 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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 679 | {0x31,0x3,0x1,0x1,0x0,0x0,0x1,0x1,0x3,0x31}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 680 | {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 681 | {0x33,0x1,0x1,0x36,0x1,0x1,0x36,0x1,0x1,0x33}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 682 | {0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0}, |
| 683 | {0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x0,0x0}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 684 | {0x21,0x3,0x1,0x21,0x2,0x2,0x21,0x1,0x3,0x21}, |
| 685 | {0x0,0x0,0x0,0x1,0x21,0x1,0x1,0x0,0x0,0x0}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 686 | {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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 710 | {0x24,0x1,0x3,0x1,0x0,0x0,0x21,0x3,0x1,0x24}, |
| 711 | {0x1,0x23,0x5,0x3,0x1,0x21,0x3,0x5,0x3,0x21}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 712 | {0x3,0x5,0x6,0x5,0x3,0x3,0x5,0x6,0x5,0x3}, |
| 713 | {0x5,0x6,0x7,0x6,0x5,0x5,0x6,0x7,0x6,0x5}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 714 | {0x6,0x7,0x2,0x27,0x6,0x6,0x27,0x2,0x7,0x6}, |
| 715 | {0x7,0x2,0x0,0x2,0x27,0x27,0x2,0x0,0x2,0x7}, |
| 716 | {0x32,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x32} |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 717 | }, |
| 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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 729 | {0x0,0x5,0x25,0x0,0x0,0x0,0x0,0x25,0x5,0x0}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 730 | {0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 731 | {0x25,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x25}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 732 | {0x5,0x0,0x3,0x0,0x6,0x6,0x0,0x3,0x0,0x5}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 733 | {0x5,0x0,0x31,0x0,0x6,0x6,0x0,0x31,0x0,0x5}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 734 | {0x5,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x5}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 735 | {0x5,0x5,0x5,0x35,0x0,0x0,0x35,0x5,0x5,0x5}, |
| 736 | {0x0,0x25,0x5,0x0,0x4,0x4,0x0,0x5,0x25,0x0} |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 737 | }, |
| 738 | { /* level 28 (DigDug) by ts-x */ |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 739 | {0x35,0x5,0x5,0x25,0x0,0x25,0x25,0x5,0x5,0x35}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 740 | {0x6,0x0,0x0,0x6,0x0,0x6,0x6,0x0,0x0,0x6}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 741 | {0x7,0x0,0x37,0x37,0x0,0x37,0x37,0x7,0x0,0x7}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 742 | {0x7,0x0,0x7,0x0,0x0,0x0,0x7,0x7,0x7,0x7}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 743 | {0x4,0x4,0x4,0x24,0x0,0x24,0x4,0x0,0x0,0x4}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 744 | {0x4,0x4,0x0,0x0,0x0,0x4,0x4,0x0,0x4,0x4}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 745 | {0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4}, |
| 746 | {0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1} |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 747 | }, |
| 748 | { /* TheEnd */ |
| 749 | {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}, |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 750 | {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0}, |
| 751 | {0x22,0x0,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0}, |
| 752 | {0x22,0x22,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0}, |
| 753 | {0x22,0x22,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0}, |
| 754 | {0x22,0x0,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0}, |
| 755 | {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0}, |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 756 | {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0} |
| 757 | } |
| 758 | }; |
| 759 | |
Ben Basha | 9131c4a | 2006-02-17 16:02:37 +0000 | [diff] [blame] | 760 | #define MAX_BALLS 10 |
| 761 | int pad_pos_x; |
| 762 | int x[MAX_BALLS],y[MAX_BALLS]; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 763 | int life; |
| 764 | int start_game,con_game; |
| 765 | int pad_type; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 766 | int score=0,vscore=0; |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 767 | bool flip_sides=false; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 768 | int cur_level=0; |
| 769 | int brick_on_board=0; |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 770 | int used_balls=1; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 771 | |
| 772 | typedef struct cube { |
| 773 | int powertop; |
| 774 | int power; |
| 775 | char poweruse; |
| 776 | char used; |
| 777 | int color; |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 778 | int hits; |
Ben Basha | db83601 | 2006-02-01 18:25:24 +0000 | [diff] [blame] | 779 | int hiteffect; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 780 | } cube; |
| 781 | cube brick[80]; |
| 782 | |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 783 | typedef 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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 792 | |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 793 | balls ball[MAX_BALLS]; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 794 | |
| 795 | typedef struct sfire { |
| 796 | int top; |
| 797 | int left; |
| 798 | } sfire; |
| 799 | sfire fire[30]; |
| 800 | |
| 801 | |
| 802 | int highscore; |
| 803 | #define MAX_POINTS 200000 /* i dont think it needs to be more */ |
| 804 | static struct configdata config[] = |
| 805 | { |
| 806 | {TYPE_INT, 0, MAX_POINTS, &highscore, "highscore", NULL, NULL} |
| 807 | }; |
| 808 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 809 | void int_game(int new_game) |
| 810 | { |
| 811 | int i,j; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 812 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 813 | pad_pos_x=LCD_WIDTH/2-PAD_WIDTH/2; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 814 | |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 815 | for(i=0;i<MAX_BALLS;i++) { |
| 816 | ball[i].x=0; |
| 817 | ball[i].y=0; |
| 818 | ball[i].tempy=0; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 819 | ball[i].tempx=0; |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 820 | 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 Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 824 | |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 825 | used_balls=1; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 826 | start_game =1; |
| 827 | con_game =0; |
| 828 | pad_type=0; |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 829 | |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 830 | flip_sides=false; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 831 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 832 | if (new_game==1) |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 833 | brick_on_board=0; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 834 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 835 | for(i=0;i<=7;i++) { |
| 836 | for(j=0;j<=9;j++) { |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 837 | brick[i*10+j].poweruse=(levels[cur_level][i][j]==0?0:1); |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 838 | 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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 843 | |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 844 | brick[i*10+j].hits=levels[cur_level][i][j]>=10? |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 845 | levels[cur_level][i][j]/16-1:0; |
Ben Basha | db83601 | 2006-02-01 18:25:24 +0000 | [diff] [blame] | 846 | brick[i*10+j].hiteffect=0; |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 847 | brick[i*10+j].powertop=TOPMARGIN+i*BRICK_HEIGHT+BRICK_HEIGHT; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 848 | brick[i*10+j].used=(levels[cur_level][i][j]==0?0:1); |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 849 | brick[i*10+j].color=(levels[cur_level][i][j]>=10? |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 850 | 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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 854 | } |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 855 | } |
| 856 | } |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 857 | } |
| 858 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 859 | int sw,i,w; |
| 860 | |
Ben Basha | 9131c4a | 2006-02-17 16:02:37 +0000 | [diff] [blame] | 861 | /* sleep timer counting the score */ |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 862 | void sleep (int secs) |
| 863 | { |
| 864 | bool done=false; |
| 865 | char s[20]; |
| 866 | int count=0; |
Ben Basha | 9131c4a | 2006-02-17 16:02:37 +0000 | [diff] [blame] | 867 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 868 | 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 Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 874 | #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 875 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 876 | #else |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 877 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 2, s); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 878 | #endif |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 879 | 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 Basha | 9131c4a | 2006-02-17 16:02:37 +0000 | [diff] [blame] | 889 | } |
| 890 | |
Hristo Kovachev | 5a0bb99 | 2006-03-21 15:24:25 +0000 | [diff] [blame] | 891 | #define HIGH_SCORE "brickmania.score" |
Ben Basha | 9131c4a | 2006-02-17 16:02:37 +0000 | [diff] [blame] | 892 | #define MENU_LENGTH 4 |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 893 | int game_menu(int when) |
| 894 | { |
| 895 | int button,cur=0; |
| 896 | char str[10]; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 897 | rb->lcd_clear_display(); |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 898 | #if LCD_DEPTH > 1 /* currently no background bmp for mono screens */ |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 899 | rb->lcd_bitmap(brickmania_menu_bg, 0, 0, MENU_BGWIDTH, MENU_BGHEIGHT); |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 900 | #endif |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 901 | while (true) { |
| 902 | for(i=0;i<MENU_LENGTH;i++) { |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 903 | #ifdef HAVE_LCD_COLOR |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 904 | if (cur==0) |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 905 | rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 906 | MENU_ITEMHEIGHT * BM_SEL_START, MENU_ITEMWIDTH, |
| 907 | MENU_ITEMXOFS, BMPYOFS_start, MENU_ITEMWIDTH, |
| 908 | MENU_ITEMHEIGHT); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 909 | else |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 910 | rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 911 | MENU_ITEMHEIGHT * BM_START, MENU_ITEMWIDTH, |
| 912 | MENU_ITEMXOFS, BMPYOFS_start, MENU_ITEMWIDTH, |
| 913 | MENU_ITEMHEIGHT); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 914 | |
| 915 | if (when==1) { |
| 916 | if (cur==1) |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 917 | rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 918 | MENU_ITEMHEIGHT * BM_SEL_RESUME, MENU_ITEMWIDTH, |
| 919 | MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH, |
| 920 | MENU_ITEMHEIGHT); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 921 | else |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 922 | rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 923 | MENU_ITEMHEIGHT * BM_RESUME, MENU_ITEMWIDTH, |
| 924 | MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH, |
| 925 | MENU_ITEMHEIGHT); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 926 | |
| 927 | } else { |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 928 | rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 929 | MENU_ITEMHEIGHT * BM_NO_RESUME, MENU_ITEMWIDTH, |
| 930 | MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH, |
| 931 | MENU_ITEMHEIGHT); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | |
| 935 | if (cur==2) |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 936 | rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 937 | MENU_ITEMHEIGHT * BM_SEL_HELP, MENU_ITEMWIDTH, |
| 938 | MENU_ITEMXOFS, BMPYOFS_help, MENU_ITEMWIDTH, |
| 939 | MENU_ITEMHEIGHT); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 940 | else |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 941 | rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 942 | MENU_ITEMHEIGHT * BM_HELP, MENU_ITEMWIDTH, |
| 943 | MENU_ITEMXOFS, BMPYOFS_help, MENU_ITEMWIDTH, |
| 944 | MENU_ITEMHEIGHT); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 945 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 946 | if (cur==3) |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 947 | rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 948 | MENU_ITEMHEIGHT * BM_SEL_QUIT, MENU_ITEMWIDTH, |
| 949 | MENU_ITEMXOFS, BMPYOFS_quit, MENU_ITEMWIDTH, |
| 950 | MENU_ITEMHEIGHT); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 951 | else |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 952 | rb->lcd_bitmap_transparent_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 953 | MENU_ITEMHEIGHT * BM_QUIT, MENU_ITEMWIDTH, |
| 954 | MENU_ITEMXOFS, BMPYOFS_quit, MENU_ITEMWIDTH, |
| 955 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 956 | #else |
| 957 | if (cur==0) |
| 958 | rb->lcd_bitmap_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 959 | MENU_ITEMHEIGHT * BM_SEL_START, MENU_ITEMWIDTH, |
| 960 | MENU_ITEMXOFS, BMPYOFS_start, MENU_ITEMWIDTH, |
| 961 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 962 | else |
| 963 | rb->lcd_bitmap_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 964 | MENU_ITEMHEIGHT * BM_START, MENU_ITEMWIDTH, |
| 965 | MENU_ITEMXOFS, BMPYOFS_start, MENU_ITEMWIDTH, |
| 966 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 967 | |
| 968 | if (when==1) { |
| 969 | if (cur==1) |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 970 | rb->lcd_bitmap_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 971 | MENU_ITEMHEIGHT * BM_SEL_RESUME, MENU_ITEMWIDTH, |
| 972 | MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH, |
| 973 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 974 | else |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 975 | rb->lcd_bitmap_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 976 | MENU_ITEMHEIGHT * BM_RESUME, MENU_ITEMWIDTH, |
| 977 | MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH, |
| 978 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 979 | |
| 980 | } else { |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 981 | rb->lcd_bitmap_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 982 | MENU_ITEMHEIGHT * BM_NO_RESUME, MENU_ITEMWIDTH, |
| 983 | MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH, |
| 984 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 985 | } |
| 986 | |
| 987 | |
| 988 | if (cur==2) |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 989 | rb->lcd_bitmap_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 990 | MENU_ITEMHEIGHT * BM_SEL_HELP, MENU_ITEMWIDTH, |
| 991 | MENU_ITEMXOFS, BMPYOFS_help, MENU_ITEMWIDTH, |
| 992 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 993 | else |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 994 | rb->lcd_bitmap_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 995 | MENU_ITEMHEIGHT * BM_HELP, MENU_ITEMWIDTH, |
| 996 | MENU_ITEMXOFS, BMPYOFS_help, MENU_ITEMWIDTH, |
| 997 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 998 | |
| 999 | if (cur==3) |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 1000 | rb->lcd_bitmap_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1001 | MENU_ITEMHEIGHT * BM_SEL_QUIT, MENU_ITEMWIDTH, |
| 1002 | MENU_ITEMXOFS, BMPYOFS_quit, MENU_ITEMWIDTH, |
| 1003 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 1004 | else |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 1005 | rb->lcd_bitmap_part(brickmania_menu_items, 0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1006 | MENU_ITEMHEIGHT * BM_QUIT, MENU_ITEMWIDTH, |
| 1007 | MENU_ITEMXOFS, BMPYOFS_quit, MENU_ITEMWIDTH, |
| 1008 | MENU_ITEMHEIGHT); |
Ben Basha | d510a6e | 2006-06-05 20:41:52 +0000 | [diff] [blame] | 1009 | #endif |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1010 | } |
Ben Basha | 265d1a0 | 2006-02-20 18:56:34 +0000 | [diff] [blame] | 1011 | rb->lcd_set_drawmode(DRMODE_FG); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1012 | /* high score */ |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1013 | #ifdef HAVE_LCD_COLOR |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1014 | rb->lcd_set_background(LCD_RGBPACK(0,0,140)); |
| 1015 | rb->lcd_set_foreground(LCD_WHITE); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1016 | #endif |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 1017 | rb->lcd_putsxy(HIGHSCORE_XPOS, HIGHSCORE_YPOS, "High Score"); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1018 | rb->snprintf(str, sizeof(str), "%d", highscore); |
| 1019 | rb->lcd_getstringsize("High Score", &sw, NULL); |
| 1020 | rb->lcd_getstringsize(str, &w, NULL); |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 1021 | rb->lcd_putsxy(HIGHSCORE_XPOS+sw/2-w/2, HIGHSCORE_YPOS+9, str); |
Ben Basha | 265d1a0 | 2006-02-20 18:56:34 +0000 | [diff] [blame] | 1022 | rb->lcd_set_drawmode(DRMODE_SOLID); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1023 | |
| 1024 | rb->lcd_update(); |
| 1025 | |
| 1026 | button = rb->button_get(true); |
Maurus Cuelenaere | 50763d5 | 2008-06-09 20:59:55 +0000 | [diff] [blame] | 1027 | #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 Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1039 | switch(button) { |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1040 | case UP: |
Zakk Roberts | a45e835 | 2007-02-21 22:48:44 +0000 | [diff] [blame] | 1041 | case UP | BUTTON_REPEAT: |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1042 | if (cur==0) |
| 1043 | cur = MENU_LENGTH-1; |
| 1044 | else |
| 1045 | cur--; |
| 1046 | if (when==0 && cur==1) { |
| 1047 | cur = 0; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1048 | } |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1049 | break; |
| 1050 | |
| 1051 | case DOWN: |
Zakk Roberts | a45e835 | 2007-02-21 22:48:44 +0000 | [diff] [blame] | 1052 | case DOWN | BUTTON_REPEAT: |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1053 | if (cur==MENU_LENGTH-1) |
| 1054 | cur = 0; |
| 1055 | else |
| 1056 | cur++; |
| 1057 | if (when==0 && cur==1) { |
| 1058 | cur=2; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1059 | } |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1060 | break; |
| 1061 | |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1062 | case RIGHT: |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1063 | 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 Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1071 | return 2; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1072 | } else if (cur==3) { |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1073 | return 3; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1074 | } |
| 1075 | break; |
Kevin Ferrare | 0e027bd | 2006-06-30 16:43:47 +0000 | [diff] [blame] | 1076 | #ifdef RC_QUIT |
| 1077 | case RC_QUIT: |
| 1078 | #endif |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1079 | case QUIT: |
| 1080 | return 3; |
| 1081 | break; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1082 | |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1083 | default: |
| 1084 | if(rb->default_event_handler(button) == SYS_USB_CONNECTED) |
| 1085 | return 3; |
| 1086 | break; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1087 | } |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | int help(int when) |
| 1092 | { |
| 1093 | int w,h; |
| 1094 | int button; |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1095 | 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énius | d86350c | 2006-11-02 18:50:08 +0000 | [diff] [blame] | 1099 | int maxY=180; |
| 1100 | int maxX=215; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1101 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1102 | while(true) { |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1103 | #ifdef HAVE_LCD_COLOR |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1104 | rb->lcd_set_background(LCD_BLACK); |
| 1105 | rb->lcd_clear_display(); |
| 1106 | rb->lcd_set_background(LCD_BLACK); |
| 1107 | rb->lcd_set_foreground(LCD_WHITE); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1108 | #else |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1109 | rb->lcd_clear_display(); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1110 | #endif |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1111 | |
| 1112 | rb->lcd_getstringsize("BrickMania", &w, &h); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1113 | rb->lcd_putsxy(LCD_WIDTH/2-w/2+xoffset, 1+yoffset, "BrickMania"); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1114 | |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1115 | #ifdef HAVE_LCD_COLOR |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1116 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1117 | rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1118 | rb->lcd_set_foreground(LCD_WHITE); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1119 | #else |
| 1120 | rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); |
| 1121 | #endif |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1122 | rb->lcd_putsxy(1+xoffset, 2*(h+2)+yoffset, |
| 1123 | "destroy all the bricks by bouncing"); |
| 1124 | rb->lcd_putsxy(1+xoffset, 3*(h+2)+yoffset, |
| 1125 | "the ball of them using the paddle."); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1126 | #ifdef HAVE_LCD_COLOR |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1127 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1128 | rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1129 | rb->lcd_set_foreground(LCD_WHITE); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1130 | #else |
| 1131 | rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1132 | #endif |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1133 | rb->lcd_putsxy(1+xoffset, 6*(h+2)+yoffset,"< & > Move the paddle"); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1134 | #if CONFIG_KEYPAD == ONDIO_PAD |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1135 | rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, |
| 1136 | "MENU Releases the ball/Fire!"); |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 1137 | #elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD) |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1138 | rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, |
| 1139 | "PLAY Releases the ball/Fire!"); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1140 | #elif CONFIG_KEYPAD == IRIVER_H300_PAD |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1141 | rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, |
| 1142 | "NAVI Releases the ball/Fire!"); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1143 | #else |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1144 | rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, |
| 1145 | "SELECT Releases the ball/Fire!"); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1146 | #endif |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 1147 | #if CONFIG_KEYPAD == IAUDIO_M3_PAD |
| 1148 | rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "REC Opens menu/Quit"); |
| 1149 | #else |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1150 | rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "STOP Opens menu/Quit"); |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 1151 | #endif |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1152 | #ifdef HAVE_LCD_COLOR |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1153 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1154 | rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials"); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1155 | rb->lcd_set_foreground(LCD_WHITE); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1156 | #else |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1157 | rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials"); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1158 | #endif |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1159 | rb->lcd_putsxy(1+xoffset, 11*(h+2)+yoffset, |
Nils Wallménius | d86350c | 2006-11-02 18:50:08 +0000 | [diff] [blame] | 1160 | "N Normal:returns paddle to normal"); |
| 1161 | rb->lcd_putsxy(1+xoffset, 12*(h+2)+yoffset, "D DIE!:loses a life"); |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1162 | rb->lcd_putsxy(1+xoffset, 13*(h+2)+yoffset, |
Nils Wallménius | d86350c | 2006-11-02 18:50:08 +0000 | [diff] [blame] | 1163 | "L Life:gains a life/power up"); |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1164 | rb->lcd_putsxy(1+xoffset, 14*(h+2)+yoffset, |
Nils Wallménius | d86350c | 2006-11-02 18:50:08 +0000 | [diff] [blame] | 1165 | "F Fire:allows you to shoot bricks"); |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1166 | rb->lcd_putsxy(1+xoffset, 15*(h+2)+yoffset, |
Nils Wallménius | d86350c | 2006-11-02 18:50:08 +0000 | [diff] [blame] | 1167 | "G Glue:ball sticks to paddle"); |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1168 | rb->lcd_putsxy(1+xoffset, 16*(h+2)+yoffset, |
Nils Wallménius | d86350c | 2006-11-02 18:50:08 +0000 | [diff] [blame] | 1169 | "B Ball:generates another ball"); |
| 1170 | rb->lcd_putsxy(1+xoffset, 17*(h+2)+yoffset, |
| 1171 | "FL Flip:flips left / right movement"); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1172 | rb->lcd_update(); |
| 1173 | |
| 1174 | button=rb->button_get(true); |
| 1175 | switch (button) { |
Kevin Ferrare | 0e027bd | 2006-06-30 16:43:47 +0000 | [diff] [blame] | 1176 | #ifdef RC_QUIT |
| 1177 | case RC_QUIT: |
| 1178 | #endif |
Maurus Cuelenaere | 50763d5 | 2008-06-09 20:59:55 +0000 | [diff] [blame] | 1179 | #ifdef HAVE_TOUCHPAD |
| 1180 | case BUTTON_TOUCHPAD: |
| 1181 | #endif |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1182 | case QUIT: |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1183 | 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 Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1193 | if (help(when)==1) |
| 1194 | return 1; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1195 | break; |
| 1196 | case 3: |
| 1197 | return 1; |
| 1198 | break; |
| 1199 | } |
Marcoen Hirschberg | c296ac5 | 2006-02-24 15:13:04 +0000 | [diff] [blame] | 1200 | return 0; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1201 | break; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1202 | case LEFT: |
| 1203 | case LEFT | BUTTON_REPEAT: |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1204 | #ifdef ALTLEFT |
| 1205 | case ALTLEFT: |
| 1206 | case ALTLEFT | BUTTON_REPEAT: |
| 1207 | #endif |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1208 | if( xoffset<0) |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1209 | xoffset+=2; |
| 1210 | break; |
| 1211 | case RIGHT: |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1212 | case RIGHT | BUTTON_REPEAT: |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1213 | #ifdef ALTRIGHT |
| 1214 | case ALTRIGHT: |
| 1215 | case ALTRIGHT | BUTTON_REPEAT: |
| 1216 | #endif |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1217 | if(xoffset+maxX > LCD_WIDTH) |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1218 | 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 Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 1230 | |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1231 | default: |
| 1232 | if(rb->default_event_handler(button) == SYS_USB_CONNECTED) |
| 1233 | return 1; |
| 1234 | break; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1235 | } |
| 1236 | } |
Marcoen Hirschberg | c296ac5 | 2006-02-24 15:13:04 +0000 | [diff] [blame] | 1237 | return 0; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1238 | } |
| 1239 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1240 | int pad_check(int ballxc, int mode, int pon ,int ballnum) |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1241 | { |
| 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 Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1250 | if (ball[ballnum].x > 0) |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1251 | return ballxc; |
| 1252 | else |
| 1253 | return ballxc*-1; |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | int 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 Hirschberg | c296ac5 | 2006-02-24 15:13:04 +0000 | [diff] [blame] | 1264 | return 0; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1265 | } |
| 1266 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1267 | int game_loop(void) |
| 1268 | { |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1269 | int j,i,k,bricky,brickx; |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1270 | char s[30]; |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1271 | int sec_count=0,num_count=10; |
Dave Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 1272 | int end; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1273 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1274 | rb->srand( *rb->current_tick ); |
| 1275 | |
| 1276 | configfile_init(rb); |
| 1277 | configfile_load(HIGH_SCORE,config,1,0); |
| 1278 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1279 | switch(game_menu(0)) { |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1280 | 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 Chapman | 553c9e2 | 2006-01-27 10:02:13 +0000 | [diff] [blame] | 1296 | while(true) { |
| 1297 | /* Convert CYCLETIME (in ms) to HZ */ |
| 1298 | end = *rb->current_tick + (CYCLETIME * HZ) / 1000; |
| 1299 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1300 | if (life >= 0) { |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1301 | #ifdef HAVE_LCD_COLOR |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1302 | rb->lcd_set_background(LCD_BLACK); |
| 1303 | rb->lcd_set_drawmode(DRMODE_SOLID); |
| 1304 | rb->lcd_clear_display(); |
| 1305 | rb->lcd_set_background(LCD_BLACK); |
Jonathan Gordon | 5d173ea | 2007-04-19 12:14:54 +0000 | [diff] [blame] | 1306 | #if LCD_HEIGHT > GAMESCREEN_HEIGHT |
| 1307 | rb->lcd_set_foreground(rb->global_settings->bg_color); |
| 1308 | rb->lcd_fillrect(0, GAMESCREEN_HEIGHT, LCD_WIDTH, |
| 1309 | LCD_HEIGHT - GAMESCREEN_HEIGHT); |
| 1310 | #endif |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1311 | rb->lcd_set_foreground(LCD_WHITE); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1312 | #else |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1313 | rb->lcd_clear_display(); |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1314 | #endif |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1315 | |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1316 | if (flip_sides) { |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1317 | 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 Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1326 | rb->lcd_putsxy(LCD_WIDTH/2-2, STRINGPOS_FLIP, s); |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1327 | } |
| 1328 | |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1329 | /* write life num */ |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1330 | #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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1334 | rb->snprintf(s, sizeof(s), "Life: %d", life); |
| 1335 | rb->lcd_putsxy(2, 2, s); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1336 | #endif |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1337 | |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1338 | #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) |
| 1339 | rb->snprintf(s, sizeof(s), "L%d", cur_level+1); |
| 1340 | rb->lcd_getstringsize(s, &sw, NULL); |
| 1341 | rb->lcd_putsxy(LCD_WIDTH-sw, 0, s); |
| 1342 | #else |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1343 | rb->snprintf(s, sizeof(s), "Level %d", cur_level+1); |
| 1344 | rb->lcd_getstringsize(s, &sw, NULL); |
| 1345 | rb->lcd_putsxy(LCD_WIDTH-sw-2, 2, s); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1346 | #endif |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1347 | |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1348 | if (vscore<score) vscore++; |
| 1349 | rb->snprintf(s, sizeof(s), "%d", vscore); |
| 1350 | rb->lcd_getstringsize(s, &sw, NULL); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1351 | #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) |
| 1352 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s); |
| 1353 | #else |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1354 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 2, s); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1355 | #endif |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1356 | |
| 1357 | /* continue game */ |
| 1358 | if (con_game== 1 && start_game!=1) { |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1359 | #if CONFIG_KEYPAD == ONDIO_PAD |
| 1360 | rb->snprintf(s, sizeof(s), "MENU To Continue"); |
| 1361 | #elif CONFIG_KEYPAD == IRIVER_H300_PAD |
| 1362 | rb->snprintf(s, sizeof(s), "Press NAVI To Continue"); |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 1363 | #elif CONFIG_KEYPAD == IAUDIO_M3_PAD |
| 1364 | rb->snprintf(s, sizeof(s), "PLAY To Continue"); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1365 | #else |
| 1366 | rb->snprintf(s, sizeof(s), "Press SELECT To Continue"); |
| 1367 | #endif |
| 1368 | rb->lcd_getstringsize(s, &sw, NULL); |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1369 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_NAVI, s); |
Ben Basha | d330ef7 | 2006-02-22 10:34:36 +0000 | [diff] [blame] | 1370 | |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1371 | sec_count=*rb->current_tick+HZ; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1372 | } |
| 1373 | |
| 1374 | /* draw the ball */ |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1375 | for(i=0;i<used_balls;i++) |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1376 | rb->lcd_bitmap(brickmania_ball,ball[i].pos_x, ball[i].pos_y, |
| 1377 | BALL, BALL); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1378 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1379 | if (brick_on_board==0) |
| 1380 | brick_on_board--; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1381 | |
| 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 Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1394 | if (brick[i*10+j].power<7) { |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1395 | if (brick[i*10+j].poweruse==2) { |
| 1396 | if (con_game!=1) |
| 1397 | brick[i*10+j].powertop+=2; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1398 | rb->lcd_bitmap_part(brickmania_powerups,0, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1399 | POWERUP_HEIGHT*brick[i*10+j |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1400 | ].power, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1401 | POWERUP_WIDTH, |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1402 | LEFTMARGIN+j*BRICK_WIDTH+ |
| 1403 | (BRICK_WIDTH/2- |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1404 | POWERUP_WIDTH/2), |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1405 | brick[i*10+j].powertop, |
Marianne Arnold | 2e5f8f5 | 2007-12-30 14:56:51 +0000 | [diff] [blame] | 1406 | POWERUP_WIDTH, |
| 1407 | POWERUP_HEIGHT); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1408 | } |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1409 | } |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1410 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1411 | if ((pad_pos_x<LEFTMARGIN+j*BRICK_WIDTH+5 && |
| 1412 | pad_pos_x+PAD_WIDTH>LEFTMARGIN+j*BRICK_WIDTH+5) && |
| 1413 | brick[i*10+j].powertop+6>=PAD_POS_Y && |
| 1414 | brick[i*10+j].poweruse==2) { |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1415 | 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 Basha | 9131c4a | 2006-02-17 16:02:37 +0000 | [diff] [blame] | 1424 | sleep(2); |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1425 | } |
| 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 Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1434 | for(k=0;k<used_balls;k++) |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1435 | ball[k].glue=false; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1436 | break; |
| 1437 | case 4: |
| 1438 | score+=23; |
| 1439 | pad_type=0; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1440 | for(k=0;k<used_balls;k++) |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1441 | ball[k].glue=false; |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1442 | flip_sides=false; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1443 | break; |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1444 | case 5: |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1445 | score+=23; |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1446 | sec_count=*rb->current_tick+HZ; |
| 1447 | num_count=10; |
| 1448 | flip_sides=!flip_sides; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1449 | break; |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1450 | case 6: |
| 1451 | score+=23; |
| 1452 | used_balls++; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1453 | ball[used_balls-1].x= rb->rand()%1 == 0 ? |
| 1454 | -1 : 1; |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1455 | ball[used_balls-1].y= -4; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1456 | break; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1457 | } |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1458 | brick[i*10+j].poweruse=1; |
| 1459 | } |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1460 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1461 | if (brick[i*10+j].powertop>PAD_POS_Y) |
| 1462 | brick[i*10+j].poweruse=1; |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 1463 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1464 | 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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1484 | brick_on_board--; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1485 | } |
Linus Nielsen Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1486 | } |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1487 | } |
| 1488 | } |
| 1489 | } |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 1490 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1491 | 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 Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1498 | #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */ |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1499 | 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 Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1508 | #endif |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1509 | } |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1510 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1511 | for(k=0;k<used_balls;k++) { |
Zakk Roberts | 4bdef7a | 2007-01-26 06:14:29 +0000 | [diff] [blame] | 1512 | if (ball[k].pos_y <160) { |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1513 | 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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1524 | } |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1525 | 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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1536 | } |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1537 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1538 | 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 Feltzing | 3325d99 | 2006-01-26 23:31:00 +0000 | [diff] [blame] | 1548 | } |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1549 | 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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1562 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1563 | if ((ball[k].pos_x+HALFBALL >= brickx && |
| 1564 | ball[k].pos_x+HALFBALL <= |
| 1565 | brickx+BRICK_WIDTH) && |
| 1566 | ((bricky+BRICK_HEIGHT==ball[k].pos_y) || |
| 1567 | (bricky+BRICK_HEIGHT-6<=ball[k].pos_y && |
| 1568 | bricky+BRICK_HEIGHT>ball[k].pos_y)) && |
| 1569 | (ball[k].y <0)) { /* bottom line */ |
| 1570 | if (brick[i*10+j].hits > 0) { |
| 1571 | brick[i*10+j].hits--; |
| 1572 | brick[i*10+j].hiteffect++; |
| 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 Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1652 | } |
| 1653 | } |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1654 | } /* for k */ |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1655 | } /* for j */ |
| 1656 | } /* for i */ |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1657 | |
| 1658 | /* draw the pad */ |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1659 | 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 Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1663 | for(k=0;k<used_balls;k++) { |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1664 | |
| 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 Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1669 | ball[k].tempy=PAD_POS_Y-ball[k].pos_y-BALL; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1670 | else if ((4>ball[k].pos_y && 0<ball[k].pos_y) && |
| 1671 | (ball[k].y <0)) |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1672 | ball[k].tempy=-ball[k].pos_y; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1673 | if ((LCD_WIDTH-4<ball[k].pos_x+BALL && |
| 1674 | LCD_WIDTH>ball[k].pos_x+BALL) && (ball[k].x >0)) |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1675 | ball[k].tempx=LCD_WIDTH-ball[k].pos_x-BALL; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1676 | else if ((4>ball[k].pos_x && 0<ball[k].pos_x) && |
| 1677 | (ball[k].x <0)) |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1678 | ball[k].tempx=-ball[k].pos_x; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1679 | |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1680 | /* top line */ |
| 1681 | if (ball[k].pos_y<= 0) |
| 1682 | ball[k].y = ball[k].y*-1; |
| 1683 | /* bottom line */ |
Nicolas Pennequin | 5a29fe1 | 2007-02-14 22:59:36 +0000 | [diff] [blame] | 1684 | else if (ball[k].pos_y+BALL >= GAMESCREEN_HEIGHT) { |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1685 | 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 Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1694 | |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1695 | ball[used_balls].x=0; |
| 1696 | ball[used_balls].y=0; |
| 1697 | ball[used_balls].tempy=0; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1698 | ball[used_balls].tempx=0; |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1699 | ball[used_balls].pos_y=PAD_POS_Y-BALL; |
| 1700 | ball[used_balls].pos_x=pad_pos_x+(PAD_WIDTH/2)-2; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1701 | |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1702 | k--; |
| 1703 | continue; |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1704 | } else { |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1705 | life--; |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1706 | if (life>=0) { |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1707 | int_game(0); |
Ben Basha | 9131c4a | 2006-02-17 16:02:37 +0000 | [diff] [blame] | 1708 | sleep(2); |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1709 | } |
Dave Chapman | 06e25c8 | 2006-01-23 16:00:06 +0000 | [diff] [blame] | 1710 | } |
| 1711 | } |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1712 | |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1713 | /* left line ,right line */ |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1714 | if ((ball[k].pos_x <= 0) || |
| 1715 | (ball[k].pos_x+BALL >= LCD_WIDTH)) { |
Ben Basha | 26e598d | 2006-02-15 17:37:45 +0000 | [diff] [blame] | 1716 | ball[k].x = ball[k].x*-1; |
Ben Basha | 9131c4a | 2006-02-17 16:02:37 +0000 | [diff] [blame] | 1717 | ball[k].pos_x = ball[k].pos_x <= 0 ? 0 : LCD_WIDTH-BALL; |
| 1718 | } |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1719 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1720 | if ((ball[k].pos_y+BALL >= PAD_POS_Y && |
| 1721 | (ball[k].pos_x >= pad_pos_x && |
| 1722 | ball[k].pos_x <= pad_pos_x+PAD_WIDTH)) && |
| 1723 | start_game != 1 && !ball[k].glue) { |
Ben Basha | a39aeb1 | 2006-02-19 21:24:46 +0000 | [diff] [blame] | 1724 | |
Daniel Stenberg | a26d315 | 2006-03-03 07:24:34 +0000 | [diff] [blame] | 1725 | if ((ball[k].pos_x+HALFBALL >= pad_pos_x && |
| 1726 | ball[k].pos_x+HALFBALL <= |
| 1727 | pad_pos_x+(PAD_WIDTH/2/4)) || |
| 1728 | (ball[k].pos_x +HALFBALL>= |
| 1729 | pad_pos_x+(PAD_WIDTH-(PAD_WIDTH/2/4)) && |
| 1730 | ball[k].pos_x+HALFBALL <= pad_pos_x+PAD_WIDTH)) { |
Zakk Roberts | |