/[VRac]/M6502/M6502.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /M6502/M6502.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 27 by dpavlin, Mon Jul 30 15:45:03 2007 UTC revision 29 by dpavlin, Mon Jul 30 17:32:41 2007 UTC
# Line 4  use strict; Line 4  use strict;
4  use warnings;  use warnings;
5    
6  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
7    use Carp qw/confess/;
8    
9  # Dobrica Pavlinusic, <dpavlin@rot13.org> 07/30/07 13:23:19 CEST  =head1 NAME
10  #  
11  # Simple Orao emulation  M6502 - perl bindings for 6502 emulator
12    
13    =cut
14    
15  my $debug = 1;  my $debug = 1;
16    
17  my @mem = (0x42) x 0x10000;     # 64M  our $VERSION = qw(0.0.1);
18    
19    our @mem = (0xff) x 0x10000;    # 64M
20    
21  # program counter  # program counter
22  our $PC = 0xbeef;  our $PC = 0xbeef;
# Line 59  sub write { Line 64  sub write {
64          my ($addr,$byte) = @_;          my ($addr,$byte) = @_;
65          $mem[$addr] = $byte;          $mem[$addr] = $byte;
66  }  }
67    
68    =head2 poke_code
69    
70    Write series of bytes into memory without passing through MMU
71    
72      $emu->poke_code( 0xbeef, 0xff, 0x00, 0xff, 0x00, 0xaa );
73    
74    =cut
75    
76    sub poke_code {
77            my $self = shift;
78            my $addr = shift;
79            warn sprintf("# poke_code(%04x,%s)\n", $addr, dump( @_ )) if $self->debug;
80            $mem[$addr++] = $_ foreach @_;
81    }
82    
83    =head2 ram
84    
85    Read searies of bytes from memory without passing through MMU
86    
87      $emu->ram( $from, $to );
88    
89    =cut
90    
91    sub ram {
92            my $self = shift;
93            my ($from,$to) = @_;
94            if ($from + $to) {
95                    #printf "ram %04x - %04x\n", $from, $to;
96                    return $mem[$from .. $to - 1];
97            }
98            return $mem[$from] if defined($from);
99            confess "no from address";
100    }
101    
102  1;  1;

Legend:
Removed from v.27  
changed lines
  Added in v.29

  ViewVC Help
Powered by ViewVC 1.1.26