#!/bin/csh -f

set prg = addTc
set ver	= "Version 1.0"

if($#argv < 5) goto Usage

set fps = 25
set DEBUG = 0

set hour = $1
set min = $2
set sec = $3
set frm = $4
set add = $5

if($DEBUG == 1) echo "Add $add frames to ${hour}:${min}:${sec}:${frm}"

set inhour = `echo "($hour  * (3600 * $fps))" | bc`
set inmin = `echo "($min  * (60 * $fps))" | bc`
set insec = `echo "($sec  * $fps)" | bc`
set infrm = $frm
set totinframes = `echo "($inhour + $inmin + $insec + $infrm)" | bc`
if($DEBUG == 1) echo Totinframes $totinframes
set totoutframes = `echo "($totinframes + $add)" | bc`
if($DEBUG == 1) echo Totoutframes $totoutframes

set newhour = `echo "($totoutframes  / (3600 * $fps))" | bc`
set totoutframes = `echo "($totoutframes  % (3600 * $fps))" | bc`
set newmin = `echo "($totoutframes  / (60 * $fps))" | bc`
set totoutframes = `echo "($totoutframes  % (60 * $fps))" | bc`
set newsec = `echo "($totoutframes  / $fps)" | bc`
set newfrm = `echo "($totoutframes  % $fps)" | bc`
if($newhour < 10) set newhour = 0$newhour
if($newmin < 10) set newmin = 0$newmin
if($newsec < 10) set newsec = 0$newsec
if($newfrm < 10) set newfrm = 0$newfrm
echo $newhour $newmin $newsec $newfrm

exit(0)

#
# Usage
#
Usage:
        echo
        echo "$prg - $ver"
        echo "(c) 1994 The Ray Rebels"
        echo
        echo "Usage:   $prg <TC Hour> <TC Min> <TC Sec> <TC Frames> <Frames to Add> "
	echo
exit(1)
