[comp.sources.amiga] v02i069: nethack - D&D-like game

page@swan.ulowell.edu (Bob Page) (12/02/88)

Submitted-by: u211344@hnykun11.bitnet (Olaf 'Rhialto' Seibert)
Posting-number: Volume 2, Issue 69
Archive-name: fun/nethack.a2

#	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:
#	NetHack.cnf
#	fcntl.h
#	hack.lnk
#	include.c
#	makefile
#	news
#	signal.h
#	stdio.h
#	test.c
# This archive created: Thu Dec  1 17:50:08 1988
cat << \SHAR_EOF > NetHack.cnf
# A '#' at the beginning of a line means the rest of the line is a comment.

# This configuration file is set up for three cases, a person with a hard
# disk as DH0:, a person with a lot of RAM for a ram disk, and several people
# with two floppy disks.  The default configuration is the second one.
# To change configuration, comment out the unwanted configurations, and
# remove the comment from the configuration you want.

# I use OPTIONS=rest_on_space,time,packorder:%/=?!+)[*0,endgame:10 t / 2
a,nopickup

OPTIONS=dogname:Bobbie,rest_on_space,time,packorder:%/=?!+)[*0,endgame:10 t / 2
a,nopickup

# The Path. Used to find NetHack.cnf, record, help, hh, and data.
# HACKDIR is always tried first. Initially Ram:;df0:;NetHack:
#PATH=NetHack:

# A hard disk configuration.

#HACKDIR=DH0:games/nethack
#SAVE=DH0:games/nethack/bones;n
##RAMDISK=Ram:
#LEVELS=DH0:games/nethack/bones

# A floppy configuration.

HACKDIR=NetHack:
LEVELS=NetHack:levels
SAVE=NetHack:save
RAMDISK=Ram:

# A ram disk configuration.
# Don't forget to copy record, hh, help, and data to HACKDIR, or to
# include their directory in PATH.

#HACKDIR=Ram:
#PATH=NetHack:
#LEVELS=Ram:
#SAVE=Ram:

# The 18 GRAPHICS characters (0-17) are:
# stone, vertical wall, horizontal wall, top left corner, top right corner
# bottom left corner, bottom right corner, door, floor, corridor, up stairs,
# down stairs, trap, pool, fountain, throne, web, kitchen sink
# You need not specify all of them.
# Note that the hack.font has special graphics characters from 192 on.
GRAPHICS = 032 192 193 194 195 196 197 198 046 035 060 062 094 123 125 092 034
035
#GRAPHICS= 032 124 045 174 174 224 167 043 046 035 060 062 094 123 125 092 034
035
SHAR_EOF
cat << \SHAR_EOF > fcntl.h
/* Copyright (C) 1986,1987 by Manx Software Systems, Inc. */

#define O_RDONLY        0
#define O_WRONLY        1
#define O_RDWR          2
#define O_CREAT         0x0100
#define O_TRUNC         0x0200
#define O_EXCL          0x0400
#define O_APPEND        0x0800

#define O_CONRAW        0x4000
#define O_STDIO         0x8000

extern struct _dev {
        long    fd;
        short   mode;
} *_devtab;

extern short _numdev;

#define O_BINARY        0   /* For MSDOS */
#define setmode(f,m)
SHAR_EOF
cat << \SHAR_EOF > hack.lnk
+SS -w
-o NetHack
amigaTermcap.o amigaWindow.o amigaTTY.o
amigaDos.o amigaUnix.o
alloc.o bones.o dog.o dothrow.o pcmain.o
mkmaze.o mkobj.o mkshop.o
monst.o o_init.o polyself.o pray.o pri.o
rip.o rnd.o rumors.o
search.o sit.o steal.o timeout.o
topl.o track.o vault.o
version.o wield.o wizard.o worm.o worn.o
apply.o cmd.o decl.o do.o do_name.o do_wear.o
dogmove.o eat.o end.o engrave.o fight.o fountain.o
hack.o invent.o lev.o makemon.o
mhitu.o mklev.o mon.o monmove.o objnam.o
options.o pager.o potion.o prisym.o read.o
shk.o shknam.o spell.o
topten.o trap.o u_init.o write.o save.o zap.o
-lcl
SHAR_EOF
cat << \SHAR_EOF > include.c
#include "stdio.h"
#include "hack.h"

SHAR_EOF
cat << \SHAR_EOF > makefile
#    Hack Makefile.
#    SCCS Id: @(#)Makefile.Amiga    2.3    88/07/10

#   Options: (case insignificant)
#   +q  string literals to data segment
#   +l  long (32 bit) integers
#   +c  large code (i.e. not pc-relative)
#   +d  large data (i.e. not relative to A4)
#   +i  include precompiled symbol table
#   library: cl (compiled with +cd)
#   using the ARP setdate command as a touch-replacement.

1=   een:
2=   twee:
E=   een\:
T=   twee\:
O =
C =  cc +cI$Osyms -DAMIGA -o# $Oxxx.o $1xxx.c

.PRECIOUS:  $1onames.h $Orumors $Odata $1date.h $1trap.h

MAIN = $1pcmain.c
TTY  = $1amiga/amigaTTY.c
UNIX = $1amiga/amigaUnix.c
TERM = $1amiga/amigaTermcap.c
DOS  = $1amiga/amigaDos.c

# make NetHack
GAME     = nethack

AUX = help hh nethack.6 nethack.sh
VARAUX = data rumors

HOBJ = $OamigaTermcap.o $OamigaWindow.o $OamigaTTY.o \
    $OamigaDos.o $OamigaUnix.o \
    $Oalloc.o $Obones.o $Odog.o $Odothrow.o $Opcmain.o \
    $Omkmaze.o $Omkobj.o $Omkshop.o \
    $Omonst.o $Oo_init.o $Opolyself.o $Opray.o $Opri.o \
    $Orip.o $Ornd.o $Orumors.o \
    $Osearch.o $Osit.o $Osteal.o $Otimeout.o \
    $Otopl.o $Otrack.o $Ovault.o \
    $Oversion.o $Owield.o $Owizard.o $Oworm.o $Oworn.o \
    $Oapply.o $Ocmd.o $Odecl.o $Odo.o $Odo_name.o $Odo_wear.o \
    $Odogmove.o $Oeat.o $Oend.o $Oengrave.o $Ofight.o $Ofountain.o \
    $Ohack.o $Oinvent.o $Olev.o $Omakemon.o \
    $Omhitu.o $Omklev.o $Omon.o $Omonmove.o $Oobjnam.o \
    $Ooptions.o $Opager.o $Opotion.o $Oprisym.o $Oread.o \
    $Osave.o $Oshk.o $Oshknam.o $Ospell.o \
    $Otopten.o $Otrap.o $Ou_init.o $Owrite.o $Ozap.o

$(GAME): $(HOBJ)
        cd $O
        ln -f hack.lnk

$Osyms: $1hack.h $1objects.h $1amiga/stdio.h makedefs
        cc +cH$Osyms -DAMIGA -ao $Oxxx@ $1amiga/include.c
        delete $Oxxx@
        l syms

$Omakedefs: $Omakedefs.o $Oalloc.o
        cd $O
        ln -o makedefs alloc.o makedefs.o -lc

$Omakedefs.o: $1makedefs.c $1config.h
        cc +c -DAMIGA -o $Omakedefs.o $1makedefs.c

RUMORFILES= $1rumors.base $1rumors.kaa $1rumors.mrx

$Orumors: $1config.h $(RUMORFILES) $Omakedefs
        copy $1rumors.base rumors.base
        copy $1rumors.kaa rumors.kaa
        copy $1rumors.mrx rumors.mrx
        makedefs -r
        copy rumors $1rumors

$Odata: $1config.h $1data.base $Omakedefs
        copy $1data.base data.base
        makedefs -d
        copy data $1data

$Edate.h: $Omakedefs $(MAIN) $(TTY) $(UNIX) $(TERM) $(DOS) $1amiga/amigaWindow.c
        copy $1date.h date.h
        makedefs -D
        copy date.h $1date.h

$Etrap.h: $1config.h $Omakedefs
        copy $1trap.h trap.h
        makedefs -t
        copy trap.h $1trap.h

$Eonames.h: $Omakedefs $1objects.h
        copy $1objects.h objects.h
        makedefs -o
        copy onames.h $1onames.h

$OamigaUnix.o: $1amiga/amigaUnix.c $1hack.h $Osyms
        $C $OamigaUnix.o $1amiga/amigaUnix.c

$OamigaTermcap.o: $1amiga/amigaTermcap.c $1hack.h $Osyms
        $C $OamigaTermcap.o $1amiga/amigaTermcap.c

$OamigaWindow.o: $1amiga/amigaWindow.c $1amiga/amigaMenu.c $Osyms
        $C $OamigaWindow.o $1amiga/amigaWindow.c +m

$OamigaTTY.o: $1amiga/amigaTTY.c $1hack.h $1func_tab.h $Osyms
        $C $OamigaTTY.o $1amiga/amigaTTY.c

$OamigaDos.o: $1amiga/amigaDos.c $1hack.h $Osyms
        $C $OamigaDos.o $1amiga/amigaDos.c

clean:
        delete *.o

spotless: clean
        delete $(GAME) makedefs
        delete $(VARAUX) main.c tty.c unix.c

depend: # Should put one source disk in df0: and other in df1:
        mkd -Idf0: -Idf1: -m df0:*.(c|h) df1:*.(c|h)

# You may delete this line

$Eobjects.h: $1config.h $1objclass.h
    setdate $1objects.h
$Omakemon.o: $2makemon.c $1hack.h $Osyms
    $C $Omakemon.o $2makemon.c
$Ohack.o: $2hack.c $1hack.h $Osyms
    $C $Ohack.o $2hack.c
$Omon.o: $2mon.c $1hack.h $1mfndpos.h $Osyms
    $C $Omon.o $2mon.c
$Ounixtty.o: $2unixtty.c $1extern.h $1hack.h $1func_tab.h $Osyms
    $C $Ounixtty.o $2unixtty.c
$Ounixunix.o: $2unixunix.c $1hack.h $1mkroom.h $Osyms
    $C $Ounixunix.o $2unixunix.c
$Oinvent.o: $2invent.c $1hack.h $1wseg.h $Osyms
    $C $Oinvent.o $2invent.c
$Ozap.o: $2zap.c $1hack.h $Osyms
    $C $Ozap.o $2zap.c
$Ou_init.o: $2u_init.c $1hack.h $Osyms
    $C $Ou_init.o $2u_init.c
$Ofountain.o: $2fountain.c $1hack.h $1mkroom.h $Osyms
    $C $Ofountain.o $2fountain.c
$Omonmove.o: $2monmove.c $1hack.h $1mfndpos.h $Osyms
    $C $Omonmove.o $2monmove.c
$Odo.o: $2do.c $1hack.h $Osyms
    $C $Odo.o $2do.c
$Ofight.o: $2fight.c $1hack.h $Osyms
    $C $Ofight.o $2fight.c
$Ooptions.o: $2options.c $1config.h $1hack.h $Osyms
    $C $Ooptions.o $2options.c
$Oread.o: $2read.c $1hack.h $Osyms
    $C $Oread.o $2read.c
$Odecl.o: $2decl.c $1hack.h $1mkroom.h $Osyms
    $C $Odecl.o $2decl.c
$Odo_wear.o: $2do_wear.c $1hack.h $Osyms
    $C $Odo_wear.o $2do_wear.c
$Opotion.o: $2potion.c $1hack.h $Osyms
    $C $Opotion.o $2potion.c
$Odogmove.o: $2dogmove.c $1hack.h $1mfndpos.h $1mkroom.h $1edog.h $Osyms
    $C $Odogmove.o $2dogmove.c
$Oshknam.o: $2shknam.c $1hack.h $1mkroom.h $1eshk.h $Osyms
    $C $Oshknam.o $2shknam.c
$Otopten.o: $2topten.c $1hack.h $Osyms
    $C $Otopten.o $2topten.c -E200
$Oeat.o: $2eat.c $1hack.h $Osyms
    $C $Oeat.o $2eat.c
$Oobjnam.o: $2objnam.c $1hack.h $Osyms
    $C $Oobjnam.o $2objnam.c
$Opager.o: $2pager.c $1hack.h $Osyms
    $C $Opager.o $2pager.c
$Omklev.o: $2mklev.c $1hack.h $1mkroom.h $Osyms
    $C $Omklev.o $2mklev.c -E300
$Odo_name.o: $2do_name.c $1hack.h $Osyms
    $C $Odo_name.o $2do_name.c
$Oapply.o: $2apply.c $1hack.h $1edog.h $1mkroom.h $Osyms
    $C $Oapply.o $2apply.c
$Omhitu.o: $2mhitu.c $1hack.h $Osyms
    $C $Omhitu.o $2mhitu.c
$Ospell.o: $2spell.c $1hack.h $Osyms
    $C $Ospell.o $2spell.c
$Oprisym.o: $2prisym.c $1hack.h $1wseg.h $Osyms
    $C $Oprisym.o $2prisym.c
$Olev.o: $2lev.c $1hack.h $1mkroom.h $1wseg.h $Osyms
    $C $Olev.o $2lev.c
$Owrite.o: $2write.c $1hack.h $Osyms
    $C $Owrite.o $2write.c
$Oshk.o: $2shk.c $1hack.h $1mfndpos.h $1mkroom.h $1eshk.h $Osyms
    $C $Oshk.o $2shk.c
$Oengrave.o: $2engrave.c $1hack.h $Osyms
    $C $Oengrave.o $2engrave.c
$Oend.o: $2end.c $1hack.h $Osyms
    $C $Oend.o $2end.c
$Ocmd.o: $2cmd.c $1hack.h $1func_tab.h $Osyms
    $C $Ocmd.o $2cmd.c
$Osave.o: $2save.c $1hack.h $Osyms
    $C $Osave.o $2save.c
$Otrap.o: $2trap.c $1hack.h $1edog.h $1mkroom.h $Osyms
    $C $Otrap.o $2trap.c
#Other disk starts here
$Oworm.o: $1worm.c $1hack.h $1wseg.h $Osyms
    $C $Oworm.o $1worm.c
$Omkobj.o: $1mkobj.c $1hack.h $Osyms
    $C $Omkobj.o $1mkobj.c
$Ehack.h: $1extern.h $1objclass.h $1monst.h $1gold.h $1trap.h $1flag.h $1rm.h
    setdate $1hack.h
$Eyou.h: $1config.h $1onames.h $1permonst.h
    setdate $1you.h
$Opcmain.o: $1pcmain.c $1hack.h $Osyms
    $C $Opcmain.o $1pcmain.c
$Opolyself.o: $1polyself.c $1hack.h $Osyms
    $C $Opolyself.o $1polyself.c
$Orumors.o: $1rumors.c $1hack.h $Osyms
    $C $Orumors.o $1rumors.c
$Otrack.o: $1track.c $1hack.h $Osyms
    $C $Otrack.o $1track.c
$Otopl.o: $1topl.c $1hack.h $Osyms
    $C $Otopl.o $1topl.c
$Oo_init.o: $1o_init.c $1config.h $1objects.h $1onames.h $Osyms
    $C $Oo_init.o $1o_init.c -Z6000 +Q
$Owizard.o: $1wizard.c $1hack.h $Osyms
    $C $Owizard.o $1wizard.c
$Ornd.o: $1rnd.c $1config.h $Osyms
    $C $Ornd.o $1rnd.c
$Omkmaze.o: $1mkmaze.c $1hack.h $1mkroom.h $Osyms
    $C $Omkmaze.o $1mkmaze.c
$Otimeout.o: $1timeout.c $1hack.h $Osyms
    $C $Otimeout.o $1timeout.c
$Oworn.o: $1worn.c $1hack.h $Osyms
    $C $Oworn.o $1worn.c
$Ounixmain.o: $1unixmain.c $1hack.h $Osyms
    $C $Ounixmain.o $1unixmain.c
$Ovault.o: $1vault.c $1hack.h $1mkroom.h $Osyms
    $C $Ovault.o $1vault.c
$Opctty.o: $1pctty.c $1hack.h $1func_tab.h $Osyms
    $C $Opctty.o $1pctty.c
$Opcunix.o: $1pcunix.c $1hack.h $Osyms
    $C $Opcunix.o $1pcunix.c
$Omonst.o: $1monst.c $1hack.h $1eshk.h $Osyms
    $C $Omonst.o $1monst.c
$Osit.o: $1sit.c $1hack.h $Osyms
    $C $Osit.o $1sit.c
$Omkshop.o: $1mkshop.c $1hack.h $1mkroom.h $Osyms
    $C $Omkshop.o $1mkshop.c
$Odog.o: $1dog.c $1hack.h $1edog.h $1mkroom.h $Osyms
    $C $Odog.o $1dog.c
$Osteal.o: $1steal.c $1hack.h $Osyms
    $C $Osteal.o $1steal.c
$Orip.o: $1rip.c $1hack.h $Osyms
    $C $Orip.o $1rip.c +Q
$Oalloc.o: $1alloc.c
    cc +c -DAMIGA -DDGK -o $Oalloc.o $1alloc.c
$Obones.o: $1bones.c $1hack.h $1amiga/fcntl.h $Osyms
    $C $Obones.o $1bones.c
$Osearch.o: $1search.c $1hack.h $Osyms
    $C $Osearch.o $1search.c
$Owield.o: $1wield.c $1hack.h $Osyms
    $C $Owield.o $1wield.c
$Oversion.o: $1version.c $1hack.h $1date.h $Osyms
    $C $Oversion.o $1version.c
$Eextern.h: $1config.h $1spell.h $1obj.h $1you.h
    setdate $1extern.h
$Opray.o: $1pray.c $1hack.h $Osyms
    $C $Opray.o $1pray.c
$Opri.o: $1pri.c $1hack.h $Osyms
    $C $Opri.o $1pri.c
$Odothrow.o: $1dothrow.c $1hack.h $Osyms
    $C $Odothrow.o $1dothrow.c
SHAR_EOF
cat << \SHAR_EOF > news


               ===--->   Amiga NetHack News Flash   <---===


    This is Amiga NetHack 2.3e, based on the sources as posted on
comp.sources.games, and their updates, by Mike Stephenson. It has been
ported to your Amiga by Olaf Seibert (KosmoSoft), Vossendijk 149,
6534 TN Nijmegen, the Netherlands.

    ********************************************************************
    *   This program or any associated or related files may not be     *
    *   used for profit in any way. They may only be redistributed     *
    *   in their original form, and charges may be made only to cover  *
    *   material and transportation costs.                             *
    *   Also, this notice must remain intact at all times.             *
    ********************************************************************

    I added the PATH in NetHack.cnf, which is used on files like record,
help, hh and data. The HACKDIR directory is always tried first to locate
one of those files, and if not found, the PATH is tried. Note that you
receive a warning message when 'record' could not be found in the HACKDIR.
This is because 'record' will be written to, while the other files are used
to read only. This warning won't harm as long as the record file can be
found along the PATH. Initially the PATH is Ram:;df0:;NetHack:

    I also changed the format of level, bones and save files, so that they
would be smaller. Level and bones files can get about half the size they
otherwise would have been (about 4K minimum), but save files are less
affected.

    NetHack uses the font Hack.font. You need not re-assign FONTS: to the
NetHack disk, but it must be reachable on NetHack:, ie your game disk must
be called NetHack, or the directory you move it into must be ASSIGNed
NetHack:. Otherwise, there are no restrictions on assigns :-) Note that in
order to load the font, the diskfont.library will be opened so you need to
keep your Workbench disk around. If you have enough memory, however, the
font may remain in memory between successive games, and the requester for
the Workbench disk may safely be cancelled after the first game. The only
bad thing that could happen is that you get accented letters instead of
graphics characters.

    Speaking of graphic characters, I have put in a few starting from $C0.
