--- M6502/M6502.pm 2007/07/31 09:37:01 42 +++ M6502/M6502.pm 2007/07/31 11:14:19 50 @@ -6,7 +6,7 @@ use Data::Dump qw/dump/; use Carp qw/confess/; use Exporter 'import'; -our @EXPORT = qw'@mem $PC $A $P $X $Y $S $IPeriod $run_for'; +our @EXPORT = qw'@mem $PC $A $P $X $Y $S $IPeriod $run_for $debug'; =head1 NAME @@ -14,7 +14,7 @@ =cut -my $debug = 1; +my $debug = 0; our $VERSION = qw(0.0.1); @@ -37,7 +37,6 @@ sub init { my $self = shift; - warn dump(@_); warn "inside init low-level M6502 from $self\n"; }; @@ -52,7 +51,7 @@ sub read { my ($addr) = @_; my $byte = $mem[$addr]; - warn "# read(",dump(@_),") = ",dump( $byte ),"\n" if $debug; + warn "## M6502::read(",dump(@_),") = ",dump( $byte ),"\n" if $debug; return $byte; } @@ -65,7 +64,7 @@ =cut sub write { - warn "# write(",dump(@_),")\n" if $debug; + warn "## M6502::write(",dump(@_),")\n" if $debug; my ($addr,$byte) = @_; $mem[$addr] = $byte; } @@ -82,7 +81,7 @@ sub poke_code { my $self = shift; my $addr = shift; - warn sprintf("# poke_code(%04x,%s)\n", $addr, dump( @_ )) if $self->debug; + warn sprintf("## M6502::poke_code(%04x,%s)\n", $addr, dump( @_ )) if $self->debug; #$mem[$addr++] = $_ foreach @_; $self->write($addr++, $_) foreach @_; } @@ -101,27 +100,6 @@ splice @mem, $addr, $len, unpack('C*', $chunk); } -=head2 ram - -Read searies of bytes from memory without passing through MMU - - $emu->ram( $from, $to ); - -=cut - -sub ram { - my $self = shift; - my ($from,$to) = @_; - warn "ram($from,$to)\n"; - if ($from + $to) { - printf "ram %04x - %04x\n", $from, $to; - return @mem[$from .. $to - 1]; - } - printf "ram %04x\n", $from; - return $mem[$from] if defined($from); - confess "no from address"; -} - =head2 prompt Call this after C<< $run_for >> cycles have been run on processor @@ -140,7 +118,7 @@ =cut sub push_R { - warn "push_R(",dump(@_),")\n"; + warn "## M6502::push_R(",dump(@_),")\n" if $debug; my ( $a, $p, $x, $y, $s, $pc ) = @_; $PC = $pc; $S=$s; $X=$x; $Y=$y; $P=$p; $A=$a; @@ -154,7 +132,7 @@ =cut sub dump_R { - warn sprintf("PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", $PC, $A, $P, $X, $Y, $S); + warn sprintf("## M6502::dump_R PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", $PC, $A, $P, $X, $Y, $S) if $debug; } 1;