/[VRac]/Tape.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Tape.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 109 by dpavlin, Fri Aug 3 10:29:33 2007 UTC revision 110 by dpavlin, Fri Aug 3 12:21:47 2007 UTC
# Line 6  use strict; Line 6  use strict;
6  use warnings;  use warnings;
7    
8  use base qw/Class::Accessor/;  use base qw/Class::Accessor/;
9  __PACKAGE__->mk_accessors(qw(tape tape_pos));  __PACKAGE__->mk_accessors(qw(tape tape_pos tape_rate));
10    
11  use File::Slurp;  use File::Slurp;
12  use Carp qw/confess/;  use Carp qw/confess/;
# Line 33  sub _warn { Line 33  sub _warn {
33          }          }
34  }  }
35    
36    my $loop;
37    
38  sub read_tape {  sub read_tape {
39          my $self = shift;          my $self = shift;
40          if ( ! $self->tape ) {          if ( ! $self->tape ) {
# Line 45  sub read_tape { Line 47  sub read_tape {
47                  _warn "end of tape [$pos]";                  _warn "end of tape [$pos]";
48                  return -1;                  return -1;
49          }          }
50          my $byte = substr($self->tape,$pos++,1);          my $byte = ord(substr($self->tape,$pos,1));
51          $self->tape_pos( $pos );  
52          return ord($byte);          if ( ++$loop % $self->tape_rate == 0 ) {
53                    warn sprintf("tape pos %d = %02x\n", $pos, $byte);
54                    $pos++;
55                    $self->tape_pos( $pos );
56            }
57            return $byte;
58  }  }
59    
60  =head2 load_tape  =head2 load_tape
# Line 64  sub load_tape { Line 71  sub load_tape {
71    
72          $self->tape_pos( 0 );          $self->tape_pos( 0 );
73          $self->tape( $tape );          $self->tape( $tape );
74          warn "loaded tape $path ", -s $path, " bytes\n";          $self->tape_rate( 512 );
75            warn "loaded tape $path ", -s $path, " bytes rate ", $self->tape_rate, "\n";
76          return 1;          return 1;
77  }  }
78    

Legend:
Removed from v.109  
changed lines
  Added in v.110

  ViewVC Help
Powered by ViewVC 1.1.26