[comp.sources.x] v04i028: xtetris - X version of tetris, Part02/03

argv@island.uu.net (Dan Heller) (06/14/89)

Submitted-by: Didier Tallot <Tallot@bdblues.altair.fr>
Posting-number: Volume 4, Issue 28
Archive-name: xtetris/part02



#!/bin/sh
# this is part 2 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file main.c continued
#
CurArch=2
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file main.c"
sed 's/^X//' << 'SHAR_EOF' >> main.c
X                                           sub1_panel,
X                                           args, i);
X	i=0;
X	XtSetArg(args[i], XtNlabel, "Start"); i++;
X	start_bt = XtCreateManagedWidget("Start",
X                              XwpushButtonWidgetClass,
X                              sub2_panel,
X                              args, i);
X	XtAddCallback(start_bt, XtNrelease,start_proc,NULL);
X	i=0;
X	XtSetArg(args[i], XtNlabel, "Pause"); i++;
X        pause_bt = XtCreateManagedWidget("Pause",
X                              XwpushButtonWidgetClass,
X                              sub2_panel,
X                              args, i);
X	XtAddCallback(pause_bt, XtNrelease,pause_proc,NULL);
X	i=0;
X	XtSetArg(args[i], XtNlabel, "New Game"); i++;
X        newgame_bt = XtCreateManagedWidget("New Game",
X                              XwpushButtonWidgetClass,
X                              sub2_panel,
X                              args, i);
X	XtAddCallback(newgame_bt, XtNrelease,restart_proc,NULL);
X	i=0;
X	XtSetArg(args[i], XtNlabel, "Scores"); i++;
X        scores_bt = XtCreateManagedWidget("Scores",
X                              XwpushButtonWidgetClass,
X                              sub2_panel,
X                              args, i);
X	XtAddCallback(scores_bt, XtNrelease,print_high_scores,NULL);
X	i=0;
X	XtSetArg(args[i], XtNlabel, "Quit"); i++;
X        quit_bt = XtCreateManagedWidget("Quit",
X                              XwpushButtonWidgetClass,
X                              sub2_panel,
X                              args, i);
X	XtAddCallback(quit_bt, XtNrelease,quit_proc,NULL);
X	i=0;
X	XtSetArg(args[i], XtNwidgetType, XwWORK_SPACE); i++;
X	XtSetArg(args[i], XtNborderWidth, 0); i++;
X	XtSetArg(args[i], XtNwidth, UWIDTH * UNIT); i++;
X	XtSetArg(args[i], XtNheight, UHEIGHT * UNIT + SHADOW_HEIGHT + NEXT_HEIGHT); i++;
X        canvas = XtCreateManagedWidget("Canvas",
X                                       XwworkSpaceWidgetClass,
X                                       frame,
X                                       args, i);
X	XtAddCallback(canvas, XtNexpose, restore_canvas, NULL);
X
X	gc = DefaultGCOfScreen(XtScreen(toplevel));
X	XSetTile(XtDisplay(toplevel), gc,
X                 XwCreateTile(XtScreen(toplevel),~0,0,Xw50_FOREGROUND));
X
X        score_frame = XtCreatePopupShell("Score_frame",
X                                         transientShellWidgetClass,
X                                         frame,
X                                         NULL,0);
X        score_panel = XtCreateManagedWidget("Score_panel",
X                                            XwrowColWidgetClass,
X                                            score_frame,
X                                            NULL, 0);
X	i=0;
X        XtSetArg(args[i], XtNstring, " "); i++;
X	XtSetArg(args[i], XtNborderWidth, 0); i++;
X	XtSetArg(args[i], XtNstrip, FALSE); i++;
X        for (j = 0; j < HIGH_TABLE_SIZE + 1; j++)
X                high_score_item[j] = XtCreateManagedWidget("Score_item",
X                                                          XwstatictextWidgetClass,
X                                                          score_panel,
X                                                          args, i);
X        i=0;
X        XtSetArg(args[i], XtNlabel, "Done"); i++;
X        done_bt = XtCreateManagedWidget("Done",
X                              XwpushButtonWidgetClass,
X                              score_panel,
X                              args, i);
X        XtAddCallback(done_bt, XtNrelease,done_proc,NULL);
X        i=0;
X	XtSetArg(args[i], XtNstring, "Pos  Name             Score  Rows Lev  Machine     When "); i++;
X	XtSetValues(high_score_item[0],args,i);
X    	XtRealizeWidget(toplevel);
X	XtAddCallback(canvas, XtNresize, restore_canvas, NULL);
X        initialise();
X
X        XtMainLoop();
X}
SHAR_EOF
echo "File main.c is complete"
chmod 0644 main.c || echo "restore of main.c fails"
echo "x - extracting notify.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > notify.c &&
X#include "defs.h"
X
Xvoid
Xdrop_block(client_data, id)
X    caddr_t client_data;
X    XtIntervalId *id;
X
X{
X	start_timer();
X        if (block_can_drop(shape_no, xpos, ypos, rot))
X                print_shape(shape_no, xpos, ypos++, rot, WHITE);
X        else {
X                if (ypos < 0)
X                        end_game();
X                else {
X                        score += shape[shape_no].pointv[rot];
X                        store_shape(shape_no, xpos, ypos, rot);
X                        remove_full_lines(ypos);
X                        create_shape();
X                        show_score();
X                        show_next();
X                }
X        }
X        print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
X        draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
X}
X
Xshow_score(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        char    buf[BUFSIZ], buf1[BUFSIZ], buf2[BUFSIZ];
X	int j;
X
X        sprintf(buf, "Score: %d", score);
X        j=0;
X        XtSetArg(args[j], XtNstring, buf); j++;
X        XtSetValues(score_item,args,j);
X        sprintf(buf1, "Level: %d", rows / 10);
X        j=0;
X        XtSetArg(args[j], XtNstring, buf1); j++;
X        XtSetValues(level_item,args,j);
X        sprintf(buf2, "Rows : %d", rows);
X        j=0;
X        XtSetArg(args[j], XtNstring, buf2); j++;
X        XtSetValues(rows_item,args,j);
X}
X
Xvoid
Xquit_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        clear_events();
X        stop_timer();
X	XtDestroyWidget(toplevel);
X	exit(0);
X}
X
Xend_game(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X	int j;
X
X        end_of_game = 1;
X        clear_events();
X        stop_timer();
X        j=0;
X        XtSetArg(args[j], XtNstring, "Game Over"); j++;
X        XtSetValues(game_over,args,j);
X        update_highscore_table();
X	print_high_scores();
X}
X
Xvoid
Xrestart_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        clear_events();
X        stop_timer();
X        init_all();
X}
X
Xvoid
Xstart_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        if (end_of_game)
X                return;
X        set_events();
X        start_timer();
X}
X
Xvoid
Xpause_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        clear_events();
X        stop_timer();
X}
X
Xleft_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        if (block_can_left(shape_no, xpos, ypos, rot)) {
X                print_shape(shape_no, xpos, ypos, rot, WHITE);
X                xpos--;
X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
X                draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
X        }
X}
X
Xright_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        if (block_can_right(shape_no, xpos, ypos, rot)) {
X                print_shape(shape_no, xpos, ypos, rot, WHITE);
X                xpos++;
X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
X                draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
X        }
X}
X
Xanti_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        int     newrot;
X
X        newrot = (rot + 3) % 4;
X        if (check_rot(shape_no, xpos, ypos, newrot)) {
X                print_shape(shape_no, xpos, ypos, rot, WHITE);
X                rot = newrot;
X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
X                draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
X        }
X}
X
Xclock_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        int     newrot;
X
X        newrot = (rot + 1) % 4;
X        if (check_rot(shape_no, xpos, ypos, newrot)) {
X                print_shape(shape_no, xpos, ypos, rot, WHITE);
X                rot = newrot;
X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
X                draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
X        }
X}
X
Xfast_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X        while (block_can_drop(shape_no, xpos, ypos, rot)) {
X                print_shape(shape_no, xpos, ypos, rot, WHITE);
X                ypos++;
X                print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
X        }
X}
X
Xvoid
Xdone_proc(w, client_data, call_data)
X    Widget w;
X    caddr_t client_data;
X    caddr_t call_data;
X{
X	XtPopdown(score_frame);
X}
SHAR_EOF
chmod 0644 notify.c || echo "restore of notify.c fails"
echo "x - extracting score.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > score.c &&
X#include "defs.h"
X
Xupdate_highscore_table()
X{
X    /* This version only allows 1 entry in the HIGH SCORE TABLE per user */
X        int     i, j;
X        long    when;
X        extern char *ctime();
X        extern long time();
X        char    hostname[20];
X        char    buf[BUFSIZ];
X
X        /* re-read high-score table in case someone else on the network is
X         * playing at the same time */
X        read_high_scores();
X
X        /* Check for previous best score */
X        for (i = 0; (i < HIGH_TABLE_SIZE) && (strcmp(name, high_scores[i].name) != 0); i++);
X        if (i < HIGH_TABLE_SIZE) {
X                if (high_scores[i].score >= score)
X                        return;         /* Same/worse score - no update */
X                for (j = i; j > 0; j--) /* Remove previous best */
X                        high_scores[j] = high_scores[j - 1];
X        }
X        /* Next line finds score greater than current one */
X        for (i = 0; ((i < HIGH_TABLE_SIZE) && (score >= high_scores[i].score)); i++);
X        i--;
X        if (i >= 0) {
X                for (j = 0; j < i; j++)
X                        high_scores[j] = high_scores[j + 1];
X                strcpy(high_scores[i].name, name);
X                high_scores[i].score = score;
X                high_scores[i].rows = rows;
X                high_scores[i].level = rows / 10;
X                if (gethostname(hostname, BUFSIZ) == -1)
X                        strcpy(high_scores[i].hostname, "unknown-host");
X                else
X                        strcpy(high_scores[i].hostname, hostname);
X                time(&when);
X                strcpy(buf, ctime(&when));      /* ctime() adds a newline
X                                                 * char */
X                strip_eoln(buf);                /* so remove it */
X                strcpy(high_scores[i].date, buf);
X                write_high_scores();
X        }
X}
X
X
Xread_high_scores()
X{
X        FILE   *fp;
X        int     i;
X        char   *c, buf[BUFSIZ];
X
X        for (i = 0; i < HIGH_TABLE_SIZE; i++) {
X                strcpy(high_scores[i].name, " ");
X                high_scores[i].score = 0;
X                high_scores[i].rows = 0;
X                high_scores[i].level = 0;
X                strcpy(high_scores[i].hostname, " ");
X                strcpy(high_scores[i].date, " ");
X        }
X        if ((fp = fopen(HIGH_SCORE_TABLE, "r")) == NULL) {
X                fprintf(stderr, "tetris: No High score file\n");
X                return;
X        }
X        for (i = 0; i < HIGH_TABLE_SIZE; i++) {
X                fgets(buf, BUFSIZ, fp);
X                strip_eoln(buf);
X                strcpy(high_scores[i].name, buf);
X                fgets(buf, BUFSIZ, fp);
X                strip_eoln(buf);
X                high_scores[i].score = atoi(buf);
X                fgets(buf, BUFSIZ, fp);
X                strip_eoln(buf);
X                high_scores[i].rows = atoi(buf);
X                fgets(buf, BUFSIZ, fp);
X                strip_eoln(buf);
X                high_scores[i].level = atoi(buf);
X                fgets(buf, BUFSIZ, fp);
X                strip_eoln(buf);
X                strcpy(high_scores[i].hostname, buf);
X                fgets(buf, BUFSIZ, fp);
X                strip_eoln(buf);
X                strcpy(high_scores[i].date, buf);
X        }
X        fclose(fp);
X}
X
Xstrip_eoln(s)
X        char   *s;
X{
X        char   *s1;
X
X        while (*s != '\0') {
X                if (*s == '\n') {       /* End of line char */
X                        s1 = s;
X                        do {
X                                *s1 = *(s1 + 1);        /* Copy rest of string */
X                                s1++;
X                        } while (*s1 != '\0');
X                } else
X                        s++;
X        }
X}
X
Xwrite_high_scores()
X{
X        FILE   *fp;
X        int     i;
X
X        if ((fp = fopen(HIGH_SCORE_TABLE, "w")) == NULL) {
X                fprintf(stderr, "tetris: Couldn't open high score file %s\n", HIGH_SCORE_TABLE);
X                return;
X        }
X        for (i = 0; i < HIGH_TABLE_SIZE; i++)
X                fprintf(fp, "%s\n%d\n%d\n%d\n%s\n%s\n",
X                        high_scores[i].name,
X                        high_scores[i].score,
X                        high_scores[i].rows,
X                        high_scores[i].level,
X                        high_scores[i].hostname,
X                        high_scores[i].date);
X        fclose(fp);
X}
X
Xvoid
Xprint_high_scores()
X{
X        int     i,j;
X        char    buf[BUFSIZ];
X
X        /* re-read high-score table in case someone else on the network is
X         * playing at the same time */
X        read_high_scores();
X
X        for (i = HIGH_TABLE_SIZE - 1; i >= 0; i--) {
X                sprintf(buf, "%3d) %-15s %6d %5d %3d  %-10s  %s \n",
X                        HIGH_TABLE_SIZE - i,
X                        high_scores[i].name,
X                        high_scores[i].score,
X                        high_scores[i].rows,
X                        high_scores[i].level,
X                        high_scores[i].hostname,
X                        high_scores[i].date);
X                j=0;
X                XtSetArg(args[j], XtNstring, buf); j++;
X                XtSetValues(high_score_item[HIGH_TABLE_SIZE - i],args,j);
X        }
X	XtPopup(score_frame, XtGrabExclusive);
X}
X
Xprint_authors()
X{
X	printf("This version of Tetris was written by Didier Tallot <tallot@bdblues.altair.fr>\nfor X windows with the HP Widgets set.\n");
X        printf("Based on the version by Phill Everson <everson@cs.bris.ac.uk>\nand Martyn Shortley <shortley@cs.bris.ac.uk>,\n");
X        printf("Based on the version posted to comp.sources.games by Adam Marguilies <vespa@ssyx.ucsc.edu>\n\nLet us know if you like it.\n");
X}
SHAR_EOF
chmod 0644 score.c || echo "restore of score.c fails"
echo "x - extracting shape.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > shape.c &&
X#include "defs.h"
X
Xvoid define_shapes()
X{
X
X    /* begin shape 0 definition, four rotations */
X
X    shape[0].table[0][0] = 0;  
X    shape[0].table[1][0] = 15;  /* #### */
X    shape[0].table[2][0] = 0; 
X    shape[0].table[3][0] = 0; 
X    shape[0].pointv[0] = 5; 
X
X    shape[0].table[0][1] = 4;   /*  #   */
X    shape[0].table[1][1] = 4;   /*  #   */
X    shape[0].table[2][1] = 4;   /*  #   */
X    shape[0].table[3][1] = 4;   /*  #   */
X    shape[0].pointv[1] = 8; 
X
X    shape[0].table[0][2] = 0; 
X    shape[0].table[1][2] = 15; /* #### */
X    shape[0].table[2][2] = 0; 
X    shape[0].table[3][2] = 0; 
X    shape[0].pointv[2] = 5; 
X
X    shape[0].table[0][3] = 4;   /*  #    */
X    shape[0].table[1][3] = 4;   /*  #    */
X    shape[0].table[2][3] = 4;   /*  #    */
X    shape[0].table[3][3] = 4;   /*  #    */
X    shape[0].pointv[3] = 8; 
X
X    shape[0].width = 4; 
X    shape[0].height = 1; 
X    shape[0].offset = 153;
X    shape[0].color = RED;
X
X    /* begin shape 1 definition, four rotations */
X
X    shape[1].table[0][0] = 12;  /* ##   */
X    shape[1].table[1][0] = 12;  /* ##   */
X    shape[1].table[2][0] = 0;   /*      */
X    shape[1].table[3][0] = 0;   /*      */
X    shape[1].pointv[0] = 6; 
X
X    shape[1].table[0][1] = 12;  /* ##   */
X    shape[1].table[1][1] = 12;  /* ##   */
X    shape[1].table[2][1] = 0;   /*      */
X    shape[1].table[3][1] = 0;   /*      */
X    shape[1].pointv[1] = 6; 
X
X    shape[1].table[0][2] = 12;  /* ##   */
X    shape[1].table[1][2] = 12;  /* ##   */
X    shape[1].table[2][2] = 0;   /*      */
X    shape[1].table[3][2] = 0;   /*      */
X    shape[1].pointv[2] = 6; 
X
X    shape[1].table[0][3] = 12;  /* ##   */
X    shape[1].table[1][3] = 12;  /* ##   */
X    shape[1].table[2][3] = 0;   /*      */
X    shape[1].table[3][3] = 0;   /*      */
X    shape[1].pointv[3] = 6; 
X
X    shape[1].width = 2; 
X    shape[1].height = 2; 
X    shape[1].offset = 0;
X    shape[1].color = ORANGE;
X
X    /* begin shape 2 definition, four rotations */
X
X    shape[2].table[0][0] = 4;  /*  #  */
X    shape[2].table[1][0] = 14; /* ### */
X    shape[2].table[2][0] = 0;  /*     */
X    shape[2].table[3][0] = 0;  /*     */
X    shape[2].pointv[0] = 5; 
X
X    shape[2].table[0][1] = 4;  /*  #  */
X    shape[2].table[1][1] = 6;  /*  ## */
X    shape[2].table[2][1] = 4;  /*  #  */
X    shape[2].table[3][1] = 0;  /*     */
X    shape[2].pointv[1] = 5; 
X
X    shape[2].table[0][2] = 0;  /*     */
X    shape[2].table[1][2] = 14; /* ### */
X    shape[2].table[2][2] = 4;  /*  #  */
X    shape[2].table[3][2] = 0;  /*     */
X    shape[2].pointv[2] = 6; 
X
X    shape[2].table[0][3] = 4;  /*  #  */
X    shape[2].table[1][3] = 12; /* ##  */
X    shape[2].table[2][3] = 4;  /*  #  */
X    shape[2].table[3][3] = 0;  /*     */
X    shape[2].pointv[3] = 5; 
X
X    shape[2].width = 3; 
X    shape[2].height = 2; 
X    shape[2].offset = 24;
X    shape[2].color = YELLOW;
X
X    /* begin shape 3 definition, four rotations */
X
X    shape[3].table[0][0] = 12; /* ##  */
X    shape[3].table[1][0] = 6;  /*  ## */
X    shape[3].table[2][0] = 0;  /*     */
X    shape[3].table[3][0] = 0;  /*     */
X    shape[3].pointv[0] = 6; 
X
X    shape[3].table[0][1] = 4;  /*  #  */
X    shape[3].table[1][1] = 12; /* ##  */
X    shape[3].table[2][1] = 8;  /* #   */
X    shape[3].table[3][1] = 0;  /*     */
X    shape[3].pointv[1] = 7; 
X
X    shape[3].table[0][2] = 12; /* ##  */
X    shape[3].table[1][2] = 6;  /*  ## */
X    shape[3].table[2][2] = 0;  /*     */
X    shape[3].table[3][2] = 0;  /*     */
X    shape[3].pointv[2] = 6; 
X
X    shape[3].table[0][3] = 4;  /*  #  */
X    shape[3].table[1][3] = 12; /* ##  */
X    shape[3].table[2][3] = 8;  /* #   */
X    shape[3].table[3][3] = 0;  /*     */
X    shape[3].pointv[3] = 7; 
X
X    shape[3].width = 3; 
X    shape[3].height = 2; 
X    shape[3].offset = 0;
X    shape[3].color = GREEN;
X
X    /* begin shape 4 definition, four rotations */
X
X    shape[4].table[0][0] = 6;  /*  ## */
X    shape[4].table[1][0] = 12; /* ##  */
X    shape[4].table[2][0] = 0;  /*     */
X    shape[4].table[3][0] = 0;  /*     */
X    shape[4].pointv[0] = 6; 
X
X    shape[4].table[0][1] = 8;  /* #   */
X    shape[4].table[1][1] = 12; /* ##  */
X    shape[4].table[2][1] = 4;  /*  #  */
X    shape[4].table[3][1] = 0;  /*     */
X    shape[4].pointv[1] = 7; 
X
X    shape[4].table[0][2] = 6;  /*  ## */
X    shape[4].table[1][2] = 12; /* ##  */
X    shape[4].table[2][2] = 0;  /*     */
X    shape[4].table[3][2] = 0;  /*     */
X    shape[4].pointv[2] = 6; 
X
X    shape[4].table[0][3] = 8;  /* #   */
X    shape[4].table[1][3] = 12; /* ##  */
X    shape[4].table[2][3] = 4;  /*  #  */
X    shape[4].table[3][3] = 0;  /*     */
X    shape[4].pointv[3] = 7; 
X
X    shape[4].width = 3; 
X    shape[4].height = 2; 
X    shape[4].offset = 0;
X    shape[4].color = BLUE;
X
X    /* begin shape 5 definition, four rotations */
X
X    shape[5].table[0][0] = 2;  /*   # */
X    shape[5].table[1][0] = 14; /* ### */
X    shape[5].table[2][0] = 0;  /*     */
X    shape[5].table[3][0] = 0;  /*     */
X    shape[5].pointv[0] = 6; 
X
X    shape[5].table[0][1] = 8;  /* #   */
X    shape[5].table[1][1] = 8;  /* #   */
X    shape[5].table[2][1] = 12; /* ##  */
X    shape[5].table[3][1] = 0;  /*     */
X    shape[5].pointv[1] = 7; 
X
X    shape[5].table[0][2] = 14; /* ### */
X    shape[5].table[1][2] = 8;  /* #   */
X    shape[5].table[2][2] = 0;  /*     */
X    shape[5].table[3][2] = 0;  /*     */
X    shape[5].pointv[2] = 6; 
X
X    shape[5].table[0][3] = 12; /* ##  */
X    shape[5].table[1][3] = 4;  /*  #  */
X    shape[5].table[2][3] = 4;  /*  #  */
X    shape[5].table[3][3] = 0;  /*     */
X    shape[5].pointv[3] = 7; 
X
X    shape[5].width = 3; 
X    shape[5].height = 2; 
X    shape[5].offset = 0;
X    shape[5].color = CYAN;
X
X    /* begin shape 6 definition, four rotations */
X
X    shape[6].table[0][0] = 14; /* ### */
X    shape[6].table[1][0] = 2;  /*   # */
X    shape[6].table[2][0] = 0;  /*     */
X    shape[6].table[3][0] = 0;  /*     */
X    shape[6].pointv[0] = 6; 
X
X    shape[6].table[0][1] = 4;  /*  #  */
X    shape[6].table[1][1] = 4;  /*  #  */
X    shape[6].table[2][1] = 12; /* ##  */
X    shape[6].table[3][1] = 0;  /*     */
X    shape[6].pointv[1] = 7; 
X
X    shape[6].table[0][2] = 8;  /* #   */
X    shape[6].table[1][2] = 14; /* ### */
X    shape[6].table[2][2] = 0;  /*     */
X    shape[6].table[3][2] = 0;  /*     */
X    shape[6].pointv[2] = 6; 
X
X    shape[6].table[0][3] = 12; /* ##  */
X    shape[6].table[1][3] = 8;  /* #   */
X    shape[6].table[2][3] = 8;  /* #   */
X    shape[6].table[3][3] = 0;  /*     */
X    shape[6].pointv[3] = 7; 
X
X    shape[6].width = 3; 
X    shape[6].height = 2; 
X    shape[6].offset = 0;
X    shape[6].color = VIOLET;
X}
X
Xstore_shape(shape_no, xpos, ypos, rot)
X        int     shape_no, xpos, ypos, rot;
X{
X        int     i;
X
X        for (i = 0; i < 4; i++) {
X                if (shape[shape_no].table[i][rot] & 8)
X                        grid[xpos][ypos + i] = 1;
X                if (shape[shape_no].table[i][rot] & 4)
X                        grid[xpos + 1][ypos + i] = 1;
X                if (shape[shape_no].table[i][rot] & 2)
X                        grid[xpos + 2][ypos + i] = 1;
X                if (shape[shape_no].table[i][rot] & 1)
X                        grid[xpos + 3][ypos + i] = 1;
X        }
X}
X
Xcreate_shape()
X{
X		shape_no = next_no;
X		rot = next_rot;
X        next_no = rand() % 7;
X        next_rot = rand() % 4;
X        xpos = (UWIDTH / 2) - 1;
X        ypos = -4;
X}
X
SHAR_EOF
chmod 0644 shape.c || echo "restore of shape.c fails"
echo "x - extracting support.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > support.c &&
X#include "defs.h"
X
Xblock_can_drop(shape_no, xpos, ypos, rot)
X        int     shape_no, xpos, ypos, rot;
X{
X        int     y1, c;
X
X        c = 3;
X
X        while ((c >= 0) && ((shape[shape_no].table[c][rot] & 8) == 0))
X                c--;
X        y1 = ypos + c + 1;
X        if ((c != -1) && (y1 >= 0))
X                if ((y1 == UHEIGHT) || (grid[xpos][y1] != 0))
X                        return (FALSE);
X
X        c = 3;
X        while ((c >= 0) && ((shape[shape_no].table[c][rot] & 4) == 0))
X                c--;
X        y1 = ypos + c + 1;
X        if ((c != -1) && (y1 >= 0))
X                if ((y1 == UHEIGHT) || (grid[xpos + 1][y1] != 0))
X                        return (FALSE);
X
X        c = 3;
X        while ((c >= 0) && ((shape[shape_no].table[c][rot] & 2) == 0))
X                c--;
X        y1 = ypos + c + 1;
X        if ((c != -1) && (y1 >= 0))
X                if ((y1 == UHEIGHT) || (grid[xpos + 2][y1] != 0))
X                        return (FALSE);
X
X        c = 3;
X        while ((c >= 0) && ((shape[shape_no].table[c][rot] & 1) == 0))
X                c--;
X        y1 = ypos + c + 1;
X        if ((c != -1) && (y1 >= 0))
X                if ((y1 == UHEIGHT) || (grid[xpos + 3][y1] != 0))
X                        return (FALSE);
X
X        return TRUE;
X}
X
Xblock_can_left(shape_no, xpos, ypos, rot)
SHAR_EOF
echo "End of part 2"
echo "File support.c is continued in part 3"
echo "3" > s2_seq_.tmp
exit 0