more windows Makefile tinkering

It looks like the Windows API call for PlaySound using SND_RESOURCE, from a
mingw32 built program, cannot find the resources that are
embeded into the .exe by the mingw32 resource compiler. That works fine
from visual studio.

For now, fall back to not using the SND_RESOURCE flag, use an ordinary
wav file name in the filesystem. Makefile.mingw32 has been modified
to copy the wav files to the binary directory along with the exe.

This probably won't be the final approach, but it will get things
working for now.
This commit is contained in:
nhmall
2023-01-31 00:45:27 -05:00
parent a7b8099ecb
commit ce0a4f60ca
5 changed files with 127 additions and 31 deletions

View File

@@ -251,7 +251,7 @@ MSWIN =../win/win32
WCURSES =../win/curses
WSHR =../win/share
QT =../win/Qt
SNDWAVDIR =../sound/wav
SNDWAVDIR = ../sound/wav
#
# Object directory.
@@ -845,14 +845,6 @@ endif
# Soundlib Support
#==========================================
ifeq "$(HAVE_SOUNDLIB)" "Y"
ifeq "$(NEED_USERSOUNDS)" "Y"
SOUNDLIBDEFS += -DUSER_SOUNDS
endif
ifeq "$(NEED_SEAUTOMAP)" "Y"
SOUNDLIBDEFS += -DSND_SOUNDEFFECTS_AUTOMAP
endif
ifeq "$(NEED_WAV)" "Y"
WAVLIST = se_squeak_A se_squeak_B se_squeak_B_flat se_squeak_C \
se_squeak_D se_squeak_D_flat se_squeak_E \
se_squeak_E_flat se_squeak_F se_squeak_F_sharp \
@@ -875,7 +867,21 @@ WAVLIST = se_squeak_A se_squeak_B se_squeak_B_flat se_squeak_C \
sound_Wooden_Harp_E sound_Wooden_Harp_F \
sound_Wooden_Harp_G
WAVS = $(addprefix $(SNDWAVDIR)/, $(addsuffix .wav, $(WAVLIST)))
ifeq "$(HAVE_SOUNDLIB)" "Y"
ifeq "$(NEED_USERSOUNDS)" "Y"
SOUNDLIBDEFS += -DUSER_SOUNDS
endif
ifeq "$(NEED_SEAUTOMAP)" "Y"
SOUNDLIBDEFS += -DSND_SOUNDEFFECTS_AUTOMAP
endif
ifeq "$(NEED_WAV)" "Y"
$(info Built-in sound file integration included)
#RCFLAGS = --include-dir=$(SNDWAVDIR) --define RCWAV
WAV = $(WAVS)
endif # NEED_WAV
else
$(info No soundlib integration)
endif # HAVE_SOUNDLIB
#==========================================
@@ -953,8 +959,8 @@ $(ONHW)/%.o: $(MSWIN)/%.c $(NHLUAH) | $(ONHW)
$(ONHW)/%.o: $(WSHR)/%.c $(NHLUAH) | $(ONHW)
$(cc) $(CFLAGSW) $< -o$@
$(NHWRES): $(MSWIN)/NetHackW.rc $(BMPS) $(WAVS) $(MSWIN)/NetHack.ico | $(ONHW)
$(rc) --include-dir=$(MSWIN) --include-dir=$(SNDWAVDIR) --input=$< -o$@
$(NHWRES): $(MSWIN)/NetHackW.rc $(BMPS) $(WAV) $(MSWIN)/NetHack.ico | $(ONHW)
$(rc) --include-dir=$(MSWIN) $(RCFLAGS) --input=$< -o$@
$(MSWIN)/tiles.bmp: $(U)tile2bmp.exe $(TILEFILES)
$< $@
@@ -971,7 +977,7 @@ $(ONHW):
@mkdir -p $@
CLEAN_DIR += $(ONHW)
CLEAN_FILE += $(NHWTARGETS) $(NHWOBJS) $(NHWRES) $(BMPS) $(WAVS)
CLEAN_FILE += $(NHWTARGETS) $(NHWOBJS) $(NHWRES) $(BMPS) $(WAV)
#==========================================
# nethack
@@ -1042,8 +1048,8 @@ $(ONH)/%.o: $(TTY)/%.c $(NHLUAH) | $(ONH)
$(ONH)/%.o: $(WCURSES)/%.c $(NHLUAH) | $(ONH)
$(cc) $(CFLAGSNH) $(PDCINCL) $< -o$@
$(NHRES): $(MSWIN)/NetHack.rc $(WAVS) $(MSWIN)/NetHack.ico | $(ONH)
$(rc) --include-dir=$(MSWIN) --include-dir=$(SNDWAVDIR) --input=$< -o$@
$(NHRES): $(MSWIN)/NetHack.rc $(WAV) $(MSWIN)/NetHack.ico | $(ONH)
$(rc) --include-dir=$(MSWIN) $(RCFLAGS) --input=$< -o$@
$(ONH):
@mkdir -p $@
@@ -1069,6 +1075,10 @@ TO_INSTALL = $(GAMEDIR)/NetHack.exe $(RTARGETS) $(GAMEDIRDLLS) \
$(addprefix $(GAMEDIR)/, $(addsuffix .template, sysconf .nethackrc) \
Guidebook.txt NetHack.txt license opthelp record symbols)
ifeq "$(HAVE_SOUNDLIB)" "Y"
TO_INSTALL += $(addprefix $(GAMEDIR)/, $(addsuffix .wav, $(WAVLIST)))
endif
ifeq "$(USE_LUADLL)" "Y"
TO_INSTALL += $(LUADLL)
endif
@@ -1115,6 +1125,9 @@ $(GAMEDIR)/%: $(DOC)/%
$(GAMEDIR)/%: $(MSWSYS)/%
cp $< $@
$(GAMEDIR)/%: $(SNDWAVDIR)/%
cp $< $@
CLEAN_FILE += $(TO_INSTALL)
clean:

View File

@@ -1056,10 +1056,12 @@ void freefakeconsole(void)
}
#endif
static boolean path_buffer_set = FALSE;
static char path_buffer[MAX_PATH];
char *
get_executable_path(void)
{
static char path_buffer[MAX_PATH];
#ifdef UNICODE
{
@@ -1077,9 +1079,22 @@ get_executable_path(void)
if (seperator)
*seperator = '\0';
path_buffer_set = TRUE;
return path_buffer;
}
#ifdef __MINGW32__
char *
exepath(void)
{
char *p = (char *) 0;
if (path_buffer_set)
p = path_buffer;
return p;
}
#endif
char *
translate_path_variables(const char* str, char* buf)
{