[comp.sources.games] v06i099: tetrix - ancient Russian

billr@saab.CNA.TEK.COM (Bill Randle) (07/06/89)

Submitted-by: "Eric S. Raymond" <eric@snark.uu.net>
Posting-number: Volume 6, Issue 99
Archive-name: tetrix.pch1
Patch-To: tetrix: Volume 6, Issue 15

	[This patch is not from the original author, yet appears to be useful
	 and is properly #ifdef'd, so I'm posting it here (since it was sent
	 to me).  Now do we need a way to differentiate between "Official"
	 patches and other useful patches?	-br]

	[[The SVr3.2 that came with my brand-new VGA-equipped 6386WGS includes 
	color-support enhancements to the curses(3) library. I wrote the following
	tetrix mods as a way to learn elementary use of the new features. The README
	patch that leads the set gives details.

		  Eric S. Raymond = eric@snark.uu.net]]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  patches01
# Wrapped by billr@saab on Thu Jul  6 06:47:35 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'patches01' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patches01'\"
else
echo shar: Extracting \"'patches01'\" \(5926 characters\)
sed "s/^X//" >'patches01' <<'END_OF_FILE'
X*** README-old	Thu Jun 29 15:15:28 1989
X--- README	Thu Jun 29 15:26:11 1989
X***************
X*** 29,31 ****
X--- 29,41 ----
X  
X  	Good luck!					Quentin Neill
X  
X+ This version has been hacked to do color under System V Release 3.2. Compile
X+ with -DCOLOR to enable this feature. Due to the limited number of colors in the
X+ curses(3) portable set, 'tan' pieces will be cyan-colored.
X+ 	If you're using an EGA or VGA display, however, you can also compile
X+ with -DEGA to get better colors (this uses the EGA quirk that yellow is
X+ 'bright brown').
X+ 	Finally, note that you may now invoke tetrix as	`tetrix <pause-value>'
X+ to set the value of INIT_PAUSE.
X+ 
X+ 	Have fun!					Eric S. Raymond
X*** Makefile-old	Thu Jun 29 11:00:13 1989
X--- Makefile	Thu Jun 29 15:12:10 1989
X***************
X*** 4,11 ****
X  #  - this will create a high score file in /usr/tmp, so doing it again
X  #    later on will erase high scores for the machine.
X  
X! 
X! OBJS= MoveR.o MoveL.o NewP.o AdvanceP.o Rotate.o tet.o
X  INCS= tet.h
X  
X  tetrix: $(OBJS) $(INCS)
X--- 4,11 ----
X  #  - this will create a high score file in /usr/tmp, so doing it again
X  #    later on will erase high scores for the machine.
X  
X! CFLAGS=-g -DCOLOR -DEGA
X! OBJS= MoveR.o MoveL.o NewP.o AdvanceP.o Rotate.o Colors.o tet.o
X  INCS= tet.h
X  
X  tetrix: $(OBJS) $(INCS)
X***************
X*** 20,25 ****
X--- 20,27 ----
X  AdvanceP.o: AdvanceP.c
X  
X  Rotate.o: Rotate.c
X+ 
X+ Colors.o: Colors.c
X  
X  tet.o: tet.c
X  
X*** tet.h-old	Thu Jun 29 10:57:18 1989
X--- tet.h	Thu Jun 29 11:12:18 1989
X***************
X*** 34,42 ****
X--- 34,47 ----
X  extern int Type, Row, Column, Pause, CurrentSpeed, FallingDown, Beep;
X  extern char Board[BOARD_WIDE][BOARD_HIGH];
X  
X+ #ifndef COLOR
X  /* Macros */
X  /* offset the character on screen by MINX and MINY */
X  #define PUTCH(x,y,z) {  mvaddch(y+MINY,x+MINX,z); Board[x][y]=z; }
X+ #else
X+ extern void PUTCH();
X+ extern void init_colors();
X+ #endif /* COLOR */
X  
X  /* test whether a square is empty and legal */
X  /*
X*** tet.c-old	Fri Mar  3 14:06:40 1989
X--- tet.c	Thu Jun 29 14:40:50 1989
X***************
X*** 12,17 ****
X--- 12,18 ----
X  int Row;		/* Row of pivot point of block */
X  int Column;		/* Column of pivot point of block */
X  int Pause;		/* Time between movements this block */
X+ int InitPause;		/* Initial value of CurrentPause */
X  int CurrentPause;	/* Time between movements per level */
X  int FallingDown;	/* True when space bar is pressed */
X  int Beep;
X***************
X*** 58,65 ****
X  #define MENU_KEY	'm'
X  
X  /**************************************************MAIN*****/
X! main()
X  {
X  	Init();
X  	for ( ; ; ) {
X  		NewGame();
X--- 59,72 ----
X  #define MENU_KEY	'm'
X  
X  /**************************************************MAIN*****/
X! main(argc, argv)
X! int argc;
X! char **argv;
X  {
X+ 	if (argc >= 2)
X+ 		InitPause = atoi(argv[1]);
X+ 	else
X+ 		InitPause = 150;
X  	Init();
X  	for ( ; ; ) {
X  		NewGame();
X***************
X*** 98,104 ****
X  	HighsChanged = 0;
X  	ScoreIt();
X  	initscr();
X! 	/* initilialize board to spaces */
X  	for (x=0; x<BOARD_WIDE; x++) 
X  		for (y=0; y<BOARD_HIGH; y++) 
X  			PUTCH(x,y,NO_CHAR);
X--- 105,114 ----
X  	HighsChanged = 0;
X  	ScoreIt();
X  	initscr();
X! #ifdef COLOR
X!         init_colors();
X! #endif /* COLOR */
X! 	/* initialize board to spaces */
X  	for (x=0; x<BOARD_WIDE; x++) 
X  		for (y=0; y<BOARD_HIGH; y++) 
X  			PUTCH(x,y,NO_CHAR);
X***************
X*** 123,129 ****
X  			case SCORE_KEY  : DrawScore(); break;
X  			case MENU_KEY	: DrawMenu(); break;
X  			case BOSS_KEY	: Boss(); break;
X! 			case PLAY_KEY	: CurrentPause=150; break;
X  			case QUIT_KEY   : Leave();
X  			}
X  	}
X--- 133,139 ----
X  			case SCORE_KEY  : DrawScore(); break;
X  			case MENU_KEY	: DrawMenu(); break;
X  			case BOSS_KEY	: Boss(); break;
X! 			case PLAY_KEY	: CurrentPause=InitPause; break;
X  			case QUIT_KEY   : Leave();
X  			}
X  	}
X*** Colors.c-old	Thu Jun 29 14:41:03 1989
X--- Colors.c	Thu Jun 29 15:57:32 1989
X***************
X*** 0 ****
X--- 1,83 ----
X+ /* Tetrix color support by Eric S. Raymond, eric@snark.uu.net */
X+ 
X+ #include <curses.h>
X+ #include "tet.h"
X+ 
X+ #ifdef COLOR
X+ /* color pair indexes for pieces */
X+ #define BLACK	0
X+ #define GREEN	1
X+ #define RED	2
X+ #define TAN	3
X+ #define WHITE	4
X+ #define	VIOLET	5
X+ #define BLUE	6
X+ #define YELLOW	7
X+ #define NCOLORS	8
X+ 
X+ static int attribs[NCOLORS];
X+ 
X+ typedef struct
X+ {
X+     int	forgrnd;
X+     int attrib;
X+ }
X+ colorpair;
X+ 
X+ void init_colors()
X+ {
X+     start_color();
X+ 
X+     init_pair(BLACK, COLOR_BLACK, COLOR_BLACK);
X+     attribs[BLACK] = COLOR_PAIR(BLACK);
X+ 
X+     init_pair(GREEN, COLOR_GREEN, COLOR_BLACK);
X+     attribs[GREEN] = COLOR_PAIR(GREEN);
X+ 
X+     init_pair(RED, COLOR_RED, COLOR_BLACK);
X+     attribs[RED] = COLOR_PAIR(RED);
X+ 
X+ #ifdef EGA
X+     init_pair(TAN, COLOR_YELLOW, COLOR_BLACK);
X+ #else
X+     init_pair(TAN, COLOR_CYAN, COLOR_BLACK);
X+ #endif /* EGA */
X+     attribs[TAN] = COLOR_PAIR(TAN);
X+ 
X+     init_pair(WHITE, COLOR_WHITE, COLOR_BLACK);
X+     attribs[WHITE] = COLOR_PAIR(WHITE);
X+ 
X+     init_pair(VIOLET, COLOR_MAGENTA, COLOR_BLACK);
X+     attribs[VIOLET] = COLOR_PAIR(VIOLET);
X+ 
X+     init_pair(BLUE, COLOR_BLUE, COLOR_BLACK);
X+     attribs[BLUE] = COLOR_PAIR(BLUE);
X+ 
X+ #ifdef EGA
X+     attribs[YELLOW] = attribs[TAN] | A_BOLD;
X+ #else
X+     init_pair(YELLOW, COLOR_YELLOW, COLOR_BLACK);
X+     attribs[YELLOW] = COLOR_PAIR(YELLOW);
X+ #endif /* EGA */
X+ }
X+ 
X+ void PUTCH(x,y,z)
X+ int	x, y, z;
X+ { 
X+     switch(z)
X+     {
X+     case ' ': attron(attribs[BLACK]); break;
X+     case 'G': attron(attribs[GREEN]); break;
X+     case 'R': attron(attribs[RED]); break;
X+     case 'O': attron(attribs[TAN]); break;
X+     case 'W': attron(attribs[WHITE]); break;
X+     case 'V': attron(attribs[VIOLET]); break;
X+     case 'B': attron(attribs[BLUE]); break;
X+     case 'Y': attron(attribs[YELLOW]); break;
X+     }
X+     mvaddch(y+MINY,x+MINX, z);
X+     attrset(0);
X+     Board[x][y]=z;
X+ }
X+ 
X+ #endif /* COLOR */
X
END_OF_FILE
if test 5926 -ne `wc -c <'patches01'`; then
    echo shar: \"'patches01'\" unpacked with wrong size!
fi
# end of 'patches01'
fi
echo shar: End of shell archive.
exit 0