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 ) { |
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; |