#!/bin/sh
echo $0 $*
progdir=`dirname "$0"`/drastic
cd $progdir

LAUNCHER=$(grep -i "dowork 0x" "/tmp/log/messages" | tail -n 1)

if ! echo "$LAUNCHER" | grep -iq "No Overlay"; then
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$progdir/lib"
    export LD_PRELOAD="./libSDL2-2.0.so.0.2600.1"
fi

echo "=============================================="
echo "==================== DRASTIC ================="
echo "=============================================="

../performance.sh

export HOME="$progdir"
#export SDL_AUDIODRIVER=dsp

DRASTIC_BINARY="./drastic_nn"
if echo "$LAUNCHER" | grep -iq "Bilinear"; then
    DRASTIC_BINARY="./drastic"
    echo "Using bilinear scaling"
else
    DRASTIC_BINARY="./drastic_nn"
    echo "Using nearest neighbour scaling"
fi

$DRASTIC_BINARY "$*"