--- Tape.pm 2007/08/05 13:27:27 145 +++ Tape.pm 2007/08/06 09:20:20 169 @@ -6,7 +6,7 @@ use warnings; use base qw/Class::Accessor/; -__PACKAGE__->mk_accessors(qw(tape tape_pos tape_rate trace)); +__PACKAGE__->mk_accessors(qw(tape tape_path tape_pos trace)); use File::Slurp; use Carp qw/confess/; @@ -47,7 +47,7 @@ } my $byte = ord( substr($self->tape,$pos,1) ); - warn sprintf("tape pos %d = %02x\n", $pos, $byte) if $self->trace; + warn sprintf("tape pos %d = %02x\n", $pos, $byte); # if $self->trace; $pos++; $self->tape_pos( $pos ); @@ -81,14 +81,33 @@ my $path = shift || return; my $tape = read_file( $path ) || confess "can't load $path: $!"; + $self->tape_path( $path ); $self->tape_pos( 0 ); $self->tape( $tape ); - $self->tape_rate( 512 ); warn "loaded tape $path ", -s $path, " bytes rate ", $self->tape_rate, "\n"; return 1; } +=head tape_status + + print $self->tape_status; + +=cut + +sub tape_status { + my $self = shift; + + return "No tape in (simulated) drive" unless $self->tape; + + my $size = length( $self->tape ); + + return sprintf( + "tape file: %s with %d 0x%x bytes, current position: %d 0x%x", + $self->tape_path, $size, $size, $self->pos, $self->pos, + ); +} + =head1 SEE ALSO L