19 |
|
|
20 |
=head2 read_tape |
=head2 read_tape |
21 |
|
|
22 |
$self->read_tape; |
my $byte = $self->read_tape; |
23 |
|
|
24 |
=cut |
=cut |
25 |
|
|
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 ) { |
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 |
89 |
return 1; |
return 1; |
90 |
} |
} |
91 |
|
|
92 |
|
=head1 SEE ALSO |
93 |
|
|
94 |
|
L<VRac> |
95 |
|
|
96 |
|
=cut |
97 |
|
|
98 |
1; |
1; |