1 /******************************************************************************/
3 /* December 1989 Larry Bartz Indianapolis, IN */
6 /* I'm dreaming of an ascii character-based monochrome Christmas, */
7 /* Just like the one's I used to know! */
8 /* Via a full duplex communications channel, */
9 /* At 9600 bits per second, */
10 /* Even though it's kinda slow. */
12 /* I'm dreaming of an ascii character-based monochrome Christmas, */
13 /* With ev'ry C program I write! */
14 /* May your screen be merry and bright! */
15 /* And may all your Christmases be amber or green, */
16 /* (for reduced eyestrain and improved visibility)! */
22 /* Feel free to modify the defined string FROMWHO to reflect you, your */
23 /* organization, your site, whatever. */
25 /* This looks a lot better if you can turn off your cursor before execution. */
26 /* The cursor is distracting but it doesn't really ruin the show. */
28 /* At our site, we invoke this for our users just after login and the */
29 /* determination of terminal type. */
34 /* I wrote this using only the very simplest curses functions so that it */
35 /* might be the most portable. I was personally able to test on five */
36 /* different cpu/UNIX combinations. */
43 /* cc -O xmas.c -lcurses -o xmas -s */
45 /******************************************************************************/
47 /* $Id: xmas.c,v 1.29 2008/07/13 16:08:17 wmcbrine Exp $ */
53 void midtop(WINDOW
*);
54 void bigtop(WINDOW
*);
55 void bigface(WINDOW
*, chtype
);
77 #define FROMWHO "From Larry Bartz, Mark Hessling and William McBrine"
81 WINDOW
*treescrn
, *treescrn2
, *treescrn3
, *treescrn4
, *treescrn5
,
82 *treescrn6
, *treescrn7
, *treescrn8
, *dotdeer0
, *stardeer0
,
83 *lildeer0
, *lildeer1
, *lildeer2
, *lildeer3
, *middeer0
,
84 *middeer1
, *middeer2
, *middeer3
, *bigdeer0
, *bigdeer1
,
85 *bigdeer2
, *bigdeer3
, *bigdeer4
, *lookdeer0
, *lookdeer1
,
86 *lookdeer2
, *lookdeer3
, *lookdeer4
, *w_holiday
, *w_del_msg
;
88 int main(int argc
, char **argv
)
97 nodelay(stdscr
, TRUE
);
108 treescrn
= newwin(16, 27, 3, 53);
109 treescrn2
= newwin(16, 27, 3, 53);
110 treescrn3
= newwin(16, 27, 3, 53);
111 treescrn4
= newwin(16, 27, 3, 53);
112 treescrn5
= newwin(16, 27, 3, 53);
113 treescrn6
= newwin(16, 27, 3, 53);
114 treescrn7
= newwin(16, 27, 3, 53);
115 treescrn8
= newwin(16, 27, 3, 53);
117 w_holiday
= newwin(1, 26, 3, 27);
119 w_del_msg
= newwin(1, 12, 23, 60);
121 mvwaddstr(w_holiday
, 0, 0, "H A P P Y H O L I D A Y S");
166 /* set up the windows for our blinking trees */
167 /* **************************************** */
170 overlay(treescrn
, treescrn3
);
173 mvwaddch(treescrn3
, 4, 18, ' ');
174 mvwaddch(treescrn3
, 7, 6, ' ');
175 mvwaddch(treescrn3
, 8, 19, ' ');
176 mvwaddch(treescrn3
, 11, 22, ' ');
179 mvwaddch(treescrn3
, 0, 12, '*');
182 mvwaddch(treescrn3
, 3, 11, ' ');
185 mvwaddch(treescrn3
, 5, 13, ' ');
186 mvwaddch(treescrn3
, 6, 10, ' ');
189 mvwaddch(treescrn3
, 7, 16, ' ');
190 mvwaddch(treescrn3
, 7, 14, ' ');
193 mvwaddch(treescrn3
, 10, 13, ' ');
194 mvwaddch(treescrn3
, 10, 10, ' ');
195 mvwaddch(treescrn3
, 11, 8, ' ');
198 mvwaddch(treescrn3
, 11, 18, ' ');
199 mvwaddch(treescrn3
, 12, 13, ' ');
203 overlay(treescrn
, treescrn4
);
206 mvwaddch(treescrn4
, 3, 9, ' ');
207 mvwaddch(treescrn4
, 4, 16, ' ');
208 mvwaddch(treescrn4
, 7, 6, ' ');
209 mvwaddch(treescrn4
, 8, 19, ' ');
210 mvwaddch(treescrn4
, 11, 2, ' ');
211 mvwaddch(treescrn4
, 12, 23, ' ');
214 mvwaddch(treescrn4
, 0, 12, '*' | A_STANDOUT
);
217 mvwaddch(treescrn4
, 3, 13, ' ');
222 mvwaddch(treescrn4
, 7, 15, ' ');
223 mvwaddch(treescrn4
, 8, 11, ' ');
226 mvwaddch(treescrn4
, 9, 16, ' ');
227 mvwaddch(treescrn4
, 10, 12, ' ');
228 mvwaddch(treescrn4
, 11, 8, ' ');
231 mvwaddch(treescrn4
, 11, 18, ' ');
232 mvwaddch(treescrn4
, 12, 14, ' ');
236 overlay(treescrn
, treescrn5
);
239 mvwaddch(treescrn5
, 3, 15, ' ');
240 mvwaddch(treescrn5
, 10, 20, ' ');
241 mvwaddch(treescrn5
, 12, 1, ' ');
244 mvwaddch(treescrn5
, 0, 12, '*');
247 mvwaddch(treescrn5
, 3, 11, ' ');
250 mvwaddch(treescrn5
, 5, 12, ' ');
253 mvwaddch(treescrn5
, 7, 14, ' ');
254 mvwaddch(treescrn5
, 8, 10, ' ');
257 mvwaddch(treescrn5
, 9, 15, ' ');
258 mvwaddch(treescrn5
, 10, 11, ' ');
259 mvwaddch(treescrn5
, 11, 7, ' ');
262 mvwaddch(treescrn5
, 11, 17, ' ');
263 mvwaddch(treescrn5
, 12, 13, ' ');
267 overlay(treescrn
, treescrn6
);
270 mvwaddch(treescrn6
, 6, 7, ' ');
271 mvwaddch(treescrn6
, 7, 18, ' ');
272 mvwaddch(treescrn6
, 10, 4, ' ');
273 mvwaddch(treescrn6
, 11, 23, ' ');
276 mvwaddch(treescrn6
, 0, 12, '*' | A_STANDOUT
);
281 mvwaddch(treescrn6
, 5, 11, ' ');
284 mvwaddch(treescrn6
, 7, 13, ' ');
285 mvwaddch(treescrn6
, 8, 9, ' ');
288 mvwaddch(treescrn6
, 9, 14, ' ');
289 mvwaddch(treescrn6
, 10, 10, ' ');
290 mvwaddch(treescrn6
, 11, 6, ' ');
293 mvwaddch(treescrn6
, 11, 16, ' ');
294 mvwaddch(treescrn6
, 12, 12, ' ');
298 overlay(treescrn
, treescrn7
);
301 mvwaddch(treescrn7
, 3, 15, ' ');
302 mvwaddch(treescrn7
, 6, 7, ' ');
303 mvwaddch(treescrn7
, 7, 18, ' ');
304 mvwaddch(treescrn7
, 10, 4, ' ');
305 mvwaddch(treescrn7
, 11, 22, ' ');
308 mvwaddch(treescrn7
, 0, 12, '*');
311 mvwaddch(treescrn7
, 3, 12, ' ');
314 mvwaddch(treescrn7
, 5, 13, ' ');
315 mvwaddch(treescrn7
, 6, 9, ' ');
318 mvwaddch(treescrn7
, 7, 15, ' ');
319 mvwaddch(treescrn7
, 8, 11, ' ');
322 mvwaddch(treescrn7
, 9, 16, ' ');
323 mvwaddch(treescrn7
, 10, 12, ' ');
324 mvwaddch(treescrn7
, 11, 8, ' ');
327 mvwaddch(treescrn7
, 11, 18, ' ');
328 mvwaddch(treescrn7
, 12, 14, ' ');
339 for (loopy
= 0; loopy
< 50; loopy
++)
349 void lil(WINDOW
*win
)
351 mvwaddch(win
, 0, 0, (chtype
) 'V');
352 mvwaddch(win
, 1, 0, (chtype
) '@');
353 mvwaddch(win
, 1, 3, (chtype
) '~');
356 void midtop(WINDOW
*win
)
358 mvwaddstr(win
, 0, 2, "yy");
359 mvwaddstr(win
, 1, 2, "0(=)~");
362 void bigtop(WINDOW
*win
)
364 mvwaddstr(win
, 0, 17, "\\/");
365 mvwaddstr(win
, 0, 20, "\\/");
366 mvwaddch(win
, 1, 18, (chtype
) '\\');
367 mvwaddch(win
, 1, 20, (chtype
) '/');
368 mvwaddstr(win
, 2, 19, "|_");
369 mvwaddstr(win
, 3, 18, "/^0\\");
370 mvwaddstr(win
, 4, 17, "//\\");
371 mvwaddch(win
, 4, 22, (chtype
) '\\');
372 mvwaddstr(win
, 5, 7, "^~~~~~~~~// ~~U");
375 void bigface(WINDOW
*win
, chtype noseattr
)
377 mvwaddstr(win
, 0, 16, "\\/ \\/");
378 mvwaddstr(win
, 1, 17, "\\Y/ \\Y/");
379 mvwaddstr(win
, 2, 19, "\\=/");
380 mvwaddstr(win
, 3, 17, "^\\o o/^");
381 mvwaddstr(win
, 4, 17, "//( )");
382 mvwaddstr(win
, 5, 7, "^~~~~~~~~// \\");
383 waddch(win
, 'O' | noseattr
);
387 void legs1(WINDOW
*win
)
389 mvwaddstr(win
, 6, 7, "( \\_____( /");
390 mvwaddstr(win
, 7, 8, "( ) /");
391 mvwaddstr(win
, 8, 9, "\\\\ /");
392 mvwaddstr(win
, 9, 11, "\\>/>");
395 void legs2(WINDOW
*win
)
397 mvwaddstr(win
, 6, 7, "(( )____( /");
398 mvwaddstr(win
, 7, 7, "( / |");
399 mvwaddstr(win
, 8, 8, "\\/ |");
400 mvwaddstr(win
, 9, 9, "|> |>");
403 void legs3(WINDOW
*win
)
405 mvwaddstr(win
, 6, 6, "( ()_____( /");
406 mvwaddstr(win
, 7, 6, "/ / /");
407 mvwaddstr(win
, 8, 5, "|/ \\");
408 mvwaddstr(win
, 9, 5, "/> \\>");
411 void legs4(WINDOW
*win
)
413 mvwaddstr(win
, 6, 6, "( )______( /");
414 mvwaddstr(win
, 7, 5, "(/ \\");
415 mvwaddstr(win
, 8, 0, "v___= ----^");
425 init_pair(31, COLOR_RED
, COLOR_BLACK
);
426 noseattr
= COLOR_PAIR(31);
432 /* set up the windows for our various reindeer */
434 dotdeer0
= newwin(3, 71, 0, 8);
435 stardeer0
= newwin(4, 56, 0, 8);
436 lildeer0
= newwin(7, 54, 0, 8);
437 middeer0
= newwin(15, 42, 0, 8);
438 bigdeer0
= newwin(10, 23, 0, 0);
439 lookdeer0
= newwin(10, 25, 0, 0);
442 lildeer1
= newwin(2, 4, 0, 0);
444 mvwaddstr(lildeer1
, 1, 1, "<>");
447 lildeer2
= newwin(2, 4, 0, 0);
449 mvwaddstr(lildeer2
, 1, 1, "||");
452 lildeer3
= newwin(2, 4, 0, 0);
454 mvwaddstr(lildeer3
, 1, 1, "><");
457 middeer1
= newwin(3, 7, 0, 0);
459 mvwaddstr(middeer1
, 2, 3, "\\/");
462 middeer2
= newwin(3, 7, 0, 0);
464 mvwaddch(middeer2
, 2, 3, (chtype
) '|');
465 mvwaddch(middeer2
, 2, 5, (chtype
) '|');
468 middeer3
= newwin(3, 7, 0, 0);
470 mvwaddch(middeer3
, 2, 2, (chtype
) '/');
471 mvwaddch(middeer3
, 2, 6, (chtype
) '\\');
474 bigdeer1
= newwin(10, 23, 0, 0);
479 bigdeer2
= newwin(10, 23, 0, 0);
484 bigdeer3
= newwin(10, 23, 0, 0);
489 bigdeer4
= newwin(10, 23, 0, 0);
494 lookdeer1
= newwin(10, 25, 0, 0);
495 bigface(lookdeer1
, noseattr
);
499 lookdeer2
= newwin(10, 25, 0, 0);
500 bigface(lookdeer2
, noseattr
);
504 lookdeer3
= newwin(10, 25, 0, 0);
505 bigface(lookdeer3
, noseattr
);
509 lookdeer4
= newwin(10, 25, 0, 0);
510 bigface(lookdeer4
, noseattr
);
518 for (x
= 0; x
< 20; ++x
)
521 for (x
= 0; x
< 80; ++x
)
557 mvaddstr(21, 13, FROMWHO
);
570 init_pair(30, COLOR_GREEN
, COLOR_BLACK
);
571 wattrset(treescrn
, COLOR_PAIR(30));
574 mvwaddch(treescrn
, 1, 11, (chtype
) '/');
575 mvwaddch(treescrn
, 2, 11, (chtype
) '/');
576 mvwaddch(treescrn
, 3, 10, (chtype
) '/');
577 mvwaddch(treescrn
, 4, 9, (chtype
) '/');
578 mvwaddch(treescrn
, 5, 9, (chtype
) '/');
579 mvwaddch(treescrn
, 6, 8, (chtype
) '/');
580 mvwaddch(treescrn
, 7, 7, (chtype
) '/');
581 mvwaddch(treescrn
, 8, 6, (chtype
) '/');
582 mvwaddch(treescrn
, 9, 6, (chtype
) '/');
583 mvwaddch(treescrn
, 10, 5, (chtype
) '/');
584 mvwaddch(treescrn
, 11, 3, (chtype
) '/');
585 mvwaddch(treescrn
, 12, 2, (chtype
) '/');
587 mvwaddch(treescrn
, 1, 13, (chtype
) '\\');
588 mvwaddch(treescrn
, 2, 13, (chtype
) '\\');
589 mvwaddch(treescrn
, 3, 14, (chtype
) '\\');
590 mvwaddch(treescrn
, 4, 15, (chtype
) '\\');
591 mvwaddch(treescrn
, 5, 15, (chtype
) '\\');
592 mvwaddch(treescrn
, 6, 16, (chtype
) '\\');
593 mvwaddch(treescrn
, 7, 17, (chtype
) '\\');
594 mvwaddch(treescrn
, 8, 18, (chtype
) '\\');
595 mvwaddch(treescrn
, 9, 18, (chtype
) '\\');
596 mvwaddch(treescrn
, 10, 19, (chtype
) '\\');
597 mvwaddch(treescrn
, 11, 21, (chtype
) '\\');
598 mvwaddch(treescrn
, 12, 22, (chtype
) '\\');
600 mvwaddch(treescrn
, 4, 10, (chtype
) '_');
601 mvwaddch(treescrn
, 4, 14, (chtype
) '_');
602 mvwaddch(treescrn
, 8, 7, (chtype
) '_');
603 mvwaddch(treescrn
, 8, 17, (chtype
) '_');
605 mvwaddstr(treescrn
, 13, 0,
606 "//////////// \\\\\\\\\\\\\\\\\\\\\\\\");
611 init_pair(20, COLOR_YELLOW
, COLOR_BLACK
);
612 wattrset(treescrn
, COLOR_PAIR(20));
615 mvwaddstr(treescrn
, 14, 11, "| |");
616 mvwaddstr(treescrn
, 15, 11, "|_|");
624 chtype ball1
, ball2
, ball3
, ball4
, ball5
, ball6
;
626 overlay(treescrn
, treescrn2
);
631 init_pair(1, COLOR_BLUE
, COLOR_BLACK
);
632 init_pair(2, COLOR_RED
, COLOR_BLACK
);
633 init_pair(3, COLOR_MAGENTA
, COLOR_BLACK
);
634 init_pair(4, COLOR_CYAN
, COLOR_BLACK
);
635 init_pair(5, COLOR_YELLOW
, COLOR_BLACK
);
636 init_pair(6, COLOR_WHITE
, COLOR_BLACK
);
637 ball1
= COLOR_PAIR(1) | '@';
638 ball2
= COLOR_PAIR(2) | '@';
639 ball3
= COLOR_PAIR(3) | '@';
640 ball4
= COLOR_PAIR(4) | '@';
641 ball5
= COLOR_PAIR(5) | '@';
642 ball6
= COLOR_PAIR(6) | '@';
646 ball1
= ball2
= ball3
= ball4
= ball5
= ball6
= '@';
648 mvwaddch(treescrn2
, 3, 9, ball1
);
649 mvwaddch(treescrn2
, 3, 15, ball2
);
650 mvwaddch(treescrn2
, 4, 8, ball3
);
651 mvwaddch(treescrn2
, 4, 16, ball4
);
652 mvwaddch(treescrn2
, 5, 7, ball5
);
653 mvwaddch(treescrn2
, 5, 17, ball6
);
654 mvwaddch(treescrn2
, 7, 6, ball1
| A_BOLD
);
655 mvwaddch(treescrn2
, 7, 18, ball2
| A_BOLD
);
656 mvwaddch(treescrn2
, 8, 5, ball3
| A_BOLD
);
657 mvwaddch(treescrn2
, 8, 19, ball4
| A_BOLD
);
658 mvwaddch(treescrn2
, 10, 4, ball5
| A_BOLD
);
659 mvwaddch(treescrn2
, 10, 20, ball6
| A_BOLD
);
660 mvwaddch(treescrn2
, 11, 2, ball1
);
661 mvwaddch(treescrn2
, 11, 22, ball2
);
662 mvwaddch(treescrn2
, 12, 1, ball3
);
663 mvwaddch(treescrn2
, 12, 23, ball4
);
671 mvwaddch(treescrn2
, 0, 12, (chtype
) '*' | A_STANDOUT
);
682 init_pair(10, COLOR_YELLOW
, COLOR_BLACK
);
683 wattrset(treescrn2
, COLOR_PAIR(10) | A_BOLD
);
686 mvwaddstr(treescrn2
, 3, 11, ".:'");
697 init_pair(11, COLOR_RED
, COLOR_BLACK
);
698 wattrset(treescrn2
, COLOR_PAIR(11) | A_BOLD
);
701 mvwaddstr(treescrn2
, 5, 11, ",.:'");
702 mvwaddstr(treescrn2
, 6, 9, ":'");
713 init_pair(12, COLOR_GREEN
, COLOR_BLACK
);
714 wattrset(treescrn2
, COLOR_PAIR(12) | A_BOLD
);
717 mvwaddstr(treescrn2
, 7, 13, ",.:'");
718 mvwaddstr(treescrn2
, 8, 9, ",.:'");
729 init_pair(13, COLOR_WHITE
, COLOR_BLACK
);
730 wattrset(treescrn2
, COLOR_PAIR(13) | A_BOLD
);
733 mvwaddstr(treescrn2
, 9, 14, ",.:'");
734 mvwaddstr(treescrn2
, 10, 10, ",.:'");
735 mvwaddstr(treescrn2
, 11, 6, ",.:'");
736 mvwaddch(treescrn2
, 12, 5, (chtype
) '\'');
747 init_pair(14, COLOR_CYAN
, COLOR_BLACK
);
748 wattrset(treescrn2
, COLOR_PAIR(14) | A_BOLD
);
751 mvwaddstr(treescrn2
, 11, 16, ",.:'");
752 mvwaddstr(treescrn2
, 12, 12, ",.:'");
754 /* save a fully lit tree */
755 overlay(treescrn2
, treescrn
);
773 overlay(treescrn3
, treescrn8
);
777 overlay(treescrn4
, treescrn8
);
781 overlay(treescrn5
, treescrn8
);
785 overlay(treescrn6
, treescrn8
);
789 overlay(treescrn7
, treescrn8
);
798 /*ALL ON************************************************** */
800 overlay(treescrn
, treescrn8
);
807 #define TSHOW(win, pause) touchwin(win); wrefresh(win); \
808 wrefresh(w_del_msg); napms(pause)
810 #define SHOW(win, pause) mvwin(win, y_pos, x_pos); wrefresh(win); \
811 wrefresh(w_del_msg); napms(pause)
819 for (x_pos
= 70; x_pos
> 62; x_pos
--)
824 for (looper
= 0; looper
< 4; looper
++)
826 mvwaddch(dotdeer0
, y_pos
, x_pos
, (chtype
) '.');
837 for (; x_pos
> 50; x_pos
--)
839 for (looper
= 0; looper
< 4; looper
++)
845 mvwaddch(stardeer0
, y_pos
, x_pos
, (chtype
) '*');
853 mvwaddch(dotdeer0
, y_pos
, x_pos
, (chtype
) '*');
865 for (y_pos
= 2; y_pos
< 5; y_pos
++)
869 for (looper
= 0; looper
< 4; looper
++)
885 for (y_pos
= 5; y_pos
< 10; y_pos
++)
891 for (looper
= 0; looper
< 2; looper
++)
909 for (x_pos
= 8; x_pos
< 16; x_pos
++)
923 for (looper
= 0; looper
< 6; looper
++)
936 for (; y_pos
< 10; y_pos
++)
938 for (looper
= 0; looper
< 2; looper
++)
954 mvwin(lookdeer3
, y_pos
, x_pos
);