summaryrefslogtreecommitdiffstats
path: root/games/sms_sdl/sms_sdl.sh
diff options
context:
space:
mode:
author B. Watson2014-01-14 17:15:36 +0100
committer Erik Hanson2014-01-30 06:21:01 +0100
commit8f4f40dc37c0553293567fe33a87a6d26762cd81 (patch)
tree0ae069615fc6aa61530191363bb4d473a98ba6f4 /games/sms_sdl/sms_sdl.sh
parentad722f51d0dc2d2b4bc7f3142ad4acbb90499a72 (diff)
downloadslackbuilds-8f4f40dc37c0553293567fe33a87a6d26762cd81.tar.gz
games/sms_sdl: Added (A Sega Master System and Game Gear Emulator).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'games/sms_sdl/sms_sdl.sh')
-rw-r--r--games/sms_sdl/sms_sdl.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/games/sms_sdl/sms_sdl.sh b/games/sms_sdl/sms_sdl.sh
new file mode 100644
index 0000000000..8efb438fa8
--- /dev/null
+++ b/games/sms_sdl/sms_sdl.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+# 20091011 bkw: Wrapper script for sms_sdl, does the following:
+
+# - Savestates and screenshots will be saved in ~/.sms_sdl/
+# - A ~/.sms_sdl/config file will be read if present, and converted to
+# command-line options for the real sms_sdl binary.
+
+# To make things work properly, we have to run the real emulator binary
+# 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.
+
+sms_exe="/usr/libexec/sms_sdl"
+sms_userdir=~/.sms_sdl
+conf_file="$sms_userdir/config"
+
+romfile=""
+conf_args=""
+
+set -e
+
+mkdir -p $sms_userdir
+
+if [ -e "$conf_file" ]; then
+ while read line; do
+ # remove comments
+ line="${line/\#*/}"
+ case "$line" in
+ "") ;; # ignore empty lines
+ -*)
+ conf_args="$conf_args $line"
+ ;;
+ *)
+ conf_args="$conf_args --$line"
+ ;;
+ esac
+ done < "$conf_file"
+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
+done
+
+set +e
+if [ -z "$romfile" ]; then
+ $sms_exe
+else
+ cd $sms_userdir
+ $sms_exe $conf_args "$romfile"
+ rm -f "$romfile"
+fi