From 06a8fc715fef1a8f4615164b7b3298517943882c Mon Sep 17 00:00:00 2001 From: Egan Ford Date: Sat, 3 Jun 2017 12:56:07 -0600 Subject: [PATCH] timing updates, added demo.sh (reg speed) --- demo.sh | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ quick.scrp | 13 +++++--- quick.sh | 19 +++++++++--- 3 files changed, 112 insertions(+), 9 deletions(-) create mode 100755 demo.sh diff --git a/demo.sh b/demo.sh new file mode 100755 index 0000000..ff3e2ad --- /dev/null +++ b/demo.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +GAME="$1" +DEMO=0 +BASENAME=$(basename $0) + +if [ "$BASENAME" = "demo.sh" ] +then + DEMO=1 +fi + +RAND=0 +if [ "$GAME" = "random" ] +then + GAME="" + RAND=1 +fi + +ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -i "$GAME" | wc -l) + +if (( RAND == 0 )) +then + if (( ITEMS == 0 )) + then + echo "game $GAME not found" >&2 + exit 1 + fi + + curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -i "$GAME" | nl -nln + + ITEM=1 + if (( ITEMS > 1 )) + then + echo + echo -n "pick one: " + read ITEM + test -z "$ITEM" && ITEM=1 + fi + + LINE=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -ni "$GAME" | head -$ITEM | tail -1 | awk -F: '{print $1}') +else + LINE=$(( RANDOM % ITEMS + 1)) +fi + +GAME=$(curl -sL http://asciiexpress.net/gameserver/links.html | sort | head -$LINE | tail -1 | awk -F\" '{print $4 "," $6}' | sed 's/.html$/.qr.wav/') + +DOWN=$((LINE - 1)) +TITLE=$(echo $GAME | awk -F, '{print $1}') +GAME_URL=$(echo $GAME | awk -F, '{print "http://asciiexpress.net/gameserver/" $2}') + +rm -f quick.aif +echo +echo -n "Downloading $GAME_URL" +echo +curl -sL $GAME_URL | sox - quick.aif +echo + +AUDIOTIME=$(soxi -D quick.aif) + +if ! OUTPUT=$( + osascript quick.scrp \ + gameserverclient.dsk \ + quick.aif \ + c_gameserverdisk_splash.tiff $((5 + DEMO * 10)) \ + c_gameserverdisk_mainscreen.tiff $((5 + DEMO * 10)) \ + $DOWN \ + $( dc <<< "$DEMO $AUDIOTIME * 1.5 + p" ) \ + $DEMO + ) +then + echo FAILED + exit 1 +fi + +if echo $OUTPUT | grep ERROR >/dev/null 2>&1 +then + echo FAILED + echo $OUTPUT + echo + exit 1 +fi + +rm -f quick.aif +echo LAUNCHED +echo + +#xdotool windowfocus $WINDOWID 2>/dev/null +#osascript -e 'activate application "XQuartz"' + diff --git a/quick.scrp b/quick.scrp index d53e33b..f1adf62 100644 --- a/quick.scrp +++ b/quick.scrp @@ -1,5 +1,4 @@ on run argv - set my_path to (system attribute "PWD") & "/" set my_disk to item 1 of argv set my_audio to item 2 of argv @@ -8,6 +7,8 @@ on run argv set my_screen2 to item 5 of argv set my_timeout2 to item 6 of argv set my_down to item 7 of argv + set my_tapedelay to item 8 of argv + set my_demo to item 9 of argv tell application "Virtual ][" activate @@ -36,7 +37,9 @@ on run argv end try -- full speed ahead - set speed to maximum + if (my_demo = "0") then + set speed to maximum + end if -- main screen try @@ -63,8 +66,10 @@ on run argv play my_path & my_audio on device "cassette recorder" delay 1.0 -- full speed ahead - set speed to maximum - delay 1.5 + if (my_demo = "0") then + set speed to maximum + end if + delay my_tapedelay -- normal speed set speed to regular diff --git a/quick.sh b/quick.sh index b37223c..ff3e2ad 100755 --- a/quick.sh +++ b/quick.sh @@ -1,6 +1,13 @@ #!/bin/bash GAME="$1" +DEMO=0 +BASENAME=$(basename $0) + +if [ "$BASENAME" = "demo.sh" ] +then + DEMO=1 +fi RAND=0 if [ "$GAME" = "random" ] @@ -15,7 +22,7 @@ if (( RAND == 0 )) then if (( ITEMS == 0 )) then - echo "no $GAME game found" >&2 + echo "game $GAME not found" >&2 exit 1 fi @@ -48,15 +55,17 @@ echo curl -sL $GAME_URL | sox - quick.aif echo -echo -n Launching $TITLE... +AUDIOTIME=$(soxi -D quick.aif) if ! OUTPUT=$( osascript quick.scrp \ gameserverclient.dsk \ quick.aif \ - c_gameserverdisk_splash.tiff 5 \ - c_gameserverdisk_mainscreen.tiff 5 \ - $DOWN + c_gameserverdisk_splash.tiff $((5 + DEMO * 10)) \ + c_gameserverdisk_mainscreen.tiff $((5 + DEMO * 10)) \ + $DOWN \ + $( dc <<< "$DEMO $AUDIOTIME * 1.5 + p" ) \ + $DEMO ) then echo FAILED