[nethack] 02/02: Imported Debian patch 3.2.2-10
James Cowgill
jcowgill-guest at moszumanska.debian.org
Mon Mar 7 17:53:03 UTC 2016
This is an automated email from the git hooks/post-receive script.
jcowgill-guest pushed a commit to annotated tag debian/3.2.2-10
in repository nethack.
commit f44ee3551b1c18098efd1f1f528a53b01408f7df
Author: Ben Gertzfield <che at debian.org>
Date: Tue Oct 28 12:53:37 1997 -0800
Imported Debian patch 3.2.2-10
---
Makefile | 35 ++--
debian/changelog | 44 +++++
debian/conffiles | 1 +
debian/control | 36 ++--
debian/menu | 6 +
debian/nethack.init | 29 +++
debian/nethack.sh | 58 ++++++
debian/nethackrc.x11 | 71 +++++++
debian/postinst | 19 +-
debian/postrm | 14 ++
debian/preinst | 34 ++++
debian/readme | 21 ++
debian/rules | 101 ++++++++--
spoilers.tar.uu => debian/spoilers.tar.uu | 0
doc/recover.6 | 44 +----
include/config.h | 8 +-
include/global.h | 2 +-
include/unixconf.h | 16 +-
makelog | 115 +++++++++++
src/Makefile | 18 +-
src/drawing.c | 4 +-
src/files.c | 16 +-
src/interp.c | 309 ++++++++++++++++++++++++++++++
src/music.c | 13 +-
sys/share/ioctl.c | 10 +
sys/share/unixtty.c | 52 +++++
sys/unix/Files | 1 +
sys/unix/Install | 37 ++++
sys/unix/Makefile | 22 +++
sys/unix/Makefile.src | 20 +-
sys/unix/Makefile.top | 4 +-
sys/unix/Makefile.utl | 14 +-
sys/unix/Master | 1 +
sys/unix/Name | 1 +
sys/unix/Node | 1 +
sys/unix/READ.ME | 51 +++++
sys/unix/Remove | 25 +++
sys/unix/Size | 2 +
sys/unix/System | 1 +
sys/unix/install.bsd | 59 ++++++
sys/unix/interp.c | 309 ++++++++++++++++++++++++++++++
sys/unix/playtest | 25 +++
sys/unix/spkr.7 | 117 +++++++++++
sys/unix/spkr.c | 305 +++++++++++++++++++++++++++++
sys/unix/spkr.h | 34 ++++
sys/unix/unixmain.c | 16 +-
sys/unix/unixunix.c | 15 +-
util/Makefile | 10 +-
util/recover.c | 19 +-
win/tty/termcap.c | 9 +-
50 files changed, 2004 insertions(+), 170 deletions(-)
diff --git a/Makefile b/Makefile
index 1060bbe..2664504 100644
--- a/Makefile
+++ b/Makefile
@@ -15,15 +15,15 @@
# make NetHack
GAME = nethack
-GAMEUID = root
-GAMEGRP = games
+GAMEUID = games
+GAMEGRP = bin
# Permissions - some places use setgid instead of setuid, for instance
# See also the option "SECURE" in include/config.h
-GAMEPERM = 2775
-FILEPERM = 664
-EXEPERM = 755
-DIRPERM = 775
+GAMEPERM = 04755
+FILEPERM = 0644
+EXEPERM = 0755
+DIRPERM = 0755
# GAMEDIR also appears in config.h as "HACKDIR".
#
@@ -32,11 +32,8 @@ DIRPERM = 775
# therefore there should not be anything in GAMEDIR that you want to keep
# (if there is, you'll have to do the installation by hand or modify the
# instructions)
-GAMEDIR = $(PREFIX)/usr/lib/games/$(GAME)
-REALGAMEDIR = /usr/lib/games/$(GAME)
-SHELLDIR = $(PREFIX)/usr/games
-REALSHELLDIR = /usr/games
-VARDIR = $(PREFIX)/var/lib/games/$(GAME)
+GAMEDIR = /usr/lib/games/$(GAME)dir
+SHELLDIR = /usr/games
# per discussion in Install.X11
# VARDATND =
@@ -140,7 +137,7 @@ dofiles:
$(MAKE) dofiles-$${target-nodlb}
cp src/$(GAME) $(GAMEDIR)
-rm -f $(SHELLDIR)/$(GAME)
- sed -e 's;/usr/games/lib/nethackdir;$(REALGAMEDIR);' \
+ sed -e 's;/usr/games/lib/nethackdir;$(GAMEDIR);' \
-e 's;HACKDIR/nethack;HACKDIR/$(GAME);' \
< sys/unix/nethack.sh \
> $(SHELLDIR)/$(GAME)
@@ -153,7 +150,7 @@ dofiles:
chmod $(EXEPERM) $(SHELLDIR)/$(GAME)
dofiles-dlb: check-dlb
- ( cd dat; cp nhdat $(DATNODLB) $(GAMEDIR) )
+ ( cd dat ; cp nhdat $(DATNODLB) $(GAMEDIR) )
# set up their permissions
-( cd $(GAMEDIR) ; $(CHOWN) $(GAMEUID) nhdat $(DATNODLB) ; \
$(CHGRP) $(GAMEGRP) nhdat $(DATNODLB) ; \
@@ -187,15 +184,15 @@ install: $(GAME) $(VARDAT) dungeon spec_levs
# set up the directories
-mkdir $(SHELLDIR)
-rm -rf $(GAMEDIR)
- -mkdir $(GAMEDIR) $(VARDIR) $(VARDIR)/save
- -$(CHOWN) $(GAMEUID) $(GAMEDIR) $(VARDIR) $(VARDIR)/save
- $(CHGRP) $(GAMEGRP) $(GAMEDIR) $(VARDIR) $(VARDIR)/save
- chmod $(DIRPERM) $(GAMEDIR) $(VARDIR)/save
+ -mkdir $(GAMEDIR) $(GAMEDIR)/save
+ -$(CHOWN) $(GAMEUID) $(GAMEDIR) $(GAMEDIR)/save
+ $(CHGRP) $(GAMEGRP) $(GAMEDIR) $(GAMEDIR)/save
+ chmod $(DIRPERM) $(GAMEDIR) $(GAMEDIR)/save
# set up the game files
( $(MAKE) dofiles )
# set up some additional files
- touch $(VARDIR)/perm $(VARDIR)/record $(VARDIR)/logfile
- -( cd $(VARDIR) ; $(CHOWN) $(GAMEUID) perm record logfile ; \
+ touch $(GAMEDIR)/perm $(GAMEDIR)/record $(GAMEDIR)/logfile
+ -( cd $(GAMEDIR) ; $(CHOWN) $(GAMEUID) perm record logfile ; \
$(CHGRP) $(GAMEGRP) perm record logfile ; \
chmod $(FILEPERM) perm record logfile )
# and a reminder
diff --git a/debian/changelog b/debian/changelog
index 7bb493b..8a2c56f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,46 @@
+nethack (3.2.2-10) stable; urgency=low
+
+ * Re-built with libc5 libraries, as 3.2.2-7 was broken.
+ * Fixed text menu entry pausing bug.
+ * Took out dpkg-shlibdeps call for the lib5 build.
+ * Changed chmod /var/lib/games/nethack 04775 in postinst to 02775.
+
+ -- Ben Gertzfield <che at debian.org> Tue, 28 Oct 1997 12:53:37 -0800
+
+nethack (3.2.2-9) unstable; urgency=low
+
+ * Re-added fix for permissions on /var/lib/games/nethack to postinst;
+ fixes bug #13596.
+ * Added X NetHack entry to menu file, fixes wishlist #13036.
+ * Menu entry for text NetHack now pauses after the game ends, fixes
+ bug #13035.
+ * Built with all-glibc libraries, fixes bug #12793.
+ * Copied 'license' text-file to /usr/lib/games/nethack, fixes bug #13033.
+ * Upgraded to Standards-Version 2.3.0.0.
+
+ -- Ben Gertzfield <che at debian.org> Fri, 10 Oct 1997 16:17:46 -0700
+
+nethack (3.2.2-8) unstable; urgency=low
+
+ * New maintainer.
+ * Compiled under libc6.
+ * Added patch for proper IBM graphics support.
+ * Added patch for sound (speaker) support at the console.
+ * No longer writes to /usr/lib/games/nethack; fixes bug #10454.
+ * No longer uses i386-specific commands in makefile; fixes bug #10795.
+ * Re-added dgn_comp and lev_comp to package; fixes bug #11013.
+ * Created /etc/rc.boot/nethack to recover save-files on boot;
+ fixes bug #11012.
+ * Changed rules file to no longer use debstd.
+ * Made the recover utility setgid and removed the -d option to
+ prevent cheating.
+ * Really fixed bug #10149 -- both logfile and record are now
+ conffiles.
+ * If upgrading from a version with incompatible logfile/record files,
+ warns before clearing out /var/lib/games/nethack.
+
+ -- Ben Gertzfield <che at debian.org> Wed, 23 Jul 1997 20:33:26 -0500
+
nethack (3.2.2-7) frozen unstable; urgency=low
* changes to makefile to force compiling under libc5
@@ -76,5 +119,6 @@ nethack (3.2.1-1) unstable; urgency=low
-- Paul Haggart <phaggart at cybertap.com> Sun, 27 Oct 1996 05:56:48 -0500
Local variables:
+add-log-mailing-address: "che at debian.org"
mode: debian-changelog
End:
diff --git a/debian/conffiles b/debian/conffiles
index df03017..1d072db 100644
--- a/debian/conffiles
+++ b/debian/conffiles
@@ -1 +1,2 @@
/var/lib/games/nethack/logfile
+/var/lib/games/nethack/record
diff --git a/debian/control b/debian/control
index 25dce80..cfeb7dd 100644
--- a/debian/control
+++ b/debian/control
@@ -1,23 +1,27 @@
Source: nethack
Section: games
Priority: optional
-Maintainer: Paul Haggart <phaggart at debian.org>
-Standards-Version: 2.1.0.0
+Maintainer: Ben Gertzfield <che at debian.org>
+Standards-Version: 2.3.0.0
Package: nethack
Architecture: any
-Depends: ${shlibs:Depends}
-Description: console mode dungeon exploration game
- Nethack is a single-user, fantasy role-playing computer game, a direct
- descendant of the games Hack and Rogue. Nethack is a -very- complex game,
- compared to ones such as Moria, Rogue, or Angband. There are several
- different character classes, a larger variety of items (from keys to
- artifacts), a leaner, meaner collection of monsters, and several quests that
- a player must finish before winning the game. There are also many new
- dungeon features as well as interesting and quite amusing things that a
- player can do.
+Depends: libc5 (>= 5.4.0-0), ncurses3.0, xlib6 (>= 3.2-0), xpm4.7 (>= 3.4j-0)
+Description: Text-based/X11 overhead view D&D-style adventure game
+ Nethack is a wonderfully silly, yet quite addicting, Dungeons and
+ Dragons-style adventure game. You play the part of a fierce fighter,
+ wizard, or any of many other classes, fighting your way down to
+ retrieve the Amulet of Yendor (try saying THAT one backwards!) for
+ your god. On the way, you might encounter a quantum mechanic or two,
+ or perhaps a microscopic space fleet, or -- if you're REALLY lucky --
+ the Ravenous Bugblatter Beast of Traal.
.
- Much of the Dungeons of Doom within Nethack is borrowed from several fantasy
- genres, including Tolkien's Middle Earth, King Aurthor, and Dungeons and
- Dragons, as well as a few small references to Star Trek, Doctor Who, and the
- Hitchhiker's Guide to the Galaxy.
+ The Debian package of Nethack includes spoiler files, to be read only
+ in sheer desperation, in /usr/doc/nethack/spoilers.
+ .
+ A few utilities -- recover, for retrieving your auto-save files in case
+ of a power failure, and dgn_comp and lev_comp, two utilities for making
+ your own Nethack levels and dungeons, have been included in
+ /usr/lib/games/nethack. 'recover' will be run every time your system
+ boots, if there are any auto-save files available.
+
diff --git a/debian/menu b/debian/menu
new file mode 100644
index 0000000..9facac6
--- /dev/null
+++ b/debian/menu
@@ -0,0 +1,6 @@
+?package(nethack):command="sh -c '/usr/games/nethack; echo Press ENTER to quit. ; read;'" \
+ icon="none" needs="text" section="Games/Adventure" \
+ title="NetHack"
+?package(nethack):needs=x11 \
+ command="sh -c 'NETHACKOPTIONS=/etc/nethackrc.x11 /usr/games/nethack'"\
+ section="Games/Adventure" title="X NetHack"
diff --git a/debian/nethack.init b/debian/nethack.init
new file mode 100644
index 0000000..b64b9a2
--- /dev/null
+++ b/debian/nethack.init
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# Nethack save-file recovery script for Debian
+#
+# Ben Gertzfield (che at debian.org) 29 July 1997
+# Copyright 1997 Ben Gertzfield. This script is released under the
+# GNU General Public License, version 2 or later.
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+set -e
+
+# Has the nethack package been removed?
+test -f /usr/lib/games/nethack/recover || exit 0
+
+# Are there any lock-files to recover?
+ls /var/lib/games/nethack/*lock.0 >/dev/null 2>&1 || exit 0
+
+# Yes; recover them.
+for file in /var/lib/games/nethack/*lock.0; do
+ owner=$(ls -l $file | awk '{print $3}')
+ echo -n "Recovering Nethack save file owned by $owner: "
+ su $owner -c "/usr/lib/games/nethack/recover $file" >/dev/null 2>&1
+ if (($?)); then
+ echo error $?\!
+ else
+ echo "recovered."
+ fi
+done
diff --git a/debian/nethack.sh b/debian/nethack.sh
new file mode 100644
index 0000000..6ee8b4e
--- /dev/null
+++ b/debian/nethack.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+# SCCS Id: @(#)nethack.sh 3.2 90/02/26
+
+HACKDIR=/usr/lib/games/nethack
+HACK=$HACKDIR/nethack
+MAXNROFPLAYERS=42
+
+# see if we can find the full path name of PAGER, so help files work properly
+# assume that if someone sets up a special variable (HACKPAGER) for NetHack,
+# it will already be in a form acceptable to NetHack
+# ideas from brian at radio.astro.utoronto.ca
+if test \( "xxx$PAGER" != xxx \) -a \( "xxx$HACKPAGER" = xxx \)
+then
+
+ HACKPAGER=$PAGER
+
+# use only the first word of the pager variable
+# this prevents problems when looking for file names with trailing
+# options, but also makes the options unavailable for later use from
+# NetHack
+ for i in $HACKPAGER
+ do
+ HACKPAGER=$i
+ break
+ done
+
+ if test ! -f $HACKPAGER
+ then
+ IFS=:
+ for i in $PATH
+ do
+ if test -f $i/$HACKPAGER
+ then
+ HACKPAGER=$i/$HACKPAGER
+ export HACKPAGER
+ break
+ fi
+ done
+ IFS=' '
+ fi
+ if test ! -f $HACKPAGER
+ then
+ echo Cannot find $PAGER -- unsetting PAGER.
+ unset HACKPAGER
+ unset PAGER
+ fi
+fi
+
+
+cd $HACKDIR
+case $1 in
+ -s*)
+ exec $HACK -d $HACKDIR "$@"
+ ;;
+ *)
+ exec $HACK -d $HACKDIR "$@" $MAXNROFPLAYERS
+ ;;
+esac
diff --git a/debian/nethackrc.x11 b/debian/nethackrc.x11
new file mode 100644
index 0000000..b079038
--- /dev/null
+++ b/debian/nethackrc.x11
@@ -0,0 +1,71 @@
+#
+# System-wide NetHack configuration file for X-based NetHack.
+#
+
+OPTIONS=windowtype:x11,toptenwin,hilite_pet
+OPTIONS=fixinv,safe_pet,sortpack,tombstone
+OPTIONS=verbose,news,fruit:yiffmelon
+OPTIONS=dogname:Kitsune
+OPTIONS=catname:Neko-chan
+OPTIONS=pickup_types:$
+
+#
+# There are 17 object symbols and various graphics symbols.
+# The descriptions of these symbols can be found in dat/opthelp.
+#
+#
+# Font: nh10 (10x20)
+#
+OBJECTS= 180 183 188 192 181 184 182 189 190 196 \
+ 191 194 193 187 185 186 195
+#
+DUNGEON= 032 025 018 013 012 014 011 015 023 024 \
+ 022 021 128 129 130 131 132 133 134 135 \
+ 136 137 145 146 144 143 142 141 140 149 \
+ 150 031 031 147 148 031 161 140
+#
+TRAPS= 138 138 138 138 138 138 138 138 138 138 \
+ 138 138 138 138 138 139 138 138 138 138 \
+ 138 138
+#
+EFFECTS= 151 152 153 154 155 156 157 158 \
+ 159 160 161 162 \
+ 163 164 165 166 167 168 169 170 \
+ 171 172 173 174 175 176 177 178 179
+#
+#
+# Font: ibm (8x14)
+#
+#OBJECTS= 207 210 215 219 208 211 209 216 217 223 \
+# 218 221 220 214 212 213 222
+#
+#DUNGEON= 032 128 129 130 131 132 133 134 135 136 \
+# 137 138 139 045 124 142 143 144 145 146 \
+# 147 148 155 156 227 154 153 152 151 159 \
+# 160 200 200 157 158 250 170 151
+#
+#TRAPS= 149 149 149 149 149 149 149 149 149 149 \
+# 149 149 149 149 149 150 149 149 149 149 \
+# 149 149
+#
+#EFFECTS= 161 162 163 164 165 166 167 168 \
+# 169 170 171 172 \
+# 173 174 175 176 177 178 179 180 \
+# 181 182 183 184 185 186 187 188 189
+#
+#
+# Font: a "standard" font like 6x13
+#
+#DUNGEON = 032 025 018 013 012 014 011 015 023 024 \
+# 022 021 031 045 124 043 043 031 035 001 \
+# 060 062 060 062 019 092 035 123 125 031 \
+# 125 046 046 035 035 046 127 125
+#
+#TRAPS= 094 094 094 094 094 094 094 094 094 094 \
+# 094 094 094 094 094 002 094 094 094 094 \
+# 094 094
+#
+#EFFECTS= 124 045 092 047 042 033 041 040 \
+# 048 035 064 042 \
+# 047 045 092 124 124 092 045 047 \
+# 047 064 092 064 064 064 092 064 047
diff --git a/debian/postinst b/debian/postinst
index f7a68ca..1faecea 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -1,9 +1,18 @@
#!/bin/sh
-chown root.games /var/lib/games/nethack /var/lib/games/nethack/save
-chmod 775 /var/lib/games/nethack/save /var/lib/games/nethack/save
+# Nethack post-installation script for Debian
+#
+# Ben Gertzfield (che at debian.org) 29 July 1997
+# Copyright 1997 Ben Gertzfield. This script is released under the
+# GNU General Public License, version 2 or later.
-chown root.games /usr/lib/games/nethack
-chmod 775 /usr/lib/games/nethack
+# Modified 10 October 1997 to fix permissions on /var/lib/games/nethack.
-mkfontdir /usr/X11R6/lib/X11/fonts/misc
+set -e
+
+chmod 02775 /var/lib/games/nethack
+
+if [ -x /usr/X11R6/bin/mkfontdir ] ; then /usr/X11R6/bin/mkfontdir \
+ /usr/X11R6/lib/X11/fonts/misc ; fi
+
+if [ -x /usr/bin/update-menus ] ; then /usr/bin/update-menus ; fi
diff --git a/debian/postrm b/debian/postrm
new file mode 100644
index 0000000..ac7bdab
--- /dev/null
+++ b/debian/postrm
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Nethack post-remove script for Debian
+#
+# Ben Gertzfield (che at debian.org) 29 July 1997
+# Copyright 1997 Ben Gertzfield. This script is released under the
+# GNU General Public License, version 2 or later.
+
+set -e
+
+if [ -x /usr/X11R6/bin/mkfontdir ] ; then /usr/X11R6/bin/mkfontdir \
+ /usr/X11R6/lib/X11/fonts/misc ; fi
+
+if [ -x /usr/bin/update-menus ] ; then /usr/bin/update-menus ; fi
diff --git a/debian/preinst b/debian/preinst
new file mode 100644
index 0000000..2005536
--- /dev/null
+++ b/debian/preinst
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# Nethack pre-installation script for Debian
+#
+# Ben Gertzfield (che at debian.org) 29 July 1997
+# Copyright 1997 Ben Gertzfield. This script is released under the
+# GNU General Public License, version 2 or later.
+
+set -e
+
+dpkg --compare-versions $2 lt-nl 3.2.2 || exit 0
+
+cat <<EOF
+You seem to have a version of Nethack prior to this package's version,
+which is 3.2.2. Unfortunately, the save files and high scores that
+older versions used are incompatible with this version, and will be
+cleared if you continue installing this package.
+
+If you want to save these, back up /var/lib/games/nethack now!
+
+EOF
+
+echo -n "Do you want to continue? (Y/n) "
+read answer
+
+if [ "$answer" = "n" -o "$answer" = "N" ] ; then
+ echo "Aborting installation of Nethack."
+ exit 1
+else
+ echo "Removing old save files and high scores.."
+ rm -rf /var/lib/games/nethack
+fi
+
+
diff --git a/debian/readme b/debian/readme
new file mode 100644
index 0000000..90c7ad9
--- /dev/null
+++ b/debian/readme
@@ -0,0 +1,21 @@
+README for Debian GNU/Linux Nethack 3.2.2:
+
+Nethack is a wonderfully silly yet quite addicting Dungeons and
+Dragons-style adventure game. You play the part of a fierce fighter,
+wizard, or any of many other classes, fighting your way down to
+retrieve the Amulet of Yendor (try saying THAT one backwards!) for
+your god. On the way, you might encounter a quantum mechanic or two,
+or perhaps a microscopic space fleet, or -- if you're REALLY lucky --
+the Ravenous Bugblatter Beast of Traal.
+
+The Debian package of Nethack includes spoiler files, to be read only
+in sheer desperation, in /usr/doc/nethack/spoilers.
+
+A few utilities -- recover, for retrieving your auto-save files in case
+of a power failure, and dgn_comp and lev_comp, two utilities for making
+your own Nethack levels and dungeons, have been included in
+/usr/lib/games/nethack.
+
+The recover utility will be run upon bootup, by /etc/rc.boot/nethack.
+Any auto-save files will be retrieved and converted into proper save
+files.
diff --git a/debian/rules b/debian/rules
index e9cfa43..9b63dc6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,53 +1,116 @@
#!/usr/bin/make -f
+# Nethack build script for Debian
+#
+# Ben Gertzfield (che at debian.org) 29 July 1997
+# Copyright 1997 Ben Gertzfield. This script is released under the
+# GNU General Public License, version 2 or later.
+
+
+ARCH=$(shell dpkg --print-gnu-build-architecture)
+CCLIBC1=$(ARCH)-linuxlibc1-gcc
+VPATH=/usr/$(ARCH)-linuxlibc1/lib
+
build:
$(checkdir)
- make
+ make all CC=$(CCLIBC1) CFLAGS='-DDEBIAN -O2 -I../include \
+ -I/usr/$(ARCH)-linuxlibc1/include -fomit-frame-pointer'
touch build
+ cd util && make recover CC=$(CCLIBC1) \
+ CFLAGS='-DDEBIAN -O2 -I../include \
+ -I/usr/$(ARCH)-linuxlibc1/include -fomit-frame-pointer'
clean:
$(checkdir)
-rm -f build nh10.pcf
- -make spotless
+ -rm -f `find . -name "*.orig"`
-rm -f `find . -name "*~"`
-rm -rf debian/tmp debian/files* core debian/substvars
+ -make spotless
binary-indep: checkroot build
$(checkdir)
-# There are no architecture-independent files to be uploaded
binary-arch: checkroot build
$(checkdir)
install -d debian/tmp/usr/games
- install -d debian/tmp/usr/doc/nethack
install -d debian/tmp/usr/X11R6/lib/X11/app-defaults
install -d debian/tmp/usr/X11R6/lib/X11/fonts/misc
- install -d debian/tmp/usr/lib/games/nethack
- install -d debian/tmp/var/lib/games/nethack
-
- # make console-mode nethack
- make install PREFIX=`pwd`/debian/tmp
+ install -d -m 755 -o root -g games \
+ debian/tmp/usr/lib/games/nethack
+ install -d -m 2775 -o root -g games \
+ debian/tmp/var/lib/games/nethack
+ install -d -m 2775 -o root -g games \
+ debian/tmp/var/lib/games/nethack/save
+ install -d debian/tmp/usr/man/man6
+ install -d debian/tmp/usr/lib/menu
+ install -d debian/tmp/etc/rc.boot
+ install -d debian/tmp/DEBIAN
+ install -d debian/tmp/usr/doc/nethack
+
+ install -m 0644 -o root -g root \
+ dat/{nhdat,x11tiles,pet_mark.xbm,rip.xpm,license} \
+ debian/tmp/usr/lib/games/nethack
+ install -m 0755 -o root -g games \
+ debian/nethack.sh debian/tmp/usr/games/nethack
+
+ install -m 2755 -o root -g games src/nethack \
+ debian/tmp/usr/lib/games/nethack/
+
+ touch debian/tmp/var/lib/games/nethack/{perm,record,logfile}
+ chown root.games debian/tmp/var/lib/games/nethack/{perm,record,logfile}
+ chmod 0664 debian/tmp/var/lib/games/nethack/{perm,record,logfile}
+
# build the recover prog, and move it where it's supposed to be
- (cd util; /usr/bin/i486-linuxlibc1-gcc -O2 -I../include recover.c -o recover)
- install -o root -g games -m 755 util/recover debian/tmp/usr/games/recover
+ install -o root -g games -m 2755 util/recover \
+ debian/tmp/usr/lib/games/nethack/recover
+
+ # install the dgn_comp and lev_comp programs
+ install -o root -g games -m 755 util/dgn_comp \
+ debian/tmp/usr/lib/games/nethack/dgn_comp
+
+ install -o root -g games -m 755 util/lev_comp \
+ debian/tmp/usr/lib/games/nethack/lev_comp
# install X11 stuff
install -m 644 win/X11/NetHack.ad debian/tmp/usr/X11R6/lib/X11/app-defaults/NetHack
- bdftopcf -o nh10.pcf win/X11/nh10.bdf
+ /usr/X11R6/bin/bdftopcf -o nh10.pcf win/X11/nh10.bdf
install -m 644 nh10.pcf debian/tmp/usr/X11R6/lib/X11/fonts/misc/
# extract spoilers
- uudecode -o /dev/stdout spoilers.tar.uu | tar xf - -C debian/tmp/usr/doc/nethack
+ uudecode -o /dev/stdout debian/spoilers.tar.uu | tar xf - -C debian/tmp/usr/doc/nethack
+
+ # man pages
+ install -m 644 -o root -g root doc/*.6 debian/tmp/usr/man/man6
+
+ install -m 644 -o root -g root doc/Guidebook \
+ debian/tmp/usr/doc/nethack
+
+ install -m 644 -o root -g root debian/readme \
+ debian/tmp/usr/doc/nethack/README.debian
+
+ # init.d script
+ install -m 755 -o root -g root debian/nethack.init \
+ debian/tmp/etc/rc.boot/nethack
- # build the nethack package
- debstd doc/Guidebook.txt win/X11/nethack.rc
+ # system-wide X nethack.rc file, thanks again joey :)
+ install -m 644 -o root -g root debian/nethackrc.x11 \
+ debian/tmp/etc/nethackrc.x11
- # remove some unused manpages
- rm debian/tmp/usr/man/man6/dgn_comp.6.gz
- rm debian/tmp/usr/man/man6/dlb.6.gz
- rm debian/tmp/usr/man/man6/lev_comp.6.gz
+ install -m 755 -o root -g root debian/postinst debian/tmp/DEBIAN
+ install -m 755 -o root -g root debian/postrm debian/tmp/DEBIAN
+ install -m 644 -o root -g root debian/conffiles debian/tmp/DEBIAN
+ install -m 644 -o root -g root debian/changelog \
+ debian/tmp/usr/doc/nethack/changelog.Debian
+ install -m 644 -o root -g root debian/menu \
+ debian/tmp/usr/lib/menu/nethack
+ install -m 644 -o root -g root debian/copyright \
+ debian/tmp/usr/doc/nethack/copyright
+ -find debian/tmp/usr/{doc,man} -type f -not -name '*.gz' | \
+ xargs gzip -9f
+# dpkg-shlibdeps debian/tmp/usr/lib/games/nethack/{nethack,recover}
dpkg-gencontrol -pnethack
dpkg --build debian/tmp ..
diff --git a/spoilers.tar.uu b/debian/spoilers.tar.uu
similarity index 100%
rename from spoilers.tar.uu
rename to debian/spoilers.tar.uu
diff --git a/doc/recover.6 b/doc/recover.6
index d813264..b5418bd 100644
--- a/doc/recover.6
+++ b/doc/recover.6
@@ -4,10 +4,6 @@
recover \- recover a NetHack game interrupted by disaster
.SH SYNOPSIS
.B recover
-[
-.B \-d
-.I directory
-]
.I "base1 base2" ...
.SH DESCRIPTION
.PP
@@ -25,14 +21,6 @@ options tell
which files to process.
Each base option specifies recovery of a separate game.
.PP
-The
-.B \-d
-option, which must be the first argument if it appears,
-supplies a directory which is the NetHack playground.
-It overrides the value from NETHACKDIR, HACKDIR, or the directory
-specified by the game administrator during compilation
-(usually /usr/games/lib/nethackdir).
-.PP
For recovery to be possible,
.I nethack
must have been compiled with the INSURANCE option, and the run-time option
@@ -61,33 +49,13 @@ will transform these level files into a save file of the same name as
.I nethack
would have used.
.PP
-Since
-.I recover
-must be able to read and delete files from the playground
-and create files in the save directory,
-it has interesting interactions with game security.
-Giving ordinary players access to
-.I recover
-through setuid or setgid is tantamount to leaving the playground
-world-writable,
-with respect to both cheating and messing up other players.
-For a single-user system, this of course does not change anything,
-so some of the microcomputer ports install
-.I recover
-by default.
-.PP
-For a multi-user system,
-the game administrator may want to arrange for all .0 files in the
-playground to be fed to recover when the host machine boots,
-and handle game crashes individually.
-If the user population is sufficiently trustworthy,
-.I recover
-can be installed with the same permissions the
-.I nethack
-executable has.
-In either case,
.I recover
-is easily compiled from the distribution utility directory.
+has been installed under Debian GNU/Linux as sgid games. This makes
+it possible for users to recover their own games. The security hazards
+of possible cheating have been removed, by taking out the
+.I -d
+option and making sure the only directory auto-save files can be read
+from is /var/lib/games/nethack.
.SH NOTES
.PP
Like
diff --git a/include/config.h b/include/config.h
index 337be8a..fd86320 100644
--- a/include/config.h
+++ b/include/config.h
@@ -256,7 +256,7 @@
* would allow:
* xpmtoppm <x11tiles.xpm | pnmscale 1.25 | ppmquant 90 >x11tiles_big.xpm
*/
-#define USE_XPM /* Disable if you do not have the XPM library */
+# define USE_XPM /* Disable if you do not have the XPM library */
# ifdef USE_XPM
# define GRAPHIC_TOMBSTONE /* Use graphical tombstone (rip.xpm) */
# endif
@@ -282,8 +282,8 @@
# define LOGFILE "/var/lib/games/nethack/logfile"
# define NEWS "/var/lib/games/nethack/news"
#else
-# define LOGFILE "logfile" /* larger file for debugging purposes */
-# define NEWS "news" /* the file containing the latest hack news */
+# define LOGFILE "logfile" /* larger file for debugging purposes */
+# define NEWS "news" /* the file containing the latest hack news */
#endif
/*
@@ -432,7 +432,7 @@ typedef unsigned char uchar;
* functions that have been macroized.
*/
-/*#define VISION_TABLES /* use vision tables generated at compile time */
+#define VISION_TABLES /* use vision tables generated at compile time */
#ifndef VISION_TABLES
# ifndef NO_MACRO_CPATH
# define MACRO_CPATH /* use clear_path macros instead of functions */
diff --git a/include/global.h b/include/global.h
index f507008..f2d30bd 100644
--- a/include/global.h
+++ b/include/global.h
@@ -17,7 +17,7 @@
#ifdef DEBIAN
# define RECORD "/var/lib/games/nethack/record"
#else
-# define RECORD "record" /* a file containing list of topscorers */
+# define RECORD "record" /* a file containing list of topscorers */
#endif
#define HELP "help" /* a file containing command descriptions */
diff --git a/include/unixconf.h b/include/unixconf.h
index ba93667..06cca75 100644
--- a/include/unixconf.h
+++ b/include/unixconf.h
@@ -24,13 +24,13 @@
/* #define ULTRIX /* define for Ultrix v3.0 or higher (but not lower) */
/* Use BSD for < v3.0 */
/* "ULTRIX" not to be confused with "ultrix" */
-/* #define SYSV /* define for System V */
+#define SYSV /* define for System V */
/* #define HPUX /* Hewlett-Packard's Unix, version 6.5 or higher */
/* use SYSV for < v6.5 */
/* define any of the following that are appropriate */
-/* #define SVR4 /* use in addition to SYSV for System V Release 4 */
+#define SVR4 /* use in addition to SYSV for System V Release 4 */
#define NETWORK /* if running on a networked system */
/* e.g. Suns sharing a playground through NFS */
/* #define SUNOS4 /* SunOS 4.x */
@@ -45,9 +45,9 @@
#define TEXTCOLOR /* Use System V r3.2 terminfo color support */
/* and/or ANSI color support on termcap systems */
/* and/or X11 color */
-/* #define POSIX_JOB_CONTROL /* use System V / POSIX job control
+#define POSIX_JOB_CONTROL /* use System V / POSIX job control
* (e.g., VSUSP) */
-/* #define POSIX_TYPES /* use POSIX types for system calls and termios */
+#define POSIX_TYPES /* use POSIX types for system calls and termios */
/* define for many recent OS releases, including
* those with specific defines (since types are
* changing toward the standard from earlier chaos).
@@ -71,7 +71,7 @@
/* see sys/unix/snd86.shr for more information on these */
/* #define UNIX386MUSIC /* Play real music through speaker on systems with
music driver installed */
-/* #define VPIX_MUSIC /* Play real music through speaker on systems with
+#define VPIX_MUSIC /* Play real music through speaker on systems with
built-in VPIX support */
@@ -114,7 +114,7 @@
* "extra output" method is used, but not all systems provide access to
* a fine-grained timer.
*/
-/* #define TIMED_DELAY /* usleep() */
+#define TIMED_DELAY /* usleep() */
#endif
/*
@@ -242,9 +242,9 @@
#endif
#ifdef DEBIAN
-# define HLOCK "/var/lib/games/nethack/perm"
+# define HLOCK "/var/lib/games/nethack/perm"
#else
-# define HLOCK "perm" /* an empty file used for locking purposes */
+# define HLOCK "perm" /* an empty file used for locking purposes */
#endif
#ifndef REDO
diff --git a/makelog b/makelog
new file mode 100644
index 0000000..3e38c45
--- /dev/null
+++ b/makelog
@@ -0,0 +1,115 @@
+( cd src ; make )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/src'
+make[1]: `nethack' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/src'
+( cd dat ; make data )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `data' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd dat ; make oracles )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `oracles' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd dat ; make options )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `options' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd dat ; make quest.dat )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `quest.dat' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd dat ; make rumors )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `rumors' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd util ; make tile2x11 )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/util'
+make[1]: `tile2x11' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/util'
+( cd dat ; make x11tiles )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `x11tiles' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd dat ; make pet_mark.xbm )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `pet_mark.xbm' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd dat ; make rip.xpm )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `rip.xpm' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd util ; make dgn_comp )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/util'
+make[2]: Entering directory `/home/che/nethack/nethack-3.2.2/src'
+make[2]: `../include/date.h' is up to date.
+make[2]: Leaving directory `/home/che/nethack/nethack-3.2.2/src'
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/util'
+( cd dat ; make dungeon )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `dungeon' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd util ; make lev_comp )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/util'
+make[2]: Entering directory `/home/che/nethack/nethack-3.2.2/src'
+make[2]: `../include/date.h' is up to date.
+make[2]: Leaving directory `/home/che/nethack/nethack-3.2.2/src'
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/util'
+( cd dat ; make spec_levs )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `spec_levs' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+( cd dat ; make quest_levs )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[1]: `quest_levs' is up to date.
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+mkdir /usr/games
+rm -rf /usr/lib/games/nethackdir
+mkdir /usr/lib/games/nethackdir /usr/lib/games/nethackdir/save
+chown games /usr/lib/games/nethackdir /usr/lib/games/nethackdir/save
+chgrp bin /usr/lib/games/nethackdir /usr/lib/games/nethackdir/save
+chmod 0755 /usr/lib/games/nethackdir /usr/lib/games/nethackdir/save
+( make dofiles )
+make[1]: Entering directory `/home/che/nethack/nethack-3.2.2'
+target=`sed -n \
+ -e '/librarian/{' \
+ -e 's/.*/dlb/p' \
+ -e 'q' \
+ -e '}' \
+ -e '$s/.*/nodlb/p' < dat/options` ; \
+make dofiles-${target-nodlb}
+make[2]: Entering directory `/home/che/nethack/nethack-3.2.2'
+( cd dat; make options )
+make[3]: Entering directory `/home/che/nethack/nethack-3.2.2/dat'
+make[3]: `options' is up to date.
+make[3]: Leaving directory `/home/che/nethack/nethack-3.2.2/dat'
+ color, data file compression, data librarian, debug mode, Elbereth,
+make[3]: Entering directory `/home/che/nethack/nethack-3.2.2'
+( cd util ; make dlb )
+make[4]: Entering directory `/home/che/nethack/nethack-3.2.2/util'
+make[4]: `dlb' is up to date.
+make[4]: Leaving directory `/home/che/nethack/nethack-3.2.2/util'
+( cd dat ; ../util/dlb cf nhdat help hh cmdhelp history opthelp wizhelp dungeon asmodeus.lev baalz.lev bigrm-?.lev castle.lev fakewiz?.lev juiblex.lev knox.lev medusa-?.lev minend-?.lev minefill.lev minetn-?.lev oracle.lev orcus.lev sanctum.lev tower?.lev valley.lev wizard?.lev astral.lev air.lev earth.lev fire.lev water.lev ?-goal.lev ?-fill?.lev ?-locate.lev ?-start.lev data oracles options quest.dat rumors )
+make[3]: Leaving directory `/home/che/nethack/nethack-3.2.2'
+( cd dat ; cp nhdat x11tiles pet_mark.xbm rip.xpm license /usr/lib/games/nethackdir )
+( cd /usr/lib/games/nethackdir ; chown games nhdat x11tiles pet_mark.xbm rip.xpm license ; \
+ chgrp bin nhdat x11tiles pet_mark.xbm rip.xpm license ; \
+ chmod 0644 nhdat x11tiles pet_mark.xbm rip.xpm license )
+make[2]: Leaving directory `/home/che/nethack/nethack-3.2.2'
+cp src/nethack /usr/lib/games/nethackdir
+rm -f /usr/games/nethack
+sed -e 's;/usr/games/lib/nethackdir;/usr/lib/games/nethackdir;' \
+-e 's;HACKDIR/nethack;HACKDIR/nethack;' \
+< sys/unix/nethack.sh \
+ > /usr/games/nethack
+( cd /usr/lib/games/nethackdir ; chown games nethack ; \
+ chgrp bin nethack )
+chmod 04755 /usr/lib/games/nethackdir/nethack
+chown games /usr/games/nethack
+chgrp bin /usr/games/nethack
+chmod 0755 /usr/games/nethack
+make[1]: Leaving directory `/home/che/nethack/nethack-3.2.2'
+touch /usr/lib/games/nethackdir/perm /usr/lib/games/nethackdir/record /usr/lib/games/nethackdir/logfile
+( cd /usr/lib/games/nethackdir ; chown games perm record logfile ; \
+ chgrp bin perm record logfile ; \
+ chmod 0644 perm record logfile )
+You may also want to reinstall the man pages via the doc Makefile.
diff --git a/src/Makefile b/src/Makefile
index d8354fd..da48b14 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -56,7 +56,7 @@ SYSOBJ = ioctl.o unixmain.o unixtty.o unixunix.o
# if you get setcgtty() warnings during execution, you are feeding gcc
# a non-ANSI <sys/ioctl.h> -- either run fixincludes on it or use
# -traditional in CFLAGS
-CC = /usr/bin/i486-linuxlibc1-gcc
+CC = gcc
#
# For Bull DPX/2 systems at B.O.S. 2.0 or higher use the following:
#
@@ -109,8 +109,8 @@ CC = /usr/bin/i486-linuxlibc1-gcc
# flags for Linux
# compile normally
-CFLAGS = -O2 -fomit-frame-pointer -I../include -I/usr/X11R6/include -I/usr/include -DDEBIAN
-LFLAGS = -L/usr/X11R6/lib -L/usr/lib
+# CFLAGS = -O2 -fomit-frame-pointer -I../include -I/usr/X11/include
+# LFLAGS = -L/usr/X11/lib
# OR compile backwards compatible a.out format
# CFLAGS = -O2 -b i486-linuxaout -fomit-frame-pointer -I../include -I/usr/X11/include
# LFLAGS = -b i486-linuxaout -L/usr/X11/lib
@@ -124,8 +124,8 @@ LFLAGS = -L/usr/X11R6/lib -L/usr/lib
# flags for debugging:
# CFLAGS = -g -I../include
-# CFLAGS = -O -I../include
-# LFLAGS =
+CFLAGS = -O2 -I../include -I/usr/X11R6/include
+LFLAGS = -s -L/usr/X11R6/lib
# Set the WINSRC, WINOBJ, and WINLIB lines to correspond to your desired
@@ -160,17 +160,17 @@ WINOBJ = $(WINTTYOBJ) $(WINX11OBJ)
#
# libraries for tty ports
# WINTTYLIB = -ltermcap
-# WINTTYLIB = -lcurses
+WINTTYLIB = -lcurses
# WINTTYLIB = -lcurses16
-WINTTYLIB = -lncurses
+# WINTTYLIB = -lncurses
# WINTTYLIB = -ltermlib
#
# libraries for X11
# If USE_XPM is defined in config.h, you will also need -lXpm here.
-WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11 -lXpm
+# WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
# WINX11LIB = -lXaw -lXmu -lXt -lX11
# WINX11LIB = -lXaw -lXmu -lXext -lXt -lXpm -lX11 -lm
-# WINX11LIB = -lXaw -lXmu -lXpm -lXext -lXt -lX11 -lSM -lICE -lm # BSD/OS 2.0
+WINX11LIB = -lXaw -lXmu -lXpm -lXext -lXt -lX11 -lSM -lICE # Linux 2.0
#
#
WINLIB = $(WINTTYLIB) $(WINX11LIB)
diff --git a/src/drawing.c b/src/drawing.c
index 179864f..2c25298 100644
--- a/src/drawing.c
+++ b/src/drawing.c
@@ -812,7 +812,7 @@ boolean is_rlevel;
#endif /* ASCIIGRAPH */
for (i = 0; i < MAXOCLASSES; i++) {
-#ifdef ASCIIGRAPH
+#if defined(ASCIIGRAPH) && !defined(LINUX)
if (iflags.IBMgraphics
# if defined(USE_TILES) && defined(MSDOS)
&& !iflags.grmode
@@ -820,7 +820,7 @@ boolean is_rlevel;
)
oc_syms[i] = IBM_r_oc_syms[i];
else
-#endif /* ASCIIGRAPH */
+#endif /* ASCIIGRAPH && !LINUX */
oc_syms[i] = r_oc_syms[i];
}
#if defined(MSDOS)
diff --git a/src/files.c b/src/files.c
index 2f67535..4e12cbe 100644
--- a/src/files.c
+++ b/src/files.c
@@ -39,7 +39,7 @@ char lock[PL_NSIZ+17] = "1lock"; /* long enough for _uid+name+.99;1 */
# else
# ifdef DEBIAN
char bones[] = "/var/lib/games/nethack/bonesnn.xxx";
-char lock[255] = "/var/lib/games/nethack/1lock";
+char lock[255] = "/var/lib/games/nethack/1lock";
# else
char bones[] = "bonesnn.xxx";
char lock[PL_NSIZ+14] = "1lock"; /* long enough for uid+name+.99 */
@@ -430,13 +430,13 @@ set_savefile_name()
regularize(SAVEF+i);
}
Strcat(SAVEF, ".sav");
-# else
-# ifdef DEBIAN
- Sprintf(SAVEF, "/var/lib/games/nethack/save/%d%s", (int)getuid(), plname);
- regularize(SAVEF+28); /* avoid . or / in name */
-# else
- Sprintf(SAVEF, "save/%d%s", (int)getuid(), plname);
- regularize(SAVEF+5); /* avoid . or / in name */
+ # else
+ # ifdef DEBIAN
+ Sprintf(SAVEF, "/var/lib/games/nethack/save/%d%s", (int)getuid(), plname);
+ regularize(SAVEF+28); /* avoid . or / in name */
+# else
+ Sprintf(SAVEF, "save/%d%s", (int)getuid(), plname);
+ regularize(SAVEF+5); /* avoid . or / in name */
# endif /* DEBIAN */
# endif /* MICRO */
#endif /* VMS */
diff --git a/src/interp.c b/src/interp.c
new file mode 100644
index 0000000..55cfe0b
--- /dev/null
+++ b/src/interp.c
@@ -0,0 +1,309 @@
+/*
+ * interp.c -- device driver for console speaker on 80386
+ *
+ * v1.1 by Eric S. Raymond (esr at snark.thyrsus.com) Feb 1990
+ *
+ * this is the part of the code common to all 386 UNIX OSes
+ *
+ * playinit() and playstring() are called from the appropriate driver
+ */
+
+#ifdef __386BSD__
+#include "param.h"
+#else
+#include <sys/param.h>
+#endif
+
+#ifndef HZ
+#define HZ 60
+#endif
+
+
+/**************** PLAY STRING INTERPRETER BEGINS HERE **********************
+ *
+ * Play string interpretation is modelled on IBM BASIC 2.0's PLAY statement;
+ * M[LNS] are missing and the ~ synonym and octave-tracking facility is added.
+ * Requires tone(), rest(), and endtone(). String play is not interruptible
+ * except possibly at physical block boundaries.
+ */
+
+typedef int bool;
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define toupper(c) ((c) - ' ' * (((c) >= 'a') && ((c) <= 'z')))
+#define isdigit(c) (((c) >= '0') && ((c) <= '9'))
+#define dtoi(c) ((c) - '0')
+
+static int octave; /* currently selected octave */
+static int whole; /* whole-note time at current tempo, in ticks */
+static int value; /* whole divisor for note time, quarter note = 1 */
+static int fill; /* controls spacing of notes */
+static bool octtrack; /* octave-tracking on? */
+static bool octprefix; /* override current octave-tracking state? */
+
+/*
+ * Magic number avoidance...
+ */
+#define SECS_PER_MIN 60 /* seconds per minute */
+#define WHOLE_NOTE 4 /* quarter notes per whole note */
+#define MIN_VALUE 64 /* the most we can divide a note by */
+#define DFLT_VALUE 4 /* default value (quarter-note) */
+#define FILLTIME 8 /* for articulation, break note in parts */
+#define STACCATO 6 /* 6/8 = 3/4 of note is filled */
+#define NORMAL 7 /* 7/8ths of note interval is filled */
+#define LEGATO 8 /* all of note interval is filled */
+#define DFLT_OCTAVE 4 /* default octave */
+#define MIN_TEMPO 32 /* minimum tempo */
+#define DFLT_TEMPO 120 /* default tempo */
+#define MAX_TEMPO 255 /* max tempo */
+#define NUM_MULT 3 /* numerator of dot multiplier */
+#define DENOM_MULT 2 /* denominator of dot multiplier */
+
+/* letter to half-tone: A B C D E F G */
+static int notetab[8] = {9, 11, 0, 2, 4, 5, 7};
+
+/*
+ * This is the American Standard A440 Equal-Tempered scale with frequencies
+ * rounded to nearest integer. Thank Goddess for the good ol' CRC Handbook...
+ * our octave 0 is standard octave 2.
+ */
+#define OCTAVE_NOTES 12 /* semitones per octave */
+static int pitchtab[] =
+{
+/* C C# D D# E F F# G G# A A# B*/
+/* 0 */ 65, 69, 73, 78, 82, 87, 93, 98, 103, 110, 117, 123,
+/* 1 */ 131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247,
+/* 2 */ 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494,
+/* 3 */ 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988,
+/* 4 */ 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1975,
+/* 5 */ 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951,
+/* 6 */ 4186, 4435, 4698, 4978, 5274, 5588, 5920, 6272, 6644, 7040, 7459, 7902,
+};
+
+static void playinit()
+{
+ octave = DFLT_OCTAVE;
+ whole = (HZ * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO;
+ fill = NORMAL;
+ value = DFLT_VALUE;
+ octtrack = FALSE;
+ octprefix = TRUE; /* act as though there was an initial O(n) */
+}
+
+static void playtone(pitch, value, sustain)
+/* play tone of proper duration for current rhythm signature */
+int pitch, value, sustain;
+{
+ register int sound, silence, snum = 1, sdenom = 1;
+
+ /* this weirdness avoids floating-point arithmetic */
+ for (; sustain; sustain--)
+ {
+ snum *= NUM_MULT;
+ sdenom *= DENOM_MULT;
+ }
+
+ if (pitch == -1)
+ rest(whole * snum / (value * sdenom));
+ else
+ {
+ sound = (whole * snum) / (value * sdenom)
+ - (whole * (FILLTIME - fill)) / (value * FILLTIME);
+ silence = whole * (FILLTIME-fill) * snum / (FILLTIME * value * sdenom);
+
+#ifdef DEBUG
+ printf("playtone: pitch %d for %d ticks, rest for %d ticks\n",
+ pitch, sound, silence);
+#endif /* DEBUG */
+
+ tone(pitchtab[pitch], sound);
+ if (fill != LEGATO)
+ rest(silence);
+ }
+}
+
+static int abs(n)
+int n;
+{
+ if (n < 0)
+ return(-n);
+ else
+ return(n);
+}
+
+static void playstring(cp, slen)
+/* interpret and play an item from a notation string */
+char *cp;
+size_t slen;
+{
+ int pitch, lastpitch = OCTAVE_NOTES * DFLT_OCTAVE;
+
+#define GETNUM(cp, v) for(v=0; isdigit(cp[1]) && slen > 0; ) \
+ {v = v * 10 + (*++cp - '0'); slen--;}
+ for (; slen--; cp++)
+ {
+ int sustain, timeval, tempo;
+ register char c = toupper(*cp);
+
+#ifdef DEBUG
+ printf("playstring: %c (%x)\n", c, c);
+#endif /* DEBUG */
+
+ switch (c)
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
+
+ /* compute pitch */
+ pitch = notetab[c - 'A'] + octave * OCTAVE_NOTES;
+
+ /* this may be followed by an accidental sign */
+ if (cp[1] == '#' || cp[1] == '+')
+ {
+ ++pitch;
+ ++cp;
+ slen--;
+ }
+ else if (cp[1] == '-')
+ {
+ --pitch;
+ ++cp;
+ slen--;
+ }
+
+ /*
+ * If octave-tracking mode is on, and there has been no octave-
+ * setting prefix, find the version of the current letter note
+ * closest to the last regardless of octave.
+ */
+ if (octtrack && !octprefix)
+ {
+ if (abs(pitch-lastpitch) > abs(pitch+OCTAVE_NOTES-lastpitch))
+ {
+ ++octave;
+ pitch += OCTAVE_NOTES;
+ }
+
+ if (abs(pitch-lastpitch) > abs((pitch-OCTAVE_NOTES)-lastpitch))
+ {
+ --octave;
+ pitch -= OCTAVE_NOTES;
+ }
+ }
+ octprefix = FALSE;
+ lastpitch = pitch;
+
+ /* ...which may in turn be followed by an override time value */
+ GETNUM(cp, timeval);
+ if (timeval <= 0 || timeval > MIN_VALUE)
+ timeval = value;
+
+ /* ...and/or sustain dots */
+ for (sustain = 0; cp[1] == '.'; cp++)
+ {
+ slen--;
+ sustain++;
+ }
+
+ /* time to emit the actual tone */
+ playtone(pitch, timeval, sustain);
+ break;
+
+ case 'O':
+ if (cp[1] == 'N' || cp[1] == 'n')
+ {
+ octprefix = octtrack = FALSE;
+ ++cp;
+ slen--;
+ }
+ else if (cp[1] == 'L' || cp[1] == 'l')
+ {
+ octtrack = TRUE;
+ ++cp;
+ slen--;
+ }
+ else
+ {
+ GETNUM(cp, octave);
+ if (octave >= sizeof(pitchtab) / OCTAVE_NOTES)
+ octave = DFLT_OCTAVE;
+ octprefix = TRUE;
+ }
+ break;
+
+ case '>':
+ if (octave < sizeof(pitchtab) / OCTAVE_NOTES - 1)
+ octave++;
+ octprefix = TRUE;
+ break;
+
+ case '<':
+ if (octave > 0)
+ octave--;
+ octprefix = TRUE;
+ break;
+
+ case 'N':
+ GETNUM(cp, pitch);
+ for (sustain = 0; cp[1] == '.'; cp++)
+ {
+ slen--;
+ sustain++;
+ }
+ playtone(pitch - 1, value, sustain);
+ break;
+
+ case 'L':
+ GETNUM(cp, value);
+ if (value <= 0 || value > MIN_VALUE)
+ value = DFLT_VALUE;
+ break;
+
+ case 'P':
+ case '~':
+ /* this may be followed by an override time value */
+ GETNUM(cp, timeval);
+ if (timeval <= 0 || timeval > MIN_VALUE)
+ timeval = value;
+ for (sustain = 0; cp[1] == '.'; cp++)
+ {
+ slen--;
+ sustain++;
+ }
+ playtone(-1, timeval, sustain);
+ break;
+
+ case 'T':
+ GETNUM(cp, tempo);
+ if (tempo < MIN_TEMPO || tempo > MAX_TEMPO)
+ tempo = DFLT_TEMPO;
+ whole = (HZ * SECS_PER_MIN * WHOLE_NOTE) / tempo;
+ break;
+
+ case 'M':
+ if (cp[1] == 'N' || cp[1] == 'n')
+ {
+ fill = NORMAL;
+ ++cp;
+ slen--;
+ }
+ else if (cp[1] == 'L' || cp[1] == 'l')
+ {
+ fill = LEGATO;
+ ++cp;
+ slen--;
+ }
+ else if (cp[1] == 'S' || cp[1] == 's')
+ {
+ fill = STACCATO;
+ ++cp;
+ slen--;
+ }
+ break;
+ }
+ }
+}
diff --git a/src/music.c b/src/music.c
index 8329cfd..7e2a0fc 100644
--- a/src/music.c
+++ b/src/music.c
@@ -649,6 +649,9 @@ char *buf;
#ifdef VPIX_MUSIC
+#ifdef __linux__
+#include <sys/kd.h>
+#else
# if 0
#include <sys/types.h>
#include <sys/console.h>
@@ -657,6 +660,7 @@ char *buf;
#define KIOC ('K' << 8)
#define KDMKTONE (KIOC | 8)
# endif
+#endif
#define noDEBUG
@@ -664,24 +668,27 @@ static void tone(hz, ticks)
/* emit tone of frequency hz for given number of ticks */
unsigned int hz, ticks;
{
- ioctl(0,KDMKTONE,hz|((ticks*10)<<16));
+ ioctl(0,KDMKTONE,(1193180/hz)|((ticks*10)<<16));
# ifdef DEBUG
printf("TONE: %6d %6d\n",hz,ticks * 10);
# endif
- nap(ticks * 10);
+ msleep(ticks * 10);
}
static void rest(ticks)
/* rest for given number of ticks */
int ticks;
{
- nap(ticks * 10);
+ msleep(ticks * 10);
# ifdef DEBUG
printf("REST: %6d\n",ticks * 10);
# endif
}
+static void tone();
+static void rest();
+static void speaker();
#include "interp.c" /* from snd86unx.shr */
diff --git a/sys/share/ioctl.c b/sys/share/ioctl.c
index 2fd1cfb..cfbfd6a 100644
--- a/sys/share/ioctl.c
+++ b/sys/share/ioctl.c
@@ -72,6 +72,10 @@ struct termio termio;
extern void NDECL(sco_mapon);
extern void NDECL(sco_mapoff);
#endif
+#ifdef __linux__
+extern void NDECL(linux_mapon);
+extern void NDECL(linux_mapoff);
+#endif
#ifdef AUX
void
@@ -156,6 +160,9 @@ dosuspend()
# ifdef _M_UNIX
sco_mapon();
# endif
+# ifdef __linux__
+ linux_mapon();
+# endif
(void) signal(SIGTSTP, SIG_DFL);
# ifdef AUX
( void ) kill ( 0 , SIGSTOP ) ;
@@ -165,6 +172,9 @@ dosuspend()
# ifdef _M_UNIX
sco_mapoff();
# endif
+# ifdef __linux__
+ linux_mapoff();
+# endif
resume_nhwindows();
} else {
pline("I don't think your shell has job control.");
diff --git a/sys/share/unixtty.c b/sys/share/unixtty.c
index 56b1579..7129683 100644
--- a/sys/share/unixtty.c
+++ b/sys/share/unixtty.c
@@ -365,6 +365,58 @@ init_sco_cons()
}
#endif /* _M_UNIX */
+#ifdef __linux__
+# include <sys/vt.h>
+
+int sco_flag_console = 0;
+
+void
+linux_mapon()
+{
+# ifdef TTY_GRAPHICS
+ if (!strcmp(windowprocs.name, "tty") && sco_flag_console) {
+ write(1, "\033(B", 3);
+ }
+# endif
+}
+
+void
+linux_mapoff()
+{
+# ifdef TTY_GRAPHICS
+ if (!strcmp(windowprocs.name, "tty") && sco_flag_console) {
+ write(1, "\033(U", 3);
+ }
+# endif
+}
+
+void
+check_linux_console()
+{
+ struct vt_mode vtm;
+
+ if (isatty(0) && ioctl(0,VT_GETMODE,&vtm) >= 0) {
+ sco_flag_console = 1;
+ }
+}
+
+void
+init_linux_cons()
+{
+# ifdef TTY_GRAPHICS
+ if (!strcmp(windowprocs.name, "tty") && sco_flag_console) {
+ atexit(linux_mapon);
+ linux_mapoff();
+ switch_graphics(IBM_GRAPHICS);
+# ifdef TEXTCOLOR
+ if (has_colors())
+ iflags.use_color = TRUE;
+# endif
+ }
+# endif
+}
+#endif /* __linux__ */
+
#ifndef __begui__ /* the Be GUI will define its own error proc */
/* fatal error */
diff --git a/sys/unix/Files b/sys/unix/Files
new file mode 100644
index 0000000..42e4046
--- /dev/null
+++ b/sys/unix/Files
@@ -0,0 +1 @@
+/usr/include/sys/spkr.h
diff --git a/sys/unix/Install b/sys/unix/Install
new file mode 100644
index 0000000..bf1e716
--- /dev/null
+++ b/sys/unix/Install
@@ -0,0 +1,37 @@
+#
+# Speaker driver installation script
+#
+TMP=/tmp/speaker.err
+ERR1=" Errors have been written to the file $TMP."
+ERR2=" The Speaker Driver software was not installed."
+
+echo "Installing Speaker Driver Software Package"
+
+/etc/conf/bin/idcheck -p speaker 2>$TMP
+if [ $? != 0 ]
+then
+ echo "The speaker package is already at least partly installed.
+ Removing the old version now..."
+ /etc/conf/bin/idinstall -d speaker
+fi
+
+/etc/conf/bin/idinstall -a -k speaker 2>>$TMP
+if [ $? != 0 ]
+then
+ message "There was an error during package installation. $ERR1 $ERR2"
+ exit 1
+fi
+
+/etc/conf/bin/idbuild 2>>$TMP
+if [ $? != 0 ]
+then
+ message "There was an error during kernel reconfiguration. $ERR1 $ERR2"
+ exit 1
+fi
+
+rm -f $TMP
+
+cp spkr.h /usr/include/sys/spkr.h
+
+echo "Performing shutdown..."
+cd /; exec /etc/shutdown -g0 -y
diff --git a/sys/unix/Makefile b/sys/unix/Makefile
new file mode 100644
index 0000000..d0853fa
--- /dev/null
+++ b/sys/unix/Makefile
@@ -0,0 +1,22 @@
+#
+# Speaker driver package makefile
+#
+CFLAGS = -I. -O # -DDEBUG
+LDFLAGS = -s
+
+all: Driver.o
+
+install:
+ ./Install
+
+Driver.o: spkr.c
+ $(CC) $(CFLAGS) -c spkr.c
+ mv spkr.o Driver.o
+
+clean:
+ rm -f Driver.o *~ speaker.shar
+
+DSP = Files Install Master Name Node Remove Size System
+shar:
+ shar READ.ME install.bsd spkr.7 Makefile spkr.[ch] \
+ interp.c $(DSP) playtest >speaker.shar
diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src
index ebfa843..da48b14 100644
--- a/sys/unix/Makefile.src
+++ b/sys/unix/Makefile.src
@@ -56,7 +56,7 @@ SYSOBJ = ioctl.o unixmain.o unixtty.o unixunix.o
# if you get setcgtty() warnings during execution, you are feeding gcc
# a non-ANSI <sys/ioctl.h> -- either run fixincludes on it or use
# -traditional in CFLAGS
-# CC = gcc
+CC = gcc
#
# For Bull DPX/2 systems at B.O.S. 2.0 or higher use the following:
#
@@ -124,8 +124,8 @@ SYSOBJ = ioctl.o unixmain.o unixtty.o unixunix.o
# flags for debugging:
# CFLAGS = -g -I../include
-CFLAGS = -O -I../include
-LFLAGS =
+CFLAGS = -O2 -I../include -I/usr/X11R6/include
+LFLAGS = -s -L/usr/X11R6/lib
# Set the WINSRC, WINOBJ, and WINLIB lines to correspond to your desired
@@ -146,8 +146,8 @@ WINX11OBJ = Window.o dialogs.o winX.o winmap.o winmenu.o winmesg.o \
winmisc.o winstat.o wintext.o winval.o tile.o
#
#
-WINSRC = $(WINTTYSRC)
-WINOBJ = $(WINTTYOBJ)
+WINSRC = $(WINTTYSRC) $(WINX11SRC)
+WINOBJ = $(WINTTYOBJ) $(WINX11OBJ)
# on some systems the termcap library is in -ltermcap or -lcurses
# on 386 Xenix, the -ltermlib tputs() seems not to work; use -lcurses instead
@@ -160,20 +160,20 @@ WINOBJ = $(WINTTYOBJ)
#
# libraries for tty ports
# WINTTYLIB = -ltermcap
-# WINTTYLIB = -lcurses
+WINTTYLIB = -lcurses
# WINTTYLIB = -lcurses16
# WINTTYLIB = -lncurses
-WINTTYLIB = -ltermlib
+# WINTTYLIB = -ltermlib
#
# libraries for X11
# If USE_XPM is defined in config.h, you will also need -lXpm here.
-WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
+# WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
# WINX11LIB = -lXaw -lXmu -lXt -lX11
# WINX11LIB = -lXaw -lXmu -lXext -lXt -lXpm -lX11 -lm
-# WINX11LIB = -lXaw -lXmu -lXpm -lXext -lXt -lX11 -lSM -lICE -lm # BSD/OS 2.0
+WINX11LIB = -lXaw -lXmu -lXpm -lXext -lXt -lX11 -lSM -lICE # Linux 2.0
#
#
-WINLIB = $(WINTTYLIB)
+WINLIB = $(WINTTYLIB) $(WINX11LIB)
# any other strange libraries your system needs (for Sysunix only -- the more
# specialized targets should already be right)
diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top
index 56de355..3fbd419 100644
--- a/sys/unix/Makefile.top
+++ b/sys/unix/Makefile.top
@@ -36,9 +36,9 @@ GAMEDIR = /usr/games/lib/$(GAME)dir
SHELLDIR = /usr/games
# per discussion in Install.X11
-VARDATND =
+# VARDATND =
# VARDATND = x11tiles pet_mark.xbm
-# VARDATND = x11tiles pet_mark.xbm rip.xpm
+VARDATND = x11tiles pet_mark.xbm rip.xpm
VARDATD = data oracles options quest.dat rumors
VARDAT = $(VARDATD) $(VARDATND)
diff --git a/sys/unix/Makefile.utl b/sys/unix/Makefile.utl
index 4ba4e61..ce2144c 100644
--- a/sys/unix/Makefile.utl
+++ b/sys/unix/Makefile.utl
@@ -15,7 +15,7 @@
# if you are using gcc as your compiler,
# uncomment the CC definition below if it's not in your environment
-# CC = gcc
+CC = gcc
#
# For Bull DPX/2 systems at B.O.S. 2.0 or higher use the following:
#
@@ -78,17 +78,17 @@
# flags for debugging:
# CFLAGS = -g -I../include
-CFLAGS = -O -I../include
-LFLAGS =
+CFLAGS = -O2 -I../include
+LFLAGS = -s
# yacc/lex programs to use to generate *_comp.h, *_lex.c, and *_yacc.c.
# if, instead of yacc/lex you have bison/flex, comment/uncomment the following.
-YACC = yacc
-LEX = lex
-# YACC = bison -y
+# YACC = yacc
+# LEX = lex
+YACC = bison -y
# YACC = byacc
-# LEX = flex
+LEX = flex
# these are the names of the output files from YACC/LEX. Under MS-DOS
# and similar systems, they may differ
diff --git a/sys/unix/Master b/sys/unix/Master
new file mode 100644
index 0000000..7979f46
--- /dev/null
+++ b/sys/unix/Master
@@ -0,0 +1 @@
+speaker ocwi iocH spkr 0 0 1 1 -1
diff --git a/sys/unix/Name b/sys/unix/Name
new file mode 100644
index 0000000..e608cf1
--- /dev/null
+++ b/sys/unix/Name
@@ -0,0 +1 @@
+386 UNIX Speaker Device Driver Package
diff --git a/sys/unix/Node b/sys/unix/Node
new file mode 100644
index 0000000..9d9fefb
--- /dev/null
+++ b/sys/unix/Node
@@ -0,0 +1 @@
+speaker speaker c 0
diff --git a/sys/unix/READ.ME b/sys/unix/READ.ME
new file mode 100644
index 0000000..e02392a
--- /dev/null
+++ b/sys/unix/READ.ME
@@ -0,0 +1,51 @@
+ Console Speaker Driver Package (v1.1)
+
+ by Eric S. Raymond (esr at snark.thyrsus.com)
+
+This package gives 80386 machines running SVr3.2 or later the ability to play
+tunes on the console speaker. It has been extended to 386BSD (and possibly
+BSDI) by Andrew A. Chernov, and to SCO UNIX 3.2.4 (and possibly other VPIX
+systems) by Andreas Arens.
+
+The following files are contained in the kit:
+
+Documentation and examples:
+READ.ME -- this file
+speaker.7 -- man page for the driver
+playtest -- test script exercising familiar tunes
+
+Installable driver kit parts, for SVr3.2 or later:
+Files -- list of driver package file locations
+Install -- installation script for driver kit
+Master -- mdevice entry for speaker driver
+Name -- name entry foe speaker driver
+Node -- /dev node specification file
+Remove -- Driver removal script
+Size -- installation size data
+System -- sdevice entry for speaker driver
+
+Driver source code, for SVr3.2 or later and 386BSD:
+Makefile -- Makefile for driver code
+spkr.c -- the driver source
+speaker.h -- ioctl interface file
+
+Common source code:
+interp.c -- play string interpretation code
+
+For SVr3.2 or later, simply type `make' and wait. Then type ./Install
+and follow its instructions. You will have to install the man pages by hand.
+Be aware that the speaker.7 man page uses tbl(1) constructs.
+
+For 386BSD, follow the installation instructions in install.bsd.
+
+For SCO UNIX 3.2.4, no new kernel drivers are needed, and you need only
+copy interp.c to your src directory and proceed with making NetHack, with
+VPIX_MUSIC set in unixconf.h.
+
+Interesting tunes mailed to the author will be periodically posted in batches
+and added to the test script for future versions.
+
+ Revision notes
+
+1.1 -- fixed minor bug in M[LSN] interpretation, added octave-tracking.
+ Tweaked the playtest examples.
diff --git a/sys/unix/Remove b/sys/unix/Remove
new file mode 100644
index 0000000..236b574
--- /dev/null
+++ b/sys/unix/Remove
@@ -0,0 +1,25 @@
+#
+# Speaker driver remove script
+#
+TMP=/tmp/speaker.err
+RERR="Errors have been written to the file $TMP."
+
+echo "Removing Speaker Driver Software Package"
+
+/etc/conf/bin/idinstall -d speaker 2>$TMP
+if [ $? != 0 ]
+then
+ message "There was an error during package removal. $RERR"
+ exit 1
+fi
+
+/etc/conf/bin/idbuild 2>>$TMP
+if [ $? != 0 ]
+then
+ message "There was an error during kernel reconfiguration. $RERR"
+ exit 1
+fi
+
+rm -f /dev/speaker $TMP /usr/include/sys/spkr.h
+
+exit 0
diff --git a/sys/unix/Size b/sys/unix/Size
new file mode 100644
index 0000000..8545de0
--- /dev/null
+++ b/sys/unix/Size
@@ -0,0 +1,2 @@
+ROOT=1400
+USR=100
diff --git a/sys/unix/System b/sys/unix/System
new file mode 100644
index 0000000..4a7b37b
--- /dev/null
+++ b/sys/unix/System
@@ -0,0 +1 @@
+speaker Y 1 0 0 0 0 0 0 0
diff --git a/sys/unix/install.bsd b/sys/unix/install.bsd
new file mode 100644
index 0000000..def1498
--- /dev/null
+++ b/sys/unix/install.bsd
@@ -0,0 +1,59 @@
+Copy spkr.c and interp.c to /sys/i386/isa
+Copy spkr.h to /sys/sys
+
+-----------------------------------------------------------------------------
+
+File /sys/i386/conf/YOUR_MACHINE_NAME
+add following line:
+
+pseudo-device speaker
+
+-----------------------------------------------------------------------------
+
+File /sys/i386/conf/files.i386
+add following line:
+
+i386/isa/spkr.c optional speaker
+
+-----------------------------------------------------------------------------
+
+File /sys/i386/i386/conf.c
+[major number 20 (hex) is registered for spkr driver, don't change it]
+add following code:
+
+#include "speaker.h"
+#if NSPEAKER > 0
+int spkropen(),spkrclose(),spkrwrite(),spkrioctl();
+#else
+#define spkropen enxio
+#define spkrclose enxio
+#define spkrwrite enxio
+#define spkrioctl enxio
+#endif
+ ...
+
+struct cdevsw cdevsw[] =
+{
+ ...
+
+ { spkropen, spkrclose, enxio, spkrwrite, /*20*/
+ spkrioctl, enxio, enxio, NULL,
+ enxio, enxio, enxio },
+ ...
+
+-----------------------------------------------------------------------------
+
+Make corresponding device:
+
+ mknod /dev/speaker c 32 0
+
+[major number 32 (20 hex) is registered for spkr driver, don't change it]
+
+-----------------------------------------------------------------------------
+
+Go to /sys/i386/conf and type
+ config YOUR_MACHINE_NAME
+then go to /sys/compile/YOUR_MACHINE_NAME and type
+ make depend
+ make
+
diff --git a/sys/unix/interp.c b/sys/unix/interp.c
new file mode 100644
index 0000000..55cfe0b
--- /dev/null
+++ b/sys/unix/interp.c
@@ -0,0 +1,309 @@
+/*
+ * interp.c -- device driver for console speaker on 80386
+ *
+ * v1.1 by Eric S. Raymond (esr at snark.thyrsus.com) Feb 1990
+ *
+ * this is the part of the code common to all 386 UNIX OSes
+ *
+ * playinit() and playstring() are called from the appropriate driver
+ */
+
+#ifdef __386BSD__
+#include "param.h"
+#else
+#include <sys/param.h>
+#endif
+
+#ifndef HZ
+#define HZ 60
+#endif
+
+
+/**************** PLAY STRING INTERPRETER BEGINS HERE **********************
+ *
+ * Play string interpretation is modelled on IBM BASIC 2.0's PLAY statement;
+ * M[LNS] are missing and the ~ synonym and octave-tracking facility is added.
+ * Requires tone(), rest(), and endtone(). String play is not interruptible
+ * except possibly at physical block boundaries.
+ */
+
+typedef int bool;
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define toupper(c) ((c) - ' ' * (((c) >= 'a') && ((c) <= 'z')))
+#define isdigit(c) (((c) >= '0') && ((c) <= '9'))
+#define dtoi(c) ((c) - '0')
+
+static int octave; /* currently selected octave */
+static int whole; /* whole-note time at current tempo, in ticks */
+static int value; /* whole divisor for note time, quarter note = 1 */
+static int fill; /* controls spacing of notes */
+static bool octtrack; /* octave-tracking on? */
+static bool octprefix; /* override current octave-tracking state? */
+
+/*
+ * Magic number avoidance...
+ */
+#define SECS_PER_MIN 60 /* seconds per minute */
+#define WHOLE_NOTE 4 /* quarter notes per whole note */
+#define MIN_VALUE 64 /* the most we can divide a note by */
+#define DFLT_VALUE 4 /* default value (quarter-note) */
+#define FILLTIME 8 /* for articulation, break note in parts */
+#define STACCATO 6 /* 6/8 = 3/4 of note is filled */
+#define NORMAL 7 /* 7/8ths of note interval is filled */
+#define LEGATO 8 /* all of note interval is filled */
+#define DFLT_OCTAVE 4 /* default octave */
+#define MIN_TEMPO 32 /* minimum tempo */
+#define DFLT_TEMPO 120 /* default tempo */
+#define MAX_TEMPO 255 /* max tempo */
+#define NUM_MULT 3 /* numerator of dot multiplier */
+#define DENOM_MULT 2 /* denominator of dot multiplier */
+
+/* letter to half-tone: A B C D E F G */
+static int notetab[8] = {9, 11, 0, 2, 4, 5, 7};
+
+/*
+ * This is the American Standard A440 Equal-Tempered scale with frequencies
+ * rounded to nearest integer. Thank Goddess for the good ol' CRC Handbook...
+ * our octave 0 is standard octave 2.
+ */
+#define OCTAVE_NOTES 12 /* semitones per octave */
+static int pitchtab[] =
+{
+/* C C# D D# E F F# G G# A A# B*/
+/* 0 */ 65, 69, 73, 78, 82, 87, 93, 98, 103, 110, 117, 123,
+/* 1 */ 131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247,
+/* 2 */ 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494,
+/* 3 */ 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988,
+/* 4 */ 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1975,
+/* 5 */ 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951,
+/* 6 */ 4186, 4435, 4698, 4978, 5274, 5588, 5920, 6272, 6644, 7040, 7459, 7902,
+};
+
+static void playinit()
+{
+ octave = DFLT_OCTAVE;
+ whole = (HZ * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO;
+ fill = NORMAL;
+ value = DFLT_VALUE;
+ octtrack = FALSE;
+ octprefix = TRUE; /* act as though there was an initial O(n) */
+}
+
+static void playtone(pitch, value, sustain)
+/* play tone of proper duration for current rhythm signature */
+int pitch, value, sustain;
+{
+ register int sound, silence, snum = 1, sdenom = 1;
+
+ /* this weirdness avoids floating-point arithmetic */
+ for (; sustain; sustain--)
+ {
+ snum *= NUM_MULT;
+ sdenom *= DENOM_MULT;
+ }
+
+ if (pitch == -1)
+ rest(whole * snum / (value * sdenom));
+ else
+ {
+ sound = (whole * snum) / (value * sdenom)
+ - (whole * (FILLTIME - fill)) / (value * FILLTIME);
+ silence = whole * (FILLTIME-fill) * snum / (FILLTIME * value * sdenom);
+
+#ifdef DEBUG
+ printf("playtone: pitch %d for %d ticks, rest for %d ticks\n",
+ pitch, sound, silence);
+#endif /* DEBUG */
+
+ tone(pitchtab[pitch], sound);
+ if (fill != LEGATO)
+ rest(silence);
+ }
+}
+
+static int abs(n)
+int n;
+{
+ if (n < 0)
+ return(-n);
+ else
+ return(n);
+}
+
+static void playstring(cp, slen)
+/* interpret and play an item from a notation string */
+char *cp;
+size_t slen;
+{
+ int pitch, lastpitch = OCTAVE_NOTES * DFLT_OCTAVE;
+
+#define GETNUM(cp, v) for(v=0; isdigit(cp[1]) && slen > 0; ) \
+ {v = v * 10 + (*++cp - '0'); slen--;}
+ for (; slen--; cp++)
+ {
+ int sustain, timeval, tempo;
+ register char c = toupper(*cp);
+
+#ifdef DEBUG
+ printf("playstring: %c (%x)\n", c, c);
+#endif /* DEBUG */
+
+ switch (c)
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
+
+ /* compute pitch */
+ pitch = notetab[c - 'A'] + octave * OCTAVE_NOTES;
+
+ /* this may be followed by an accidental sign */
+ if (cp[1] == '#' || cp[1] == '+')
+ {
+ ++pitch;
+ ++cp;
+ slen--;
+ }
+ else if (cp[1] == '-')
+ {
+ --pitch;
+ ++cp;
+ slen--;
+ }
+
+ /*
+ * If octave-tracking mode is on, and there has been no octave-
+ * setting prefix, find the version of the current letter note
+ * closest to the last regardless of octave.
+ */
+ if (octtrack && !octprefix)
+ {
+ if (abs(pitch-lastpitch) > abs(pitch+OCTAVE_NOTES-lastpitch))
+ {
+ ++octave;
+ pitch += OCTAVE_NOTES;
+ }
+
+ if (abs(pitch-lastpitch) > abs((pitch-OCTAVE_NOTES)-lastpitch))
+ {
+ --octave;
+ pitch -= OCTAVE_NOTES;
+ }
+ }
+ octprefix = FALSE;
+ lastpitch = pitch;
+
+ /* ...which may in turn be followed by an override time value */
+ GETNUM(cp, timeval);
+ if (timeval <= 0 || timeval > MIN_VALUE)
+ timeval = value;
+
+ /* ...and/or sustain dots */
+ for (sustain = 0; cp[1] == '.'; cp++)
+ {
+ slen--;
+ sustain++;
+ }
+
+ /* time to emit the actual tone */
+ playtone(pitch, timeval, sustain);
+ break;
+
+ case 'O':
+ if (cp[1] == 'N' || cp[1] == 'n')
+ {
+ octprefix = octtrack = FALSE;
+ ++cp;
+ slen--;
+ }
+ else if (cp[1] == 'L' || cp[1] == 'l')
+ {
+ octtrack = TRUE;
+ ++cp;
+ slen--;
+ }
+ else
+ {
+ GETNUM(cp, octave);
+ if (octave >= sizeof(pitchtab) / OCTAVE_NOTES)
+ octave = DFLT_OCTAVE;
+ octprefix = TRUE;
+ }
+ break;
+
+ case '>':
+ if (octave < sizeof(pitchtab) / OCTAVE_NOTES - 1)
+ octave++;
+ octprefix = TRUE;
+ break;
+
+ case '<':
+ if (octave > 0)
+ octave--;
+ octprefix = TRUE;
+ break;
+
+ case 'N':
+ GETNUM(cp, pitch);
+ for (sustain = 0; cp[1] == '.'; cp++)
+ {
+ slen--;
+ sustain++;
+ }
+ playtone(pitch - 1, value, sustain);
+ break;
+
+ case 'L':
+ GETNUM(cp, value);
+ if (value <= 0 || value > MIN_VALUE)
+ value = DFLT_VALUE;
+ break;
+
+ case 'P':
+ case '~':
+ /* this may be followed by an override time value */
+ GETNUM(cp, timeval);
+ if (timeval <= 0 || timeval > MIN_VALUE)
+ timeval = value;
+ for (sustain = 0; cp[1] == '.'; cp++)
+ {
+ slen--;
+ sustain++;
+ }
+ playtone(-1, timeval, sustain);
+ break;
+
+ case 'T':
+ GETNUM(cp, tempo);
+ if (tempo < MIN_TEMPO || tempo > MAX_TEMPO)
+ tempo = DFLT_TEMPO;
+ whole = (HZ * SECS_PER_MIN * WHOLE_NOTE) / tempo;
+ break;
+
+ case 'M':
+ if (cp[1] == 'N' || cp[1] == 'n')
+ {
+ fill = NORMAL;
+ ++cp;
+ slen--;
+ }
+ else if (cp[1] == 'L' || cp[1] == 'l')
+ {
+ fill = LEGATO;
+ ++cp;
+ slen--;
+ }
+ else if (cp[1] == 'S' || cp[1] == 's')
+ {
+ fill = STACCATO;
+ ++cp;
+ slen--;
+ }
+ break;
+ }
+ }
+}
diff --git a/sys/unix/playtest b/sys/unix/playtest
new file mode 100644
index 0000000..a6a7f07
--- /dev/null
+++ b/sys/unix/playtest
@@ -0,0 +1,25 @@
+:
+# Test script for the speaker driver
+#
+# v1.0 by Eric S. Raymond (Feb 1990)
+# modified for 386bsd by Andrew A. Chernov <ache at astral.msk.su>
+#
+reveille="t255l8c.f.afc~c.f.afc~c.f.afc.f.a..f.~c.f.afc~c.f.afc~c.f.afc~c.f.."
+contact="<cd<a#~<a#>f"
+dance="t240<cfcfgagaa#b#>dc<a#a.~fg.gaa#.agagegc.~cfcfgagaa#b#>dc<a#a.~fg.gga.agfgfgf."
+loony="t255cf8f8edc<a.>~cf8f8edd#e.~ce8cdce8cd.<a>c8c8c#def8af8."
+
+case $1 in
+reveille) echo $reveille >/dev/speaker;;
+contact) echo $contact >/dev/speaker;;
+dance) echo $dance >/dev/speaker;;
+loony) echo $loony >/dev/speaker;;
+*)
+ echo "No such tune. Available tunes are:"
+ echo
+ echo "reveille -- Reveille"
+ echo "contact -- Contact theme from Close Encounters"
+ echo "dance -- Lord of the Dance (aka Simple Gifts)"
+ echo "loony -- Loony Toons theme"
+ ;;
+esac
diff --git a/sys/unix/spkr.7 b/sys/unix/spkr.7
new file mode 100644
index 0000000..7c20280
--- /dev/null
+++ b/sys/unix/spkr.7
@@ -0,0 +1,117 @@
+.TH SPKR 7
+.SH NAME
+spkr \- console speaker device driver
+.SH DESCRIPTION
+The speaker device driver allows applications to control the PC console
+speaker on an IBM-PC-compatible machine running UNIX.
+.PP
+Only one process may have this device open at any given time; open() and
+close() are used to lock and relinquish it. An attempt to open() when
+another process has the device locked will return -1 with an EBUSY error
+indication. Writes to the device are interpreted as 'play strings' in a
+simple ASCII melody notation. An ioctl() for tone generation at arbitrary
+frequencies is also supported.
+.PP
+Sound-generation does \fInot\fR monopolize the processor; in fact, the driver
+spends most of its time sleeping while the PC hardware is emitting
+tones. Other processes may emit beeps while the driver is running.
+.PP
+Applications may call ioctl() on a speaker file descriptor to control the
+speaker driver directly; definitions for the ioctl() interface are in
+sys/spkr.h. The tone_t structure used in these calls has two fields,
+specifying a frequency (in hz) and a duration (in 1/100ths of a second).
+A frequency of zero is interpreted as a rest.
+.PP
+At present there are two such ioctls. SPKRTONE accepts a pointer to a
+single tone structure as third argument and plays it. SPKRTUNE accepts a
+pointer to the first of an array of tone structures and plays them in
+continuous sequence; this array must be terminated by a final member with
+a zero duration.
+.PP
+The play-string language is modelled on the PLAY statement conventions of
+IBM BASIC 2.0. The MB, MF and X primitives of PLAY are not useful in a UNIX
+environment and are omitted. The `octave-tracking' feature is also new.
+.PP
+There are 84 accessible notes numbered 1-83 in 7 octaves, each running from
+C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
+with middle C. By default, the play function emits half-second notes with the
+last 1/16th second being `rest time'.
+.PP
+Play strings are interpreted left to right as a series of play command groups;
+letter case is ignored. Play command groups are as follows:
+.PP
+CDEFGAB -- letters A through G cause the corresponding note to be played in the
+current octave. A note letter may optionally be followed by an \fIaccidental
+sign\fR, one of # + or -; the first two of these cause it to be sharped one
+half-tone, the last causes it to be flatted one half-tone. It may also be
+followed by a time value number and by sustain dots (see below). Time values
+are interpreted as for the L command below;.
+.PP
+O <n> -- if <n> is numeric, this sets the current octave. <n> may also be one
+of 'L' or 'N' to enable or disable octave-tracking (it is disabled by default).
+When octave-tracking is on, interpretation of a pair of letter notes will
+change octaves if necessary in order to make the smallest possible jump between
+notes. Thus "olbc" will be played as "olb>c", and "olcb" as "olc<b". Octave
+locking is disabled for one letter note following by >, < and O[0123456].
+.PP
+> -- bump the current octave up one.
+.PP
+< -- drop the current octave down one.
+.PP
+N <n> -- play note n, n being 1 to 84 or 0 for a rest of current time value.
+May be followedv by sustain dots.
+.PP
+L <n> -- sets the current time value for notes. The default is L4, quarter
+notes. The lowest possible value is 1; values up to 64 are accepted. L1 sets
+whole notes, L2 sets half notes, L4 sets quarter notes, etc..
+.PP
+P <n> -- pause (rest), with <n> interpreted as for L. May be followed by
+sustain dots. May also be written '~'.
+.PP
+T <n> -- Sets the number of quarter notes per minute; default is 120. Musical
+names for common tempi are:
+
+.TS
+a a a.
+ Tempo Beats Per Minute
+very slow Larghissimo
+ Largo 40-60
+ Larghetto 60-66
+ Grave
+ Lento
+ Adagio 66-76
+slow Adagietto
+ Andante 76-108
+medium Andantino
+ Moderato 108-120
+fast Allegretto
+ Allegro 120-168
+ Vivace
+ Veloce
+ Presto 168-208
+very fast Prestissimo
+.TE
+.PP
+M[LNS] -- set articulation. MN (N for normal) is the default; the last 1/8th of
+the note's value is rest time. You can set ML for legato (no rest space) or
+MS (staccato) 1/4 rest space.
+.PP
+Notes (that is, CDEFGAB or N command character groups) may be followed by
+sustain dots. Each dot causes the note's value to be lengthened by one-half
+for each one. Thus, a note dotted once is held for 3/2 of its undotted value;
+dotted twice, it is held 9/4, and three times would give 27/8.
+.PP
+Whitespace in play strings is simply skipped and may be used to separate
+melody sections.
+.SH BUGS
+Due to roundoff in the pitch tables and slop in the tone-generation and timer
+hardware (neither of which was designed for precision), neither pitch accuracy
+nor timings will be mathematically exact. There is no volume control.
+.PP
+In play strings which are very long (longer than your system's physical I/O
+blocks) note suffixes or numbers may occasionally be parsed incorrectly due
+to crossing a block boundary.
+.SH FILES
+/dev/speaker -- speaker device file
+.SH AUTHOR
+Eric S. Raymond (esr at snark.thyrsus.com) Feb 1990
diff --git a/sys/unix/spkr.c b/sys/unix/spkr.c
new file mode 100644
index 0000000..d100d0c
--- /dev/null
+++ b/sys/unix/spkr.c
@@ -0,0 +1,305 @@
+/*
+ * spkr.c -- device driver for console speaker on 80386
+ *
+ * v1.1 by Eric S. Raymond (esr at snark.thyrsus.com) Feb 1990
+ * modified for 386bsd by Andrew A. Chernov <ache at astral.msk.su>
+ */
+
+#ifdef __386BSD__
+#include "speaker.h"
+#endif
+#if !defined(__386BSD__) || (NSPEAKER > 0)
+
+#ifdef __386BSD__
+#include "types.h"
+#include "param.h"
+#include "errno.h"
+#include "buf.h"
+#include "uio.h"
+
+#define CADDR caddr_t
+#define err_ret(x) return(x)
+#else /* SYSV */
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/dir.h>
+#include <sys/signal.h>
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/user.h>
+#include <sys/sysmacros.h>
+#include <limits.h>
+
+#define CADDR char *
+#define err_ret(x) u.u_error = (x)
+#endif
+
+#include "spkr.h"
+
+/**************** MACHINE DEPENDENT PART STARTS HERE *************************
+ *
+ * This section defines a function tone() which causes a tone of given
+ * frequency and duration from the 80x86's console speaker.
+ * Another function endtone() is defined to force sound off, and there is
+ * also a rest() entry point to do pauses.
+ *
+ * Audible sound is generated using the Programmable Interval Timer (PIT) and
+ * Programmable Peripheral Interface (PPI) attached to the 80x86's speaker. The
+ * PPI controls whether sound is passed through at all; the PIT's channel 2 is
+ * used to generate clicks (a square wave) of whatever frequency is desired.
+ *
+ * The non-BSD code requires SVr3.2-compatible inb(), outb(), timeout(),
+ * sleep(), and wakeup().
+ */
+
+/*
+ * PIT and PPI port addresses and control values
+ *
+ * Most of the magic is hidden in the TIMER_PREP value, which selects PIT
+ * channel 2, frequency LSB first, square-wave mode and binary encoding.
+ * The encoding is as follows:
+ *
+ * +----------+----------+---------------+-----+
+ * | 1 0 | 1 1 | 0 1 1 | 0 |
+ * | SC1 SC0 | RW1 RW0 | M2 M1 M0 | BCD |
+ * +----------+----------+---------------+-----+
+ * Counter Write Mode 3 Binary
+ * Channel 2 LSB first, (Square Wave) Encoding
+ * MSB second
+ */
+#define PPI 0x61 /* port of Programmable Peripheral Interface */
+#define PPI_SPKR 0x03 /* turn these PPI bits on to pass sound */
+#define PIT_CTRL 0x43 /* PIT control address */
+#define PIT_COUNT 0x42 /* PIT count address */
+#define PIT_MODE 0xB6 /* set timer mode for sound generation */
+
+/*
+ * Magic numbers for timer control.
+ */
+#define TIMER_CLK 1193180L /* corresponds to 18.2 MHz tick rate */
+
+static int endtone()
+/* turn off the speaker, ending current tone */
+{
+ wakeup((CADDR)endtone);
+ outb(PPI, inb(PPI) & ~PPI_SPKR);
+}
+
+static void tone(hz, ticks)
+/* emit tone of frequency hz for given number of ticks */
+unsigned int hz, ticks;
+{
+ unsigned int divisor = TIMER_CLK / hz;
+ int sps;
+
+#ifdef DEBUG
+ printf("tone: hz=%d ticks=%d\n", hz, ticks);
+#endif /* DEBUG */
+
+ /* set timer to generate clicks at given frequency in Hertz */
+#ifdef __386BSD__
+ sps = spltty();
+#else
+ sps = spl5();
+#endif
+ outb(PIT_CTRL, PIT_MODE); /* prepare timer */
+ outb(PIT_COUNT, (unsigned char) divisor); /* send lo byte */
+ outb(PIT_COUNT, (divisor >> 8)); /* send hi byte */
+ splx(sps);
+
+ /* turn the speaker on */
+ outb(PPI, inb(PPI) | PPI_SPKR);
+
+ /*
+ * Set timeout to endtone function, then give up the timeslice.
+ * This is so other processes can execute while the tone is being
+ * emitted.
+ */
+ timeout((CADDR)endtone, (CADDR)NULL, ticks);
+ sleep((CADDR)endtone, PZERO - 1);
+}
+
+static int endrest()
+/* end a rest */
+{
+ wakeup((CADDR)endrest);
+}
+
+static void rest(ticks)
+/* rest for given number of ticks */
+int ticks;
+{
+ /*
+ * Set timeout to endrest function, then give up the timeslice.
+ * This is so other processes can execute while the rest is being
+ * waited out.
+ */
+#ifdef DEBUG
+ printf("rest: %d\n", ticks);
+#endif /* DEBUG */
+ timeout((CADDR)endrest, (CADDR)NULL, ticks);
+ sleep((CADDR)endrest, PZERO - 1);
+}
+
+#include "interp.c" /* playinit() and playstring() */
+
+/******************* UNIX DRIVER HOOKS BEGIN HERE **************************
+ *
+ * This section implements driver hooks to run playstring() and the tone(),
+ * endtone(), and rest() functions defined above. For non-BSD systems,
+ * SVr3.2-compatible copyin() is also required.
+ */
+
+static int spkr_active; /* exclusion flag */
+#ifdef __386BSD__
+static struct buf *spkr_inbuf; /* incoming buf */
+#endif
+
+int spkropen(dev)
+dev_t dev;
+{
+#ifdef DEBUG
+ printf("spkropen: entering with dev = %x\n", dev);
+#endif /* DEBUG */
+
+ if (minor(dev) != 0)
+ err_ret(ENXIO);
+ else if (spkr_active)
+ err_ret(EBUSY);
+ else
+ {
+ playinit();
+#ifdef __386BSD__
+ spkr_inbuf = geteblk(DEV_BSIZE);
+#endif
+ spkr_active = 1;
+ }
+#ifdef __386BSD__
+ return(0);
+#endif
+}
+
+#ifdef __386BSD__
+int spkrwrite(dev, uio)
+struct uio *uio;
+#else
+int spkrwrite(dev)
+#endif
+dev_t dev;
+{
+#ifdef __386BSD__
+ register unsigned n;
+ char *cp;
+ int error;
+#endif
+#ifdef DEBUG
+#ifdef __386BSD__
+ printf("spkrwrite: entering with dev = %x, count = %d\n",
+ dev, uio->uio_resid);
+#else
+ printf("spkrwrite: entering with dev = %x, u.u_count = %d\n",
+ dev, u.u_count);
+#endif
+#endif /* DEBUG */
+
+ if (minor(dev) != 0)
+ err_ret(ENXIO);
+ else
+ {
+#ifdef __386BSD__
+ n = MIN(DEV_BSIZE, uio->uio_resid);
+ cp = spkr_inbuf->b_un.b_addr;
+ error = uiomove(cp, n, uio);
+ if (!error)
+ playstring(cp, n);
+ return(error);
+#else
+ char bfr[STD_BLK];
+
+ copyin(u.u_base, bfr, u.u_count);
+ playstring(bfr, u.u_count);
+ u.u_base += u.u_count;
+ u.u_count = 0;
+#endif
+ }
+}
+
+int spkrclose(dev)
+dev_t dev;
+{
+#ifdef DEBUG
+ printf("spkrclose: entering with dev = %x\n", dev);
+#endif /* DEBUG */
+
+ if (minor(dev) != 0)
+ err_ret(ENXIO);
+ else
+ {
+ endtone();
+#ifdef __386BSD__
+ brelse(spkr_inbuf);
+#endif
+ spkr_active = 0;
+ }
+#ifdef __386BSD__
+ return(0);
+#endif
+}
+
+int spkrioctl(dev, cmd, cmdarg)
+dev_t dev;
+int cmd;
+CADDR cmdarg;
+{
+#ifdef DEBUG
+ printf("spkrioctl: entering with dev = %x, cmd = %x\n", dev, cmd);
+#endif /* DEBUG */
+
+ if (minor(dev) != 0)
+ err_ret(ENXIO);
+ else if (cmd == SPKRTONE)
+ {
+ tone_t *tp = (tone_t *)cmdarg;
+
+ if (tp->frequency == 0)
+ rest(tp->duration);
+ else
+ tone(tp->frequency, tp->duration);
+ }
+ else if (cmd == SPKRTUNE)
+ {
+#ifdef __386BSD__
+ tone_t *tp = (tone_t *)(*(caddr_t *)cmdarg);
+ tone_t ttp;
+ int error;
+
+ for (; ; tp++) {
+ error = copyin(tp, &ttp, sizeof(tone_t));
+ if (error)
+ return(error);
+ if (ttp.duration == 0)
+ break;
+ if (ttp.frequency == 0)
+ rest(ttp.duration);
+ else
+ tone(ttp.frequency, ttp.duration);
+ }
+#else
+ tone_t *tp = (tone_t *)cmdarg;
+
+ for (; tp->duration; tp++)
+ if (tp->frequency == 0)
+ rest(tp->duration);
+ else
+ tone(tp->frequency, tp->duration);
+#endif
+ }
+ else
+ err_ret(EINVAL);
+#ifdef __386BSD__
+ return(0);
+#endif
+}
+
+#endif /* !defined(__386BSD__) || (NSPEAKER > 0) */
+/* spkr.c ends here */
diff --git a/sys/unix/spkr.h b/sys/unix/spkr.h
new file mode 100644
index 0000000..98252ef
--- /dev/null
+++ b/sys/unix/spkr.h
@@ -0,0 +1,34 @@
+/*
+ * spkr.h -- interface definitions for speaker ioctl()
+ *
+ * v1.1 by Eric S. Raymond (esr at snark.thyrsus.com) Feb 1990
+ * modified for 386bsd by Andrew A. Chernov <ache at astral.msk.su>
+ */
+
+#ifndef _SPKR_H_
+#define _SPKR_H_
+
+#ifdef __386BSD__
+#ifndef KERNEL
+#include <sys/ioctl.h>
+#else
+#include "ioctl.h"
+#endif
+
+#define SPKRTONE _IOW('S', 1, tone_t) /* emit tone */
+#define SPKRTUNE _IO('S', 2) /* emit tone sequence*/
+#else /* SYSV */
+#define SPKRIOC ('S'<<8)
+#define SPKRTONE (SPKRIOC|1) /* emit tone */
+#define SPKRTUNE (SPKRIOC|2) /* emit tone sequence*/
+#endif
+
+typedef struct
+{
+ int frequency; /* in hertz */
+ int duration; /* in 1/100ths of a second */
+}
+tone_t;
+
+#endif /* _SPKR_H_ */
+/* spkr.h ends here */
diff --git a/sys/unix/unixmain.c b/sys/unix/unixmain.c
index 28fd734..f10f6b8 100644
--- a/sys/unix/unixmain.c
+++ b/sys/unix/unixmain.c
@@ -34,6 +34,10 @@ static void FDECL(process_options, (int, char **));
extern void NDECL(check_sco_console);
extern void NDECL(init_sco_cons);
#endif
+#ifdef __linux__
+extern void NDECL(check_linux_console);
+extern void NDECL(init_linux_cons);
+#endif
static void NDECL(wd_message);
#ifdef WIZARD
@@ -120,12 +124,18 @@ char *argv[];
#ifdef _M_UNIX
check_sco_console();
#endif
+#ifdef __linux__
+ check_linux_console();
+#endif
initoptions();
init_nhwindows(&argc,argv);
exact_username = whoami();
#ifdef _M_UNIX
init_sco_cons();
#endif
+#ifdef __linux__
+ init_linux_cons();
+#endif
/*
* It seems you really want to play.
@@ -176,15 +186,15 @@ char *argv[];
(void) signal(SIGINT,SIG_IGN);
if(!locknum)
#ifdef DEBIAN
- Sprintf(lock, "/var/lib/games/nethack/%d%s", (int)getuid(), plname);
+ Sprintf(lock, "/var/lib/games/nethack/%d%s", (int)getuid(), plname);
#else
- Sprintf(lock, "%d%s", (int)getuid(), plname);
+ Sprintf(lock, "%d%s", (int)getuid(), plname);
#endif
getlock();
#ifdef WIZARD
} else {
#ifdef DEBIAN
- Sprintf(lock, "/var/lib/games/nethack/%d%s", (int)getuid(), plname);
+ Sprintf(lock, "/var/lib/games/nethack/%d%s", (int)getuid(), plname);
#else
Sprintf(lock, "%d%s", (int)getuid(), plname);
#endif
diff --git a/sys/unix/unixunix.c b/sys/unix/unixunix.c
index af5b0ea..6a9b7f2 100644
--- a/sys/unix/unixunix.c
+++ b/sys/unix/unixunix.c
@@ -17,6 +17,10 @@
extern void NDECL(sco_mapon);
extern void NDECL(sco_mapoff);
#endif
+#ifdef __linux__
+extern void NDECL(linux_mapon);
+extern void NDECL(linux_mapoff);
+#endif
static struct stat buf, hbuf;
@@ -180,11 +184,10 @@ getlock()
wait_synch();
error("%s", "");
}
-
#ifdef DEBIAN
- regularize(lock);
-#else
regularize(lock+23);
+#else
+ regularize(lock);
#endif
set_levelfile_name(lock, 0);
@@ -323,6 +326,9 @@ int wt;
#ifdef _M_UNIX
sco_mapon();
#endif
+#ifdef __linux__
+ linux_mapon();
+#endif
if((f = fork()) == 0){ /* child */
(void) setgid(getgid());
(void) setuid(getuid());
@@ -342,6 +348,9 @@ int wt;
#ifdef _M_UNIX
sco_mapoff();
#endif
+#ifdef __linux__
+ linux_mapoff();
+#endif
(void) signal(SIGINT, (SIG_RET_TYPE) done1);
#ifdef WIZARD
if(wizard) (void) signal(SIGQUIT,SIG_DFL);
diff --git a/util/Makefile b/util/Makefile
index de3a07e..ce2144c 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -15,7 +15,7 @@
# if you are using gcc as your compiler,
# uncomment the CC definition below if it's not in your environment
-CC = /usr/bin/i486-linuxlibc1-gcc
+CC = gcc
#
# For Bull DPX/2 systems at B.O.S. 2.0 or higher use the following:
#
@@ -64,8 +64,8 @@ CC = /usr/bin/i486-linuxlibc1-gcc
# flags for Linux
# compile normally
-CFLAGS = -O2 -fomit-frame-pointer -I../include -I/usr/X11R6/include -DDEBIAN
-LFLAGS = -L/usr/X11R6/lib
+# CFLAGS = -O2 -fomit-frame-pointer -I../include -I/usr/X11/include
+# LFLAGS = -L/usr/X11/lib
# OR compile backwards compatible a.out format
# CFLAGS = -O2 -b i486-linuxaout -fomit-frame-pointer -I../include -I/usr/X11/include
# LFLAGS = -b i486-linuxaout -L/usr/X11/lib
@@ -78,8 +78,8 @@ LFLAGS = -L/usr/X11R6/lib
# flags for debugging:
# CFLAGS = -g -I../include
-# CFLAGS = -O -I../include
-# LFLAGS =
+CFLAGS = -O2 -I../include
+LFLAGS = -s
# yacc/lex programs to use to generate *_comp.h, *_lex.c, and *_yacc.c.
diff --git a/util/recover.c b/util/recover.c
index a0513b7..0fe85f5 100644
--- a/util/recover.c
+++ b/util/recover.c
@@ -53,13 +53,23 @@ char *argv[];
char *startdir = (char *)0;
#endif
+#ifdef DEBIAN
+ if (argc == 1) {
+ Fprintf(stderr,
+ "Usage: %s base1 base2 ...\n", argv[0]);
+ exit(EXIT_FAILURE);
+ }
+#else
if (argc == 1 || (argc == 2 && !strcmp(argv[1], "-"))) {
Fprintf(stderr,
"Usage: %s [-d directory] base1 base2 ...\n", argv[0]);
exit(EXIT_FAILURE);
}
+#endif
argno = 1;
+
+#ifndef DEBIAN
if (!strncmp(argv[argno], "-d", 2)) {
dir = argv[argno]+2;
if (*dir == '=' || *dir == ':') dir++;
@@ -78,16 +88,17 @@ char *argv[];
if (!dir) dir = getenv("NETHACKDIR");
if (!dir) dir = getenv("HACKDIR");
-#if defined(SECURE) && !defined(VMS)
+# if defined(SECURE) && !defined(VMS)
if (dir
-# ifdef HACKDIR
+# ifdef HACKDIR
&& strcmp(dir, HACKDIR)
-# endif
+# endif
) {
(void) setgid(getgid());
(void) setuid(getuid());
}
-#endif /* SECURE && !VMS */
+# endif /* SECURE && !VMS */
+#endif /* DEBIAN */
#ifdef HACKDIR
if (!dir) dir = HACKDIR;
diff --git a/win/tty/termcap.c b/win/tty/termcap.c
index db3579d..2a7aa38 100644
--- a/win/tty/termcap.c
+++ b/win/tty/termcap.c
@@ -41,8 +41,9 @@ struct tc_lcl_data tc_lcl_data = { 0, 0, 0, 0,0, 0,0, FALSE };
STATIC_VAR char *HO, *CL, *CE, *UP, *XD, *BC, *SO, *SE, *TI, *TE;
STATIC_VAR char *VS, *VE;
+STATIC_VAR char *ME;
#if 0
-STATIC_VAR char *MR, *ME;
+STATIC_VAR char *MR;
STATIC_VAR char *MB, *MH;
STATIC_VAR char *MD; /* may already be in use below */
#endif
@@ -158,8 +159,8 @@ int *wid, *hgt;
US = "\033[4m";
# if 0
MR = "\033[7m";
- ME = "\033[0m";
# endif
+ ME = "\033[0m";
TI = HE = SE = UE = "\033[0m";
/* strictly, SE should be 2, and UE should be 24,
but we can't trust all ANSI emulators to be
@@ -288,8 +289,8 @@ int *wid, *hgt;
MB = Tgetstr("mb"); /* blink */
MD = Tgetstr("md"); /* boldface */
MH = Tgetstr("mh"); /* dim */
- ME = Tgetstr("me");
# endif
+ ME = Tgetstr("me");
/* Get rid of padding numbers for HI and HE. Hope they
* aren't really needed!!! HI and HE are ouputted to the
@@ -1082,7 +1083,7 @@ term_end_raw_bold()
void
term_end_color()
{
- xputs(HE);
+ xputs(ME);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/nethack.git
More information about the Pkg-games-commits
mailing list