# - this will create a high score file in /usr/tmp, so doing it again
# later on will erase high scores for the machine.
-CFLAGS=-O -DCOLOR -DTERMINFO -DEGA
-LFLAGS = -s
+CFLAGS=-g -DEGA
+LFLAGS = # -s
OBJS= MoveR.o MoveL.o DrawP.o AdvanceP.o Rotate.o Colors.o tet.o
INCS= tet.h
tetrix: $(OBJS) $(INCS)
- cc $(LFLAGS) $(OBJS) -o tetrix -lcurses
+ cc $(LFLAGS) $(OBJS) -ldcurses -o tetrix
MoveR.o: MoveR.c tet.h
MoveL.o: MoveL.c tet.h
} High[HIGHCOUNT];
int ThisScore,HighsChanged;
-char *ttyname();
-char combuf[2];
-struct termio origtty, tty;
char Board[BOARD_WIDE][BOARD_HIGH];
char Temp[BOARD_WIDE][BOARD_HIGH]; /* temp storage for TestRows */
time(&timein); /* get start time */
srand48(timein); /* start rand randomly */
- ttnam = ttyname (0);
- close (0);
- open (ttnam, O_NDELAY);
- /*
- * setup raw mode, no echo
- */
- ioctl (0, TCGETA, &origtty);
- ioctl (0, TCGETA, &tty);
- tty.c_iflag &= 077;
- tty.c_oflag &= 077700;
- tty.c_lflag = 0201;
- tty.c_cc[4] = 1;
- ioctl (1, TCSETAW, &tty);
signal(SIGINT, SIG_IGN);
Beep=0;
HighsChanged = 0;
- ScoreIt();
initscr();
+ nodelay(stdscr, TRUE);
+ noecho();
+ cbreak();
+ ScoreIt();
-#ifdef TERMINFO
+#ifdef ACS_VLINE
/* good, we can use the defined forms-drawing characters */
VERT = ACS_VLINE;
HORIZ = ACS_HLINE;
URC = ACS_URCORNER;
LLC = ACS_LLCORNER;
LRC = ACS_LRCORNER;
-#endif /* TERMINFO */
+#endif /* ACS_VLINE */
-#ifdef COLOR
+#ifdef A_COLOR
init_colors();
-#endif /* COLOR */
+#endif /* A_COLOR */
/* initialize board to spaces */
for (x=0; x<BOARD_WIDE; x++)
for (y=0; y<BOARD_HIGH; y++)
{
register int x, y;
-#ifdef TERMINFO
- attron(A_ALTCHARSET);
-#endif
for (y = t + 1; y < t + d; y++)
{
mvaddch(y, l, VERT);
mvaddch(t + d, l, LLC);
mvaddch(t, l + w, URC);
mvaddch(t + d, l + w, LRC);
-#ifdef TERMINFO
- attroff(A_ALTCHARSET);
-#endif
}
/******************************************************************/
for(i=0; i<HIGHCOUNT; i++)
High[i].Score = 0;
for(i=0; i<HIGHCOUNT; i++)
- strncpy(" ",High[i].Name,NAMELEN);
+ strncpy(High[i].Name," ",NAMELEN);
}
umask(oldmask);
Boss()
{ register int x,y;
- clear();
- refresh();
- ioctl (0, TCSETA, &origtty);
- system("sh </dev/tty >/dev/tty");
- ioctl (1, TCSETAW, &tty);
clear();
DrawMenu();
/* restore board */
/*********************************************************************/
GetKey()
{
-/* fflush(stdout); */
+ int c;
+
Key = NULL_KEY;
top:
- if (read (0, combuf, 1) == 0)
+ if ((c = getch()) == ERR)
return;
- else Key = (*combuf&0177);
+ else Key = (c & 0177);
goto top;
}
mvaddstr(23,0,"");
refresh();
sleep(1);
- ioctl (0, TCSETA, &origtty);
+ endwin();
exit(0);
}
extern char Board[BOARD_WIDE][BOARD_HIGH];
-#ifndef COLOR
+#ifndef A_COLOR
/* Macros */
/* offset the character on screen by MINX and MINY */
#define PUTCH(x,y,z) { mvaddch(y,x,z); if (INBOARD(x, y)) Board[x-MINX][y-MINY]=z; }
#else
extern void PUTCH();
extern void init_colors();
-#endif /* COLOR */
+#endif /* A_COLOR */
#ifdef BIGCPP
/* test whether a square is empty and legal */