Skip to content

Commit

Permalink
Fixed CPI/CPD/CPIR/CPDR instruction timings
Browse files Browse the repository at this point in the history
The CPI/CPD timing was usually masked by contention, but the repeat
instructions were running too fast. Thanks sirdavid!
  • Loading branch information
simonowen committed May 12, 2020
1 parent f277fa9 commit aa3f162
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Base/EDops.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
#define cpi(loop) do { \
BYTE carry = cy, x = timed_read_byte(HL); \
BYTE sum = A - x, z = A ^ x ^ sum; \
g_dwCycleCounter += 2; \
g_dwCycleCounter += 5; \
HL++; \
BC--; \
F = (sum & 0x80) | (!sum << 6) | (((sum - ((z&0x10)>>4)) & 2) << 4) | (z & 0x10) | ((sum - ((z >> 4) & 1)) & 8) | ((BC != 0) << 2) | FLAG_N | carry; \
Expand All @@ -133,7 +133,7 @@
#define cpd(loop) do { \
BYTE carry = cy, x = timed_read_byte(HL); \
BYTE sum = A - x, z = A ^ x ^ sum; \
g_dwCycleCounter += 2; \
g_dwCycleCounter += 5; \
HL--; \
BC--; \
F = (sum & 0x80) | (!sum << 6) | (((sum - ((z&0x10)>>4)) & 2) << 4) | (z & 0x10) | ((sum - ((z >> 4) & 1)) & 8) | ((BC != 0) << 2) | FLAG_N | carry; \
Expand Down

0 comments on commit aa3f162

Please sign in to comment.