add an interface for sound libraries

Groundwork for a more versatile interface for using
sound libraries. A lot of sound libraries work across
multiple platforms.

The current NetHack sound stuff is quite limited.

Binaries can have a variety of window ports linked into
them, and it makes sense to have something similar for
sound.

This tries to set things up in a more soundlib-centric way,
rather than inserting things in a platform-centric way.

It establishes a new top-level directory sound (akin to win
for the window interface routines, or "window-port") where
sound-related additions and sndprocs and support files can be
added and used across platforms.

The default interface is nosound and the 'nosound' interface
is in src/sounds.c

The interface for 'windsound', which contains the same minimal
USER_SOUNDS support using built-in routines that has been in the
windows port for a long time is added to
sound/windsound/windsound.c.

For now, the sound interface support for 'qtsound' has been added
to the existing Qt files win/Qt/qt_bind.h and win/Qt/qt_bind.cpp,
and a note has been placed in sound/qtsound/README.md to avoid
confusion.

New header file added: include/sndprocs.h.
This commit is contained in:
nhmall
2023-01-19 18:51:42 -05:00
parent 6e49372d8f
commit ea4a81901d
24 changed files with 705 additions and 85 deletions

View File

@@ -78,6 +78,7 @@ endif
WINCFLAGS=
WINSRC =
WINOBJ0 =
SND_CFLAGS=
XTRASRC =
XTRAOBJ =
@@ -144,6 +145,7 @@ ifdef WANT_WIN_QT
WINCFLAGS += -DQT_GRAPHICS
WINSRC += $(WINQTSRC)
WINOBJ0 += $(WINQTOBJ)
SNDCFLAGS += -DSND_LIB_QTSOUND -DUSER_SOUNDS
XTRASRC += tile.c
XTRAOBJ += $(TARGETPFX)tile.o
#

View File

@@ -114,9 +114,11 @@ endif #HAVE_NCURSESW
endif #WANT_WIN_CURSES
CFLAGS+= $(WINCFLAGS) #WINCFLAGS set from multiw-2.370
CFLAGS+= $(SNDCFLAGS) #SNDCFLAGS set from multiw-2.370
CFLAGS+= $(NHCFLAGS)
CCXXFLAGS+= $(WINCFLAGS) #WINCFLAGS set from multiw-2.370
CCXXFLAGS+= $(SNDCFLAGS) #SNDCFLAGS set from multiw-2.370
CCXXFLAGS+= $(NHCFLAGS)
VARDATND =

View File

@@ -156,9 +156,11 @@ endif #CURSES_UNIODE=sys
endif #MAKEFILE_SRC
CFLAGS+= $(PKGCFLAGS) $(WINCFLAGS) #WINCFLAGS set from multiw-2.370
CFLAGS+= $(SNDCFLAGS) #SNDCFLAGS set from multiw-2.370
CFLAGS+= $(NHCFLAGS)
CCXXFLAGS+= $(WINCFLAGS) #WINCFLAGS set from multiw-2.370
CCXXFLAGS+= $(SNDCFLAGS) #SNDCFLAGS set from multiw-2.370
CCXXFLAGS+= $(NHCFLAGS)
VARDATND =

View File

