6 |
use blib; |
use blib; |
7 |
use lib './lib'; |
use lib './lib'; |
8 |
|
|
9 |
use Test::More tests => 54; |
use Test::More tests => 92; |
10 |
use Test::Exception; |
use Test::Exception; |
11 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
12 |
|
|
65 |
cmp_ok( M6502::_read($a), '==', $byte, 'M6502::_read' ); |
cmp_ok( M6502::_read($a), '==', $byte, 'M6502::_read' ); |
66 |
} |
} |
67 |
|
|
|
$mem[$_] = 0b11101101 foreach ( 0x6000 .. 0x7ffff ); |
|
|
|
|
68 |
# flip bytes 6502 asm |
# flip bytes 6502 asm |
69 |
my $a = 0x1000; |
my $a = 0x1000; |
70 |
|
|
78 |
0xd9, 0x60, 0x00, |
0xd9, 0x60, 0x00, |
79 |
); |
); |
80 |
|
|
81 |
diag dump_R(); |
my @flip_tests = ( |
82 |
$PC = 0x1000; |
{ fill => 0b11101101, expect => 0b10110111 }, |
83 |
|
{ fill => 0b11101101, expect => 0b10110111, disable_all_callbacks => 1 }, |
84 |
|
{ fill => 0b11110000, expect => 0b00001111, disable_all_callbacks => 1 } |
85 |
|
); |
86 |
|
|
87 |
|
foreach my $test ( @flip_tests ) { |
88 |
|
|
89 |
|
diag "test ",dump( $test ); |
90 |
|
|
91 |
|
is( M6502::disable_all_callbacks(), 0x11, 'disable_all_callbacks' ) if $test->{disable_all_callbacks}; |
92 |
|
|
93 |
|
$mem[$_] = $test->{fill} foreach ( 0x6000 .. 0x7ffff ); |
94 |
|
|
95 |
|
diag dump_R(); |
96 |
|
$PC = 0x1000; |
97 |
|
|
98 |
ok( my $left = M6502::exec( 1 ), 'M6502::exec(1)' ); |
ok( my $left = M6502::exec( 1 ), 'M6502::exec(1)' ); |
99 |
cmp_ok( $PC, '==', 0x1002, 'PC moved' ); |
cmp_ok( $PC, '==', 0x1002, 'PC moved' ); |
100 |
cmp_ok( $left, '==', -1, 'no cycles left' ); |
cmp_ok( $left, '==', -1, 'no cycles left' ); |
101 |
|
|
102 |
ok( ! M6502::exec( 1000 ), 'M6502::exec' ); |
ok( ! M6502::exec( 1000 ), 'M6502::exec' ); |
103 |
cmp_ok( $PC, '==', 0x1016, 'PC moved' ); |
cmp_ok( $PC, '==', 0x1016, 'PC moved' ); |
104 |
|
|
105 |
foreach my $a ( 0x6000 .. 0x600c ) { |
foreach my $a ( 0x6000 .. 0x600c ) { |
106 |
cmp_ok( $mem[$a], '==', 0b10110111, sprintf('flipped %04x',$a) ); |
cmp_ok( $mem[$a], '==', $test->{expect}, sprintf('flipped %04x to %08b',$a, $mem[$a]) ); |
107 |
|
} |
108 |
} |
} |