They are most useful as walls and corners. There are two sets of these:
single and double line walls. I also duplicated the non-letter characters
with ASCII codes with the high bit set. You may wish to use, for example,
the alt + sign instead of the normal + for doors, since + signs are
highlighted because they could be spell books. (all objects get an extra
accent by a black background (if you have standard Workbench colors), and
monsters also have an orange foreground).

    Sounds complicated? Well, it depends. Just have a good game.

SHAR_EOF
cat << \SHAR_EOF > signal.h
#define SIG_IGN     1
#define SIG_DFL     0
#define signal(x,y) SIG_IGN

SHAR_EOF
cat << \SHAR_EOF > stdio.h
/* Copyright (C) 1982, 1984, 1986 by Manx Software Systems */
#ifndef _STDIO_H
#define _STDIO_H

#define fgetc getc
#define fputc putc
#ifndef NULL
#define NULL 0L
#endif
#define EOF -1


#define BUFSIZ 1024
#define MAXSTREAM       20

#define _BUSY   0x01
#define _ALLBUF 0x02
#define _DIRTY  0x04
#define _EOF    0x08
#define _IOERR  0x10
#define _TEMP   0x20    /* temporary file (delete on close) */

typedef struct {
        char *_bp;              /* current position in buffer */
        char *_bend;            /* last character in buffer + 1 */
        char *_buff;            /* address of buffer */
        char _flags;            /* open mode, etc. */
        char _unit;             /* token returned by open */
        char _bytbuf;           /* single byte buffer for unbuffer streams */
        short _buflen;          /* length of buffer */
        char *_tmpname;         /* name of file for temporaries */
} FILE;

