#!/bin/bash


# pi2parallel pi2|pi2bin|pi2bin2

export infile="$1"
export statfile=${infile}stat.dat

rm $statfile

do_stat()
{
  tr=$1
  if [ $tr -le 10 ]
  then
    tracks=$((tr*2))
  else
    tracks=$((tr*5-30))
  fi
ascfile=tapes/mk/${infile}.asc
tmpin=/tmp/stat_${tracks}_$$.asc
tmpout=/tmp/stat_${tracks}_$$.flx
demofile=/tmp/stat_${tracks}_$$.demo
  sed "s/gulerod/$tracks/g" <$ascfile >$tmpin

cat >$demofile <<EOF
LOADCONFIG configs/drumtjek.gier
HIDE KB1
HIDE KB2
LOADREADER $tmpin
LOADPUNCH $tmpout
SELECT 3 48
WAITINPUT
$(./maketext.sh 'r<')
WAITSTOP
PRESS START
WAITINPUT
FINISHPUNCH
QUIT
EOF
./GIER $demofile
./flx2a <$tmpout | ./pi2binstat.pl >>$statfile
}
export -f do_stat

seq 1 20|parallel --ungroup do_stat


