--- M6502/M6502.pm 2007/07/30 15:45:03 27 +++ M6502/M6502.pm 2007/07/30 17:32:41 29 @@ -4,14 +4,19 @@ use warnings; use Data::Dump qw/dump/; +use Carp qw/confess/; -# Dobrica Pavlinusic, 07/30/07 13:23:19 CEST -# -# Simple Orao emulation +=head1 NAME + +M6502 - perl bindings for 6502 emulator + +=cut my $debug = 1; -my @mem = (0x42) x 0x10000; # 64M +our $VERSION = qw(0.0.1); + +our @mem = (0xff) x 0x10000; # 64M # program counter our $PC = 0xbeef; @@ -59,4 +64,39 @@ my ($addr,$byte) = @_; $mem[$addr] = $byte; } + +=head2 poke_code + +Write series of bytes into memory without passing through MMU + + $emu->poke_code( 0xbeef, 0xff, 0x00, 0xff, 0x00, 0xaa ); + +=cut + +sub poke_code { + my $self = shift; + my $addr = shift; + warn sprintf("# poke_code(%04x,%s)\n", $addr, dump( @_ )) if $self->debug; + $mem[$addr++] = $_ foreach @_; +} + +=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) = @_; + if ($from + $to) { + #printf "ram %04x - %04x\n", $from, $to; + return $mem[$from .. $to - 1]; + } + return $mem[$from] if defined($from); + confess "no from address"; +} + 1;