Fixed POP AF instruction (lowest 4 bits in flags are always 0)
authorslack <slack@codemaniacs.com>
Sun, 2 Oct 2011 14:06:12 +0000 (16:06 +0200)
committerslack <slack@codemaniacs.com>
Sun, 2 Oct 2011 14:06:12 +0000 (16:06 +0200)
core/GameBoy.cc

index 28d70382c163196fd352a5bd744fb1652a1270db..bf789fb6ba468e87edb2023615f77800323cfa35 100644 (file)
@@ -629,8 +629,15 @@ GameBoy::run_status GameBoy::run_cycle()
                                        PUSH(0xD5, D, E)
                                        PUSH(0xE5, H, L)
 
+                                       // POP AF: special because bits 0-3 in F are always 0
+                                       case 0xF1:
+                                           regs.flags = memory.read(regs.SP) & 0xF0;
+                                           regs.A = memory.read(regs.SP+1);
+                                           regs.SP += 2;
+                                           cycles_until_next_instruction = 12;
+                                           break;
+
                                        // POP nn
-                                       POP(0xF1, A, flags)
                                        POP(0xC1, B, C)
                                        POP(0xD1, D, E)
                                        POP(0xE1, H, L)