#!/usr/bin/perl -w
#
# Original idea and program (in C) by Rene Schickbauer
#
# Perl version of the Telnet blinkenlight server
# (c) 2003 Wolfgang Dautermann
#
# blinkplayer (c) 2003 Ben Okopnik

use strict;
use Term::ANSIScreen qw/:color :cursor :screen/;

my $file = shift or die "Usage: play.pl <blm.gz file>\n";
#my $screen = <<'+EoT+';
#+EoT+
#
#my ( $author, $name, $description, @moviearray ) = readblm($file);
print cls(), locate( 0, 0 );
#print $screen;
#print "  $author:\n"           if $author;
#print "  $name\n"	       if $name;
#print "  ASCII History of Moving Images\n\n";
#print "  $description\n" if $description;
#sleep 5;		# Show opening screen for 1 second

open(FILE, "zcat $file |") or die "Can not open file: $file \n";
my $l = 0;
while (<FILE>) { 
	if (/^@([0-9]+)/) { select( undef, undef, undef, $1 / 1000 ); $l = 0 }
	elsif ($l < 24)
	 #{ tr/01/ \#/;  print locate( 1 + $l++, 0 ), $_; }
	 { print locate( 1 + $l++, 0 ), $_; }
	 
}
