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