27 |
my $value = $$self{WRAP}[$index & 0xffff]; |
my $value = $$self{WRAP}[$index & 0xffff]; |
28 |
cluck "read undef value from $index" unless defined($value); |
cluck "read undef value from $index" unless defined($value); |
29 |
# printf "_read(%04x) = %2x %d\n", $index, $value, $value; |
# printf "_read(%04x) = %2x %d\n", $index, $value, $value; |
30 |
$self->{mem_acc}->( $index, 'read', $value ); |
$self->{mmu}->( $index, 'read', $value ); |
31 |
return $value; |
return $value; |
32 |
} |
} |
33 |
|
|
34 |
sub _write { |
sub _write { |
35 |
my ( $self, $index, $value ) = @_; |
my ( $self, $index, $value ) = @_; |
|
if ( $index >= 0x6000 && $index < 0x8000 ) { |
|
|
$self->{vram}->( $index - 0x6000 , $value ); |
|
|
} |
|
|
if ( $index > 0xAFFF ) { |
|
|
printf "access to %04x above affff aborting\n", $index; |
|
|
return -1; |
|
|
} |
|
|
if ( $index == 0x8800 ) { |
|
|
printf "sound ignored: %x\n", $value; |
|
|
} |
|
36 |
confess "write undef value to $index" unless defined($value); |
confess "write undef value to $index" unless defined($value); |
37 |
# printf "_write(%04x) = %2x %d\n", $index, $value, $value; |
# printf "_write(%04x) = %2x %d\n", $index, $value, $value; |
38 |
$self->{mem_acc}->( $index, 'write', $value ); |
$self->{mmu}->( $index, 'write', $value ); |
39 |
$$self{WRAP}[$index] = $value; |
$$self{WRAP}[$index] = $value; |
40 |
} |
} |
41 |
|
|
46 |
my ($class, $args) = @_; |
my ($class, $args) = @_; |
47 |
warn "tiemem",dump( $class, $args ); |
warn "tiemem",dump( $class, $args ); |
48 |
$self{WRAP} = \@ram; |
$self{WRAP} = \@ram; |
49 |
foreach my $p ( qw/vram mem_acc/ ) { |
foreach my $p ( qw/mmu/ ) { |
50 |
$self{$p} = $args->{$p} || die "no $p ?"; |
$self{$p} = $args->{$p} || die "no $p ?"; |
51 |
} |
} |
52 |
return bless \%self, $class; |
return bless \%self, $class; |