extern FILE Cbuffs[];
FILE *fopen();
long ftell();

#define stdin       @#$%(&Cbuffs[0])    /* Syntax error ! */
#define stdout      @#$%(&Cbuffs[1])
#define stderr      (&Cbuffs[2])
#define getchar()   WindowGetchar()
#define putchar(c)  WindowPutchar(c)
#define puts(s)     WindowPuts(s)
#define stdout_puts(s) WindowFPuts(s)
#define printf      WindowPrintf
/*#define feof(fp) (((fp)->_flags&_EOF)!=0)*/
#define ferror(fp) (((fp)->_flags&_IOERR)!=0)
/*#define clearerr(fp) ((fp)->_flags &= ~(_IOERR|_EOF))*/
/*#define fileno(fp) ((fp)->_unit)*/
#define fflush(fp) WindowFlush()
#define rewind(fp) fseek(fp, 0L, 0)

#define P_tmpdir        ""
#define L_tmpnam        40

#endif

SHAR_EOF
cat << \SHAR_EOF > test.c
#include "stdio.h"
#include "hack.h"

struct flag flags;
struct you u;

curs_on_u(){}
int multi;
remember_topl(){}
int in_doagain;
savech(){}
popch(){return 0;}
pline(){}
char *save_cm="";
clrlin(){}
parseoptions(){}
xchar curx, cury;
long *alloc(n){extern void *malloc();return malloc(n);}
char extcmdlist;    /* NOT VERY USABLE */
putstr(s)char*s;{WindowFPuts(s);}
putsym(c)int c;{WindowPutchar(c);}
char bones[1], *alllevels, permbones[1], *allbones, lock1[1], hackdir[1];
char *configfile, plname[1], plnamesuffix, lock[1];
int saveprompt, ramdisk;
char SAVEF[1];
char levels[1];
struct symbols defsyms, showsyms;

extern char orgdir[];

main()
{
    int c;
    int i;

    startup();
    gettty();
    printf("Dit is %s", "een test\n");

    getret();
    putchar('\n');
    chdir("df1:");
    printf("Freediskspace: %ld\n", freediskspace(""));
    for (i = 1023; i >= 0; i--)
        putchar('x');

    getret();
    putchar('\n');
    for (i = 1023; i >= 0; i--)
        putchar('x'), fflush(stdout);

    while (c = getchar()) {
        putchar(c);
        putchar(c | 128);
        fflush(stdout);
        if (c == 'q' || c == 'Q')
            break;
    }
    chdir(orgdir);
    settty();
    CleanUp();
}

SHAR_EOF
#	End of shell archive
exit 0
-- 
Bob Page, U of Lowell CS Dept.  page@swan.ulowell.edu  ulowell!page
Have five nice days.