billr@saab.CNA.TEK.COM (Bill Randle) (07/19/89)
Submitted-by: "Scott S. Snyder" <ssnyder@tybalt.caltech.edu>
Posting-number: Volume 7, Issue 42
Archive-name: ularn/Patch2a
Patch-To: ularn: Volume 7, Issue 1-9
[[This posting contains patches to allow Ularn to compile and run on
MS-DOS systems, using Turbo C v2.0.]]
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# patch02.1
# This archive created: Sun Jul 16 07:21:26 1989
export PATH; PATH=/bin:$PATH
echo shar: extracting "'patch02.1'" '(50636 characters)'
if test -f 'patch02.1'
then
echo shar: will not over-write existing file "'patch02.1'"
else
sed 's/^X//' << \SHAR_EOF > 'patch02.1'
Xdiff -c orig/README.dos new/README.dos
X*** orig/README.dos Sun Jul 16 05:19:15 1989
X--- new/README.dos Sun Jul 16 04:59:16 1989
X***************
X*** 0 ****
X--- 1,84 ----
X+
X+ This set of patches will allow Ularn to compile and run under Mess-Dos
X+ using Turbo C v2.0. Installation instructions, in brief:
X+
X+ 1. Apply the patches.
X+ 2. Edit ularn.lnk, and change the directory names to wherever you keep the
X+ Turbo C libraries.
X+ 3. Rename 'makefile.tcc' to 'makefile'.
X+ 4. Run make.
X+ 5. Copy ularn.exe and the data files ufortune, uhelp, and umaps to wherever
X+ you want to keep them.
X+ 6. You must have ANSI.SYS (or NANSI.SYS) installed in order to use Ularn.
X+ 7. When running the program, you can specify your character name on the
X+ command line by using 'ularn character-name'. If you don't specify a
X+ name on the command line or in an options file, you will be asked to
X+ enter a name when the game starts.
X+
X+
X+ The changes that I made fall into several classes:
X+
X+ New features:
X+
X+ 1. Graphics characters. You can specify arbitrary character codes to be
X+ used for drawing the floor and walls of the dungeon. This is done by a
X+ line in the options file of the form 'graphics: floor-code wall-code'.
X+ For example, I use 'graphics: 176 178'.
X+
X+ 2. Swapping. If memory is limited, levels that are not currently in use
X+ will be swapped out to disk. This feature is enabled by defining the
X+ symbol SWAPPING when compiling savelev.c.
X+
X+ Warning: the savefile format has been changed. Finish any old games before
X+ installing this version!
X+
X+
X+ Modifications for MS-DOS:
X+
X+ 1. Location of options file. If an options file is specified on the command
X+ line, Ularn will look for it there and abort if it isn't found. Otherwise,
X+ Ularn will try to open the file 'ularnopt', first in the current directory,
X+ and then in the directory in which ularn.exe is located.
X+
X+ 2. Location of data files. Ularn expects its data files to be in the
X+ directory that ularn.exe is located in. This can be overridden by using
X+ the 'larn-path:' keyword in the options file.
X+
X+ 3. Character name and save files. The character name can be specified on
X+ the command line ('ularn character-name') or in the options file. If it
X+ is given by both methods, the name specified on the command line takes
X+ precedence. If it is given by neither, you will be asked to enter a name
X+ when the game starts. The name used for the save file will be the first
X+ eight characters of your character's name, followed by '.sav'. This can
X+ be overridden, however, by using the 'savefile:' keyword in the options
X+ file.
X+
X+ 4. Keypad support. If you have an IBM compatible and want to use the
X+ keypad for movement, include the 'keypad' keyword in the options file.
X+ You can then move around using the eight directional keys (Num Lock
X+ should be _off_). You can run in a given direction by shifting a directional
X+ key. Ins is equivalent to 'i' and Del is equivalent to '.'.
X+
X+ 5. NANSI support. If you are using NANSI.SYS instead of ANSI.SYS, you
X+ should include the 'nansi' keyword in the options file. Ularn will then
X+ use the insert-line and delete-line control sequences. If you have an IBM
X+ compatible, you can also set the 'rawio' option, which results in faster
X+ output.
X+
X+ 6. Screen color. You can specify the foreground and background colors
X+ of the screen by using the options 'foreground:' and 'background:', e.g.,
X+ 'foreground: magenta' or 'background: blue'. Most combinations look pretty
X+ ghastly, though.
X+
X+
X+ Bug fixes:
X+
X+ Mostly int/long mismatches. I also ran across a TC code generation bug
X+ and had to rearrange several lines to avoid it. I'm sure there are still
X+ some left, but I've already spent too much time ... um ... _testing_ this
X+ program... :-)
X+
X+ Enjoy,
X+
X+ Scott Snyder
X+ ssnyder@tybalt.caltech.edu
Xdiff -c orig/Makefile.tcc new/Makefile.tcc
X*** orig/Makefile.tcc Sun Jul 16 05:19:07 1989
X--- new/Makefile.tcc Sun Jul 16 04:59:02 1989
X***************
X*** 0 ****
X--- 1,57 ----
X+ # your favorite compiler
X+ CC = tcc
X+
X+ # user id of wizard (wizard password is defined in config.c)
X+ WIZID = 0
X+
X+ # name of program
X+ GAME = Ularn.exe
X+
X+ # program options
X+ OPTIONS = -DWIZID=$(WIZID)
X+
X+ # compile flags
X+ CFLAGS = -v -mh $(OPTIONS)
X+
X+ # link flags
X+ LDFLAGS = /v
X+
X+ # the object files
X+ OBJ = bill.obj config.obj create.obj data.obj diag.obj display.obj \
X+ fortune.obj global.obj help.obj io.obj main.obj monster.obj \
X+ moreobj.obj movem.obj object.obj regen.obj savelev.obj scores.obj \
X+ signal.obj store.obj tok.obj nap.obj
X+
X+ # the source files
X+ SRC = bill.c config.c create.c data.c diag.c display.c fortune.c\
X+ global.c help.c io.c main.c monster.c moreobj.c movem.c object.c\
X+ regen.c savelev.c scores.c signal.c store.c tok.c nap.c
X+
X+ # the header file
X+ HDR = header.h
X+
X+ UTIL = to_ansi.exe
X+ UTIL_OBJ = to_ansi.obj
X+ UTIL_SRC = to_ansi.c
X+
X+ ##########################################################################
X+
X+ love: $(GAME) Uhelp
X+
X+ $(GAME): $(OBJ)
X+ tlink $(LDFLAGS) @ularn.lnk
X+
X+ .c.obj:
X+ $(CC) -c $(CFLAGS) $.
X+
X+ $(OBJ): header.h
X+
X+ $(UTIL): $(UTIL_SRC)
X+ tcc $(UTIL_SRC)
X+
X+ #$(UTIL): $(UTIL_OBJ)
X+ # $(CC) $(UTIL_OBJ)
X+
X+ Uhelp: $(UTIL) Uhelp.no_control
X+ makehelp
X+
Xdiff -c orig/Uhelp.no_control new/Uhelp.no_control
X*** orig/Uhelp.no_control Sun Jul 16 01:06:32 1989
X--- new/Uhelp.no_control Sun Jul 16 05:03:58 1989
X***************
X*** 1,4 ****
X! 5 Welcome to the game of Ularn. At this moment, you face a great problem.
X Your daughter has contracted a strange disease, and none of your home remedies
X seem to have any effect. You sense that she is in mortal danger, and you must
X try to save her. Time ago you heard of a land of great danger and opportunity.
X--- 1,4 ----
X! 6 Welcome to the game of Ularn. At this moment, you face a great problem.
X Your daughter has contracted a strange disease, and none of your home remedies
X seem to have any effect. You sense that she is in mortal danger, and you must
X try to save her. Time ago you heard of a land of great danger and opportunity.
X***************
X*** 107,118 ****
X letter of name is monster's character.
X savefile: save-file-name full pathname of savefile
X character: character choose your character
X
X Your name and monster names must be enclosed in double quotation marks and may
X be up to 34 characters long. Longer names are truncated. Anything enclosed in
X quotation marks is considered one word, and must be separated from other words
X by whitespace.
X-
X ^[[7mExplanation of the Ularn scoreboard facility^[[m
X
X Ularn supports TWO scoreboards, one for winners, and one for deceased
X--- 107,118 ----
X letter of name is monster's character.
X savefile: save-file-name full pathname of savefile
X character: character choose your character
X+ graphics: floor-chr wall-chr char codes to use to draw floor and walls
X
X Your name and monster names must be enclosed in double quotation marks and may
X be up to 34 characters long. Longer names are truncated. Anything enclosed in
X quotation marks is considered one word, and must be separated from other words
X by whitespace.
X ^[[7mExplanation of the Ularn scoreboard facility^[[m
X
X Ularn supports TWO scoreboards, one for winners, and one for deceased
X***************
X*** 129,134 ****
X--- 129,155 ----
X at the time of his death.
X
X
X+
X+
X+
X+
X+
X+
X+
X+ ^[[7mAdditional options for MS-DOS^[[m
X+
X+ If you are running Ularn under MSDOS, there are several other options
X+ which can be in your 'ularnopt' file:
X+
X+ Word Meaning
X+ larn-path: directory the directory where the data files are kept
X+ background: color the background screen color
X+ foreground: color the foreground screel color
X+ nansi you have NANSI.SYS installed instead of
X+ ANSI.SYS.
X+ rawio faster screen output (requires NANSI.SYS and
X+ an IBM compatible)
X+ keypad use the numeric keypad for movement
X
X
X
Xdiff -c orig/bill.c new/bill.c
X*** orig/bill.c Sun Jul 16 00:59:47 1989
X--- new/bill.c Sun Jul 16 04:38:37 1989
X***************
X*** 3,8 ****
X--- 3,9 ----
X #include "header.h"
X
X static char mail600[32];
X+
X /*
X * function to create the tax bill for the user
X */
X***************
X*** 9,20 ****
X static int pid;
X letter1()
X {
X sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600) < 0) {
X write(1,"can't write 600 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X lprcat("From:");
X lprcat(" the URS (Ularn Revenue Service)\n");
X lprcat("\nSubject:");
X--- 10,25 ----
X static int pid;
X letter1()
X {
X+ #ifdef __MSDOS__
X+ clear();
X+ #else
X sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600,0) < 0) {
X write(1,"can't write 600 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X+ #endif
X lprcat("From:");
X lprcat(" the URS (Ularn Revenue Service)\n");
X lprcat("\nSubject:");
X***************
X*** 31,48 ****
X lprcat("\nof this notice, and is due within 5 days. Failure to pay will");
X lprcat("\nmean penalties. Once again, congratulations, We look forward");
X lprcat("\nto your future successful expeditions.\n");
X lwclose();
X return(1);
X }
X
X letter2()
X {
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600) < 0) {
X write(1,"can't write 601 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X lprcat("From:");
X lprcat(" His Majesty King Wilfred of Ularndom\n");
X lprcat("\nSubject:");
X--- 36,62 ----
X lprcat("\nof this notice, and is due within 5 days. Failure to pay will");
X lprcat("\nmean penalties. Once again, congratulations, We look forward");
X lprcat("\nto your future successful expeditions.\n");
X+
X+ #ifdef __MSDOS__
X+ retcont();
X+ #else
X lwclose();
X+ #endif
X return(1);
X }
X
X letter2()
X {
X+ #ifdef __MSDOS__
X+ clear();
X+ #else
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600,0) < 0) {
X write(1,"can't write 601 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X+ #endif
X lprcat("From:");
X lprcat(" His Majesty King Wilfred of Ularndom\n");
X lprcat("\nSubject:");
X***************
X*** 56,73 ****
X lprcat("\nhonour of Knightess of the realm. Upon thy name shall it be written. . .");
X lprcat("\nBravery and courage be yours.");
X lprcat("\nMay you live in happiness forevermore . . .\n");
X lwclose();
X return(1);
X }
X
X letter3()
X {
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600) < 0) {
X write(1,"can't write 602 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X lprcat("From:");
X lprcat(" Count Endelford\n");
X lprcat("\nSubject:");
X--- 70,95 ----
X lprcat("\nhonour of Knightess of the realm. Upon thy name shall it be written. . .");
X lprcat("\nBravery and courage be yours.");
X lprcat("\nMay you live in happiness forevermore . . .\n");
X+ #ifdef __MSDOS__
X+ retcont();
X+ #else
X lwclose();
X+ #endif
X return(1);
X }
X
X letter3()
X {
X+ #ifdef __MSDOS__
X+ clear();
X+ #else
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600,0) < 0) {
X write(1,"can't write 602 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X+ #endif
X lprcat("From:");
X lprcat(" Count Endelford\n");
X lprcat("\nSubject:");
X***************
X*** 83,100 ****
X lprcat("With several attempts I have yet to endure the");
X lprcat(" caves,\nand you, a nobody, makes the journey! From this time");
X lprcat(" onward, bewarned\nupon our meeting you shall pay the price!\n");
X lwclose();
X return(1);
X }
X
X letter4()
X {
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600) < 0) {
X write(1,"can't write 603 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X lprcat("From:");
X lprcat(" Mainair, Duke of Ularnty\n");
X lprcat("\nSubject:");
X--- 105,130 ----
X lprcat("With several attempts I have yet to endure the");
X lprcat(" caves,\nand you, a nobody, makes the journey! From this time");
X lprcat(" onward, bewarned\nupon our meeting you shall pay the price!\n");
X+ #ifdef __MSDOS__
X+ retcont();
X+ #else
X lwclose();
X+ #endif
X return(1);
X }
X
X letter4()
X {
X+ #ifdef __MSDOS__
X+ clear();
X+ #else
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600,0) < 0) {
X write(1,"can't write 603 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X+ #endif
X lprcat("From:");
X lprcat(" Mainair, Duke of Ularnty\n");
X lprcat("\nSubject:");
X***************
X*** 105,122 ****
X lprcat("\nyearn to behold his anger and jealously. Should ye choose to");
X lprcat("\nunleash some of thy wealth upon those who be unfortunate, I,");
X lprcat("\nDuke Mainair, Shall equal thy gift also.\n");
X lwclose();
X return(1);
X }
X
X letter5()
X {
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600) < 0) {
X write(1,"can't write 604 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X lprcat("From:");
X lprcat(" St. Mary's Children's Home\n");
X lprcat("\nSubject:");
X--- 135,160 ----
X lprcat("\nyearn to behold his anger and jealously. Should ye choose to");
X lprcat("\nunleash some of thy wealth upon those who be unfortunate, I,");
X lprcat("\nDuke Mainair, Shall equal thy gift also.\n");
X+ #ifdef __MSDOS__
X+ retcont();
X+ #else
X lwclose();
X return(1);
X+ #endif
X }
X
X letter5()
X {
X+ #ifdef __MSDOS__
X+ clear();
X+ #else
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600,0) < 0) {
X write(1,"can't write 604 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X+ #endif
X lprcat("From:");
X lprcat(" St. Mary's Children's Home\n");
X lprcat("\nSubject:");
X***************
X*** 133,150 ****
X lprcat("\ngood food. Could you possibly find it in your heart to help us");
X lprcat("\nin our plight? Whatever you could give will help much.");
X lprcat("\n(your gift is tax deductible)\n");
X lwclose();
X return(1);
X }
X
X letter6()
X {
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600) < 0) {
X write(1,"can't write 605 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X lprcat("From:");
X lprcat(" The National Dianthroritis Society of Ularn\n");
X lprcat("\nSubject:");
X--- 171,196 ----
X lprcat("\ngood food. Could you possibly find it in your heart to help us");
X lprcat("\nin our plight? Whatever you could give will help much.");
X lprcat("\n(your gift is tax deductible)\n");
X+ #ifdef __MSDOS__
X+ retcont();
X+ #else
X lwclose();
X+ #endif
X return(1);
X }
X
X letter6()
X {
X+ #ifdef __MSDOS__
X+ clear();
X+ #else
X sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
X! if (lcreat(mail600,0) < 0) {
X write(1,"can't write 605 letter\n",23);
X return(0);
X }
X lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
X+ #endif
X lprcat("From:");
X lprcat(" The National Dianthroritis Society of Ularn\n");
X lprcat("\nSubject:");
X***************
X*** 159,165 ****
X--- 205,215 ----
X lprcat("\ndreaded disease, and you can help today. Could you please see it");
X lprcat("\nin your heart to give generously? Your continued good health");
X lprcat("\ncan be your everlasting reward.\n");
X+ #ifdef __MSDOS__
X+ retcont();
X+ #else
X lwclose();
X+ #endif
X return(1);
X }
X
X***************
X*** 175,191 ****
X--- 225,247 ----
X register int i;
X char buf[128];
X
X+ #ifndef __MSDOS__
X wait(0);
X pid=getpid();
X if (fork() == 0) {
X+ #endif
X resetscroll();
X for (i=0; i<sizeof(pfn)/sizeof(int (*)()); i++)
X if ((*pfn[i])()) {
X+ #ifndef __MSDOS__
X sleep(20);
X sprintf(buf,"mail %s < %s",loginname,mail600);
X system(buf);
X unlink(mail600);
X+ #endif
X }
X+ #ifndef __MSDOS__
X exit(0);
X }
X+ #endif
X }
Xdiff -c orig/config.c new/config.c
X*** orig/config.c Sun Jul 16 01:06:34 1989
X--- new/config.c Sun Jul 16 04:49:20 1989
X***************
X*** 7,32 ****
X */
X #include "header.h"
X
X /* the game save filename */
X char savefilename[SAVEFILENAMESIZE] = HOME;
X
X /* the score file */
X! char scorefile[sizeof(HOME)+sizeof(SCORENAME)] = HOME;
X
X /* the logging file */
X! char logfile[sizeof(HOME)+sizeof(LOGFNAME)] = HOME;
X
X /* the help text file */
X! char helpfile[sizeof(HOME)+sizeof(HELPNAME)] = HOME;
X
X /* the maze data file */
X! char larnlevels[sizeof(HOME)+sizeof(LEVELSNAME)] = HOME;
X
X /* the fortune data file */
X! char fortfile[sizeof(HOME)+sizeof(FORTSNAME)] = HOME;
X
X /* the .Ularnopts filename */
X! char optsfile[128] ="/.Ularnopts"; /* the option file */
X
X char diagfile[] ="Diagfile"; /* the diagnostic filename */
X char ckpfile[] ="Ularn.ckp"; /* the checkpoint filename */
X--- 7,43 ----
X */
X #include "header.h"
X
X+ #ifdef __MSDOS__
X+
X+ # define HOMESIZE SAVEFILENAMESIZE
X+ # define HOME ""
X+
X+ #else
X+
X+ # define HOMESIZE sizeof(HOME)
X+
X+ #endif
X+
X /* the game save filename */
X char savefilename[SAVEFILENAMESIZE] = HOME;
X
X /* the score file */
X! char scorefile[HOMESIZE+sizeof(SCORENAME)] = HOME;
X
X /* the logging file */
X! char logfile[HOMESIZE+sizeof(LOGFNAME)] = HOME;
X
X /* the help text file */
X! char helpfile[HOMESIZE+sizeof(HELPNAME)] = HOME;
X
X /* the maze data file */
X! char larnlevels[HOMESIZE+sizeof(LEVELSNAME)] = HOME;
X
X /* the fortune data file */
X! char fortfile[HOMESIZE+sizeof(FORTSNAME)] = HOME;
X
X /* the .Ularnopts filename */
X! char optsfile[SAVEFILENAMESIZE] ="/.Ularnopts"; /* the option file */
X
X char diagfile[] ="Diagfile"; /* the diagnostic filename */
X char ckpfile[] ="Ularn.ckp"; /* the checkpoint filename */
Xdiff -c orig/create.c new/create.c
X*** orig/create.c Sun Jul 16 01:02:19 1989
X--- new/create.c Sun Jul 16 04:44:41 1989
X***************
X*** 136,142 ****
X for (i=mxl; i<mxh; i++)
X for (j=myl; j<myh; j++) {
X item[i][j]=0;
X! if ((mitem[i][j]=z))
X hitp[i][j]=monster[z].hitpoints;
X }
X }
X--- 136,142 ----
X for (i=mxl; i<mxh; i++)
X for (j=myl; j<myh; j++) {
X item[i][j]=0;
X! if ((mitem[i][j]=z)!=0)
X hitp[i][j]=monster[z].hitpoints;
X }
X }
X***************
X*** 219,225 ****
X register int i,j;
X int it,arg,mit,marg;
X
X! if (lopen(larnlevels)<0) {
X write(1,"Can't open the maze data file\n",30);
X died(-282);
X return(0);
X--- 219,225 ----
X register int i,j;
X int it,arg,mit,marg;
X
X! if (lopen(larnlevels, 0)<0) {
X write(1,"Can't open the maze data file\n",30);
X died(-282);
X return(0);
X***************
X*** 630,636 ****
X if ((item[x][y]==0) && (mitem[x][y]==0) &&
X ((playerx!=x) || (playery!=y))) {
X mitem[x][y] = what;
X! know[x][y]=0;
X hitp[x][y] = monster[what].hitpoints;
X return(0);
X }
X--- 630,636 ----
X if ((item[x][y]==0) && (mitem[x][y]==0) &&
X ((playerx!=x) || (playery!=y))) {
X mitem[x][y] = what;
X! if (know[x][y]) know[x][y] = 2;
X hitp[x][y] = monster[what].hitpoints;
X return(0);
X }
Xdiff -c orig/data.c new/data.c
X*** orig/data.c Sun Jul 16 01:00:56 1989
X--- new/data.c Sun Jul 16 04:40:23 1989
X***************
X*** 74,87 ****
X
X char *lpbuf,*lpnt,
X *inbuffer,*lpend; /* input/output pointers to the buffers */
X- struct cel *cell; /* pointer to the dungeon storage */
X short hitp[MAXX][MAXY]; /* monster hp on level */
X short iarg[MAXX][MAXY]; /* arg for the item array */
X char item[MAXX][MAXY]; /* objects in maze if any */
X! char know[MAXX][MAXY]; /* 1 or 0 if here before */
X char mitem[MAXX][MAXY]; /* monster item array */
X char moved[MAXX][MAXY]; /* monster movement flags */
X! char stealth[MAXX][MAXY];/* 0=sleeping 1=awake monst */
X char iven[26]; /* inventory for player */
X short ivenarg[26]; /* inventory args for player */
X char lastmonst[40]; /*this has the name of the current monster*/
X--- 74,87 ----
X
X char *lpbuf,*lpnt,
X *inbuffer,*lpend; /* input/output pointers to the buffers */
X short hitp[MAXX][MAXY]; /* monster hp on level */
X short iarg[MAXX][MAXY]; /* arg for the item array */
X char item[MAXX][MAXY]; /* objects in maze if any */
X! char know[MAXX][MAXY]; /* 1 or 0 if here before; 2 if we know there's */
X! /* floor here, but not what's on top */
X char mitem[MAXX][MAXY]; /* monster item array */
X char moved[MAXX][MAXY]; /* monster movement flags */
X! char stealth[MAXX][MAXY]; /* 0=sleeping 1=awake monst */
X char iven[26]; /* inventory for player */
X short ivenarg[26]; /* inventory args for player */
X char lastmonst[40]; /*this has the name of the current monster*/
X***************
X*** 796,798 ****
X--- 796,799 ----
X char nplt[] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 4 };
X char ndgg[] = { 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 5 };
X char nsw[] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 3 };
X+
Xdiff -c orig/diag.c new/diag.c
X*** orig/diag.c Sun Jul 16 01:02:52 1989
X--- new/diag.c Sun Jul 16 04:54:19 1989
X***************
X*** 2,8 ****
X #include "header.h"
X
X extern long int initialtime;
X! extern int rmst,maxitm,lasttime;
X extern char nosignal;
X
X char *cdef[] = {
X--- 2,8 ----
X #include "header.h"
X
X extern long int initialtime;
X! extern int maxitm;
X extern char nosignal;
X
X char *cdef[] = {
X***************
X*** 75,81 ****
X
X fprintf(dfile, "Hit points: %2ld(%2ld)\n", c[HP], c[HPMAX]);
X
X! fprintf(dfile, "gold: %ld Experience: %ld Character level: %d Level in caverns: %ld\n",
X (long) c[GOLD],
X (long) c[EXPERIENCE],
X (long) c[LEVEL],
X--- 75,81 ----
X
X fprintf(dfile, "Hit points: %2ld(%2ld)\n", c[HP], c[HPMAX]);
X
X! fprintf(dfile, "gold: %ld Experience: %ld Character level: %ld Level in caverns: %d\n",
X (long) c[GOLD],
X (long) c[EXPERIENCE],
X (long) c[LEVEL],
X***************
X*** 193,448 ****
X /* east west walls of this line */
X for (i = 0; i < MAXY; i++) {
X for (j = 0; j < MAXX; j++)
X! if (k = mitem[j][i])
X fprintf(dfile, "%c", monstnamelist[k]);
X else
X fprintf(dfile, "%c", objnamelist[item[j][i]]);
X fprintf(dfile, "\n");
X }
X- }
X- /*
X- to save the game in a file
X- */
X- static long int zzz=0;
X- savegame(fname)
X- char *fname;
X- {
X- register int i,k;
X- register struct sphere *sp;
X- struct stat statbuf;
X-
X- nosignal=1;
X- lflush();
X- savelevel();
X- ointerest();
X- if (lcreat(fname) < 0) {
X- lcreat((char*)0);
X- lprintf("\nCan't open file <%s> to save game\n",fname);
X- nosignal=0;
X- return(-1);
X- }
X-
X- set_score_output();
X- lwrite((char*)beenhere,MAXLEVEL+MAXVLEVEL);
X- for (k=0; k<MAXLEVEL+MAXVLEVEL; k++)
X- if (beenhere[k])
X- lwrite((char*)&cell[k*MAXX*MAXY],sizeof(struct cel)*MAXY*MAXX);
X- lwrite((char*)&c[0],100*sizeof(long));
X- lprint((long)gtime);
X- lprc(level);
X- lprc(playerx);
X- lprc(playery);
X- lwrite((char*)iven,26);
X- lwrite((char*)ivenarg,26*sizeof(short));
X- lwrite((char*)char_class,20);
X- for (k=0; k<MAXSCROLL; k++) lprc(scrollname[k][0]);
X- for (k=0; k<MAXPOTION; k++) lprc(potionname[k][0]);
X- lwrite((char*)spelknow,SPNUM);
X- lprc(wizard);
X- lprc(rmst); /* random monster generation counter */
X- for (i=0; i<90; i++) lprc(itm[i].qty);
X- lwrite((char*)course,25);
X- lprc(cheat);
X-
X- /* genocide info */
X- for (i=0; i<MAXMONST; i++) lprc(monster[i].genocided);
X-
X- /* save spheres of annihilation */
X- for (sp=spheres; sp; sp=sp->p)
X- lwrite((char*)sp,sizeof(struct sphere));
X-
X- time(&zzz);
X- lprint((long)(zzz-initialtime));
X- lwrite((char*)&zzz,sizeof(long));
X-
X- if (fstat(lfd,&statbuf)< 0) lprint(0L);
X- else
X- lprint((long)statbuf.st_ino); /* inode # */
X-
X- lwclose();
X- lastmonst[0] = 0;
X- lcreat((char*)0);
X- nosignal=0;
X- return(0);
X- }
X-
X- restoregame(fname)
X- char *fname;
X- {
X- register int i,k;
X- register struct sphere *sp,*sp2;
X- struct stat filetimes;
X-
X- cursors();
X- lprcat("\nRestoring . . .");
X- lflush();
X- if (lopen(fname) <= 0) {
X- lcreat((char*)0);
X- lprintf("\nCan't open file <%s> to restore game\n",fname);
X- nap(2000);
X- c[GOLD]=c[BANKACCOUNT]=0;
X- died(-265);
X- return;
X- }
X-
X- lrfill((char*)beenhere,MAXLEVEL+MAXVLEVEL);
X- for (k=0; k<MAXLEVEL+MAXVLEVEL; k++)
X- if (beenhere[k])
X- lrfill((char*)&cell[k*MAXX*MAXY],sizeof(struct cel)*MAXY*MAXX);
X-
X- lrfill((char*)&c[0],100*sizeof(long));
X- gtime = lrint();
X- level = c[CAVELEVEL] = lgetc();
X-
X- playerx = lgetc();
X- playery = lgetc();
X-
X- lrfill((char*)iven,26);
X- lrfill((char*)ivenarg,26*sizeof(short));
X- lrfill((char*)char_class,20);
X-
X- for (k=0; k<MAXSCROLL; k++) scrollname[k][0] = lgetc();
X- for (k=0; k<MAXPOTION; k++) potionname[k][0] = lgetc();
X-
X- lrfill((char*)spelknow,SPNUM);
X-
X- wizard = lgetc();
X- rmst = lgetc(); /* random monster creation flag */
X-
X- for (i=0; i<90; i++)
X- itm[i].qty = lgetc();
X-
X- lrfill((char*)course,25);
X- cheat = lgetc();
X-
X- /* genocide info */
X- for (i=0; i<MAXMONST; i++) monster[i].genocided=lgetc();
X-
X- for (sp=0,i=0; i<c[SPHCAST]; i++) {
X- sp2 = sp;
X- sp = (struct sphere *)malloc(sizeof(struct sphere));
X- if (sp==0) {
X- fprintf(stderr, "Can't malloc() for sphere space\n");
X- break;
X- }
X- /* get spheres of annihilation */
X- lrfill((char*)sp,sizeof(struct sphere));
X- sp->p=0; /* null out pointer */
X- if (i==0) spheres=sp; /* beginning of list */
X- else sp2->p = sp;
X- }
X-
X-
X- time(&zzz);
X- initialtime = zzz-lrint();
X-
X- fstat(fd,&filetimes);/*get the creation and modification time of file*/
X-
X- lrfill((char*)&zzz,sizeof(long));
X-
X- zzz += 6;
X- if (filetimes.st_ctime > zzz)
X- fsorry(); /*file create time */
X- else if (filetimes.st_mtime > zzz)
X- fsorry(); /* file modify time*/
X-
X-
X- if (c[HP]<0) {
X- died(284);
X- return;
X- } /* died a post mortem death */
X-
X- oldx = oldy = 0;
X-
X- i = lrint(); /* inode # */
X- if (i && (filetimes.st_ino!=i))
X- fsorry(); /* different inode number, file was copied */
X-
X- lrclose();
X-
X- if (strcmp(fname,ckpfile) == 0) {
X- if (lappend(fname) < 0)
X- fcheat();
X- else {
X- lprc(' ');
X- lwclose();
X- }
X- lcreat((char*)0);
X- }
X- else if (unlink(fname) < 0)
X- fcheat(); /* can't unlink save file */
X-
X- /* for the greedy cheater checker */
X- /* for (k=0; k<6; k++) if (c[k]>99) greedy();
X- if (c[HPMAX]>999 || c[SPELLMAX]>125) greedy(); */
X- if (c[LEVEL]==25 && c[EXPERIENCE]>skill[24]) {
X- long tmp = c[EXPERIENCE]-skill[24]; /* amount to go up */
X- c[EXPERIENCE] = skill[24];
X- raiseexperience((long)tmp);
X- }
X- getlevel();
X- lasttime=gtime;
X-
X- for (k=0; k<26; k++)
X- if (iven[k] == OLARNEYE) {
X- monstnamelist[DEMONLORD] = '1';
X- monstnamelist[DEMONLORD+1] = '2';
X- monstnamelist[DEMONLORD+2] = '3';
X- monstnamelist[DEMONLORD+3] = '4';
X- monstnamelist[DEMONLORD+4] = '5';
X- monstnamelist[DEMONLORD+5] = '6';
X- monstnamelist[DEMONLORD+6] = '7';
X- monstnamelist[DEMONPRINCE] = '9';
X- monstnamelist[LUCIFER] = '0';
X- break;
X- }
X- }
X-
X- /*
X- subroutine to not allow greedy cheaters
X- */
X- greedy()
X- {
X- if (wizard) return;
X-
X- lprcat("\n\nI am so sorry, but your character is a little TOO good! Since this\n");
X- lprcat("cannot normally happen from an honest game, I must assume that you cheated.\n");
X- lprcat("In that you are GREEDY as well as a CHEATER, I cannot allow this game\n");
X- lprcat("to continue.\n");
X- nap(5000);
X- c[GOLD]=c[BANKACCOUNT]=0;
X- died(-267);
X- return;
X- }
X-
X- /*
X- subroutine to not allow altered save files and terminate the attempted
X- restart
X- */
X- fsorry()
X- {
X- if(cheat) return;
X- lprcat("\nSorry, but your savefile has been altered.\n");
X- lprcat("However, seeing as I am a good sport, I will let you play.\n");
X- lprcat("Be advised though, you won't be placed on the scoreboard.");
X- cheat = 1;
X- nap(4000);
X- }
X-
X- /*
X- subroutine to not allow game if save file can't be deleted
X- */
X- fcheat()
X- {
X- if (wizard) return;
X- if(cheat) return;
X-
X- lprcat("\nSorry, but your savefile can't be deleted. This can only mean\n");
X- lprcat("that you tried to CHEAT by protecting the directory the savefile\n");
X- lprcat("is in. Since this is unfair to the rest of the Ularn community, I\n");
X- lprcat("cannot let you play this game.\n");
X- nap(5000);
X- c[GOLD]=c[BANKACCOUNT]=0;
X- died(-268);
X- return;
X }
X--- 193,202 ----
X /* east west walls of this line */
X for (i = 0; i < MAXY; i++) {
X for (j = 0; j < MAXX; j++)
X! if ((k = mitem[j][i])!=0)
X fprintf(dfile, "%c", monstnamelist[k]);
X else
X fprintf(dfile, "%c", objnamelist[item[j][i]]);
X fprintf(dfile, "\n");
X }
X }
Xdiff -c orig/display.c new/display.c
X*** orig/display.c Sun Jul 16 01:02:58 1989
X--- new/display.c Sun Jul 16 04:46:58 1989
X***************
X*** 1,7 ****
X /* display.c */
X #include "header.h"
X
X! #define makecode(_a,_b,_c) (((_a)<<16) + ((_b)<<8) + (_c))
X
X static int minx,maxx,miny,maxy,k,m;
X static char bot1f=0,bot2f=0,bot3f=0;
X--- 1,7 ----
X /* display.c */
X #include "header.h"
X
X! #define makecode(_a,_b,_c) (((long)(_a)<<16) + ((_b)<<8) + (_c))
X
X static int minx,maxx,miny,maxy,k,m;
X static char bot1f=0,bot2f=0,bot3f=0;
X***************
X*** 200,206 ****
X }
X
X botsub(idx,str)
X! register int idx;
X char *str;
X {
X register int x,y;
X--- 200,206 ----
X }
X
X botsub(idx,str)
X! register long idx;
X char *str;
X {
X register int x,y;
X***************
X*** 274,281 ****
X for (i=d_ymin; i<d_ymax; i++)
X for (j=d_xmin; j<d_xmax; j++)
X if (know[j][i]==0) screen[j][i] = ' ';
X else
X! if (k=mitem[j][i]) {
X if (k==MIMIC)
X screen[j][i] =
X monstnamelist[rund(MAXMONST)];
X--- 274,283 ----
X for (i=d_ymin; i<d_ymax; i++)
X for (j=d_xmin; j<d_xmax; j++)
X if (know[j][i]==0) screen[j][i] = ' ';
X+ else if (know[j][i]==2)
X+ screen[j][i] = objnamelist[0];
X else
X! if ((k=mitem[j][i])!=0) {
X if (k==MIMIC)
X screen[j][i] =
X monstnamelist[rund(MAXMONST)];
X***************
X*** 284,291 ****
X }
X else
X if ((k=item[j][i])==OWALL)
X! screen[j][i] = '#';
X! else screen[j][i] = ' ';
X
X for (i=d_ymin; i<d_ymax; i++) {
X j=d_xmin;
X--- 286,294 ----
X }
X else
X if ((k=item[j][i])==OWALL)
X! screen[j][i] = objnamelist[OWALL];
X! else
X! screen[j][i] = objnamelist[0];
X
X for (i=d_ymin; i<d_ymax; i++) {
X j=d_xmin;
X***************
X*** 316,325 ****
X
X for (lastx=lasty=127, i=d_ymin; i<d_ymax; i++)
X for (j=d_xmin; j<d_xmax; j++) {
X! if (k=item[j][i])
X if (k != OWALL)
X if ((know[j][i]) && (mitem[j][i]==0))
X! if (objnamelist[k]!=' ') {
X if (lasty!=i+1 || lastx!=j)
X cursor(lastx=j+1,lasty=i+1);
X else lastx++;
X--- 319,328 ----
X
X for (lastx=lasty=127, i=d_ymin; i<d_ymax; i++)
X for (j=d_xmin; j<d_xmax; j++) {
X! if ((k=item[j][i])!=0)
X if (k != OWALL)
X if ((know[j][i]) && (mitem[j][i]==0))
X! if (objnamelist[k]!=objnamelist[0]) {
X if (lasty!=i+1 || lastx!=j)
X cursor(lastx=j+1,lasty=i+1);
X else lastx++;
X***************
X*** 370,379 ****
X
X for (j=miny; j<=maxy; j++)
X for (m=minx; m<=maxx; m++)
X! if (know[m][j]==0) {
X cursor(m+1,j+1);
X x=maxx;
X! while (know[x][j]) --x;
X for (i=m; i<=x; i++) {
X if ((k=mitem[i][j]) != 0) {
X if (k==MIMIC)
X--- 373,382 ----
X
X for (j=miny; j<=maxy; j++)
X for (m=minx; m<=maxx; m++)
X! if ((know[m][j] & 1)==0) {
X cursor(m+1,j+1);
X x=maxx;
X! while (know[x][j] & 1) --x;
X for (i=m; i<=x; i++) {
X if ((k=mitem[i][j]) != 0) {
X if (k==MIMIC)
Xdiff -c orig/fortune.c new/fortune.c
X*** orig/fortune.c Sun Jul 16 01:03:01 1989
X--- new/fortune.c Sun Jul 16 04:58:04 1989
X***************
X*** 31,37 ****
X }
X
X /* read in the entire fortune file */
X! if (read(fd,base,stat.st_size) != stat.st_size) {
X close(fd);
X fd= -1;
X free((char*)base);
X--- 31,37 ----
X }
X
X /* read in the entire fortune file */
X! if ((stat.st_size = read(fd,base,stat.st_size)) == -1) {
X close(fd);
X fd= -1;
X free((char*)base);
Xdiff -c orig/global.c new/global.c
X*** orig/global.c Sun Jul 16 01:02:28 1989
X--- new/global.c Sun Jul 16 04:46:04 1989
X***************
X*** 300,309 ****
X
X if (lev < 5)
X while (tmp==WATERLORD)
X! tmp=rnd((x=monstlevel[lev-1])?x:1);
X
X else while (tmp==WATERLORD)
X! tmp=rnd((x=monstlevel[lev-1]-monstlevel[lev-4])?x:1)+monstlevel[lev-4];
X
X while (monster[tmp].genocided && tmp<MAXMONST) tmp++; /* genocided? */
X
X--- 300,310 ----
X
X if (lev < 5)
X while (tmp==WATERLORD)
X! tmp=rnd(((x=monstlevel[lev-1])!=0)?x:1);
X
X else while (tmp==WATERLORD)
X! tmp=rnd(((x=monstlevel[lev-1]-monstlevel[lev-4])!=0)?x:1)
X! +monstlevel[lev-4];
X
X while (monster[tmp].genocided && tmp<MAXMONST) tmp++; /* genocided? */
X
X***************
X*** 858,875 ****
X case OLANCE:
X c[LANCEDEATH]=0;
X return;
X! case OLARNEYE:
X! monstnamelist[DEMONLORD] = ' ';
X! monstnamelist[DEMONLORD+1] = ' ';
X! monstnamelist[DEMONLORD+2] = ' ';
X! monstnamelist[DEMONLORD+3] = ' ';
X! monstnamelist[DEMONLORD+4] = ' ';
X! monstnamelist[DEMONLORD+5] = ' ';
X! monstnamelist[DEMONLORD+6] = ' ';
X! monstnamelist[DEMONPRINCE] = ' ';
X! monstnamelist[LUCIFER] = ' ';
X cursors();
X return;
X case OPOTION:
X case OSCROLL:
X return;
X--- 859,878 ----
X case OLANCE:
X c[LANCEDEATH]=0;
X return;
X! case OLARNEYE: {
X! char c = objnamelist[0];
X! monstnamelist[DEMONLORD ] = c;
X! monstnamelist[DEMONLORD+1] = c;
X! monstnamelist[DEMONLORD+2] = c;
X! monstnamelist[DEMONLORD+3] = c;
X! monstnamelist[DEMONLORD+4] = c;
X! monstnamelist[DEMONLORD+5] = c;
X! monstnamelist[DEMONLORD+6] = c;
X! monstnamelist[DEMONPRINCE] = c;
X! monstnamelist[LUCIFER] = c;
X cursors();
X return;
X+ }
X case OPOTION:
X case OSCROLL:
X return;
Xdiff -c orig/header.h new/header.h
X*** orig/header.h Sun Jul 16 01:06:56 1989
X--- new/header.h Sun Jul 16 06:14:28 1989
X***************
X*** 2,20 ****
X #include <sys/types.h>
X #include <sys/stat.h>
X
X! #ifdef BSD
X # include <sys/timeb.h>
X # include <sys/time.h>
X # include <sgtty.h>
X! #else
X # include <sys/times.h>
X # include <termio.h>
X! #endif
X
X #include <fcntl.h>
X #include <ctype.h>
X! #include <varargs.h>
X! #include <pwd.h>
X #include <signal.h>
X #include <stdio.h>
X
X--- 2,26 ----
X #include <sys/types.h>
X #include <sys/stat.h>
X
X! #ifndef __MSDOS__
X! # include <pwd.h>
X! # ifdef BSD
X # include <sys/timeb.h>
X # include <sys/time.h>
X # include <sgtty.h>
X! # else
X # include <sys/times.h>
X # include <termio.h>
X! # endif
X! #endif /* __MSDOS__ */
X
X #include <fcntl.h>
X #include <ctype.h>
X! #ifdef __TURBOC__
X! # include <stdarg.h>
X! #else
X! # include <varargs.h>
X! #endif
X #include <signal.h>
X #include <stdio.h>
X
X***************
X*** 69,84 ****
X char qty;
X };
X
X- /* this is the structure that holds the entire dungeon specifications */
X- struct cel
X- {
X- short hitp; /* monster's hit points */
X- char mitem; /* the monster ID */
X- char item; /* the object's ID */
X- short iarg; /* the object's argument */
X- char know; /* have we been here before*/
X- };
X-
X /* this is the structure for maintaining & moving the spheres of annihilation */
X struct sphere
X {
X--- 75,80 ----
X***************
X*** 397,403 ****
X extern int dayplay,enable_scroll,srcount,stayflag,yrepcount,userid,lfd,fd;
X extern long initialtime,outstanding_taxes,skill[],gtime,c[],cbak[];
X extern unsigned long randx;
X- extern struct cel *cell;
X extern struct monst monster[];
X extern struct sphere *spheres;
X extern struct _itm itm[];
X--- 393,398 ----
X***************
X*** 454,461 ****
X /* macro to seed the random number generator */
X #define srand(x) (randx=x)
X /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
X! #define rnd(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1)
X! #define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x)))
X /* macros for miscellaneous data conversion */
X #define min(x,y) (((x)>(y))?(y):(x))
X #define max(x,y) (((x)>(y))?(x):(y))
X--- 449,458 ----
X /* macro to seed the random number generator */
X #define srand(x) (randx=x)
X /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
X! #define rnd(x) ((int)((((randx=randx*1103515245+12345)>>7)%(x))+1))
X! #define rund(x) ((int)((((randx=randx*1103515245+12345)>>7)%(x))))
X! #define rndl(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1)
X! #define rundl(x) ((((randx=randx*1103515245+12345)>>7)%(x)))
X /* macros for miscellaneous data conversion */
X #define min(x,y) (((x)>(y))?(y):(x))
X #define max(x,y) (((x)>(y))?(x):(y))
Xdiff -c orig/help.c new/help.c
X*** orig/help.c Sun Jul 16 01:01:55 1989
X--- new/help.c Sun Jul 16 04:54:28 1989
X***************
X*** 86,92 ****
X */
X openhelp()
X {
X! if (lopen(helpfile)<0) {
X lprintf("Can't open help file \"%s\" ",helpfile);
X lflush();
X sleep(4);
X--- 86,92 ----
X */
X openhelp()
X {
X! if (lopen(helpfile, 0)<0) {
X lprintf("Can't open help file \"%s\" ",helpfile);
X lflush();
X sleep(4);
Xdiff -c orig/io.c new/io.c
X*** orig/io.c Sun Jul 16 01:01:07 1989
X--- new/io.c Sun Jul 16 04:37:38 1989
X***************
X*** 30,38 ****
X *
X * FILE OPEN / CLOSE ROUTINES
X *
X! * lcreat(filename) create a new file for write
X! * lopen(filename) open a file for read
X! * lappend(filename) open for append to an existing file
X * lrclose() close the input file
X * lwclose() close output file
X * lflush() flush the output buffer
X--- 30,38 ----
X *
X * FILE OPEN / CLOSE ROUTINES
X *
X! * lcreat(filename, mode) create a new file for write
X! * lopen(filename, mode) open a file for read
X! * lappend(filename, mode) open for append to an existing file
X * lrclose() close the input file
X * lwclose() close output file
X * lflush() flush the output buffer
X***************
X*** 55,71 ****
X * Note: ** entries are available only in termcap mode.
X */
X #include "header.h"
X
X! #ifdef BSD
X # define GTTY(arg) (ioctl(0, TIOCGETP, arg))
X # define STTY(arg) (ioctl(0, TIOCSETP, arg))
X static struct sgttyb inittyb, curttyb;
X! #else /* SYSV */
X # define GTTY(arg) (ioctl(0, TCGETA, arg))
X # define STTY(arg) (ioctl(0, TCSETAW, arg))
X # define SPEED(x) ((x).c_cflag & CBAUD)
X static struct termio inittyb, curttyb;
X! #endif /* BSD */
X
X #define ON 1
X #define OFF 0
X--- 55,84 ----
X * Note: ** entries are available only in termcap mode.
X */
X #include "header.h"
X+ #ifdef __MSDOS__
X+ # include <dos.h>
X
X! static short inittyb, curttyb;
X! # define GTTY(arg) (-((*(arg)=(ioctl(0, 0, arg)&0xff)) == ((-1)&0xff)))
X! # define STTY(arg) (-(ioctl(0, 1, (int *)(*(arg)))==-1))
X!
X! int keypad=0, rawio=0, nansi=0;
X! int fg_color = 7, bg_color = 0;
X! static int echo = 1;
X!
X! #else /* __MSDOS__ */
X!
X! # ifdef BSD
X # define GTTY(arg) (ioctl(0, TIOCGETP, arg))
X # define STTY(arg) (ioctl(0, TIOCSETP, arg))
X static struct sgttyb inittyb, curttyb;
X! # else /* SYSV */
X # define GTTY(arg) (ioctl(0, TCGETA, arg))
X # define STTY(arg) (ioctl(0, TCSETAW, arg))
X # define SPEED(x) ((x).c_cflag & CBAUD)
X static struct termio inittyb, curttyb;
X! # endif /* BSD */
X! #endif /* __MSDOS__ */
X
X #define ON 1
X #define OFF 0
X***************
X*** 117,122 ****
X--- 130,136 ----
X }
X curttyb = inittyb;
X #ifndef BSD
X+ # ifndef __MSDOS__
X ospeed = SPEED(inittyb);
X /* do not expand tabs - they might be needed inside a cm sequence */
X if(curttyb.c_oflag & TAB3) {
X***************
X*** 123,128 ****
X--- 137,143 ----
X curttyb.c_oflag &= ~TAB3;
X setctty();
X }
X+ # endif /* __MSDOS__ */
X #endif /* BSD */
X setuptty();
X }
X***************
X*** 158,167 ****
X ** function to setup all required terminal modes for game
X */
X setuptty(){
X- int change = 0;
X #ifdef BSD
X scbr();
X! #else /* SYSV */
X if((curttyb.c_lflag & ECHO) != OFF){
X curttyb.c_lflag &= ~ECHO;
X change++;
X--- 173,183 ----
X ** function to setup all required terminal modes for game
X */
X setuptty(){
X #ifdef BSD
X scbr();
X! #else
X! # ifdef SYSV
X! int change = 0;
X if((curttyb.c_lflag & ECHO) != OFF){
X curttyb.c_lflag &= ~ECHO;
X change++;
X***************
X*** 176,181 ****
X--- 192,204 ----
X }
X if(change)
X setctty();
X+ # else /* __MSDOS__ */
X+ scbr();
X+ if (rawio) {
X+ curttyb |= 0x20;
X+ setctty();
X+ }
X+ # endif
X #endif /* BSD */
X }
X
X***************
X*** 186,199 ****
X */
X scbr()
X {
X! #ifdef BSD
X curttyb.sg_flags |= CBREAK;
X curttyb.sg_flags &= ~ECHO;
X! #else /* SYSV */
X curttyb.c_lflag &= ~ECHO;
X curttyb.c_lflag &= ~ICANON;
X! #endif /* BSD */
X setctty();
X }
X
X /*
X--- 209,226 ----
X */
X scbr()
X {
X! #ifdef __MSDOS__
X! echo = 0;
X! #else
X! # ifdef BSD
X curttyb.sg_flags |= CBREAK;
X curttyb.sg_flags &= ~ECHO;
X! # else /* SYSV */
X curttyb.c_lflag &= ~ECHO;
X curttyb.c_lflag &= ~ICANON;
X! # endif /* BSD */
X setctty();
X+ #endif /* __MSDOS__ */
X }
X
X /*
X***************
X*** 203,216 ****
X */
X sncbr()
X {
X! #ifdef BSD
X curttyb.sg_flags &= ~CBREAK;
X curttyb.sg_flags |= ECHO;
X! #else /* SYSV */
X curttyb.c_lflag |= ECHO;
X curttyb.c_lflag |= ICANON;
X! #endif /* BSD */
X setctty();
X }
X
X /*
X--- 230,247 ----
X */
X sncbr()
X {
X! #ifdef __MSDOS__
X! echo = 1;
X! #else
X! # ifdef BSD
X curttyb.sg_flags &= ~CBREAK;
X curttyb.sg_flags |= ECHO;
X! # else /* SYSV */
X curttyb.c_lflag |= ECHO;
X curttyb.c_lflag |= ICANON;
X! # endif /* BSD */
X setctty();
X+ #endif /* not __MSDOS__ */
X }
X
X /*
X***************
X*** 220,227 ****
X--- 251,291 ----
X {
X char byt;
X
X+ #ifdef __MSDOS__
X+ static int kpd_trans[] = {
X+ 'y', 'k', 'u', -1,
X+ 'h', '.', 'l', -1,
X+ 'b', 'j', 'n',
X+ 'i', '.',
X+ };
X+ static int kpd_shift_trans[] = {
X+ 'i', 'B', 'J', 'N', 'H', '.', 'L', 'Y', 'K', 'U',
X+ };
X+
X lflush(); /* be sure output buffer is flushed */
X+ try_again:
X+ byt = echo ? getche() : getch();
X+ if (byt == '\r') byt = '\n';
X+ if (echo) return byt;
X+ if (keypad && byt == '\0') { /* translate extended scan codes */
X+ byt = getch();
X+ if (byt < 71 || byt >= 71 + sizeof(kpd_trans)/sizeof(kpd_trans[0]))
X+ goto try_again;
X+ byt = kpd_trans[byt-71];
X+ if (byt == -1) goto try_again;
X+ }
X+ else if (keypad && isdigit(byt)) {
X+ union REGS regs;
X+ regs.h.ah = 2;
X+ int86(0x16, ®s, ®s); /* get shift state */
X+ if (regs.h.al & 0x03) /* is either shift key down? */
X+ byt = kpd_shift_trans[byt-'0'];
X+ }
X+
X+ #else
X+ lflush(); /* be sure output buffer is flushed */
X read(0,&byt,1); /* get byte from terminal */
X+ #endif
X return(byt);
X }
X
X***************
X*** 254,270 ****
X--- 318,347 ----
X * Returns nothing of value.
X */
X /*VARARGS*/
X+ #ifdef __TURBOC__
X+ lprintf(char *fmt, ...)
X+ #else
X lprintf(va_alist)
X va_dcl
X+ #endif
X {
X va_list ap; /* pointer for variable argument list */
X+ #ifndef __TURBOC__
X char *fmt;
X+ #endif
X char *outb,*tmpb;
X long wide,left,cont,n; /* data for lprintf */
X char db[12]; /* %d buffer in lprintf */
X
X+ #ifdef __TURBOC__
X+ va_start(ap, fmt); /* initialize the varargs pointer */
X+ #else
X va_start(ap); /* initialize the var args pointer */
X+ #endif
X+
X+ #ifndef __TURBOC__
X fmt = va_arg(ap, char *); /* pointer to format string */
X+ #endif
X if (lpnt >= lpend) lflush();
X outb = lpnt;
X for ( ; ; ) {
X***************
X*** 310,316 ****
X case 's':
X tmpb = va_arg(ap, char *);
X if (wide==0) {
X! while (*outb++ = *tmpb++);
X --outb;
X }
X else {
X--- 387,393 ----
X case 's':
X tmpb = va_arg(ap, char *);
X if (wide==0) {
X! while ((*outb++ = *tmpb++)!=0);
X --outb;
X }
X else {
X***************
X*** 318,324 ****
X if (left)
X while (n-- > 0)
X *outb++ = ' ';
X! while (*outb++ = *tmpb++)
X ;
X --outb;
X if (left==0)
X--- 395,401 ----
X if (left)
X while (n-- > 0)
X *outb++ = ' ';
X! while ((*outb++ = *tmpb++)!=0)
X ;
X --outb;
X if (left==0)
X***************
X*** 437,444 ****
X
X if (ipoint != iepoint)
X return(inbuffer[ipoint++]);
X- if (iepoint!=MAXIBUF)
X- return(0);
X if ((i=read(fd,inbuffer,MAXIBUF))<=0) {
X if (i!=0)
X fprintf(stderr,"error reading from input file\n");
X--- 514,519 ----
X***************
X*** 567,585 ****
X }
X
X /*
X! * lcreat(filename) Create a new file for write
X * char *filename;
X *
X * lcreat((char*)0); means to the terminal
X * Returns -1 if error, otherwise the file descriptor opened.
X */
X! lcreat(str)
X char *str;
X {
X lpnt = lpbuf;
X lpend = lpbuf+BUFBIG;
X if (str==0) return(lfd=1);
X! if ((lfd=creat(str,0644)) < 0) {
X lfd=1;
X lprintf("error creating file <%s>\n",str);
X lflush();
X--- 642,668 ----
X }
X
X /*
X! * lcreat(filename, mode) Create a new file for write
X * char *filename;
X+ * int mode;
X *
X+ * mode is 0 for text files and 1 for binary files.
X * lcreat((char*)0); means to the terminal
X * Returns -1 if error, otherwise the file descriptor opened.
X */
X! lcreat(str, mode)
X char *str;
X+ int mode;
X {
X lpnt = lpbuf;
X lpend = lpbuf+BUFBIG;
X if (str==0) return(lfd=1);
X! #ifdef __MSDOS__
X! mode = (mode ? O_BINARY : O_TEXT) | O_WRONLY | O_CREAT | O_TRUNC;
X! #else
X! mode = O_WRONLY | O_CREAT | O_TRUNC;
X! #endif
X! if ((lfd=open(str,mode,0644)) < 0) {
X lfd=1;
X lprintf("error creating file <%s>\n",str);
X lflush();
X***************
X*** 589,606 ****
X }
X
X /*
X! * lopen(filename) Open a file for read
X * char *filename;
X *
X * lopen(0) means from the terminal
X * Returns -1 if error, otherwise the file descriptor opened.
X */
X! lopen(str)
X char *str;
X {
X ipoint = iepoint = MAXIBUF;
X if (str==0) return(fd=0);
X! if ((fd=open(str,0)) < 0) {
X lwclose();
X lfd=1;
X lpnt=lpbuf;
X--- 672,697 ----
X }
X
X /*
X! * lopen(filename, mode) Open a file for read
X * char *filename;
X+ * int mode;
X *
X+ * mode is 0 for text files and 1 for binary files.
X * lopen(0) means from the terminal
X * Returns -1 if error, otherwise the file descriptor opened.
X */
X! lopen(str, mode)
X char *str;
X+ int mode;
X {
X ipoint = iepoint = MAXIBUF;
X if (str==0) return(fd=0);
X! #ifdef __MSDOS__
X! mode = (mode ? O_BINARY : O_TEXT) | O_RDONLY;
X! #else
X! mode = O_RDONLY;
X! #endif
X! if ((fd=open(str,mode)) < 0) {
X lwclose();
X lfd=1;
X lpnt=lpbuf;
X***************
X*** 610,628 ****
X }
X
X /*
X! * lappend(filename) Open for append to an existing file
X * char *filename;
X *
X * lappend(0) means to the terminal
X * Returns -1 if error, otherwise the file descriptor opened.
X */
X! lappend(str)
X char *str;
X {
X lpnt = lpbuf;
X lpend = lpbuf+BUFBIG;
X if (str==0) return(lfd=1);
X! if ((lfd=open(str,2)) < 0) {
X lfd=1;
X return(-1);
X }
X--- 701,727 ----
X }
X
X /*
X! * lappend(filename, mode) Open for append to an existing file
X * char *filename;
X+ * int mode;
X *
X+ * mode is 0 for text files and 1 for binary files.
X * lappend(0) means to the terminal
X * Returns -1 if error, otherwise the file descriptor opened.
X */
X! lappend(str, mode)
X char *str;
X+ int mode;
X {
X lpnt = lpbuf;
X lpend = lpbuf+BUFBIG;
X if (str==0) return(lfd=1);
X! #ifdef __MSDOS__
X! mode = (mode ? O_BINARY : O_TEXT) | O_WRONLY | O_APPEND;
X! #else
X! mode = O_WRONLY | O_APPEND;
X! #endif
X! if ((lfd=open(str,mode)) < 0) {
X lfd=1;
X return(-1);
X }
X***************
X*** 664,670 ****
X if (lpnt >= lpend)
X lflush();
X str2 = lpnt;
X! while (*str2++ = *str++)
X ;
X lpnt = str2 - 1;
X }
X--- 763,769 ----
X if (lpnt >= lpend)
X lflush();
X str2 = lpnt;
X! while ((*str2++ = *str++)!=0)
X ;
X lpnt = str2 - 1;
X }
X***************
X*** 708,713 ****
X--- 807,813 ----
X */
X init_term()
X {
X+ #ifndef __MSDOS__
X char termbuf[1024];
X char *capptr = cap+10;
X char *term;
X***************
X*** 760,768 ****
X fflush(stderr);
X exit(1);
X }
X /* get memory for decoded output buffer*/
X if ((outbuf=malloc(BUFBIG+16))==0) {
X! fprintf(stderr,"Error malloc'ing memory for decoded output buffer\n");
X fflush(stderr);
X died(-285); /* malloc() failure */
X }
X--- 860,896 ----
X fflush(stderr);
X exit(1);
X }
X+ #else /* __MSDOS__ */
X+
X+ static char sobuf[20], sebuf[20];
X+
X+ CM = "\033[%d;%dH"; /* Cursor motion */
X+ CE = "\033[K"; /* Clear to eoln */
X+ CL = "\033[2J"; /* Clear screen */
X+
X+ /* OPTIONAL */
X+ if (nansi) {
X+ AL = "\033[L"; /* Insert line */
X+ DL = "\033[M"; /* Delete line */
X+ }
X+ else {
X+ AL = NULL; /* Insert line */
X+ DL = NULL; /* Delete line */
X+ }
X+
X+ sprintf(sobuf, "\033[1;%d;%dm", fg_color + 30, bg_color + 40);
X+ sprintf(sebuf, "\033[0;%d;%dm", fg_color + 30, bg_color + 40);
X+
X+ SO = sobuf; /* Begin standout mode */
X+ SE = sebuf; /* End standout mode */
X+ CD = NULL; /* Clear to end of display */
X+
X+ puts(sebuf);
X+ #endif /* __MSDOS__ */
X+
X /* get memory for decoded output buffer*/
X if ((outbuf=malloc(BUFBIG+16))==0) {
X! fprintf(stderr,"Error malloc'ing memory for decoded output buffer\n");
X fflush(stderr);
X died(-285); /* malloc() failure */
X }
X***************
X*** 839,844 ****
X--- 967,990 ----
X {
X enable_scroll = -1;
X }
X+
X+ #ifdef __MSDOS__
X+
X+ void tputs(char *s, int x, int (*outch)())
X+ {
X+ while (*s) (*outch)(*s++);
X+ ++x;
X+ }
X+
X+ char *tgoto(char *s, int x, int y)
X+ {
X+ static char buf[12];
X+
X+ sprintf(buf, s, y+1, x+1);
X+ return buf;
X+ }
X+
X+ #endif /* __MSDOS__ */
X
X /*
X * lflush() Flush the output buffer
SHAR_EOF
if test 50636 -ne "`wc -c < 'patch02.1'`"
then
echo shar: error transmitting "'patch02.1'" '(should have been 50636 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0