diff options
author | Twinaphex | 2018-06-26 16:29:32 +0200 |
---|---|---|
committer | GitHub | 2018-06-26 16:29:32 +0200 |
commit | 4423de5973de2e1a243031ee59d997f5e6220a6c (patch) | |
tree | 3c4accc2257f3343bc3f67cf67e47680bd50d608 /hakchi/bin/snes05 | |
parent | b83a86f02139b7aae9dc22149ebd5cbeac32faf4 (diff) | |
parent | b650caa89c2e269b58307f548b89a39640c76dac (diff) | |
download | snes9x2005-4423de5973de2e1a243031ee59d997f5e6220a6c.tar.gz snes9x2005-4423de5973de2e1a243031ee59d997f5e6220a6c.tar.bz2 snes9x2005-4423de5973de2e1a243031ee59d997f5e6220a6c.zip |
Merge pull request #59 from HakchiCloud/master
Added Hakchi platform
Diffstat (limited to 'hakchi/bin/snes05')
-rwxr-xr-x | hakchi/bin/snes05 | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/hakchi/bin/snes05 b/hakchi/bin/snes05 new file mode 100755 index 0000000..c6da74b --- /dev/null +++ b/hakchi/bin/snes05 @@ -0,0 +1,38 @@ +#!/bin/sh + +setFileName(){ + filename="$(readlink -f "$1")" + filebase="$(basename "$filename")" + extension="${filebase##*.}" +} + +getSfrom(){ + local rom="$(hexdump -e '1/4 "%u"' -s8 -n4 "$1")" + local footer="$(hexdump -e '1/4 "%u"' -s20 -n4 "$1")" + local size="$(hexdump -e '1/4 "%u"' -s$((footer+1)) -n4 "$1")" + dd "status=none" "if=$1" "iflag=skip_bytes" "skip=$rom" "bs=$size" "count=1" +} + +setFileName "$1" +shift + +tmppath="/tmp/rom" +rm -rf "$tmppath" +mkdir -p "$tmppath" +cd "$tmppath" + +if [ "$extension" = "7z" ]; then + tiny7zx x "$filename" + filename="$tmppath/$(ls | head -n1)" + filename_str="${filename// /_}" + mv "$filename" "$filename_str" + setFileName "$filename_str" +fi + +if [ "$extension" = "sfrom" ]; then + filename_str="$filebase.sfc" + getSfrom "$filename" > "$filename_str" + setFileName "$filename_str" +fi + +exec retroarch-clover snes9x2005 "$filename" "$@" |