#!/usr/bin/perl
# framelist.pl
# Display the animation framelist
# Copyright © 1997, Dick Balaska and BuckoSoft, Inc.

$lastframe=998;

$qs=$ENV{'QUERY_STRING'};
print "Content-Type: text/html\n\n";
$title=" - With Minutes" if $qs eq'm';
$title=" - With Seconds" if $qs eq 's';
$title=" - Tight"        if $qs eq 't';
print << "EOT";
<HEAD><TITLE>Bucko's Animation Progress$title</TITLE></HEAD>
<BODY background="/g/backchoo.gif">
<CENTER><H1>Bucko's Animation Progress$title</H1></CENTER>
EOT
if ($qs eq '')
	{print "Without Times ";}
	else
	{print '<A HREF="framelist.pl">Without Times</A> ';}
if ($qs eq 't')
	{print 'Tight ';}
	else
	{print '<A HREF="framelist.pl?t">Tight</A> ';}
if ($qs eq 's')
	{print 'Seconds ';}
	else
	{print '<A HREF="framelist.pl?s">Seconds</A> ';}
if ($qs eq 'm')
	{print "Minutes ";}
	else
	{print '<A HREF="framelist.pl?m">Minutes</A> ';}
print "<HR>";
print "<PRE>";
# print "qs='$qs'\n";

opendir TDIR, "e:/povwin3/BuckoSoft/tteoac/" || die "Can't open dir";
@dir = readdir TDIR;
closedir TDIR;
for ($i=0; $dir[$i]; $i++)
{
	if ($dir[$i] =~ /tteo\d\d\d\d\.ppm/)
	{
		$s = substr($dir[$i], 4, 4);
		$files[$s] = $dir[$i];
		# print "$s $dir[$i]\n";
	}
}
for ($i=1; $i<51; $i++)
{
	for ($j=0; $j<$lastframe; $j+=50)
	{
		next if ($i+$j > $lastframe);
		$s=sprintf("%03d", $i+$j);
		$c='<FONT COLOR="#FF0000">';
		$dtime=0;
		if ($files[$i+$j])
		{
			$c='<FONT COLOR="#000000">';
			($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
	                      $atime,$mtime,$ctime,$blksize,$blocks)
                          = stat("e:/povwin3/BuckoSoft/tteoac/$files[$i+$j]");
			# printf ("size=%d\n", $size);
			$c='<FONT COLOR="#FFFFFF">' if ($size != 230415);
			$dtime=$mtime;
			if ($files[$i+$j-1])
			{
				($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
		                      $atime,$mtime,$ctime,$blksize,$blocks)
                	          = stat("e:/povwin3/BuckoSoft/tteoac/$files[$i+$j-1]");
				$dtime -= $mtime;
			}
			else
			{
				$dtime = 0;
			}
			$dtime = 0 if ($dtime <0);
			$dtime = 0 if ($dtime >9999);
		}
		print "$c$s";
		if ($qs eq '')
		{ print " ";}
		elsif ($qs eq 's')
		{	$ds = sprintf("%4d ", $dtime);
			print "<FONT SIZE=-1> $ds</FONT>";
		}
		elsif ($qs eq 'm')
		{
			$min=$dtime/60;
			if ($min >= 9.95)
			{ $ds= sprintf("%3d ", $min); }
			elsif ($dtime == 0)
			{ $ds = "0   "; }
			else
			{ $ds = sprintf("%2.1f ", $dtime/60); }
			print "<FONT SIZE=-1> $ds</FONT>";
		}
		print "</FONT>";
	}
	print "\n";
}
print "</PRE></BODY></HTML>";