@@ -37,6 +37,15 @@ default: install
GAMEDIR = ../binary
#
#---------------------------------------------------------------
# Do you want to include any sound libraries? If so leave the
# appropriate compile macro below uncommented, or add others
# that are available.
#
SOUNDLIBDEFS = -DWINDSOUND -DUSER_SOUNDS
#
#---------------------------------------------------------------
# Do you want debug information in the executable?
@@ -223,6 +232,7 @@ NHV=$(subst ",,$(NHV1))
# MSWIN - window port files (win32)
# WCURSES - window port files (curses)
# WSHR - Tile support files
# SNDSYS - sound suppport files for win32
# QT - QT window support files
INCL =../include
@@ -231,6 +241,7 @@ DOC =../doc
UTIL =../util
SRC =../src
SSYS =../sys/share
SNDSYS =../sound/windsound
MSWSYS =../sys/windows
TTY =../win/tty
MSWIN =../win/win32
@@ -741,15 +752,15 @@ COREOBJS = $(addsuffix .o, allmain alloc apply artifact attrib ball bones botl c
hack hacklib insight invent isaac64 light lock \
mail makemon mcastu mdlib mhitm mhitu minion mklev mkmap mkmaze mkobj mkroom \
mon mondata monmove monst mplayer mthrowu muse music \
nhlobj nhlsel nhlua ntsound o_init objects objnam options \
nhlobj nhlsel nhlua windsound o_init objects objnam options \
pager pickup pline polyself potion pray priest quest questpgr \
random read rect region restore rip rnd role rumors \
safeproc save sfstruct shk shknam sit sounds sp_lev spell steal steed symbols sys \
teleport timeout topten track trap u_init uhitm utf8map vault version vision \
weapon were wield windmain windows windsys wizard worm worn write zap)
CFLAGSW = $(CFLAGS) $(CFLAGSXTRA) $(COMMONDEF) $(DLBFLG) -DTILES -D_WINDOWS -DMSWIN_GRAPHICS -DSAFEPROCS -DNOTTYGRAPHICS
CPPFLAGSW = $(CFLAGS) $(CPPFLAGSXTRA) $(COMMONDEF) $(DLBFLG) -DTILES -D_WINDOWS -DMSWIN_GRAPHICS -DSAFEPROCS -DNOTTYGRAPHICS
CFLAGSW = $(CFLAGS) $(CFLAGSXTRA) $(COMMONDEF) $(DLBFLG) -DTILES -D_WINDOWS -DMSWIN_GRAPHICS -DSAFEPROCS -DNOTTYGRAPHICS $(SOUNDLIBDEFS)
CPPFLAGSW = $(CFLAGS) $(CPPFLAGSXTRA) $(COMMONDEF) $(DLBFLG) -DTILES -D_WINDOWS -DMSWIN_GRAPHICS -DSAFEPROCS -DNOTTYGRAPHICS $(SOUNDLIBDEFS)
ONHW = $(O)nethackw
NHWONLY = $(addsuffix .o, mhaskyn mhdlg mhfont mhinput mhmain mhmap mhmenu \
@@ -786,6 +797,9 @@ $(ONHW)/cppregex.o: $(SSYS)/cppregex.cpp $(NHLUAH) | $(ONHW)
$(ONHW)/%.o: $(SSYS)/%.c $(NHLUAH) | $(ONHW)
$(cc) $(CFLAGSW) $< -o$@
$(ONHW)/%.o: $(SNDSYS)/%.c $(NHLUAH) | $(ONHW)
$(cc) $(CFLAGSW) $< -o$@
$(ONHW)/%.o: $(MSWSYS)/%.c $(NHLUAH) | $(ONHW)
$(cc) $(CFLAGSW) $< -o$@
@@ -814,8 +828,8 @@ CLEAN_FILE += $(NHWTARGETS) $(NHWOBJS) $(NHWRES) $(BMPS)
#==========================================
# nethack
#==========================================
CFLAGSNH = $(CFLAGSU) $(CFLAGSXTRA) -DNO_TILE_C -DSAFEPROCS -D_LIB -DWIN32CON
CPPFLAGSNH = $(CFLAGSU) $(CPPFLAGSXTRA) -DNO_TILE_C -DSAFEPROCS -D_LIB -DWIN32CON
CFLAGSNH = $(CFLAGSU) $(CFLAGSXTRA) -DNO_TILE_C -DSAFEPROCS -D_LIB -DWIN32CON $(SOUNDLIBDEFS)
CPPFLAGSNH = $(CFLAGSU) $(CPPFLAGSXTRA) -DNO_TILE_C -DSAFEPROCS -D_LIB -DWIN32CON $(SOUNDLIBDEFS)
ONH = $(O)nethack
@@ -855,6 +869,9 @@ $(ONH)/cppregex.o: $(SSYS)/cppregex.cpp $(NHLUAH) | $(ONH)
$(ONH)/%.o: $(SSYS)/%.c $(NHLUAH) | $(ONH)
$(cc) $(CFLAGSNH) $< -o$@
$(ONH)/%.o: $(SNDSYS)/%.c $(NHLUAH) | $(ONH)
$(cc) $(CFLAGSNH) $< -o$@
$(ONH)/%.o: $(MSWSYS)/%.c $(NHLUAH) | $(ONH)
$(cc) $(CFLAGSNH) $< -o$@

View File

@@ -66,6 +66,9 @@ $(ONHW)/cppregex.d: $(SSYS)/cppregex.cpp $(NHLUAH) | $(ONHW)
$(ONHW)/%.d: $(SSYS)/%.c $(NHLUAH) | $(ONHW)
$(cce) $(CFLAGSW) $< -o$@
$(ONHW)/%.d: $(SNDSYS)/%.c $(NHLUAH) | $(ONHW)
$(cce) $(CFLAGSW) $< -o$@
$(ONHW)/%.d: $(MSWSYS)/%.c $(NHLUAH) | $(ONHW)
$(cce) $(CFLAGSW) $< -o$@
@@ -84,6 +87,9 @@ $(ONH)/cppregex.d: $(SSYS)/cppregex.cpp $(NHLUAH) | $(ONH)
$(ONH)/%.d: $(SSYS)/%.c $(NHLUAH) | $(ONH)
$(cce) $(CFLAGSNH) $< -o$@
$(ONH)/%.d: $(SNDSYS)/%.c $(NHLUAH) | $(ONH)
$(cce) $(CFLAGSNH) $< -o$@
$(ONH)/%.d: $(MSWSYS)/%.c $(NHLUAH) | $(ONH)
$(cce) $(CFLAGSNH) $< -o$@

View File

@@ -443,7 +443,7 @@ HACKINCL = $(INCL)\align.h $(INCL)\artifact.h $(INCL)\artilist.h \
$(INCL)\timeout.h $(INCL)\tradstdc.h $(INCL)\trap.h \
$(INCL)\unixconf.h $(INCL)\vision.h $(INCL)\vmsconf.h \
$(INCL)\wintty.h $(INCL)\wincurs.h $(INCL)\winX.h \
$(INCL)\winprocs.h $(INCL)\wintype.h $(INCL)\you.h \
$(INCL)\winprocs.h $(INCL)\sndprocs.h $(INCL)\wintype.h $(INCL)\you.h \
$(INCL)\youprop.h
# all .c that are part of the main NetHack program and are not operating- or
@@ -523,7 +523,7 @@ MDLIBTTY = $(OTTY)mdlib.o
DLBOBJTTY = $(OTTY)dlb.o
REGEXTTY = $(OTTY)cppregex.o
LUAOBJTTY = $(OTTY)nhlua.o $(OTTY)nhlsel.o $(OTTY)nhlobj.o
SOUNDTTY = $(OTTY)ntsound.o
SOUNDTTY = $(OTTY)windsound.o
VVOBJTTY = $(OTTY)version.o
SOBJTTY = $(OTTY)windmain.o $(OTTY)windsys.o $(OTTY)win10.o \
@@ -588,7 +588,7 @@ MDLIBGUI = $(OGUI)mdlib.o
DLBOBJGUI = $(OGUI)dlb.o
REGEXGUI = $(OGUI)cppregex.o
LUAOBJGUI = $(OGUI)nhlua.o $(OGUI)nhlsel.o $(OGUI)nhlobj.o
SOUNDGUI = $(OGUI)ntsound.o
SOUNDGUI = $(OGUI)windsound.o
VVOBJGUI = $(OGUI)version.o
SOBJGUI = $(OGUI)windmain.o $(OGUI)windsys.o $(OGUI)win10.o \
@@ -650,6 +650,8 @@ OPTIONS_FILE = $(DAT)\options
DLBOBJ_HOST = $(OTTY)dlb$(HOST).o
!ENDIF
SOUNDLIBDEFS = -DSND_LIB_WINDSOUND -DUSER_SOUNDS
#==========================================
# Header file macros
#==========================================
@@ -675,7 +677,8 @@ HACK_H = $(INCL)\hack.h $(CONFIG_H) $(INCL)\lint.h $(INCL)\align.h \
$(INCL)\obj.h $(INCL)\engrave.h $(INCL)\you.h \
$(INCL)\attrib.h $(INCL)\monst.h $(INCL)\mextra.h \
$(INCL)\skills.h $(INCL)\timeout.h $(INCL)\trap.h \
$(INCL)\flag.h $(INCL)\winprocs.h $(INCL)\sys.h
$(INCL)\flag.h $(INCL)\winprocs.h $(INCL)\sndprocs.h \
$(INCL)\sys.h
TILE_H = ..\win\share\tile.h
@@ -898,8 +901,8 @@ INCLDIR= /I..\include /I..\sys\windows $(LUAINCL)
# Util and console builds
#==========================================
CFLAGS = $(ctmpflags) $(INCLDIR) $(DLBDEF) -DSAFEPROCS
CPPFLAGS = $(cpptmpflags) $(INCLDIR) $(DLBDEF) -DSAFEPROCS
CFLAGS = $(ctmpflags) $(INCLDIR) $(DLBDEF) -DSAFEPROCS $(SOUNDLIBDEFS)
CPPFLAGS = $(cpptmpflags) $(INCLDIR) $(DLBDEF) -DSAFEPROCS $(SOUNDLIBDEFS)
LFLAGS = $(lflags) $(conlibs) $(MACHINE)
#==========================================
@@ -942,6 +945,16 @@ DLB =
{$(SRC)}.c{$(OBJUTIL)}.o:
$(Q)$(CC) $(CFLAGS) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<
#==========================================
# Rules for files in sound\wind
#==========================================
{..\sound\windsound}.c{$(OBJTTY)}.o:
$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(TTYDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<
{..\sound\windsound}.c{$(OBJGUI)}.o:
$(Q)$(CC) $(CFLAGS) -I$(WSHR) $(GUIDEF) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $<
#==========================================
# Rules for files in sys\share
#==========================================
@@ -1735,14 +1748,14 @@ $(OLUA)lapi.o: $(LUASRC)\lapi.c
$(OTTY)consoletty.o: $(MSWSYS)\consoletty.c $(WINDHDR) $(HACK_H) $(TILE_H)
$(OTTY)win10.o: $(MSWSYS)\win10.c $(WINDHDR) $(HACK_H)
$(OTTY)windsys.o: $(MSWSYS)\windsys.c $(WINDHDR) $(HACK_H)
$(OTTY)ntsound.o: $(MSWSYS)\ntsound.c $(WINDHDR) $(HACK_H)
$(OTTY)windsound.o: ..\sound\windsound\windsound.c $(HACK_H)
$(OTTY)windmain.o: $(MSWSYS)\windmain.c $(WINDHDR) $(HACK_H)
$(OTTY)safeproc.o: $(WSHR)\safeproc.c $(WINDHDR) $(HACK_H)
$(OGUI)consoletty.o: $(MSWSYS)\consoletty.c $(WINDHDR) $(HACK_H) $(TILE_H)
$(OGUI)win10.o: $(MSWSYS)\win10.c $(WINDHDR) $(HACK_H)
$(OGUI)windsys.o: $(MSWSYS)\windsys.c $(WINDHDR) $(HACK_H)
$(OGUI)ntsound.o: $(MSWSYS)\ntsound.c $(WINDHDR) $(HACK_H)
$(OGUI)windsound.o: ..\sound\windsound\windsound.c $(HACK_H)
$(OGUI)windmain.o: $(MSWSYS)\windmain.c $(WINDHDR) $(HACK_H)
$(OGUI)safeproc.o: $(WSHR)\safeproc.c $(WINDHDR) $(HACK_H)
@@ -2046,7 +2059,7 @@ MOCPATH = moc.exe
# $(INCL)\obj.h $(INCL)\engrave.h $(INCL)\you.h \
# $(INCL)\attrib.h $(INCL)\monst.h $(INCL)\mextra.h \
# $(INCL)\skills.h $(INCL)\timeout.h $(INCL)\flag.h \
# $(INCL)\winprocs.h $(INCL)\sys.h
# $(INCL)\winprocs.h $(INCL)\sndprocs.h $(INCL)\sys.h
# touch $(HACK_H)
#
$(OTTY)pcmain.o: ..\sys\share\pcmain.c $(HACK_H) $(INCL)\dlb.h
@@ -2465,7 +2478,7 @@ MOCPATH = moc.exe
# $(INCL)\obj.h $(INCL)\engrave.h $(INCL)\you.h \
# $(INCL)\attrib.h $(INCL)\monst.h $(INCL)\mextra.h \
# $(INCL)\skills.h $(INCL)\timeout.h $(INCL)\flag.h \
# $(INCL)\winprocs.h $(INCL)\sys.h
# $(INCL)\winprocs.h $(INCL)\sndprocs.h $(INCL)\sys.h
# touch $(HACK_H)
#
$(OGUI)pcmain.o: ..\sys\share\pcmain.c $(HACK_H) $(INCL)\dlb.h

View File

@@ -590,6 +590,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
windowtype = gc.chosen_windowtype;
}
choose_windows(windowtype);
assign_soundlib(soundlib_windsound);
u.uhp = 1; /* prevent RIP on early quits */
u.ux = 0; /* prevent flush_screen() */