/[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 192 by dpavlin, Sat Apr 12 14:20:01 2008 UTC revision 193 by dpavlin, Sat Apr 12 16:18:09 2008 UTC
# Line 39  my $mask = 1; Line 39  my $mask = 1;
39    
40  sub read_tape {  sub read_tape {
41          my $self = shift;          my $self = shift;
42          if ( ! $self->tape ) {  
                 _warn "please load tape!";  
                 return 0;  
         }  
43          my $pos = $self->tape_pos;          my $pos = $self->tape_pos;
44          my $tape = $self->tape;          my $tape = $self->tape;
45          if ( $pos > length( $tape ) ) {  
46                  _warn "end of tape [$pos]";          if ( ! $tape ) {
47                  return -1;                  _warn "please load tape!";
48                    return 0;
49          }          }
50    
51          if ( $c_0 ) {          if ( $c_0 ) {
# Line 64  sub read_tape { Line 62  sub read_tape {
62                  $pos++;                  $pos++;
63                  $self->tape_pos( $pos );                  $self->tape_pos( $pos );
64                  $mask = 1;                  $mask = 1;
65          };          }
66    
67            my $byte = 0;
68            my $tape_len = length( $tape );
69    
70            if ( $pos <= $tape_len ) {
71                    $byte = ord( substr($self->tape,$pos,1) );
72                    warn sprintf("## tape pos %d/%d %.02f%% 0x%04x = %02x\n", $pos, $tape_len, ($pos * 100) / $tape_len, $pos, $byte);
73            } elsif ( $pos  == $tape_len ) {
74                    _warn "end of tape [$pos]";
75            }
76    
         my $byte = ord( substr($self->tape,$pos,1) );  
77          my $bit = $byte & $mask;          my $bit = $byte & $mask;
78  #       warn sprintf("## tape pos %d 0x%04x mask %02x and %02x = %d\n", $pos, $pos, $mask, $byte, $bit); # if $self->trace;          #warn sprintf("## tape pos %d 0x%04x mask %02x and %02x = %d\n", $pos, $pos, $mask, $byte, $bit); # if $self->trace;
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;

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

  ViewVC Help
Powered by ViewVC 1.1.26