z80, some cz80 cleanup
authorkub <derkub@gmail.com>
Fri, 8 Oct 2021 16:40:06 +0000 (18:40 +0200)
committerkub <derkub@gmail.com>
Fri, 8 Oct 2021 16:40:06 +0000 (18:40 +0200)
cpu/cz80/cz80_opED.c

index eb9f6ee..71f7dbc 100644 (file)
@@ -491,27 +491,23 @@ OP_LDX:
 -----------------------------------------*/\r
 \r
        OPED(0xb0): // LDIR\r
-               if (zBC != 1)\r
-                       PC -= 2;\r
                do\r
                {\r
                        val = READ_MEM8(zHL++);\r
                        WRITE_MEM8(zDE++, val);\r
                        zBC--;\r
                        USE_CYCLES(21)\r
-               } while (zBC > 1 && (CPU->ICount > 0) && !CPU->Status);\r
+               } while (zBC && (CPU->ICount > -4) && !CPU->Status);\r
                goto OP_LDXR;\r
 \r
        OPED(0xb8): // LDDR\r
-               if (zBC != 1)\r
-                       PC -= 2;\r
                do\r
                {\r
                        val = READ_MEM8(zHL--);\r
                        WRITE_MEM8(zDE--, val);\r
                        zBC--;\r
                        USE_CYCLES(21)\r
-               } while (zBC > 1 && (CPU->ICount > 0) && !CPU->Status);\r
+               } while (zBC && (CPU->ICount > -4) && !CPU->Status);\r
 \r
 OP_LDXR:\r
                F = zF & (SF | ZF | CF);\r
@@ -520,6 +516,7 @@ OP_LDXR:
                if (zBC)\r
                {\r
                        zF = F | VF;\r
+                       PC -= 2;\r
 #if CZ80_EMULATE_R_EXACTLY\r
                        zR--;\r
 #endif\r
@@ -556,8 +553,6 @@ OP_CPX:
 -----------------------------------------*/\r
 \r
        OPED(0xb1): // CPIR\r
-               if (zBC != 1)\r
-                       PC -= 2;\r
                do\r
                {\r
                        val = READ_MEM8(zHL++);\r
@@ -570,12 +565,10 @@ OP_CPX:
                        if (zBC) F |= VF;\r
                        zF = F;\r
                        USE_CYCLES(21)\r
-               } while (zBC > 1 && !(F & ZF) && (CPU->ICount > 0) && !CPU->Status);\r
+               } while (zBC && !(F & ZF) && (CPU->ICount > -4) && !CPU->Status);\r
                goto OP_CPXR;\r
 \r
        OPED(0xb9): // CPDR\r
-               if (zBC != 1)\r
-                       PC -= 2;\r
                do\r
                {\r
                        val = READ_MEM8(zHL--);\r
@@ -588,11 +581,12 @@ OP_CPX:
                        if (zBC) F |= VF;\r
                        zF = F;\r
                        USE_CYCLES(21)\r
-               } while (zBC > 1 && !(F & ZF) && (CPU->ICount > 0) && !CPU->Status);\r
+               } while (zBC && !(F & ZF) && (CPU->ICount > -4) && !CPU->Status);\r
 \r
 OP_CPXR:\r
                if (zBC && !(F & ZF))\r
                {\r
+                       PC -= 2;\r
 #if CZ80_EMULATE_R_EXACTLY\r
                        zR--;\r
 #endif\r
@@ -631,27 +625,23 @@ OP_INX:
 -----------------------------------------*/\r
 \r
        OPED(0xb2): // INIR\r
-               if (zB != 1)\r
-                       PC -= 2;\r
                do\r
                {\r
                        val = IN(zBC);\r
                        zB--;\r
                        WRITE_MEM8(zHL++, val);\r
                        USE_CYCLES(21)\r
-               } while (zB > 1 && (CPU->ICount > 0) && !CPU->Status);\r
+               } while (zB && (CPU->ICount > -4) && !CPU->Status);\r
                goto OP_INXR;\r
 \r
        OPED(0xba): // INDR\r
-               if (zB != 1)\r
-                       PC -= 2;\r
                do\r
                {\r
                        val = IN(zBC);\r
                        zB--;\r
                        WRITE_MEM8(zHL--, val);\r
                        USE_CYCLES(21)\r
-               } while (zB > 1 && (CPU->ICount > 0) && !CPU->Status);\r
+               } while (zB && (CPU->ICount > -4) && !CPU->Status);\r
 \r
 OP_INXR:\r
                F = SZ[zB];\r
@@ -662,6 +652,7 @@ OP_INXR:
                zF = F;\r
                if (zB)\r
                {\r
+                       PC -= 2;\r
 #if CZ80_EMULATE_R_EXACTLY\r
                        zR--;\r
 #endif\r
@@ -700,27 +691,23 @@ OP_OUTX:
 -----------------------------------------*/\r
 \r
        OPED(0xb3): // OTIR\r
-               if (zB != 1)\r
-                       PC -= 2;\r
                do\r
                {\r
                        val = READ_MEM8(zHL++);\r
                        zB--;\r
                        OUT(zBC, val);\r
                        USE_CYCLES(21)\r
-               } while (zB > 1 && (CPU->ICount > 0) && !CPU->Status);\r
+               } while (zB && (CPU->ICount > -4) && !CPU->Status);\r
                goto OP_OTXR;\r
 \r
        OPED(0xbb): // OTDR\r
-               if (zB != 1)\r
-                       PC -= 2;\r
                do\r
                {\r
                        val = READ_MEM8(zHL--);\r
                        zB--;\r
                        OUT(zBC, val);\r
                        USE_CYCLES(21)\r
-               } while (zB > 1 && (CPU->ICount > 0) && !CPU->Status);\r
+               } while (zB && (CPU->ICount > -4) && !CPU->Status);\r
 \r
 OP_OTXR:\r
                F = SZ[zB];\r
@@ -731,6 +718,7 @@ OP_OTXR:
                zF = F;\r
                if (zB)\r
                {\r
+                       PC -= 2;\r
 #if CZ80_EMULATE_R_EXACTLY\r
                        zR--;\r
 #endif\r