[net.sources] Chanuka funstuff -- it's not only Christmas!

smk (12/14/82)

/**** DO NOT DELETE BELOW THIS LINE !!!
	A rebuttal to Dave Curry.  This isn't only the Christmas season.
    Jews may have felt left out, so here is something to cheer you up.

   Yes  folks,  it's  the  newest  thing  in  Chanukah  gift  giving,
   "Chanukah  by mail"! At the end of this letter, you will find your
   gift in the form of a 'C' program. Simply follow  the  instructions
   below, and then sit back and enjoy your gift. 

   ASSEMBLY INSTRUCTIONS (no tools needed):

	1) Save this letter in a file called "present.c".  Then, edit
	   the file and delete all lines before the "DO NOT..." line
	   above.

	If you are on one of the Purdue University VAX computers,
	do the following:
		1) Exit the editor, if you haven't already.
		2) Type the following command:
			cc. -O -s -N -o present present.c -lcurses -ltermcap
		3) Run your program by typing "present".

	If you are not on one of the Purdue University VAX computers,
	do the following:

		1) If your system does not have the "nap()" system 
		   call (a 1/60 second sleep()), delete that call 
		   from the "output2()" routine.  

		2) If your system does not have the Berkeley "curses"
		   library, you must do the following:
			[a] delete the lines:
				#include <curses.h>
				initscr();
				endwin();
			[b] write a routine called "move(y, x)" which
			    will position the cursor on your terminal
			    at the given (x, y) coordinates.   Note 
			    that the 'y' coordinate is the first argu-
			    ment.  The top left corner of your screen
			    should be (0,0).  If you have an "adm3a",
			    "adm3a+", or "adm5" terminal, there is a
			    routine at the end of this program which 
			    will do this for you.
			[c] write a routine called "clear()" to clear
			    your terminal's screen.  If you have one 
			    of the terminals mentioned above, there is
			    a routine at the end of this program to 
			    do this for you.
			[d] Un-comment the routines supplied at the 
			    end of the program.
		4) If your system DOES have the "curses" library, 
		   compile your program as follows:

			cc -O -s -o present present.c -lcurses -ltermcap

		   NOTE: You may have to substitute "-ltermlib" for
			 "-ltermcap".

		   If your system DOES NOT have the "curses" library,
		   compile your program as follows:

			cc -O -s -o present present.c

		5) Execute your program, and enjoy.  Please feel free 
		   to give copies of this to all your friends.

Merry Christmas,
	--steve kramer
	linus!smk

*/


#include <curses.h>

#define FLICKER 40

