/[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 114 by dpavlin, Fri Aug 3 20:01:51 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 @tape_bits;
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);  
51          $self->tape_pos( $pos );          if ( ! @tape_bits ) {
52          return ord($byte);                  my $byte = ord( substr($self->tape,$pos,1) );
53                    warn sprintf("tape pos %d = %02x\n", $pos, $byte);
54    
55                    $pos++;
56                    $self->tape_pos( $pos );
57    
58                    @tape_bits = split(//, unpack("B8",$byte) );
59            }
60            my $bit = shift @tape_bits ? 0xff : 0x00;
61            warn "\t$bit\n";
62            return $bit;
63  }  }
64    
65  =head2 load_tape  =head2 load_tape
# Line 64  sub load_tape { Line 76  sub load_tape {
76    
77          $self->tape_pos( 0 );          $self->tape_pos( 0 );
78          $self->tape( $tape );          $self->tape( $tape );
79          warn "loaded tape $path ", -s $path, " bytes\n";          $self->tape_rate( 512 );
80            warn "loaded tape $path ", -s $path, " bytes rate ", $self->tape_rate, "\n";
81          return 1;          return 1;
82  }  }
83    

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

  ViewVC Help
Powered by ViewVC 1.1.26