3 //extern void setitimer(int, long *, int), system(char *), sigvec(), srand(int), exit(int);
4 //extern int atoi(char *), rand(void), getpid(void);
19 int v
[] = {(int)t
, 0, 2};
21 int w
, s
, I
, K
= 0, i
= 276, j
, k
, q
[276], Q
[276], *n
= q
, *m
, x
= 17;
24 7, -13, -12, 1, // 0 0 -> 7 -> 0
25 8, -11, -12, -1, // 1 1 -> 8 -> 1
26 9, -1, 1, 12, // 2 2 -> 9 -> 10 -> 11 -> 2
27 3, -13, -12, -1, // 3 Square block!
28 12, -1, 11, 1, // 4 4 -> 12 -> 13 -> 14 -> 4
29 15, -1, 13, 1, // 5 5 -> 15 -> 16 -> 17 -> 5
30 18, -1, 1, 2, // 6 6 -> 18 -> 6
36 13, -12, 12, 13, // 12
38 4, -13, -12, 12, // 14
39 16, -11,-12, 12, // 15
45 // Lazy screen refresh
48 for (i
= 11; ++i
< 264;)
49 if ((k
= q
[i
]) - Q
[i
]) {
51 if (i
- ++I
|| i
% 12 < 1) {
54 gotoxy(i
% 12 * 2 + 28, i
/ 12);
62 mmix_putchar("# "[!k
]);
64 printf("\033[%dm " + (K
- k
? 0 : 5), k
);
68 Q
[263] = key
= getchar();
72 int test_brick(long newpos
)
87 int draw_brick(long color
)
95 int main(long argc
, char **argv
)
99 h
[3] = 1000000 / (level
= argc
> 1 ? atoi(argv
[1]) : 2);
101 a
= argc
> 2 ? argv
[2] : "jkl pq";
104 for (i
= 276; i
; --i
)
105 *n
++ = i
< 25 || i
% 12 < 2 ? 7 : 0;
109 system("stty cbreak -echo stop u");
119 puts("\033[H\033[J");
122 for (n
= shape
+ rand() % 7 * 4;; draw_brick(7), update(), draw_brick(0)) {
124 if (test_brick(x
+ 12))
129 for (j
= 0; j
< 252; j
= 12 * (j
/ 12 + 1))
132 for (; j
% 12; q
[j
--] = 0)
135 for (; --j
; q
[j
+ 12] = q
[j
])
139 n
= shape
+ rand() % 7 * 4;
140 test_brick(x
= 17) || (key
= a
[5]);
146 test_brick(--x
) || ++x
;
150 n
= shape
+ 4 * *(m
= n
), test_brick(x
) || (n
= m
);
154 test_brick(++x
) || --x
;
158 for (; test_brick(x
+ 12); ++w
)
161 if (key
== a
[4] || key
== a
[5]) {
164 printf("\033[H\033[J\033[0m%d\n", w
);
167 for (j
= 264; j
--; Q
[j
] = 0);
168 while (getchar() - a
[4])
170 puts("\033[H\033[J\033[7m");
178 d
= popen("stty -cbreak echo stop \023;cat - HI|sort -rn|head -20>/tmp/$$;mv /tmp/$$ HI;cat HI", "w");
179 fprintf(d
, "%4d on level %1d by %s\n", w
, level
, getlogin());