main()
{
	int x, y;

	srand ((int) time (0));

	/*
	 * If you don't have the Berkeley "curses" library, delete
	 * this routine call.
	 */
	initscr();

	clear();
	refresh();
	sleep(1);

	output2(4, 39, '*'); output2(4, 41, '*');
	output2(5, 39, '*'); output2(5, 41, '*');
	output2(6, 39, '*'); output2(6, 41, '*');
	output2(7, 39, '*'); output2(7, 41, '*');
	output2(8, 39, '*'); output2(8, 41, '*');
	output2(9, 39, '*'); output2(9, 41, '*');
	output2(10, 39, '*'); output2(10, 41, '*');
	output2(11, 39, '*'); output2(11, 41, '*');
	output2(12, 39, '*'); output2(12, 41, '*');
	output2(13, 39, '*'); output2(13, 41, '*');
	output2(14, 39, '*'); output2(14, 41, '*');
	output2(15, 39, '*'); output2(15, 41, '*');
	output2(16, 39, '*'); output2(16, 41, '*');
	output2(17, 39, '*'); output2(17, 41, '*');
	output2(18, 39, '*'); output2(18, 41, '*');
	output2(19, 36, '*'); output2(19, 44, '*');
	output2(20, 34, '*'); output2(20, 46, '*');

	for (x = 35; x <= 45; x++)
		output2 (21, x, '_');

	move(0,0);
	refresh();
	sleep(4);

	output2 (5, 14, '*'); output2 (5, 16, '*');
	output2 (5, 64, '*'); output2 (5, 66, '*');
	for (x=6; x<= 9; x++)
	{
		output2 (x, 8+x, '*'); output2 (x, 10+x, '*');
		output2 (x, 70-x, '*'); output2 (x, 72-x, '*');
	}

	output2(10, 19, '*'); output2(10, 21, '*');
	output2(10, 59, '*'); output2(10, 61, '*');
	output2(11, 21, '*'); output2(11, 23, '*');
	output2(11, 57, '*'); output2(11, 59, '*');
	output2(12, 23, '*'); output2(12, 25, '*');
	output2(12, 55, '*'); output2(12, 57, '*');
	output2(13, 25, '*'); output2(13, 27, '*');
	output2(13, 53, '*'); output2(13, 55, '*');
	output2(14, 27, '*'); output2(14, 29, '*');
	output2(14, 51, '*'); output2(14, 53, '*');
	output2(15, 30, '*'); output2(15, 32, '*');
	output2(15, 48, '*'); output2(15, 50, '*');
	output2(16, 33, '*'); output2(16, 35, '*');
	output2(16, 45, '*'); output2(16, 47, '*');
	output2(17, 36, '*'); output2(17, 38, '*');
	output2(17, 42, '*'); output2(17, 44, '*');

	move(0,0);
	refresh();
	sleep(4);

	output2 (5, 20, '*'); output2 (5, 22, '*');
	output2 (5, 58, '*'); output2 (5, 60, '*');
	for (x=6; x<= 9; x++)
	{
		output2 (x, 14+x, '*'); output2 (x, 16+x, '*');
		output2 (x, 64-x, '*'); output2 (x, 66-x, '*');
	}
	output2(10, 25, '*'); output2(10, 27, '*');
	output2(10, 53, '*'); output2(10, 55, '*');
	output2(11, 27, '*'); output2(11, 29, '*');
	output2(11, 51, '*'); output2(11, 53, '*');
	output2(12, 29, '*'); output2(12, 31, '*');
	output2(12, 49, '*'); output2(12, 51, '*');
	output2(13, 31, '*'); output2(13, 33, '*');
	output2(13, 47, '*'); output2(13, 49, '*');
	output2(14, 33, '*'); output2(14, 35, '*');
	output2(14, 45, '*'); output2(14, 47, '*');
	output2(15, 36, '*'); output2(15, 38, '*');
	output2(15, 42, '*'); output2(15, 44, '*');

	move(0,0);
	refresh();
	sleep(4);

	output2 (5, 26, '*'); output2 (5, 28, '*');
	output2 (5, 52, '*'); output2 (5, 54, '*');
	for (x=6; x<= 9; x++)
	{
		output2 (x, 20+x, '*'); output2 (x, 22+x, '*');
		output2 (x, 58-x, '*'); output2 (x, 60-x, '*');
	}
	output2(10, 31, '*'); output2(10, 33, '*');
	output2(10, 47, '*'); output2(10, 49, '*');
	output2(11, 33, '*'); output2(11, 35, '*');
	output2(11, 45, '*'); output2(11, 47, '*');
	output2(12, 35, '*'); output2(12, 37, '*');
	output2(12, 37, '*'); output2(12, 43, '*');

	move(0,0);
	refresh();
	sleep(4);

	output2 (5, 32, '*'); output2 (5, 34, '*');
	output2 (5, 46, '*'); output2 (5, 48, '*');
	for (x=6; x<= 9; x++)
	{
		output2 (x, 26+x, '*'); output2 (x, 28+x, '*');
		output2 (x, 52-x, '*'); output2 (x, 54-x, '*');
	}
	output2(10, 37, '*'); output2(10, 43, '*');

	move(0,0);
	refresh();
	sleep(5);

	output2(3, 39, '|'); output2(3, 41, '|');
	output2(4, 14, '|'); output2(4, 16, '|');
	output2(4, 66, '|'); output2(4, 64, '|');
	output2(4, 60, '|'); output2(4, 58, '|');
	output2(4, 20, '|'); output2(4, 22, '|');
	output2(4, 26, '|'); output2(4, 28, '|');
	output2(4, 54, '|'); output2(4, 52, '|');
	output2(4, 48, '|'); output2(4, 46, '|');
	output2(4, 32, '|'); output2(4, 34, '|');

	move(0,0);
	refresh();
	sleep(5);

	random (0);

	output2(23, 10, 'D'); output2(23, 12, 'A'); output2(23, 14, 'Y');
	output2(23, 16, ':');

	output2(23, 20, '1');
	output2(3, 64, '/'); output2(3, 66, '\\');
	random(1);
	output2(23, 20, '2');
	output2(3, 58, '/'); output2(3, 60, '\\');
	random(2);
	output2(23, 20, '3');
	output2(3, 52, '/'); output2(3, 54, '\\');
	random(3);
	output2(23, 20, '4');
	output2(3, 46, '/'); output2(3, 48, '\\');
	random(4);
	output2(23, 20, '5');
	output2(3, 32, '/'); output2(3, 34, '\\');
	random(5);
	output2(23, 20, '6');
	output2(3, 26, '/'); output2(3, 28, '\\');
	random(6);
	output2(23, 20, '7');
	output2(3, 20, '/'); output2(3, 22, '\\');
	random(7);
	output2(23, 20, '8');
	output2(3, 14, '/'); output2(3, 16, '\\');
	random(8);

	output2(2, 39, '/'); output2(2, 41, '\\');
	output2(3, 14, '/'); output2(3, 16, '\\');
	output2(3, 20, '/'); output2(3, 22, '\\');
	output2(3, 26, '/'); output2(3, 28, '\\');
	output2(3, 32, '/'); output2(3, 34, '\\');
	output2(3, 46, '/'); output2(3, 48, '\\');
	output2(3, 52, '/'); output2(3, 54, '\\');
	output2(3, 58, '/'); output2(3, 60, '\\');
	output2(3, 64, '/'); output2(3, 66, '\\');

	output2(23, 10, ' '); output2(23, 12, ' '); output2(23, 14, ' ');
	output2(23, 16, ' '); output2(23, 20, ' ');
	output2(23, 24, 'H'); output2(23, 26, 'A'); output2(23, 28, 'P');
	output2(23, 30, 'P'); output2(23, 32, 'Y');
	output2(23, 34, ' '); output2(23, 36, 'C');
	output2(23, 38, 'H'); output2(23, 40, 'A'); output2(23, 42, 'N');
	output2(23, 44, 'U'); output2(23, 46, 'K'); output2(23, 48, 'A');
	output2(23, 50, 'H'); output2(23, 52, '!'); output2(23, 54, '!');
	output2(23, 56, '!');

	move(23,0);
	refresh();

	/*
	 * If you don't have the Berkeley "curses" library, delete
	 * this routine call.
	 */
	endwin();
}
output(y, x, c)
int y, x;
char c;
{
	mvaddch(y-1, x, c);
	refresh();

	/*
	 * If your system doesn't have the "nap()" system call,
	 * delete this line.
	 */
	nap(8);
}
output2(y, x, c)
int y, x;
char c;
{
	mvaddch(y-1, x, c);
	refresh();
}


