/[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 193 by dpavlin, Sat Apr 12 16:18:09 2008 UTC revision 210 by dpavlin, Mon Apr 14 21:16:19 2008 UTC
# Line 69  sub read_tape { Line 69  sub read_tape {
69    
70          if ( $pos <= $tape_len ) {          if ( $pos <= $tape_len ) {
71                  $byte = ord( substr($self->tape,$pos,1) );                  $byte = ord( substr($self->tape,$pos,1) );
                 warn sprintf("## tape pos %d/%d %.02f%% 0x%04x = %02x\n", $pos, $tape_len, ($pos * 100) / $tape_len, $pos, $byte);  
72          } elsif ( $pos  == $tape_len ) {          } elsif ( $pos  == $tape_len ) {
73                  _warn "end of tape [$pos]";                  _warn "end of tape [$pos]";
74          }          }
75    
76          my $bit = $byte & $mask;          my $bit = $byte & $mask;
77          #warn sprintf("## tape pos %d 0x%04x mask %02x and %02x = %d\n", $pos, $pos, $mask, $byte, $bit); # if $self->trace;  
78            warn sprintf("## tape pos %d/%d %.02f%% 0x%04x = %02x\n", $pos, $tape_len, ($pos * 100) / $tape_len, $pos, $byte) if $mask == 1;
79    
80          ( $c_0, $c_1 ) = ( 0x17, 0x17 );          ( $c_0, $c_1 ) = ( 0x17, 0x17 );
81          ( $c_0, $c_1 ) = ( 0x30, 0x30 ) if $bit;          ( $c_0, $c_1 ) = ( 0x30, 0x30 ) if $bit;
# Line 100  sub write_tape { Line 100  sub write_tape {
100    
101  =head2 load_tape  =head2 load_tape
102    
103    $self->load_tape( '/path/to/file' );    $self->load_tape( '/path/to/file', $position );
104    
105  =cut  =cut
106    
107  sub load_tape {  sub load_tape {
108          my $self = shift;          my $self = shift;
109          my $path = shift || return;          my $path = shift || return;
110            my $pos = shift || 0;
111    
112          my $tape = read_file( $path ) || confess "can't load $path: $!";          my $tape = read_file( $path ) || confess "can't load $path: $!";
113          $self->tape_path( $path );          $self->tape_path( $path );
114    
115          $self->tape_pos( 0 );          $self->tape_pos( $pos );
116          $self->tape( $tape );          $self->tape( $tape );
117          warn "loaded tape $path ", -s $path, " bytes\n";          warn "loaded tape $path ", -s $path, " bytes at $pos\n";
118          return 1;          return 1;
119  }  }
120    
# Line 132  sub tape_status { Line 133  sub tape_status {
133    
134          return sprintf(          return sprintf(
135                  "tape file: %s with %d 0x%x bytes, current position: %d 0x%x",                  "tape file: %s with %d 0x%x bytes, current position: %d 0x%x",
136                  $self->tape_path, $size, $size, $self->pos, $self->pos,                  $self->tape_path, $size, $size, $self->tape_pos, $self->tape_pos,
137          );          );
138  }  }
139    

Legend:
Removed from v.193  
changed lines
  Added in v.210

  ViewVC Help
Powered by ViewVC 1.1.26