@@ -21,7 +21,7 @@ public class CPU {
21
21
22
22
public int additionalCycles = 0 ;
23
23
24
- public Instruction [] lookup = new Instruction [0xFF ];
24
+ public Instruction [] lookup = new Instruction [0x100 ];
25
25
26
26
public CPU () {
27
27
reset ();
@@ -95,14 +95,14 @@ public CPU() {
95
95
lookup [0xE4 ] = new Instruction ("CPX" ,"ZPP" ,3 );
96
96
lookup [0xEC ] = new Instruction ("CPX" ,"ABS" ,4 );
97
97
98
- lookup [0xC0 ] = new Instruction ("CPX " ,"IMM" ,2 );
99
- lookup [0xC4 ] = new Instruction ("CPX " ,"ZPP" ,3 );
100
- lookup [0xCC ] = new Instruction ("CPX " ,"ABS" ,4 );
98
+ lookup [0xC0 ] = new Instruction ("CPY " ,"IMM" ,2 );
99
+ lookup [0xC4 ] = new Instruction ("CPY " ,"ZPP" ,3 );
100
+ lookup [0xCC ] = new Instruction ("CPY " ,"ABS" ,4 );
101
101
102
- lookup [0xC6 ] = new Instruction ("CPX " ,"ZPP" ,5 );
103
- lookup [0xD6 ] = new Instruction ("CPX " ,"ZPX" ,6 );
104
- lookup [0xCE ] = new Instruction ("CPX " ,"ABS" ,6 );
105
- lookup [0xDE ] = new Instruction ("CPX " ,"ABX" ,7 );
102
+ lookup [0xC6 ] = new Instruction ("DEC " ,"ZPP" ,5 );
103
+ lookup [0xD6 ] = new Instruction ("DEC " ,"ZPX" ,6 );
104
+ lookup [0xCE ] = new Instruction ("DEC " ,"ABS" ,6 );
105
+ lookup [0xDE ] = new Instruction ("DEC " ,"ABX" ,7 );
106
106
107
107
lookup [0xCA ] = new Instruction ("DEX" ,"IMP" ,2 );
108
108
@@ -345,6 +345,8 @@ void reset() {
345
345
cycles = 8 ;
346
346
347
347
startTime = System .currentTimeMillis ();
348
+
349
+ opcode = Bus .read (programCounter );
348
350
}
349
351
350
352
void irq () {
@@ -702,7 +704,7 @@ public void CPY() {
702
704
703
705
public void DEC () {
704
706
fetch ();
705
- short temp = (short ) (fetched -1 );
707
+ int temp = (Byte . toUnsignedInt (fetched ) -1 );
706
708
Bus .write (addressAbsolute , (byte )(temp &0x00FF ));
707
709
setFlag ('Z' ,(temp &0x00FF )==0x0000 );
708
710
setFlag ('N' ,(temp &0x0080 )==0x0080 );
0 commit comments