random (day)
	register int day;
{
	register int repeat;

	for (repeat = 0; repeat < FLICKER; repeat++)
		switch (rand() % (3*(day+1)))
		{
			case 0:
				output(2, 39, '/'); output(2, 41, '\\');
				break;
			case 1:
				output(2, 39, '\\'); output(2, 41, '\\');
				break;
			case 2:
				output(2, 39, '/'); output(2, 41, '/');
				break;
			case 3:
				output(3, 64, '/'); output(3, 66, '\\');
				break;
			case 4:
				output(3, 64, '\\'); output(3, 66, '\\');
				break;
			case 5:
				output(3, 64, '/'); output(3, 66, '/');
				break;
			case 6:
				output(3, 58, '/'); output(3, 60, '\\');
				break;
			case 7:
				output(3, 58, '\\'); output(3, 60, '\\');
				break;
			case 8:
				output(3, 58, '/'); output(3, 60, '/');
				break;
			case 9:
				output(3, 52, '/'); output(3, 54, '\\');
				break;
			case 10:
				output(3, 52, '\\'); output(3, 54, '\\');
				break;
			case 11:
				output(3, 52, '/'); output(3, 54, '/');
				break;
			case 12:
				output(3, 46, '/'); output(3, 48, '\\');
				break;
			case 13:
				output(3, 46, '\\'); output(3, 48, '\\');
				break;
			case 14:
				output(3, 46, '/'); output(3, 48, '/');
				break;
			case 15:
				output(3, 32, '/'); output(3, 34, '\\');
				break;
			case 16:
				output(3, 32, '\\'); output(3, 34, '\\');
				break;
			case 17:
				output(3, 32, '/'); output(3, 34, '/');
				break;
			case 18:
				output(3, 26, '/'); output(3, 28, '\\');
				break;
			case 19:
				output(3, 26, '\\'); output(3, 28, '\\');
				break;
			case 20:
				output(3, 26, '/'); output(3, 28, '/');
				break;
			case 21:
				output(3, 20, '/'); output(3, 22, '\\');
				break;
			case 22:
				output(3, 20, '\\'); output(3, 22, '\\');
				break;
			case 23:
				output(3, 20, '/'); output(3, 22, '/');
				break;
			case 24:
				output(3, 14, '/'); output(3, 16, '\\');
				break;
			case 25:
				output(3, 14, '\\'); output(3, 16, '\\');
				break;
			case 26:
				output(3, 14, '/'); output(3, 16, '/');
				break;
		}
}




/*
 * Routines to use if you don't have the Berkeley "curses" library.
 * This version of "move" will work for adm3a, adm3a+, and adm5 terminals,
 * along with this version of "clear".
 *
 * Note: the adm terminals above use the following sequence for cursor
 *	 control:
 *			033=YX
 *		where:
 *			033 = escape character
 *			Y   = number between 0 and 23 added to 040 (space)
 *			X   = number between 0 and 79 added to 040 (space)
 *
 *	 And a control-Z (ASCII 032) to clear the screen.
 *
 */

/************** DELETE THIS LINE TO USE THESE ROUTINES *********************

#include <stdio.h>

move(y, x)
int y, x;
{
	printf("\033=%c%c", (y+' '), (x+' '));
}
clear()
{
	putchar('\032');
}
mvaddch(y, x, c)
int y, x;
char c;
{
	move(y, x);
	putchar(c);
}
refresh()
{
	fflush(stdout);
}

	*/