home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / games / volume15 / gtetris3 / patch1 / patches01
Text File  |  1993-01-27  |  26KB  |  963 lines

  1. diff -c tetris.2.0/README tetris.2.1/README
  2. *** tetris.2.0/README    Fri Jan 15 13:04:29 1993
  3. --- tetris.2.1/README    Fri Jan 15 15:59:59 1993
  4. ***************
  5. *** 1,5
  6.       GENERIC TETRIS
  7. !     ==============    Yet Another Tetris Game on X, V2.0.1
  8.   
  9.   
  10.   WHY ANOTHER?
  11.  
  12. --- 1,5 -----
  13.       GENERIC TETRIS
  14. !     ==============    Yet Another Tetris Game on X, V2.1.0
  15.   
  16.   
  17.   WHY ANOTHER?
  18. ***************
  19. *** 81,86
  20.   
  21.       Since the days of V1.8, I have got many responses over the net.
  22.       Thanks go to people who helped me in improving the program.
  23.   
  24.     [Jan 12, 93]  V2.0.1: added arrow keys. Changed error handling method
  25.           in locking score file, suggested by Hellmut Golde
  26.  
  27. --- 81,93 -----
  28.   
  29.       Since the days of V1.8, I have got many responses over the net.
  30.       Thanks go to people who helped me in improving the program.
  31. +   [Jan 15, 93]  V2.1.0: Fixed a resource look-up bug found by Kiyotaka
  32. +         Sakai <ksakai@mtl.t.u-tokyo.ac.jp>. Added "-u" option.
  33. +         New feature: when a row is deleted, remaining blocks
  34. +         remains rounded -- suggested by Elwood C. Downey
  35. +         <ecdowney@hwking.cca.cr.rockwell.com> and Bill Leue
  36. +         <leue@crd.ge.com>.
  37.   
  38.     [Jan 12, 93]  V2.0.1: added arrow keys. Changed error handling method
  39.           in locking score file, suggested by Hellmut Golde
  40. Common subdirectories: tetris.2.0/X11 and tetris.2.1/X11
  41. Common subdirectories: tetris.2.0/bitmaps and tetris.2.1/bitmaps
  42. diff -c tetris.2.0/playing.c tetris.2.1/playing.c
  43. *** tetris.2.0/playing.c    Fri Jan 15 13:04:31 1993
  44. --- tetris.2.1/playing.c    Fri Jan 15 15:46:35 1993
  45. ***************
  46. *** 27,32
  47.   #include    "tetris.h"
  48.   
  49.   static Bool     paused = False;
  50.   
  51.   static int      speeds[NUM_LEVELS] = {
  52.       100, 92, 84, 76, 68, 60, 53, 46, 39, 32, 26, 20, 15, 10, 6, 3, 1, 0};
  53.  
  54. --- 27,33 -----
  55.   #include    "tetris.h"
  56.   
  57.   static Bool     paused = False;
  58. + static Bool     firstFall = False;
  59.   
  60.   static int      speeds[NUM_LEVELS] = {
  61.   100, 92, 84, 76, 68, 60, 53, 46, 39, 32, 26, 20, 15, 10, 6, 3, 1, 0};
  62. ***************
  63. *** 29,35
  64.   static Bool     paused = False;
  65.   
  66.   static int      speeds[NUM_LEVELS] = {
  67. !     100, 92, 84, 76, 68, 60, 53, 46, 39, 32, 26, 20, 15, 10, 6, 3, 1, 0};
  68.   static int      thresh[NUM_LEVELS] = {
  69.       10, 20, 30, 40, 50, 60, 70, 80, 90,
  70.       100, 110, 120, 130, 140, 150, 160, 170, 180};
  71.  
  72. --- 30,36 -----
  73.   static Bool     firstFall = False;
  74.   
  75.   static int      speeds[NUM_LEVELS] = {
  76. ! 100, 92, 84, 76, 68, 60, 53, 46, 39, 32, 26, 20, 15, 10, 6, 3, 1, 0};
  77.   static int      thresh[NUM_LEVELS] = {
  78.       10, 20, 30, 40, 50, 60, 70, 80, 90,
  79.   100, 110, 120, 130, 140, 150, 160, 170, 180};
  80. ***************
  81. *** 32,38
  82.       100, 92, 84, 76, 68, 60, 53, 46, 39, 32, 26, 20, 15, 10, 6, 3, 1, 0};
  83.   static int      thresh[NUM_LEVELS] = {
  84.       10, 20, 30, 40, 50, 60, 70, 80, 90,
  85. !     100, 110, 120, 130, 140, 150, 160, 170, 180};
  86.   
  87.   static struct timeval nextFall, now, delay;
  88.   static struct timezone tzone = {0, 0};
  89.  
  90. --- 33,39 -----
  91.   100, 92, 84, 76, 68, 60, 53, 46, 39, 32, 26, 20, 15, 10, 6, 3, 1, 0};
  92.   static int      thresh[NUM_LEVELS] = {
  93.       10, 20, 30, 40, 50, 60, 70, 80, 90,
  94. ! 100, 110, 120, 130, 140, 150, 160, 170, 180};
  95.   
  96.   static struct timeval nextFall, now, delay;
  97.   static struct timezone tzone = {0, 0};
  98. ***************
  99. *** 43,48
  100.   playing()
  101.   {
  102.       Bool            resetTime = True;
  103.   
  104.       score = prefilled * level * 10;
  105.       while (True) {
  106.  
  107. --- 44,50 -----
  108.   playing()
  109.   {
  110.       Bool            resetTime = True;
  111. +     int             conNum = ConnectionNumber(display);
  112.   
  113.       score = prefilled * level * 10;
  114.       while (True) {
  115. ***************
  116. *** 52,58
  117.           realTime(&nextFall);
  118.       } else {
  119.           int             writefd = 0, exceptfd = 0;
  120. !         int             readfd = 1 << ConnectionNumber(display);
  121.   
  122.           (void) gettimeofday(&now, &tzone);
  123.           delay.tv_sec = nextFall.tv_sec - now.tv_sec;
  124.  
  125. --- 54,60 -----
  126.           realTime(&nextFall);
  127.       } else {
  128.           int             writefd = 0, exceptfd = 0;
  129. !         int             readfd = 1 << conNum;
  130.   
  131.           (void) gettimeofday(&now, &tzone);
  132.           delay.tv_sec = nextFall.tv_sec - now.tv_sec;
  133. ***************
  134. *** 58,65
  135.           delay.tv_sec = nextFall.tv_sec - now.tv_sec;
  136.           delay.tv_usec = nextFall.tv_usec - now.tv_usec;
  137.           realTime(&delay);
  138. !         if (delay.tv_sec >= 0) {    /* sleep */
  139. !         (void) select(sizeof(int) * 8, (fd_set *) &readfd,
  140.                  (fd_set *) & writefd, (fd_set *) & exceptfd, &delay);
  141.           }
  142.       }
  143.  
  144. --- 60,69 -----
  145.           delay.tv_sec = nextFall.tv_sec - now.tv_sec;
  146.           delay.tv_usec = nextFall.tv_usec - now.tv_usec;
  147.           realTime(&delay);
  148. !         if ((delay.tv_sec > 0) ||
  149. !             ((delay.tv_sec == 0) && (delay.tv_usec > 0))) {
  150. !         /* sleep */
  151. !         (void) select(conNum + 1, (fd_set *) & readfd,
  152.                  (fd_set *) & writefd, (fd_set *) & exceptfd, &delay);
  153.           }
  154.       }
  155. ***************
  156. *** 66,72
  157.       (void) gettimeofday(&now, &tzone);
  158.       if ((now.tv_sec > nextFall.tv_sec) ||
  159.           ((now.tv_sec == nextFall.tv_sec) &&
  160. !         (now.tv_usec > nextFall.tv_usec))) {
  161.           (void) evGotNewThing(True);
  162.           resetTime = True;
  163.       } else {
  164.  
  165. --- 70,76 -----
  166.       (void) gettimeofday(&now, &tzone);
  167.       if ((now.tv_sec > nextFall.tv_sec) ||
  168.           ((now.tv_sec == nextFall.tv_sec) &&
  169. !          (now.tv_usec > nextFall.tv_usec))) {
  170.           (void) evGotNewThing(True);
  171.           resetTime = True;
  172.           firstFall = True;
  173. ***************
  174. *** 69,74
  175.           (now.tv_usec > nextFall.tv_usec))) {
  176.           (void) evGotNewThing(True);
  177.           resetTime = True;
  178.       } else {
  179.           resetTime = evGotNewThing(False);
  180.       }
  181.  
  182. --- 73,79 -----
  183.            (now.tv_usec > nextFall.tv_usec))) {
  184.           (void) evGotNewThing(True);
  185.           resetTime = True;
  186. +         firstFall = True;
  187.       } else {
  188.           resetTime = evGotNewThing(False);
  189.       }
  190. ***************
  191. *** 72,77
  192.       } else {
  193.           resetTime = evGotNewThing(False);
  194.       }
  195.       }
  196.       /* never come to here */
  197.   }
  198.  
  199. --- 77,84 -----
  200.       } else {
  201.           resetTime = evGotNewThing(False);
  202.       }
  203. +     if (paused)
  204. +         resetTime = True;
  205.       }
  206.       /* never come to here */
  207.   }
  208. ***************
  209. *** 203,210
  210.           break;
  211.   
  212.       case FocusOut:
  213. !         paused = True;
  214. !         banner(MSG_PAUSED);
  215.           break;
  216.   
  217.       case Expose:
  218.  
  219. --- 210,219 -----
  220.           break;
  221.   
  222.       case FocusOut:
  223. !         if (firstFall) {
  224. !         paused = True;
  225. !         banner(MSG_PAUSED);
  226. !         }
  227.           break;
  228.   
  229.       case Expose:
  230. ***************
  231. *** 260,266
  232.       score += (showNext ? 3 : 5) * level * level * lines * lines;
  233.       rows += lines;
  234.       if (rows > thresh[level])
  235. !         level ++;
  236.       drawStatus();
  237.       newThing();
  238.       if (showNext) {
  239.  
  240. --- 269,275 -----
  241.       score += (showNext ? 3 : 5) * level * level * lines * lines;
  242.       rows += lines;
  243.       if (rows > thresh[level])
  244. !         level++;
  245.       drawStatus();
  246.       newThing();
  247.       if (showNext) {
  248. ***************
  249. *** 267,275
  250.           clearNext();
  251.           drawNext();
  252.       }
  253. !     XSync(display, False);
  254. !     while (XPending(display))
  255. !         XNextEvent(display, &ev);
  256.       if (overlapping())
  257.           gameOver();
  258.       drawThing();
  259.  
  260. --- 276,282 -----
  261.           clearNext();
  262.           drawNext();
  263.       }
  264. !     XSync(display, True);    /* discard all events */
  265.       if (overlapping())
  266.           gameOver();
  267.       drawThing();
  268. ***************
  269. *** 277,283
  270.       } else {
  271.       tryMove(move);
  272.       if (rows > thresh[level]) {
  273. !         level ++;
  274.           drawStatus();
  275.       }
  276.       return False;
  277.  
  278. --- 284,290 -----
  279.       } else {
  280.       tryMove(move);
  281.       if (rows > thresh[level]) {
  282. !         level++;
  283.           drawStatus();
  284.       }
  285.       return False;
  286. ***************
  287. *** 311,317
  288.       (void) fprintf(stderr, "Cannot write the score-file!\n");
  289.       return;
  290.       }
  291.       /* lock */
  292.       (void) strcpy(lockfile, SCOREFILE);
  293.       (void) strcat(lockfile, ".lock");
  294.  
  295. --- 318,323 -----
  296.       (void) fprintf(stderr, "Cannot write the score-file!\n");
  297.       return;
  298.       }
  299.       /* lock */
  300.       (void) strcpy(lockfile, SCOREFILE);
  301.       (void) strcat(lockfile, ".lock");
  302. ***************
  303. *** 316,322
  304.       (void) strcpy(lockfile, SCOREFILE);
  305.       (void) strcat(lockfile, ".lock");
  306.       while (((lfd = open(lockfile, O_CREAT | O_EXCL, 0644)) < 0) &&
  307. !         errno == EEXIST)
  308.       sleep(1);
  309.   
  310.       if (lfd < 0) {
  311.  
  312. --- 322,328 -----
  313.       (void) strcpy(lockfile, SCOREFILE);
  314.       (void) strcat(lockfile, ".lock");
  315.       while (((lfd = open(lockfile, O_CREAT | O_EXCL, 0644)) < 0) &&
  316. !         errno == EEXIST)
  317.       sleep(1);
  318.   
  319.       if (lfd < 0) {
  320. ***************
  321. *** 324,330
  322.       (void) fprintf(stderr, "Score not recorded - sorry.\n");
  323.       return;
  324.       }
  325.       tmp = 0;
  326.       ptmp = 1;
  327.       bcopy((char *) &myscore, buff[1], SCORESIZE);
  328.  
  329. --- 330,335 -----
  330.       (void) fprintf(stderr, "Score not recorded - sorry.\n");
  331.       return;
  332.       }
  333.       tmp = 0;
  334.       ptmp = 1;
  335.       bcopy((char *) &myscore, buff[1], SCORESIZE);
  336. ***************
  337. *** 330,336
  338.       bcopy((char *) &myscore, buff[1], SCORESIZE);
  339.   
  340.       while (read(fd, buff[tmp], SCORESIZE) == SCORESIZE) {
  341. !     sscanf(((score_t *)buff[tmp])->score, " %d", &s1);
  342.       if (!saved && (s1 <= score)) {
  343.           trickle = True;
  344.           saved = True;
  345.  
  346. --- 335,341 -----
  347.       bcopy((char *) &myscore, buff[1], SCORESIZE);
  348.   
  349.       while (read(fd, buff[tmp], SCORESIZE) == SCORESIZE) {
  350. !     sscanf(((score_t *) buff[tmp])->score, " %d", &s1);
  351.       if (!saved && (s1 <= score)) {
  352.           trickle = True;
  353.           saved = True;
  354. ***************
  355. *** 337,343
  356.           mycount++;
  357.       }
  358.       if (!strncmp(myscore.myname, ((score_t *) buff[tmp])->myname,
  359. !         NAMELEN)) {
  360.           mycount++;
  361.       }
  362.       /* Then check if we should trickle the score */
  363.  
  364. --- 342,348 -----
  365.           mycount++;
  366.       }
  367.       if (!strncmp(myscore.myname, ((score_t *) buff[tmp])->myname,
  368. !              NAMELEN)) {
  369.           mycount++;
  370.       }
  371.       /* Then check if we should trickle the score */
  372. ***************
  373. *** 342,348
  374.       }
  375.       /* Then check if we should trickle the score */
  376.       if (trickle) {
  377. !         lseek(fd, (off_t) -SCORESIZE, SEEK_CUR);
  378.           write(fd, buff[ptmp], SCORESIZE);
  379.           ptmp = tmp;
  380.           tmp = (tmp + 1) % 2;
  381.  
  382. --- 347,353 -----
  383.       }
  384.       /* Then check if we should trickle the score */
  385.       if (trickle) {
  386. !         lseek(fd, (off_t) - SCORESIZE, SEEK_CUR);
  387.           write(fd, buff[ptmp], SCORESIZE);
  388.           ptmp = tmp;
  389.           tmp = (tmp + 1) % 2;
  390. ***************
  391. *** 347,352
  392.           ptmp = tmp;
  393.           tmp = (tmp + 1) % 2;
  394.       }
  395.       /*
  396.        * As we trickle, we add up records owned by me. Once we hit max,
  397.        * we throw it away, and stop trickling.
  398.  
  399. --- 352,358 -----
  400.           ptmp = tmp;
  401.           tmp = (tmp + 1) % 2;
  402.       }
  403.       /*
  404.        * As we trickle, we add up records owned by me. Once we hit max, we
  405.        * throw it away, and stop trickling.
  406. ***************
  407. *** 348,355
  408.           tmp = (tmp + 1) % 2;
  409.       }
  410.       /*
  411. !      * As we trickle, we add up records owned by me. Once we hit max,
  412. !      * we throw it away, and stop trickling.
  413.        */
  414.       if ((mycount > MAXSCORES) || ((mycount == MAXSCORES) && !trickle)) {
  415.           trickle = False;
  416.  
  417. --- 354,361 -----
  418.       }
  419.   
  420.       /*
  421. !      * As we trickle, we add up records owned by me. Once we hit max, we
  422. !      * throw it away, and stop trickling.
  423.        */
  424.       if ((mycount > MAXSCORES) || ((mycount == MAXSCORES) && !trickle)) {
  425.           trickle = False;
  426. ***************
  427. *** 355,361
  428.           trickle = False;
  429.           break;
  430.       }
  431. !     }    /* while */
  432.   
  433.       if (trickle) {
  434.       write(fd, buff[ptmp], SCORESIZE);
  435.  
  436. --- 361,367 -----
  437.           trickle = False;
  438.           break;
  439.       }
  440. !     }                /* while */
  441.   
  442.       if (trickle) {
  443.       write(fd, buff[ptmp], SCORESIZE);
  444. ***************
  445. *** 363,369
  446.       if (!saved && (mycount < MAXSCORES)) {
  447.       write(fd, (char *) &myscore, SCORESIZE);
  448.       }
  449.       /* unlock */
  450.       close(lfd);
  451.       (void) unlink(lockfile);
  452.  
  453. --- 369,374 -----
  454.       if (!saved && (mycount < MAXSCORES)) {
  455.       write(fd, (char *) &myscore, SCORESIZE);
  456.       }
  457.       /* unlock */
  458.       close(lfd);
  459.       (void) unlink(lockfile);
  460. ***************
  461. *** 397,403
  462.   
  463.       (void) fprintf(stderr, "            GENERIC TETRIS  HALL OF FAME\n\n");
  464.       (void) fprintf(stderr,
  465. !     "   # USER            SCORE   L    R  HOST         DATE\n");
  466.   
  467.       while (read(fd, (char *) &curs, SCORESIZE) == SCORESIZE) {
  468.       i++;
  469.  
  470. --- 402,408 -----
  471.   
  472.       (void) fprintf(stderr, "            GENERIC TETRIS  HALL OF FAME\n\n");
  473.       (void) fprintf(stderr,
  474. !         "   # USER            SCORE   L    R  HOST         DATE\n");
  475.   
  476.       while (read(fd, (char *) &curs, SCORESIZE) == SCORESIZE) {
  477.       i++;
  478. ***************
  479. *** 403,410
  480.       i++;
  481.       if ((num == 0) || (i <= num))
  482.           (void) fprintf(stderr, "%4d %-12s%9s %3s %4s  %-12s %-s",
  483. !         i, curs.myname, curs.score, curs.level, curs.rows,
  484. !         curs.myhost, curs.mydate);
  485.       }
  486.       close(fd);
  487.       (void) fprintf(stderr, "There are %d scores to date.\n", i);
  488.  
  489. --- 408,415 -----
  490.       i++;
  491.       if ((num == 0) || (i <= num))
  492.           (void) fprintf(stderr, "%4d %-12s%9s %3s %4s  %-12s %-s",
  493. !                i, curs.myname, curs.score, curs.level, curs.rows,
  494. !                curs.myhost, curs.mydate);
  495.       }
  496.       close(fd);
  497.       (void) fprintf(stderr, "There are %d scores to date.\n", i);
  498. diff -c tetris.2.0/tetris.c tetris.2.1/tetris.c
  499. *** tetris.2.0/tetris.c    Fri Jan 15 13:04:29 1993
  500. --- tetris.2.1/tetris.c    Fri Jan 15 15:12:51 1993
  501. ***************
  502. *** 72,78
  503.   Bool            showNext = False, beep = False;
  504.   score_t         myscore;
  505.   
  506. ! static int      opTableEntries = 15;
  507.   static XrmOptionDescRec opTable[] = {
  508.       {"-s", ".scoresOnly", XrmoptionIsArg, (caddr_t) NULL},
  509.       {"-l", "*startLevel", XrmoptionSepArg, (caddr_t) NULL},
  510.  
  511. --- 72,78 -----
  512.   Bool            showNext = False, beep = False;
  513.   score_t         myscore;
  514.   
  515. ! static int      opTableEntries = 16;
  516.   static XrmOptionDescRec opTable[] = {
  517.       {"-s", ".scoresOnly", XrmoptionIsArg, (caddr_t) NULL},
  518.       {"-l", "*startLevel", XrmoptionSepArg, (caddr_t) NULL},
  519. ***************
  520. *** 88,93
  521.       {"-fg", "*foreground", XrmoptionSepArg, (caddr_t) NULL},
  522.       {"-bigFont", "*bigFont", XrmoptionSepArg, (caddr_t) NULL},
  523.       {"-tinyFont", "*tinyFont", XrmoptionSepArg, (caddr_t) NULL},
  524.       {"-xrm", NULL, XrmoptionResArg, (caddr_t) NULL}
  525.   };
  526.   static XrmDatabase cmmDB = (XrmDatabase) NULL, rDB = (XrmDatabase) NULL;
  527.  
  528. --- 88,94 -----
  529.       {"-fg", "*foreground", XrmoptionSepArg, (caddr_t) NULL},
  530.       {"-bigFont", "*bigFont", XrmoptionSepArg, (caddr_t) NULL},
  531.       {"-tinyFont", "*tinyFont", XrmoptionSepArg, (caddr_t) NULL},
  532. +     {"-u", "*playerName", XrmoptionSepArg, (caddr_t) NULL},
  533.       {"-xrm", NULL, XrmoptionResArg, (caddr_t) NULL}
  534.   };
  535.   static XrmDatabase cmmDB = (XrmDatabase) NULL, rDB = (XrmDatabase) NULL;
  536. ***************
  537. *** 104,110
  538.       char           *argv[];
  539.   {
  540.       (void) fprintf(stderr,
  541. !            "                 GENERIC TETRIS V2.0.1\n");
  542.       (void) fprintf(stderr,
  543.        "Copyright (C) 1992-93      Q. Alex Zhao, azhao@cs.arizona.edu\n");
  544.       (void) fprintf(stderr,
  545.  
  546. --- 105,111 -----
  547.       char           *argv[];
  548.   {
  549.       (void) fprintf(stderr,
  550. !            "                 GENERIC TETRIS V2.1.0\n");
  551.       (void) fprintf(stderr,
  552.        "Copyright (C) 1992-93      Q. Alex Zhao, azhao@cs.arizona.edu\n");
  553.       (void) fprintf(stderr,
  554. ***************
  555. *** 136,142
  556.   
  557.       myDisplayName[0] = '\0';
  558.   
  559. !     XrmParseCommand(&cmmDB, opTable, opTableEntries, argv[0], argc, argv);
  560.   
  561.       /* check for any arguments left */
  562.       if (*argc != 1) {
  563.  
  564. --- 137,143 -----
  565.   
  566.       myDisplayName[0] = '\0';
  567.   
  568. !     XrmParseCommand(&cmmDB, opTable, opTableEntries, "tetris", argc, argv);
  569.   
  570.       /* check for any arguments left */
  571.       if (*argc != 1) {
  572. ***************
  573. *** 151,157
  574.       /* get display now */
  575.       if (XrmGetResource(cmmDB, "tetris.display", "Tetris.Display",
  576.                  str_type, &value) == True)
  577. !     (void) strncpy(myDisplayName, value.addr, (int) value.size);
  578.   
  579.       if (!(display = XOpenDisplay(myDisplayName))) {
  580.       (void) fprintf(stderr, "%s: Can't open display '%s'\n",
  581.  
  582. --- 152,159 -----
  583.       /* get display now */
  584.       if (XrmGetResource(cmmDB, "tetris.display", "Tetris.Display",
  585.                  str_type, &value) == True)
  586. !     (void) strncpy(myDisplayName, value.addr, ZLIM(value.size, 255));
  587. !     myDisplayName[255] = '\0';
  588.   
  589.       if (!(display = XOpenDisplay(myDisplayName))) {
  590.       (void) fprintf(stderr, "%s: Can't open display '%s'\n",
  591. ***************
  592. *** 205,211
  593.       (void) fprintf(stderr,
  594.       "   [-bigFont <font>] [-tinyFont <font>] [-showNext] [-beep]\n");
  595.       (void) fprintf(stderr,
  596. !     "   [-xrm <resource specifications>]\n");
  597.   
  598.       exit(1);
  599.   }
  600.  
  601. --- 207,213 -----
  602.       (void) fprintf(stderr,
  603.       "   [-bigFont <font>] [-tinyFont <font>] [-showNext] [-beep]\n");
  604.       (void) fprintf(stderr,
  605. !     "   [-u <name>] [-xrm <resource specifications>]\n");
  606.   
  607.       exit(1);
  608.   }
  609. ***************
  610. *** 296,302
  611.   
  612.       if (XrmGetResource(rDB, "tetris.foreground", "Tetris.Foreground",
  613.                  str_type, &value) == True) {
  614. !     (void) strncpy(name, value.addr, (int) value.size);
  615.       fg = getColor(name);
  616.       } else
  617.       fg = BlackPixel(display, screen_num);
  618.  
  619. --- 298,305 -----
  620.   
  621.       if (XrmGetResource(rDB, "tetris.foreground", "Tetris.Foreground",
  622.                  str_type, &value) == True) {
  623. !     (void) strncpy(name, value.addr, ZLIM(value.size, 255));
  624. !     name[254] = '\0';
  625.       fg = getColor(name);
  626.       } else
  627.       fg = BlackPixel(display, screen_num);
  628. ***************
  629. *** 303,309
  630.   
  631.       if (XrmGetResource(rDB, "tetris.background", "Tetris.Background",
  632.                  str_type, &value) == True) {
  633. !     (void) strncpy(name, value.addr, (int) value.size);
  634.       bg = getColor(name);
  635.       } else
  636.       bg = WhitePixel(display, screen_num);
  637.  
  638. --- 306,313 -----
  639.   
  640.       if (XrmGetResource(rDB, "tetris.background", "Tetris.Background",
  641.                  str_type, &value) == True) {
  642. !     (void) strncpy(name, value.addr, ZLIM(value.size, 255));
  643. !     name[254] = '\0';
  644.       bg = getColor(name);
  645.       } else
  646.       bg = WhitePixel(display, screen_num);
  647. ***************
  648. *** 317,323
  649.   
  650.       if (XrmGetResource(rDB, "tetris.geometry", "Tetris.Geometry",
  651.                  str_type, &value) == True) {
  652. !     (void) strncpy(geoStr, value.addr, (int) value.size);
  653.       } else {
  654.       geoStr[0] = '\0';
  655.       }
  656.  
  657. --- 321,328 -----
  658.   
  659.       if (XrmGetResource(rDB, "tetris.geometry", "Tetris.Geometry",
  660.                  str_type, &value) == True) {
  661. !     (void) strncpy(geoStr, value.addr, ZLIM(value.size, 20));
  662. !     geoStr[19] = '\0';
  663.       } else {
  664.       geoStr[0] = '\0';
  665.       }
  666. ***************
  667. *** 341,347
  668.   
  669.       if (XrmGetResource(rDB, "tetris.iconGeometry", "Tetris.IconGeometry",
  670.                  str_type, &value) == True) {
  671. !     (void) strncpy(icongeoStr, value.addr, (int) value.size);
  672.       } else {
  673.       icongeoStr[0] = '\0';
  674.       }
  675.  
  676. --- 346,353 -----
  677.   
  678.       if (XrmGetResource(rDB, "tetris.iconGeometry", "Tetris.IconGeometry",
  679.                  str_type, &value) == True) {
  680. !     (void) strncpy(icongeoStr, value.addr, ZLIM(value.size, 20));
  681. !     icongeoStr[19] = '\0';
  682.       } else {
  683.       icongeoStr[0] = '\0';
  684.       }
  685. ***************
  686. *** 367,373
  687.   
  688.       /*** get fonts ***/
  689.   
  690. !     if (XrmGetResource(rDB, "tetris.bigFont", "tetris.BigFont",
  691.                  str_type, &value) == True) {
  692.       (void) strncpy(name, value.addr, (int) value.size);
  693.       } else {
  694.  
  695. --- 373,379 -----
  696.   
  697.       /*** get fonts ***/
  698.   
  699. !     if (XrmGetResource(rDB, "tetris.bigFont", "Tetris.BigFont",
  700.                  str_type, &value) == True) {
  701.       (void) strncpy(name, value.addr, ZLIM(value.size, 255));
  702.       name[254] = '\0';
  703. ***************
  704. *** 369,375
  705.   
  706.       if (XrmGetResource(rDB, "tetris.bigFont", "tetris.BigFont",
  707.                  str_type, &value) == True) {
  708. !     (void) strncpy(name, value.addr, (int) value.size);
  709.       } else {
  710.       (void) strcpy(name, BIGFONT);
  711.       }
  712.  
  713. --- 375,382 -----
  714.   
  715.       if (XrmGetResource(rDB, "tetris.bigFont", "Tetris.BigFont",
  716.                  str_type, &value) == True) {
  717. !     (void) strncpy(name, value.addr, ZLIM(value.size, 255));
  718. !     name[254] = '\0';
  719.       } else {
  720.       (void) strcpy(name, BIGFONT);
  721.       }
  722. ***************
  723. *** 377,383
  724.       (void) fprintf(stderr, "Tetris: can't open font '%s'.\n", name);
  725.       exit(1);
  726.       }
  727. !     if (XrmGetResource(rDB, "tetris.tinyFont", "tetris.TinyFont",
  728.                  str_type, &value) == True) {
  729.       (void) strncpy(name, value.addr, (int) value.size);
  730.       } else {
  731.  
  732. --- 384,390 -----
  733.       (void) fprintf(stderr, "Tetris: can't open font '%s'.\n", name);
  734.       exit(1);
  735.       }
  736. !     if (XrmGetResource(rDB, "tetris.tinyFont", "Tetris.TinyFont",
  737.                  str_type, &value) == True) {
  738.       (void) strncpy(name, value.addr, ZLIM(value.size, 255));
  739.       name[254] = '\0';
  740. ***************
  741. *** 379,385
  742.       }
  743.       if (XrmGetResource(rDB, "tetris.tinyFont", "tetris.TinyFont",
  744.                  str_type, &value) == True) {
  745. !     (void) strncpy(name, value.addr, (int) value.size);
  746.       } else {
  747.       (void) strcpy(name, TINYFONT);
  748.       }
  749.  
  750. --- 386,393 -----
  751.       }
  752.       if (XrmGetResource(rDB, "tetris.tinyFont", "Tetris.TinyFont",
  753.                  str_type, &value) == True) {
  754. !     (void) strncpy(name, value.addr, ZLIM(value.size, 255));
  755. !     name[254] = '\0';
  756.       } else {
  757.       (void) strcpy(name, TINYFONT);
  758.       }
  759. ***************
  760. *** 386,391
  761.       if ((tinyFont = XLoadQueryFont(display, name)) == NULL) {
  762.       (void) fprintf(stderr, "Tetris: can't open font '%s'.\n", name);
  763.       exit(1);
  764.       }
  765.   
  766.       /*
  767.  
  768. --- 394,407 -----
  769.       if ((tinyFont = XLoadQueryFont(display, name)) == NULL) {
  770.       (void) fprintf(stderr, "Tetris: can't open font '%s'.\n", name);
  771.       exit(1);
  772. +     }
  773. +     /* player name */
  774. +     if (XrmGetResource(rDB, "tetris.playerName", "Tetris.PlayerName",
  775. +                str_type, &value) == True) {
  776. +     (void) strncpy(myscore.myname, value.addr, ZLIM(value.size, 20));
  777. +     myscore.myname[19] = '\0';
  778.       }
  779.   
  780.       /*
  781. diff -c tetris.2.0/tetris.h tetris.2.1/tetris.h
  782. *** tetris.2.0/tetris.h    Fri Jan 15 13:04:29 1993
  783. --- tetris.2.1/tetris.h    Fri Jan 15 15:14:58 1993
  784. ***************
  785. *** 111,116
  786.   #endif
  787.   #endif
  788.   
  789.   /*** constants ***/
  790.   
  791.   #ifndef    SCOREFILE
  792.  
  793. --- 111,120 -----
  794.   #endif
  795.   #endif
  796.   
  797. + /*** macros ***/
  798. + #define    ZLIM(X, Y)    (((int) X) < (Y) ? ((int) X) : (Y))
  799.   /*** constants ***/
  800.   
  801.   #ifndef    SCOREFILE
  802. diff -c tetris.2.0/tetris.man tetris.2.1/tetris.man
  803. *** tetris.2.0/tetris.man    Fri Jan 15 13:04:29 1993
  804. --- tetris.2.1/tetris.man    Fri Jan 15 14:09:27 1993
  805. ***************
  806. *** 1,4
  807. ! .TH TETRIS 6 "11 Jan 1993, V2.0.1" "Univ of Arizona"
  808.   .SH NAME
  809.   GENERIC TETRIS \- Yet Another Tetris Game on X
  810.   .SH SYNOPSIS
  811.  
  812. --- 1,4 -----
  813. ! .TH TETRIS 6 "15 Jan 1993, V2.1.0" "Univ of Arizona"
  814.   .SH NAME
  815.   GENERIC TETRIS \- Yet Another Tetris Game on X
  816.   .SH SYNOPSIS
  817. ***************
  818. *** 6,12
  819.   [-s] [-l <start level>] [-p <prefilled lines>] [-showNext] [-beep]
  820.   [-display <display>] [-geometry <geometry>] [-iconGeometry <geometry>]
  821.   [-{background | bg} <color>] [-{foreground | fg} <color>] [-bigFont
  822. ! <font>] [-tinyFont <font>] [-xrm <resource specification>]
  823.   .SH DESCRIPTION
  824.   .LP
  825.   One of the motivations of this tetris program is simplicity. It does
  826.  
  827. --- 6,12 -----
  828.   [-s] [-l <start level>] [-p <prefilled lines>] [-showNext] [-beep]
  829.   [-display <display>] [-geometry <geometry>] [-iconGeometry <geometry>]
  830.   [-{background | bg} <color>] [-{foreground | fg} <color>] [-bigFont
  831. ! <font>] [-tinyFont <font>] [-u <name>] [-xrm <resource specification>]
  832.   .SH DESCRIPTION
  833.   .LP
  834.   One of the motivations of this tetris program is simplicity. It does
  835. ***************
  836. *** 40,45
  837.   .TP 8
  838.   .B \-s
  839.   This option lets the program only list all the recorded scores then exit.
  840.   .TP 8
  841.   .B \-l \fIlevel\fP
  842.   This option starts the program at the specified level (resource name
  843.  
  844. --- 40,48 -----
  845.   .TP 8
  846.   .B \-s
  847.   This option lets the program only list all the recorded scores then exit.
  848. + .TP 8
  849. + .B \-u \fIname\fP
  850. + This option sets alternative player name.
  851.   .TP 8
  852.   .B \-l \fIlevel\fP
  853.   This option starts the program at the specified level (resource name
  854. diff -c tetris.2.0/utils.c tetris.2.1/utils.c
  855. *** tetris.2.0/utils.c    Fri Jan 15 13:04:30 1993
  856. --- tetris.2.1/utils.c    Fri Jan 15 15:42:16 1993
  857. ***************
  858. *** 116,121
  859.       }
  860.   };
  861.   
  862.   static char    *thingFGs[NUM_THINGS] = {
  863.       "Magenta", "ForestGreen", "Blue", "Red", "DarkTurquoise", "Black", "Brown"
  864.   };
  865.  
  866. --- 116,128 -----
  867.       }
  868.   };
  869.   
  870. + static int      checkUp[NUM_BITMAPS] = {
  871. +     0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6
  872. + };
  873. + static int      checkDown[NUM_BITMAPS] = {
  874. +     0, 1, 0, 1, 4, 5, 4, 5, 8, 9, 8, 9, 12, 13, 12
  875. + };
  876.   static char    *thingFGs[NUM_THINGS] = {
  877.       "Magenta", "ForestGreen", "Blue", "Red", "DarkTurquoise", "Brown", "Black"
  878.   };
  879. ***************
  880. *** 117,123
  881.   };
  882.   
  883.   static char    *thingFGs[NUM_THINGS] = {
  884. !     "Magenta", "ForestGreen", "Blue", "Red", "DarkTurquoise", "Black", "Brown"
  885.   };
  886.   
  887.   static Pixmap   pms[NUM_BITMAPS];
  888.  
  889. --- 124,130 -----
  890.   };
  891.   
  892.   static char    *thingFGs[NUM_THINGS] = {
  893. !     "Magenta", "ForestGreen", "Blue", "Red", "DarkTurquoise", "Brown", "Black"
  894.   };
  895.   
  896.   static Pixmap   pms[NUM_BITMAPS];
  897. ***************
  898. *** 619,625
  899.           for (i = j; i > 0; i--)
  900.               lSet[i] = lSet[i-1];
  901.           lSet[0] = 0;
  902. !         
  903.           j++;
  904.           XFlush(display);
  905.           }
  906.  
  907. --- 626,642 -----
  908.           for (i = j; i > 0; i--)
  909.               lSet[i] = lSet[i-1];
  910.           lSet[0] = 0;
  911. !         if (j > 0)
  912. !             for (i = 0; i < COLS; i++) {
  913. !             int             tmp = field[j][i].pm_num;
  914. !             if ((tmp >= 0) && (tmp != checkDown[tmp])) {
  915. !                 field[j][i].pm_num = checkDown[tmp];
  916. !                 drawBox(blockWin, field[j][i].pm_num,
  917. !                 field[j][i].cid, i * BOXSIZE, j * BOXSIZE);
  918. !             }
  919. !             }
  920.           j++;
  921.   
  922.           if (j < ROWS)
  923. ***************
  924. *** 621,626
  925.           lSet[0] = 0;
  926.           
  927.           j++;
  928.           XFlush(display);
  929.           }
  930.       }
  931.  
  932. --- 638,654 -----
  933.               }
  934.   
  935.           j++;
  936. +         if (j < ROWS)
  937. +             for (i = 0; i < COLS; i++) {
  938. +             int             tmp = field[j][i].pm_num;
  939. +             if ((tmp >= 0) && (tmp != checkUp[tmp])) {
  940. +                 field[j][i].pm_num = checkUp[tmp];
  941. +                 drawBox(blockWin, field[j][i].pm_num,
  942. +                 field[j][i].cid, i * BOXSIZE, j * BOXSIZE);
  943. +             }
  944. +             }
  945.           XFlush(display);
  946.           }
  947.       }
  948.  
  949.