/[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 30 by dpavlin, Mon Jul 30 17:56:13 2007 UTC revision 38 by dpavlin, Mon Jul 30 23:28:25 2007 UTC
# Line 5  use warnings; Line 5  use warnings;
5    
6  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
7  use Carp qw/confess/;  use Carp qw/confess/;
8    use Exporter 'import';
9    our @EXPORT = qw'@mem $PC $A $P $X $Y $S $IPeriod';
10    
11  =head1 NAME  =head1 NAME
12    
# Line 32  Called before C<Run6502> Line 34  Called before C<Run6502>
34  =cut  =cut
35    
36  sub init {  sub init {
37          warn "inside init\n";          my $self = shift;
38          print "stdout\n";          warn dump(@_);
39            warn "inside init low-level M6502 from $self\n";
40  };  };
41    
42  =head2 read  =head2 read
# Line 80  sub poke_code { Line 83  sub poke_code {
83          $mem[$addr++] = $_ foreach @_;          $mem[$addr++] = $_ foreach @_;
84  }  }
85    
86    =head2 write_chunk
87    
88      $emu->write_chunk( $address, $chunk_of_data );
89    
90    =cut
91    
92    sub write_chunk {
93            my ($self, $addr, $chunk) = @_;
94            my $len = length($chunk);
95            splice @mem, $addr, $len, unpack('C*', $chunk);
96    }
97    
98  =head2 ram  =head2 ram
99    
100  Read searies of bytes from memory without passing through MMU  Read searies of bytes from memory without passing through MMU
# Line 91  Read searies of bytes from memory withou Line 106  Read searies of bytes from memory withou
106  sub ram {  sub ram {
107          my $self = shift;          my $self = shift;
108          my ($from,$to) = @_;          my ($from,$to) = @_;
109            warn "ram($from,$to)\n";
110          if ($from + $to) {          if ($from + $to) {
111                  printf "ram %04x - %04x\n", $from, $to;                  printf "ram %04x - %04x\n", $from, $to;
112                  return $mem[$from .. $to - 1];                  return @mem[$from .. $to - 1];
113          }          }
114          printf "ram %04x\n", $from;          printf "ram %04x\n", $from;
115          return $mem[$from] if defined($from);          return $mem[$from] if defined($from);
116          confess "no from address";          confess "no from address";
117  }  }
118    
119    =head2 push_R
120    
121    called by C<perl.c> to push changes in registars back to perl variables
122    
123    =cut
124    
125    sub push_R {
126            warn "push_R(",dump(@_),")\n";
127            my ( $a, $p, $x, $y, $s, $pc ) = @_;
128            $PC = $pc;
129            $S=$s; $X=$x; $Y=$y; $P=$p; $A=$a;
130            dump_R();
131    }
132    
133    =head2 dump_R
134    
135    helper function which dumps registers
136    
137    =cut
138    
139    sub dump_R {
140            warn sprintf("PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", $PC, $A, $P, $X, $Y, $S);
141    }
142    
143  1;  1;

Legend:
Removed from v.30  
changed lines
  Added in v.38

  ViewVC Help
Powered by ViewVC 1.1.26