@@ -119,6 +119,14 @@ def test_skip_if_reg_equal_value(self):
119
119
else :
120
120
self .assertEqual (self .cpu .pc , 0 )
121
121
122
+ def test_skip_if_reg_equal_val_load_long_exception (self ):
123
+ self .cpu .memory [0x0200 ] = 0xF0
124
+ self .cpu .memory [0x0201 ] = 0x00
125
+ self .cpu .v [1 ] = 1
126
+ self .cpu .operand = 0x3101
127
+ self .cpu .skip_if_reg_equal_val ()
128
+ self .assertEqual (0x0204 , self .cpu .pc )
129
+
122
130
def test_skip_if_reg_not_equal_val (self ):
123
131
for register in range (0x10 ):
124
132
for value in range (0 , 0xFF , 0x10 ):
@@ -133,6 +141,14 @@ def test_skip_if_reg_not_equal_val(self):
133
141
else :
134
142
self .assertEqual (self .cpu .pc , 0 )
135
143
144
+ def test_skip_if_reg_not_equal_val_load_long_exception (self ):
145
+ self .cpu .memory [0x0200 ] = 0xF0
146
+ self .cpu .memory [0x0201 ] = 0x00
147
+ self .cpu .v [1 ] = 1
148
+ self .cpu .operand = 0x4102
149
+ self .cpu .skip_if_reg_not_equal_val ()
150
+ self .assertEqual (0x0204 , self .cpu .pc )
151
+
136
152
def test_skip_if_reg_equal_reg (self ):
137
153
for reg_num in range (0x10 ):
138
154
self .cpu .v [reg_num ] = reg_num
@@ -155,6 +171,15 @@ def test_skip_if_reg_equal_reg(self):
155
171
else :
156
172
self .assertEqual (self .cpu .pc , 0 )
157
173
174
+ def test_skip_if_reg_equal_reg_load_long_exception (self ):
175
+ self .cpu .memory [0x0200 ] = 0xF0
176
+ self .cpu .memory [0x0201 ] = 0x00
177
+ self .cpu .v [1 ] = 1
178
+ self .cpu .v [2 ] = 1
179
+ self .cpu .operand = 0x5120
180
+ self .cpu .skip_if_reg_equal_reg ()
181
+ self .assertEqual (0x0204 , self .cpu .pc )
182
+
158
183
def test_move_value_to_reg (self ):
159
184
val = 0x23
160
185
for reg_num in range (0x10 ):
@@ -410,6 +435,15 @@ def test_skip_if_reg_not_equal_reg(self):
410
435
else :
411
436
self .assertEqual (self .cpu .pc , 0 )
412
437
438
+ def test_skip_if_reg_not_equal_reg_load_long_exception (self ):
439
+ self .cpu .memory [0x0200 ] = 0xF0
440
+ self .cpu .memory [0x0201 ] = 0x00
441
+ self .cpu .v [1 ] = 1
442
+ self .cpu .v [2 ] = 2
443
+ self .cpu .operand = 0x9120
444
+ self .cpu .skip_if_reg_not_equal_reg ()
445
+ self .assertEqual (0x0204 , self .cpu .pc )
446
+
413
447
def test_load_index_reg_with_value (self ):
414
448
for value in range (0x10000 ):
415
449
self .cpu .operand = value
@@ -679,6 +713,18 @@ def test_operation_9E_pc_skips_if_key_pressed(self):
679
713
self .assertTrue (key_mock .asssert_called )
680
714
self .assertEqual (2 , self .cpu .pc )
681
715
716
+ def test_operation_9E_pc_skips_if_key_pressed_load_long_exception (self ):
717
+ self .cpu .operand = 0x09E
718
+ self .cpu .v [0 ] = 1
719
+ result_table = [False ] * 512
720
+ self .cpu .memory [0x0200 ] = 0xF0
721
+ self .cpu .memory [0x0201 ] = 0x00
722
+ result_table [pygame .K_1 ] = True
723
+ with mock .patch ("pygame.key.get_pressed" , return_value = result_table ) as key_mock :
724
+ self .cpu .keyboard_routines ()
725
+ self .assertTrue (key_mock .asssert_called )
726
+ self .assertEqual (0x0204 , self .cpu .pc )
727
+
682
728
def test_operation_9E_pc_does_not_skip_if_key_not_pressed (self ):
683
729
self .cpu .operand = 0x09E
684
730
self .cpu .v [0 ] = 1
@@ -699,6 +745,17 @@ def test_operation_A1_pc_skips_if_key_not_pressed(self):
699
745
self .assertTrue (key_mock .asssert_called )
700
746
self .assertEqual (2 , self .cpu .pc )
701
747
748
+ def test_operation_A1_pc_skips_if_key_not_pressed_load_long_exception (self ):
749
+ self .cpu .operand = 0x0A1
750
+ self .cpu .v [0 ] = 1
751
+ result_table = [False ] * 512
752
+ self .cpu .memory [0x0200 ] = 0xF0
753
+ self .cpu .memory [0x0201 ] = 0x00
754
+ with mock .patch ("pygame.key.get_pressed" , return_value = result_table ) as key_mock :
755
+ self .cpu .keyboard_routines ()
756
+ self .assertTrue (key_mock .asssert_called )
757
+ self .assertEqual (0x0204 , self .cpu .pc )
758
+
702
759
def test_operation_A1_pc_does_not_skip_if_key_pressed (self ):
703
760
self .cpu .operand = 0x0A1
704
761
self .cpu .v [0 ] = 1
@@ -749,10 +806,10 @@ def test_execute_logical_instruction_raises_exception_on_unknown_op_codes(self):
749
806
self .cpu .execute_logical_instruction ()
750
807
751
808
def test_misc_routines_raises_exception_on_unknown_op_codes (self ):
752
- self .cpu .operand = 0x0
809
+ self .cpu .operand = 0xF0FF
753
810
with self .assertRaises (UnknownOpCodeException ) as context :
754
811
self .cpu .misc_routines ()
755
- self .assertEqual ("Unknown op-code: 0000 " , str (context .exception ))
812
+ self .assertEqual ("Unknown op-code: F0FF " , str (context .exception ))
756
813
757
814
def test_scroll_down_called (self ):
758
815
self .cpu .operand = 0x00C4
@@ -1006,6 +1063,24 @@ def test_read_subset_regs_integration(self):
1006
1063
self .assertEqual (9 , self .cpu .v [2 ])
1007
1064
self .assertEqual (8 , self .cpu .v [3 ])
1008
1065
1066
+ def test_load_long (self ):
1067
+ self .cpu .index = 0x5000
1068
+ self .cpu .memory [0x0200 ] = 0x12
1069
+ self .cpu .memory [0x0201 ] = 0x34
1070
+ self .cpu .index_load_long ()
1071
+ self .assertEqual (0x1234 , self .cpu .index )
1072
+ self .assertEqual (0x0202 , self .cpu .pc )
1073
+
1074
+ def test_load_long_integration (self ):
1075
+ self .cpu .index = 0x5000
1076
+ self .cpu .memory [0x0200 ] = 0xF0
1077
+ self .cpu .memory [0x0201 ] = 0x00
1078
+ self .cpu .memory [0x0202 ] = 0x12
1079
+ self .cpu .memory [0x0203 ] = 0x34
1080
+ self .cpu .execute_instruction ()
1081
+ self .assertEqual (0x1234 , self .cpu .index )
1082
+ self .assertEqual (0x0204 , self .cpu .pc )
1083
+
1009
1084
# M A I N #####################################################################
1010
1085
1011
1086
0 commit comments