diff options
Diffstat (limited to 'setup')
-rw-r--r-- | setup/Makefile.am | 3 | ||||
-rw-r--r-- | setup/configfile.c | 28 | ||||
-rw-r--r-- | setup/execute.c | 123 | ||||
-rw-r--r-- | setup/mainmenu.c | 1 | ||||
-rw-r--r-- | setup/sound.c | 18 | ||||
-rw-r--r-- | setup/sound.h | 14 |
6 files changed, 117 insertions, 70 deletions
diff --git a/setup/Makefile.am b/setup/Makefile.am index 22bcb224..92b4e394 100644 --- a/setup/Makefile.am +++ b/setup/Makefile.am @@ -1,7 +1,7 @@ gamesdir = $(prefix)/games -AM_CFLAGS = -I../textscreen -I../src -DINSTALL_DIR="\"$(gamesdir)\"" +AM_CFLAGS = -I../textscreen -I../src @SDLMIXER_CFLAGS@ games_PROGRAMS = chocolate-setup @@ -34,6 +34,7 @@ endif chocolate_setup_LDADD = \ ../wince/libc_wince.a \ ../textscreen/libtextscreen.a \ + @SDLMIXER_LIBS@ \ @LDFLAGS@ .rc.o: diff --git a/setup/configfile.c b/setup/configfile.c index fe3c13de..99ec2e03 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -42,6 +42,8 @@ #include <sys/types.h> #endif +#include "SDL_mixer.h" + #include "config.h" #include "doomfeatures.h" @@ -530,7 +532,15 @@ static void LoadDefaultCollection(default_collection_t *collection) intparm = ParseIntParameter(strparm); defaults[i].untranslated = intparm; - intparm = scantokey[intparm]; + + if (intparm >= 0 && intparm < 128) + { + intparm = scantokey[intparm]; + } + else + { + intparm = 0; + } defaults[i].original_translated = intparm; * (int *) def->location = intparm; @@ -721,5 +731,21 @@ void M_ApplyPlatformDefaults(void) #ifdef _WIN32_WCE M_ApplyWindowsCEDefaults(); #endif + + // Before SDL_mixer version 1.2.11, MIDI music caused the game + // to crash when it looped. If this is an old SDL_mixer version, + // disable MIDI. + +#ifdef __MACOSX__ + { + const SDL_version *v = Mix_Linked_Version(); + + if (SDL_VERSIONNUM(v->major, v->minor, v->patch) + < SDL_VERSIONNUM(1, 2, 11)) + { + snd_musicdevice = SNDDEVICE_NONE; + } + } +#endif } diff --git a/setup/execute.c b/setup/execute.c index 03a4f65c..fb9885fa 100644 --- a/setup/execute.c +++ b/setup/execute.c @@ -55,7 +55,7 @@ #ifdef _WIN32 #define DOOM_BINARY PACKAGE_TARNAME ".exe" #else -#define DOOM_BINARY INSTALL_DIR "/" PACKAGE_TARNAME +#define DOOM_BINARY PACKAGE_TARNAME #endif #ifdef _WIN32 @@ -172,81 +172,69 @@ static unsigned int WaitForProcessExit(HANDLE subprocess) } } -static wchar_t *GetFullExePath(const char *program) +static void ConcatWCString(wchar_t *buf, const char *value) +{ + MultiByteToWideChar(CP_OEMCP, 0, + value, strlen(value) + 1, + buf + wcslen(buf), strlen(value) + 1); +} + +// Build the command line string, a wide character string of the form: +// +// "program" "arg" + +static wchar_t *BuildCommandLine(const char *program, const char *arg) { wchar_t *result; - unsigned int path_len; char *sep; - // Find the full path to the EXE to execute, by taking the path - // to this program and concatenating the EXE name: + result = calloc(strlen(myargv[0]) + strlen(program) + strlen(arg) + 6, + sizeof(wchar_t)); + + wcscpy(result, L"\""); sep = strrchr(myargv[0], DIR_SEPARATOR); - if (sep == NULL) - { - path_len = 0; - result = calloc(strlen(program) + 1, sizeof(wchar_t)); - } - else + if (sep != NULL) { - path_len = sep - myargv[0] + 1; - - result = calloc(path_len + strlen(program) + 1, - sizeof(wchar_t)); - MultiByteToWideChar(CP_OEMCP, 0, - myargv[0], path_len, - result, path_len); - } - - MultiByteToWideChar(CP_OEMCP, 0, - program, strlen(program) + 1, - result + path_len, strlen(program) + 1); - - return result; -} + ConcatWCString(result, myargv[0]); -// Convert command line argument to wchar_t string and add surrounding -// "" quotes: + // Cut off the string after the last directory separator, + // before appending the actual program. -static wchar_t *GetPaddedWideArg(const char *arg) -{ - wchar_t *result; - unsigned int len = strlen(arg); + result[sep - myargv[0] + 2] = '\0'; + + } - // Convert the command line arg to a wide char string: + ConcatWCString(result, program); - result = calloc(len + 3, sizeof(wchar_t)); - MultiByteToWideChar(CP_OEMCP, 0, - arg, len + 1, - result + 1, len + 1); + wcscat(result, L"\" \""); - // Surrounding quotes: + ConcatWCString(result, arg); - result[0] = '"'; - result[len + 1] = '"'; - result[len + 2] = 0; + wcscat(result, L"\""); return result; } static int ExecuteCommand(const char *program, const char *arg) { + STARTUPINFOW startup_info; PROCESS_INFORMATION proc_info; - wchar_t *exe_path; - wchar_t *warg; + wchar_t *command; int result = 0; - exe_path = GetFullExePath(program); - warg = GetPaddedWideArg(arg); + command = BuildCommandLine(program, arg); // Invoke the program: memset(&proc_info, 0, sizeof(proc_info)); + memset(&startup_info, 0, sizeof(startup_info)); + startup_info.cb = sizeof(startup_info); - if (!CreateProcessW(exe_path, warg, - NULL, NULL, FALSE, 0, NULL, NULL, NULL, - &proc_info)) + if (!CreateProcessW(NULL, command, + NULL, NULL, FALSE, 0, NULL, NULL, + &startup_info, &proc_info)) { result = -1; } @@ -260,19 +248,48 @@ static int ExecuteCommand(const char *program, const char *arg) CloseHandle(proc_info.hThread); } - free(exe_path); - free(warg); + free(command); return result; } #else +// Given the specified program name, get the full path to the program, +// assuming that it is in the same directory as this program is. + +static char *GetFullExePath(const char *program) +{ + char *result; + char *sep; + unsigned int path_len; + + sep = strrchr(myargv[0], DIR_SEPARATOR); + + if (sep == NULL) + { + result = strdup(program); + } + else + { + path_len = sep - myargv[0] + 1; + + result = malloc(strlen(program) + path_len + 1); + + strncpy(result, myargv[0], path_len); + result[path_len] = '\0'; + + strcat(result, program); + } + + return result; +} + static int ExecuteCommand(const char *program, const char *arg) { pid_t childpid; int result; - const char *argv[] = { program, arg, NULL }; + const char *argv[3]; childpid = fork(); @@ -280,6 +297,10 @@ static int ExecuteCommand(const char *program, const char *arg) { // This is the child. Execute the command. + argv[0] = GetFullExePath(program); + argv[1] = arg; + argv[2] = NULL; + execv(argv[0], (char **) argv); exit(-1); diff --git a/setup/mainmenu.c b/setup/mainmenu.c index ba85ca1f..4ad1ac02 100644 --- a/setup/mainmenu.c +++ b/setup/mainmenu.c @@ -19,6 +19,7 @@ // 02111-1307, USA. // +#include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/setup/sound.c b/setup/sound.c index 92a6cbae..0ca95b08 100644 --- a/setup/sound.c +++ b/setup/sound.c @@ -27,20 +27,6 @@ #include "sound.h" -enum -{ - SNDDEVICE_NONE = 0, - SNDDEVICE_PCSPEAKER = 1, - SNDDEVICE_ADLIB = 2, - SNDDEVICE_SB = 3, - SNDDEVICE_PAS = 4, - SNDDEVICE_GUS = 5, - SNDDEVICE_WAVEBLASTER = 6, - SNDDEVICE_SOUNDCANVAS = 7, - SNDDEVICE_GENMIDI = 8, - SNDDEVICE_AWE32 = 9, -}; - typedef enum { SFXMODE_DISABLED, @@ -71,13 +57,11 @@ static char *musmode_strings[] = "Native MIDI" }; -#define DEFAULT_MUSIC_DEVICE SNDDEVICE_SB - int snd_sfxdevice = SNDDEVICE_SB; int numChannels = 8; int sfxVolume = 15; -int snd_musicdevice = DEFAULT_MUSIC_DEVICE; +int snd_musicdevice = SNDDEVICE_SB; int musicVolume = 15; int snd_samplerate = 22050; diff --git a/setup/sound.h b/setup/sound.h index 170dda0a..6c366151 100644 --- a/setup/sound.h +++ b/setup/sound.h @@ -22,6 +22,20 @@ #ifndef SETUP_SOUND_H #define SETUP_SOUND_H +enum +{ + SNDDEVICE_NONE = 0, + SNDDEVICE_PCSPEAKER = 1, + SNDDEVICE_ADLIB = 2, + SNDDEVICE_SB = 3, + SNDDEVICE_PAS = 4, + SNDDEVICE_GUS = 5, + SNDDEVICE_WAVEBLASTER = 6, + SNDDEVICE_SOUNDCANVAS = 7, + SNDDEVICE_GENMIDI = 8, + SNDDEVICE_AWE32 = 9, +}; + extern int snd_sfxdevice; extern int numChannels; extern int sfxVolume; |