diff options
author | Maxwell Beck <max@rastertail.net> | 2024-12-28 19:07:40 -0600 |
---|---|---|
committer | Maxwell Beck <max@rastertail.net> | 2024-12-28 19:07:40 -0600 |
commit | 6ae60dd26bc8900a3fec955b846b4b3119c80dd8 (patch) | |
tree | 8233b47e77bce264b499df00de6902019c232f2f | |
parent | df3838ef78d4ad45f4f5c42cebf48be491c6e980 (diff) |
Fix ARR instruction
-rw-r--r-- | src/6502.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/6502.c b/src/6502.c index 5d38029..b33b49d 100644 --- a/src/6502.c +++ b/src/6502.c @@ -403,11 +403,11 @@ do { \ uint8_t c = FLAG_GET(C); \ r = r & a; \ - uint16_t res = r + a + c; \ - FLAG_SET(N, (res & 0x100) >> 8); \ - FLAG_SET(V, ((r ^ res) & (a ^ res) & 0x80) >> 7); \ - FLAG_SET(C, r & 1); \ - r = (r >> 1) | (r << 7); \ + r = (r >> 1) | (c << 7); \ + FLAG_SET(C, (r & 0x40) >> 6); \ + FLAG_SET(V, ((r & 0x40) ^ ((r & 0x20) << 1)) >> 6); \ + FLAG_SET(N, (r & 0x80) >> 7); \ + FLAG_SET(Z, (r == 0) ? 1 : 0); \ } while (0); #define DCP(src, dst) \ @@ -946,7 +946,6 @@ uint8_t cpu_step(cpu_t *cpu) { uint8_t a; R_IMM(); ARR(); - FLAG_SET(Z, (r == 0) ? 1 : 0); cpu->a = r; } while (0); break; |