annotate src/scenario.c @ 3:17286938e22a

change DS alt. rotate key to rotate twice
author paulo@localhost
date Wed, 08 Apr 2009 21:50:13 -0700
parents
children
rev   line source
paulo@0 1 /* Scenario code for LOCKJAW, an implementation of the Soviet Mind Game
paulo@0 2
paulo@0 3 Copyright (C) 2008 Damian Yerrick <tepples+lj@spamcop.net>
paulo@0 4
paulo@0 5 This work is free software; you can redistribute it and/or modify
paulo@0 6 it under the terms of the GNU General Public License as published by
paulo@0 7 the Free Software Foundation; either version 2 of the License, or
paulo@0 8 (at your option) any later version.
paulo@0 9
paulo@0 10 This program is distributed in the hope that it will be useful,
paulo@0 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
paulo@0 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
paulo@0 13 GNU General Public License for more details.
paulo@0 14
paulo@0 15 You should have received a copy of the GNU General Public License
paulo@0 16 along with this program; if not, write to the Free Software
paulo@0 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
paulo@0 18
paulo@0 19 Original game concept and design by Alexey Pajitnov.
paulo@0 20 The Software is not sponsored or endorsed by Alexey Pajitnov, Elorg,
paulo@0 21 or The Tetris Company LLC.
paulo@0 22
paulo@0 23 */
paulo@0 24
paulo@0 25 #include "scenario.h"
paulo@0 26 #include "options.h"
paulo@0 27 #include <string.h>
paulo@0 28
paulo@0 29 #define END_OF_PRESET {OPTIONS_MENU_LEN}
paulo@0 30
paulo@0 31 const Preset predefPresets[] = {
paulo@0 32 {"Guideline", {
paulo@0 33 {OPTIONS_WIDTH, 10},
paulo@0 34 {OPTIONS_HEIGHT, 20},
paulo@0 35 {OPTIONS_ENTRY_DELAY, 0},
paulo@0 36 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 37 {OPTIONS_RANDOMIZER, LJRAND_BAG},
paulo@0 38 {OPTIONS_HOLD_PIECE, LJHOLD_EMPTY},
paulo@0 39 {OPTIONS_ROTATION_SYSTEM, LJROT_SRS},
paulo@0 40 {OPTIONS_FLOOR_KICKS, 6},
paulo@0 41 {OPTIONS_LOCKDOWN, LJLOCK_MOVE},
paulo@0 42 {OPTIONS_LOCK_DELAY, 30},
paulo@0 43 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 44 {OPTIONS_LINE_DELAY, 30},
paulo@0 45 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 46 {OPTIONS_GLUING, 0},
paulo@0 47 {OPTIONS_SCORING, LJSCORE_TDS},
paulo@0 48 {OPTIONS_DROP_SCORING, LJDROP_1S_2H},
paulo@0 49 {OPTIONS_T_SPIN, LJTS_TDS},
paulo@0 50 END_OF_PRESET
paulo@0 51 }},
paulo@0 52
paulo@0 53 {"Classic", {
paulo@0 54 {OPTIONS_GIMMICK, LJGM_ATYPE},
paulo@0 55 {OPTIONS_WIDTH, 10},
paulo@0 56 {OPTIONS_HEIGHT, 20},
paulo@0 57 {OPTIONS_ENTER_ABOVE, 0},
paulo@0 58 {OPTIONS_ENTRY_DELAY, 10},
paulo@0 59 {OPTIONS_SPEED_CURVE, LJSPD_NES},
paulo@0 60 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 61 {OPTIONS_RANDOMIZER, LJRAND_PURE},
paulo@0 62 {OPTIONS_HOLD_PIECE, LJHOLD_NONE},
paulo@0 63 {OPTIONS_ROTATION_SYSTEM, LJROT_NES},
paulo@0 64 {OPTIONS_FLOOR_KICKS, 0},
paulo@0 65 {OPTIONS_LOCKDOWN, LJLOCK_NOW},
paulo@0 66 {OPTIONS_LOCK_DELAY, 0},
paulo@0 67 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 68 {OPTIONS_LINE_DELAY, 30},
paulo@0 69 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 70 {OPTIONS_GLUING, 0},
paulo@0 71 {OPTIONS_SCORING, LJSCORE_NES},
paulo@0 72 {OPTIONS_DROP_SCORING, LJDROP_NES},
paulo@0 73 {OPTIONS_GARBAGE, LJGARBAGE_NONE},
paulo@0 74 {OPTIONS_SIDEWAYS_DELAY, 15},
paulo@0 75 {OPTIONS_SIDEWAYS_SPEED, 6},
paulo@0 76 {OPTIONS_SOFT_DROP_SPEED, 2},
paulo@0 77 {OPTIONS_INITIAL_SIDEWAYS, 1},
paulo@0 78 {OPTIONS_IRS, 0},
paulo@0 79 {OPTIONS_NEXT_PIECES, 1},
paulo@0 80 END_OF_PRESET
paulo@0 81 }},
paulo@0 82
paulo@0 83 /* http://www.tetrisconcept.com/forum/viewtopic.php?t=892 */
paulo@0 84 {"Master", {
paulo@0 85 {OPTIONS_GIMMICK, LJGM_ATYPE},
paulo@0 86 {OPTIONS_WIDTH, 10},
paulo@0 87 {OPTIONS_HEIGHT, 20},
paulo@0 88 {OPTIONS_ENTER_ABOVE, 0},
paulo@0 89 {OPTIONS_SPEED_CURVE, LJSPD_TGM},
paulo@0 90 {OPTIONS_ENTRY_DELAY, 30},
paulo@0 91 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 92 {OPTIONS_RANDOMIZER, LJRAND_HIST_6},
paulo@0 93 {OPTIONS_HOLD_PIECE, LJHOLD_NONE},
paulo@0 94 {OPTIONS_ROTATION_SYSTEM, LJROT_ARIKA},
paulo@0 95 {OPTIONS_FLOOR_KICKS, 0},
paulo@0 96 {OPTIONS_LOCKDOWN, LJLOCK_STEP},
paulo@0 97 {OPTIONS_LOCK_DELAY, 30},
paulo@0 98 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 99 {OPTIONS_LINE_DELAY, 0},
paulo@0 100 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 101 {OPTIONS_GLUING, LJGLUING_STICKY},
paulo@0 102 {OPTIONS_GARBAGE, LJGARBAGE_NONE},
paulo@0 103 {OPTIONS_SIDEWAYS_DELAY, 16},
paulo@0 104 {OPTIONS_SIDEWAYS_SPEED, 1},
paulo@0 105 {OPTIONS_INITIAL_SIDEWAYS, 0},
paulo@0 106 {OPTIONS_IRS, 1},
paulo@0 107 {OPTIONS_SOFT_DROP_SPEED, 1},
paulo@0 108 {OPTIONS_SOFT_DROP, LJZANGI_LOCK},
paulo@0 109 {OPTIONS_HARD_DROP, LJZANGI_SLIDE},
paulo@0 110 {OPTIONS_NEXT_PIECES, 1},
paulo@0 111 END_OF_PRESET
paulo@0 112 }},
paulo@0 113
paulo@0 114 /* http://www.tetrisconcept.com/forum/viewtopic.php?t=892 */
paulo@0 115 {"T.A. Death", {
paulo@0 116 {OPTIONS_GIMMICK, LJGM_ATYPE},
paulo@0 117 {OPTIONS_SPEED_CURVE, LJSPD_DEATH},
paulo@0 118 {OPTIONS_WIDTH, 10},
paulo@0 119 {OPTIONS_HEIGHT, 20},
paulo@0 120 {OPTIONS_ENTER_ABOVE, 0},
paulo@0 121 {OPTIONS_ENTRY_DELAY, 30},
paulo@0 122 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 123 {OPTIONS_RANDOMIZER, LJRAND_HIST_6},
paulo@0 124 {OPTIONS_HOLD_PIECE, LJHOLD_NONE},
paulo@0 125 {OPTIONS_ROTATION_SYSTEM, LJROT_ARIKA},
paulo@0 126 {OPTIONS_FLOOR_KICKS, 0},
paulo@0 127 {OPTIONS_LOCKDOWN, LJLOCK_STEP},
paulo@0 128 {OPTIONS_LOCK_DELAY, 30},
paulo@0 129 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 130 {OPTIONS_LINE_DELAY, 0},
paulo@0 131 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 132 {OPTIONS_GLUING, LJGLUING_STICKY},
paulo@0 133 {OPTIONS_GARBAGE, LJGARBAGE_NONE},
paulo@0 134 {OPTIONS_SIDEWAYS_DELAY, 16},
paulo@0 135 {OPTIONS_SIDEWAYS_SPEED, 1},
paulo@0 136 {OPTIONS_INITIAL_SIDEWAYS, 0},
paulo@0 137 {OPTIONS_IRS, 1},
paulo@0 138 {OPTIONS_NEXT_PIECES, 1},
paulo@0 139 END_OF_PRESET
paulo@0 140 }},
paulo@0 141
paulo@0 142 {"Square", {
paulo@0 143 {OPTIONS_GIMMICK, LJGM_ATYPE},
paulo@0 144 {OPTIONS_WIDTH, 10},
paulo@0 145 {OPTIONS_HEIGHT, 20},
paulo@0 146 {OPTIONS_ENTER_ABOVE, 1},
paulo@0 147 {OPTIONS_ENTRY_DELAY, 30},
paulo@0 148 {OPTIONS_SPEED_CURVE, LJSPD_EXP},
paulo@0 149 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 150 {OPTIONS_RANDOMIZER, LJRAND_PURE},
paulo@0 151 {OPTIONS_HOLD_PIECE, LJHOLD_TNT},
paulo@0 152 {OPTIONS_ROTATION_SYSTEM, LJROT_SRS},
paulo@0 153 {OPTIONS_FLOOR_KICKS, 6},
paulo@0 154 {OPTIONS_LOCKDOWN, LJLOCK_STEP},
paulo@0 155 {OPTIONS_LOCK_DELAY, 30},
paulo@0 156 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 157 {OPTIONS_LINE_DELAY, 40},
paulo@0 158 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 159 {OPTIONS_GLUING, LJGLUING_SQUARE},
paulo@0 160 {OPTIONS_SCORING, LJSCORE_TNT64},
paulo@0 161 {OPTIONS_DROP_SCORING, LJDROP_NOSCORE},
paulo@0 162 {OPTIONS_T_SPIN, LJTS_TNT},
paulo@0 163 {OPTIONS_GARBAGE, LJGARBAGE_NONE},
paulo@0 164 {OPTIONS_SIDEWAYS_DELAY, 11},
paulo@0 165 {OPTIONS_SIDEWAYS_SPEED, 5},
paulo@0 166 {OPTIONS_SOFT_DROP_SPEED, 2},
paulo@0 167 {OPTIONS_SOFT_DROP, LJZANGI_SLIDE},
paulo@0 168 {OPTIONS_HARD_DROP, LJZANGI_SLIDE},
paulo@0 169 {OPTIONS_INITIAL_SIDEWAYS, 0},
paulo@0 170 {OPTIONS_IRS, 0},
paulo@0 171 {OPTIONS_NEXT_PIECES, 3},
paulo@0 172 END_OF_PRESET
paulo@0 173 }},
paulo@0 174
paulo@0 175 /* http://www.tetrisconcept.com/forum/viewtopic.php?t=549 */
paulo@0 176 {"40 Lines", {
paulo@0 177 {OPTIONS_GIMMICK, LJGM_BTYPE},
paulo@0 178 {OPTIONS_WIDTH, 10},
paulo@0 179 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 180 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 181 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 182 {OPTIONS_GARBAGE, 0},
paulo@0 183 END_OF_PRESET
paulo@0 184 }},
paulo@0 185
paulo@0 186 /* http://www.tetrisconcept.com/forum/viewtopic.php?t=549 */
paulo@0 187 {"180 Seconds", {
paulo@0 188 {OPTIONS_GIMMICK, LJGM_ULTRA},
paulo@0 189 {OPTIONS_WIDTH, 10},
paulo@0 190 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 191 {OPTIONS_HOLD_PIECE, LJHOLD_EMPTY},
paulo@0 192 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 193 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 194 {OPTIONS_GLUING, 0},
paulo@0 195 {OPTIONS_SCORING, LJSCORE_LJ},
paulo@0 196 {OPTIONS_DROP_SCORING, 0},
paulo@0 197 {OPTIONS_T_SPIN, 0},
paulo@0 198 {OPTIONS_GARBAGE, 0},
paulo@0 199 END_OF_PRESET
paulo@0 200 }},
paulo@0 201
paulo@0 202 /* http://www.tetrisconcept.com/forum/viewtopic.php?t=892 */
paulo@0 203 {"Death 300", {
paulo@0 204 {OPTIONS_GIMMICK, LJGM_ULTRA},
paulo@0 205 {OPTIONS_SPEED_CURVE, LJSPD_DEATH300},
paulo@0 206 {OPTIONS_WIDTH, 10},
paulo@0 207 {OPTIONS_HEIGHT, 20},
paulo@0 208 {OPTIONS_ENTER_ABOVE, 0},
paulo@0 209 {OPTIONS_ENTRY_DELAY, 30},
paulo@0 210 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 211 {OPTIONS_RANDOMIZER, LJRAND_HIST_6},
paulo@0 212 {OPTIONS_HOLD_PIECE, LJHOLD_EMPTY},
paulo@0 213 {OPTIONS_ROTATION_SYSTEM, LJROT_ARIKA},
paulo@0 214 {OPTIONS_FLOOR_KICKS, 0},
paulo@0 215 {OPTIONS_LOCKDOWN, LJLOCK_STEP},
paulo@0 216 {OPTIONS_LOCK_DELAY, 30},
paulo@0 217 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 218 {OPTIONS_LINE_DELAY, 0},
paulo@0 219 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 220 {OPTIONS_GLUING, LJGLUING_STICKY},
paulo@0 221 {OPTIONS_GARBAGE, LJGARBAGE_NONE},
paulo@0 222 {OPTIONS_SIDEWAYS_DELAY, 16},
paulo@0 223 {OPTIONS_SIDEWAYS_SPEED, 1},
paulo@0 224 {OPTIONS_INITIAL_SIDEWAYS, 0},
paulo@0 225 {OPTIONS_IRS, 1},
paulo@0 226 {OPTIONS_NEXT_PIECES, 1},
paulo@0 227 END_OF_PRESET
paulo@0 228 }},
paulo@0 229
paulo@0 230 {"M-Roll", {
paulo@0 231 {OPTIONS_GIMMICK, LJGM_BTYPE},
paulo@0 232 {OPTIONS_SPEED_CURVE, LJSPD_DEATH300},
paulo@0 233 {OPTIONS_WIDTH, 10},
paulo@0 234 {OPTIONS_HEIGHT, 20},
paulo@0 235 {OPTIONS_ENTER_ABOVE, 0},
paulo@0 236 {OPTIONS_ENTRY_DELAY, 30},
paulo@0 237 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 238 {OPTIONS_RANDOMIZER, LJRAND_HIST_6},
paulo@0 239 {OPTIONS_HOLD_PIECE, LJHOLD_EMPTY},
paulo@0 240 {OPTIONS_ROTATION_SYSTEM, LJROT_ARIKA},
paulo@0 241 {OPTIONS_FLOOR_KICKS, 0},
paulo@0 242 {OPTIONS_LOCKDOWN, LJLOCK_STEP},
paulo@0 243 {OPTIONS_LOCK_DELAY, 30},
paulo@0 244 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 245 {OPTIONS_LINE_DELAY, 0},
paulo@0 246 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 247 {OPTIONS_GLUING, LJGLUING_STICKY},
paulo@0 248 {OPTIONS_GARBAGE, LJGARBAGE_NONE},
paulo@0 249 {OPTIONS_SIDEWAYS_DELAY, 16},
paulo@0 250 {OPTIONS_SIDEWAYS_SPEED, 1},
paulo@0 251 {OPTIONS_INITIAL_SIDEWAYS, 0},
paulo@0 252 {OPTIONS_IRS, 1},
paulo@0 253 {OPTIONS_NEXT_PIECES, 1},
paulo@0 254 {OPTIONS_HIDE_PF, 1},
paulo@0 255 END_OF_PRESET
paulo@0 256 }},
paulo@0 257
paulo@0 258 /* http://www.tetrisconcept.com/forum/viewtopic.php?t=549 */
paulo@0 259 {"Cascade", {
paulo@0 260 {OPTIONS_GIMMICK, LJGM_BTYPE},
paulo@0 261 {OPTIONS_WIDTH, 10},
paulo@0 262 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 263 {OPTIONS_HOLD_PIECE, LJHOLD_EMPTY},
paulo@0 264 {OPTIONS_CLEAR_GRAVITY, LJGRAV_CASCADE},
paulo@0 265 {OPTIONS_GARBAGE, 0},
paulo@0 266 END_OF_PRESET
paulo@0 267 }},
paulo@0 268
paulo@0 269 /* http://www.tetrisconcept.com/forum/viewtopic.php?t=777 */
paulo@0 270 {"Baboo!", {
paulo@0 271 {OPTIONS_GIMMICK, LJGM_BABY},
paulo@0 272 {OPTIONS_WIDTH, 10},
paulo@0 273 {OPTIONS_PIECE_SET, LJRAND_4BLK},
paulo@0 274 {OPTIONS_SPEED_CURVE, LJSPD_ZERO},
paulo@0 275 {OPTIONS_BOTTOM_BLOCKS, 0},
paulo@0 276 {OPTIONS_CLEAR_GRAVITY, LJGRAV_NAIVE},
paulo@0 277 {OPTIONS_GLUING, 0},
paulo@0 278 {OPTIONS_SCORING, LJSCORE_LJ},
paulo@0 279 {OPTIONS_DROP_SCORING, 0},
paulo@0 280 {OPTIONS_T_SPIN, LJTS_TDS},
paulo@0 281 {OPTIONS_GARBAGE, 0}
paulo@0 282 }},
paulo@0 283
paulo@0 284 };
paulo@0 285
paulo@0 286 const Preset *loadedPresets = predefPresets;
paulo@0 287 size_t nLoadedPresets = sizeof(predefPresets)/sizeof(predefPresets[0]);
paulo@0 288
paulo@0 289 static unsigned char presetBuffer[OPTIONS_MENU_LEN];
paulo@0 290
paulo@0 291 void presetStart(void) {
paulo@0 292 memset(&presetBuffer, 255, sizeof(presetBuffer));
paulo@0 293 }
paulo@0 294
paulo@0 295 void presetAdd(size_t which) {
paulo@0 296 if (which >= nLoadedPresets) {
paulo@0 297 return;
paulo@0 298 }
paulo@0 299 const PresetRule *r = loadedPresets[which].rules;
paulo@0 300 for (size_t i = 0;
paulo@0 301 i < PRESET_MAX_RULES
paulo@0 302 && r[i].line < OPTIONS_MENU_LEN;
paulo@0 303 ++i) {
paulo@0 304 presetBuffer[r[i].line] = r[i].value;
paulo@0 305 }
paulo@0 306 }
paulo@0 307
paulo@0 308 void presetFinish(struct LJView *v) {
paulo@0 309 unpackCommonOptions(v, presetBuffer);
paulo@0 310 }
paulo@0 311
paulo@0 312 #if 0
paulo@0 313 void loadPresetsFromText(FILE *fp) {
paulo@0 314 Preset *presets = NULL;
paulo@0 315
paulo@0 316 size_t capacity = 0, n = 0;
paulo@0 317
paulo@0 318 {
paulo@0 319 // allocate memory for this preset
paulo@0 320 if (capacity <= n) {
paulo@0 321 if (capacity < 32) {
paulo@0 322 capacity += 16;
paulo@0 323 } else {
paulo@0 324 capacity += capacity / 2;
paulo@0 325 }
paulo@0 326 Preset *newPresets = realloc(presets,
paulo@0 327 capacity * sizeof(preset));
paulo@0 328 // if we can't allocate memory, screw it
paulo@0 329 if (!newPresets) {
paulo@0 330 break;
paulo@0 331 }
paulo@0 332 }
paulo@0 333 }
paulo@0 334
paulo@0 335 loadedPresets = presets;
paulo@0 336 nLoadedPresets = n;
paulo@0 337 }
paulo@0 338 #endif
paulo@0 339