suppress output from the fixup stages
[AROS-Contrib.git] / Games / cxhextris / xio.c
blobd518c4ddf1ff782714c499afa4652bf3f9b47002
1 /*
2 * xhextris Copyright 1990 David Markley, dm3e@+andrew.cmu.edu, dam@cs.cmu.edu
4 * Permission to use, copy, modify, and distribute, this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders be used in
9 * advertising or publicity pertaining to distribution of the software with
10 * specific, written prior permission, and that no fee is charged for further
11 * distribution of this software, or any modifications thereof. The copyright
12 * holder make no representations about the suitability of this software for
13 * any purpose. It is provided "as is" without express or implied warranty.
15 * THE COPYRIGHT HOLDER DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA, PROFITS, QPA OR GPA, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
20 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21 * PERFORMANCE OF THIS SOFTWARE.
24 /* This file contains the X I/O handling routines for hextris.
27 #include <stdio.h>
28 #include <strings.h>
29 #include <X11/Xlib.h>
30 #include <X11/Xutil.h>
31 #include <X11/keysym.h>
32 #include <sys/types.h>
33 #include <sys/dir.h>
34 #include <sys/time.h>
35 #include <pwd.h>
37 #ifdef LOG
38 #include <system.h>
39 #endif
41 #include "header.h"
43 /* Macros to make 4.2 BSD select compatible with 4.3 BSD select */
44 #ifndef FD_SET
45 #define fd_set int
46 #define FD_SET(fd,fdset) (*(fdset) |= (1<<(fd)))
47 #define FD_CLR(fd,fdset) (*(fdset) &= ~(1<<(fd)))
48 #define FD_ISSET(fd, fdset) (*(fdset) & (1<<(fd)))
49 #define FD_ZERO(fdset) (*(fdset) = 0)
50 #endif
52 /* I dislike global variables, but this made it much simpler */
53 Display *display;
54 int screen;
55 Window win;
56 GC gc, hexgc;
57 XFontStruct *font_info, *hexfont_info;
58 Pixmap black, white;
59 XColor Orange1, Red1, Blue1, Green1, Yellow1, Chocolate1, Purple1,
60 SteelBlue1, Black, White, Plum1, Maroon1, Pink1, Wheat;
61 XColor Orange4, Red4, Blue4, Green4, Yellow4, Chocolate4, Purple4, SteelBlue4,
62 Plum4, Maroon4, Pink4, DarkSlateGrey;
63 #ifdef AFS
64 extern int PlayerUID;
65 #endif
67 /* This is the big, ugly main X procedure...
69 void main(argc, argv)
70 int argc;
71 char **argv;
73 char buffer[512];
74 int width, height, i, bufsize=20, inverse=0, pleasure=0, window_size = 0;
75 XSizeHints size_hints;
76 XEvent report;
77 KeySym key;
78 XComposeStatus compose;
79 struct timeval tp, ltp;
80 struct timezone tzp;
81 double intvl = 0, newintvl;
82 fd_set fdst;
83 struct passwd *pwent;
84 /* The following variables are required by hextris */
85 int score = 0, rows = 0, game_over = 1, game_view = 1, oldscore = 0;
87 high_score_t high_scores[MAXHIGHSCORES];
88 position_t grid[MAXROW][MAXCOLUMN];
89 piece_t npiece, piece;
90 char *name, *log_name;
92 #ifdef AFS
93 Authenticate();
94 bePlayer();
95 pwent = getpwuid(PlayerUID);
96 if (pwent == (struct passwd *) NULL) {
97 if ((log_name = (char *)getenv("USER")) == NULL)
98 log_name = "anon";
99 } else
100 log_name = pwent->pw_name;
101 #else
102 pwent = getpwuid(getuid());
103 if (pwent == (struct passwd *) NULL) {
104 if ((log_name = (char *)getenv("USER")) == NULL)
105 log_name = "anon";
106 } else
107 log_name = pwent->pw_name;
108 #endif
109 for (i = 1; i < argc; i++) {
110 if (! strcmp(argv[i],"-rv")) {
111 inverse = 1;
112 continue;
114 if (! strcmp(argv[i],"-p"))
115 pleasure = 1;
117 if ((name = (char *)getenv("XHEXNAME")) == NULL)
118 name = log_name;
119 printf("\nWelcome, %s...\n",name);
120 gettimeofday(&tp, &tzp);
121 srandom((int)(tp.tv_usec));
122 #ifdef LOG
123 strcpy(log_message,log_name);
124 strcat(log_message,"\t");
125 strcat(log_message,SYS_NAME);
126 strcat(log_message,"\t1.00");
127 #endif
128 set_up_display(inverse);
129 set_up_window(&width,&height,&size_hints,argv,argc);
130 XSync(display,True);
131 while(1) {
132 if (pleasure) {
133 score = 0;
134 intvl = 400000;
135 } else
136 intvl = 100000+(200000-((rows > 40) ? 20 : (rows/2))*10000);
137 oldscore = score;
138 if (! game_over)
139 if ((game_over = update_drop(grid,&npiece,&piece,&score,&rows))) {
140 read_high_scores(high_scores);
141 if (is_high_score(name, log_name, score, rows, high_scores))
142 write_high_scores(high_scores,log_name);
143 read_high_scores(high_scores);
145 if (score != oldscore) {
146 XSync(display,True);
147 intvl = 400000;
149 gettimeofday(&ltp, NULL);
150 while (1) {
151 gettimeofday(&tp, NULL);
152 newintvl = intvl - (((tp.tv_sec - ltp.tv_sec)*1000000)+
153 (tp.tv_usec - ltp.tv_usec));
154 if (newintvl <= 0)
155 break;
156 tp.tv_sec = 0;
157 tp.tv_usec = newintvl;
158 FD_ZERO(&fdst);
159 FD_SET(ConnectionNumber(display),&fdst);
160 select(ConnectionNumber(display)+1,&fdst,0,0,&tp);
161 while (XPending(display)) {
162 XNextEvent(display, &report);
163 switch (report.type) {
164 case Expose:
165 while (XCheckTypedEvent(display, Expose, &report));
166 if (window_size)
167 TooSmall();
168 redraw_game(grid,&npiece,&piece,&score,&rows,game_view,
169 high_scores);
170 break;
171 case ConfigureNotify:
172 while (XCheckTypedEvent(display,ConfigureNotify,&report));
173 width = report.xconfigure.width;
174 height = report.xconfigure.height;
175 if ((width < size_hints.min_width) ||
176 (height < size_hints.min_height))
177 window_size = 1;
178 else
179 window_size = 0;
180 redraw_game(grid,&npiece,&piece,&score,&rows,game_view,
181 high_scores);
182 break;
183 case EnterNotify:
184 break;
185 case LeaveNotify:
186 break;
187 case ButtonPress:
188 XBell(display,50);
189 break;
190 case KeyPress:
191 XLookupString(&(report.xkey), buffer, bufsize, &key, &compose);
192 switch (key) {
193 case XK_Left:
194 buffer[0] = '4';
195 break;
196 case XK_Up:
197 buffer[0] = '8';
198 break;
199 case XK_Right:
200 buffer[0] = '6';
201 break;
202 case XK_Down:
203 buffer[0] = '2';
204 break;
205 default:
206 break;
208 oldscore = score;
209 do_choice(buffer,grid,&npiece,&piece,&score,&rows,
210 &game_over, &game_view, high_scores);
211 if ((score != oldscore) || (! score)) {
212 XSync(display,True);
213 intvl = 400000;
214 gettimeofday(&ltp, NULL);
216 break;
217 default:
218 break;
225 /* This sets up the basic connections to the X server, the fonts, and
226 * which colors are to be foreground and background.
228 set_up_display(inverse)
229 int inverse;
231 Pixmap temp;
233 if ( (display = XOpenDisplay(NULL)) == NULL) {
234 fprintf(stderr, "xhextris: cannot connect to X server.\n");
235 exit(-1);
237 screen = DefaultScreen(display);
238 XAllocNamedColor(display, DefaultColormap(display, screen),
239 "red4", &Red4, &Red4);
240 XAllocNamedColor(display, DefaultColormap(display, screen),
241 "green4", &Green4, &Green4);
242 XAllocNamedColor(display, DefaultColormap(display, screen),
243 "black", &Black, &Black);
244 XAllocNamedColor(display, DefaultColormap(display, screen),
245 "white", &White, &White);
246 XAllocNamedColor(display, DefaultColormap(display, screen),
247 "Orange4", &Orange4, &Orange4);
248 XAllocNamedColor(display, DefaultColormap(display, screen),
249 "blue4", &Blue4, &Blue4);
250 XAllocNamedColor(display, DefaultColormap(display, screen),
251 "yellow4", &Yellow4, &Yellow4);
252 XAllocNamedColor(display, DefaultColormap(display, screen),
253 "chocolate4", &Chocolate4, &Chocolate4);
254 XAllocNamedColor(display, DefaultColormap(display, screen),
255 "purple4", &Purple4, &Purple4);
256 XAllocNamedColor(display, DefaultColormap(display, screen),
257 "SteelBlue4", &SteelBlue4, &SteelBlue4);
258 XAllocNamedColor(display, DefaultColormap(display, screen),
259 "Plum4", &Plum4, &Plum4);
260 XAllocNamedColor(display, DefaultColormap(display, screen),
261 "Maroon4", &Maroon4, &Maroon4);
262 XAllocNamedColor(display, DefaultColormap(display, screen),
263 "pink4", &Pink4, &Pink4);
264 XAllocNamedColor(display, DefaultColormap(display, screen),
265 "Wheat", &Wheat, &Wheat);
266 XAllocNamedColor(display, DefaultColormap(display, screen),
267 "darkslategrey", &DarkSlateGrey, &DarkSlateGrey);
270 XAllocNamedColor(display, DefaultColormap(display, screen),
271 "red1", &Red1, &Red1);
272 XAllocNamedColor(display, DefaultColormap(display, screen),
273 "green1", &Green1, &Green1);
274 XAllocNamedColor(display, DefaultColormap(display, screen),
275 "Orange1", &Orange1, &Orange1);
276 XAllocNamedColor(display, DefaultColormap(display, screen),
277 "blue1", &Blue1, &Blue1);
278 XAllocNamedColor(display, DefaultColormap(display, screen),
279 "yellow1", &Yellow1, &Yellow1);
280 XAllocNamedColor(display, DefaultColormap(display, screen),
281 "chocolate1", &Chocolate1, &Chocolate1);
282 XAllocNamedColor(display, DefaultColormap(display, screen),
283 "purple1", &Purple1, &Purple1);
284 XAllocNamedColor(display, DefaultColormap(display, screen),
285 "SteelBlue1", &SteelBlue1, &SteelBlue1);
286 XAllocNamedColor(display, DefaultColormap(display, screen),
287 "Plum1", &Plum1, &Plum1);
288 XAllocNamedColor(display, DefaultColormap(display, screen),
289 "Maroon1", &Maroon1, &Maroon1);
290 XAllocNamedColor(display, DefaultColormap(display, screen),
291 "pink1", &Pink1, &Pink1);
292 black = BlackPixel(display, screen);
293 white = WhitePixel(display, screen);
295 set_font_path(HEXFONTDIR);
299 /* This sets up the font path to contain the directories that have the
300 * fonts this program needs.
302 set_font_path(fontdir)
303 char *fontdir;
305 int i, font_length;
306 char **font_path = XGetFontPath(display, &font_length);
308 for (i = 0; (i < font_length) && strcmp(font_path[i],fontdir); i++);
310 if (i >= font_length) {
311 char **new_font_path;
313 if (new_font_path = (char **) malloc((font_length+1)*sizeof(char *))) {
314 for(i = 0; i < font_length; i++)
315 new_font_path[i] = font_path[i];
316 new_font_path[i] = fontdir;
317 XSetFontPath(display, new_font_path, font_length + 1);
318 free(new_font_path);
321 if (font_path)
322 XFreeFontPath(font_path);
325 /* This sets up the window position, size, fonts, and gcs.
327 set_up_window(width,height,size_hints,argv,argc)
328 int *width, *height;
329 XSizeHints *size_hints;
330 char *argv[];
331 int argc;
333 *width = MAXCOLUMN*40;
334 *height = (MAXROW+4)*20;
335 win = XCreateSimpleWindow(display,RootWindow(display, screen),0,0,
336 *width, *height, 4, white, black);
337 size_hints->flags = PPosition | PSize | PMinSize;
338 size_hints->x = 0;
339 size_hints->y = 0;
340 size_hints->width = *width;
341 size_hints->height = *height;
342 size_hints->min_width = 300;
343 size_hints->min_height = 700;
344 XSetStandardProperties(display, win, WINDOWNAME, ICONNAME, (int) NULL, argv,
345 argc, size_hints);
346 XSelectInput(display, win, ExposureMask | KeyPressMask | ButtonPressMask |
347 StructureNotifyMask | EnterWindowMask | LeaveWindowMask);
348 load_font(&font_info, FONTNAME);
349 get_GC(win, &gc, font_info);
350 XSetForeground(display, gc, Wheat.pixel);
351 XSetBackground(display, gc, black);
352 load_font(&hexfont_info, HEXFONTNAME);
353 get_GC(win, &hexgc, hexfont_info);
354 XSetForeground(display, hexgc, black);
355 XSetBackground(display, hexgc, DarkSlateGrey.pixel);
356 XMapWindow(display, win);
357 XFlush(display);
360 /* This sets up a gc
362 get_GC(win, tgc, tfont_info)
363 Window win;
364 GC *tgc;
365 XFontStruct *tfont_info;
367 unsigned long valuemask = 0;
368 XGCValues values;
369 unsigned int line_width = 2;
370 int line_style = LineSolid;
371 int cap_style = CapRound;
372 int join_style = JoinRound;
373 int dash_offset = 0;
374 static char dash_list[] = { 12, 24 };
375 int list_length = 2;
377 *tgc = XCreateGC(display, win, valuemask, &values);
378 XSetFont(display, *tgc, tfont_info->fid);
379 XSetForeground(display, *tgc, white);
380 XSetLineAttributes(display, *tgc, line_width, line_style, cap_style,
381 join_style);
382 XSetDashes(display, *tgc, dash_offset, dash_list, list_length);
385 /* This loads a font
387 load_font(tfont_info, font_name)
388 XFontStruct **tfont_info;
389 char *font_name;
391 if ((*tfont_info = XLoadQueryFont(display, font_name)) == NULL) {
392 (void)fprintf(stderr, "xhextris: Cannot open %s font.\n",font_name);
393 exit(-1);
397 /* This yells if the window is too small.
399 TooSmall()
401 char *string1 = "Too Small";
402 int y_offset, x_offset;
404 y_offset = font_info->max_bounds.ascent + 2;
405 x_offset = 2;
406 XDrawString(display, win, gc, x_offset, y_offset, string1,
407 strlen(string1));
410 /* This is required by hextris!
412 * This clears the window.
414 clear_display()
416 XClearWindow(display,win);
419 /* This is required by hextris!
421 * This displays the current score and rows completed.
423 display_scores(score,rows)
424 int *score, *rows;
426 int y_offset, x_offset;
427 char scores[40];
429 XSetFillStyle(display, gc, FillSolid);
430 sprintf(scores,"Score: %6d", *score);
431 y_offset = 160;
432 x_offset = (MAXCOLUMN + 1) * 20;
433 XClearArea(display,win,x_offset,y_offset-20,MAXCOLUMN*20, 50, False);
434 XDrawString(display, win, gc, x_offset, y_offset, scores,strlen(scores));
435 sprintf(scores,"Rows: %3d", *rows);
436 y_offset += 20;
437 XDrawString(display, win, gc, x_offset, y_offset, scores,strlen(scores));
438 XFlush(display);
441 /* This is required by hextris!
443 * This displays the help information.
445 display_help()
447 int y_offset, x_offset, i;
448 static char *message[] = { "The keys to press are:",
449 "J,j,4 - move left.",
450 "L,l,6 - move right.",
451 "K,k,5 - rotate ccw.",
452 "I,i,8 - rotate cw.",
453 "space,0 - drop.",
454 "N,n - new game.",
455 "P,p - pause game.",
456 "U,u - unpause game.",
457 "R,r - redisplay game.",
458 "H,h - show high scores.",
459 "G,g - show game.",
460 "Q,q - quit game.",
461 " ",
462 "--------------------",
463 "Created By:",
464 " David Markley",
465 "Font By:",
466 " Jon Slenk" };
469 XSetFillStyle(display, gc, FillSolid);
470 y_offset = 200;
471 x_offset = (MAXCOLUMN + 1) * 20;
472 for (i = 0; i < 19; i++)
473 XDrawString(display, win, gc, x_offset, y_offset+(i*17), message[i],
474 strlen(message[i]));
475 XFlush(display);
478 display_help_score()
480 int y_offset, x_offset, i;
481 static char *message[] = { "Keys:",
482 "N,n - new game.",
483 "G,g - show game.",
484 "Q,q - quit game."};
486 XSetFillStyle(display, gc, FillSolid);
487 y_offset = 200;
488 x_offset = (MAXCOLUMN + 1) * 26;
489 for (i = 0; i < 4; i++)
490 XDrawString(display, win, gc, x_offset, y_offset+(i*17), message[i],
491 strlen(message[i]));
492 XFlush(display);
495 /* This is required by hextris!
497 * This displays the high score list.
499 display_high_scores(high_scores)
500 high_score_t high_scores[MAXHIGHSCORES];
502 int y_offset, i;
503 static int x_offset[5] = {5,30,150,200,300};
504 static char *header[] = {"#","Name","UID","Score","Rows"};
505 char message[40] = "";
507 XClearWindow(display,win);
508 XSetFillStyle(display, gc, FillSolid);
509 y_offset = 40;
510 for (i = 0; i < 5; i++)
511 XDrawString(display, win, gc, x_offset[i], y_offset,
512 header[i],strlen(header[i]));
513 y_offset = 60;
514 for (i = 0; i < ((MAXHIGHSCORES > 40) ? 30 : MAXHIGHSCORES); i++) {
515 itoa(i+1,message);
516 XDrawString(display, win, gc, x_offset[0], y_offset+(i*17),
517 message,strlen(message));
518 XDrawString(display, win, gc, x_offset[1], y_offset+(i*17),
519 high_scores[i].name,strlen(high_scores[i].name));
520 strncpy(message, high_scores[i].userid, 5);
521 XDrawString(display, win, gc, x_offset[2], y_offset+(i*17),
522 message, strlen(message));
523 itoa(high_scores[i].score,message);
524 XDrawString(display, win, gc, x_offset[3], y_offset+(i*17),
525 message,strlen(message));
526 itoa(high_scores[i].rows,message);
527 XDrawString(display, win, gc, x_offset[4], y_offset+(i*17),
528 message,strlen(message));
530 XFlush(display);
533 /* This is required by hextris!
535 * This displays the next piece to be dropped.
537 show_next_piece(npiece)
538 piece_t *npiece;
540 piece_t tpiece;
542 tpiece.type = npiece->type;
543 tpiece.rotation = npiece->rotation;
544 tpiece.row = 1;
545 tpiece.column = MAXCOLUMN+6;
546 XClearArea(display,win,(MAXCOLUMN+3)*18,0,150,140, False);
547 init_piece(&tpiece, 0);
548 XFlush(display);
551 /* This is required by hextris!
553 * This draws one hex at the specified row and column specified.
555 draw_hex(row,column,fill,type)
556 int row,column,fill,type;
558 int y_offset, x_offset;
559 char hex[2];
561 x_offset = 20 + column * 16;
562 y_offset = 20 + row * 19 + (column & 1) * 9;
563 if (fill) {
564 strcpy(hex, "|");
565 switch (type) {
566 case 0:
567 XSetForeground(display, hexgc, Orange1.pixel);
568 XSetBackground(display, hexgc, Orange4.pixel);
569 break;
570 case 1:
571 XSetForeground(display, hexgc, Red1.pixel);
572 XSetBackground(display, hexgc, Red4.pixel);
573 break;
574 case 2:
575 XSetForeground(display, hexgc, Blue1.pixel);
576 XSetBackground(display, hexgc, Blue4.pixel);
577 break;
578 case 3:
579 XSetForeground(display, hexgc, Green1.pixel);
580 XSetBackground(display, hexgc, Green4.pixel);
581 break;
582 case 4:
583 XSetForeground(display, hexgc, Yellow1.pixel);
584 XSetBackground(display, hexgc, Yellow4.pixel);
585 break;
586 case 5:
587 XSetForeground(display, hexgc, Chocolate1.pixel);
588 XSetBackground(display, hexgc, Chocolate4.pixel);
589 break;
590 case 6:
591 XSetForeground(display, hexgc, Purple1.pixel);
592 XSetBackground(display, hexgc, Purple4.pixel);
593 break;
594 case 7:
595 XSetForeground(display, hexgc, SteelBlue1.pixel);
596 XSetBackground(display, hexgc, SteelBlue4.pixel);
597 break;
598 case 8:
599 XSetForeground(display, hexgc, Plum1.pixel);
600 XSetBackground(display, hexgc, Plum4.pixel);
601 break;
602 case 9:
603 XSetForeground(display, hexgc, Maroon1.pixel);
604 XSetBackground(display, hexgc, Maroon4.pixel);
605 break;
606 case 10:
607 XSetForeground(display, hexgc, Pink1.pixel);
608 XSetBackground(display, hexgc, Pink4.pixel);
609 break;
611 } else {
612 XSetForeground(display,hexgc,DarkSlateGrey.pixel);
613 XSetBackground(display, hexgc, DarkSlateGrey.pixel);
614 strcpy(hex,"}");
616 XDrawString(display, win, hexgc, x_offset, y_offset, hex, strlen(hex));
617 XFlush(display);
620 draw_pos(column,fill,type)
621 int column,fill,type;
623 int y_offset, x_offset;
624 char hex[2];
626 x_offset = 20 + column * 16;
627 y_offset = 20 + (MAXROW + 2) * 19 + (column & 1) * 9;
628 if (fill) {
629 strcpy(hex, "|");
630 switch (type) {
631 case 0:
632 XSetForeground(display, hexgc, Orange1.pixel);
633 XSetBackground(display, hexgc, Orange4.pixel);
634 break;
635 case 1:
636 XSetForeground(display, hexgc, Red1.pixel);
637 XSetBackground(display, hexgc, Red4.pixel);
638 break;
639 case 2:
640 XSetForeground(display, hexgc, Blue1.pixel);
641 XSetBackground(display, hexgc, Blue4.pixel);
642 break;
643 case 3:
644 XSetForeground(display, hexgc, Green1.pixel);
645 XSetBackground(display, hexgc, Green4.pixel);
646 break;
647 case 4:
648 XSetForeground(display, hexgc, Yellow1.pixel);
649 XSetBackground(display, hexgc, Yellow4.pixel);
650 break;
651 case 5:
652 XSetForeground(display, hexgc, Chocolate1.pixel);
653 XSetBackground(display, hexgc, Chocolate4.pixel);
654 break;
655 case 6:
656 XSetForeground(display, hexgc, Purple1.pixel);
657 XSetBackground(display, hexgc, Purple4.pixel);
658 break;
659 case 7:
660 XSetForeground(display, hexgc, SteelBlue1.pixel);
661 XSetBackground(display, hexgc, SteelBlue4.pixel);
662 break;
663 case 8:
664 XSetForeground(display, hexgc, Plum1.pixel);
665 XSetBackground(display, hexgc, Plum4.pixel);
666 break;
667 case 9:
668 XSetForeground(display, hexgc, Maroon1.pixel);
669 XSetBackground(display, hexgc, Maroon4.pixel);
670 break;
671 case 10:
672 XSetForeground(display, hexgc, Pink1.pixel);
673 XSetBackground(display, hexgc, Pink4.pixel);
674 break;
676 } else {
677 XSetForeground(display,hexgc,DarkSlateGrey.pixel);
678 XSetBackground(display, hexgc, DarkSlateGrey.pixel);
679 strcpy(hex,"}");
681 XDrawString(display, win, hexgc, x_offset, y_offset, hex, strlen(hex));
682 XFlush(display);
685 /* This is required by hextris!
687 * This ends the game by closing everything down and exiting.
689 end_game()
691 XFreeGC (display, gc);
692 XFreeGC (display, hexgc);
693 XDestroyWindow (display, win);
694 XCloseDisplay (display);
695 exit(0);