]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - tetris/screen.c
Fix merge conflicts
[bsdgames-darwin.git] / tetris / screen.c
index 1babdb498800a73ec82128e71f715f37e442cf82..bb0da760b1cac516f7f67d0e1b14654a361a78e6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: screen.c,v 1.30 2015/07/07 22:53:25 nat Exp $  */
+/*     $NetBSD: screen.c,v 1.34 2021/05/02 12:50:46 rillig Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -50,6 +50,8 @@
 #include <termios.h>
 #include <unistd.h>
 
+#include <termcap.h>
+
 #ifndef sigmask
 #define sigmask(s) (1 << ((s) - 1))
 #endif
@@ -197,6 +199,7 @@ scr_set(void)
                    MINCOLS, MINROWS);
                stop("");       /* stop() supplies \n */
        }
+       Offset = (Rows - D_LAST + D_FIRST - 2) / 2;
        if (tcgetattr(0, &oldtt) < 0)
                stop("tcgetattr() fails");
        newtt = oldtt;
@@ -211,10 +214,11 @@ scr_set(void)
         * We made it.  We are now in screen mode, modulo TIstr
         * (which we will fix immediately).
         */
-       if (enter_ca_mode)
-               putstr(enter_ca_mode);
-       if (cursor_invisible)
-               putstr(cursor_invisible);
+       const char *tstr;
+       if ((tstr = enter_ca_mode) != NULL)
+               putstr(tstr);
+       if ((tstr = cursor_invisible) != NULL)
+               putstr(tstr);
        if (tstp != SIG_IGN)
                (void) signal(SIGTSTP, scr_stop);
        if (ttou != SIG_IGN)
@@ -238,15 +242,16 @@ scr_end(void)
        sigaddset(&nsigset, SIGTTOU);
        (void) sigprocmask(SIG_BLOCK, &nsigset, &osigset);
        /* move cursor to last line */
-       if (cursor_to_ll)
-               putstr(cursor_to_ll);
+       const char *tstr;
+       if ((tstr = cursor_to_ll) != NULL)
+               putstr(tstr);
        else
                moveto(Rows - 1, 0);
        /* exit screen mode */
-       if (exit_ca_mode)
-               putstr(exit_ca_mode);
-       if (cursor_normal)
-               putstr(cursor_normal);
+       if ((tstr = exit_ca_mode) != NULL)
+               putstr(tstr);
+       if ((tstr = cursor_normal) != NULL)
+               putstr(tstr);
        (void) fflush(stdout);
        (void) tcsetattr(0, TCSADRAIN, &oldtt);
        isset = 0;
@@ -315,10 +320,10 @@ scr_update(void)
        /* draw preview of nextpattern */
        if (showpreview && (nextshape != lastshape)) {
                static int r=5, c=2;
-               int tr, tc, t; 
+               int tr, tc, t;
 
                lastshape = nextshape;
-               
+
                /* clean */
                putpad(exit_standout_mode);
                moveto(r-1, c-1); putstr("          ");
@@ -328,10 +333,10 @@ scr_update(void)
 
                moveto(r-3, c-2);
                putstr("Next shape:");
-                                               
+
                /* draw */
-               putpad(enter_standout_mode);
                setcolor(nextshape->color);
+               putpad(enter_standout_mode);
                moveto(r, 2*c);
                putstr("  ");
                for(i=0; i<3; i++) {
@@ -346,7 +351,7 @@ scr_update(void)
                }
                putpad(exit_standout_mode);
        }
-       
+
        bp = &board[D_FIRST * B_COLS];
        sp = &curscreen[D_FIRST * B_COLS];
        for (j = D_FIRST; j < D_LAST; j++) {
@@ -360,7 +365,7 @@ scr_update(void)
                                        putpad(exit_standout_mode);
                                        cur_so = 0;
                                }
-                               moveto(RTOD(j), CTOD(i));
+                               moveto(RTOD(j + Offset), CTOD(i));
                        }
                        if (enter_standout_mode) {
                                if (so != cur_so) {
@@ -412,7 +417,7 @@ scr_update(void)
 void
 scr_msg(char *s, int set)
 {
-       
+
        if (set || clr_eol == NULL) {
                int l = strlen(s);