/[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

Contents of /M6502/M6502.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27 - (show annotations)
Mon Jul 30 15:45:03 2007 UTC (16 years, 9 months ago) by dpavlin
File size: 860 byte(s)
implement memory read and write callbacks to perl
1 package M6502;
2
3 use strict;
4 use warnings;
5
6 use Data::Dump qw/dump/;
7
8 # Dobrica Pavlinusic, <dpavlin@rot13.org> 07/30/07 13:23:19 CEST
9 #
10 # Simple Orao emulation
11
12 my $debug = 1;
13
14 my @mem = (0x42) x 0x10000; # 64M
15
16 # program counter
17 our $PC = 0xbeef;
18 # CPU registars
19 our ( $A, $P, $X, $Y, $S ) = (0) x 5;
20 # Set IPeriod to number of CPU cycles between calls to Loop6502
21 our $IPeriod = 1;
22
23 =head1 init
24
25 Called before C<Run6502>
26
27 =cut
28
29 sub init {
30 warn "inside init\n";
31 print "stdout\n";
32 };
33
34 =head2 read
35
36 Read from memory
37
38 $byte = read( $address );
39
40 =cut
41
42 sub read {
43 my ($addr) = @_;
44 my $byte = $mem[$addr];
45 warn "# read(",dump(@_),") = ",dump( $byte ),"\n" if $debug;
46 return $byte;
47 }
48
49 =head2 write
50
51 Write into emory
52
53 write( $address, $byte );
54
55 =cut
56
57 sub write {
58 warn "# write(",dump(@_),")\n" if $debug;
59 my ($addr,$byte) = @_;
60 $mem[$addr] = $byte;
61 }
62 1;

  ViewVC Help
Powered by ViewVC 1.1.26