#!/bin/bash

EXPINPUTIMG=$(echo ../inputs/*.img)
EXPINPUTS=$(echo ../inputs/*.input)
EXPSIM=$(echo ../bin/6502)

if [[ -z $EXPINPUTIMG ]]; then echo "ERROR: can't find input img"; exit -1; fi
if [[ -z $EXPINPUTS ]]; then echo "ERROR: can't find input input files"; exit -1; fi
if [[ -z $EXPSIM ]]; then echo "ERROR: can't find input simulator"; exit -1; fi

EXPPREFIX=${EXPINPUTIMG%%.img}
EXPPREFIX=${EXPPREFIX##../inputs/}

for EXPSTDIN in $EXPINPUTS
do
  EXP="${EXPPREFIX}_${EXPSTDIN##../inputs/}"
  echo "DOING: ${EXPSIM} -t act -o ${EXP}.trc -p ${EXP}.stdout ${EXPINPUTIMG} ${EXP}.oimg <${EXPSTDIN} 2>${EXP}.stderr"
  ${EXPSIM} -t act -o ${EXP}.trc -p ${EXP}.stdout ${EXPINPUTIMG} ${EXP}.oimg <${EXPSTDIN} 2>${EXP}.stderr
done
