summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-08-04 05:46:18 -0400
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2016-08-13 07:22:55 +0700
commit2b7b2efae33d39b078ba5017cb3afbd2f3f871d6 (patch)
treecc812d1e03150a5d68f5754ecc0bc5f70f39e6d9 /games
parent2c2c487adc2a4455870c031b621430825ba414ee (diff)
downloadslackbuilds-2b7b2efae33d39b078ba5017cb3afbd2f3f871d6.tar.gz
games/sms_sdl: Fix/enhance shell script wrapper.
Diffstat (limited to 'games')
-rw-r--r--games/sms_sdl/README4
-rw-r--r--games/sms_sdl/sms_sdl.SlackBuild5
-rw-r--r--games/sms_sdl/sms_sdl.sh86
3 files changed, 75 insertions, 20 deletions
diff --git a/games/sms_sdl/README b/games/sms_sdl/README
index 7e35d4bc65..1ad0ad2e88 100644
--- a/games/sms_sdl/README
+++ b/games/sms_sdl/README
@@ -5,5 +5,9 @@ it was written to run under DOS. Since Charles Mac Donald released
his emulator under the GPL terms, this emulator has been ported to
different platforms.
+Zipped ROM images are now supported. Only the first ROM image in the
+.zip file will be used. Other files (.txt, etc) in the .zip file are
+allowed and ignored.
+
The sms_sdl.png icon is by finite, from
http://www.pixeljoint.com/pixelart/2312.htm
diff --git a/games/sms_sdl/sms_sdl.SlackBuild b/games/sms_sdl/sms_sdl.SlackBuild
index 304124bd87..9656394de9 100644
--- a/games/sms_sdl/sms_sdl.SlackBuild
+++ b/games/sms_sdl/sms_sdl.SlackBuild
@@ -6,6 +6,9 @@
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
+# 20160804 bkw:
+# - fix and enhance sms_sdl.sh (qv), bump BUILD
+
# 20140907 bkw:
# - use gzipped patches to avoid \r being stripped by SBo git
# - update man page, convert to pod, move to section 6
@@ -16,7 +19,7 @@
PRGNAM=sms_sdl
VERSION=${VERSION:-0.9.4a_r7.1}
-BUILD=${BUILD:-2}
+BUILD=${BUILD:-3}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
diff --git a/games/sms_sdl/sms_sdl.sh b/games/sms_sdl/sms_sdl.sh
index 8efb438fa8..d9a6ff1afd 100644
--- a/games/sms_sdl/sms_sdl.sh
+++ b/games/sms_sdl/sms_sdl.sh
@@ -10,6 +10,14 @@
# with its cwd set to ~/.sms_sdl/, and create a symlink to the ROM file
# in the same directory. After the emu exits, we remove the symlink.
+# 20160804 bkw: various fixes and enhancements.
+# - Make --filter <mode> and --fskip <n> options work from
+# the command line. They work already in a config file, which is why
+# I didn't notice they were broken for *7 years*.
+# - Fix the usage message so it doesn't show the /usr/libexec/ path.
+# - Make the return value of the script match the return value of the emulator.
+# - Add support for single-file zipped ROMs, since I have so many of them.
+
sms_exe="/usr/libexec/sms_sdl"
sms_userdir=~/.sms_sdl
conf_file="$sms_userdir/config"
@@ -19,6 +27,26 @@ conf_args=""
set -e
+usage() {
+ $sms_exe | sed "/^Usage:/s,$sms_exe,sms_sdl,"
+}
+
+unzip_rom() {
+ # extract one file (hopefully a ROM image) from a zip file. if there are
+ # more files (ROMs or otherwise), they will be ignored.
+
+ # look for known filename extensions first, in case there are readme or
+ # file_id or whatever inside the zipfile.
+ romfile="$( zipinfo -1 "$1" | egrep -i '\.(sms|gg|rom|bin)$' | head -1 )"
+
+ # if none found, just grab the first filename and hope for the best.
+ if [ -z "$romfile" ]; then
+ romfile="$( zipinfo -1 "$1" | head -1 )"
+ fi
+
+ unzip "$arg" "$romfile" -d $sms_userdir || exit 1
+}
+
mkdir -p $sms_userdir
if [ -e "$conf_file" ]; then
@@ -38,31 +66,51 @@ if [ -e "$conf_file" ]; then
fi
for arg; do
- case "$arg" in
- -h|-help|--help|-\?)
- $sms_exe
- exit 0
- ;;
-
- --*)
- conf_args="$conf_args $arg"
- ;;
-
- *)
- if [ -z "$romfile" ]; then
- arg="$( readlink -f "$arg" )"
- romfile="$( basename "$arg" )"
- ( cd $sms_userdir ; rm -f "$romfile" ; ln -s "$arg" . )
- fi
- ;;
- esac
+ if [ "$needparam" = "1" ]; then
+ conf_args="$conf_args $arg"
+ needparam=0
+ else
+ case "$arg" in
+ -h|-help|--help|-\?)
+ usage
+ exit 0
+ ;;
+
+ --filter|--fskip)
+ conf_args="$conf_args $arg"
+ needparam=1
+ ;;
+
+ --*)
+ conf_args="$conf_args $arg"
+ ;;
+
+ *)
+ if [ -z "$romfile" ]; then
+ case "$arg" in
+ *.zip|*.ZIP*|*.Zip)
+ unzip_rom "$arg" # sets romfile
+ ;;
+ *)
+ arg="$( readlink -f "$arg" )"
+ romfile="$( basename "$arg" )"
+ ( cd $sms_userdir ; rm -f "$romfile" ; ln -s "$arg" . )
+ esac
+ fi
+ ;;
+ esac
+ fi
done
set +e
if [ -z "$romfile" ]; then
- $sms_exe
+ usage
+ exit 1
else
cd $sms_userdir
+ #echo $sms_exe $conf_args "$romfile"
$sms_exe $conf_args "$romfile"
+ rv="$?"
rm -f "$romfile"
+ exit $rv
fi