# Overview

It takes 1024MB of memory to build NetHack 3.6.x in DJGPP!  I used
FreeDOS 1.3 with DJGPP 2.05 including the following programs:

* ed
* gunzip
* ls
* patch
* tar
* touch

In order to run NetHack in Qemu, it was necessary to patch DJGPP
libc.a to fix the "drunken keys" bug.

https://www.vogons.org/viewtopic.php?f=61&t=71459

Starting with NetHack 3.6.1, OPTIONS=video:autodetect defaults to
VESA, which causes tiles mode to be too slow for me in Qemu.  A
workaround is to set OPTIONS=video:vga instead.

Below are the steps i took to build NetHack.

# Enable DOSLFN and extract nethack source code

doslfn e
ren nethack-367-src.tgz nh367.tgz
gzip -dc nh367.tgz >nh367.tar
tar --no-attributes -xvf nh367.tar

# Rename to shorter file names

ren NetHack-3.6.7 nh367
cd nh366\dat
copy data~1.bas data.old
ren data~1.bas data.bas
cd ..\doc
copy guideb~1.txt guideboo.old
ren guideb~1.txt guideboo.txt
cd ..\include
copy patchl~1.h patchlev.old
ren patchl~1.h patchlev.h
cd ..\sys\share
copy posixr~1.c posixreg.old
ren posixr~1.c posixreg.c
cd ..\..
copy sys\msdos\Makefile.GCC src\Makefile
copy sys\winnt\syscon~1.tem sys\msdos\sysconf

# Configure nethack

ed include/pcconf.h
/^#define SCREEN_BIOS
s,^#define SCREEN_BIOS,/* #define SCREEN_BIOS */,
+1s,^/\* #define SCREEN_DJGPPFAST \*/,#define SCREEN_DJGPPFAST,
/^#define MAIL
s,^#define MAIL,/* #define MAIL */,
wq

ed src/Makefile
/ADD_CURSES
s,ADD_CURSES=Y,ADD_CURSES=N,
wq

# Disable DOSLFN and compile nethack

doslfn d
mkdir binary
cd src
make install
cd ..\binary
strip nethack.exe
copy \djgpp\bin\cwsdpmi.exe .
copy ..\sys\msdos\msdoshlp.txt .
copy ..\sys\msdos\sysconf .
copy ..\..\bldnote.txt .
cd ..
ren binary nh367dos
zip -r nh367dos.zip nh367dos
