Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2005 Eli Sherer |
| 11 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 12 | * Heavily modified for embedded use by Björn Stenberg (bjorn@haxx.se) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 13 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License |
| 16 | * as published by the Free Software Foundation; either version 2 |
| 17 | * of the License, or (at your option) any later version. |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 18 | * |
| 19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 20 | * KIND, either express or implied. |
| 21 | * |
| 22 | ****************************************************************************/ |
| 23 | #include "plugin.h" |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 24 | #include "lib/display_text.h" |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 25 | #include "lib/helper.h" |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 26 | #include "lib/highscore.h" |
| 27 | #include "lib/playback_control.h" |
| 28 | #include "lib/playergfx.h" |
Michael Sevakis | e63e84a | 2010-06-04 13:22:50 +0000 | [diff] [blame] | 29 | #include "lib/mylcd.h" |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 30 | |
Thomas Martitz | cae4ae2 | 2010-08-24 14:30:46 +0000 | [diff] [blame] | 31 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 32 | |
Jens Arnold | b701322 | 2007-07-27 09:57:27 +0000 | [diff] [blame] | 33 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || \ |
| 34 | (CONFIG_KEYPAD == IPOD_3G_PAD) || \ |
| 35 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 36 | |
| 37 | #define ROCKBLOX_OFF (BUTTON_MENU | BUTTON_SELECT) |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 38 | #define ROCKBLOX_ROTATE_CCW BUTTON_SCROLL_BACK |
| 39 | #define ROCKBLOX_ROTATE_CCW2 (BUTTON_MENU | BUTTON_REL) |
| 40 | #define ROCKBLOX_ROTATE_CW BUTTON_SCROLL_FWD |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 41 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 42 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 43 | #define ROCKBLOX_DOWN BUTTON_PLAY |
| 44 | #define ROCKBLOX_RESTART (BUTTON_SELECT | BUTTON_PLAY) |
| 45 | #define ROCKBLOX_DROP (BUTTON_SELECT | BUTTON_REL) |
| 46 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 47 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ |
| 48 | (CONFIG_KEYPAD == IRIVER_H300_PAD) |
| 49 | |
| 50 | #define ROCKBLOX_OFF BUTTON_OFF |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 51 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 52 | #define ROCKBLOX_ROTATE_CW BUTTON_SELECT |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 53 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 54 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 55 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 56 | #define ROCKBLOX_DROP BUTTON_MODE |
| 57 | #define ROCKBLOX_RESTART BUTTON_ON |
| 58 | |
| 59 | #define ROCKBLOX_RC_OFF BUTTON_RC_STOP |
Jens Arnold | b701322 | 2007-07-27 09:57:27 +0000 | [diff] [blame] | 60 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 61 | #elif CONFIG_KEYPAD == RECORDER_PAD |
| 62 | |
| 63 | #define ROCKBLOX_OFF BUTTON_OFF |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 64 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 65 | #define ROCKBLOX_ROTATE_CW BUTTON_PLAY |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 66 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 67 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 68 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 69 | #define ROCKBLOX_DROP BUTTON_ON |
| 70 | #define ROCKBLOX_RESTART BUTTON_F1 |
| 71 | |
Dave Chapman | d64e626 | 2007-01-14 13:48:09 +0000 | [diff] [blame] | 72 | #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD |
| 73 | |
| 74 | #define ROCKBLOX_OFF BUTTON_OFF |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 75 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 76 | #define ROCKBLOX_ROTATE_CW BUTTON_SELECT |
Dave Chapman | d64e626 | 2007-01-14 13:48:09 +0000 | [diff] [blame] | 77 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 78 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 79 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 80 | #define ROCKBLOX_DROP BUTTON_ON |
| 81 | #define ROCKBLOX_RESTART BUTTON_F1 |
| 82 | |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 83 | #elif CONFIG_KEYPAD == PLAYER_PAD |
| 84 | |
Marianne Arnold | f772673 | 2009-05-18 21:30:06 +0000 | [diff] [blame] | 85 | #define ROCKBLOX_OFF_PRE BUTTON_STOP |
| 86 | #define ROCKBLOX_OFF (BUTTON_STOP|BUTTON_REL) |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 87 | #define ROCKBLOX_ROTATE_CCW BUTTON_PLAY |
| 88 | #define ROCKBLOX_ROTATE_CW (BUTTON_ON|BUTTON_PLAY) |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 89 | #define ROCKBLOX_DOWN BUTTON_MENU |
| 90 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 91 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 92 | #define ROCKBLOX_DROP_PRE BUTTON_ON |
| 93 | #define ROCKBLOX_DROP (BUTTON_ON|BUTTON_REL) |
Thomas Martitz | ba5618a | 2009-05-16 16:48:18 +0000 | [diff] [blame] | 94 | #define ROCKBLOX_RESTART (BUTTON_STOP|BUTTON_MENU) |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 95 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 96 | #elif CONFIG_KEYPAD == ONDIO_PAD |
| 97 | |
Marianne Arnold | f772673 | 2009-05-18 21:30:06 +0000 | [diff] [blame] | 98 | #define ROCKBLOX_OFF_PRE BUTTON_OFF |
| 99 | #define ROCKBLOX_OFF (BUTTON_OFF|BUTTON_REL) |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 100 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 101 | #define ROCKBLOX_ROTATE_CW (BUTTON_MENU|BUTTON_UP) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 102 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 103 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 104 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 105 | #define ROCKBLOX_DROP_PRE BUTTON_MENU |
| 106 | #define ROCKBLOX_DROP (BUTTON_MENU|BUTTON_REL) |
Thomas Martitz | ba5618a | 2009-05-16 16:48:18 +0000 | [diff] [blame] | 107 | #define ROCKBLOX_RESTART (BUTTON_OFF|BUTTON_MENU) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 108 | |
Jens Arnold | 85a226d | 2007-03-16 23:02:39 +0000 | [diff] [blame] | 109 | #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 110 | |
| 111 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 112 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 113 | #define ROCKBLOX_ROTATE_CW BUTTON_SELECT |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 114 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 115 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 116 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 117 | #define ROCKBLOX_DROP BUTTON_REC |
| 118 | #define ROCKBLOX_RESTART BUTTON_PLAY |
| 119 | |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 120 | #elif CONFIG_KEYPAD == SANSA_E200_PAD |
| 121 | |
| 122 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 123 | #define ROCKBLOX_ROTATE_CCW BUTTON_SCROLL_BACK |
| 124 | #define ROCKBLOX_ROTATE_CCW2 BUTTON_UP |
| 125 | #define ROCKBLOX_ROTATE_CW BUTTON_SCROLL_FWD |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 126 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 127 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 128 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 129 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 130 | #define ROCKBLOX_RESTART BUTTON_REC |
| 131 | |
Michael Giacomelli | 6d5823f | 2009-01-04 23:33:15 +0000 | [diff] [blame] | 132 | #elif CONFIG_KEYPAD == SANSA_FUZE_PAD |
| 133 | |
Thomas Martitz | e6cbad6 | 2009-04-10 17:28:26 +0000 | [diff] [blame] | 134 | #define ROCKBLOX_OFF (BUTTON_HOME|BUTTON_REPEAT) |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 135 | #define ROCKBLOX_ROTATE_CCW BUTTON_SCROLL_BACK |
| 136 | #define ROCKBLOX_ROTATE_CCW2 BUTTON_UP |
| 137 | #define ROCKBLOX_ROTATE_CW BUTTON_SCROLL_FWD |
Michael Giacomelli | 6d5823f | 2009-01-04 23:33:15 +0000 | [diff] [blame] | 138 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 139 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 140 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
Thomas Martitz | e6cbad6 | 2009-04-10 17:28:26 +0000 | [diff] [blame] | 141 | #define ROCKBLOX_DROP (BUTTON_SELECT | BUTTON_REL) |
| 142 | #define ROCKBLOX_RESTART (BUTTON_SELECT | BUTTON_UP) |
Michael Giacomelli | 6d5823f | 2009-01-04 23:33:15 +0000 | [diff] [blame] | 143 | |
| 144 | |
Marianne Arnold | 12ddb8e | 2007-09-20 10:49:48 +0000 | [diff] [blame] | 145 | #elif CONFIG_KEYPAD == SANSA_C200_PAD |
| 146 | |
| 147 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 148 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 149 | #define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN |
| 150 | #define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP |
Marianne Arnold | 12ddb8e | 2007-09-20 10:49:48 +0000 | [diff] [blame] | 151 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 152 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 153 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 154 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 155 | #define ROCKBLOX_RESTART BUTTON_REC |
| 156 | |
Rafaël Carré | 5656f82 | 2008-11-28 00:37:28 +0000 | [diff] [blame] | 157 | #elif CONFIG_KEYPAD == SANSA_CLIP_PAD |
| 158 | |
| 159 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 160 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 161 | #define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN |
| 162 | #define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP |
Rafaël Carré | 5656f82 | 2008-11-28 00:37:28 +0000 | [diff] [blame] | 163 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 164 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 165 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 166 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 167 | #define ROCKBLOX_RESTART BUTTON_HOME |
| 168 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 169 | #elif CONFIG_KEYPAD == SANSA_M200_PAD |
Dominik Wenger | 90bcf9b | 2008-12-12 19:50:49 +0000 | [diff] [blame] | 170 | |
| 171 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 172 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 173 | #define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN |
| 174 | #define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP |
Dominik Wenger | 90bcf9b | 2008-12-12 19:50:49 +0000 | [diff] [blame] | 175 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 176 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 177 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 178 | #define ROCKBLOX_RESTART (BUTTON_SELECT | BUTTON_UP) |
| 179 | #define ROCKBLOX_DROP (BUTTON_SELECT | BUTTON_REL) |
| 180 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 181 | #elif CONFIG_KEYPAD == IRIVER_H10_PAD |
| 182 | |
| 183 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 184 | #define ROCKBLOX_ROTATE_CCW BUTTON_SCROLL_UP |
| 185 | #define ROCKBLOX_ROTATE_CW BUTTON_REW |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 186 | #define ROCKBLOX_DOWN BUTTON_SCROLL_DOWN |
| 187 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 188 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 189 | #define ROCKBLOX_DROP BUTTON_FF |
| 190 | #define ROCKBLOX_RESTART BUTTON_PLAY |
| 191 | |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 192 | #elif CONFIG_KEYPAD == GIGABEAT_PAD |
| 193 | |
Marcoen Hirschberg | a7168fe | 2007-05-19 23:38:09 +0000 | [diff] [blame] | 194 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 195 | #define ROCKBLOX_ROTATE_CCW BUTTON_VOL_DOWN |
| 196 | #define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP |
Marcoen Hirschberg | a7168fe | 2007-05-19 23:38:09 +0000 | [diff] [blame] | 197 | #define ROCKBLOX_ROTATE BUTTON_UP |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 198 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 199 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 200 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 201 | #define ROCKBLOX_DROP BUTTON_SELECT |
Marcoen Hirschberg | a7168fe | 2007-05-19 23:38:09 +0000 | [diff] [blame] | 202 | #define ROCKBLOX_RESTART BUTTON_A |
Marianne Arnold | 59c9dcc | 2007-01-06 12:38:41 +0000 | [diff] [blame] | 203 | |
| 204 | #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD |
| 205 | |
| 206 | #define ROCKBLOX_OFF BUTTON_PLAY |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 207 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 208 | #define ROCKBLOX_ROTATE_CW BUTTON_SELECT |
Marianne Arnold | 59c9dcc | 2007-01-06 12:38:41 +0000 | [diff] [blame] | 209 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 210 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 211 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 212 | #define ROCKBLOX_DROP BUTTON_MODE |
| 213 | #define ROCKBLOX_RESTART BUTTON_EQ |
| 214 | |
Jonathan Gordon | 56ddddc | 2007-10-23 15:40:51 +0000 | [diff] [blame] | 215 | #elif CONFIG_KEYPAD == MROBE500_PAD |
| 216 | #define ROCKBLOX_OFF BUTTON_POWER |
Jonathan Gordon | 56ddddc | 2007-10-23 15:40:51 +0000 | [diff] [blame] | 217 | |
Will Robertson | 8215b34 | 2008-02-17 12:23:02 +0000 | [diff] [blame] | 218 | #elif CONFIG_KEYPAD == GIGABEAT_S_PAD |
| 219 | #define ROCKBLOX_OFF BUTTON_BACK |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 220 | #define ROCKBLOX_ROTATE_CCW BUTTON_VOL_DOWN |
| 221 | #define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP |
Will Robertson | 8215b34 | 2008-02-17 12:23:02 +0000 | [diff] [blame] | 222 | #define ROCKBLOX_ROTATE BUTTON_UP |
| 223 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 224 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 225 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 226 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 227 | #define ROCKBLOX_RESTART BUTTON_PLAY |
| 228 | |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 229 | #elif CONFIG_KEYPAD == MROBE100_PAD |
| 230 | |
| 231 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 232 | #define ROCKBLOX_ROTATE_CCW BUTTON_MENU |
| 233 | #define ROCKBLOX_ROTATE_CW BUTTON_PLAY |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 234 | #define ROCKBLOX_ROTATE BUTTON_UP |
| 235 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 236 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 237 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 238 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 239 | #define ROCKBLOX_RESTART BUTTON_DISPLAY |
| 240 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 241 | #elif CONFIG_KEYPAD == IAUDIO_M3_PAD |
| 242 | |
| 243 | #define ROCKBLOX_OFF BUTTON_RC_REC |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 244 | #define ROCKBLOX_ROTATE_CCW BUTTON_RC_VOL_DOWN |
| 245 | #define ROCKBLOX_ROTATE_CW BUTTON_RC_VOL_UP |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 246 | #define ROCKBLOX_DOWN BUTTON_RC_MENU |
| 247 | #define ROCKBLOX_LEFT BUTTON_RC_REW |
| 248 | #define ROCKBLOX_RIGHT BUTTON_RC_FF |
| 249 | #define ROCKBLOX_DROP BUTTON_RC_PLAY |
| 250 | #define ROCKBLOX_RESTART BUTTON_RC_MODE |
| 251 | |
Tomer Shalev | 47ddbaa | 2009-12-15 20:51:41 +0000 | [diff] [blame] | 252 | #elif CONFIG_KEYPAD == COWON_D2_PAD |
Tomer Shalev | 83d589d | 2010-02-24 21:16:48 +0000 | [diff] [blame] | 253 | |
Rob Purchase | 554d7ed | 2008-03-22 22:03:34 +0000 | [diff] [blame] | 254 | #define ROCKBLOX_OFF BUTTON_POWER |
Rob Purchase | 554d7ed | 2008-03-22 22:03:34 +0000 | [diff] [blame] | 255 | #define ROCKBLOX_RESTART BUTTON_MENU |
| 256 | |
Vitja Makarov | 2f84f69 | 2008-10-07 16:38:28 +0000 | [diff] [blame] | 257 | #elif CONFIG_KEYPAD == IAUDIO67_PAD |
| 258 | |
| 259 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 260 | #define ROCKBLOX_ROTATE_CCW BUTTON_VOLDOWN |
| 261 | #define ROCKBLOX_ROTATE_CW BUTTON_VOLUP |
Vitja Makarov | 2f84f69 | 2008-10-07 16:38:28 +0000 | [diff] [blame] | 262 | #define ROCKBLOX_DOWN BUTTON_STOP |
| 263 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 264 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 265 | #define ROCKBLOX_DROP BUTTON_PLAY |
| 266 | #define ROCKBLOX_RESTART BUTTON_MENU |
| 267 | |
Björn Stenberg | cea285d | 2008-12-04 21:28:56 +0000 | [diff] [blame] | 268 | #elif CONFIG_KEYPAD == CREATIVEZVM_PAD |
| 269 | #define ROCKBLOX_OFF BUTTON_BACK |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 270 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 271 | #define ROCKBLOX_ROTATE_CW BUTTON_PLAY |
Björn Stenberg | cea285d | 2008-12-04 21:28:56 +0000 | [diff] [blame] | 272 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 273 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 274 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
Maurus Cuelenaere | 6471b3c | 2008-12-08 09:51:42 +0000 | [diff] [blame] | 275 | #define ROCKBLOX_DROP BUTTON_SELECT |
Björn Stenberg | cea285d | 2008-12-04 21:28:56 +0000 | [diff] [blame] | 276 | #define ROCKBLOX_RESTART BUTTON_CUSTOM |
| 277 | |
Mark Arigo | 2490262 | 2009-01-24 22:41:55 +0000 | [diff] [blame] | 278 | #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD |
| 279 | |
| 280 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 281 | #define ROCKBLOX_ROTATE_CCW BUTTON_VOL_DOWN |
| 282 | #define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP |
Mark Arigo | 2490262 | 2009-01-24 22:41:55 +0000 | [diff] [blame] | 283 | #define ROCKBLOX_ROTATE BUTTON_UP |
| 284 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 285 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 286 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 287 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 288 | #define ROCKBLOX_RESTART BUTTON_MENU |
| 289 | |
Robert Menes | 82d322c | 2010-11-02 14:36:08 +0000 | [diff] [blame] | 290 | #elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD |
| 291 | |
| 292 | #define ROCKBLOX_OFF BUTTON_POWER |
| 293 | #define ROCKBLOX_ROTATE_CCW BUTTON_PREV |
| 294 | #define ROCKBLOX_ROTATE_CW BUTTON_NEXT |
| 295 | #define ROCKBLOX_ROTATE BUTTON_UP |
| 296 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 297 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 298 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 299 | #define ROCKBLOX_DROP BUTTON_PLAY |
| 300 | #define ROCKBLOX_RESTART BUTTON_MENU |
| 301 | |
Robert Menes | 9dc1c1a | 2009-12-09 18:20:49 +0000 | [diff] [blame] | 302 | # elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD |
| 303 | |
| 304 | #define ROCKBLOX_OFF BUTTON_POWER |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 305 | #define ROCKBLOX_ROTATE_CCW BUTTON_VOL_DOWN |
| 306 | #define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP |
Robert Menes | 9dc1c1a | 2009-12-09 18:20:49 +0000 | [diff] [blame] | 307 | #define ROCKBLOX_ROTATE BUTTON_UP |
| 308 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 309 | #define ROCKBLOX_LEFT BUTTON_PREV |
| 310 | #define ROCKBLOX_RIGHT BUTTON_NEXT |
| 311 | #define ROCKBLOX_DROP BUTTON_PLAY |
| 312 | #define ROCKBLOX_RESTART BUTTON_MENU |
| 313 | |
Maurus Cuelenaere | fef405c | 2009-04-07 23:41:44 +0000 | [diff] [blame] | 314 | #elif CONFIG_KEYPAD == ONDAVX747_PAD |
| 315 | #define ROCKBLOX_OFF BUTTON_POWER |
| 316 | #define ROCKBLOX_RESTART BUTTON_MENU |
Maurus Cuelenaere | 9680244 | 2009-08-31 21:11:32 +0000 | [diff] [blame] | 317 | #elif CONFIG_KEYPAD == ONDAVX777_PAD |
| 318 | #define ROCKBLOX_OFF BUTTON_POWER |
Maurus Cuelenaere | fef405c | 2009-04-07 23:41:44 +0000 | [diff] [blame] | 319 | |
Michael Giacomelli | 594b6e2 | 2009-08-04 03:08:32 +0000 | [diff] [blame] | 320 | #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD |
| 321 | |
| 322 | #define ROCKBLOX_OFF (BUTTON_REC|BUTTON_PLAY) |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 323 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 324 | #define ROCKBLOX_ROTATE_CW BUTTON_DOWN |
Michael Giacomelli | 594b6e2 | 2009-08-04 03:08:32 +0000 | [diff] [blame] | 325 | #define ROCKBLOX_DOWN BUTTON_REW |
| 326 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 327 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 328 | #define ROCKBLOX_DROP BUTTON_FFWD |
| 329 | #define ROCKBLOX_RESTART (BUTTON_REC|BUTTON_REW) |
| 330 | |
Szymon Dziok | 05577e4 | 2010-02-11 22:40:17 +0000 | [diff] [blame] | 331 | #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD |
| 332 | |
| 333 | #define ROCKBLOX_OFF BUTTON_REC |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 334 | #define ROCKBLOX_ROTATE_CCW BUTTON_PLAY |
| 335 | #define ROCKBLOX_ROTATE_CW BUTTON_MENU |
Szymon Dziok | 05577e4 | 2010-02-11 22:40:17 +0000 | [diff] [blame] | 336 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 337 | #define ROCKBLOX_LEFT BUTTON_PREV |
| 338 | #define ROCKBLOX_RIGHT BUTTON_NEXT |
| 339 | #define ROCKBLOX_DROP BUTTON_OK |
| 340 | #define ROCKBLOX_RESTART BUTTON_CANCEL |
| 341 | |
Marcin Bukat | b09d3ae | 2010-04-26 21:40:00 +0000 | [diff] [blame] | 342 | #elif CONFIG_KEYPAD == MPIO_HD200_PAD |
| 343 | #define ROCKBLOX_OFF (BUTTON_REC|BUTTON_PLAY) |
Marcin Bukat | 59ba8fe | 2010-11-02 10:44:34 +0000 | [diff] [blame] | 344 | #define ROCKBLOX_ROTATE_CCW BUTTON_REW |
| 345 | #define ROCKBLOX_ROTATE_CW BUTTON_FF |
| 346 | #define ROCKBLOX_DOWN BUTTON_FUNC |
Marcin Bukat | b09d3ae | 2010-04-26 21:40:00 +0000 | [diff] [blame] | 347 | #define ROCKBLOX_LEFT BUTTON_VOL_DOWN |
| 348 | #define ROCKBLOX_RIGHT BUTTON_VOL_UP |
| 349 | #define ROCKBLOX_DROP BUTTON_PLAY |
| 350 | #define ROCKBLOX_RESTART BUTTON_REC |
| 351 | |
Marcin Bukat | dd61702 | 2010-11-30 10:52:14 +0000 | [diff] [blame] | 352 | #elif CONFIG_KEYPAD == MPIO_HD300_PAD |
Marcin Bukat | 5863361 | 2012-02-02 14:42:42 +0100 | [diff] [blame] | 353 | #define ROCKBLOX_OFF (BUTTON_MENU|BUTTON_REPEAT) |
| 354 | #define ROCKBLOX_ROTATE_CCW BUTTON_UP |
| 355 | #define ROCKBLOX_ROTATE_CW BUTTON_DOWN |
| 356 | #define ROCKBLOX_DOWN (BUTTON_ENTER | BUTTON_REL) |
| 357 | #define ROCKBLOX_LEFT BUTTON_REW |
| 358 | #define ROCKBLOX_RIGHT BUTTON_FF |
Marcin Bukat | dd61702 | 2010-11-30 10:52:14 +0000 | [diff] [blame] | 359 | #define ROCKBLOX_DROP BUTTON_PLAY |
| 360 | #define ROCKBLOX_RESTART BUTTON_REC |
| 361 | |
Amaury Pouly | 24930a3 | 2011-10-02 15:39:46 +0000 | [diff] [blame] | 362 | #elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD |
Jean-Louis Biasini | 5bfbc64 | 2012-03-01 23:23:29 +0100 | [diff] [blame] | 363 | #define ROCKBLOX_OFF_PRE BUTTON_POWER |
| 364 | #define ROCKBLOX_OFF BUTTON_POWER|BUTTON_REL |
| 365 | #define ROCKBLOX_ROTATE_CW BUTTON_BOTTOMRIGHT |
| 366 | #define ROCKBLOX_ROTATE_CCW BUTTON_BOTTOMLEFT |
| 367 | #define ROCKBLOX_DOWN BUTTON_SELECT |
Amaury Pouly | 24930a3 | 2011-10-02 15:39:46 +0000 | [diff] [blame] | 368 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 369 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
Jean-Louis Biasini | 5bfbc64 | 2012-03-01 23:23:29 +0100 | [diff] [blame] | 370 | #define ROCKBLOX_DROP_PRE BUTTON_DOWN |
| 371 | #define ROCKBLOX_DROP BUTTON_DOWN|BUTTON_REL |
| 372 | #define ROCKBLOX_RESTART BUTTON_BACK|BUTTON_REPEAT |
| 373 | #define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_UP |
| 374 | #define ROCKBLOX_ROTATE_CW2 BUTTON_VOL_DOWN |
Amaury Pouly | 24930a3 | 2011-10-02 15:39:46 +0000 | [diff] [blame] | 375 | |
Tomasz Moń | e8a8a1b | 2011-11-16 14:08:01 +0000 | [diff] [blame] | 376 | #elif CONFIG_KEYPAD == SANSA_CONNECT_PAD |
| 377 | #define ROCKBLOX_OFF BUTTON_POWER |
| 378 | #define ROCKBLOX_ROTATE_CW BUTTON_NEXT |
| 379 | #define ROCKBLOX_ROTATE_CCW BUTTON_PREV |
| 380 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 381 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 382 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 383 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 384 | #define ROCKBLOX_RESTART BUTTON_VOL_DOWN |
| 385 | |
Thomas Martitz | 249bba0 | 2011-12-24 11:56:46 +0000 | [diff] [blame] | 386 | #elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD |
| 387 | |
| 388 | #define ROCKBLOX_OFF BUTTON_BACK |
| 389 | #define ROCKBLOX_ROTATE_CCW BUTTON_POWER |
| 390 | #define ROCKBLOX_ROTATE_CW BUTTON_MENU |
| 391 | #define ROCKBLOX_ROTATE BUTTON_UP |
| 392 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 393 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 394 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 395 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 396 | #define ROCKBLOX_RESTART BUTTON_USER |
| 397 | |
Andrew Ryabinin | 397863a | 2012-03-23 22:32:50 +0400 | [diff] [blame] | 398 | #elif CONFIG_KEYPAD == HM60X_PAD |
| 399 | |
| 400 | #define ROCKBLOX_OFF BUTTON_POWER |
| 401 | #define ROCKBLOX_ROTATE_CCW (BUTTON_LEFT|BUTTON_POWER) |
| 402 | #define ROCKBLOX_ROTATE_CW (BUTTON_RIGHT|BUTTON_POWER) |
| 403 | #define ROCKBLOX_ROTATE BUTTON_UP |
| 404 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 405 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 406 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 407 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 408 | #define ROCKBLOX_RESTART (BUTTON_DOWN|BUTTON_POWER) |
| 409 | |
Andrew Ryabinin | 6ee3fc8 | 2012-04-06 20:17:27 +0400 | [diff] [blame] | 410 | #elif CONFIG_KEYPAD == HM801_PAD |
| 411 | |
| 412 | #define ROCKBLOX_OFF BUTTON_POWER |
| 413 | #define ROCKBLOX_ROTATE_CCW BUTTON_PREV |
| 414 | #define ROCKBLOX_ROTATE_CW BUTTON_NEXT |
| 415 | #define ROCKBLOX_ROTATE BUTTON_UP |
| 416 | #define ROCKBLOX_DOWN BUTTON_DOWN |
| 417 | #define ROCKBLOX_LEFT BUTTON_LEFT |
| 418 | #define ROCKBLOX_RIGHT BUTTON_RIGHT |
| 419 | #define ROCKBLOX_DROP BUTTON_SELECT |
| 420 | #define ROCKBLOX_RESTART BUTTON_PLAY |
| 421 | |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 422 | #else |
| 423 | #error No keymap defined! |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 424 | #endif |
| 425 | |
Maurus Cuelenaere | 1392dc2 | 2008-08-23 09:46:38 +0000 | [diff] [blame] | 426 | #ifdef HAVE_TOUCHSCREEN |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 427 | #ifndef ROCKBLOX_OFF |
| 428 | #define ROCKBLOX_OFF BUTTON_TOPLEFT |
| 429 | #endif |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 430 | #ifdef ROCKBLOX_ROTATE_CCW |
Tomer Shalev | 3218431 | 2010-02-24 20:59:35 +0000 | [diff] [blame] | 431 | #define ROCKBLOX_ROTATE_CCW2 BUTTON_BOTTOMLEFT |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 432 | #else |
Tomer Shalev | 3218431 | 2010-02-24 20:59:35 +0000 | [diff] [blame] | 433 | #define ROCKBLOX_ROTATE_CCW BUTTON_BOTTOMLEFT |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 434 | #endif |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 435 | #ifdef ROCKBLOX_ROTATE_CW |
Tomer Shalev | 3218431 | 2010-02-24 20:59:35 +0000 | [diff] [blame] | 436 | #define ROCKBLOX_ROTATE_CW2 BUTTON_BOTTOMRIGHT |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 437 | #else |
Tomer Shalev | 3218431 | 2010-02-24 20:59:35 +0000 | [diff] [blame] | 438 | #define ROCKBLOX_ROTATE_CW BUTTON_BOTTOMRIGHT |
Tomer Shalev | 83d589d | 2010-02-24 21:16:48 +0000 | [diff] [blame] | 439 | #define ROCKBLOX_ROTATE_CW2 BUTTON_TOPMIDDLE |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 440 | #endif |
| 441 | #ifndef ROCKBLOX_DOWN |
| 442 | #define ROCKBLOX_DOWN BUTTON_BOTTOMMIDDLE |
| 443 | #endif |
| 444 | #ifndef ROCKBLOX_LEFT |
| 445 | #define ROCKBLOX_LEFT BUTTON_MIDLEFT |
| 446 | #endif |
| 447 | #ifndef ROCKBLOX_RIGHT |
| 448 | #define ROCKBLOX_RIGHT BUTTON_MIDRIGHT |
| 449 | #endif |
| 450 | #ifndef ROCKBLOX_DROP |
| 451 | #define ROCKBLOX_DROP BUTTON_CENTER |
| 452 | #endif |
| 453 | #ifndef ROCKBLOX_RESTART |
| 454 | #define ROCKBLOX_RESTART BUTTON_TOPRIGHT |
| 455 | #endif |
| 456 | #endif |
| 457 | |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 458 | #define BLOCKS_NUM 7 |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 459 | #define EMPTY_BLOCK 7 |
| 460 | |
| 461 | #define BOARD_WIDTH 10 |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 462 | |
| 463 | #ifdef HAVE_LCD_BITMAP |
| 464 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 465 | #define BOARD_HEIGHT 20 |
| 466 | |
Karl Kurbjun | d3c0a7f | 2007-11-10 22:12:54 +0000 | [diff] [blame] | 467 | #if (LCD_WIDTH == 640) && (LCD_HEIGHT == 480) |
| 468 | |
Karl Kurbjun | 70deae0 | 2009-07-21 03:52:59 +0000 | [diff] [blame] | 469 | #define BLOCK_WIDTH 24 |
| 470 | #define BLOCK_HEIGHT 24 |
| 471 | #define BOARD_X 172 |
| 472 | #define BOARD_Y 0 |
| 473 | #define PREVIEW_X 24 |
| 474 | #define PREVIEW_Y 22 |
| 475 | #define LABEL_X 482 |
| 476 | #define SCORE_Y 50 |
| 477 | #define LEVEL_Y 140 |
| 478 | #define LINES_Y 210 |
Karl Kurbjun | d3c0a7f | 2007-11-10 22:12:54 +0000 | [diff] [blame] | 479 | |
| 480 | #elif (LCD_WIDTH == 480) && (LCD_HEIGHT == 640) |
Jonathan Gordon | 56ddddc | 2007-10-23 15:40:51 +0000 | [diff] [blame] | 481 | |
| 482 | #define BLOCK_WIDTH 30 |
| 483 | #define BLOCK_HEIGHT 30 |
| 484 | #define BOARD_X 14 |
| 485 | #define BOARD_Y 2 |
| 486 | #define PREVIEW_X 342 |
| 487 | #define PREVIEW_Y 482 |
| 488 | #define LABEL_X 344 |
| 489 | #define SCORE_Y 58 |
| 490 | #define LEVEL_Y 142 |
| 491 | #define LINES_Y 218 |
Jonathan Gordon | 56ddddc | 2007-10-23 15:40:51 +0000 | [diff] [blame] | 492 | |
| 493 | #elif (LCD_WIDTH == 320) && (LCD_HEIGHT == 240) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 494 | |
| 495 | #define BLOCK_WIDTH 12 |
| 496 | #define BLOCK_HEIGHT 12 |
| 497 | #define BOARD_X 86 |
| 498 | #define BOARD_Y 0 |
| 499 | #define PREVIEW_X 12 |
| 500 | #define PREVIEW_Y 11 |
| 501 | #define LABEL_X 242 |
| 502 | #define SCORE_Y 25 |
| 503 | #define LEVEL_Y 70 |
| 504 | #define LINES_Y 105 |
| 505 | |
Maurus Cuelenaere | fef405c | 2009-04-07 23:41:44 +0000 | [diff] [blame] | 506 | #elif (LCD_WIDTH == 240) && ((LCD_HEIGHT == 320) || (LCD_HEIGHT == 400)) |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 507 | |
Steve Gotthardt | 1f38e21 | 2007-01-06 03:03:52 +0000 | [diff] [blame] | 508 | #define BLOCK_WIDTH 15 |
| 509 | #define BLOCK_HEIGHT 15 |
| 510 | #define BOARD_X 7 |
| 511 | #define BOARD_Y 1 |
| 512 | #define PREVIEW_X 171 |
| 513 | #define PREVIEW_Y 241 |
| 514 | #define LABEL_X 172 |
| 515 | #define SCORE_Y 29 |
| 516 | #define LEVEL_Y 71 |
| 517 | #define LINES_Y 109 |
| 518 | #define HIGH_LABEL_X 172 |
| 519 | #define HIGH_SCORE_Y 163 |
| 520 | #define HIGH_LEVEL_Y 172 |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 521 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 522 | #elif (LCD_WIDTH == 220) && (LCD_HEIGHT == 176) |
| 523 | |
| 524 | #define BLOCK_WIDTH 8 |
| 525 | #define BLOCK_HEIGHT 8 |
| 526 | #define BOARD_X 27 |
| 527 | #define BOARD_Y 5 |
| 528 | #define PREVIEW_X 158 |
| 529 | #define PREVIEW_Y 130 |
| 530 | #define LABEL_X 147 |
| 531 | #define SCORE_Y 20 |
| 532 | #define LEVEL_Y 65 |
| 533 | #define LINES_Y 100 |
| 534 | |
| 535 | #elif (LCD_WIDTH == 176) && (LCD_HEIGHT == 132) |
| 536 | |
| 537 | #define BLOCK_WIDTH 6 |
| 538 | #define BLOCK_HEIGHT 6 |
| 539 | #define BOARD_X 25 |
| 540 | #define BOARD_Y 1 |
| 541 | #define PREVIEW_X 126 |
| 542 | #define PREVIEW_Y 102 |
| 543 | #define LABEL_X 112 |
| 544 | #define SCORE_Y 17 |
| 545 | #define LEVEL_Y 49 |
| 546 | #define LINES_Y 81 |
| 547 | |
Marianne Arnold | 59c9dcc | 2007-01-06 12:38:41 +0000 | [diff] [blame] | 548 | #elif (LCD_WIDTH == 176) && (LCD_HEIGHT == 220) |
| 549 | |
Thomas Martitz | 1123115 | 2009-05-13 17:45:07 +0000 | [diff] [blame] | 550 | /* no room for the space in the highscore list */ |
| 551 | #define _SPACE "" |
| 552 | |
Marianne Arnold | 59c9dcc | 2007-01-06 12:38:41 +0000 | [diff] [blame] | 553 | #define BLOCK_WIDTH 10 |
| 554 | #define BLOCK_HEIGHT 10 |
| 555 | #define BOARD_X 6 |
| 556 | #define BOARD_Y 10 |
| 557 | #define PREVIEW_X 124 |
Thomas Martitz | 1123115 | 2009-05-13 17:45:07 +0000 | [diff] [blame] | 558 | #define PREVIEW_Y 174 |
Marianne Arnold | 59c9dcc | 2007-01-06 12:38:41 +0000 | [diff] [blame] | 559 | #define LABEL_X 117 |
Thomas Martitz | 1123115 | 2009-05-13 17:45:07 +0000 | [diff] [blame] | 560 | #define SCORE_Y 18 |
| 561 | #define LEVEL_Y 52 |
| 562 | #define LINES_Y 85 |
| 563 | #define HIGH_SCORE_Y 119 |
| 564 | #define HIGH_LEVEL_Y 126 |
| 565 | #define HIGH_LABEL_X 114 |
| 566 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 567 | #elif (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) |
| 568 | |
Thomas Martitz | 1123115 | 2009-05-13 17:45:07 +0000 | [diff] [blame] | 569 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 570 | #define BLOCK_WIDTH 6 |
| 571 | #define BLOCK_HEIGHT 6 |
| 572 | #define BOARD_X 22 |
| 573 | #define BOARD_Y 3 |
| 574 | #define PREVIEW_X 114 |
| 575 | #define PREVIEW_Y 100 |
| 576 | #define LABEL_X 101 |
| 577 | #define SCORE_Y 17 |
| 578 | #define LEVEL_Y 49 |
| 579 | #define LINES_Y 82 |
| 580 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 581 | #elif (LCD_WIDTH == 138) && (LCD_HEIGHT == 110) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 582 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 583 | #define BLOCK_WIDTH 5 |
| 584 | #define BLOCK_HEIGHT 5 |
| 585 | #define BOARD_X 14 |
| 586 | #define BOARD_Y 0 |
| 587 | #define PREVIEW_X 98 |
| 588 | #define PREVIEW_Y 88 |
| 589 | #define LABEL_X 80 |
| 590 | #define SCORE_Y 15 |
| 591 | #define LEVEL_Y 45 |
| 592 | #define LINES_Y 74 |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 593 | |
Marianne Arnold | 12ddb8e | 2007-09-20 10:49:48 +0000 | [diff] [blame] | 594 | #elif (LCD_WIDTH == 132) && (LCD_HEIGHT == 80) |
| 595 | |
| 596 | #define BLOCK_WIDTH 4 |
| 597 | #define BLOCK_HEIGHT 4 |
| 598 | #define BOARD_X 10 |
| 599 | #define BOARD_Y 0 |
| 600 | #define PREVIEW_X 89 |
| 601 | #define PREVIEW_Y 61 |
| 602 | #define LABEL_X 78 |
| 603 | #define SCORE_Y 10 |
| 604 | #define LEVEL_Y 30 |
| 605 | #define LINES_Y 50 |
| 606 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 607 | #elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 128) |
| 608 | |
| 609 | #define BLOCK_WIDTH 6 |
| 610 | #define BLOCK_HEIGHT 6 |
| 611 | #define BOARD_X 4 |
| 612 | #define BOARD_Y 3 |
| 613 | #define PREVIEW_X 84 |
| 614 | #define PREVIEW_Y 100 |
| 615 | #define LABEL_X 71 |
| 616 | #define SCORE_Y 17 |
| 617 | #define LEVEL_Y 49 |
| 618 | #define LINES_Y 82 |
| 619 | |
Robert Menes | 9dc1c1a | 2009-12-09 18:20:49 +0000 | [diff] [blame] | 620 | #elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 160) |
| 621 | |
Michael Sevakis | 9f4fdbd | 2011-01-10 07:32:29 +0000 | [diff] [blame] | 622 | #define BLOCK_WIDTH 7 |
| 623 | #define BLOCK_HEIGHT 7 |
Robert Menes | 9dc1c1a | 2009-12-09 18:20:49 +0000 | [diff] [blame] | 624 | #define BOARD_X 4 |
Michael Sevakis | 9f4fdbd | 2011-01-10 07:32:29 +0000 | [diff] [blame] | 625 | #define BOARD_Y 5 |
| 626 | #define PREVIEW_X 88 |
| 627 | #define PREVIEW_Y 111 |
| 628 | #define LABEL_X 82 |
| 629 | #define SCORE_Y (2+16) |
| 630 | #define LEVEL_Y (36+16) |
| 631 | #define LINES_Y (70+16) |
Robert Menes | 9dc1c1a | 2009-12-09 18:20:49 +0000 | [diff] [blame] | 632 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 633 | #elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 96) |
| 634 | |
| 635 | #define BLOCK_WIDTH 4 |
| 636 | #define BLOCK_HEIGHT 4 |
| 637 | #define BOARD_X 14 |
| 638 | #define BOARD_Y 2 |
| 639 | #define PREVIEW_X 89 |
| 640 | #define PREVIEW_Y 76 |
| 641 | #define LABEL_X 70 |
| 642 | #define SCORE_Y 14 |
| 643 | #define LEVEL_Y 39 |
| 644 | #define LINES_Y 64 |
| 645 | |
Marianne Arnold | 59c9dcc | 2007-01-06 12:38:41 +0000 | [diff] [blame] | 646 | #elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 64) |
| 647 | |
| 648 | #define BLOCK_WIDTH 3 |
| 649 | #define BLOCK_HEIGHT 3 |
| 650 | #define BOARD_X 9 |
| 651 | #define BOARD_Y 3 |
| 652 | #define PREVIEW_X 53 |
| 653 | #define PREVIEW_Y 5 |
| 654 | #define LABEL_X 70 |
| 655 | #define SCORE_Y 32 |
| 656 | #define LEVEL_Y 13 |
| 657 | #define LINES_Y 51 |
| 658 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 659 | #elif (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) |
| 660 | |
| 661 | #define BLOCK_WIDTH 4 |
| 662 | #define BLOCK_HEIGHT 3 |
| 663 | #define BOARD_X 9 |
| 664 | #define BOARD_Y 3 |
| 665 | #define PREVIEW_X 59 |
| 666 | #define PREVIEW_Y 5 |
| 667 | #define LABEL_X 59 |
| 668 | #define SCORE_Y 32 |
| 669 | #define LEVEL_Y 13 |
| 670 | #define LEVEL_X 78 |
| 671 | #define LINES_Y 51 |
| 672 | |
Rafaël Carré | bd691ef | 2011-12-02 20:28:20 +0000 | [diff] [blame] | 673 | #elif LCD_WIDTH == 96 && LCD_HEIGHT == 96 |
| 674 | |
| 675 | #define BLOCK_WIDTH 3 |
| 676 | #define BLOCK_HEIGHT 3 |
| 677 | #define BOARD_X 9 |
| 678 | #define BOARD_Y 3 |
| 679 | #define PREVIEW_X 59 |
| 680 | #define PREVIEW_Y 5 |
| 681 | #define LABEL_X 59 |
| 682 | #define SCORE_Y 32 |
| 683 | #define LEVEL_Y 13 |
| 684 | #define LEVEL_X 78 |
| 685 | #define LINES_Y 51 |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 686 | #endif |
| 687 | |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 688 | #ifndef LEVEL_X |
| 689 | #define LEVEL_X LABEL_X |
| 690 | #endif |
| 691 | |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 692 | #ifndef LINES_X |
| 693 | #define LINES_X LABEL_X |
| 694 | #endif |
| 695 | |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 696 | extern const fb_data rockblox_background[]; |
| 697 | |
| 698 | #else /* HAVE_LCD_CHARCELLS */ |
| 699 | |
| 700 | #define BOARD_HEIGHT 14 |
| 701 | |
| 702 | #define BLOCK_WIDTH 1 |
| 703 | #define BLOCK_HEIGHT 1 |
| 704 | #define BOARD_X 5 |
| 705 | #define BOARD_Y 0 |
| 706 | #define PREVIEW_X 15 |
| 707 | #define PREVIEW_Y 1 |
| 708 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 709 | #endif |
| 710 | |
Thomas Martitz | 1123115 | 2009-05-13 17:45:07 +0000 | [diff] [blame] | 711 | #ifndef _SPACE |
| 712 | #define _SPACE " " |
| 713 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 714 | /* <<Explanation on Rockblox shapes>> |
| 715 | |
| 716 | %% |
| 717 | %% - O has 1 orientation |
| 718 | |
| 719 | %% % |
| 720 | %% %% - Z has 2 orientations |
| 721 | % |
| 722 | |
| 723 | %% % |
| 724 | %% %% - S has 2 orientations |
| 725 | % |
| 726 | % |
| 727 | % |
| 728 | % %%%% - I has 2 orientations |
| 729 | % |
| 730 | |
| 731 | % %% |
| 732 | % % % %%% - L has 4 orientations |
| 733 | %% %%% % % |
| 734 | |
Michael Giacomelli | 6d5823f | 2009-01-04 23:33:15 +0000 | [diff] [blame] | 735 | % %% |
| 736 | % % % %%% - J has 4 orientations |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 737 | %% %%% % % |
| 738 | |
| 739 | % % %%% |
| 740 | %% % %% % - T has 4 orientations |
| 741 | % %%% % |
| 742 | */ |
| 743 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 744 | /* c=current f=figure o=orientation n=next */ |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 745 | static struct _rockblox_status |
| 746 | { |
| 747 | int gameover; |
| 748 | int lines; |
| 749 | int level; |
| 750 | int score; |
| 751 | int cx; |
| 752 | int cy; |
| 753 | int cf; |
| 754 | int co; |
| 755 | int nf; |
| 756 | short board[BOARD_HEIGHT][BOARD_WIDTH]; /* 20 rows of 10 blocks */ |
| 757 | } rockblox_status; |
| 758 | |
| 759 | /* prototypes */ |
| 760 | static void draw_next_block(void); |
| 761 | static void new_block(void); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 762 | |
Thomas Martitz | 19f3d60 | 2009-02-26 20:52:16 +0000 | [diff] [blame] | 763 | #ifdef HAVE_SCROLLWHEEL |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 764 | int wheel_events = 0, last_wheel_event = 0; |
| 765 | bool wheel_enabled = false; |
| 766 | #endif |
| 767 | |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 768 | static const short scoring[4] = { /* scoring for each number of lines */ |
| 769 | #if BOARD_HEIGHT == 20 |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 770 | 40 /* single */ , 100 /* double */ , 300 /* triple */ , 1200 /* rockblox */ |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 771 | #elif BOARD_HEIGHT == 14 /* Player special values */ |
| 772 | 60 /* single */ , 150 /* double */ , 500 /* triple */ , 2000 /* rockblox */ |
| 773 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 774 | }; |
| 775 | |
| 776 | struct figure |
| 777 | { |
| 778 | #if LCD_DEPTH >= 2 |
| 779 | unsigned short color[3]; /* color of figure (light,middle,shadow) */ |
| 780 | #endif |
| 781 | unsigned short max_or; /* max orientations */ |
| 782 | signed short shapeX[4], shapeY[4]; /* implementation of figures */ |
| 783 | } |
| 784 | |
| 785 | /* array of figures */ |
| 786 | figures[BLOCKS_NUM] = { |
| 787 | /* O */ |
| 788 | { |
| 789 | #if LCD_DEPTH >= 16 |
| 790 | {LCD_RGBPACK (153, 255, 255), LCD_RGBPACK(0, 255, 255), |
| 791 | LCD_RGBPACK(0,153,153)}, |
| 792 | #elif LCD_DEPTH == 2 |
| 793 | {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY}, |
| 794 | #endif |
| 795 | 1, |
| 796 | {-1, 0, -1, 0}, |
| 797 | {0, 0, 1, 1} |
| 798 | }, |
| 799 | /* I */ |
| 800 | { |
| 801 | #if LCD_DEPTH >= 16 |
| 802 | {LCD_RGBPACK (255, 153, 128), LCD_RGBPACK (255, 0, 0), |
| 803 | LCD_RGBPACK (153, 0, 0)}, |
| 804 | #elif LCD_DEPTH == 2 |
| 805 | {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY}, |
| 806 | #endif |
| 807 | 2, |
| 808 | {-2, -1, 0, 1}, |
| 809 | {0, 0, 0, 0} |
| 810 | }, |
| 811 | /* 'Z' */ |
| 812 | { |
| 813 | #if LCD_DEPTH >= 16 |
| 814 | {LCD_RGBPACK (153, 255, 153), LCD_RGBPACK (0, 255, 0), |
| 815 | LCD_RGBPACK (0, 153, 0)}, |
| 816 | #elif LCD_DEPTH == 2 |
| 817 | {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY}, |
| 818 | #endif |
| 819 | 2, |
| 820 | {0, 1, -1, 0}, |
| 821 | {0, 0, 1, 1} |
| 822 | }, |
| 823 | /* 'S' */ |
| 824 | { |
| 825 | #if LCD_DEPTH >= 16 |
| 826 | {LCD_RGBPACK (153, 153, 255), LCD_RGBPACK (0, 0, 255), |
| 827 | LCD_RGBPACK (0, 0, 153)}, |
| 828 | #elif LCD_DEPTH == 2 |
| 829 | {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY}, |
| 830 | #endif |
| 831 | 2, |
| 832 | {-1, 0, 0, 1}, |
| 833 | {0, 0, 1, 1} |
| 834 | }, |
| 835 | /* 'L' */ |
| 836 | { |
| 837 | #if LCD_DEPTH >= 16 |
| 838 | {LCD_RGBPACK (255, 255, 153), LCD_RGBPACK (255, 255, 0), |
| 839 | LCD_RGBPACK (153, 153, 0)}, |
| 840 | #elif LCD_DEPTH == 2 |
| 841 | {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY}, |
| 842 | #endif |
| 843 | 4, |
| 844 | {-1, 0, 1, 1}, |
| 845 | {0, 0, 0, 1} |
| 846 | }, |
| 847 | /* 'J' */ |
| 848 | { |
| 849 | #if LCD_DEPTH >= 16 |
| 850 | {LCD_RGBPACK (255, 153, 255), LCD_RGBPACK (255, 0, 255), |
| 851 | LCD_RGBPACK (153, 0, 153)}, |
| 852 | #elif LCD_DEPTH == 2 |
| 853 | {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY}, |
| 854 | #endif |
| 855 | 4, |
| 856 | {-1, 0, 1, -1}, |
| 857 | {0, 0, 0, 1} |
| 858 | }, |
| 859 | /* 'T' */ |
| 860 | { |
| 861 | #if LCD_DEPTH >= 16 |
| 862 | {LCD_RGBPACK (204, 204, 204), LCD_RGBPACK (153, 153, 153), |
| 863 | LCD_RGBPACK (85, 85, 85)}, |
| 864 | #elif LCD_DEPTH == 2 |
| 865 | {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY}, |
| 866 | #endif |
| 867 | 4, |
| 868 | {-1, 0, 1, 0}, |
| 869 | {0, 0, 0, 1} |
| 870 | } |
| 871 | }; |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 872 | bool resume = false; |
| 873 | bool resume_file = false; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 874 | |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 875 | /* Rockbox File System only supports full filenames inc dir */ |
Thomas Jarosch | f9f89cf | 2011-03-02 23:43:54 +0000 | [diff] [blame] | 876 | #define SCORE_FILE PLUGIN_GAMES_DATA_DIR "/rockblox.score" |
| 877 | #define RESUME_FILE PLUGIN_GAMES_DATA_DIR "/rockblox.resume" |
Teruaki Kawashima | 3f8d4a5 | 2010-02-27 14:45:37 +0000 | [diff] [blame] | 878 | #define NUM_SCORES 5 |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 879 | |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 880 | /* Default High Scores... */ |
Teruaki Kawashima | 3f8d4a5 | 2010-02-27 14:45:37 +0000 | [diff] [blame] | 881 | struct highscore highscores[NUM_SCORES]; |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 882 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 883 | /* get random number from (0) to (range-1) */ |
| 884 | static int t_rand (int range) |
| 885 | { |
| 886 | return rb->rand () % range; |
| 887 | } |
| 888 | |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 889 | static inline void show_game_over (void) |
| 890 | { |
| 891 | rb->splash(HZ,"Game over!"); |
| 892 | } |
| 893 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 894 | /* init the board array to have no blocks */ |
| 895 | static void init_board (void) |
| 896 | { |
| 897 | int i, j; |
| 898 | for (i = 0; i < BOARD_WIDTH; i++) |
| 899 | for (j = 0; j < BOARD_HEIGHT; j++) |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 900 | rockblox_status.board[j][i] = EMPTY_BLOCK; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | /* show the score, level and lines */ |
| 904 | static void show_details (void) |
| 905 | { |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 906 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 907 | #if LCD_DEPTH >= 2 |
| 908 | rb->lcd_set_foreground (LCD_BLACK); |
| 909 | rb->lcd_set_background (LCD_WHITE); |
| 910 | #endif |
Rafaël Carré | ab9fd18 | 2010-08-28 21:46:45 +0000 | [diff] [blame] | 911 | rb->lcd_putsxyf (LABEL_X, SCORE_Y, "%d", rockblox_status.score); |
| 912 | rb->lcd_putsxyf (LEVEL_X, LEVEL_Y, "%d", rockblox_status.level); |
| 913 | rb->lcd_putsxyf (LINES_X, LINES_Y, "%d", rockblox_status.lines); |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 914 | #else /* HAVE_LCD_CHARCELLS */ |
Rafaël Carré | ab9fd18 | 2010-08-28 21:46:45 +0000 | [diff] [blame] | 915 | rb->lcd_putsf (5, 0, "L%d/%d", rockblox_status.level, |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 916 | rockblox_status.lines); |
Rafaël Carré | ab9fd18 | 2010-08-28 21:46:45 +0000 | [diff] [blame] | 917 | rb->lcd_putsf (5, 1, "S%d", rockblox_status.score); |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 918 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 919 | } |
| 920 | |
Greg White | f7afb1b | 2007-01-05 18:44:32 +0000 | [diff] [blame] | 921 | #ifdef HIGH_SCORE_Y |
Adam Gashlin | 8e5a39c | 2007-11-16 09:29:34 +0000 | [diff] [blame] | 922 | static void show_highscores (void) |
| 923 | { |
Greg White | f7afb1b | 2007-01-05 18:44:32 +0000 | [diff] [blame] | 924 | int i; |
Adam Gashlin | 8e5a39c | 2007-11-16 09:29:34 +0000 | [diff] [blame] | 925 | |
Teruaki Kawashima | 3f8d4a5 | 2010-02-27 14:45:37 +0000 | [diff] [blame] | 926 | for (i = 0; i<NUM_SCORES; i++) |
Rafaël Carré | ab9fd18 | 2010-08-28 21:46:45 +0000 | [diff] [blame] | 927 | rb->lcd_putsxyf (HIGH_LABEL_X, HIGH_SCORE_Y + (10 * i), |
| 928 | "%06d" _SPACE "L%1d", highscores[i].score, highscores[i].level); |
Adam Gashlin | 8e5a39c | 2007-11-16 09:29:34 +0000 | [diff] [blame] | 929 | } |
Greg White | f7afb1b | 2007-01-05 18:44:32 +0000 | [diff] [blame] | 930 | #endif |
Adam Gashlin | 8e5a39c | 2007-11-16 09:29:34 +0000 | [diff] [blame] | 931 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 932 | static void load_game(void) |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 933 | { |
| 934 | int fd; |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 935 | |
| 936 | resume = false; |
| 937 | |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 938 | fd = rb->open(RESUME_FILE, O_RDONLY); |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 939 | if (fd < 0) return; |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 940 | |
| 941 | if (rb->read(fd, &rockblox_status, sizeof(struct _rockblox_status)) |
| 942 | < (ssize_t)sizeof(struct _rockblox_status)) |
| 943 | { |
| 944 | rb->splash(HZ/2, "Loading Rockblox resume info failed"); |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 945 | } else { |
| 946 | resume = true; |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | rb->close(fd); |
| 950 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 951 | return; |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 952 | } |
| 953 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 954 | static void dump_resume(void) |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 955 | { |
| 956 | int fd; |
| 957 | |
Thomas Martitz | 0a1d7c2 | 2010-05-06 17:35:13 +0000 | [diff] [blame] | 958 | fd = rb->open(RESUME_FILE, O_WRONLY|O_CREAT, 0666); |
Thomas Martitz | 9a2e8c2 | 2009-05-16 20:45:00 +0000 | [diff] [blame] | 959 | if (fd < 0) |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 960 | goto fail; |
| 961 | |
| 962 | if (rb->write(fd, &rockblox_status, sizeof(struct _rockblox_status)) |
| 963 | <= 0) |
| 964 | { |
| 965 | rb->close(fd); |
| 966 | goto fail; |
| 967 | } |
| 968 | rb->close(fd); |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 969 | return; |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 970 | |
| 971 | fail: |
| 972 | rb->splash(HZ/2, "Writing Rockblox resume info failed"); |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 973 | return; |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 974 | } |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 975 | |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 976 | static void init_rockblox (bool resume) |
Adam Gashlin | 8e5a39c | 2007-11-16 09:29:34 +0000 | [diff] [blame] | 977 | { |
Alexander Levin | 6a5245a | 2009-06-30 20:00:46 +0000 | [diff] [blame] | 978 | char score_name[50]; |
| 979 | struct tm* tm; |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 980 | |
Alexander Levin | 6a5245a | 2009-06-30 20:00:46 +0000 | [diff] [blame] | 981 | tm = rb->get_time(); |
| 982 | rb->snprintf(score_name, sizeof(score_name), "%04d%02d%02d %02d%02d%02d", |
| 983 | tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, |
| 984 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 985 | |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 986 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 987 | rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT); |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 988 | #else /* HAVE_LCD_CHARCELLS */ |
| 989 | pgfx_display (0, 0); |
| 990 | pgfx_display_block (3, 0, 3, 1); |
| 991 | pgfx_display_block (4, 0, 3, 0); |
Jens Arnold | 8edca8e | 2010-04-25 06:30:19 +0000 | [diff] [blame] | 992 | rb->lcd_puts(4, 1, " "); |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 993 | pgfx_clear_display(); |
| 994 | pgfx_fillrect (3, 0, 2, 14); |
| 995 | pgfx_fillrect (15, 7, 2, 7); |
| 996 | pgfx_update(); |
| 997 | #endif |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 998 | if (!resume) |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 999 | { |
| 1000 | rockblox_status.level = 1; |
| 1001 | rockblox_status.lines = 0; |
| 1002 | rockblox_status.score = 0; |
| 1003 | rockblox_status.nf = t_rand(BLOCKS_NUM); |
| 1004 | init_board (); |
| 1005 | new_block (); |
| 1006 | } |
| 1007 | draw_next_block(); |
| 1008 | |
Greg White | f7afb1b | 2007-01-05 18:44:32 +0000 | [diff] [blame] | 1009 | show_details (); |
Jens Arnold | 1764583 | 2007-03-26 08:52:36 +0000 | [diff] [blame] | 1010 | #ifdef HIGH_SCORE_Y |
Adam Gashlin | 8e5a39c | 2007-11-16 09:29:34 +0000 | [diff] [blame] | 1011 | show_highscores (); |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 1012 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1013 | } |
| 1014 | |
| 1015 | static inline int level_speed(int level) |
| 1016 | { |
Jens Arnold | dfcbcd1 | 2006-10-08 17:27:33 +0000 | [diff] [blame] | 1017 | #if BOARD_HEIGHT == 20 |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1018 | return (5*HZ) / (level + 9); |
Jens Arnold | dfcbcd1 | 2006-10-08 17:27:33 +0000 | [diff] [blame] | 1019 | #elif BOARD_HEIGHT == 14 |
| 1020 | return (7*HZ) / (level + 9); |
| 1021 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
| 1024 | static int getRelativeX (int figure, int square, int orientation) |
| 1025 | { |
| 1026 | switch (orientation) { |
| 1027 | case 0: |
| 1028 | return figures[figure].shapeX[square]; |
| 1029 | case 1: |
| 1030 | return figures[figure].shapeY[square]; |
| 1031 | case 2: |
| 1032 | return -figures[figure].shapeX[square]; |
| 1033 | case 3: |
| 1034 | return -figures[figure].shapeY[square]; |
| 1035 | default: |
| 1036 | return 0; |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | static int getRelativeY (int figure, int square, int orientation) |
| 1041 | { |
| 1042 | switch (orientation) { |
| 1043 | case 0: |
| 1044 | return figures[figure].shapeY[square]; |
| 1045 | case 1: |
| 1046 | return -figures[figure].shapeX[square]; |
| 1047 | case 2: |
| 1048 | return -figures[figure].shapeY[square]; |
| 1049 | case 3: |
| 1050 | return figures[figure].shapeX[square]; |
| 1051 | default: |
| 1052 | return 0; |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | /* redraw the while board on the screen */ |
| 1057 | static void refresh_board (void) |
| 1058 | { |
| 1059 | int i, j, x, y, block; |
| 1060 | |
| 1061 | #if LCD_DEPTH >= 2 |
| 1062 | rb->lcd_set_foreground (LCD_BLACK); |
| 1063 | #elif LCD_DEPTH == 1 |
Michael Sevakis | e63e84a | 2010-06-04 13:22:50 +0000 | [diff] [blame] | 1064 | mylcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1065 | #endif |
| 1066 | |
Michael Sevakis | e63e84a | 2010-06-04 13:22:50 +0000 | [diff] [blame] | 1067 | mylcd_fillrect (BOARD_X, BOARD_Y, BOARD_WIDTH * BLOCK_WIDTH, |
| 1068 | BOARD_HEIGHT * BLOCK_HEIGHT); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1069 | |
| 1070 | #if LCD_DEPTH == 1 |
Michael Sevakis | e63e84a | 2010-06-04 13:22:50 +0000 | [diff] [blame] | 1071 | mylcd_set_drawmode (DRMODE_SOLID); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1072 | #endif |
| 1073 | |
| 1074 | for (i = 0; i < BOARD_WIDTH; i++) |
| 1075 | for (j = 0; j < BOARD_HEIGHT; j++) { |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1076 | block = rockblox_status.board[j][i]; |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1077 | if (block != EMPTY_BLOCK) { |
| 1078 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1079 | #if LCD_DEPTH >= 2 |
| 1080 | /* middle drawing */ |
| 1081 | rb->lcd_set_foreground (figures[block].color[1]); |
| 1082 | #endif |
| 1083 | rb->lcd_fillrect (BOARD_X + i * BLOCK_WIDTH, |
| 1084 | BOARD_Y + j * BLOCK_HEIGHT, |
| 1085 | BLOCK_WIDTH, BLOCK_HEIGHT); |
| 1086 | #if LCD_DEPTH >= 2 |
| 1087 | /* light drawing */ |
| 1088 | rb->lcd_set_foreground (figures[block].color[0]); |
| 1089 | #endif |
| 1090 | rb->lcd_vline (BOARD_X + i * BLOCK_WIDTH, |
| 1091 | BOARD_Y + j * BLOCK_HEIGHT, |
| 1092 | BOARD_Y + (j + 1) * BLOCK_HEIGHT - 2); |
| 1093 | rb->lcd_hline (BOARD_X + i * BLOCK_WIDTH, |
| 1094 | BOARD_X + (i + 1) * BLOCK_WIDTH - 2, |
| 1095 | BOARD_Y + j * BLOCK_HEIGHT); |
| 1096 | #if LCD_DEPTH >= 2 |
| 1097 | /* shadow drawing */ |
| 1098 | rb->lcd_set_foreground (figures[block].color[2]); |
| 1099 | #endif |
| 1100 | rb->lcd_vline (BOARD_X + (i + 1) * BLOCK_WIDTH - 1, |
| 1101 | BOARD_Y + j * BLOCK_HEIGHT + 1, |
| 1102 | BOARD_Y + (j + 1) * BLOCK_HEIGHT - 1); |
| 1103 | rb->lcd_hline (BOARD_X + i * BLOCK_WIDTH + 1, |
| 1104 | BOARD_X + (i + 1) * BLOCK_WIDTH - 1, |
| 1105 | BOARD_Y + (j + 1) * BLOCK_HEIGHT - 1); |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1106 | #else /* HAVE_LCD_CHARCELLS */ |
| 1107 | pgfx_drawpixel (BOARD_X + i, BOARD_Y + j); |
| 1108 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | for (i = 0; i < 4; i++) { |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1113 | x = getRelativeX (rockblox_status.cf, i, rockblox_status.co) |
| 1114 | + rockblox_status.cx; |
| 1115 | y = getRelativeY (rockblox_status.cf, i, rockblox_status.co) |
| 1116 | + rockblox_status.cy; |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1117 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1118 | #if LCD_DEPTH >= 2 |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1119 | /* middle drawing */ |
| 1120 | rb->lcd_set_foreground (figures[rockblox_status.cf].color[1]); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1121 | #endif |
| 1122 | rb->lcd_fillrect (BOARD_X + x * BLOCK_WIDTH, |
| 1123 | BOARD_Y + y * BLOCK_HEIGHT, |
| 1124 | BLOCK_WIDTH, BLOCK_HEIGHT); |
| 1125 | #if LCD_DEPTH >= 2 |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1126 | /* light drawing */ |
| 1127 | rb->lcd_set_foreground (figures[rockblox_status.cf].color[0]); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1128 | #endif |
| 1129 | rb->lcd_vline (BOARD_X + x * BLOCK_WIDTH, BOARD_Y + y * BLOCK_HEIGHT, |
| 1130 | BOARD_Y + (y + 1) * BLOCK_HEIGHT - 2); |
| 1131 | rb->lcd_hline (BOARD_X + x * BLOCK_WIDTH, |
| 1132 | BOARD_X + (x + 1) * BLOCK_WIDTH - 2, |
| 1133 | BOARD_Y + y * BLOCK_HEIGHT); |
| 1134 | #if LCD_DEPTH >= 2 |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1135 | /* shadow drawing */ |
| 1136 | rb->lcd_set_foreground (figures[rockblox_status.cf].color[2]); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1137 | #endif |
| 1138 | rb->lcd_vline (BOARD_X + (x + 1) * BLOCK_WIDTH - 1, |
| 1139 | BOARD_Y + y * BLOCK_HEIGHT + 1, |
| 1140 | BOARD_Y + (y + 1) * BLOCK_HEIGHT - 1); |
| 1141 | rb->lcd_hline (BOARD_X + x * BLOCK_WIDTH + 1, |
| 1142 | BOARD_X + (x + 1) * BLOCK_WIDTH - 1, |
| 1143 | BOARD_Y + (y + 1) * BLOCK_HEIGHT - 1); |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1144 | #else /* HAVE_LCD_CHARCELLS */ |
| 1145 | pgfx_drawpixel (BOARD_X + x, BOARD_Y + y); |
| 1146 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1147 | } |
Michael Sevakis | e63e84a | 2010-06-04 13:22:50 +0000 | [diff] [blame] | 1148 | mylcd_update (); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
| 1151 | static bool canMoveTo (int x, int y, int newOrientation) |
| 1152 | { |
| 1153 | int i, rx, ry; |
| 1154 | for (i = 0; i < 4; i++) { |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1155 | ry = getRelativeY (rockblox_status.cf, i, newOrientation) + y; |
| 1156 | rx = getRelativeX (rockblox_status.cf, i, newOrientation) + x; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1157 | if ((rx < 0 || rx >= BOARD_WIDTH) || |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1158 | (ry < 0 || ry >= BOARD_HEIGHT) || |
| 1159 | (rockblox_status.board[ry][rx] != EMPTY_BLOCK)) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1160 | return false; |
| 1161 | } |
| 1162 | return true; |
| 1163 | } |
| 1164 | |
| 1165 | /* draws the preview of next block in the preview window */ |
| 1166 | static void draw_next_block (void) |
| 1167 | { |
| 1168 | int i, rx, ry; |
| 1169 | /* clear preview window first */ |
| 1170 | #if LCD_DEPTH >= 2 |
| 1171 | rb->lcd_set_foreground (LCD_BLACK); |
| 1172 | #elif LCD_DEPTH == 1 |
Michael Sevakis | e63e84a | 2010-06-04 13:22:50 +0000 | [diff] [blame] | 1173 | mylcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1174 | #endif |
| 1175 | |
| 1176 | /* 4x4 */ |
Michael Sevakis | e63e84a | 2010-06-04 13:22:50 +0000 | [diff] [blame] | 1177 | mylcd_fillrect (PREVIEW_X, PREVIEW_Y, BLOCK_WIDTH * 4, BLOCK_HEIGHT * 4); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1178 | |
| 1179 | #if LCD_DEPTH == 1 |
Michael Sevakis | e63e84a | 2010-06-04 13:22:50 +0000 | [diff] [blame] | 1180 | mylcd_set_drawmode (DRMODE_SOLID); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1181 | #endif |
| 1182 | |
| 1183 | /* draw the lightgray rectangles */ |
| 1184 | #if LCD_DEPTH >= 16 |
| 1185 | rb->lcd_set_foreground (LCD_RGBPACK (40, 40, 40)); |
| 1186 | #elif LCD_DEPTH == 2 |
| 1187 | rb->lcd_set_foreground (LCD_DARKGRAY); |
| 1188 | #endif |
| 1189 | |
| 1190 | #if LCD_DEPTH >= 2 |
| 1191 | for (rx = 0; rx < 4; rx++) |
| 1192 | for (ry = 0; ry < 4; ry++) |
| 1193 | rb->lcd_drawrect (PREVIEW_X + rx * BLOCK_WIDTH, |
| 1194 | PREVIEW_Y + ry * BLOCK_HEIGHT, BLOCK_WIDTH, |
| 1195 | BLOCK_HEIGHT); |
| 1196 | #endif |
| 1197 | |
| 1198 | /* draw the figure */ |
| 1199 | for (i = 0; i < 4; i++) { |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1200 | rx = getRelativeX (rockblox_status.nf, i, 0) + 2; |
| 1201 | ry = getRelativeY (rockblox_status.nf, i, 0) + 2; |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1202 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1203 | #if LCD_DEPTH >= 2 |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1204 | rb->lcd_set_foreground (figures[rockblox_status.nf].color[1]); /* middle drawing */ |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1205 | #endif |
| 1206 | rb->lcd_fillrect (PREVIEW_X + rx * BLOCK_WIDTH, |
| 1207 | PREVIEW_Y + ry * BLOCK_HEIGHT, |
| 1208 | BLOCK_WIDTH, BLOCK_HEIGHT); |
| 1209 | #if LCD_DEPTH >= 2 |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1210 | rb->lcd_set_foreground (figures[rockblox_status.nf].color[0]); /* light drawing */ |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1211 | #endif |
| 1212 | rb->lcd_vline (PREVIEW_X + rx * BLOCK_WIDTH, |
| 1213 | PREVIEW_Y + ry * BLOCK_HEIGHT, |
| 1214 | PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 2); |
| 1215 | rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH, |
| 1216 | PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 2, |
| 1217 | PREVIEW_Y + ry * BLOCK_HEIGHT); |
| 1218 | #if LCD_DEPTH >= 2 |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1219 | rb->lcd_set_foreground (figures[rockblox_status.nf].color[2]); /* shadow drawing */ |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1220 | #endif |
| 1221 | rb->lcd_vline (PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1, |
| 1222 | PREVIEW_Y + ry * BLOCK_HEIGHT + 1, |
| 1223 | PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1); |
| 1224 | rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH + 1, |
| 1225 | PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1, |
| 1226 | PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1); |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1227 | #else /* HAVE_LCD_CHARCELLS */ |
| 1228 | pgfx_drawpixel (PREVIEW_X + rx, PREVIEW_Y + ry); |
| 1229 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1230 | } |
| 1231 | |
| 1232 | } |
| 1233 | |
| 1234 | /* move the block to a relative location */ |
| 1235 | static void move_block (int x, int y, int o) |
| 1236 | { |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1237 | if (canMoveTo (rockblox_status.cx + x, rockblox_status.cy + y, o)) { |
| 1238 | rockblox_status.cy += y; |
| 1239 | rockblox_status.cx += x; |
| 1240 | rockblox_status.co = o; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1241 | } |
| 1242 | } |
| 1243 | |
| 1244 | /* try to add a new block to play with (return true if gameover) */ |
| 1245 | static void new_block (void) |
| 1246 | { |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1247 | rockblox_status.cy = 1; |
| 1248 | rockblox_status.cx = 5; |
| 1249 | rockblox_status.cf = rockblox_status.nf; |
| 1250 | rockblox_status.co = 0; /* start at the same orientation all time */ |
| 1251 | rockblox_status.nf = t_rand (BLOCKS_NUM); |
| 1252 | rockblox_status.gameover = !canMoveTo (rockblox_status.cx, |
| 1253 | rockblox_status.cy, rockblox_status.co); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1254 | |
| 1255 | draw_next_block (); |
| 1256 | } |
| 1257 | |
| 1258 | |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1259 | /* check for filled rockblox_status.lines and do what necessary */ |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1260 | static int check_lines (void) |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1261 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1262 | { |
| 1263 | int i, j, y; |
| 1264 | int rockblox = 0; |
| 1265 | |
| 1266 | for (j = 0; j < BOARD_HEIGHT; j++) { |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1267 | for (i = 0; ((i < BOARD_WIDTH) && |
| 1268 | (rockblox_status.board[j][i] != EMPTY_BLOCK)); i++); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1269 | if (i == BOARD_WIDTH) { /* woo hoo, we have a line */ |
| 1270 | rockblox++; |
| 1271 | for (y = j; y > 0; y--) |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1272 | { |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1273 | for (i = 0; i < BOARD_WIDTH; i++) |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1274 | { /* fall line */ |
| 1275 | rockblox_status.board[y][i] = rockblox_status.board[y - 1][i]; |
| 1276 | } |
| 1277 | } |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | return rockblox; |
| 1282 | } |
| 1283 | |
| 1284 | /* moves down the figure and returns true if gameover */ |
| 1285 | static void move_down (void) |
| 1286 | { |
| 1287 | int l, i, rx, ry; |
| 1288 | |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1289 | if (!canMoveTo (rockblox_status.cx, rockblox_status.cy + 1, rockblox_status.co)) { |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1290 | /* save figure to board */ |
| 1291 | for (i = 0; i < 4; i++) { |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1292 | rx = getRelativeX (rockblox_status.cf, i, rockblox_status.co) + rockblox_status.cx; |
| 1293 | ry = getRelativeY (rockblox_status.cf, i, rockblox_status.co) + rockblox_status.cy; |
| 1294 | rockblox_status.board[ry][rx] = rockblox_status.cf; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1295 | } |
| 1296 | /* check if formed some lines */ |
| 1297 | l = check_lines (); |
| 1298 | if (l) { |
| 1299 | /* the original scoring from "http://en.wikipedia.org/wiki/Rockblox" */ |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1300 | rockblox_status.score += scoring[l - 1] * rockblox_status.level; |
| 1301 | rockblox_status.lines += l; |
| 1302 | rockblox_status.level = (int) rockblox_status.lines / 10 + 1; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | /* show details */ |
| 1306 | show_details (); |
| 1307 | |
| 1308 | /* generate a new figure */ |
| 1309 | new_block (); |
| 1310 | } else |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1311 | move_block (0, 1, rockblox_status.co); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1312 | } |
| 1313 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1314 | static bool rockblox_help(void) |
| 1315 | { |
Teruaki Kawashima | 56d29e8 | 2010-02-22 07:17:15 +0000 | [diff] [blame] | 1316 | static char *help_text[] = { |
| 1317 | "Rockblox", "", "Aim", "", |
| 1318 | "Make", "the", "falling", "blocks", "of", |
| 1319 | "different", "shapes", "form", "full", "rows.", |
| 1320 | "Whenever", "a", "row", "is", "completed,", |
| 1321 | "it", "will", "be", "cleared", "away", |
| 1322 | "and", "you", "gain", "points." |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1323 | }; |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1324 | static struct style_text formation[]={ |
| 1325 | { 0, TEXT_CENTER|TEXT_UNDERLINE }, |
| 1326 | { 2, C_RED }, |
Teruaki Kawashima | 56d29e8 | 2010-02-22 07:17:15 +0000 | [diff] [blame] | 1327 | LAST_STYLE_ITEM |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1328 | }; |
Teruaki Kawashima | 56d29e8 | 2010-02-22 07:17:15 +0000 | [diff] [blame] | 1329 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1330 | #ifdef HAVE_LCD_BITMAP |
| 1331 | rb->lcd_setfont(FONT_UI); |
| 1332 | #endif |
| 1333 | #ifdef HAVE_LCD_COLOR |
| 1334 | rb->lcd_set_background(LCD_BLACK); |
| 1335 | rb->lcd_set_foreground(LCD_WHITE); |
| 1336 | #endif |
Teruaki Kawashima | 56d29e8 | 2010-02-22 07:17:15 +0000 | [diff] [blame] | 1337 | if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1338 | return true; |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1339 | #ifdef HAVE_LCD_BITMAP |
| 1340 | rb->lcd_setfont(FONT_SYSFIXED); |
| 1341 | #endif |
Teruaki Kawashima | 56d29e8 | 2010-02-22 07:17:15 +0000 | [diff] [blame] | 1342 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1343 | return false; |
| 1344 | } |
| 1345 | |
| 1346 | static int rockblox_menu_cb(int action, const struct menu_item_ex *this_item) |
| 1347 | { |
| 1348 | int i = ((intptr_t)this_item); |
| 1349 | if(action == ACTION_REQUEST_MENUITEM |
| 1350 | && !resume && (i==0 || i==5)) |
| 1351 | return ACTION_EXIT_MENUITEM; |
| 1352 | return action; |
| 1353 | } |
| 1354 | |
| 1355 | static int rockblox_menu(void) |
| 1356 | { |
| 1357 | int selected = 0; |
| 1358 | |
| 1359 | MENUITEM_STRINGLIST(main_menu, "Rockblox Menu", rockblox_menu_cb, |
| 1360 | "Resume Game", "Start New Game", |
| 1361 | "Help", "High Scores", "Playback Control", |
| 1362 | "Quit without Saving", "Quit"); |
| 1363 | |
| 1364 | rb->button_clear_queue(); |
| 1365 | while (true) { |
| 1366 | switch (rb->do_menu(&main_menu, &selected, NULL, false)) { |
| 1367 | case 0: |
| 1368 | if(resume_file) |
| 1369 | rb->remove(RESUME_FILE); |
| 1370 | init_rockblox(true); |
| 1371 | return 0; |
| 1372 | case 1: |
| 1373 | init_rockblox(false); |
| 1374 | return 0; |
| 1375 | case 2: |
| 1376 | if (rockblox_help()) |
| 1377 | return 1; |
| 1378 | break; |
| 1379 | case 3: |
Teruaki Kawashima | 3f8d4a5 | 2010-02-27 14:45:37 +0000 | [diff] [blame] | 1380 | highscore_show(-1, highscores, NUM_SCORES, true); |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1381 | break; |
| 1382 | case 4: |
| 1383 | if (playback_control(NULL)) |
| 1384 | return 1; |
| 1385 | break; |
| 1386 | case 5: |
| 1387 | return 1; |
| 1388 | case 6: |
| 1389 | if (resume) { |
| 1390 | rb->splash(HZ*1, "Saving game ..."); |
| 1391 | dump_resume(); |
| 1392 | } |
| 1393 | return 1; |
| 1394 | case MENU_ATTACHED_USB: |
| 1395 | return 1; |
| 1396 | default: |
| 1397 | return 1; |
| 1398 | break; |
| 1399 | } |
| 1400 | } |
| 1401 | } |
| 1402 | |
| 1403 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1404 | static int rockblox_loop (void) |
| 1405 | { |
| 1406 | int button; |
Andree Buschmann | 27d153d | 2011-05-01 14:44:20 +0000 | [diff] [blame] | 1407 | #if defined(ROCKBLOX_OFF_PRE) || defined(ROCKBLOX_DROP_PRE) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1408 | int lastbutton = BUTTON_NONE; |
Andree Buschmann | 27d153d | 2011-05-01 14:44:20 +0000 | [diff] [blame] | 1409 | #endif |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1410 | long next_down_tick = *rb->current_tick + level_speed(rockblox_status.level); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1411 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1412 | if (rockblox_menu()) { |
| 1413 | return 1; |
| 1414 | } |
| 1415 | resume = false; |
| 1416 | resume_file = false; |
| 1417 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1418 | while (1) { |
| 1419 | #ifdef HAS_BUTTON_HOLD |
| 1420 | if (rb->button_hold ()) { |
Peter D'Hoye | cb53e3c | 2007-08-15 12:42:09 +0000 | [diff] [blame] | 1421 | /* Turn on backlight timeout (revert to settings) */ |
Teruaki Kawashima | 01313d5 | 2011-01-24 12:29:16 +0000 | [diff] [blame] | 1422 | backlight_use_settings(); |
Jens Arnold | 4d6374c | 2007-03-16 21:56:08 +0000 | [diff] [blame] | 1423 | rb->splash(0, "Paused"); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1424 | while (rb->button_hold ()) |
| 1425 | rb->sleep(HZ/10); |
| 1426 | |
Peter D'Hoye | 767c0ec | 2007-08-16 23:01:18 +0000 | [diff] [blame] | 1427 | /* Turn off backlight timeout */ |
Teruaki Kawashima | 01313d5 | 2011-01-24 12:29:16 +0000 | [diff] [blame] | 1428 | backlight_ignore_timeout(); |
Greg White | c76d3ae | 2007-01-05 18:00:56 +0000 | [diff] [blame] | 1429 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1430 | /* get rid of the splash text */ |
| 1431 | rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT); |
| 1432 | show_details (); |
Adam Gashlin | 8e5a39c | 2007-11-16 09:29:34 +0000 | [diff] [blame] | 1433 | #ifdef HIGH_SCORE_Y |
| 1434 | show_highscores (); |
| 1435 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1436 | draw_next_block (); |
| 1437 | refresh_board (); |
| 1438 | } |
| 1439 | #endif |
| 1440 | |
| 1441 | button = rb->button_get_w_tmo (MAX(next_down_tick - *rb->current_tick, 1)); |
| 1442 | switch (button) { |
| 1443 | #ifdef ROCKBLOX_RC_OFF |
| 1444 | case ROCKBLOX_RC_OFF: |
| 1445 | #endif |
| 1446 | case ROCKBLOX_OFF: |
Marianne Arnold | f772673 | 2009-05-18 21:30:06 +0000 | [diff] [blame] | 1447 | #ifdef ROCKBLOX_OFF_PRE |
| 1448 | if (lastbutton != ROCKBLOX_OFF_PRE) |
| 1449 | break; |
| 1450 | #endif |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1451 | resume = true; |
| 1452 | return 0; |
| 1453 | break; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1454 | |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 1455 | #if defined(ROCKBLOX_ROTATE) |
Greg White | f7afb1b | 2007-01-05 18:44:32 +0000 | [diff] [blame] | 1456 | case ROCKBLOX_ROTATE: |
Greg White | c76d3ae | 2007-01-05 18:00:56 +0000 | [diff] [blame] | 1457 | #endif |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 1458 | case ROCKBLOX_ROTATE_CCW: |
| 1459 | case ROCKBLOX_ROTATE_CCW | BUTTON_REPEAT: |
Thomas Martitz | 19f3d60 | 2009-02-26 20:52:16 +0000 | [diff] [blame] | 1460 | #ifdef HAVE_SCROLLWHEEL |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1461 | /* if the wheel is disabled, add an event to the stack. */ |
| 1462 | if(wheel_enabled == false) |
| 1463 | wheel_events++; |
| 1464 | |
| 1465 | /* if it's enabled, go ahead and rotate.. */ |
| 1466 | if(wheel_enabled) |
| 1467 | #endif |
Tomer Shalev | 83d589d | 2010-02-24 21:16:48 +0000 | [diff] [blame] | 1468 | #ifdef ROCKBLOX_ROTATE_CCW2 |
| 1469 | /* fallback */ |
| 1470 | case ROCKBLOX_ROTATE_CCW2: |
| 1471 | #endif |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1472 | move_block (0, 0, (rockblox_status.co + 1) % figures[rockblox_status.cf].max_or); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1473 | break; |
| 1474 | |
Tomer Shalev | 12332de | 2010-02-24 20:56:52 +0000 | [diff] [blame] | 1475 | case ROCKBLOX_ROTATE_CW: |
| 1476 | case ROCKBLOX_ROTATE_CW | BUTTON_REPEAT: |
Thomas Martitz | 19f3d60 | 2009-02-26 20:52:16 +0000 | [diff] [blame] | 1477 | #ifdef HAVE_SCROLLWHEEL |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1478 | if(wheel_enabled == false) |
| 1479 | wheel_events++; |
| 1480 | |
| 1481 | if(wheel_enabled) |
| 1482 | #endif |
Tomer Shalev | 83d589d | 2010-02-24 21:16:48 +0000 | [diff] [blame] | 1483 | #ifdef ROCKBLOX_ROTATE_CW2 |
| 1484 | /* fallback */ |
| 1485 | case ROCKBLOX_ROTATE_CW2: |
| 1486 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1487 | move_block (0, 0, |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1488 | (rockblox_status.co + figures[rockblox_status.cf].max_or - |
| 1489 | 1) % figures[rockblox_status.cf].max_or); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1490 | break; |
| 1491 | |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1492 | case ROCKBLOX_DOWN: |
| 1493 | case ROCKBLOX_DOWN | BUTTON_REPEAT: |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1494 | move_block (0, 1, rockblox_status.co); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1495 | break; |
| 1496 | |
| 1497 | case ROCKBLOX_RIGHT: |
| 1498 | case ROCKBLOX_RIGHT | BUTTON_REPEAT: |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1499 | move_block (1, 0, rockblox_status.co); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1500 | break; |
| 1501 | |
| 1502 | case ROCKBLOX_LEFT: |
| 1503 | case ROCKBLOX_LEFT | BUTTON_REPEAT: |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1504 | move_block (-1, 0, rockblox_status.co); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1505 | break; |
| 1506 | |
| 1507 | case ROCKBLOX_DROP: |
| 1508 | #ifdef ROCKBLOX_DROP_PRE |
| 1509 | if (lastbutton != ROCKBLOX_DROP_PRE) |
| 1510 | break; |
| 1511 | #endif |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1512 | while (canMoveTo (rockblox_status.cx, rockblox_status.cy + 1, rockblox_status.co)) |
| 1513 | move_block (0, 1, rockblox_status.co); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1514 | break; |
| 1515 | #ifdef ROCKBLOX_RESTART |
| 1516 | case ROCKBLOX_RESTART: |
Jens Arnold | 4d6374c | 2007-03-16 21:56:08 +0000 | [diff] [blame] | 1517 | rb->splash (HZ * 1, "Restarting..."); |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 1518 | init_rockblox (false); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1519 | break; |
| 1520 | #endif |
| 1521 | |
| 1522 | default: |
| 1523 | if (rb->default_event_handler (button) == SYS_USB_CONNECTED) |
| 1524 | return PLUGIN_USB_CONNECTED; |
| 1525 | break; |
| 1526 | } |
Andree Buschmann | 27d153d | 2011-05-01 14:44:20 +0000 | [diff] [blame] | 1527 | #if defined(ROCKBLOX_OFF_PRE) || defined(ROCKBLOX_DROP_PRE) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1528 | if (button != BUTTON_NONE) |
| 1529 | lastbutton = button; |
Andree Buschmann | 27d153d | 2011-05-01 14:44:20 +0000 | [diff] [blame] | 1530 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1531 | |
Thomas Martitz | 19f3d60 | 2009-02-26 20:52:16 +0000 | [diff] [blame] | 1532 | #ifdef HAVE_SCROLLWHEEL |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1533 | /* check if we should enable the scroll wheel, if events |
| 1534 | * begin to stack up... */ |
| 1535 | if(wheel_enabled == false) |
| 1536 | { |
| 1537 | /* stopped rotating the wheel, reset the count */ |
| 1538 | if(wheel_events == last_wheel_event) |
| 1539 | { |
| 1540 | last_wheel_event = 0; |
| 1541 | wheel_events = 0; |
| 1542 | } |
| 1543 | /* rotated the wheel a while constantly, enable it. */ |
| 1544 | else if(wheel_events > 3) |
| 1545 | { |
| 1546 | wheel_enabled = true; |
| 1547 | } |
| 1548 | |
| 1549 | /* this evens out the last event and the "current" event. |
| 1550 | * if we get an event next time through button reading, it will |
| 1551 | * remain ahead of last_event. if we don't, they'll end up equaling |
| 1552 | * each other.. thus, the scroll count will be reset. */ |
| 1553 | if(wheel_enabled == false && wheel_events > last_wheel_event) |
| 1554 | last_wheel_event++; |
| 1555 | } |
| 1556 | #endif |
| 1557 | |
| 1558 | if (TIME_AFTER(*rb->current_tick, next_down_tick)) { |
| 1559 | move_down (); |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1560 | next_down_tick += level_speed(rockblox_status.level); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1561 | if (TIME_AFTER(*rb->current_tick, next_down_tick)) |
| 1562 | /* restart time "raster" when we had to wait longer than usual |
| 1563 | * (pause, game restart etc) */ |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1564 | next_down_tick = *rb->current_tick + level_speed(rockblox_status.level); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1565 | } |
| 1566 | |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1567 | if (rockblox_status.gameover) { |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1568 | #if LCD_DEPTH >= 2 |
| 1569 | rb->lcd_set_foreground (LCD_BLACK); |
| 1570 | #endif |
Thomas Martitz | 399a094 | 2009-05-16 18:52:00 +0000 | [diff] [blame] | 1571 | show_game_over(); |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1572 | resume = false; |
| 1573 | return 0; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1574 | } |
| 1575 | |
| 1576 | refresh_board (); |
| 1577 | } |
| 1578 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1579 | return 0; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1580 | } |
| 1581 | |
Andrew Mahone | 23d9812 | 2009-01-16 10:34:40 +0000 | [diff] [blame] | 1582 | enum plugin_status plugin_start (const void *parameter) |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1583 | { |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1584 | |
| 1585 | (void) parameter; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1586 | |
| 1587 | rb->srand (*rb->current_tick); |
Greg White | c76d3ae | 2007-01-05 18:00:56 +0000 | [diff] [blame] | 1588 | |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 1589 | /* Load HighScore if any */ |
Teruaki Kawashima | 3f8d4a5 | 2010-02-27 14:45:37 +0000 | [diff] [blame] | 1590 | highscore_load(SCORE_FILE, highscores, NUM_SCORES); |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 1591 | |
Karl Kurbjun | 1a9442c | 2006-11-15 06:46:35 +0000 | [diff] [blame] | 1592 | #if LCD_DEPTH > 1 |
Karl Kurbjun | d6b0c97 | 2006-11-15 06:14:27 +0000 | [diff] [blame] | 1593 | rb->lcd_set_backdrop(NULL); |
Karl Kurbjun | 1a9442c | 2006-11-15 06:46:35 +0000 | [diff] [blame] | 1594 | #endif |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1595 | |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1596 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1597 | rb->lcd_setfont (FONT_SYSFIXED); |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1598 | #else |
Andrew Mahone | 23d9812 | 2009-01-16 10:34:40 +0000 | [diff] [blame] | 1599 | if (!pgfx_init(4, 2)) |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1600 | { |
Jens Arnold | 4d6374c | 2007-03-16 21:56:08 +0000 | [diff] [blame] | 1601 | rb->splash(HZ*2, "Old LCD :("); |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1602 | return PLUGIN_OK; |
| 1603 | } |
| 1604 | #endif |
Peter D'Hoye | 767c0ec | 2007-08-16 23:01:18 +0000 | [diff] [blame] | 1605 | /* Turn off backlight timeout */ |
Teruaki Kawashima | 01313d5 | 2011-01-24 12:29:16 +0000 | [diff] [blame] | 1606 | backlight_ignore_timeout(); |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1607 | load_game(); |
| 1608 | resume_file = resume; |
| 1609 | while(!rockblox_loop()) { |
| 1610 | if(!resume) { |
Teruaki Kawashima | c1bb06c | 2010-02-22 13:45:24 +0000 | [diff] [blame] | 1611 | int position = highscore_update(rockblox_status.score, |
| 1612 | rockblox_status.level, "", |
Teruaki Kawashima | 3f8d4a5 | 2010-02-27 14:45:37 +0000 | [diff] [blame] | 1613 | highscores, NUM_SCORES); |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1614 | if (position != -1) { |
Teruaki Kawashima | 3f8d4a5 | 2010-02-27 14:45:37 +0000 | [diff] [blame] | 1615 | if (position == 0) |
| 1616 | rb->splash(HZ*2, "New High Score"); |
| 1617 | highscore_show(position, highscores, NUM_SCORES, true); |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1618 | } |
| 1619 | } |
| 1620 | } |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1621 | |
Thomas Martitz | 732ef1e | 2009-05-16 17:12:07 +0000 | [diff] [blame] | 1622 | #ifndef HAVE_LCD_BITMAP |
Jens Arnold | 8965865 | 2006-10-07 20:00:49 +0000 | [diff] [blame] | 1623 | pgfx_release(); |
| 1624 | #endif |
Steve Gotthardt | d850db1 | 2007-01-05 16:32:20 +0000 | [diff] [blame] | 1625 | /* Save user's HighScore */ |
Teruaki Kawashima | 3f8d4a5 | 2010-02-27 14:45:37 +0000 | [diff] [blame] | 1626 | highscore_save(SCORE_FILE, highscores, NUM_SCORES); |
Teruaki Kawashima | 01313d5 | 2011-01-24 12:29:16 +0000 | [diff] [blame] | 1627 | backlight_use_settings(); |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1628 | |
Johannes Schwarz | 8826115 | 2009-11-17 06:57:36 +0000 | [diff] [blame] | 1629 | return PLUGIN_OK; |
Björn Stenberg | 9e7f361 | 2006-09-19 20:48:47 +0000 | [diff] [blame] | 1630 | } |