Rev 1449 | Rev 1528 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1449 | Rev 1472 | ||
---|---|---|---|
Line 43... | Line 43... | ||
43 | 43 | ||
44 | /* |
44 | /* |
45 | * Tetris (or however it is spelled). |
45 | * Tetris (or however it is spelled). |
46 | */ |
46 | */ |
47 | 47 | ||
48 | #include <sys/param.h> |
48 | //#include <sys/param.h> |
49 | #include <sys/time.h> |
49 | #include <sys/time.h> |
50 | #include <sys/types.h> |
50 | #include <sys/types.h> |
51 | 51 | ||
52 | #include <err.h> |
52 | #include <err.h> |
53 | //#include <signal.h> |
53 | //#include <signal.h> |
Line 149... | Line 149... | ||
149 | j = random() % 4; |
149 | j = random() % 4; |
150 | for (i = 0; i < j; i++) |
150 | for (i = 0; i < j; i++) |
151 | tmp = &shapes[classic? tmp->rotc : tmp->rot]; |
151 | tmp = &shapes[classic? tmp->rotc : tmp->rot]; |
152 | return (tmp); |
152 | return (tmp); |
153 | } |
153 | } |
- | 154 | ||
- | 155 | static void srandomdev(void) |
|
154 | 156 | { |
|
- | 157 | struct timeval tv; |
|
- | 158 | ||
- | 159 | gettimeofday(&tv, NULL); |
|
- | 160 | srandom(tv.tv_sec + tv.tv_usec / 100000); |
|
- | 161 | } |
|
155 | 162 | ||
156 | int |
163 | int |
157 | main(int argc, char *argv[]) |
164 | main(int argc, char *argv[]) |
158 | { |
165 | { |
159 | int pos, c; |
166 | int pos, c; |
Line 214... | Line 221... | ||
214 | for (j = i+1; j <= 5; j++) { |
221 | for (j = i+1; j <= 5; j++) { |
215 | if (keys[i] == keys[j]) |
222 | if (keys[i] == keys[j]) |
216 | errx(1, "duplicate command keys specified."); |
223 | errx(1, "duplicate command keys specified."); |
217 | } |
224 | } |
218 | if (keys[i] == ' ') |
225 | if (keys[i] == ' ') |
219 | strlcpy(key_write[i], "<space>", sizeof key_write[i]); |
226 | strncpy(key_write[i], "<space>", sizeof key_write[i]); |
220 | else { |
227 | else { |
221 | key_write[i][0] = keys[i]; |
228 | key_write[i][0] = keys[i]; |
222 | key_write[i][1] = '\0'; |
229 | key_write[i][1] = '\0'; |
223 | } |
230 | } |
224 | } |
231 | } |
Line 289... | Line 296... | ||
289 | place(curshape, pos, 1); |
296 | place(curshape, pos, 1); |
290 | do { |
297 | do { |
291 | scr_update(); |
298 | scr_update(); |
292 | scr_msg(key_msg, 0); |
299 | scr_msg(key_msg, 0); |
293 | scr_msg(msg, 1); |
300 | scr_msg(msg, 1); |
294 | (void) fflush(stdout); |
301 | // (void) fflush(stdout); |
295 | } while (rwait((struct timeval *)NULL) == -1); |
302 | } while (rwait((struct timeval *)NULL) == -1); |
296 | scr_msg(msg, 0); |
303 | scr_msg(msg, 0); |
297 | scr_msg(key_msg, 1); |
304 | scr_msg(key_msg, 1); |
298 | place(curshape, pos, 0); |
305 | place(curshape, pos, 0); |
299 | continue; |
306 | continue; |