From edbad04ca69126b6756dcb986caef864f27984c6 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Fri, 1 Dec 2023 19:01:03 -0600 Subject: [PATCH] Multiple audio track support added to command line and games.dat. --- CHANGELOG.txt | 9 ++++++++- INSTALL.txt | 41 +++++++++++++++++++++-------------------- assets/Framework.singe | 6 ++++-- src/main.c | 16 ++++++++++++---- src/singe.c | 10 ++++++++++ src/singe.h | 1 + 6 files changed, 56 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6aeb40e6e..754042ec0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -16,6 +16,10 @@ New Features - Optional sprite anti-aliasing. +- Multiple audio track support for videos. New command line options to select + which default audio track you want (-o or --audio). For games with multiple + languages, you can specify AUDIO_TRACK in the games.dat as well. + - SINGE_DEAD_ZONE global variable now available based on the DEAD_ZONE controller configuration option. @@ -55,6 +59,9 @@ Fixes - Framework.singe was missing keyboard mode constants. MODE_NORMAL and MODE_FULL are now included. +- SINGE 2.00 added two new input events but never had them in the framework. + SWITCH_BUTTON4 and SWITCH_TILT are now available. + - Taking screenshots could sometimes crash Singe. - PNG files no longer generate warnings on the console. @@ -65,4 +72,4 @@ Fixes - Building Singe depended on a lot of undocumented software cobbled together from other projects. This has been vastly improved and should be usable by - actual humans now. + actual humans now. Humans running Linux anyway. diff --git a/INSTALL.txt b/INSTALL.txt index 40797a9d4..e6a393a6a 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -32,7 +32,7 @@ For all Singe 2 and later games, it will automatically appear in the menu. To upgrade, back up any changes you may have made to files inside the Singe subdirectory that was generated during installation. (You really shouldn't be changing things in there!) Delete the Singe subdirectory, Menu.bat (or -.sh) and run the new Singe binary with no command line arguments to generate +.sh) and run the new Singe binary with no command line arguments to generate the new files. @@ -45,22 +45,23 @@ COMMAND LINE Usage: Singe-v2.10-Windows-x86_64.exe [OPTIONS] scriptName{.singe} - -a, --aspect=N:D force aspect ratio - -c, --showcalculated show calculated framefile values for debugging - -d, --datadir=PATHNAME alternate location for written files - -e, --volume_nonvldp=PERCENT specify sound effects volume in percent - -f, --fullscreen run in full screen mode - -h, --help this display - -k, --nologos kill the splash screens - -l, --volume_vldp=PERCENT specify laserdisc volume in percent - -m, --nomouse disable mouse - -n, --nocrosshair request game not display gun crosshairs - -p, --program trace Singe execution to screen and file - -s, --nosound, --mutesound mutes all sound - -t, --trace trace script execution to screen and file - -u, --stretch use ugly stretched video - -v, --framefile=FILENAME use an alternate video file - -w, --fullscreen_window run in windowed full screen mode - -x, --xresolution=VALUE specify horizontal resolution - -y, --yresolution=VALUE specify vertical resolution - -z, --noconsole zero console output + -a, --aspect=N:D force aspect ratio + -c, --showcalculated show calculated framefile values for debugging + -d, --datadir=PATHNAME alternate location for written files + -e, --volume_nonvldp=PERCENT specify sound effects volume in percent + -f, --fullscreen run in full screen mode + -h, --help this display + -k, --nologos kill the splash screens + -l, --volume_vldp=PERCENT specify laserdisc volume in percent + -m, --nomouse disable mouse + -n, --nocrosshair request game not display gun crosshairs + -o, --audio=TRACK select default track for audio output + -p, --program trace Singe execution to screen and file + -s, --nosound, --mutesound mutes all sound + -t, --trace trace script execution to screen and file + -u, --stretch use ugly stretched video + -v, --framefile=FILENAME use an alternate video file + -w, --fullscreen_window run in windowed full screen mode + -x, --xresolution=VALUE specify horizontal resolution + -y, --yresolution=VALUE specify vertical resolution + -z, --noconsole zero console output diff --git a/assets/Framework.singe b/assets/Framework.singe index 8033361d9..8a746f080 100644 --- a/assets/Framework.singe +++ b/assets/Framework.singe @@ -429,8 +429,8 @@ SWITCH_GRAB = 23 MOUSE_SINGLE = 100 MOUSE_MANY = 200 -SPRITE_SMOOTH = 1 -SPRITE_PIXELATED = 0 +RENDER_SMOOTH = 1 +RENDER_PIXELATED = 0 -- Singe 1.xx Features ------------------------------------------------------- @@ -460,6 +460,8 @@ SWITCH_SCREENSHOT = 17 SWITCH_QUIT = 18 SWITCH_PAUSE = 19 SWITCH_CONSOLE = 20 +SWITCH_BUTTON4 = 21 -- Added in Singe 2.00 +SWITCH_TILT = 22 -- Added in Singe 2.00 FONT_QUALITY_SOLID = 1 FONT_QUALITY_SHADED = 2 diff --git a/src/main.c b/src/main.c index 2eb463283..ad57164b7 100644 --- a/src/main.c +++ b/src/main.c @@ -171,6 +171,7 @@ ConfigT *createConf(char *exeName, int argc, char *argv[]) { struct Arg_parser parser; static struct ap_Option options[] = { { 'a', "aspect", ap_yes }, +// { 'b', "scalefactor", ap_yes }, { 'c', "showcalculated", ap_no }, { 'd', "datadir", ap_yes }, { 'e', "volume_nonlvdp", ap_yes }, @@ -181,7 +182,7 @@ ConfigT *createConf(char *exeName, int argc, char *argv[]) { { 'l', "volume_vldp", ap_yes }, { 'm', "nomouse", ap_no }, { 'n', "nocrosshair", ap_no }, -// { 'o', "scalefactor", ap_yes }, + { 'o', "audio", ap_yes }, { 'p', "program", ap_no }, { 's', "nosound", ap_no }, { 't', "trace", ap_no }, @@ -229,6 +230,12 @@ ConfigT *createConf(char *exeName, int argc, char *argv[]) { argCount++; break; + // Overscan Zoom + case 'b': + conf->scaleFactor = atoi(arg); + argCount++; + break; + // Show Calculated Frame File Values case 'c': conf->showCalculated = true; @@ -285,9 +292,9 @@ ConfigT *createConf(char *exeName, int argc, char *argv[]) { conf->noCrosshair = true; break; - // Overscan Zoom + // Audio Track Output case 'o': - conf->scaleFactor = atoi(arg); + conf->audioOutputTrack = atoi(arg); argCount++; break; @@ -733,6 +740,7 @@ void showUsage(char *name, char *message) { utilSay("Usage: %s [OPTIONS] scriptName{.singe}", utilGetLastPathComponent(name)); utilSay(""); utilSay(" -a, --aspect=N:D force aspect ratio"); +// utilSay(" -b, --scalefactor=PERCENT reduce screen size for overscan compensation"); utilSay(" -c, --showcalculated show calculated framefile values for debugging"); utilSay(" -d, --datadir=PATHNAME alternate location for written files"); utilSay(" -e, --volume_nonvldp=PERCENT specify sound effects volume in percent"); @@ -743,7 +751,7 @@ void showUsage(char *name, char *message) { utilSay(" -l, --volume_vldp=PERCENT specify laserdisc volume in percent"); utilSay(" -m, --nomouse disable mouse"); utilSay(" -n, --nocrosshair request game not display gun crosshairs"); -// utilSay(" -o, --scalefactor=PERCENT reduce screen size for overscan compensation"); + utilSay(" -o, --audio=TRACK select default track for audio output"); utilSay(" -p, --program trace Singe execution to screen and file"); utilSay(" -s, --nosound, --mutesound mutes all sound"); utilSay(" -t, --trace trace script execution to screen and file"); diff --git a/src/singe.c b/src/singe.c index fb13543a7..8dd4b1790 100644 --- a/src/singe.c +++ b/src/singe.c @@ -2607,6 +2607,10 @@ int32_t apiVideoLoad(lua_State *L) { video->lastFrame = -1; result = _global.nextVideoId++; HASH_ADD_INT(_global.videoList, id, video); + // Select desired default audio track + if (_global.conf->audioOutputTrack < videoGetAudioTracks(video->id)) { + videoSetAudioTrack(video->id, _global.conf->audioOutputTrack); + } } } @@ -3336,6 +3340,8 @@ ConfigT *buildConfFromTable(lua_State *L) { sindenString = strdup(valueString); if (!parseSindenString(&sindenString, c)) c->sindenArgc = 0; free(sindenString); + } else if (strcmp(confKey, "AUDIO_TRACK") == 0) { + c->audioOutputTrack = valueNumber; } // Clean up for next pair @@ -4429,6 +4435,10 @@ void singe(SDL_Window *window, SDL_Renderer *renderer, ConfigT *conf) { progTrace("Starting laserdisc video in stopped state"); videoPlay(_global.videoHandle); _global.discStopped = false; + // Select desired default audio track + if (_global.conf->audioOutputTrack < videoGetAudioTracks(_global.videoHandle)) { + videoSetAudioTrack(_global.videoHandle, _global.conf->audioOutputTrack); + } // Start script progTrace("Compiling %s", _global.conf->scriptFile); diff --git a/src/singe.h b/src/singe.h index 2ab8128a0..0eb4e383f 100644 --- a/src/singe.h +++ b/src/singe.h @@ -71,6 +71,7 @@ typedef struct ConfigS { int32_t yResolution; int32_t sindenArgc; int32_t sindenArgv[SINDEN_OPTION_COUNT]; + int32_t audioOutputTrack; } ConfigT;