[comp.sources.games.bugs] Ularn works under GEMDOS

7103_300@uwovax.uwo.ca (07/15/89)

Here are the patches for compiling Ularn under GEMDOS. They may also
be useful as a base for porting Ularn to MS-DOS, since the two operating
systems are so similar. I used the GCC 1.34 to do the compilation; if
you use another compiler, or an older version of the GCC library, you
may also need to make some changes:

(1) I used 32 bit integers; I spotted and fixed a few places where it
is assumed that sizeof(int) == sizeof(long), but there are no doubt
some more lurking about. Watch out for these if your compiler has 16 bit
integers.

(2) You'll need a termcap library. I used the Fred Fish PD one.

(3) The library I used has two routines, console_read_byte() and
console_input_status(), which are used by read() to get bytes from the
keyboard; console_read_byte() returns the ASCII value of the next key
pressed, and console_input_status returns a nonzero value if there are
keys in the input buffer. You may need to #define these to whatever is
appropriate for your compiler in header.h.

(4) The new macro feature, and the remapping of the keypad keys, are
supported by the library routine console_set_key. It is called as
   console_set_key(int scan, char *r, char *s, char *a)
where "scan" is the key scan code returned by the BIOS, "r" is the string
to be sent when the key is pressed, "s" is the string to be sent when
SHIFT+key is pressed, and "a" is the string to be sent when ALT+key is
pressed. The header file <keycodes.h> defines the scan codes of some
commonly used keys, e.g. F_1 for function key 1. If you want to use this
feature, you'll have to write a version of console_set_key(); otherwise,
just #define out all references to console_set_key and keycodes.h.

(5) MSDOS users: the values for the scan codes of the keypad are hardwired
into io.c, and are Atari ST specific; they'll need to be changed to whatever
is appropriate for DOS.

Oh yes, one other thing: the patches are against the original source posting,
with no patches applied.

