Rev 4348 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4348 | Rev 4691 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | * |
34 | * |
35 | * @(#)tetris.c 8.1 (Berkeley) 5/31/93 |
35 | * @(#)tetris.c 8.1 (Berkeley) 5/31/93 |
36 | */ |
36 | */ |
37 | 37 | ||
38 | /** @addtogroup tetris Tetris |
38 | /** @addtogroup tetris Tetris |
39 | * @brief Tetris ported from OpenBSD |
39 | * @brief Tetris ported from OpenBSD |
40 | * @{ |
40 | * @{ |
41 | */ |
41 | */ |
42 | /** @file |
42 | /** @file |
43 | */ |
43 | */ |
44 | 44 | ||
45 | #ifndef lint |
- | |
46 | static const char copyright[] = |
45 | static const char copyright[] = |
47 | "@(#) Copyright (c) 1992, 1993\n\ |
46 | "@(#) Copyright (c) 1992, 1993\n" |
48 | The Regents of the University of California. All rights reserved.\n"; |
47 | "\tThe Regents of the University of California. All rights reserved.\n"; |
49 | #endif /* not lint */ |
- | |
50 | - | ||
51 | /* |
- | |
52 | * Tetris (or however it is spelled). |
- | |
53 | */ |
- | |
54 | 48 | ||
55 | #include <sys/time.h> |
49 | #include <sys/time.h> |
56 | #include <sys/types.h> |
50 | #include <sys/types.h> |
57 | - | ||
58 | #include <err.h> |
51 | #include <err.h> |
- | 52 | #include <errno.h> |
|
59 | #include <stdio.h> |
53 | #include <stdio.h> |
60 | #include <stdlib.h> |
54 | #include <stdlib.h> |
61 | #include <string.h> |
55 | #include <string.h> |
62 | #include <unistd.h> |
56 | #include <unistd.h> |
- | 57 | #include <getopt.h> |
|
63 | 58 | ||
64 | #include "input.h" |
59 | #include "input.h" |
65 | #include "scores.h" |
60 | #include "scores.h" |
66 | #include "screen.h" |
61 | #include "screen.h" |
67 | #include "tetris.h" |
62 | #include "tetris.h" |
68 | 63 | ||
69 | cell board[B_SIZE]; |
64 | cell board[B_SIZE]; |
- | 65 | ||
- | 66 | int Rows; |
|
70 | int Rows, Cols; |
67 | int Cols; |
- | 68 | ||
71 | const struct shape *curshape; |
69 | const struct shape *curshape; |
72 | const struct shape *nextshape; |
70 | const struct shape *nextshape; |
- | 71 | ||
73 | long fallrate; |
72 | long fallrate; |
74 | int score; |
73 | int score; |
75 | //gid_t gid, egid; |
- | |
76 | char key_msg[100]; |
74 | char key_msg[100]; |
77 | int showpreview, classic; |
75 | int showpreview; |
- | 76 | int classic; |
|
78 | 77 | ||
79 | static void elide(void); |
78 | static void elide(void); |
80 | static void setup_board(void); |
79 | static void setup_board(void); |
81 | const struct shape *randshape(void); |
80 | static const struct shape *randshape(void); |
- | 81 | ||
82 | void onintr(int); |
82 | static void usage(void); |
- | 83 | ||
83 | void usage(void); |
84 | static int firstgame = 1; |
84 | 85 | ||
85 | /* |
86 | /* |
86 | * Set up the initial board. The bottom display row is completely set, |
87 | * Set up the initial board. The bottom display row is completely set, |
87 | * along with another (hidden) row underneath that. Also, the left and |
88 | * along with another (hidden) row underneath that. Also, the left and |
88 | * right edges are set. |
89 | * right edges are set. |
89 | */ |
90 | */ |
90 | static void |
- | |
91 | setup_board(void) |
91 | static void setup_board(void) |
92 | { |
92 | { |
93 | int i; |
93 | int i; |
94 | cell *p; |
94 | cell *p = board; |
95 | 95 | ||
96 | p = board; |
- | |
97 | for (i = B_SIZE; i; i--) |
96 | for (i = B_SIZE; i; i--) |
98 | *p++ = i <= (2 * B_COLS) || (i % B_COLS) < 2; |
97 | *p++ = (i <= (2 * B_COLS) || (i % B_COLS) < 2) ? 0x0000ff : 0x000000; |
99 | } |
98 | } |
100 | 99 | ||
101 | /* |
100 | /* |
102 | * Elide any full active rows. |
101 | * Elide any full active rows. |
103 | */ |
102 | */ |
104 | static void |
- | |
105 | elide(void) |
103 | static void elide(void) |
106 | { |
104 | { |
107 | int rows = 0; |
105 | int rows = 0; |
- | 106 | int i; |
|
- | 107 | int j; |
|
108 | int i, j, base; |
108 | int base; |
109 | cell *p; |
109 | cell *p; |
110 | 110 | ||
111 | for (i = A_FIRST; i < A_LAST; i++) { |
111 | for (i = A_FIRST; i < A_LAST; i++) { |
112 | base = i * B_COLS + 1; |
112 | base = i * B_COLS + 1; |
113 | p = &board[base]; |
113 | p = &board[base]; |
114 | for (j = B_COLS - 2; *p++ != 0;) { |
114 | for (j = B_COLS - 2; *p++ != 0;) { |
115 | if (--j <= 0) { |
115 | if (--j <= 0) { |
116 | /* this row is to be elided */ |
116 | /* This row is to be elided */ |
117 | rows++; |
117 | rows++; |
118 | memset(&board[base], 0, B_COLS - 2); |
118 | memset(&board[base], 0, sizeof(cell) * (B_COLS - 2)); |
- | 119 | ||
119 | scr_update(); |
120 | scr_update(); |
120 | tsleep(); |
121 | tsleep(); |
- | 122 | ||
121 | while (--base != 0) |
123 | while (--base != 0) |
122 | board[base + B_COLS] = board[base]; |
124 | board[base + B_COLS] = board[base]; |
- | 125 | ||
123 | scr_update(); |
126 | scr_update(); |
124 | tsleep(); |
127 | tsleep(); |
- | 128 | ||
125 | break; |
129 | break; |
126 | } |
130 | } |
127 | } |
131 | } |
128 | } |
132 | } |
- | 133 | ||
129 | switch (rows) { |
134 | switch (rows) { |
130 | case 1: |
135 | case 1: |
131 | score += 10; |
136 | score += 10; |
132 | break; |
137 | break; |
133 | case 2: |
138 | case 2: |
Line 142... | Line 147... | ||
142 | default: |
147 | default: |
143 | break; |
148 | break; |
144 | } |
149 | } |
145 | } |
150 | } |
146 | 151 | ||
147 | const struct shape * |
152 | const struct shape *randshape(void) |
148 | randshape(void) |
- | |
149 | { |
153 | { |
150 | const struct shape *tmp; |
154 | const struct shape *tmp = &shapes[random() % 7]; |
151 | int i, j; |
155 | int i; |
152 | - | ||
153 | tmp = &shapes[random() % 7]; |
- | |
154 | j = random() % 4; |
156 | int j = random() % 4; |
- | 157 | ||
155 | for (i = 0; i < j; i++) |
158 | for (i = 0; i < j; i++) |
156 | tmp = &shapes[classic? tmp->rotc : tmp->rot]; |
159 | tmp = &shapes[classic ? tmp->rotc : tmp->rot]; |
- | 160 | ||
157 | return (tmp); |
161 | return (tmp); |
158 | } |
162 | } |
159 | 163 | ||
160 | static void srandomdev(void) |
164 | static void srandomdev(void) |
161 | { |
165 | { |
162 | struct timeval tv; |
166 | struct timeval tv; |
163 | 167 | ||
164 | gettimeofday(&tv, NULL); |
168 | gettimeofday(&tv, NULL); |
165 | srandom(tv.tv_sec + tv.tv_usec / 100000); |
169 | srandom(tv.tv_sec + tv.tv_usec / 100000); |
166 | } |
170 | } |
167 | 171 | ||
168 | static void tetris_menu_draw(int level) |
172 | static void tetris_menu_draw(int level) |
169 | { |
173 | { |
170 | clear_screen(); |
174 | clear_screen(); |
171 | moveto(5,10); |
175 | moveto(5, 10); |
172 | puts("Tetris\n\n"); |
176 | puts("Tetris\n\n"); |
173 | 177 | ||
174 | moveto(8,10); |
178 | moveto(8, 10); |
175 | printf("Level = %d (press keys 1 - 9 to change)",level); |
179 | printf("Level = %d (press keys 1 - 9 to change)", level); |
176 | moveto(9,10); |
180 | moveto(9, 10); |
177 | printf("Preview is %s (press 'p' to change)", (showpreview?"on ":"off")); |
181 | printf("Preview is %s (press 'p' to change)", (showpreview ? "on ": "off")); |
178 | moveto(12,10); |
182 | moveto(12, 10); |
179 | printf("Press 'h' to show hiscore table."); |
183 | printf("Press 'h' to show hiscore table."); |
180 | moveto(13,10); |
184 | moveto(13, 10); |
181 | printf("Press 's' to start game."); |
185 | printf("Press 's' to start game."); |
182 | moveto(14,10); |
186 | moveto(14, 10); |
183 | printf("Press 'q' to quit game."); |
187 | printf("Press 'q' to quit game."); |
184 | moveto(20,10); |
188 | moveto(20, 10); |
185 | printf("In game controls:"); |
189 | printf("In game controls:"); |
186 | moveto(21,0); |
190 | moveto(21, 0); |
187 | puts(key_msg); |
191 | puts(key_msg); |
188 | } |
192 | } |
189 | 193 | ||
190 | static int tetris_menu(int *level) |
194 | static int tetris_menu(int *level) |
191 | { |
195 | { |
192 | static int firstgame = 1; |
- | |
193 | int i; |
- | |
194 | /* if (showpreview == 0) |
- | |
195 | (void)printf("Your score: %d point%s x level %d = %d\n", |
- | |
196 | score, score == 1 ? "" : "s", level, score * level); |
- | |
197 | else { |
- | |
198 | (void)printf("Your score: %d point%s x level %d x preview penalty %0.3f = %d\n", |
- | |
199 | score, score == 1 ? "" : "s", level, (double)PRE_PENALTY, |
- | |
200 | (int)(score * level * PRE_PENALTY)); |
- | |
201 | score = score * PRE_PENALTY; |
- | |
202 | } |
- | |
203 | savescore(level); |
- | |
204 | - | ||
205 | showscores(level); |
- | |
206 | |
- | |
207 | printf("\nHit 's' to new game, 'q' to quit.\n"); |
- | |
208 | */ |
- | |
209 | tetris_menu_draw(*level); |
196 | tetris_menu_draw(*level); |
210 | while (1) { |
197 | while (1) { |
211 | - | ||
212 | i = getchar(); |
198 | int i = getchar(); |
213 | 199 | ||
214 | switch(i) { |
200 | switch(i) { |
215 | case 'p': |
201 | case 'p': |
216 | showpreview = !showpreview; |
202 | showpreview = !showpreview; |
217 | moveto(9,21); |
203 | moveto(9, 21); |
218 | if (showpreview) |
204 | if (showpreview) |
219 | printf("on "); |
205 | printf("on "); |
220 | else |
206 | else |
221 | printf("off"); |
207 | printf("off"); |
222 | - | ||
223 | break; |
208 | break; |
224 | case 'h': |
209 | case 'h': |
- | 210 | loadscores(); |
|
225 | showscores(firstgame); |
211 | showscores(firstgame); |
226 | tetris_menu_draw(*level); |
212 | tetris_menu_draw(*level); |
227 | break; |
213 | break; |
228 | case 's': |
214 | case 's': |
229 | firstgame = 0; |
215 | firstgame = 0; |
Line 233... | Line 219... | ||
233 | case '1': |
219 | case '1': |
234 | case '2': |
220 | case '2': |
235 | case '3': |
221 | case '3': |
236 | case '4': |
222 | case '4': |
237 | case '5': |
223 | case '5': |
238 | case '6': |
224 | case '6': |
239 | case '7': |
225 | case '7': |
240 | case '8': |
226 | case '8': |
241 | case '9': |
227 | case '9': |
242 | *level = i - '0'; |
228 | *level = i - '0'; |
243 | moveto(8,18); |
229 | moveto(8, 18); |
244 | printf("%d", *level); |
230 | printf("%d", *level); |
245 | break; |
231 | break; |
246 | } |
232 | } |
247 | } |
233 | } |
248 | - | ||
249 | } |
234 | } |
250 | 235 | ||
251 | int |
- | |
252 | main(int argc, char *argv[]) |
236 | int main(int argc, char *argv[]) |
253 | { |
237 | { |
254 | int pos, c; |
238 | int pos; |
- | 239 | int c; |
|
255 | char *keys; |
240 | const char *keys; |
256 | int level = 2; |
241 | int level = 2; |
257 | char key_write[6][10]; |
242 | char key_write[6][10]; |
- | 243 | int i; |
|
258 | int i, j; |
244 | int j; |
- | 245 | int ch; |
|
259 | 246 | ||
260 | keys = "jkl pq"; |
247 | keys = "jkl pq"; |
261 | - | ||
262 | // gid = getgid(); |
- | |
263 | // egid = getegid(); |
- | |
264 | // setegid(gid); |
- | |
265 | 248 | ||
266 | classic = 0; |
249 | classic = 0; |
267 | showpreview = 1; |
250 | showpreview = 1; |
268 | - | ||
269 | /* while ((ch = getopt(argc, argv, "ck:l:ps")) != -1) */ |
- | |
270 | /* switch(ch) { */ |
- | |
271 | /* case 'c': */ |
- | |
272 | /* /\* */ |
- | |
273 | /* * this means: */ |
- | |
274 | /* * - rotate the other way; */ |
- | |
275 | /* * - no reverse video. */ |
- | |
276 | /* *\/ */ |
- | |
277 | /* classic = 1; */ |
- | |
278 | /* break; */ |
- | |
279 | /* case 'k': */ |
- | |
280 | /* if (str_size(keys = optarg) != 6) */ |
- | |
281 | /* usage(); */ |
- | |
282 | /* break; */ |
- | |
283 | /* case 'l': */ |
- | |
284 | /* level = (int)strtonum(optarg, MINLEVEL, MAXLEVEL, */ |
- | |
285 | /* &errstr); */ |
- | |
286 | /* if (errstr) */ |
- | |
287 | /* errx(1, "level must be from %d to %d", */ |
- | |
288 | /* MINLEVEL, MAXLEVEL); */ |
- | |
289 | /* break; */ |
- | |
290 | /* case 'p': */ |
- | |
291 | /* showpreview = 1; */ |
- | |
292 | /* break; */ |
- | |
293 | /* case 's': */ |
- | |
294 | /* showscores(0); */ |
- | |
295 | /* exit(0); */ |
- | |
296 | /* default: */ |
- | |
297 | /* usage(); */ |
- | |
298 | /* } */ |
- | |
299 | - | ||
300 | /* argc -= optind; */ |
- | |
301 | /* argv += optind; */ |
- | |
302 | - | ||
303 | /* if (argc) */ |
- | |
304 | /* usage(); */ |
- | |
305 | - | ||
306 | 251 | ||
- | 252 | while ((ch = getopt(argc, argv, "ck:ps")) != -1) |
|
- | 253 | switch(ch) { |
|
- | 254 | case 'c': |
|
- | 255 | /* |
|
- | 256 | * this means: |
|
- | 257 | * - rotate the other way |
|
- | 258 | * - no reverse video |
|
- | 259 | */ |
|
- | 260 | classic = 1; |
|
- | 261 | break; |
|
- | 262 | case 'k': |
|
- | 263 | if (str_size(keys = optarg) != 6) |
|
- | 264 | usage(); |
|
- | 265 | break; |
|
- | 266 | case 'p': |
|
- | 267 | showpreview = 1; |
|
- | 268 | break; |
|
- | 269 | case 's': |
|
- | 270 | showscores(0); |
|
- | 271 | exit(0); |
|
- | 272 | default: |
|
- | 273 | usage(); |
|
- | 274 | } |
|
307 | 275 | ||
- | 276 | argc -= optind; |
|
- | 277 | argv += optind; |
|
- | 278 | ||
- | 279 | if (argc) |
|
- | 280 | usage(); |
|
- | 281 | ||
308 | for (i = 0; i <= 5; i++) { |
282 | for (i = 0; i <= 5; i++) { |
309 | for (j = i+1; j <= 5; j++) { |
283 | for (j = i + 1; j <= 5; j++) { |
310 | if (keys[i] == keys[j]) |
284 | if (keys[i] == keys[j]) |
311 | errx(1, "duplicate command keys specified."); |
285 | errx(1, "duplicate command keys specified."); |
312 | } |
286 | } |
- | 287 | ||
313 | if (keys[i] == ' ') |
288 | if (keys[i] == ' ') |
314 | str_cpy(key_write[i], sizeof key_write[i], "<space>"); |
289 | str_cpy(key_write[i], sizeof(key_write[i]), "<space>"); |
315 | else { |
290 | else { |
316 | key_write[i][0] = keys[i]; |
291 | key_write[i][0] = keys[i]; |
317 | key_write[i][1] = '\0'; |
292 | key_write[i][1] = '\0'; |
318 | } |
293 | } |
319 | } |
294 | } |
320 | 295 | ||
321 | snprintf(key_msg, sizeof key_msg, |
296 | snprintf(key_msg, sizeof(key_msg), |
322 | "%s - left %s - rotate %s - right %s - drop %s - pause %s - quit", |
297 | "%s - left %s - rotate %s - right %s - drop %s - pause %s - quit", |
323 | key_write[0], key_write[1], key_write[2], key_write[3], |
298 | key_write[0], key_write[1], key_write[2], key_write[3], |
324 | key_write[4], key_write[5]); |
299 | key_write[4], key_write[5]); |
325 | 300 | ||
326 | scr_init(); |
301 | scr_init(); |
- | 302 | if (loadscores() != EOK) |
|
327 | initscores(); |
303 | initscores(); |
- | 304 | ||
328 | while (tetris_menu(&level)) { |
305 | while (tetris_menu(&level)) { |
329 | fallrate = 1000000 / level; |
306 | fallrate = 1000000 / level; |
330 | 307 | ||
331 | scr_clear(); |
308 | scr_clear(); |
332 | setup_board(); |
309 | setup_board(); |
333 | 310 | ||
334 | srandomdev(); |
311 | srandomdev(); |
335 | scr_set(); |
312 | scr_set(); |
336 | 313 | ||
337 | pos = A_FIRST*B_COLS + (B_COLS/2)-1; |
314 | pos = A_FIRST * B_COLS + (B_COLS / 2) - 1; |
338 | nextshape = randshape(); |
315 | nextshape = randshape(); |
339 | curshape = randshape(); |
316 | curshape = randshape(); |
340 | 317 | ||
341 | scr_msg(key_msg, 1); |
318 | scr_msg(key_msg, 1); |
342 | 319 | ||
343 | for (;;) { |
320 | while (1) { |
344 | place(curshape, pos, 1); |
321 | place(curshape, pos, 1); |
345 | scr_update(); |
322 | scr_update(); |
346 | place(curshape, pos, 0); |
323 | place(curshape, pos, 0); |
347 | c = tgetchar(); |
324 | c = tgetchar(); |
348 | if (c < 0) { |
325 | if (c < 0) { |
Line 351... | Line 328... | ||
351 | */ |
328 | */ |
352 | if (fits_in(curshape, pos + B_COLS)) { |
329 | if (fits_in(curshape, pos + B_COLS)) { |
353 | pos += B_COLS; |
330 | pos += B_COLS; |
354 | continue; |
331 | continue; |
355 | } |
332 | } |
356 | 333 | ||
357 | /* |
334 | /* |
358 | * Put up the current shape `permanently', |
335 | * Put up the current shape `permanently', |
359 | * bump score, and elide any full rows. |
336 | * bump score, and elide any full rows. |
360 | */ |
337 | */ |
361 | place(curshape, pos, 1); |
338 | place(curshape, pos, 1); |
362 | score++; |
339 | score++; |
363 | elide(); |
340 | elide(); |
364 | 341 | ||
365 | /* |
342 | /* |
366 | * Choose a new shape. If it does not fit, |
343 | * Choose a new shape. If it does not fit, |
367 | * the game is over. |
344 | * the game is over. |
368 | */ |
345 | */ |
369 | curshape = nextshape; |
346 | curshape = nextshape; |
370 | nextshape = randshape(); |
347 | nextshape = randshape(); |
371 | pos = A_FIRST*B_COLS + (B_COLS/2)-1; |
348 | pos = A_FIRST * B_COLS + (B_COLS / 2) - 1; |
- | 349 | ||
372 | if (!fits_in(curshape, pos)) |
350 | if (!fits_in(curshape, pos)) |
373 | break; |
351 | break; |
- | 352 | ||
374 | continue; |
353 | continue; |
375 | } |
354 | } |
376 | 355 | ||
377 | /* |
356 | /* |
378 | * Handle command keys. |
357 | * Handle command keys. |
379 | */ |
358 | */ |
380 | if (c == keys[5]) { |
359 | if (c == keys[5]) { |
381 | /* quit */ |
360 | /* quit */ |
382 | break; |
361 | break; |
383 | } |
362 | } |
- | 363 | ||
384 | if (c == keys[4]) { |
364 | if (c == keys[4]) { |
385 | static char msg[] = |
365 | static char msg[] = |
386 | "paused - press RETURN to continue"; |
366 | "paused - press RETURN to continue"; |
387 | 367 | ||
388 | place(curshape, pos, 1); |
368 | place(curshape, pos, 1); |
389 | do { |
369 | do { |
390 | scr_update(); |
370 | scr_update(); |
391 | scr_msg(key_msg, 0); |
371 | scr_msg(key_msg, 0); |
392 | scr_msg(msg, 1); |
372 | scr_msg(msg, 1); |
393 | (void) fflush(stdout); |
373 | (void) fflush(stdout); |
394 | } while (rwait((struct timeval *)NULL) == -1); |
374 | } while (rwait((struct timeval *) NULL) == -1); |
- | 375 | ||
395 | scr_msg(msg, 0); |
376 | scr_msg(msg, 0); |
396 | scr_msg(key_msg, 1); |
377 | scr_msg(key_msg, 1); |
397 | place(curshape, pos, 0); |
378 | place(curshape, pos, 0); |
398 | continue; |
379 | continue; |
399 | } |
380 | } |
- | 381 | ||
400 | if (c == keys[0]) { |
382 | if (c == keys[0]) { |
401 | /* move left */ |
383 | /* move left */ |
402 | if (fits_in(curshape, pos - 1)) |
384 | if (fits_in(curshape, pos - 1)) |
403 | pos--; |
385 | pos--; |
404 | continue; |
386 | continue; |
405 | } |
387 | } |
- | 388 | ||
406 | if (c == keys[1]) { |
389 | if (c == keys[1]) { |
407 | /* turn */ |
390 | /* turn */ |
408 | const struct shape *new = &shapes[ |
391 | const struct shape *new = |
409 | classic? curshape->rotc : curshape->rot]; |
392 | &shapes[classic ? curshape->rotc : curshape->rot]; |
410 | 393 | ||
411 | if (fits_in(new, pos)) |
394 | if (fits_in(new, pos)) |
412 | curshape = new; |
395 | curshape = new; |
413 | continue; |
396 | continue; |
414 | } |
397 | } |
- | 398 | ||
415 | if (c == keys[2]) { |
399 | if (c == keys[2]) { |
416 | /* move right */ |
400 | /* move right */ |
417 | if (fits_in(curshape, pos + 1)) |
401 | if (fits_in(curshape, pos + 1)) |
418 | pos++; |
402 | pos++; |
419 | continue; |
403 | continue; |
420 | } |
404 | } |
- | 405 | ||
421 | if (c == keys[3]) { |
406 | if (c == keys[3]) { |
422 | /* move to bottom */ |
407 | /* move to bottom */ |
423 | while (fits_in(curshape, pos + B_COLS)) { |
408 | while (fits_in(curshape, pos + B_COLS)) { |
424 | pos += B_COLS; |
409 | pos += B_COLS; |
425 | score++; |
410 | score++; |
426 | } |
411 | } |
427 | continue; |
412 | continue; |
428 | } |
413 | } |
- | 414 | ||
429 | if (c == '\f') { |
415 | if (c == '\f') { |
430 | scr_clear(); |
416 | scr_clear(); |
431 | scr_msg(key_msg, 1); |
417 | scr_msg(key_msg, 1); |
432 | } |
418 | } |
433 | } |
419 | } |
434 | 420 | ||
435 | scr_clear(); |
421 | scr_clear(); |
- | 422 | loadscores(); |
|
436 | insertscore(score, level); |
423 | insertscore(score, level); |
- | 424 | savescores(); |
|
437 | score=0; |
425 | score = 0; |
438 | } |
426 | } |
439 | 427 | ||
440 | scr_clear(); |
428 | scr_clear(); |
441 | printf("\n\n\n\t\tGame over.\n"); |
429 | printf("\nGame over.\n"); |
442 | /* |
- | |
443 | while ((i = getchar()) != '\n') |
- | |
444 | if (i == EOF) |
- | |
445 | break |
- | |
446 | */ |
- | |
447 | scr_end(); |
430 | scr_end(); |
448 | 431 | ||
449 | return 0; |
432 | return 0; |
450 | } |
433 | } |
451 | 434 | ||
452 | /* void */ |
- | |
453 | /* onintr(int signo) */ |
- | |
454 | /* { */ |
- | |
455 | /* scr_clear(); /\* XXX signal race *\/ */ |
- | |
456 | /* scr_end(); /\* XXX signal race *\/ */ |
- | |
457 | /* _exit(0); */ |
- | |
458 | /* } */ |
- | |
459 | - | ||
460 | void |
- | |
461 | usage(void) |
435 | void usage(void) |
462 | { |
436 | { |
463 | (void)fprintf(stderr, "usage: tetris [-ps] [-k keys] [-l level]\n"); |
437 | fprintf(stderr, "usage: tetris [-ps] [-k keys]\n"); |
464 | exit(1); |
438 | exit(1); |
465 | } |
439 | } |
466 | 440 | ||
467 | /** @} |
441 | /** @} |
468 | */ |
442 | */ |
469 | - |