#!/bin/bash #set -x EE6502=${EE6502:=6502} DATADIR=${DATADIR:="Data"} SRCDIR=${SRCDIR:="${DATADIR}/src"} MANIFEST=${MANIFEST:="${SRCDIR}/manifest.txt"} NUMINST=${NUMINST:=1000} [[ ! -d $DATADIR ]] && mkdir -p ${DATADIR} [[ ! -d $SRCDIR ]] && mkdir -p ${SRCDIR} SCRIPTDIR=$(dirname $(readlink -f $0)) MKCODE=${SCRIPTDIR}/mkcode ASM=${SCRIPTDIR}/p65 BMPPGM=${SCRIPTDIR}/../tools/2bmp name=$* name=${name// /_} function usage() { echo "USAGE: $0 [ ...]" exit -1 } if [[ -z $name ]]; then usage fi if ! type -P ${EE6502} > /dev/null; then echo "ERROR: cannot find the 6502 executable (${EE6502}) to generate trace" usage fi if [[ ! -x ${MKCODE} ]]; then echo "ERROR: ${MKCODE} cannot be found or executed" usage fi if [[ ! -x ${BMPPGM} ]]; then echo "ERROR: ${BMPPGM} cannot be found or executed" usage fi src=${SRCDIR}/${name}.s memimg=${SRCDIR}/${name}.img trace=$(mktemp ${DATADIR}/XXXXXXXXXXXXXXXX.svbintrc) # see if data already is in manifest for these parameters # if so exit if grep -q "^${name} " $MANIFEST >/dev/null 2>&1 ; then echo "Data for ${name} already exists" exit 0 fi # else # make source code file ${MKCODE} $@ > ${src} if [[ ! -a ${src} ]]; then echo "ERROR: can't find $src" exit -1 fi # assemble into an image if ! ${ASM} ${src} ${memimg} ; then echo "ERROR: $ASM $src $memimg failed" exit -1 fi if [[ ! -a ${memimg} ]] ; then echo "ERROR: can't find $memimg" exit -1 fi # run image to create trace if ! ${EE6502} -t sv -o ${trace} -c ${NUMINST} ${memimg} /dev/null 2> /dev/null ; then echo "ERROR: $EE6502 failed" exit -1 fi if [[ ! -s ${trace} ]]; then echo "ERROR: $trace is empty" exit -1 fi #( # cd $(dirname ${trace}) # ${BMPPGM} -r $(( $NUMINST + 1 )) $(( 2**16 + 8 )) $(basename ${trace}) #) # add to manifest echo "${name} ${src} ${memimg} ${trace} $(md5sum ${trace}) : ${EE6502} -t sv -o ${trace} -c ${NUMINST} ${memimg} /dev/null 2\> /dev/null" >> ${MANIFEST} # compress to save space gzip -9 $trace gzip -9 $memimg