summary refs log tree commit diff
path: root/src/6502.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/6502.c')
-rw-r--r--src/6502.c11
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;