/[VRac]/M6502/t/05-M6502.t
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/t/05-M6502.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 91 by dpavlin, Thu Aug 2 12:37:06 2007 UTC revision 198 by dpavlin, Sun Apr 13 11:05:29 2008 UTC
# Line 6  use strict; Line 6  use strict;
6  use blib;  use blib;
7  use lib './lib';  use lib './lib';
8    
9  use Test::More tests => 36;  use Test::More tests => 164;
10  use Test::Exception;  use Test::Exception;
11  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
12    
# Line 65  foreach my $byte ( 0x00, 0x01, 0xff, 0xa Line 65  foreach my $byte ( 0x00, 0x01, 0xff, 0xa
65          cmp_ok( M6502::_read($a), '==', $byte, 'M6502::_read' );          cmp_ok( M6502::_read($a), '==', $byte, 'M6502::_read' );
66  }  }
67    
68    # flip bytes 6502 asm
 $mem[$_] = 0 foreach ( 0x6000 .. 0x7ffff );  
   
 # invert screen in 6502 asm  
69  my $a = 0x1000;  my $a = 0x1000;
70    
71  $mem[$a++] = $_ foreach (  $mem[$a++] = $_ foreach (
# Line 81  $mem[$a++] = $_ foreach ( Line 78  $mem[$a++] = $_ foreach (
78          0xd9, 0x60, 0x00,          0xd9, 0x60, 0x00,
79  );  );
80    
81  diag dump_R();  my @flip_tests = (
82  $PC = 0x1000;          { fill => 0b11101101, expect => 0b10110111, callbacks => 0x33 },
83            { fill => 0b11101101, expect => 0b10110111, callbacks => 0x22 },
84            { fill => 0b11110000, expect => 0b00001111, callbacks => 0x11 },
85            { fill => 0b11110011, expect => 0b11001111, callbacks => 0x00 },
86    );
87    
88  ok( ! M6502::exec( 1 ), 'M6502::exec(1)' );  foreach my $test ( @flip_tests ) {
 cmp_ok( $PC, '>', 0x1000, 'PC moved' );  
89    
90  diag dump_R();          diag "test ",dump( $test );
91    
92            is( M6502::set_all_callbacks( $test->{callbacks} ), $test->{callbacks}, 'set_all_callbacks' );
93    
94            $mem[$_] = $test->{fill} foreach ( 0x6000 .. 0x7ffff );
95    
96            diag dump_R();
97            $PC = 0x1000;
98    
99  ok( my $left = M6502::exec( 10000 ), 'M6502::exec' );          ok( my $left = M6502::exec( 1 ), 'M6502::exec(1)' );
100            cmp_ok( $PC, '==', 0x1002, 'PC moved' );
101            cmp_ok( $left, '==', -1, 'no cycles left' );
102    
103  diag dump_R(), "cycles left: $left";          ok( ! M6502::exec( 1000 ), 'M6502::exec' );
104            cmp_ok( $PC, '==', 0x1016, 'PC moved' );
105    
106  foreach my $a ( 0x6000 .. 0x6001 ) {          foreach my $a ( 0x6000 .. 0x600c ) {
107          cmp_ok( $mem[$a], '==', 0xff, sprintf('inverted %04x',$a) );                  cmp_ok( $mem[$a], '==', $test->{expect}, sprintf('flipped %04x %08b -> %08b',$a, $test->{fill}, $mem[$a]) );
108                    cmp_ok( M6502::get_callback( $a ), '==', $test->{callbacks}, 'callback' );
109            }
110  }  }

Legend:
Removed from v.91  
changed lines
  Added in v.198

  ViewVC Help
Powered by ViewVC 1.1.26