/[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 132 by dpavlin, Sat Aug 4 21:04:05 2007 UTC revision 145 by dpavlin, Sun Aug 5 13:27:27 2007 UTC
# Line 19  Tape - implement tape reader/recorder Line 19  Tape - implement tape reader/recorder
19    
20  =head2 read_tape  =head2 read_tape
21    
22    $self->read_tape;    my $byte = $self->read_tape;
23    
24  =cut  =cut
25    
# Line 33  sub _warn { Line 33  sub _warn {
33          }          }
34  }  }
35    
 my @tape_bits;  
   
36  sub read_tape {  sub read_tape {
37          my $self = shift;          my $self = shift;
38          if ( ! $self->tape ) {          if ( ! $self->tape ) {
# Line 48  sub read_tape { Line 46  sub read_tape {
46                  return -1;                  return -1;
47          }          }
48    
49          if ( ! @tape_bits ) {          my $byte = ord( substr($self->tape,$pos,1) );
50                  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;  
51    
52                  $pos++;          $pos++;
53                  $self->tape_pos( $pos );          $self->tape_pos( $pos );
54    
55                  @tape_bits = split(//, unpack("B8",$byte) );          return $byte;
56          }  }
57          my $bit = shift @tape_bits ? 0xff : 0x00;  
58          warn "\t$bit\n" if $self->trace;  =head2 write_tape
59          return $bit;  
60      $self->write_tape( $byte );
61    
62    =cut
63    
64    
65    sub write_tape {
66            my ( $self, $byte ) = @_;
67    
68            $self->append_to_file( 'tape.dmp', chr($byte) );
69    
70            return $byte;
71  }  }
72    
73  =head2 load_tape  =head2 load_tape
# Line 81  sub load_tape { Line 89  sub load_tape {
89          return 1;          return 1;
90  }  }
91    
92    =head1 SEE ALSO
93    
94    L<VRac>
95    
96    =cut
97    
98  1;  1;

Legend:
Removed from v.132  
changed lines
  Added in v.145

  ViewVC Help
Powered by ViewVC 1.1.26