/[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

M6502/Tape.pm revision 110 by dpavlin, Fri Aug 3 12:21:47 2007 UTC Tape.pm revision 132 by dpavlin, Sat Aug 4 21:04:05 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 tape_rate));  __PACKAGE__->mk_accessors(qw(tape tape_pos tape_rate trace));
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;  my @tape_bits;
37    
38  sub read_tape {  sub read_tape {
39          my $self = shift;          my $self = shift;
# Line 47  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          }          }
         my $byte = ord(substr($self->tape,$pos,1));  
50    
51          if ( ++$loop % $self->tape_rate == 0 ) {          if ( ! @tape_bits ) {
52                  warn sprintf("tape pos %d = %02x\n", $pos, $byte);                  my $byte = ord( substr($self->tape,$pos,1) );
53                    warn sprintf("tape pos %d = %02x\n", $pos, $byte) if $self->trace;
54    
55                  $pos++;                  $pos++;
56                  $self->tape_pos( $pos );                  $self->tape_pos( $pos );
57    
58                    @tape_bits = split(//, unpack("B8",$byte) );
59          }          }
60          return $byte;          my $bit = shift @tape_bits ? 0xff : 0x00;
61            warn "\t$bit\n" if $self->trace;
62            return $bit;
63  }  }
64    
65  =head2 load_tape  =head2 load_tape

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

  ViewVC Help
Powered by ViewVC 1.1.26