/[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 40 by dpavlin, Tue Jul 31 08:41:06 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 $run_for';
10    
11  =head1 NAME  =head1 NAME
12    
# Line 24  our $PC = 0xbeef; Line 26  our $PC = 0xbeef;
26  our ( $A, $P, $X, $Y, $S ) = (0) x 5;  our ( $A, $P, $X, $Y, $S ) = (0) x 5;
27  # Set IPeriod to number of CPU cycles between calls to Loop6502  # Set IPeriod to number of CPU cycles between calls to Loop6502
28  our $IPeriod = 1;  our $IPeriod = 1;
29    # Exec6502 cycles
30    our $run_for = 1;
31    $run_for = 0x42;
32    
33  =head1 init  =head1 init
34    
# Line 32  Called before C<Run6502> Line 37  Called before C<Run6502>
37  =cut  =cut
38    
39  sub init {  sub init {
40          warn "inside init\n";          my $self = shift;
41          print "stdout\n";          warn dump(@_);
42            warn "inside init low-level M6502 from $self\n";
43  };  };
44    
45  =head2 read  =head2 read
# Line 80  sub poke_code { Line 86  sub poke_code {
86          $mem[$addr++] = $_ foreach @_;          $mem[$addr++] = $_ foreach @_;
87  }  }
88    
89    =head2 write_chunk
90    
91      $emu->write_chunk( $address, $chunk_of_data );
92    
93    =cut
94    
95    sub write_chunk {
96            my ($self, $addr, $chunk) = @_;
97            my $len = length($chunk);
98            splice @mem, $addr, $len, unpack('C*', $chunk);
99    }
100    
101  =head2 ram  =head2 ram
102    
103  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 109  Read searies of bytes from memory withou
109  sub ram {  sub ram {
110          my $self = shift;          my $self = shift;
111          my ($from,$to) = @_;          my ($from,$to) = @_;
112            warn "ram($from,$to)\n";
113          if ($from + $to) {          if ($from + $to) {
114                  printf "ram %04x - %04x\n", $from, $to;                  printf "ram %04x - %04x\n", $from, $to;
115                  return $mem[$from .. $to - 1];                  return @mem[$from .. $to - 1];
116          }          }
117          printf "ram %04x\n", $from;          printf "ram %04x\n", $from;
118          return $mem[$from] if defined($from);          return $mem[$from] if defined($from);
119          confess "no from address";          confess "no from address";
120  }  }
121    
122    =head2 push_R
123    
124    called by C<perl.c> to push changes in registars back to perl variables
125    
126    =cut
127    
128    sub push_R {
129            warn "push_R(",dump(@_),")\n";
130            my ( $a, $p, $x, $y, $s, $pc ) = @_;
131            $PC = $pc;
132            $S=$s; $X=$x; $Y=$y; $P=$p; $A=$a;
133            dump_R();
134    }
135    
136    =head2 dump_R
137    
138    helper function which dumps registers
139    
140    =cut
141    
142    sub dump_R {
143            warn sprintf("PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", $PC, $A, $P, $X, $Y, $S);
144    }
145    
146  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26