--
Eric R. Smith                     email:
Dept. of Mathematics            7103_300@uwovax.uwo.ca
University of Western Ontario   7103_300@uwovax.bitnet
London, Ont. Canada N6A 5B7     (a shared mailbox: put my name on
ph: (519) 661-3638              the message, please!)

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	notes
#	patches
#	readme.st
#	makefile
#	xconsole.c
#	ularn.opt
# This archive created: 13 July 1989 09:59:42 PM EDT
# By:	eric (at home)
echo shar: extracting notes
sed 's/^X//' << \SHAR_EOF > notes
XHere are the patches for compiling Ularn under GEMDOS. They may also
Xbe useful as a base for porting Ularn to MS-DOS, since the two operating
Xsystems are so similar. I used the GCC 1.34 to do the compilation; if
Xyou use another compiler, or an older version of the GCC library, you
Xmay also need to make some changes:
X
X(1) I used 32 bit integers; I spotted and fixed a few places where it
Xis assumed that sizeof(int) == sizeof(long), but there are no doubt
Xsome more lurking about. Watch out for these if your compiler has 16 bit
Xintegers.
X
X(2) You'll need a termcap library. I used the Fred Fish PD one.
X
X(3) The library I used has two routines, console_read_byte() and
Xconsole_input_status(), which are used by read() to get bytes from the
Xkeyboard; console_read_byte() returns the ASCII value of the next key
Xpressed, and console_input_status returns a nonzero value if there are
Xkeys in the input buffer. You may need to #define these to whatever is
Xappropriate for your compiler in header.h.
X
X(4) The new macro feature, and the remapping of the keypad keys, are
Xsupported by the library routine console_set_key. It is called as
X   console_set_key(int scan, char *r, char *s, char *a)
Xwhere "scan" is the key scan code returned by the BIOS, "r" is the string
Xto be sent when the key is pressed, "s" is the string to be sent when
XSHIFT+key is pressed, and "a" is the string to be sent when ALT+key is
Xpressed. The header file <keycodes.h> defines the scan codes of some
Xcommonly used keys, e.g. F_1 for function key 1. If you want to use this
Xfeature, you'll have to write a version of console_set_key(); otherwise,
Xjust #define out all references to console_set_key and keycodes.h.
X
X(5) MSDOS users: the values for the scan codes of the keypad are hardwired
Xinto io.c, and are Atari ST specific; they'll need to be changed to whatever
Xis appropriate for DOS.
X
X--
XEric R. Smith                     email:
XDept. of Mathematics            7103_300@uwovax.uwo.ca
XUniversity of Western Ontario   7103_300@uwovax.bitnet
XLondon, Ont. Canada N6A 5B7     (a shared mailbox: put my name on
Xph: (519) 661-3638              the message, please!)
X
SHAR_EOF
if test 2139 -ne "`wc -c notes`"
then
echo shar: error transmitting notes '(should have been 2139 characters)'
fi
echo shar: extracting patches
sed 's/^X//' << \SHAR_EOF > patches
X*** orig/bill.c	Fri Jul  7 21:14:40 1989
X--- bill.c	Mon Jul 10 20:32:20 1989
X***************
X*** 9,15 ****
X--- 9,19 ----
X  static int pid;
X  letter1()
X  {
X+ #ifdef GEMDOS
X+ 	strcpy(mail600, "mail600"); /* prepare path */
X+ #else
X  	sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */
X+ #endif
X  	if (lcreat(mail600) < 0) { 
X  		write(1,"can't write 600 letter\n",23); 
X  		return(0);
X***************
X*** 37,43 ****
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--- 41,51 ----
X  
X  letter2()
X  {
X! #ifdef GEMDOS
X! 	strcpy(mail600, "mail601"); /* prepare path */
X! #else
X! 	sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */
X! #endif
X  	if (lcreat(mail600) < 0) { 
X  		write(1,"can't write 601 letter\n",23); 
X  		return(0);
X***************
X*** 62,68 ****
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--- 70,80 ----
X  
X  letter3()
X  {
X! #ifdef GEMDOS
X! 	strcpy(mail600, "mail602",pid); /* prepare path */
X! #else
X! 	sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */
X! #endif
X  	if (lcreat(mail600) < 0) { 
X  		write(1,"can't write 602 letter\n",23); 
X  		return(0);
X***************
X*** 89,95 ****
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--- 101,111 ----
X  
X  letter4()
X  {
X! #ifdef GEMDOS
X! 	strcpy(mail600, "mail603"); /* prepare path */
X! #else
X! 	sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */
X! #endif
X  	if (lcreat(mail600) < 0) { 
X  		write(1,"can't write 603 letter\n",23); 
X  		return(0);
X***************
X*** 111,117 ****
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--- 127,137 ----
X  
X  letter5()
X  {
X! #ifdef GEMDOS
X! 	strcpy(mail600, "mail604"); /* prepare path */
X! #else
X! 	sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */
X! #endif
X  	if (lcreat(mail600) < 0) { 
X  		write(1,"can't write 604 letter\n",23); 
X  		return(0);
X***************
X*** 139,145 ****
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--- 159,169 ----
X  
X  letter6()
X  {
X! #ifdef GEMDOS
X! 	strcpy(mail600, "mail605"); /* prepare path */
X! #else
X! 	sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */
X! #endif
X  	if (lcreat(mail600) < 0) { 
X  		write(1,"can't write 605 letter\n",23); 
X  		return(0);
X***************
X*** 175,185 ****
X--- 199,217 ----
X  	register int i;
X  	char buf[128];
X  
X+ #ifndef GEMDOS
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+ #ifdef GEMDOS
X+ 		{
X+ 			if ((*pfn[i])())
X+ 				lwclose();
X+ 		}
X+ #else
X  			if ((*pfn[i])()) {
X  				sleep(20);  
X  				sprintf(buf,"mail %s < %s",loginname,mail600);
X***************
X*** 188,191 ****
X--- 220,224 ----
X  			}
X  		exit(0);
X  	}
X+ #endif
X  }
X*** orig/config.c	Fri Jul  7 21:17:10 1989
X--- config.c	Fri Jul  7 21:49:54 1989
X***************
X*** 7,12 ****
X--- 7,24 ----
X   */
X  #include "header.h"
X  
X+ #ifdef GEMDOS
X+ #include <stdio.h>
X+ 
X+ typedef char File_name[FILENAME_MAX];
X+ 
X+ File_name savefilename, scorefile, logfile, helpfile, larnlevels, fortfile,
X+ 	optsfile;
X+ 
X+ File_name HOME;
X+ 
X+ #else
X+ 
X  /* the game save filename   */
X  char savefilename[SAVEFILENAMESIZE] = 	HOME;
X  
X***************
X*** 27,32 ****
X--- 39,46 ----
X  
X  /* the .Ularnopts filename */
X  char optsfile[128] ="/.Ularnopts";	/* the option file */
X+ 
X+ #endif /* GEMDOS */
X  
X  char diagfile[] ="Diagfile";		/* the diagnostic filename	*/
X  char ckpfile[] ="Ularn.ckp";		/* the checkpoint filename	*/
X*** orig/diag.c	Fri Jul  7 21:16:42 1989
X--- diag.c	Sat Jul  8 01:09:50 1989
X***************
X*** 255,261 ****
X--- 255,265 ----
X  	lprint((long)(zzz-initialtime));
X  	lwrite((char*)&zzz,sizeof(long));
X  
X+ #ifdef GEMDOS
X+ 	if (stat(fname, &statbuf) < 0) lprint(0L);
X+ #else
X  	if (fstat(lfd,&statbuf)< 0) lprint(0L);
X+ #endif
X  	else 
X  		lprint((long)statbuf.st_ino); /* inode # */
X  
X***************
X*** 336,343 ****
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--- 340,350 ----
X  	time(&zzz);
X  	initialtime = zzz-lrint();
X  
X+ #ifdef GEMDOS
X+ 	stat(fname,&filetimes);/*get the creation and modification time of file*/
X+ #else
X  	fstat(fd,&filetimes);/*get the creation and modification time of file*/
X! #endif
X  	lrfill((char*)&zzz,sizeof(long));	
X  
X  	zzz += 6;
X***************
X*** 355,363 ****
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--- 362,371 ----
X  	oldx = oldy = 0;
X  
X  	i = lrint();  /* inode # */
X+ #ifndef GEMDOS
X  	if (i && (filetimes.st_ino!=i)) 
X  		fsorry();	/* different inode number, file was copied */
X! #endif
X  	lrclose();
X  
X  	if (strcmp(fname,ckpfile) == 0) {
X*** orig/fortune.c	Fri Jul  7 21:16:52 1989
X--- fortune.c	Sat Jul  8 01:44:52 1989
X***************
X*** 13,28 ****
X  {
X  	register char *p;
X  	register int lines,tmp;
X! 	struct stat stat;
X  	char *malloc();
X! 
X  	if (fd==0) {
X  		if ((fd=open(file,O_RDONLY)) < 0)	/* open the file */
X  			return(0); /* can't find file */
X  
X  		/* find out how big fortune file is and get memory for it */
X! 		stat.st_size = 16384;
X! 		if ((fstat(fd,&stat) < 0) || ((base=malloc(1+stat.st_size)) == 0))
X  		{
X  			close(fd); 
X  			fd= -1; 
X--- 13,33 ----
X  {
X  	register char *p;
X  	register int lines,tmp;
X! 	struct stat stb;
X! #if 0		/* ERS -- this is already defined in header.h */
X  	char *malloc();
X! #endif
X  	if (fd==0) {
X  		if ((fd=open(file,O_RDONLY)) < 0)	/* open the file */
X  			return(0); /* can't find file */
X  
X  		/* find out how big fortune file is and get memory for it */
X! 		stb.st_size = 16384;
X! #ifdef GEMDOS
X! 		if ((stat(file,&stb) < 0) || ((base=malloc(1+stb.st_size)) == 0))
X! #else
X! 		if ((fstat(fd,&stb) < 0) || ((base=malloc(1+stb.st_size)) == 0))
X! #endif
X  		{
X  			close(fd); 
X  			fd= -1; 
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--- 36,42 ----
X  		}
X  
X  		/* read in the entire fortune file */
X! 		if (read(fd,base,stb.st_size) != stb.st_size) {
X  			close(fd); 
X  			fd= -1; 
X  			free((char*)base); 
X***************
X*** 38,47 ****
X  			return(0); 	/* can't read file */
X  		}
X  		close(fd);  
X! 		base[stat.st_size]=0;	/* final NULL termination */
X  
X  	/* count up all the lines (and NULL terminate) to know memory needs */
X! 		for (p=base,lines=0; p<base+stat.st_size; p++) /* count lines */
X  			if (*p == '\n') *p=0,lines++;
X  		nlines = lines;
X  
X--- 43,52 ----
X  			return(0); 	/* can't read file */
X  		}
X  		close(fd);  
X! 		base[stb.st_size]=0;	/* final NULL termination */
X  
X  	/* count up all the lines (and NULL terminate) to know memory needs */
X! 		for (p=base,lines=0; p<base+stb.st_size; p++) /* count lines */
X  			if (*p == '\n') *p=0,lines++;
X  		nlines = lines;
X  
X*** orig/header.h	Fri Jul  7 21:16:28 1989
X--- header.h	Sat Jul  8 01:41:22 1989
X***************
X*** 1,4 ****
X--- 1,11 ----
X  /*	header.h */
X+ #ifdef GEMDOS
X+ #include <types.h>
X+ #include <stat.h>
X+ #include <time.h>
X+ #include <ioctl.h>
X+ #define lwrite l_write		/* library conflict */
X+ #else
X  #include <sys/types.h>
X  #include <sys/stat.h>
X  #include <sys/timeb.h>
X***************
X*** 10,15 ****
X--- 17,23 ----
X  #    include <sys/times.h>
X  #    include <termio.h>
X  #endif
X+ #endif /* GEMDOS */
X  
X  #include <fcntl.h>
X  #include <ctype.h>
X***************
X*** 17,22 ****
X--- 25,33 ----
X  #include <pwd.h>
X  #include <signal.h>
X  #include <stdio.h>
X+ #if __STDC__		/* ERS */
X+ #include <stdlib.h>
X+ #endif
X  
X  #define SCORENAME   "Uscore"
X  #define LOGFNAME    "Ulog"
X***************
X*** 402,408 ****
X--- 413,424 ----
X  extern struct sphere *spheres;
X  extern struct _itm itm[];
X  
X+ #if __STDC__
X+ /* malloc is really void *; see stdlib.h  -- ERS */
X+ char *fortune(),*getenv(),*getlogin(),*lgetw(),*lgetl(),*ctime();
X+ #else
X  char *fortune(),*malloc(),*getenv(),*getlogin(),*lgetw(),*lgetl(),*ctime();
X+ #endif
X  char *tmcapcnv(),*tgetstr(),*tgoto();
X  long paytaxes(),lgetc(),lrint(),time();
X  long readnum();
X***************
X*** 459,461 ****
X--- 475,482 ----
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+ 
X+ /* added by ERS for the Atari ST version, but useful for any ANSI compiler */
X+ #if __STDC__
X+ #include "ularn_proto.h"
X+ #endif
X*** orig/io.c	Fri Jul  7 21:15:24 1989
X--- io.c	Sun Jul  9 10:31:54 1989
X***************
X*** 56,61 ****
X--- 56,65 ----
X   */
X  #include "header.h"
X  
X+ #ifdef GEMDOS
X+ #define BSD		/* closest match */
X+ #endif
X+ 
X  #ifdef BSD
X  #    define	GTTY(arg)	(ioctl(0, TIOCGETP, arg))
X  #    define	STTY(arg)	(ioctl(0, TIOCSETP, arg))
X***************
X*** 88,93 ****
X--- 92,100 ----
X  	clear();  
X  	setscroll();  
X  	gettty();
X+ #ifdef GEMDOS
X+ 	setkeys();
X+ #endif
X  }
X  
X  /*
X***************
X*** 1016,1018 ****
X--- 1023,1065 ----
X  {
X  	if (!nobeep) *lpnt++ = '\7';
X  }
X+ 
X+ #ifdef GEMDOS
X+ /*
X+  * setkeys(): uses console_set_key (see xconsole.c in the curses/termcap
X+  * library) to rebind the keys. If you're not using the GCC with the
X+  * new library, you'll have to find a kludge around this.
X+  */
X+ 
X+ #define KEYPADLO 0x61	/* UNDO key */
X+ #define KEYPADHI 0x72	/* Enter key */
X+ 
X+ static char *kp_unshft[KEYPADHI - KEYPADLO + 1] =
X+ {	"\033", "?",		/* UNDO, HELP */
X+ 	"r", "w", "d", "q",
X+ 	"y", "k", "u",		/* 7, 8, 9 */
X+ 	"h", ".", "l",		/* 4, 5, 6 */
X+ 	"b", "j", "n",		/* 1, 2, 3 */
X+ 	"i", "g", "Z"		/* 0, ., Enter */
X+ };
X+ 
X+ static char *kp_shft[KEYPADHI - KEYPADLO + 1] =
X+ {	"\033", "v",		/* UNDO, HELP */
X+ 	"", "W", "T", "e",
X+ 	"Y", "K", "U",		/* 7, 8, 9 */
X+ 	"H", ".", "L",		/* 4, 5, 6 */
X+ 	"B", "J", "N",		/* 1, 2, 3 */
X+ 	"D", "P", "c"		/* 0, ., Enter */
X+ };
X+ 
X+ 
X+ int setkeys()
X+ {
X+ 	int i;
X+ 
X+ 	for (i = 0; i <= KEYPADHI - KEYPADLO; i++) {
X+ 		console_set_key(i + KEYPADLO, kp_unshft[i], kp_shft[i], "");
X+ 	}
X+ }
X+ 
X+ #endif /* GEMDOS */
X*** orig/main.c	Fri Jul  7 21:16:06 1989
X--- main.c	Tue Jul 11 08:54:36 1989
X***************
X*** 5,10 ****
X--- 5,16 ----
X  static char copyright[]=
X  "\nUlarn was created by Phil Cordier and is based on Larn by Noah Morgan\n";
X  
X+ #ifdef GEMDOS
X+ extern char HOME[];
X+ long _stksize = 32*1024L;
X+ #define setuserid() {userid=(userid<0)?char_class[0]*256+char_class[1]:userid; }
X+ #endif
X+ 
X  int srcount=0;	/* line counter for showstr()	*/
X  int dropflag=0; /* if 1 then don't lookforobject() next round */
X  int rmst=80;	/* random monster creation counter		*/
X***************
X*** 30,35 ****
X--- 36,52 ----
X    -##  specify level of difficulty (example: Ularn -5)\n\
X    -++  restore game checkpoint file\n";
X  
X+ #ifdef GEMDOS
X+ /*
X+  * Pauses to allow player to read messages before desktop is redrawn.
X+  */
X+ static void do_pause()
X+ {
X+ 	puts("Hit any key to continue\n");
X+ 	getcharacter();
X+ }
X+ #endif /* GEMDOS */
X+ 
X  /*
X  	************
X  	MAIN PROGRAM
X***************
X*** 45,50 ****
X--- 62,95 ----
X  	char *ptr=0;
X  	struct passwd *pwe,*getpwuid();
X  
X+ #ifdef GEMDOS
X+ /* See if we should pause before going back, for the benefit of users
X+    running from the desktop */
X+ 	if (*argv[0] == 0)		/* many CLI's set argv[0], desktop doesn't  */
X+ 		atexit(do_pause);
X+ 
X+ /* Make sure there's enough memory */
X+ 	if (!(ptr = malloc(172000))) {
X+ 		fprintf(stderr, "Insufficient memory to run\n");
X+ 		exit(1);
X+ 	}
X+ 	free(ptr);
X+ /*
X+  * Find out where the files are; either the environment variable LARNDIR
X+  * or the current directory.
X+  */
X+ 	if (!(ptr = getenv("LARNDIR")))
X+ 		ptr = ".";
X+ 	strcpy(HOME, ptr);
X+ 	strcat(HOME, "/");
X+ 	strcpy(savefilename, HOME);
X+ 	strcpy(scorefile, HOME);
X+ 	strcpy(logfile, HOME);
X+ 	strcpy(helpfile, HOME);
X+ 	strcpy(larnlevels, HOME);
X+ 	strcpy(fortfile, HOME);
X+ #endif /* GEMDOS */
X+ 
X  	init_term();	/*setup the terminal (find out what type) for termcap */
X  
X  /*
X***************
X*** 69,83 ****
X  	strcpy(logname,ptr);	
X  
X  	/* this will be overwritten with the players name */
X  	if ((ptr = getenv("HOME")) == NULL) 
X  		if ((ptr = pwe->pw_dir) == NULL)
X  			ptr = ".";
X  
X  	/* save file name in home directory */
X  	strcpy(savefilename, ptr);
X  	strcat(savefilename, "/Ularn.sav");	
X- 
X  	sprintf(optsfile, "%s/.Ularnopts",ptr);	/* the .Ularnopts filename */
X  	strcat(scorefile, SCORENAME);	/* the Ularn scoreboard filename */
X  	strcat(logfile, LOGFNAME);
X  
X--- 114,137 ----
X  	strcpy(logname,ptr);	
X  
X  	/* this will be overwritten with the players name */
X+ #ifdef GEMDOS
X+ 	ptr = HOME;
X+ #else
X  	if ((ptr = getenv("HOME")) == NULL) 
X  		if ((ptr = pwe->pw_dir) == NULL)
X  			ptr = ".";
X+ #endif
X  
X  	/* save file name in home directory */
X+ 
X+ #ifdef GEMDOS
X+ 	sprintf(savefilename, "%sUlarn.sav", ptr);
X+ 	sprintf(optsfile, "%sUlarn.opt",ptr);	/* the .Ularnopts filename */
X+ #else
X  	strcpy(savefilename, ptr);
X  	strcat(savefilename, "/Ularn.sav");	
X  	sprintf(optsfile, "%s/.Ularnopts",ptr);	/* the .Ularnopts filename */
X+ #endif
X  	strcat(scorefile, SCORENAME);	/* the Ularn scoreboard filename */
X  	strcat(logfile, LOGFNAME);
X  
X***************
X*** 164,176 ****
X  		}
X  	}
X  
X! 
X  	userid = geteuid();	/* obtain the user's effective id number */
X- 
X  	sigsetup();	/* trap all needed signals	*/
X  	sethard(hard);	/* set up the desired difficulty	*/
X  	setupvt100();	/* setup the terminal special mode	*/
X  	readopts();	/* read the options file if there is one */
X  
X  	/* restore game if need to */
X  	if (access(savefilename,0)==0)	{
X--- 218,238 ----
X  		}
X  	}
X  
X! #ifndef GEMDOS
X  	userid = geteuid();	/* obtain the user's effective id number */
X  	sigsetup();	/* trap all needed signals	*/
X  	sethard(hard);	/* set up the desired difficulty	*/
X  	setupvt100();	/* setup the terminal special mode	*/
X  	readopts();	/* read the options file if there is one */
X+ #else
X+ 	if (ptr = getenv("USERID"))
X+ 		userid = atoi(ptr);
X+ 	else
X+ 		userid = -1;
X+ 	sigsetup();	/* trap all needed signals	*/
X+ 	setupvt100();	/* setup the terminal special mode	*/
X+ 	readopts();	/* read the options file if there is one */
X+ #endif
X  
X  	/* restore game if need to */
X  	if (access(savefilename,0)==0)	{
X***************
X*** 177,188 ****
X  		clear();	
X  		restorflag = 1;
X  		hitflag=1;	
X! 		restoregame(savefilename);  
X  	}
X  
X  	/* create new game */
X  	if (c[HP]==0) {
X  		makeplayer();	/*	make the character that will play*/
X  		newcavelevel(0);/*	make the dungeon */
X  		predostuff = 1;	
X  
X--- 239,258 ----
X  		clear();	
X  		restorflag = 1;
X  		hitflag=1;	
X! 		restoregame(savefilename);
X! #ifdef GEMDOS
X! 		setuserid();
X! 		sethard(hard);  
X! #endif
X  	}
X  
X  	/* create new game */
X  	if (c[HP]==0) {
X  		makeplayer();	/*	make the character that will play*/
X+ #ifdef GEMDOS
X+ 		setuserid();
X+ 		sethard(hard);	/* set up the desired difficulty	*/
X+ #endif
X  		newcavelevel(0);/*	make the dungeon */
X  		predostuff = 1;	
X  
X***************
X*** 269,275 ****
X  		srcount++; 
X  	}
X  
X! 	for (k=0; k<=26; k++)
X  		if (iven[k]) show3(k);
X  
X  	lprintf("\nElapsed time is %d.  You have %d mobuls left",
X--- 339,345 ----
X  		srcount++; 
X  	}
X  
X! 	for (k=0; k<26; k++)
X  		if (iven[k]) show3(k);
X  
X  	lprintf("\nElapsed time is %d.  You have %d mobuls left",
X***************
X*** 320,326 ****
X  	srcount=0;
X  
X  	/* count number of items we will display */
X! 	for (count=2,j=0; j<=26; j++)	 
X  	   if (i=iven[j])
X  		switch(i) {
X  			case OLEATHER:	
X--- 390,396 ----
X  	srcount=0;
X  
X  	/* count number of items we will display */
X! 	for (count=2,j=0; j<26; j++)	 
X  	   if (i=iven[j])
X  		switch(i) {
X  			case OLEATHER:	
X***************
X*** 339,345 ****
X  	t_setup(count);
X  
X  	for (i=22; i<93; i++)
X! 		 for (j=0; j<=26; j++)
X  		   if (i==iven[j])
X  			switch(i) {
X  				case OLEATHER:	
X--- 409,415 ----
X  	t_setup(count);
X  
X  	for (i=22; i<93; i++)
X! 		 for (j=0; j<26; j++)
X  		   if (i==iven[j])
X  			switch(i) {
X  				case OLEATHER:	
X***************
X*** 368,374 ****
X  	sigsav=nosignal;  nosignal=1; /* don't allow ^c etc */
X  	srcount=0;
X  
X! 	 for (count=2,j=0; j<=26; j++)	/* count how many items */
X  	   if (i=iven[j])
X  		switch(i) {
X  			case ODIAMOND:  case ORUBY:  case OEMERALD:  
X--- 438,444 ----
X  	sigsav=nosignal;  nosignal=1; /* don't allow ^c etc */
X  	srcount=0;
X  
X! 	 for (count=2,j=0; j<26; j++)	/* count how many items */
X  	   if (i=iven[j])
X  		switch(i) {
X  			case ODIAMOND:  case ORUBY:  case OEMERALD:  
X***************
X*** 390,396 ****
X  	t_setup(count);
X  
X  	for (i=22; i<93; i++)
X! 		 for (j=0; j<=26; j++)
X  		   if (i==iven[j])
X  			switch(i) {
X  				case ODIAMOND:  case ORUBY:  
X--- 460,466 ----
X  	t_setup(count);
X  
X  	for (i=22; i<93; i++)
X! 		 for (j=0; j<26; j++)
X  		   if (i==iven[j])
X  			switch(i) {
X  				case ODIAMOND:  case ORUBY:  
X***************
X*** 419,425 ****
X  	sigsav=nosignal;  nosignal=1; /* don't allow ^c etc */
X  	srcount=0;
X  
X! 	for (count=2,j=0; j<=26; j++)
X  		switch(iven[j]) {
X  			case OBOOK:	
X  			case OSCROLL:	
X--- 489,495 ----
X  	sigsav=nosignal;  nosignal=1; /* don't allow ^c etc */
X  	srcount=0;
X  
X! 	for (count=2,j=0; j<26; j++)
X  		switch(iven[j]) {
X  			case OBOOK:	
X  			case OSCROLL:	
X***************
X*** 428,434 ****
X  	t_setup(count);
X  
X  	for (i=22; i<84; i++)
X! 		 for (j=0; j<=26; j++)
X  		   if (i==iven[j])
X  			switch(i) {
X  				case OBOOK:	
X--- 498,504 ----
X  	t_setup(count);
X  
X  	for (i=22; i<84; i++)
X! 		 for (j=0; j<26; j++)
X  		   if (i==iven[j])
X  			switch(i) {
X  				case OBOOK:	
X***************
X*** 451,457 ****
X  	nosignal=1; /* don't allow ^c etc */
X  	srcount=0;
X  
X! 	for (count=2,j=0; j<=26; j++)
X  		switch(iven[j]) {
X  			case OCOOKIE:	
X  				count++;
X--- 521,527 ----
X  	nosignal=1; /* don't allow ^c etc */
X  	srcount=0;
X  
X! 	for (count=2,j=0; j<26; j++)
X  		switch(iven[j]) {
X  			case OCOOKIE:	
X  				count++;
X***************
X*** 459,465 ****
X  	t_setup(count);
X  
X  	for (i=22; i<84; i++)
X! 		 for (j=0; j<=26; j++)
X  		   if (i==iven[j])
X  			switch(i) {
X  				case OCOOKIE:	
X--- 529,535 ----
X  	t_setup(count);
X  
X  	for (i=22; i<84; i++)
X! 		 for (j=0; j<26; j++)
X  		   if (i==iven[j])
X  			switch(i) {
X  				case OCOOKIE:	
X***************
X*** 481,487 ****
X  	nosignal=1; /* don't allow ^c etc */
X  	srcount=0;
X  
X! 	for (count=2,j=0; j<=26; j++)
X  		switch(iven[j]) {
X  			case OPOTION:	
X  				count++;
X--- 551,557 ----
X  	nosignal=1; /* don't allow ^c etc */
X  	srcount=0;
X  
X! 	for (count=2,j=0; j<26; j++)
X  		switch(iven[j]) {
X  			case OPOTION:	
X  				count++;
X***************
X*** 489,495 ****
X  	t_setup(count);
X  
X  	for (i=22; i<84; i++)
X! 	  for (j=0; j<=26; j++)
X  	     if (i==iven[j])
X  		switch(i) {
X  			case OPOTION:	
X--- 559,565 ----
X  	t_setup(count);
X  
X  	for (i=22; i<84; i++)
X! 	  for (j=0; j<26; j++)
X  	     if (i==iven[j])
X  		switch(i) {
X  			case OPOTION:	
X***************
X*** 1129,1135 ****
X  	char gack[26];
X  
X  	cursors();
X! 	for (j=0; j<=26; j++)
X  		switch(iven[j]) {
X  			case OPOTION:	gack[i++] = j;
X  		};
X--- 1199,1205 ----
X  	char gack[26];
X  
X  	cursors();
X! 	for (j=0; j<26; j++)
X  		switch(iven[j]) {
X  			case OPOTION:	gack[i++] = j;
X  		};
X***************
X*** 1164,1170 ****
X  	else if (!strcmp(str, "eat")) e = 1;
X  	else if (!strcmp(str, "drop")) d = 1;
X  
X! 	for (j=0; j<=26; j++) {
X  		switch(iven[j]) {
X  		case OSWORDofSLASHING :
X  		case OHAMMER:
X--- 1234,1240 ----
X  	else if (!strcmp(str, "eat")) e = 1;
X  	else if (!strcmp(str, "drop")) d = 1;
X  
X! 	for (j=0; j<26; j++) {
X  		switch(iven[j]) {
X  		case OSWORDofSLASHING :
X  		case OHAMMER:
X*** orig/scores.c	Fri Jul  7 21:15:38 1989
X--- scores.c	Sun Jul  9 11:46:20 1989
X***************
X*** 199,204 ****
X--- 199,207 ----
X  
X  	c[HARDGAME] = 0;
X  
X+ #ifdef GEMDOS
X+ 	outstanding_taxes = 0;
X+ #endif
X  	if (readboard() < 0) 
X  		return(0);	/* can't find scoreboard */
X  
X*** orig/signal.c	Fri Jul  7 21:15:08 1989
X--- signal.c	Fri Jul  7 22:39:16 1989
X***************
X*** 85,91 ****
X--- 85,93 ----
X  {
X  	signal(SIGQUIT, cntlc); 		
X  	signal(SIGINT,  cntlc); 
X+ #ifndef GEMDOS
X  	signal(SIGKILL, SIG_IGN);		
X+ #endif
X  	signal(SIGHUP,  sgam);
X  	signal(SIGILL,  sigill);		
X  	signal(SIGTRAP, sigtrap);
X***************
X*** 137,142 ****
X--- 139,145 ----
X  	"","","","" };
X  
X  #else  /* SYSV */
X+ #ifndef GEMDOS
X  static char *signame[NSIG] = { 
X  	"",
X  	"SIGHUP",  /*	1	 hangup */
X***************
X*** 159,164 ****
X--- 162,168 ----
X  	"SIGCLD",  /*	18	 child death */
X  	"SIGPWR"   /*	19	 power fail */
X  };
X+ #endif /* GEMDOS */
X  #endif /* BSD */
X  
X  /*
X***************
X*** 168,175 ****
X--- 172,183 ----
X  int sig;
X  {
X  	signal(sig,SIG_DFL);
X+ #ifdef GEMDOS
X+ 	psignal(sig, "Ularn got a fatal signal");
X+ #else
X  	fprintf(stderr,"\nUlarn - SHIT! Signal %d !!! [%s]\n",sig,signame[sig]);
X  	fflush(stderr);
X+ #endif
X  	sleep(2);
X  	sncbr();
X  	savegame(savefilename); 
X*** orig/store.c	Fri Jul  7 21:15:44 1989
X--- store.c	Sat Jul  8 02:16:12 1989
X***************
X*** 216,227 ****
X  				outofstock(); 
X  			else if (pocketfull()) 
X  				handsfull(); 
X! 			else if (c[GOLD] < itm[i].price*10) 
X  				nogold(); 
X  			else { 	
X  				if (itm[i].mem != 0) 
X  					*itm[i].mem[itm[i].arg] = ' ';
X! 				c[GOLD] -= itm[i].price*10;
X  				itm[i].qty--;  
X  				take(itm[i].obj,itm[i].arg);
X  				if (itm[i].qty==0) 
X--- 216,227 ----
X  				outofstock(); 
X  			else if (pocketfull()) 
X  				handsfull(); 
X! 			else if (c[GOLD] < itm[i].price*10L) 
X  				nogold(); 
X  			else { 	
X  				if (itm[i].mem != 0) 
X  					*itm[i].mem[itm[i].arg] = ' ';
X! 				c[GOLD] -= itm[i].price*10L;
X  				itm[i].qty--;  
X  				take(itm[i].obj,itm[i].arg);
X  				if (itm[i].qty==0) 
X***************
X*** 284,290 ****
X  	}
X  	else lprintf("%s",objectname[itm[i].obj]);
X  	cursor( j+31,k );  
X! 	lprintf("%6d",(long)(itm[i].price*10));
X  }
X  
X  
X--- 284,290 ----
X  	}
X  	else lprintf("%s",objectname[itm[i].obj]);
X  	cursor( j+31,k );  
X! 	lprintf("%6d",(long)(itm[i].price*10L));
X  }
X  
X  
X***************
X*** 682,688 ****
X  appraise(gemstone)
X  int gemstone;
X  {
X! 	register int j,amt;
X  
X  	for (j=0; j<26; j++)
X  		if (iven[j]==gemstone) {
X--- 682,688 ----
X  appraise(gemstone)
X  int gemstone;
X  {
X! 	register long	j, amt;  /* used to be int -- ERS */
X  
X  	for (j=0; j<26; j++)
X  		if (iven[j]==gemstone) {
X***************
X*** 728,734 ****
X  
X  otradepost()
X  {
X! 	int i,j,value,isub,izarg;
X  
X  	dnditm = dndcount = 0;
X  	nosignal = 1; /* disable signals */
X--- 728,734 ----
X  
X  otradepost()
X  {
X! 	long i,j,value,isub,izarg;	/* ERS -- used to be int */
X  
X  	dnditm = dndcount = 0;
X  	nosignal = 1; /* disable signals */
X*** orig/tok.c	Fri Jul  7 21:17:12 1989
X--- tok.c	Tue Jul 11 10:34:12 1989
X***************
X*** 13,18 ****
X--- 13,24 ----
X  static char usermonster[MAXUM][MAXMNAME]; 
X  static char usermpoint=0;			/* the user monster pointer */
X  
X+ #ifdef GEMDOS
X+ #include <keycodes.h>
X+ #include <process.h>
X+ static char *shell;
X+ #endif
X+ 
X  /*
X  	lexical analyzer for larn
X   */
X***************
X*** 40,45 ****
X--- 46,52 ----
X  	lflush();  
X  	while (1) {
X  		c[BYTESIN]++;
X+ #ifndef GEMDOS
X  		if (ckpflag)
X  			/* check for periodic checkpointing */
X  			if ( c[BYTESIN] == 1 || (c[BYTESIN] % 400) == 0) {
X***************
X*** 49,54 ****
X--- 56,62 ----
X  					exit(0); 
X  				}
X  			}
X+ #endif
X  #ifdef BSD
X  		/* if keyboard input buffer is too big, flush some of it */
X  		do {
X***************
X*** 68,73 ****
X--- 76,94 ----
X  			sncbr();
X  			cl_dn(0,0);
X  			lflush();
X+ #ifdef GEMDOS
X+ 			if (shell = getenv("SHELL")) {
X+ 				ic = spawnlp(P_WAIT, shell, shell, (char *)0);
X+ 				if (ic < 0) {
X+ 					perror(shell);
X+ 					sleep(2);
X+ 				}
X+ 			}
X+ 			else {
X+ 				fprintf(stderr, "No SHELL in environment\n");
X+ 				sleep(2);
X+ 			}
X+ #else
X  			if ((ic=fork())==0) {
X  				execl("/bin/csh", "/bin/csh", (char *)0);	
X  				exit(1);
X***************
X*** 81,86 ****
X--- 102,108 ----
X  				fflush(stderr);
X  				sleep(2);
X  			}
X+ #endif /* GEMDOS */
X  			setscroll();
X  			scbr();
X  			return(lastok = 'L'-64);	/* redisplay screen */
X***************
X*** 99,104 ****
X--- 121,130 ----
X   */
X  flushall()
X  {
X+ #ifdef GEMDOS
X+ 	while (console_input_status(0))
X+ 		console_read_byte(0);
X+ #endif
X  #ifdef BSD
X  	char cc;
X  	int ic;
X***************
X*** 135,141 ****
X  		}
X  		else  if (hard > c[HARDGAME]) c[HARDGAME] = hard;
X  	}
X! 
X  	if (k=c[HARDGAME])
X  		for (j=0; j<=MAXMONST+8; j++) {
X  			i = ((6+k)*monster[j].hitpoints+1)/6;
X--- 161,170 ----
X  		}
X  		else  if (hard > c[HARDGAME]) c[HARDGAME] = hard;
X  	}
X! #ifdef GEMDOS
X! 	else
X! 		hashewon();	/* set outstanding taxes anyways */
X! #endif
X  	if (k=c[HARDGAME])
X  		for (j=0; j<=MAXMONST+8; j++) {
X  			i = ((6+k)*monster[j].hitpoints+1)/6;
X***************
X*** 165,174 ****
X--- 194,212 ----
X  		strcpy(logname,loginname); 
X  		return; /* user name if no character name */
X  	}
X+ #ifdef GEMDOS
X+ 	i = optsfile;	/* get around bug in GCC 1.34 */
X+ #else
X  	i = " ";
X+ #endif
X  	while (*i) {
X  		if ((i=(char *)lgetw()) == 0) break; /* check for EOF */
X+ #ifdef GEMDOS
X+ 		while ((*i==' ')||(*i=='\t')||(*i=='\r'))
X+ 			i++; /* eat leading whitespace*/
X+ #else
X  		while ((*i==' ') || (*i=='\t')) i++; /* eat leading whitespace*/
X+ #endif
X  		switch(*i) {
X  		case 'b':	
X  			if (strcmp(i,"bold-off") == 0)  
X***************
X*** 202,207 ****
X--- 240,258 ----
X  				}
X  			}
X  			else if (strcmp(i,"male") == 0)	sex=1;
X+ #ifdef GEMDOS
X+ 			else if (strcmp(i,"macro:") == 0) {
X+ 				if ((i = lgetw())==0) break;
X+ 				j = atoi(i);
X+ 				if (j<1 || j>10) {
X+ 					fprintf(stderr,"bad macro key:%d\n",j);
X+ 					sleep(2);
X+ 					break;
X+ 				}
X+ 				if ((i = lgetw())==0) break;
X+ 				console_set_key((F_1-1)+j,i,(char *)0,(char *)0);
X+ 			}
X+ #endif
X  			break;
X  
X  		case 'n':	
X*** orig/ularn_proto.h	Tue Jul 11 16:09:00 1989
X--- ularn_proto.h	Sat Jul  8 01:33:24 1989
X***************
X*** 0 ****
X--- 1,326 ----
X+ 
X+ /* bill.c */
X+ int letter1 ( void );
X+ int letter2 ( void );
X+ int letter3 ( void );
X+ int letter4 ( void );
X+ int letter5 ( void );
X+ int letter6 ( void );
X+ int mailbill ( void );
X+ 
X+ /* config.c */
X+ 
X+ /* create.c */
X+ int makeplayer ( void );
X+ int newcavelevel ( int x );
X+ int makemaze ( int k );
X+ int eat ( int xx , int yy );
X+ int cannedlevel ( int k );
X+ int treasureroom ( int lv );
X+ int troom ( int lv , int xsize , int ysize , int tx , int ty , int glyph );
X+ int makeobject ( int j );
X+ int fillmroom ( int n , int what , int arg );
X+ int froom ( int n , int itm , int arg );
X+ int fillroom ( int what , int arg );
X+ int fillmonst ( int what );
X+ int sethp ( int flg );
X+ int checkgen ( void );
X+ 
X+ /* data.c */
X+ 
X+ /* diag.c */
X+ int diag ( void );
X+ int diagdrawscreen ( void );
X+ int savegame ( char *fname );
X+ int restoregame ( char *fname );
X+ int greedy ( void );
X+ int fsorry ( void );
X+ int fcheat ( void );
X+ 
X+ /* display.c */
X+ int bottomline ( void );
X+ int bottomhp ( void );
X+ int bottomspell ( void );
X+ int bottomdo ( void );
X+ int bot_linex ( void );
X+ int bottomgold ( void );
X+ int bot_hpx ( void );
X+ int bot_spellx ( void );
X+ int botside ( void );
X+ int botsub ( int idx , char *str );
X+ int draws ( int xmin , int xmax , int ymin , int ymax );
X+ int drawscreen ( void );
X+ int showcell ( int x , int y );
X+ int show1cell ( int x , int y );
X+ int showplayer ( void );
X+ int moveplayer ( int dir );
X+ int seemagic ( int arg );
X+ int seepage ( void );
X+ 
X+ /* fortune.c */
X+ char *fortune ( char *file );
X+ 
X+ /* global.c */
X+ int raiselevel ( void );
X+ int loselevel ( void );
X+ int raiseexperience ( long x );
X+ int loseexperience ( long x );
X+ int losehp ( int x );
X+ int losemhp ( int x );
X+ int raisehp ( int x );
X+ int raisemhp ( int x );
X+ int raisespells ( int x );
X+ int raisemspells ( int x );
X+ int losespells ( int x );
X+ int losemspells ( int x );
X+ int makemonst ( int lev );
X+ int positionplayer ( void );
X+ int recalc ( void );
X+ int quit ( void );
X+ int more ( void );
X+ int take ( int itm , int arg );
X+ int drop_object ( int k );
X+ int enchantarmor ( void );
X+ int enchweapon ( void );
X+ int pocketfull ( void );
X+ int nearbymonst ( void );
X+ int stealsomething ( void );
X+ int emptyhanded ( void );
X+ int creategem ( void );
X+ int adjustcvalues ( int itm , int arg );
X+ int gettokstr ( char *str );
X+ int getpassword ( void );
X+ int getyn ( void );
X+ int packweight ( void );
X+ 
X+ /* help.c */
X+ int help ( void );
X+ int welcome ( void );
X+ int retcont ( void );
X+ int openhelp ( void );
X+ 
X+ /* io.c */
X+ int setupvt100 ( void );
X+ int clearvt100 ( void );
X+ int gettty ( void );
X+ int settty ( void );
X+ int setctty ( void );
X+ int setuptty ( void );
X+ int scbr ( void );
X+ int sncbr ( void );
X+ int getcharacter ( void );
X+ int newgame ( void );
X+ /* int lprintf ( char *, ...); */
X+ int lprint ( long x );
X+ int lwrite ( char *buf , int len );
X+ long lgetc ( void );
X+ long lrint ( void );
X+ int lrfill ( char *adr , int num );
X+ char *lgetw ( void );
X+ char *lgetl ( void );
X+ int lcreat ( char *str );
X+ int lopen ( char *str );
X+ int lappend ( char *str );
X+ int lrclose ( void );
X+ int lwclose ( void );
X+ int lprcat ( char *str );
X+ int cursor ( int x , int y );
X+ int cursors ( void );
X+ int init_term ( void );
X+ int cl_line ( int x , int y );
X+ int cl_up ( int x , int y );
X+ int cl_dn ( int x , int y );
X+ int standout ( char *str );
X+ int set_score_output ( void );
X+ int lflush ( void );
X+ int putcharacter ( int c );
X+ int flush_buf ( void );
X+ char *tmcapcnv ( char *sd , char *ss );
X+ int beep ( void );
X+ 
X+ /* main.c */
X+ int main ( int argc , char **argv );
X+ int showstr ( void );
X+ int qshowstr ( void );
X+ int t_setup ( int count );
X+ int t_endup ( int count );
X+ int showwear ( void );
X+ int showwield ( void );
X+ int showread ( void );
X+ int showeat ( void );
X+ int showquaff ( void );
X+ int show1 ( int idx , char *str2 []);
X+ int show3 ( int index );
X+ int randmonst ( void );
X+ int parse ( void );
X+ int parse2 ( void );
X+ int run ( int dir );
X+ int wield ( void );
X+ int ydhi ( int x );
X+ int ycwi ( int x );
X+ int wear ( void );
X+ int dropobj ( void );
X+ int readscr ( void );
X+ int eatcookie ( void );
X+ int quaff ( void );
X+ int qwhatitem ( void );
X+ int whatitem ( char *str );
X+ long readnum ( long mx );
X+ 
X+ /* monster.c */
X+ int createmonster ( int mon );
X+ int cgood ( int x , int y , int itm , int monst );
X+ int createitem ( int it , long arg );
X+ int cast ( void );
X+ int speldamage ( int x );
X+ int loseint ( void );
X+ int isconfuse ( void );
X+ int nospell ( int x , int monst );
X+ int fullhit ( int xx );
X+ int direct ( int spnum , int dam , char *str , int arg );
X+ int godirect ( int spnum , int dam , char *str , int delay , int cshow );
X+ int ifblind ( int x , int y );
X+ int tdirect ( int spnum );
X+ int makewall ( int spnum );
X+ int omnidirect ( int spnum , int dam , char *str );
X+ int dirsub ( int *x , int *y );
X+ int vxy ( int *x , int *y );
X+ int dirpoly ( int spnum );
X+ int hitmonster ( int x , int y );
X+ int hitm ( int x , int y , int amt );
X+ int hitplayer ( int x , int y );
X+ int dropsomething ( int monst );
X+ int dropgold ( int amount );
X+ int something ( int lev );
X+ int newobject ( int lev , int *i );
X+ int spattack ( int x , int xx , int yy );
X+ int checkloss ( int x );
X+ int annihilate ( void );
X+ int newsphere ( int x , int y , int dir , int life );
X+ int rmsphere ( int x , int y );
X+ int sphboom ( int x , int y );
X+ int genmonst ( void );
X+ 
X+ /* moreobj.c */
X+ int oaltar ( void );
X+ int ohear ( void );
X+ int othrone ( int arg );
X+ int odeadthrone ( void );
X+ int ochest ( void );
X+ int ofountain ( void );
X+ int fntchange ( int how );
X+ int fch ( int how , long *x );
X+ 
X+ /* movem.c */
X+ int movemonst ( void );
X+ int movemt ( int i , int j );
X+ int mmove ( int aa , int bb , int cc , int dd );
X+ int movsphere ( void );
X+ 
X+ /* nap.c */
X+ int nap ( int x );
X+ int napms ( int time );
X+ int nullf ( void );
X+ int napms ( int time );
X+ int napms ( int time );
X+ int napms ( int time );
X+ 
X+ /* object.c */
X+ int lookforobject ( void );
X+ int finditem ( int itm );
X+ int ostairs ( int dir );
X+ int oteleport ( int err );
X+ int opotion ( int pot );
X+ int quaffpotion ( int pot );
X+ int oscroll ( int typ );
X+ int adjtime ( long tim );
X+ int read_scroll ( int typ );
X+ int opit ( void );
X+ int obottomless ( void );
X+ int oelevator ( int dir );
X+ int ostatue ( void );
X+ int omirror ( void );
X+ int obook ( void );
X+ int readbook ( int arg );
X+ int ocookie ( void );
X+ int ogold ( int arg );
X+ int ohome ( void );
X+ int iopts ( void );
X+ int ignore ( void );
X+ 
X+ /* regen.c */
X+ int regen ( void );
X+ 
X+ /* savelev.c */
X+ int savelevel ( void );
X+ int getlevel ( void );
X+ 
X+ /* scores.c */
X+ int readboard ( void );
X+ int writeboard ( void );
X+ int makeboard ( void );
X+ int hashewon ( void );
X+ long paytaxes ( long x );
X+ int winshou ( void );
X+ int shou ( int x );
X+ int showscores ( void );
X+ int showallscores ( void );
X+ int sortboard ( void );
X+ int newscore ( long score , char *whoo , int whyded , int winner );
X+ int new1sub ( long score , int i , char *whoo , long taxes );
X+ int new2sub ( long score , int i , char *whoo , int whyded );
X+ int died ( int x );
X+ int diedsub ( int x );
X+ int showscore3 ( int index );
X+ int showscore1 ( int idx , char *str2 []);
X+ 
X+ /* signal.c */
X+ int s2choose ( void );
X+ int cntlc ( void );
X+ int sgam ( void );
X+ int tstop ( void );
X+ int sigill ( void );
X+ int sigtrap ( void );
X+ int sigiot ( void );
X+ int sigemt ( void );
X+ int sigfpe ( void );
X+ int sigbus ( void );
X+ int sigsegv ( void );
X+ int sigsys ( void );
X+ int sigpipe ( void );
X+ int sigterm ( void );
X+ int sigsetup ( void );
X+ int sigpanic ( int sig );
X+ 
X+ /* store.c */
X+ int dnd_2hed ( void );
X+ int dnd_hed ( void );
X+ int dndstore ( void );
X+ int handsfull ( void );
X+ int outofstock ( void );
X+ int nogold ( void );
X+ int dnditem ( int i );
X+ int sch_hed ( void );
X+ int oschool ( void );
X+ int obank ( void );
X+ int obank2 ( void );
X+ int banktitle ( char *str );
X+ int ointerest ( void );
X+ int obanksub ( void );
X+ int appraise ( int gemstone );
X+ int otradhead ( void );
X+ int otradepost ( void );
X+ int cnsitm ( void );
X+ int olrs ( void );
X+ int nomore ( void );
X+ int nocash ( void );
X+ int pad_hd ( void );
X+ int opad ( void );
X+ int snag ( int itm );
X+ int pick_char ( int foo );
X+ 
X+ /* tok.c */
X+ int yylex ( void );
X+ int flushall ( void );
X+ int sethard ( int hard );
X+ int readopts ( void );
SHAR_EOF
if test 34887 -ne "`wc -c patches`"
then
echo shar: error transmitting patches '(should have been 34887 characters)'
fi
echo shar: extracting readme.st
sed 's/^X//' << \SHAR_EOF > readme.st
XHere is Ultra-Larn, ported to the Atari ST running GEMDOS. See the
Xenclosed "readme" file for general notes about Ularn. This file describes
Xthe features specific to the ST version:
X
X(1) It's already compiled; don't worry about references to the Makefile,
Xetc. in readme. I'll post the source diffs w.r.t. the original Ularn posting
Xin comp.sources.games. Just stick ularn.ttp and all the associated files
X(uhelp, ufortune, umaps, uscore, ularn.opt) into the directory where
Xyou want them to live.
X
X(2) Checkpointed games are not implemented.
X
X(3) The environment variable LARNDIR is used to find the files
Xuhelp, ufortune, umaps, uscore, ularn.opt, and ularn.sav. If LARNDIR isn't
Xdefined, the current directory is used.
X
X(4) The user's name comes either from the options file (ularn.opt) or
Xfrom the environment variable USER; if neither of these are present,
Xthen the string "user" is used.
X
X(5) In the Unix version, only one score per user id is allowed in the
Xhigh score file. In the ST version, the user id (an integer) is taken
Xfrom the environment variable USERID, if it is present; otherwise, the user
Xid is generated from the character class, so that in the normal case your
Xhigh score file will contain one entry for each character class. The
Xuser id is also used for tax purposes, so if USERID is not set and
Xyou win as a klingon, then you will not have to pay taxes until
Xyou play again as a klingon.
X
X(6) When you win, mail gets put in the files mail600, mail601, etc. in
Xthe current directory. The mail is amusing, so you might want to read it;
Xunfortunately, it doesn't have any carriage returns, so it is best viewed
Xin an editor, not from the desktop.
X
X(7) I haven't tested this, but it should be possible to play Ularn over
Xthe modem. A Unix style termcap file may be provided in \etc\termcap
Xor in the current directory; in this case the environment variable TERM
Xis used to select the terminal type. If no sensible terminal type can
Xbe determined, the program will default to the Atari ST's built in VT52
Xemulation.
X
X(8) The 1-9 keys on the keypad may be used to move instead of hjkl etc.;
X8 means up, 2 means down, etc. The other keypad keys, HELP, and UNDO are
Xalso bound to useful keys as well, as follows:
X------------------------------------------------------------------------
XRegular:
XHELP ? (help)		UNDO Esc
X
X( r (read) 	) w (wield)	/ d (drop)	* q (quaff)
X7 y (nw)	8 k (n) 	9 u (ne)
X4 h (w) 	5 . (rest)	6 l (e)
X1 b (sw)	2 j (s) 	3 n (se)
X0 i (inventory)	. g (pack weight)		Enter Z (teleport)
X
XShifted:
XHELP v (version)	UNDO Esc
X
X( not used	) W (wear)	/ T (take off)	* e (eat)
X7 Y (run nw)	8 K (run n)	9 U (run ne)
X4 H (run w)	5 . (rest)	6 L (run e)
X1 B (run sw)	2 J (run s)	3 N (run se)
X0 D (show discoveries)	. P (give tax status)	Enter c (cast spell)
X----------------------------------------------------------------------
X
X(9) A new keyword, macro, is allowed in the options file ularn.opt.
XThe syntax is 'macro: n string' where n is an integer from 1-10 and
Xstring is the string which is to be generated when function key n is
Xpressed. If string contains any spaces or control characters then it
Xmust be enclosed in double quotes. E.g.:
Xmacro: 1 cssp		# cast the sonic spear spell
Xmacro: 2 "? "		# get to the second page of the help screen
X
X(10) Ularn will pause and ask you to "Hit any key to continue" if
Xyou run it from the desktop, or from any CLI that does not support
Xthe MWC extended argument passing convention. If you're using Gulam
Xand want to avoid this, you can set the environment style to MWC
Xby typing "set env_style mw" before running Ularn (or putting the
Xsame line in your gulam.g file).
X
XGood luck, and happy Ularning. You can report bugs, etc. to me
Xat the address below. If you do so, **BE SURE TO PUT MY NAME IN THE
XSUBJECT: FIELD OF YOUR MESSAGE**. I share the mailbox with the entire
Xmath department!
X--
XEric R. Smith                     email:
XDept. of Mathematics            7103_300@uwovax.uwo.ca
XUniversity of Western Ontario   7103_300@uwovax.bitnet
XLondon, Ont. Canada N6A 5B7     (a shared mailbox: put my name on
Xph: (519) 661-3638              the message, please!)
X
SHAR_EOF
if test 4132 -ne "`wc -c readme.st`"
then
echo shar: error transmitting readme.st '(should have been 4132 characters)'
fi
echo shar: extracting makefile
sed 's/^X//' << \SHAR_EOF > makefile
X#	your favorite compiler
XCC	=	d:\gnu\bin\gcc.ttp
X
X#  	SYSV or BSD
X#UNIX	=	SYSV
X#UNIX	=	BSD
XUNIX	=	GEMDOS
X
X#  	location of data files (not needed for GEMDOS)
X#HOME	= 	.
X
X#	final location of binary (for 'make install')
XBINDIR	=	.
X
X#	user id of wizard	(wizard password is defined in config.c)
XWIZID	=	1
X
X#  	name of program 
XGAME	= 	Ularn.ttp
X
X# 	termlib	options
XTERMLIB	= 	-lcurses
X
X#  	program options 
XOPTIONS	= 	-DWIZID=$(WIZID) -D$(UNIX)
X
X# 	compile flags 
XCFLAGS	=       -O $(OPTIONS) 
X#CFLAGS	=       -M3e -g $(OPTIONS) -DHOME=\"$(HOME)/\" 
X
X#	link flags
XLDFLAGS=	-s
X#LDFLAGS	=
X
X#	the object files
XOBJ	= bill.o config.o create.o data.o diag.o display.o fortune.o\
X	global.o help.o io.o main.o monster.o moreobj.o movem.o object.o\
X	regen.o savelev.o scores.o signal.o store.o tok.o nap.o
X
X#	the source files 
XSRC	= 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
XHDR	= header.h
X
XUTIL = to_ansi.ttp
XUTIL_OBJ = to_ansi.o
XUTIL_SRC = to_ansi.c
X
X##########################################################################
X
Xlove:	$(GAME)
X
X$(GAME): $(OBJ) 
X	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $(GAME) $(TERMLIB)
X
X.c.o:
X	$(CC) -c $(CFLAGS) $<
X
X$(OBJ): header.h
X
X$(UTIL): $(UTIL_OBJ)
X	$(CC) $(CFLAGS) -o $(UTIL) $(UTIL_OBJ)
X
XUhelp: $(UTIL) Uhelp.no_control
X	$(UTIL) <Uhelp.no_control >Uhelp
X
Xtags:	tag
Xtag:
X	rm -f Tags
X	ctags -x $(SRC) $(HDR) > Tags
X	ctags $(SRC) $(HDR)
X
Xlint: 	$(SRC)
X	rm -f Lint.out
X	lint $(SRC) $(TERMLIB) > Lint.out
X
Xinstall: $(GAME) Umaps Ufortune Uhelp
X	touch Uscore
X	chmod 644 Umaps Ufortune Uhelp
X	chmod 666 Uscore
X	-mkdir $(HOME)
X	cp Uscore Umaps Ufortune Uhelp $(HOME)
X	chmod 711 $(HOME)
X	chmod 711 $(GAME)
X	-mv $(GAME) $(BINDIR)
X
Xclean:
X	rm -f core *.o $(GAME)
X#
X##########################################################################
X#      shar the source
X##########################################################################
X#
XSHAR	=	/u/philc/bin/shar -a
XSHAR1 	=	bill.c config.c create.c diag.c fortune.c help.c io.c tok.c
XSHAR2	=	data.c display.c regen.c savelev.c nap.c
XSHAR3	=	global.c header.h moreobj.c signal.c Makefile
XSHAR4	=	monster.c
XSHAR5	=	main.c movem.c
XSHAR6	=	object.c MANIFEST README
XSHAR7	=	scores.c store.c
XSHAR8	=	Ufortune Uhelp Umaps
Xshar:
X	$(SHAR) -m 1 -n 8 $(SHAR1) > Ushar.1
X	$(SHAR) -m 2 -n 8 $(SHAR2) > Ushar.2
X	$(SHAR) -m 3 -n 8 $(SHAR3) > Ushar.3
X	$(SHAR) -m 4 -n 8 $(SHAR4) > Ushar.4
X	$(SHAR) -m 5 -n 8 $(SHAR5) > Ushar.5
X	$(SHAR) -m 6 -n 8 $(SHAR6) > Ushar.6
X	$(SHAR) -m 7 -n 8 $(SHAR7) > Ushar.7
X	@cp $(HOME)/Ufortune .
X	@cp $(HOME)/Uhelp .
X	@cp $(HOME)/Umaps .
X	$(SHAR) -m 8 -n 8 $(SHAR8) > Ushar.8
SHAR_EOF
if test 2721 -ne "`wc -c makefile`"
then
echo shar: error transmitting makefile '(should have been 2721 characters)'
fi
echo shar: extracting xconsole.c
sed 's/^X//' << \SHAR_EOF > xconsole.c
X/* Replacement console read/write routines that allow for key
X   remappings */
X/* Written by Eric R. Smith for the Atari ST computer, and placed
X   in the public domain */
X
X#include <osbind.h>
X#include <support.h>
X#include <keycodes.h>
X#include <stdlib.h>
X#include <string.h>
X
X#define S_SHIFT 0x03
X#define S_CNTRL	0x04
X#define S_ALT	0x08
X
Xstatic char *__strdup(char **, char *);
X#define STRDUP(x, y) __strdup(&x, y)
X
X/* arrays to hold keyboard strings */
X
Xstatic char *kb_unshft[N_KEYCODES], *kb_shft[N_KEYCODES], *kb_alt[N_KEYCODES];
Xstatic char *_str = NULL;
X
Xvoid console_set_key(keycode, regular, shifted, alted)
Xint keycode;
Xchar *regular, *shifted, *alted;
X{
X	if (keycode < 1 || keycode >= N_KEYCODES)
X		return;
X
X	if (regular) {
X		if (!*regular) regular = 0;
X		STRDUP(kb_unshft[keycode], regular);
X	}
X	if (shifted) {
X		if (!*shifted) shifted = 0;
X/* shifted function keys are a bit screwy */
X		if (keycode >= F_1 && keycode <= F_10) {
X			STRDUP(kb_shft[keycode - F_1 + 0x54],shifted);
X		}
X		else {
X			STRDUP(kb_shft[keycode],shifted);
X		}
X	}
X	if (alted) {
X		if (!*alted) alted = 0;
X		STRDUP(kb_alt[keycode],alted);
X	}
X}
X
X/* NOTE: all input is assumed to come from the standard input */
X
Xunsigned int console_read_byte(handle)
Xint handle;
X{
X	long r;
X	unsigned scan, key, shft;
X
X	if (_str) {
X		if (*_str)
X			return *(unsigned char *)_str++;
X		else
X			_str = 0;
X	}
X	r = Crawcin();
X	scan = (r & 0x00ff0000) >> 16;
X	key = r & 0x00ff;
X	if (scan > 0 && scan < N_KEYCODES) {
X		shft = Kbshift(-1);
X		if (shft & S_ALT)
X			_str = kb_alt[scan];
X		else if (shft & S_SHIFT)
X			_str = kb_shft[scan];
X		else if (!(shft & S_CNTRL))
X			_str = kb_unshft[scan];
X		if (_str) return *(unsigned char *)_str++;
X	}
X	return key;
X}
X
Xint console_input_status(handle)
Xint handle;
X{
X	return (_str && *_str) ? 1 : Cconis();
X}
X
X/* The write routine, on the other hand, is completely general */
X
Xvoid
Xconsole_write_byte(handle, n)
Xint handle;
Xint n;
X{
X  char c = (char) n;
X  Fwrite(handle, 1L, &c);
X}
X
X/* routine to duplicate a string for the console input routines */
X
Xstatic
Xchar *__strdup(char **x, char *y)
X{
X	char *s = *x;
X
X	if (s) free(s);
X	if (y) {
X		s = malloc(strlen(y)+1);
X		strcpy(s, y);
X	}
X	else
X		s = 0;
X	*x = s;
X}
SHAR_EOF
if test 2201 -ne "`wc -c xconsole.c`"
then
echo shar: error transmitting xconsole.c '(should have been 2201 characters)'
fi
echo shar: extracting ularn.opt
sed 's/^X//' << \SHAR_EOF > ularn.opt
Xno-introduction
Xname: "Kharg the Merciless"
Xsavefile: eric.sav
Xmacro: 1 cvpr
Xmacro: 2 clit
Xmacro: 3 cssp
Xmacro: 4 cmfi
SHAR_EOF
if test 119 -ne "`wc -c ularn.opt`"
then
echo shar: error transmitting ularn.opt '(should have been 119 characters)'
fi
#	End of shell archive
exit 0