First post, by onre
- Rank
- Newbie
Greetings all.
I couldn't find old Nethack binaries anywhere so I decided to roll my own. Here's how to produce a working binary for Nethack 2.3e as the process isn't completely trivial. I couldn't find a similar walkthru anywhere so I decided to write it here.
1. Install MS C 4.0, available at least on WinWorldPC
- as I did not know the preferred installation layout, I just copied contents of disk 1 and 2 into one dir (BIN) and 3, 4, and 5 into another (03)
- one could of course make a neat installation where binaries are in BIN, includes in INCLUDE and libraries in LIB, but I was lazy
- after this, edit autoexec.bat and include following:
PATH=C:\BIN;%PATH% (or wherever you put the binaries)
set LIB=C:\LIB (or wherever you put the libraries)
set INCLUDE=C:\INCLUDE (or wherever you put the includes)
- reboot to have the vars set
2. Install NDMAKE 4.5 somewhere in path
- this includes MAKE45.EXE and MAKE45L.EXE, whose difference is the memory model used, which affects the complexity of makefiles they can process
- I just renamed MAKE45L.EXE to NDMAKE.EXE
3. Unpack Nethack 2.3e source somewhere
4. Use an uudecode tool (I did this on a separate Unix machine) to extract termcap.uu to get termcap.arc
5. Unpack termcap.arc someplace else
6. Use this makefile to compile the termcap lib
# SCCS Id: @(#)Makefile.lib 3.0 90/02/17
# Nethack makefile for Fred fish termlib -- Norman Meluch
#
CC = cl /c
MODEL = L
CFLAGS = /A$(MODEL) /Os /Oa /Gs /Zp1 /W0
#
# Termcap routines.
TERMLIB = termlib.lib
#
TL_LOBJECTS = tgetent.o tgetflag.o tgetnum.o \
tgetstr.o tgoto.o tputs.o \
isdigit.o fgetlr.o
#
.SUFFIXES: .exe .o .c .obj .asm
#
.c.o:
$(CC) $(CFLAGS) /Fo$*.o $*.c
#
$(TERMLIB): $(TL_LOBJECTS)
lib $(TERMLIB) -+ $(TL_LOBJECTS);
- to actually compile, run ndmake
- ignore whatever the library tool says, just copy the resulting *.O files to the Nethack 2.3e source dir
7. go back to nethack 2.3e source dir and copy makefile.pc to makefile
8. edit makefile as follows
- we want to avoid creating too large segments because otherwise linking will fail, thus we adjust the -Gt parameter of the compiler
- change line 8 (CFLAGS) to:
CFLAGS = -A$(MODEL) -DREGBUG -DLINT_ARGS -DVER=$V $(WIZARD) -Ot -Gs -Gt16
- I could not figure out for life of mine how to make the MS C 4.0 linker to actually accept both libs and objects when linking the final executable, so I took a shortcut by just including the object files for termlib instead of actually using the lib (apparently there are no online copies of MS C 4.0 documentation?)
- also, the maximum number of segments should be increased because whatever the default value is, it is too small
- change line 46 (commented out by default) to:
link fgetlr.o isdigit.o tgetent.o tgetflag.o tgetnum.o tgetstr.o tgoto.o tputs.o $(OBJS), $(GAME) /NOIG /STACK:0xa00 /CP:1 /
SEG:256;
9. edit config.h
- #define MSDOS because the compiler does not seem to do it despite contrary claims in the makefile
- comment out everything that looks like unix
- here's a diff so you can figure out what to change and where:
21c21
< # define MSDOS /* define for MS-DOS (actually defined by compiler) */
---
> /* # define MSDOS /* define for MS-DOS (actually defined by compiler) */
23c23
< /* #define UNIX /* delete if no fork(), exec() available */
---
> #define UNIX /* delete if no fork(), exec() available */
25c25
< /* #define BSD /* defind for 4.n BSD */
---
> #define BSD /* defind for 4.n BSD */
32c32
< /* #define PYRAMID_BUG /* avoid a bug on the Pyramid */
---
> #define PYRAMID_BUG /* avoid a bug on the Pyramid */
48c48
< /* #define LOGFILE "logfile" /* larger file for debugging purposes */
---
> #define LOGFILE "logfile" /* larger file for debugging purposes */
75c75
< /* #define MAIL
---
> #define MAIL
78d77
< */
80c79,80
< /* #define SHELL /* do not delete the '!' command */
---
>
> #define SHELL /* do not delete the '!' command */
103c103
< /* #define HACKDIR "/usr/games/lib/nethackdir" */
---
> #define HACKDIR "/usr/games/lib/nethackdir"
112c112
< /* #define SECURE /* do setuid(getuid()) after chdir() */
---
> #define SECURE /* do setuid(getuid()) after chdir() */
9. run ndmake
10. wait (took about three hours on Toshiba T1200)
11. make directory C:\ETC
12. copy TERMCAP.CNF to C:\ETC\TERMCAP - no extension
- the termlib could be compiled so that it looks for termcap.cnf in current dir instead but I didn't bother
13. if you don't have ANSI.SYS or equivalent, uudecode nansi_sy.uu, copy it somewhere and put device=C:\somewher\nansi.sys into config.sys, reboot to load it
14. set TERM=ibmpc (or ibmpc-mono if you have a monochrome monitor)
15. make a directory for nethack, say, C:\nethack
16. copy hack.exe and nethack.cnf to the dir created, edit nethack.cnf to point to the dir you just created
17. make directory save under the dir created, also create an empty file record
18. run HACK.EXE
19. (countless hours of frustration trying to ascend)
These should be complete instructions. Took me better part of a day to figure this out. Next I'll try 3.1 or 3.2.