Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 Frederic Dang Ngoc |
| 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. |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +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 | #include "plugin.h" |
| 22 | #ifdef HAVE_LCD_BITMAP |
| 23 | |
Jens Arnold | a36b1d4 | 2006-01-15 18:20:18 +0000 | [diff] [blame] | 24 | PLUGIN_HEADER |
| 25 | |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 26 | /* size of a level in file */ |
| 27 | #define STAR_LEVEL_SIZE ((STAR_WIDTH + 1) * STAR_HEIGHT + 1) |
| 28 | |
| 29 | /* size of the game board */ |
| 30 | #define STAR_WIDTH 16 |
| 31 | #define STAR_HEIGHT 9 |
| 32 | |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 33 | /* number of level */ |
| 34 | #define STAR_LEVEL_COUNT 20 |
| 35 | |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 36 | /* values of object in the board */ |
Zakk Roberts | ec216ac | 2006-06-03 19:24:10 +0000 | [diff] [blame] | 37 | #define STAR_VOID '.' |
| 38 | #define STAR_WALL '*' |
| 39 | #define STAR_STAR 'o' |
| 40 | #define STAR_BALL 'X' |
| 41 | #define STAR_BLOCK 'x' |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 42 | |
| 43 | /* sleep time between two frames */ |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 44 | #if (LCD_HEIGHT * LCD_WIDTH >= 70000) && defined(IPOD_ARCH) |
| 45 | /* iPod 5G LCD is *slow* */ |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 46 | #define STAR_SLEEP rb->yield(); |
| 47 | #elif (LCD_HEIGHT * LCD_WIDTH >= 30000) |
Shachar Liberman | 585510a | 2006-08-10 20:56:09 +0000 | [diff] [blame] | 48 | #define STAR_SLEEP rb->sleep(0); |
Antoine Cellerier | fb3c066 | 2006-06-11 13:25:44 +0000 | [diff] [blame] | 49 | #else |
Shachar Liberman | 585510a | 2006-08-10 20:56:09 +0000 | [diff] [blame] | 50 | #define STAR_SLEEP rb->sleep(1); |
Antoine Cellerier | fb3c066 | 2006-06-11 13:25:44 +0000 | [diff] [blame] | 51 | #endif |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 52 | |
| 53 | /* value of ball and block control */ |
| 54 | #define STAR_CONTROL_BALL 0 |
| 55 | #define STAR_CONTROL_BLOCK 1 |
| 56 | |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 57 | /* variable button definitions */ |
| 58 | #if CONFIG_KEYPAD == RECORDER_PAD |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 59 | #define STAR_QUIT BUTTON_OFF |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 60 | #define STAR_LEFT BUTTON_LEFT |
| 61 | #define STAR_RIGHT BUTTON_RIGHT |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 62 | #define STAR_UP BUTTON_UP |
| 63 | #define STAR_DOWN BUTTON_DOWN |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 64 | #define STAR_TOGGLE_CONTROL BUTTON_ON |
| 65 | #define STAR_TOGGLE_CONTROL2 BUTTON_PLAY |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 66 | #define STAR_LEVEL_UP BUTTON_F3 |
| 67 | #define STAR_LEVEL_DOWN BUTTON_F1 |
| 68 | #define STAR_LEVEL_REPEAT BUTTON_F2 |
| 69 | #define STAR_MENU_RUN BUTTON_PLAY |
| 70 | #define STAR_MENU_RUN2 BUTTON_RIGHT |
| 71 | #define STAR_MENU_RUN3 BUTTON_ON |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 72 | |
Dave Chapman | d64e626 | 2007-01-14 13:48:09 +0000 | [diff] [blame] | 73 | #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD |
| 74 | #define STAR_QUIT BUTTON_OFF |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 75 | #define STAR_LEFT BUTTON_LEFT |
| 76 | #define STAR_RIGHT BUTTON_RIGHT |
Dave Chapman | d64e626 | 2007-01-14 13:48:09 +0000 | [diff] [blame] | 77 | #define STAR_UP BUTTON_UP |
| 78 | #define STAR_DOWN BUTTON_DOWN |
| 79 | #define STAR_TOGGLE_CONTROL BUTTON_ON |
| 80 | #define STAR_TOGGLE_CONTROL2 BUTTON_SELECT |
| 81 | #define STAR_LEVEL_UP BUTTON_F3 |
| 82 | #define STAR_LEVEL_DOWN BUTTON_F1 |
| 83 | #define STAR_LEVEL_REPEAT BUTTON_F2 |
| 84 | #define STAR_MENU_RUN BUTTON_SELECT |
| 85 | #define STAR_MENU_RUN2 BUTTON_RIGHT |
| 86 | #define STAR_MENU_RUN3 BUTTON_ON |
| 87 | |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 88 | #elif CONFIG_KEYPAD == ONDIO_PAD |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 89 | #define STAR_QUIT BUTTON_OFF |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 90 | #define STAR_LEFT BUTTON_LEFT |
| 91 | #define STAR_RIGHT BUTTON_RIGHT |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 92 | #define STAR_UP BUTTON_UP |
| 93 | #define STAR_DOWN BUTTON_DOWN |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 94 | #define STAR_TOGGLE_CONTROL_PRE BUTTON_MENU |
| 95 | #define STAR_TOGGLE_CONTROL (BUTTON_MENU | BUTTON_REL) |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 96 | #define STAR_LEVEL_UP (BUTTON_MENU | BUTTON_RIGHT) |
| 97 | #define STAR_LEVEL_DOWN (BUTTON_MENU | BUTTON_LEFT) |
| 98 | #define STAR_LEVEL_REPEAT (BUTTON_MENU | BUTTON_UP) |
| 99 | #define STAR_MENU_RUN BUTTON_RIGHT |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 100 | |
Daniel Stenberg | 01377e2 | 2005-06-29 12:47:24 +0000 | [diff] [blame] | 101 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ |
| 102 | (CONFIG_KEYPAD == IRIVER_H300_PAD) |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 103 | #define STAR_QUIT BUTTON_OFF |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 104 | #define STAR_LEFT BUTTON_LEFT |
| 105 | #define STAR_RIGHT BUTTON_RIGHT |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 106 | #define STAR_UP BUTTON_UP |
| 107 | #define STAR_DOWN BUTTON_DOWN |
Shachar Liberman | 078e44e | 2006-08-10 17:21:01 +0000 | [diff] [blame] | 108 | #define STAR_TOGGLE_CONTROL BUTTON_MODE |
| 109 | #define STAR_TOGGLE_CONTROL2 BUTTON_SELECT |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 110 | #define STAR_LEVEL_UP (BUTTON_ON | BUTTON_RIGHT) |
| 111 | #define STAR_LEVEL_DOWN (BUTTON_ON | BUTTON_LEFT) |
| 112 | #define STAR_LEVEL_REPEAT (BUTTON_ON | BUTTON_SELECT) |
| 113 | #define STAR_MENU_RUN BUTTON_RIGHT |
| 114 | #define STAR_MENU_RUN2 BUTTON_SELECT |
Dave Chapman | 54d44c8 | 2005-12-14 01:31:37 +0000 | [diff] [blame] | 115 | |
Kevin Ferrare | 0e027bd | 2006-06-30 16:43:47 +0000 | [diff] [blame] | 116 | #define STAR_RC_QUIT BUTTON_RC_STOP |
Dave Chapman | fb4e384 | 2006-02-24 20:54:09 +0000 | [diff] [blame] | 117 | #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ |
Jens Arnold | b701322 | 2007-07-27 09:57:27 +0000 | [diff] [blame] | 118 | (CONFIG_KEYPAD == IPOD_3G_PAD) || \ |
| 119 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) |
Dave Chapman | 54d44c8 | 2005-12-14 01:31:37 +0000 | [diff] [blame] | 120 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 121 | #define STAR_QUIT (BUTTON_SELECT | BUTTON_MENU) |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 122 | #define STAR_LEFT BUTTON_LEFT |
| 123 | #define STAR_RIGHT BUTTON_RIGHT |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 124 | #define STAR_UP BUTTON_MENU |
| 125 | #define STAR_DOWN BUTTON_PLAY |
Zakk Roberts | ec216ac | 2006-06-03 19:24:10 +0000 | [diff] [blame] | 126 | #define STAR_TOGGLE_CONTROL_PRE BUTTON_SELECT |
| 127 | #define STAR_TOGGLE_CONTROL (BUTTON_SELECT | BUTTON_REL) |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 128 | #define STAR_LEVEL_UP (BUTTON_SELECT | BUTTON_RIGHT) |
| 129 | #define STAR_LEVEL_DOWN (BUTTON_SELECT | BUTTON_LEFT) |
| 130 | #define STAR_LEVEL_REPEAT (BUTTON_SELECT | BUTTON_PLAY) |
| 131 | #define STAR_MENU_RUN BUTTON_RIGHT |
| 132 | #define STAR_MENU_RUN2 BUTTON_SELECT |
Dave Chapman | 54d44c8 | 2005-12-14 01:31:37 +0000 | [diff] [blame] | 133 | |
Jens Arnold | 85a226d | 2007-03-16 23:02:39 +0000 | [diff] [blame] | 134 | #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) |
Daniel Stenberg | cedba88 | 2006-01-18 11:09:06 +0000 | [diff] [blame] | 135 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 136 | #define STAR_QUIT BUTTON_POWER |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 137 | #define STAR_LEFT BUTTON_LEFT |
| 138 | #define STAR_RIGHT BUTTON_RIGHT |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 139 | #define STAR_UP BUTTON_UP |
| 140 | #define STAR_DOWN BUTTON_DOWN |
| 141 | #define STAR_TOGGLE_CONTROL BUTTON_SELECT |
| 142 | #define STAR_LEVEL_UP_PRE BUTTON_REC |
| 143 | #define STAR_LEVEL_UP (BUTTON_REC|BUTTON_REL) |
| 144 | #define STAR_LEVEL_DOWN_PRE BUTTON_REC |
Jens Arnold | b10f2f9 | 2006-10-21 00:38:45 +0000 | [diff] [blame] | 145 | #define STAR_LEVEL_DOWN (BUTTON_REC|BUTTON_REPEAT) |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 146 | #define STAR_LEVEL_REPEAT BUTTON_PLAY |
| 147 | #define STAR_MENU_RUN BUTTON_RIGHT |
| 148 | #define STAR_MENU_RUN2 BUTTON_SELECT |
Daniel Stenberg | cedba88 | 2006-01-18 11:09:06 +0000 | [diff] [blame] | 149 | |
Marcoen Hirschberg | 338e2bb | 2006-02-24 15:42:52 +0000 | [diff] [blame] | 150 | #elif (CONFIG_KEYPAD == GIGABEAT_PAD) |
| 151 | |
Marcoen Hirschberg | a7168fe | 2007-05-19 23:38:09 +0000 | [diff] [blame] | 152 | #define STAR_QUIT BUTTON_POWER |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 153 | #define STAR_LEFT BUTTON_LEFT |
| 154 | #define STAR_RIGHT BUTTON_RIGHT |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 155 | #define STAR_UP BUTTON_UP |
| 156 | #define STAR_DOWN BUTTON_DOWN |
Marcoen Hirschberg | a7168fe | 2007-05-19 23:38:09 +0000 | [diff] [blame] | 157 | #define STAR_TOGGLE_CONTROL BUTTON_SELECT |
| 158 | #define STAR_LEVEL_UP BUTTON_VOL_UP |
| 159 | #define STAR_LEVEL_DOWN BUTTON_VOL_DOWN |
| 160 | #define STAR_LEVEL_REPEAT BUTTON_A |
| 161 | #define STAR_MENU_RUN BUTTON_SELECT |
Marcoen Hirschberg | 338e2bb | 2006-02-24 15:42:52 +0000 | [diff] [blame] | 162 | |
Marianne Arnold | 12ddb8e | 2007-09-20 10:49:48 +0000 | [diff] [blame] | 163 | #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ |
| 164 | (CONFIG_KEYPAD == SANSA_C200_PAD) |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 165 | |
| 166 | #define STAR_QUIT BUTTON_POWER |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 167 | #define STAR_LEFT BUTTON_LEFT |
| 168 | #define STAR_RIGHT BUTTON_RIGHT |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 169 | #define STAR_UP BUTTON_UP |
| 170 | #define STAR_DOWN BUTTON_DOWN |
Daniel Ankers | 1767667 | 2007-01-03 23:53:22 +0000 | [diff] [blame] | 171 | #define STAR_TOGGLE_CONTROL BUTTON_SELECT |
| 172 | #define STAR_LEVEL_UP (BUTTON_SELECT | BUTTON_RIGHT) |
| 173 | #define STAR_LEVEL_DOWN (BUTTON_SELECT | BUTTON_LEFT) |
| 174 | #define STAR_LEVEL_REPEAT (BUTTON_SELECT | BUTTON_DOWN) |
| 175 | #define STAR_MENU_RUN BUTTON_SELECT |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 176 | |
| 177 | |
Daniel Stenberg | 1e88be5 | 2006-08-03 20:17:25 +0000 | [diff] [blame] | 178 | #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) |
| 179 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 180 | #define STAR_QUIT BUTTON_POWER |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 181 | #define STAR_LEFT BUTTON_LEFT |
| 182 | #define STAR_RIGHT BUTTON_RIGHT |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 183 | #define STAR_UP BUTTON_SCROLL_UP |
| 184 | #define STAR_DOWN BUTTON_SCROLL_DOWN |
| 185 | #define STAR_TOGGLE_CONTROL BUTTON_REW |
| 186 | #define STAR_LEVEL_UP (BUTTON_PLAY | BUTTON_SCROLL_UP) |
| 187 | #define STAR_LEVEL_DOWN (BUTTON_PLAY | BUTTON_SCROLL_DOWN) |
| 188 | #define STAR_LEVEL_REPEAT (BUTTON_PLAY | BUTTON_RIGHT) |
| 189 | #define STAR_MENU_RUN BUTTON_FF |
Daniel Stenberg | 1e88be5 | 2006-08-03 20:17:25 +0000 | [diff] [blame] | 190 | |
Will Robertson | 8215b34 | 2008-02-17 12:23:02 +0000 | [diff] [blame] | 191 | #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) |
| 192 | |
| 193 | #define STAR_QUIT BUTTON_BACK |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 194 | #define STAR_LEFT BUTTON_LEFT |
| 195 | #define STAR_RIGHT BUTTON_RIGHT |
Will Robertson | 8215b34 | 2008-02-17 12:23:02 +0000 | [diff] [blame] | 196 | #define STAR_UP BUTTON_UP |
| 197 | #define STAR_DOWN BUTTON_DOWN |
| 198 | #define STAR_TOGGLE_CONTROL BUTTON_SELECT |
| 199 | #define STAR_LEVEL_UP BUTTON_VOL_UP |
| 200 | #define STAR_LEVEL_DOWN BUTTON_VOL_DOWN |
| 201 | #define STAR_LEVEL_REPEAT BUTTON_MENU |
| 202 | #define STAR_MENU_RUN BUTTON_SELECT |
| 203 | |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 204 | #elif (CONFIG_KEYPAD == MROBE100_PAD) |
| 205 | |
| 206 | #define STAR_QUIT BUTTON_POWER |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 207 | #define STAR_LEFT BUTTON_LEFT |
| 208 | #define STAR_RIGHT BUTTON_RIGHT |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 209 | #define STAR_UP BUTTON_UP |
| 210 | #define STAR_DOWN BUTTON_DOWN |
| 211 | #define STAR_TOGGLE_CONTROL BUTTON_SELECT |
| 212 | #define STAR_LEVEL_UP BUTTON_PLAY |
| 213 | #define STAR_LEVEL_DOWN BUTTON_MENU |
| 214 | #define STAR_LEVEL_REPEAT BUTTON_DISPLAY |
| 215 | #define STAR_MENU_RUN BUTTON_SELECT |
| 216 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 217 | #elif CONFIG_KEYPAD == IAUDIO_M3_PAD |
| 218 | |
| 219 | #define STAR_QUIT BUTTON_RC_REC |
| 220 | #define STAR_LEFT BUTTON_RC_REW |
| 221 | #define STAR_RIGHT BUTTON_RC_FF |
| 222 | #define STAR_UP BUTTON_RC_VOL_UP |
| 223 | #define STAR_DOWN BUTTON_RC_VOL_DOWN |
| 224 | #define STAR_TOGGLE_CONTROL BUTTON_RC_MODE |
| 225 | #define STAR_LEVEL_UP (BUTTON_RC_PLAY|BUTTON_RC_VOL_UP) |
| 226 | #define STAR_LEVEL_DOWN (BUTTON_RC_PLAY|BUTTON_RC_VOL_DOWN) |
| 227 | #define STAR_LEVEL_REPEAT (BUTTON_RC_PLAY|BUTTON_RC_MENU) |
| 228 | #define STAR_MENU_RUN BUTTON_RC_FF |
| 229 | |
Rob Purchase | 554d7ed | 2008-03-22 22:03:34 +0000 | [diff] [blame] | 230 | #elif (CONFIG_KEYPAD == COWOND2_PAD) |
| 231 | |
| 232 | #define STAR_QUIT BUTTON_POWER |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 233 | #define STAR_QUIT_NAME "[POWER]" |
Rob Purchase | 554d7ed | 2008-03-22 22:03:34 +0000 | [diff] [blame] | 234 | #define STAR_MENU_RUN BUTTON_MENU |
| 235 | |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 236 | #else |
| 237 | #error No keymap defined! |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 238 | #endif |
| 239 | |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 240 | #ifdef HAVE_TOUCHPAD |
| 241 | //#ifndef STAR_QUIT |
| 242 | //#define STAR_QUIT BUTTON_TOPLEFT |
| 243 | //#define STAR_QUIT_NAME "[TOPLEFT]" |
| 244 | //#endif |
| 245 | #ifndef STAR_MENU_RUN |
| 246 | #define STAR_MENU_RUN BUTTON_TOPRIGHT |
| 247 | #endif |
| 248 | #ifndef STAR_LEFT |
| 249 | #define STAR_LEFT BUTTON_MIDLEFT |
| 250 | #endif |
| 251 | #ifndef STAR_RIGHT |
| 252 | #define STAR_RIGHT BUTTON_MIDRIGHT |
| 253 | #endif |
| 254 | #ifndef STAR_UP |
| 255 | #define STAR_UP BUTTON_TOPMIDDLE |
| 256 | #endif |
| 257 | #ifndef STAR_DOWN |
| 258 | #define STAR_DOWN BUTTON_BOTTOMMIDDLE |
| 259 | #endif |
| 260 | #ifndef STAR_TOGGLE_CONTROL |
| 261 | #define STAR_TOGGLE_CONTROL BUTTON_CENTER |
| 262 | #define STAR_TOGGLE_CONTROL_NAME "[CENTER]" |
| 263 | #endif |
| 264 | #ifndef STAR_LEVEL_UP |
| 265 | #define STAR_LEVEL_UP BUTTON_TOPLEFT |
| 266 | #define STAR_LEVEL_UP_NAME "[TOPLEFT]" |
| 267 | #endif |
| 268 | #ifndef STAR_LEVEL_DOWN |
| 269 | #define STAR_LEVEL_DOWN BUTTON_BOTTOMLEFT |
| 270 | #define STAR_LEVEL_DOWN_NAME "[BOTTOMLEFT]" |
| 271 | #endif |
| 272 | #ifndef STAR_LEVEL_REPEAT |
| 273 | #define STAR_LEVEL_REPEAT BUTTON_BOTTOMRIGHT |
| 274 | #define STAR_LEVEL_REPEAT_NAME "[BOTTOMRIGHT]" |
| 275 | #endif |
| 276 | #endif |
| 277 | |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 278 | /* function returns because of USB? */ |
| 279 | static bool usb_detected = false; |
| 280 | |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 281 | /* position of the ball */ |
| 282 | static int ball_x, ball_y; |
| 283 | |
| 284 | /* position of the block */ |
| 285 | static int block_x, block_y; |
| 286 | |
| 287 | /* number of stars to get to finish the level */ |
| 288 | static int star_count; |
| 289 | |
| 290 | /* the object we control : ball or block */ |
| 291 | static int control; |
| 292 | |
| 293 | /* the current board */ |
| 294 | static char board[STAR_HEIGHT][STAR_WIDTH]; |
| 295 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 296 | #include "star_tiles.h" |
Antoine Cellerier | 40a92ea | 2006-06-10 20:39:33 +0000 | [diff] [blame] | 297 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 298 | #define TILE_WIDTH BMPWIDTH_star_tiles |
| 299 | #define TILE_HEIGHT (BMPHEIGHT_star_tiles/5) |
| 300 | #define STAR_OFFSET_X ((LCD_WIDTH - STAR_WIDTH * TILE_WIDTH) / 2) |
| 301 | #define STAR_OFFSET_Y ((LCD_HEIGHT - STAR_HEIGHT * TILE_HEIGHT - MAX(TILE_HEIGHT, 8)) / 2) |
Antoine Cellerier | 40a92ea | 2006-06-10 20:39:33 +0000 | [diff] [blame] | 302 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 303 | #define WALL 0 |
| 304 | #define SPACE 1 |
| 305 | #define BLOCK 2 |
| 306 | #define STAR 3 |
| 307 | #define BALL 4 |
Antoine Cellerier | 40a92ea | 2006-06-10 20:39:33 +0000 | [diff] [blame] | 308 | |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 309 | #define MENU_START 0 |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 310 | |
| 311 | /* char font size */ |
| 312 | static int char_width = -1; |
| 313 | static int char_height = -1; |
| 314 | |
Steve Bavin | 6526577 | 2008-05-13 09:57:56 +0000 | [diff] [blame] | 315 | static const struct plugin_api* rb; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 316 | |
| 317 | /* this arrays contains a group of levels loaded into memory */ |
Zakk Roberts | ec216ac | 2006-06-03 19:24:10 +0000 | [diff] [blame] | 318 | static unsigned char* levels = |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 319 | "****************\n" |
| 320 | "*X**........o*x*\n" |
| 321 | "*..........o.***\n" |
| 322 | "*.......**o....*\n" |
| 323 | "*...**.o......**\n" |
| 324 | "**.o..o.....o..*\n" |
| 325 | "*.o......o**.o.*\n" |
| 326 | "*.....**o.....o*\n" |
| 327 | "****************\n" |
| 328 | "\n" |
| 329 | ".*..*.*.*...*.**\n" |
| 330 | "*...o.........X*\n" |
| 331 | "...*o..*o...o...\n" |
| 332 | "*.*.o.....o..*.*\n" |
| 333 | "......*...o...*.\n" |
| 334 | "*....*x*..o....*\n" |
| 335 | "...*..*.*...*oo*\n" |
| 336 | "*.............*.\n" |
| 337 | ".*..*........*..\n" |
| 338 | "\n" |
| 339 | "****************\n" |
| 340 | "*...........o*x*\n" |
| 341 | "*...**......**X*\n" |
| 342 | "*...*o.........*\n" |
| 343 | "*.o.....o**...o*\n" |
| 344 | "*.*o..o..o*..o**\n" |
| 345 | "*.**o.*o..o.o***\n" |
| 346 | "*o....**o......*\n" |
| 347 | "****************\n" |
| 348 | "\n" |
| 349 | "****************\n" |
| 350 | "*............*x*\n" |
| 351 | "*.....*........*\n" |
| 352 | "**o*o.o*o*o*o*o*\n" |
| 353 | "*.*.*o.o*.*.*.**\n" |
| 354 | "**o*o*o.o*o*o*o*\n" |
| 355 | "*.....*........*\n" |
| 356 | "*...*.......*X.*\n" |
| 357 | "****************\n" |
| 358 | "\n" |
| 359 | ".**************.\n" |
| 360 | "*X..*...*..*...*\n" |
| 361 | "*..*o.*.o..o.*.*\n" |
| 362 | "**......*..*...*\n" |
| 363 | "*o.*o*........**\n" |
| 364 | "**.....*.o.*...*\n" |
| 365 | "*o*..*.*.*...*x*\n" |
| 366 | "*...*....o*..*o*\n" |
| 367 | ".**************.\n" |
| 368 | "\n" |
| 369 | "....************\n" |
| 370 | "...*...o...*o.o*\n" |
| 371 | "..*....o....*.**\n" |
| 372 | ".*.....o.......*\n" |
| 373 | "*X.....o.......*\n" |
| 374 | "**.....o..*...**\n" |
| 375 | "*......o....*..*\n" |
| 376 | "*x.*...o..**o..*\n" |
| 377 | "****************\n" |
| 378 | "\n" |
| 379 | "****************\n" |
| 380 | "*..............*\n" |
| 381 | ".**.***..*o.**o*\n" |
| 382 | ".*o..*o.*.*.*.*.\n" |
| 383 | "..*..*..***.**..\n" |
| 384 | ".**..*..*o*.*o**\n" |
| 385 | "*..............*\n" |
| 386 | "*..X*o....x..*o*\n" |
| 387 | "****************\n" |
| 388 | "\n" |
| 389 | "***************.\n" |
| 390 | "*..o**.........*\n" |
| 391 | "*..*o..**.o....*\n" |
| 392 | "*..o**.*.*o....*\n" |
| 393 | "**.....**..*o*.*\n" |
| 394 | "**.*.......o*o.*\n" |
| 395 | "*oxo*...o..*X*.*\n" |
| 396 | "**.............*\n" |
| 397 | ".***************\n" |
| 398 | "\n" |
| 399 | "..*.***********.\n" |
| 400 | ".*o*o......*..X*\n" |
| 401 | "*o.o*....o....*.\n" |
| 402 | ".*.*..o**..o*..*\n" |
| 403 | "*..*o.*oxo....o*\n" |
| 404 | "*.....o**.....*.\n" |
| 405 | "*o*o.........*..\n" |
| 406 | "*...........*...\n" |
| 407 | ".***********....\n" |
| 408 | "\n" |
| 409 | "....***********.\n" |
| 410 | "*****.o........*\n" |
| 411 | "*...x.***o.o*.o*\n" |
| 412 | "*.o...*o.*o...*.\n" |
| 413 | "*.....*..o..*.o*\n" |
| 414 | "*o*o..*.o*..*X*.\n" |
| 415 | ".*o...***..***..\n" |
| 416 | "*.........*.*.*.\n" |
| 417 | ".*********..*..*\n" |
| 418 | "\n" |
| 419 | "****************\n" |
| 420 | "*......*......X*\n" |
| 421 | "*..*oo.....oo.**\n" |
| 422 | "**...o...**...o*\n" |
| 423 | "*o....*o*oo..***\n" |
| 424 | "**.**....**....*\n" |
| 425 | "*o..o*.o....x.o*\n" |
| 426 | "**o***....*...**\n" |
| 427 | "***************.\n" |
| 428 | "\n" |
| 429 | "**.....**..****.\n" |
| 430 | "*X*****o.***.o**\n" |
| 431 | "*....oo.....o..*\n" |
| 432 | "*.**..**o..*o*.*\n" |
| 433 | "*.*.o.*.*o.**..*\n" |
| 434 | "*.**..**...*x*.*\n" |
| 435 | "*.....o........*\n" |
| 436 | "*........o.....*\n" |
| 437 | "****************\n" |
| 438 | "\n" |
| 439 | ".**************.\n" |
| 440 | "*.X*........o.**\n" |
| 441 | "*.*...*o...o**.*\n" |
| 442 | "*.......o....*.*\n" |
| 443 | "*.o..........*o*\n" |
| 444 | "*.*......o.....*\n" |
| 445 | "**......o.o..*o*\n" |
| 446 | "*x..*....o.*.*.*\n" |
| 447 | ".**************.\n" |
| 448 | "\n" |
| 449 | "****************\n" |
| 450 | "*o*o........o*o*\n" |
| 451 | "*.o*X......**..*\n" |
| 452 | "*.x........o...*\n" |
| 453 | "*........o*....*\n" |
| 454 | "*......o.......*\n" |
| 455 | "*.o*........*..*\n" |
| 456 | "*o*o........o*o*\n" |
| 457 | "****************\n" |
| 458 | "\n" |
| 459 | ".******.********\n" |
| 460 | "*.....o*.....o.*\n" |
| 461 | "*.*.o.*..*...o.*\n" |
| 462 | "*..X*...*oo.*o.*\n" |
| 463 | ".*.*...*.o..x*.*\n" |
| 464 | "*o.......*..*o.*\n" |
| 465 | ".*......o.....*.\n" |
| 466 | "*o............o*\n" |
| 467 | "****************\n" |
| 468 | "\n" |
| 469 | "****************\n" |
| 470 | "**.x*o.o......o*\n" |
| 471 | "*o.Xo*o.......**\n" |
| 472 | "**.***........**\n" |
| 473 | "**.....o*o*....*\n" |
| 474 | "*oo.......o*o..*\n" |
| 475 | "**.o....****o..*\n" |
| 476 | "**o*..*........*\n" |
| 477 | "****************\n" |
| 478 | "\n" |
| 479 | "****************\n" |
| 480 | "*.o*........*X.*\n" |
| 481 | "*.*..o*oo*o..*.*\n" |
| 482 | "*....*o**o*.o..*\n" |
| 483 | "*.o*.......o*..*\n" |
| 484 | "*..o*o....o*...*\n" |
| 485 | "*.*..*.**o*..*.*\n" |
| 486 | "*....o.*o...x..*\n" |
| 487 | "****************\n" |
| 488 | "\n" |
| 489 | "****************\n" |
| 490 | "*.o....o..x*...*\n" |
| 491 | "*..*o*o...*o...*\n" |
| 492 | "*...*o*....*o..*\n" |
| 493 | "*...o..*...o*o.*\n" |
| 494 | "*.*o*...*.o*...*\n" |
| 495 | "*.o*o.*.o.*....*\n" |
| 496 | "*o*X..*.....*..*\n" |
| 497 | "****************\n" |
| 498 | "\n" |
| 499 | "****************\n" |
| 500 | "*o...**.....**o*\n" |
| 501 | "*.*..*......*o.*\n" |
| 502 | "*.o*...o**..o..*\n" |
| 503 | "*.*....*o......*\n" |
| 504 | "*....*...o*....*\n" |
| 505 | "*.**.o*.**o..*x*\n" |
| 506 | "*.o*.*o.....**X*\n" |
| 507 | "****************\n" |
| 508 | "\n" |
| 509 | "****************\n" |
| 510 | "*...o*o........*\n" |
| 511 | "**o..o*.**o...**\n" |
| 512 | "*.*.*.o...*..*.*\n" |
| 513 | "*.x.*..**..*.Xo*\n" |
| 514 | "*.*..*...o.*.*.*\n" |
| 515 | "**...o**.*o..o**\n" |
| 516 | "*........o*o...*\n" |
| 517 | "****************"; |
| 518 | |
| 519 | /** |
| 520 | * Display text. |
| 521 | */ |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 522 | void star_display_text(char *str, bool waitkey) |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 523 | { |
| 524 | int chars_by_line; |
| 525 | int lines_by_screen; |
| 526 | int chars_for_line; |
| 527 | int current_line = 0; |
| 528 | int first_char_index = 0; |
| 529 | char *ptr_char; |
| 530 | char *ptr_line; |
| 531 | int i; |
| 532 | char line[255]; |
| 533 | int key; |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 534 | bool go_on; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 535 | |
| 536 | rb->lcd_clear_display(); |
| 537 | |
| 538 | chars_by_line = LCD_WIDTH / char_width; |
| 539 | lines_by_screen = LCD_HEIGHT / char_height; |
| 540 | |
| 541 | do |
| 542 | { |
| 543 | ptr_char = str + first_char_index; |
| 544 | chars_for_line = 0; |
| 545 | i = 0; |
| 546 | ptr_line = line; |
| 547 | while (i < chars_by_line) |
| 548 | { |
| 549 | switch (*ptr_char) |
| 550 | { |
| 551 | case '\t': |
| 552 | case ' ': |
| 553 | *(ptr_line++) = ' '; |
| 554 | case '\n': |
| 555 | case '\0': |
| 556 | chars_for_line = i; |
| 557 | break; |
| 558 | |
| 559 | default: |
| 560 | *(ptr_line++) = *ptr_char; |
| 561 | } |
| 562 | if (*ptr_char == '\n' || *ptr_char == '\0') |
| 563 | break; |
| 564 | ptr_char++; |
| 565 | i++; |
| 566 | } |
| 567 | |
| 568 | if (chars_for_line == 0) |
| 569 | chars_for_line = i; |
| 570 | |
| 571 | line[chars_for_line] = '\0'; |
| 572 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 573 | /* test if we have cut a word. If it is the case we don't have to */ |
Daniel Stenberg | 220fafd | 2006-03-03 08:14:44 +0000 | [diff] [blame] | 574 | /* skip the space */ |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 575 | if (i == chars_by_line && chars_for_line == chars_by_line) |
| 576 | first_char_index += chars_for_line; |
| 577 | else |
| 578 | first_char_index += chars_for_line + 1; |
| 579 | |
Daniel Stenberg | 220fafd | 2006-03-03 08:14:44 +0000 | [diff] [blame] | 580 | /* print the line on the screen */ |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 581 | rb->lcd_putsxy(0, current_line * char_height, line); |
| 582 | |
Daniel Stenberg | 220fafd | 2006-03-03 08:14:44 +0000 | [diff] [blame] | 583 | /* if the number of line showed on the screen is equals to the */ |
| 584 | /* maximum number of line we can show, we wait for a key pressed to */ |
| 585 | /* clear and show the remaining text. */ |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 586 | current_line++; |
| 587 | if (current_line == lines_by_screen || *ptr_char == '\0') |
| 588 | { |
| 589 | current_line = 0; |
| 590 | rb->lcd_update(); |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 591 | go_on = false; |
| 592 | while (waitkey && !go_on) |
| 593 | { |
| 594 | key = rb->button_get(true); |
| 595 | switch (key) |
| 596 | { |
Shachar Liberman | 078e44e | 2006-08-10 17:21:01 +0000 | [diff] [blame] | 597 | case STAR_QUIT: |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 598 | case STAR_LEFT: |
Dave Chapman | 54d44c8 | 2005-12-14 01:31:37 +0000 | [diff] [blame] | 599 | case STAR_DOWN: |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 600 | go_on = true; |
| 601 | break; |
Zakk Roberts | ec216ac | 2006-06-03 19:24:10 +0000 | [diff] [blame] | 602 | |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 603 | default: |
| 604 | if (rb->default_event_handler(key) == SYS_USB_CONNECTED) |
| 605 | { |
| 606 | usb_detected = true; |
| 607 | go_on = true; |
| 608 | break; |
| 609 | } |
| 610 | } |
| 611 | } |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 612 | rb->lcd_clear_display(); |
| 613 | } |
| 614 | } while (*ptr_char != '\0'); |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * Do a pretty transition from one level to another. |
| 619 | */ |
| 620 | static void star_transition_update(void) |
Zakk Roberts | ec216ac | 2006-06-03 19:24:10 +0000 | [diff] [blame] | 621 | { |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 622 | const int center_x = LCD_WIDTH / 2; |
| 623 | const int center_y = LCD_HEIGHT / 2; |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 624 | int x = 0; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 625 | int y = 0; |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 626 | #if LCD_WIDTH >= LCD_HEIGHT |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 627 | #if defined(IPOD_VIDEO) |
| 628 | const int step = 4; |
| 629 | #else |
| 630 | const int step = 1; |
| 631 | #endif |
| 632 | const int lcd_demi_width = LCD_WIDTH / 2; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 633 | int var_y = 0; |
| 634 | |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 635 | for (; x < lcd_demi_width ; x+=step) |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 636 | { |
| 637 | var_y += LCD_HEIGHT; |
| 638 | if (var_y > LCD_WIDTH) |
| 639 | { |
| 640 | var_y -= LCD_WIDTH; |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 641 | y+=step; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 642 | } |
Antoine Cellerier | c05ba51 | 2007-10-15 21:00:57 +0000 | [diff] [blame] | 643 | if( x ) |
| 644 | { |
| 645 | rb->lcd_update_rect(center_x - x, center_y - y, x*2, step); |
| 646 | rb->lcd_update_rect(center_x - x, center_y + y - step, x*2, step); |
| 647 | } |
| 648 | if( y ) |
| 649 | { |
| 650 | rb->lcd_update_rect(center_x - x, center_y - y, step, y*2); |
| 651 | rb->lcd_update_rect(center_x + x - step, center_y - y, step, y*2); |
| 652 | } |
Antoine Cellerier | fb3c066 | 2006-06-11 13:25:44 +0000 | [diff] [blame] | 653 | STAR_SLEEP |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 654 | } |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 655 | #else |
| 656 | int lcd_demi_height = LCD_HEIGHT / 2; |
| 657 | int var_x = 0; |
| 658 | |
| 659 | for (; y < lcd_demi_height ; y++) |
| 660 | { |
| 661 | var_x += LCD_WIDTH; |
| 662 | if (var_x > LCD_HEIGHT) |
| 663 | { |
| 664 | var_x -= LCD_HEIGHT; |
| 665 | x++; |
| 666 | } |
Antoine Cellerier | c05ba51 | 2007-10-15 21:00:57 +0000 | [diff] [blame] | 667 | if( x ) |
| 668 | { |
| 669 | rb->lcd_update_rect(center_x - x, center_y - y, x * 2, 1); |
| 670 | rb->lcd_update_rect(center_x - x, center_y + y - 1, x * 2, 1); |
| 671 | } |
| 672 | if( y ) |
| 673 | { |
| 674 | rb->lcd_update_rect(center_x - x, center_y - y, 1, y * 2); |
| 675 | rb->lcd_update_rect(center_x + x - 1, center_y - y, 1, y * 2); |
| 676 | } |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 677 | STAR_SLEEP |
| 678 | } |
| 679 | #endif |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 680 | rb->lcd_update(); |
| 681 | } |
| 682 | |
| 683 | /** |
| 684 | * Display information board of the current level. |
| 685 | */ |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 686 | static void star_display_board_info(int current_level) |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 687 | { |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 688 | int label_pos_y, tile_pos_y; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 689 | char str_info[32]; |
| 690 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 691 | if (TILE_HEIGHT > char_height) |
| 692 | { |
| 693 | tile_pos_y = LCD_HEIGHT - TILE_HEIGHT; |
| 694 | label_pos_y = tile_pos_y + (TILE_HEIGHT - char_height) / 2; |
| 695 | } |
Antoine Cellerier | 40a92ea | 2006-06-10 20:39:33 +0000 | [diff] [blame] | 696 | else |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 697 | { |
| 698 | label_pos_y = LCD_HEIGHT - char_height; |
| 699 | tile_pos_y = label_pos_y + (char_height - TILE_HEIGHT) / 2; |
| 700 | } |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 701 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 702 | rb->snprintf(str_info, sizeof(str_info), "L:%02d", current_level + 1); |
| 703 | rb->lcd_putsxy(STAR_OFFSET_X, label_pos_y, str_info); |
| 704 | rb->snprintf(str_info, sizeof(str_info), "S:%02d", star_count); |
| 705 | rb->lcd_putsxy(LCD_WIDTH/2 - 2 * char_width, label_pos_y, str_info); |
| 706 | rb->lcd_putsxy(STAR_OFFSET_X + (STAR_WIDTH-1) * TILE_WIDTH - 2 * char_width, |
| 707 | label_pos_y, "C:"); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 708 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 709 | rb->lcd_bitmap_part(star_tiles, 0, control == STAR_CONTROL_BALL ? |
| 710 | BALL*TILE_HEIGHT : BLOCK*TILE_HEIGHT, TILE_WIDTH, |
| 711 | STAR_OFFSET_X + (STAR_WIDTH-1) * TILE_WIDTH, |
| 712 | tile_pos_y, TILE_WIDTH, TILE_HEIGHT); |
Antoine Cellerier | 40a92ea | 2006-06-10 20:39:33 +0000 | [diff] [blame] | 713 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 714 | rb->lcd_update_rect(0, MIN(label_pos_y, tile_pos_y), LCD_WIDTH, |
| 715 | MAX(TILE_HEIGHT, char_height)); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | |
| 719 | /** |
| 720 | * Load a level into board array. |
| 721 | */ |
| 722 | static int star_load_level(int current_level) |
| 723 | { |
| 724 | int x, y; |
| 725 | char *ptr_tab; |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 726 | |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 727 | if (current_level < 0) |
| 728 | current_level = 0; |
| 729 | else if (current_level > STAR_LEVEL_COUNT-1) |
| 730 | current_level = STAR_LEVEL_COUNT-1; |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 731 | |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 732 | |
| 733 | ptr_tab = levels + current_level * STAR_LEVEL_SIZE; |
| 734 | control = STAR_CONTROL_BALL; |
| 735 | star_count = 0; |
| 736 | |
| 737 | rb->lcd_clear_display(); |
| 738 | |
| 739 | for (y = 0 ; y < STAR_HEIGHT ; y++) |
| 740 | { |
| 741 | for (x = 0 ; x < STAR_WIDTH ; x++) |
| 742 | { |
| 743 | board[y][x] = *ptr_tab; |
| 744 | switch (*ptr_tab) |
| 745 | { |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 746 | # define DRAW_TILE( a ) \ |
| 747 | rb->lcd_bitmap_part( star_tiles, 0, \ |
| 748 | a*TILE_HEIGHT, TILE_WIDTH, \ |
| 749 | STAR_OFFSET_X + x * TILE_WIDTH, \ |
| 750 | STAR_OFFSET_Y + y * TILE_HEIGHT, \ |
| 751 | TILE_WIDTH, TILE_HEIGHT); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 752 | case STAR_VOID: |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 753 | DRAW_TILE( SPACE ); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 754 | break; |
| 755 | |
| 756 | case STAR_WALL: |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 757 | DRAW_TILE( WALL ); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 758 | break; |
| 759 | |
| 760 | case STAR_STAR: |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 761 | DRAW_TILE( STAR ); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 762 | star_count++; |
| 763 | break; |
| 764 | |
| 765 | case STAR_BALL: |
| 766 | ball_x = x; |
| 767 | ball_y = y; |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 768 | DRAW_TILE( BALL ); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 769 | break; |
| 770 | |
| 771 | |
| 772 | case STAR_BLOCK: |
| 773 | block_x = x; |
| 774 | block_y = y; |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 775 | DRAW_TILE( BLOCK ); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 776 | break; |
| 777 | } |
| 778 | ptr_tab++; |
| 779 | } |
| 780 | ptr_tab++; |
| 781 | } |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 782 | star_display_board_info(current_level); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 783 | star_transition_update(); |
| 784 | return 1; |
| 785 | } |
| 786 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 787 | static void star_animate_tile(int tile_no, int start_x, int start_y, |
| 788 | int delta_x, int delta_y) |
| 789 | { |
| 790 | int i; |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 791 | |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 792 | if (delta_x != 0) /* horizontal */ |
| 793 | { |
| 794 | for (i = 1 ; i <= TILE_WIDTH ; i++) |
| 795 | { |
| 796 | STAR_SLEEP |
| 797 | rb->lcd_bitmap_part(star_tiles, 0, SPACE * TILE_HEIGHT, TILE_WIDTH, |
| 798 | start_x, start_y, TILE_WIDTH, TILE_HEIGHT); |
| 799 | rb->lcd_bitmap_part(star_tiles, 0, tile_no * TILE_HEIGHT, TILE_WIDTH, |
| 800 | start_x + delta_x * i, start_y, TILE_WIDTH, TILE_HEIGHT); |
| 801 | rb->lcd_update_rect(start_x + delta_x * i - (delta_x>0?1:0), |
| 802 | start_y, TILE_WIDTH + 1, TILE_HEIGHT); |
| 803 | } |
| 804 | } |
| 805 | else /* vertical */ |
| 806 | { |
| 807 | for (i = 1 ; i <= TILE_HEIGHT ; i++) |
| 808 | { |
| 809 | STAR_SLEEP |
| 810 | rb->lcd_bitmap_part(star_tiles, 0, SPACE * TILE_HEIGHT, TILE_WIDTH, |
| 811 | start_x, start_y, TILE_WIDTH, TILE_HEIGHT); |
| 812 | rb->lcd_bitmap_part(star_tiles, 0, tile_no * TILE_HEIGHT, TILE_WIDTH, |
| 813 | start_x, start_y + delta_y * i, TILE_WIDTH, TILE_HEIGHT); |
| 814 | rb->lcd_update_rect(start_x, start_y + delta_y * i - (delta_y>0?1:0), |
| 815 | TILE_WIDTH, TILE_HEIGHT + 1); |
| 816 | } |
| 817 | } |
| 818 | } |
| 819 | |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 820 | /** |
| 821 | * Run the game. |
| 822 | */ |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 823 | static int star_run_game(int current_level) |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 824 | { |
| 825 | int move_x = 0; |
| 826 | int move_y = 0; |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 827 | int key; |
| 828 | int lastkey = BUTTON_NONE; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 829 | |
| 830 | int label_offset_y; |
| 831 | |
| 832 | label_offset_y = LCD_HEIGHT - char_height; |
| 833 | |
| 834 | if (!star_load_level(current_level)) |
| 835 | return 0; |
| 836 | |
| 837 | while (true) |
| 838 | { |
| 839 | move_x = 0; |
| 840 | move_y = 0; |
| 841 | |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 842 | while ((move_x == 0) && (move_y == 0)) |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 843 | { |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 844 | key = rb->button_get(true); |
| 845 | switch (key) |
| 846 | { |
Kevin Ferrare | 0e027bd | 2006-06-30 16:43:47 +0000 | [diff] [blame] | 847 | #ifdef STAR_RC_QUIT |
| 848 | case STAR_RC_QUIT: |
| 849 | #endif |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 850 | case STAR_QUIT: |
Shachar Liberman | 078e44e | 2006-08-10 17:21:01 +0000 | [diff] [blame] | 851 | return -1; |
Zakk Roberts | ec216ac | 2006-06-03 19:24:10 +0000 | [diff] [blame] | 852 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 853 | case STAR_LEFT: |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 854 | move_x = -1; |
| 855 | break; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 856 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 857 | case STAR_RIGHT: |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 858 | move_x = 1; |
| 859 | break; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 860 | |
Dave Chapman | 54d44c8 | 2005-12-14 01:31:37 +0000 | [diff] [blame] | 861 | case STAR_UP: |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 862 | move_y = -1; |
| 863 | break; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 864 | |
Dave Chapman | 54d44c8 | 2005-12-14 01:31:37 +0000 | [diff] [blame] | 865 | case STAR_DOWN: |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 866 | move_y = 1; |
| 867 | break; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 868 | |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 869 | case STAR_LEVEL_DOWN: |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 870 | #ifdef STAR_LEVEL_DOWN_PRE |
| 871 | if (lastkey != STAR_LEVEL_DOWN_PRE) |
| 872 | break; |
| 873 | #endif |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 874 | if (current_level > 0) |
| 875 | { |
| 876 | current_level--; |
| 877 | star_load_level(current_level); |
| 878 | } |
| 879 | break; |
| 880 | |
| 881 | case STAR_LEVEL_REPEAT: |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 882 | star_load_level(current_level); |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 883 | break; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 884 | |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 885 | case STAR_LEVEL_UP: |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 886 | #ifdef STAR_LEVEL_UP_PRE |
| 887 | if (lastkey != STAR_LEVEL_UP_PRE) |
| 888 | break; |
| 889 | #endif |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 890 | if (current_level < STAR_LEVEL_COUNT - 1) |
| 891 | { |
| 892 | current_level++; |
| 893 | star_load_level(current_level); |
| 894 | } |
| 895 | break; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 896 | |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 897 | case STAR_TOGGLE_CONTROL: |
| 898 | #ifdef STAR_TOGGLE_CONTROL_PRE |
| 899 | if (lastkey != STAR_TOGGLE_CONTROL_PRE) |
| 900 | break; |
| 901 | #endif |
| 902 | #ifdef STAR_TOGGLE_CONTROL2 |
| 903 | case STAR_TOGGLE_CONTROL2: |
| 904 | #endif |
| 905 | if (control == STAR_CONTROL_BALL) |
| 906 | control = STAR_CONTROL_BLOCK; |
| 907 | else |
| 908 | control = STAR_CONTROL_BALL; |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 909 | star_display_board_info(current_level); |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 910 | break; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 911 | |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 912 | default: |
| 913 | if (rb->default_event_handler(key) == SYS_USB_CONNECTED) |
| 914 | { |
| 915 | usb_detected = true; |
| 916 | return 0; |
| 917 | } |
| 918 | break; |
| 919 | } |
| 920 | if (key != BUTTON_NONE) |
| 921 | lastkey = key; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 922 | } |
| 923 | |
| 924 | if (control == STAR_CONTROL_BALL) |
| 925 | { |
| 926 | board[ball_y][ball_x] = STAR_VOID; |
| 927 | while ((board[ball_y + move_y][ball_x + move_x] == STAR_VOID |
| 928 | || board[ball_y + move_y][ball_x + move_x] == STAR_STAR)) |
| 929 | |
| 930 | { |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 931 | star_animate_tile(BALL, STAR_OFFSET_X + ball_x * TILE_WIDTH, |
| 932 | STAR_OFFSET_Y + ball_y * TILE_HEIGHT, |
| 933 | move_x, move_y); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 934 | ball_x += move_x; |
| 935 | ball_y += move_y; |
| 936 | |
| 937 | if (board[ball_y][ball_x] == STAR_STAR) |
| 938 | { |
| 939 | board[ball_y][ball_x] = STAR_VOID; |
| 940 | star_count--; |
| 941 | |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 942 | star_display_board_info(current_level); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 943 | } |
| 944 | } |
| 945 | board[ball_y][ball_x] = STAR_BALL; |
| 946 | } |
| 947 | else |
| 948 | { |
| 949 | board[block_y][block_x] = STAR_VOID; |
| 950 | while (board[block_y + move_y][block_x + move_x] == STAR_VOID) |
| 951 | { |
Jens Arnold | 4f1ca13 | 2006-10-21 00:24:54 +0000 | [diff] [blame] | 952 | star_animate_tile(BLOCK, STAR_OFFSET_X + block_x * TILE_WIDTH, |
| 953 | STAR_OFFSET_Y + block_y * TILE_HEIGHT, |
| 954 | move_x, move_y); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 955 | block_x += move_x; |
| 956 | block_y += move_y; |
| 957 | } |
| 958 | board[block_y][block_x] = STAR_BLOCK; |
| 959 | } |
| 960 | |
| 961 | if (star_count == 0) |
| 962 | { |
| 963 | current_level++; |
| 964 | if (current_level == STAR_LEVEL_COUNT) |
| 965 | { |
| 966 | rb->lcd_clear_display(); |
Barry Wardell | 53c3eeb | 2006-10-06 16:20:57 +0000 | [diff] [blame] | 967 | star_display_text("Congratulations!", true); |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 968 | rb->lcd_update(); |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 969 | |
Barry Wardell | 53c3eeb | 2006-10-06 16:20:57 +0000 | [diff] [blame] | 970 | /* There is no such level as STAR_LEVEL_COUNT so it can't be the |
| 971 | * current_level */ |
| 972 | current_level--; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 973 | return 1; |
| 974 | } |
| 975 | star_load_level(current_level); |
| 976 | } |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | /** |
| 981 | * Display the choice menu. |
| 982 | */ |
| 983 | static int star_menu(void) |
| 984 | { |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 985 | int selection, level=1; |
| 986 | bool menu_quit = false; |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 987 | struct viewport vp[NB_SCREENS]; |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 988 | /* get the size of char */ |
| 989 | rb->lcd_getstringsize("a", &char_width, &char_height); |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 990 | |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 991 | MENUITEM_STRINGLIST(menu,"Star Menu",NULL,"Play","Choose Level", |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 992 | "Information","Keys","Quit"); |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 993 | FOR_NB_SCREENS(selection) |
| 994 | { |
| 995 | rb->viewport_set_defaults(&vp[selection], selection); |
| 996 | /* we are hiding the statusbar so fix the height also */ |
Jonathan Gordon | 476d289 | 2008-05-18 10:19:21 +0000 | [diff] [blame] | 997 | vp[selection].y = 0; |
| 998 | vp[selection].height = rb->screens[selection]->height; |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 999 | #if LCD_DEPTH > 1 |
| 1000 | if (rb->screens[selection]->depth > 1) |
| 1001 | { |
| 1002 | vp->bg_pattern = LCD_BLACK; |
| 1003 | vp->fg_pattern = LCD_WHITE; |
| 1004 | } |
| 1005 | #endif |
| 1006 | } |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1007 | while(!menu_quit) |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1008 | { |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 1009 | switch(rb->do_menu(&menu, &selection, vp, true)) |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1010 | { |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1011 | case 0: |
| 1012 | menu_quit = true; |
Zakk Roberts | ec216ac | 2006-06-03 19:24:10 +0000 | [diff] [blame] | 1013 | break; |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1014 | case 1: |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 1015 | rb->set_int("Level", "", UNIT_INT, &level, |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1016 | NULL, 1, 1, STAR_LEVEL_COUNT, NULL ); |
Zakk Roberts | ec216ac | 2006-06-03 19:24:10 +0000 | [diff] [blame] | 1017 | break; |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1018 | case 2: |
| 1019 | star_display_text( |
| 1020 | "INFO\n\n" |
| 1021 | "Take all the stars to go to the next level. " |
| 1022 | "You can toggle control with the block to " |
| 1023 | "use it as a mobile wall. The block cannot " |
| 1024 | "take stars.", true); |
| 1025 | break; |
| 1026 | case 3: |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 1027 | #if CONFIG_KEYPAD == RECORDER_PAD |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1028 | star_display_text("KEYS\n\n" |
| 1029 | "[ON] Toggle Ctl.\n" |
| 1030 | "[OFF] Exit\n" |
| 1031 | "[F1] Prev. level\n" |
| 1032 | "[F2] Reset level\n" |
| 1033 | "[F3] Next level", true); |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 1034 | #elif CONFIG_KEYPAD == ONDIO_PAD |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1035 | star_display_text("KEYS\n\n" |
| 1036 | "[MODE] Toggle Ctl\n" |
| 1037 | "[OFF] Exit\n" |
| 1038 | "[M <] Prev. level\n" |
| 1039 | "[M ^] Reset level\n" |
| 1040 | "[M >] Next level", true); |
Antoine Cellerier | 2d4cfa8 | 2006-07-27 22:28:48 +0000 | [diff] [blame] | 1041 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1042 | star_display_text("KEYS\n\n" |
| 1043 | "[MODE/NAVI] Toggle Ctrl\n" |
| 1044 | "[OFF] Exit\n" |
| 1045 | "[ON + LEFT] Prev. level\n" |
| 1046 | "[ON + NAVI] Reset level\n" |
| 1047 | "[ON + RIGHT] Next level", true); |
Jens Arnold | b701322 | 2007-07-27 09:57:27 +0000 | [diff] [blame] | 1048 | #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ |
| 1049 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1050 | star_display_text("KEYS\n\n" |
| 1051 | "[SELECT] Toggle Ctl\n" |
| 1052 | "[S + MENU] Exit\n" |
| 1053 | "[S <] Prev. level\n" |
| 1054 | "[S + PLAY] Reset level\n" |
| 1055 | "[S >] Next level", true); |
Jens Arnold | 85a226d | 2007-03-16 23:02:39 +0000 | [diff] [blame] | 1056 | #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1057 | star_display_text("KEYS\n\n" |
| 1058 | "[SELECT] Toggle Ctl\n" |
| 1059 | "[POWER] Exit\n" |
| 1060 | "[REC..] Prev. level\n" |
| 1061 | "[PLAY] Reset level\n" |
| 1062 | "[REC] Next level", true); |
Antoine Cellerier | 2d4cfa8 | 2006-07-27 22:28:48 +0000 | [diff] [blame] | 1063 | #elif CONFIG_KEYPAD == GIGABEAT_PAD |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1064 | star_display_text("KEYS\n\n" |
| 1065 | "[MENU] Toggle Control\n" |
| 1066 | "[A] Exit\n" |
| 1067 | "[PWR+DOWN] Prev. level\n" |
| 1068 | "[PWR+RIGHT] Reset level\n" |
| 1069 | "[PWR+UP] Next level", true); |
Barry Wardell | 6fdd4b0 | 2006-10-18 00:20:07 +0000 | [diff] [blame] | 1070 | #elif CONFIG_KEYPAD == IRIVER_H10_PAD |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1071 | star_display_text("KEYS\n\n" |
| 1072 | "[REW] Toggle Ctl\n" |
| 1073 | "[POWER] Exit\n" |
| 1074 | "[PLAY+DOWN] Prev. level\n" |
| 1075 | "[PLAY+RIGHT] Reset level\n" |
| 1076 | "[PLAY+UP] Next level", true); |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 1077 | #endif |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 1078 | #ifdef HAVE_TOUCHPAD |
| 1079 | star_display_text("KEYS\n\n" |
| 1080 | STAR_TOGGLE_CONTROL_NAME " Toggle Control\n" |
| 1081 | STAR_QUIT_NAME " Exit\n" |
| 1082 | STAR_LEVEL_DOWN_NAME " Prev. level\n" |
| 1083 | STAR_LEVEL_REPEAT_NAME " Reset level\n" |
| 1084 | STAR_LEVEL_UP_NAME " Next level", true); |
| 1085 | #endif |
Zakk Roberts | ec216ac | 2006-06-03 19:24:10 +0000 | [diff] [blame] | 1086 | break; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1087 | default: |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1088 | menu_quit = true; |
Jens Arnold | 2afdf95 | 2004-10-22 00:22:07 +0000 | [diff] [blame] | 1089 | break; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1090 | } |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1091 | } |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 1092 | |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1093 | if (selection == MENU_START) |
| 1094 | { |
| 1095 | rb->lcd_setfont(FONT_SYSFIXED); |
| 1096 | rb->lcd_getstringsize("a", &char_width, &char_height); |
| 1097 | level--; |
| 1098 | star_run_game(level); |
| 1099 | } |
Antoine Cellerier | e8c94d8 | 2007-06-06 21:10:48 +0000 | [diff] [blame] | 1100 | |
Tom Ross | c7f5ccc | 2007-03-28 07:33:18 +0000 | [diff] [blame] | 1101 | return PLUGIN_OK; |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1102 | } |
| 1103 | |
| 1104 | /** |
| 1105 | * Main entry point |
| 1106 | */ |
Steve Bavin | 6526577 | 2008-05-13 09:57:56 +0000 | [diff] [blame] | 1107 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1108 | { |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1109 | (void)parameter; |
| 1110 | rb = api; |
| 1111 | |
Antoine Cellerier | a322081 | 2006-07-27 22:04:07 +0000 | [diff] [blame] | 1112 | #if LCD_DEPTH > 1 |
Karl Kurbjun | d6b0c97 | 2006-11-15 06:14:27 +0000 | [diff] [blame] | 1113 | rb->lcd_set_backdrop(NULL); |
Antoine Cellerier | 40a92ea | 2006-06-10 20:39:33 +0000 | [diff] [blame] | 1114 | rb->lcd_set_background( LCD_BLACK ); |
| 1115 | rb->lcd_set_foreground( LCD_WHITE ); |
| 1116 | #endif |
| 1117 | |
Björn Stenberg | 020ab8f | 2003-06-29 21:10:27 +0000 | [diff] [blame] | 1118 | /* display choice menu */ |
| 1119 | return star_menu(); |
| 1120 | } |
| 1121 | |
| 1122 | #endif |