3 |
use strict; |
use strict; |
4 |
use warnings; |
use warnings; |
5 |
|
|
6 |
|
use Data::Dump qw/dump/; |
7 |
|
|
8 |
# Dobrica Pavlinusic, <dpavlin@rot13.org> 07/30/07 13:23:19 CEST |
# Dobrica Pavlinusic, <dpavlin@rot13.org> 07/30/07 13:23:19 CEST |
9 |
# |
# |
10 |
# Simple Orao emulation |
# Simple Orao emulation |
11 |
|
|
12 |
my $mem = (0) x 0x10000; # 64M |
my $debug = 1; |
13 |
|
|
14 |
|
my @mem = (0x42) x 0x10000; # 64M |
15 |
|
|
16 |
# program counter |
# program counter |
17 |
our $PC = 0xbeef; |
our $PC = 0xbeef; |
18 |
# CPU registars |
# CPU registars |
19 |
our ( $A, $P, $X, $Y, $S ) = (0) x 5; |
our ( $A, $P, $X, $Y, $S ) = (0) x 5; |
20 |
# Set IPeriod to number of CPU cycles between calls to Loop6502 |
# Set IPeriod to number of CPU cycles between calls to Loop6502 |
21 |
our $IPeriod = 20000; |
our $IPeriod = 1; |
22 |
|
|
23 |
=head1 init |
=head1 init |
24 |
|
|
30 |
warn "inside init\n"; |
warn "inside init\n"; |
31 |
print "stdout\n"; |
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; |
1; |