From 941c02b577621333826e07626da0676e435ae7f5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 29 Nov 1994 02:30:25 +0000 Subject: [PATCH] Initial revision --- Colors.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 31 +++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 Colors.c create mode 100644 Makefile diff --git a/Colors.c b/Colors.c new file mode 100644 index 0000000..2690373 --- /dev/null +++ b/Colors.c @@ -0,0 +1,84 @@ +/* Tetrix color support by Eric S. Raymond, eric@snark.uu.net */ + +#include +#include "tet.h" + +#ifdef COLOR +/* color pair indexes for pieces */ +#define BLACK 0 +#define GREEN 1 +#define RED 2 +#define TAN 3 +#define WHITE 4 +#define VIOLET 5 +#define BLUE 6 +#define YELLOW 7 +#define NCOLORS 8 + +static int attribs[NCOLORS]; + +typedef struct +{ + int forgrnd; + int attrib; +} +colorpair; + +void init_colors() +{ + start_color(); + + init_pair(BLACK, COLOR_BLACK, COLOR_BLACK); + attribs[BLACK] = COLOR_PAIR(BLACK); + + init_pair(GREEN, COLOR_GREEN, COLOR_BLACK); + attribs[GREEN] = COLOR_PAIR(GREEN); + + init_pair(RED, COLOR_RED, COLOR_BLACK); + attribs[RED] = COLOR_PAIR(RED); + +#ifdef EGA + init_pair(TAN, COLOR_YELLOW, COLOR_BLACK); +#else + init_pair(TAN, COLOR_CYAN, COLOR_BLACK); +#endif /* EGA */ + attribs[TAN] = COLOR_PAIR(TAN); + + init_pair(WHITE, COLOR_WHITE, COLOR_BLACK); + attribs[WHITE] = COLOR_PAIR(WHITE); + + init_pair(VIOLET, COLOR_MAGENTA, COLOR_BLACK); + attribs[VIOLET] = COLOR_PAIR(VIOLET); + + init_pair(BLUE, COLOR_BLUE, COLOR_BLACK); + attribs[BLUE] = COLOR_PAIR(BLUE); + +#ifdef EGA + attribs[YELLOW] = attribs[TAN] | A_BOLD; +#else + init_pair(YELLOW, COLOR_YELLOW, COLOR_BLACK); + attribs[YELLOW] = COLOR_PAIR(YELLOW); +#endif /* EGA */ +} + +void PUTCH(x,y,z) +int x, y, z; +{ + switch(z) + { + case NO_CHAR: attron(attribs[WHITE]); break; + case 'G': attron(attribs[GREEN]); break; + case 'R': attron(attribs[RED]); break; + case 'O': attron(attribs[TAN]); break; + case 'W': attron(attribs[WHITE]); break; + case 'V': attron(attribs[VIOLET]); break; + case 'B': attron(attribs[BLUE]); break; + case 'Y': attron(attribs[YELLOW]); break; + } + mvaddch(y, x, z); + if (INBOARD(x, y)) + Board[x-MINX][y-MINY]=z; + attrset(0); +} + +#endif /* COLOR */ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3d9e733 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +# - un'cpio' this in /usr/src or /usr/local/src or something - doesn't matter. +# - do a 'make install' in the tetrix directory +# - tetrix gets installed in /usr/local/bin +# - 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 +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 + +MoveR.o: MoveR.c tet.h +MoveL.o: MoveL.c tet.h +DrawP.o: DrawP.c tet.h +AdvanceP.o: AdvanceP.c tet.h +Rotate.o: Rotate.c tet.h +Colors.o: Colors.c tet.h +tet.o: tet.c tet.h + +install: tetrix + chmod 755 tetrix + /bin/mv -f tetrix /usr/local/bin + +shar: + shar README Makefile tet.h $(OBJS:.o=.c) + +clean: + /bin/rm -rf tetrix core *.o -- 2.43.0