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 "output()" 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); output(4, 39, '*'); output(4, 41, '*'); output(5, 39, '*'); output(5, 41, '*'); output(6, 39, '*'); output(6, 41, '*'); output(7, 39, '*'); output(7, 41, '*'); output(8, 39, '*'); output(8, 41, '*'); output(9, 39, '*'); output(9, 41, '*'); output(10, 39, '*'); output(10, 41, '*'); output(11, 39, '*'); output(11, 41, '*'); output(12, 39, '*'); output(12, 41, '*'); output(13, 39, '*'); output(13, 41, '*'); output(14, 39, '*'); output(14, 41, '*'); output(15, 39, '*'); output(15, 41, '*'); output(16, 39, '*'); output(16, 41, '*'); output(17, 39, '*'); output(17, 41, '*'); output(18, 39, '*'); output(18, 41, '*'); output(19, 36, '*'); output(19, 44, '*'); output(20, 34, '*'); output(20, 46, '*'); for (x = 35; x <= 45; x++) output (21, x, '_'); move(0,0); refresh(); sleep(4); output (5, 14, '*'); output (5, 16, '*'); output (5, 64, '*'); output (5, 66, '*'); for (x=6; x<= 9; x++) { output (x, 8+x, '*'); output (x, 10+x, '*'); output (x, 70-x, '*'); output (x, 72-x, '*'); } output(10, 19, '*'); output(10, 21, '*'); output(10, 59, '*'); output(10, 61, '*'); output(11, 21, '*'); output(11, 23, '*'); output(11, 57, '*'); output(11, 59, '*'); output(12, 23, '*'); output(12, 25, '*'); output(12, 55, '*'); output(12, 57, '*'); output(13, 25, '*'); output(13, 27, '*'); output(13, 53, '*'); output(13, 55, '*'); output(14, 27, '*'); output(14, 29, '*'); output(14, 51, '*'); output(14, 53, '*'); output(15, 30, '*'); output(15, 32, '*'); output(15, 48, '*'); output(15, 50, '*'); output(16, 33, '*'); output(16, 35, '*'); output(16, 45, '*'); output(16, 47, '*'); output(17, 36, '*'); output(17, 38, '*'); output(17, 42, '*'); output(17, 44, '*'); move(0,0); refresh(); sleep(4); output (5, 20, '*'); output (5, 22, '*'); output (5, 58, '*'); output (5, 60, '*'); for (x=6; x<= 9; x++) { output (x, 14+x, '*'); output (x, 16+x, '*'); output (x, 64-x, '*'); output (x, 66-x, '*'); } output(10, 25, '*'); output(10, 27, '*'); output(10, 53, '*'); output(10, 55, '*'); output(11, 27, '*'); output(11, 29, '*'); output(11, 51, '*'); output(11, 53, '*'); output(12, 29, '*'); output(12, 31, '*'); output(12, 49, '*'); output(12, 51, '*'); output(13, 31, '*'); output(13, 33, '*'); output(13, 47, '*'); output(13, 49, '*'); output(14, 33, '*'); output(14, 35, '*'); output(14, 45, '*'); output(14, 47, '*'); output(15, 36, '*'); output(15, 38, '*'); output(15, 42, '*'); output(15, 44, '*'); move(0,0); refresh(); sleep(4); output (5, 26, '*'); output (5, 28, '*'); output (5, 52, '*'); output (5, 54, '*'); for (x=6; x<= 9; x++) { output (x, 20+x, '*'); output (x, 22+x, '*'); output (x, 58-x, '*'); output (x, 60-x, '*'); } output(10, 31, '*'); output(10, 33, '*'); output(10, 47, '*'); output(10, 49, '*'); output(11, 33, '*'); output(11, 35, '*'); output(11, 45, '*'); output(11, 47, '*'); output(12, 35, '*'); output(12, 37, '*'); output(12, 37, '*'); output(12, 43, '*'); move(0,0); refresh(); sleep(4); output (5, 32, '*'); output (5, 34, '*'); output (5, 46, '*'); output (5, 48, '*'); for (x=6; x<= 9; x++) { output (x, 26+x, '*'); output (x, 28+x, '*'); output (x, 52-x, '*'); output (x, 54-x, '*'); } output(10, 37, '*'); output(10, 43, '*'); move(0,0); refresh(); sleep(5); output(3, 39, '|'); output(3, 41, '|'); output(4, 14, '|'); output(4, 16, '|'); output(4, 66, '|'); output(4, 64, '|'); output(4, 60, '|'); output(4, 58, '|'); output(4, 20, '|'); output(4, 22, '|'); output(4, 26, '|'); output(4, 28, '|'); output(4, 54, '|'); output(4, 52, '|'); output(4, 48, '|'); output(4, 46, '|'); output(4, 32, '|'); output(4, 34, '|'); move(0,0); refresh(); sleep(5); random (0); output(23, 10, 'D'); output(23, 12, 'A'); output(23, 14, 'Y'); output(23, 16, ':'); output(23, 20, '1'); output(3, 64, '/'); output(3, 66, '\\'); random(1); output(23, 20, '2'); output(3, 58, '/'); output(3, 60, '\\'); random(2); output(23, 20, '3'); output(3, 52, '/'); output(3, 54, '\\'); random(3); output(23, 20, '4'); output(3, 46, '/'); output(3, 48, '\\'); random(4); output(23, 20, '5'); output(3, 32, '/'); output(3, 34, '\\'); random(5); output(23, 20, '6'); output(3, 26, '/'); output(3, 28, '\\'); random(6); output(23, 20, '7'); output(3, 20, '/'); output(3, 22, '\\'); random(7); output(23, 20, '8'); output(3, 14, '/'); output(3, 16, '\\'); random(8); output(2, 39, '/'); output(2, 41, '\\'); output(3, 14, '/'); output(3, 16, '\\'); output(3, 20, '/'); output(3, 22, '\\'); output(3, 26, '/'); output(3, 28, '\\'); output(3, 32, '/'); output(3, 34, '\\'); output(3, 46, '/'); output(3, 48, '\\'); output(3, 52, '/'); output(3, 54, '\\'); output(3, 58, '/'); output(3, 60, '\\'); output(3, 64, '/'); output(3, 66, '\\'); output(23, 10, ' '); output(23, 12, ' '); output(23, 14, ' '); output(23, 16, ' '); output(23, 20, ' '); output(23, 24, 'H'); output(23, 26, 'A'); output(23, 28, 'P'); output(23, 30, 'P'); output(23, 32, 'Y'); output(23, 34, ' '); output(23, 36, 'C'); output(23, 38, 'H'); output(23, 40, 'A'); output(23, 42, 'N'); output(23, 44, 'U'); output(23, 46, 'K'); output(23, 48, 'A'); output(23, 50, 'H'); output(23, 52, '!'); output(23, 54, '!'); output(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(15); } 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); } */