marks@mgse.UUCP (Mark Seiffert) (05/03/89)
Here is a little program i wrote while i was learning curses. It compiles under SCO Xenix, and should compile under Unix as well. It will also compile under MS-DOS if you have the Aspen Scientific Curses library. You may have to create your own nap() function for MS-DOS, to insert a pause in the program, or you can ignore nap() all together. Please send bug reports back to me at rex!mgse!marks. #! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # The tool that generated this appeared in the comp.sources.unix newsgroup; # send mail to comp-sources-unix@uunet.uu.net if you want that tool. # If this archive is complete, you will see the following message at the end: # "End of shell archive." # Contents: bite.doc bite.c makefile.sco makefile.unix makefile.msc # Wrapped by root@mgse on Wed May 3 07:26:05 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'bite.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'bite.doc'\" else echo shar: Extracting \"'bite.doc'\" \(1511 characters\) sed "s/^X//" >'bite.doc' <<'END_OF_FILE' XBite is like a program I found in the /usr/games directory on a Sanyo Icon X4000 system I worked on for a little while. It uses the curses library under XXenix and Unix, and the aspen curses library under MS/PC-DOS. Makefiles are Xprovided for Xenix make as well as MicroSquishy's backwards make program. X XTo compile, extract the files from the distribution, rename the makefile for Xyour system to 'makefile', and type make. There are makefiles for Xenix, XUnix, and microsoft make. The Xenix version of bite requires the Terminfo Xcurses library, not Termcap, I would guess the Unix version does as well. Once Xyou have compiled the program, move it into your games directory. X XOther than possibly requiring terminfo instead of termcap, this program Xalso uses the nap() function to pause for a half and quarter second. Some Xsystems may not have this function. I think the select() function is a Xreplacement for nap() on these systems. X XTo compile with MSC and aspen scientific's type 'make makefile.msc'. you may Xhave to change the makefile to reflect the location of your curses libraries. X XTo terminate the program press any key. X XFor more information on the aspen scientific curses library, contact Xaspen scientific Xp.o. box 72 Xwheat ridge, co., 80034-0072 X(303) 423-8088 X XPlease send bug reports, and hopefully corrections to me at the follow Xaddress; X XMark Seiffert, Metairie, LA. X Xuucp: rex!mgse!marks Xbitnet: marks%mgse@REX.CS.TULANE.EDU Xinternet: marks%mgse@rex.cs.tulane.edu END_OF_FILE echo shar: NEWLINE appended to \"'bite.doc'\" if test 1512 -ne `wc -c <'bite.doc'`; then echo shar: \"'bite.doc'\" unpacked with wrong size! fi # end of 'bite.doc' fi if test -f 'bite.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'bite.c'\" else echo shar: Extracting \"'bite.c'\" \(3441 characters\) sed "s/^X//" >'bite.c' <<'END_OF_FILE' X#include <curses.h> X#ifdef unix /* Xenix needs this for... */ X#include <signal.h> /* signal handling */ X#endif X Xstatic char Sccsid[] = "bite.c 1.5 5/3/89"; X X#ifdef unix Xdone() /* signal handler routine */ X{ X endwin(); /* terminate curses handling */ X exit(0); /* and exit to OS */ X} X#endif X Xmain() X{ X#ifdef unix /* if compiled under xenix OS */ X signal(SIGINT, done); /* set up some signals */ X signal(SIGQUIT, done); /* have to trap INTR for */ X signal(SIGKILL, done); /* endwin(). */ X#endif X initscr(); /* initialize screen handling */ X X nodelay(stdscr, TRUE); /* don't wait for char on input */ X raw(); X noecho(); X nonl(); X /* draw face, lip up */ X clear(); X X mvaddstr( 2,30, "__---------__"); X mvaddstr( 3,28, "_~ ~_"); X mvaddstr( 4,27, "/ \\"); X mvaddstr( 5,26, "~ ~"); X mvaddstr( 6,25,"/ \\"); X mvaddstr( 7,25,"| |"); X mvaddstr( 8,25,"| |"); X mvaddstr( 9,25,"| |"); X mvaddstr(10,26, "\\ /"); X mvaddstr(11,27, "--\\ /--"); X mvaddstr(12,28, "| | | |"); X mvaddstr(13,28, "| | | |"); X mvaddstr(14,28, "| vvVvvvvvvvVvv |"); X mvaddstr(15,28, "| ^^^^^^^^^^^ |"); X mvaddstr(16,29, "\\_ _/"); X mvaddstr(17,31, "~---------~"); X X attrset(A_REVERSE); /* set reverse screen attributes */ X mvaddstr( 7,30, "XXXX"); /* draw left eye */ X mvaddstr( 8,30, "XXXX"); X mvaddstr( 9,30, "XXX"); X X mvaddstr( 7,39, "XXXX"); /* draw right eye */ X mvaddstr( 8,39, "XXXX"); X mvaddstr( 9,40, "XXX"); X X mvaddstr(10,36, "@"); /* draw nose */ X mvaddstr(11,35, "@@@"); X mvaddstr(12,35, "@@@"); X X attrset(A_NORMAL); /* set normal screen attributes */ X refresh(); /* draw screen with face */ X X while (TRUE) { /* a for ever loop */ X mvaddstr(15,31, " "); /* move lower lip down */ X mvaddstr(16,31, "^^^^^^^^^^^"); X refresh(); /* redraw screen */ X X (void) nap((long)500); /* wait awhile */ X X mvaddstr(15,31, "^^^^^^^^^^^"); /* move lower lip up */ X mvaddstr(16,31, " "); X refresh(); /* redraw screen */ X if (getch() != -1) { /* if a key has been hit */ X break; /* break from while loop */ X } X (void) nap((long)250); /* wait little awhile */ X } X#ifdef unix X/* a bug in curses? it no delay is not turned off, the Xbourne shell logs out, and the c-shell has to be killed off. the problem Xdoes not exist with the aspen curses library. i would guess that endwin() Xis not entirely resetting the terminal entry state */ X nodelay(stdscr, FALSE); X#endif X X/* I think i have the problem figured out. the function nodelay(), when XTRUE, will cause getch() to return a -1 if there is no character waiting, or Xthe character if there is one. this is all fine and dandy, but endwin() is Xnot resetting nodelay() to FALSE when it is called, so when you exit to Xthe bourne shell, it trys to read a character, gets a -1 and exits the Xshell, thinking that the user has typed a ^D, the EOF character. In the Xc-shell, it works the same way, except if you have ignoreeof set, the Xdefault when shipped from sco. if ignoreeof is set, when get a message Xtelling you to type exit to logout, and the c-shell trys to read another Xcharacter, gets a -1, and the sequence repeats until the process is killed Xfrom another terminal. neat. now is this a bug a feature or what??? X*/ X X endwin(); /* terminate curses */ X} X END_OF_FILE echo shar: NEWLINE appended to \"'bite.c'\" if test 3442 -ne `wc -c <'bite.c'`; then echo shar: \"'bite.c'\" unpacked with wrong size! fi # end of 'bite.c' fi if test -f 'makefile.sco' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'makefile.sco'\" else echo shar: Extracting \"'makefile.sco'\" \(114 characters\) sed "s/^X//" >'makefile.sco' <<'END_OF_FILE' Xbite: bite.o X cc -Ox bite.o -lx -ltinfo -s -o bite X fixhdr -F 2000 bite X Xbite.o: bite.c X cc -c -Dunix -Ox bite.c X END_OF_FILE echo shar: NEWLINE appended to \"'makefile.sco'\" if test 115 -ne `wc -c <'makefile.sco'`; then echo shar: \"'makefile.sco'\" unpacked with wrong size! fi # end of 'makefile.sco' fi if test -f 'makefile.unix' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'makefile.unix'\" else echo shar: Extracting \"'makefile.unix'\" \(89 characters\) sed "s/^X//" >'makefile.unix' <<'END_OF_FILE' Xbite: bite.o X cc -O bite.o -lcurses -s -o bite X Xbite.o: bite.c X cc -c -Dunix -Ox bite.c X END_OF_FILE echo shar: NEWLINE appended to \"'makefile.unix'\" if test 90 -ne `wc -c <'makefile.unix'`; then echo shar: \"'makefile.unix'\" unpacked with wrong size! fi # end of 'makefile.unix' fi if test -f 'makefile.msc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'makefile.msc'\" else echo shar: Extracting \"'makefile.msc'\" \(123 characters\) sed "s/^X//" >'makefile.msc' <<'END_OF_FILE' X Xbite.obj: bite.c X cc -c -Ox bite.c X Xbite.exe: bite.obj X cc -Ox bite.obj \msc\lib\scurses.lib X END_OF_FILE echo shar: NEWLINE appended to \"'makefile.msc'\" if test 124 -ne `wc -c <'makefile.msc'`; then echo shar: \"'makefile.msc'\" unpacked with wrong size! fi # end of 'makefile.msc' fi echo shar: End of shell archive. exit 0