From d119854631590776d2c6c13e7c25104f6f38b9cb Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Sun, 21 Jan 2018 16:21:15 -0600 Subject: [PATCH] Carry is set by left- or right-most bits Don't rely on modify_status() to get it right. --- src/mos6502.bits.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mos6502.bits.c b/src/mos6502.bits.c index 6d57aca..c2ffa66 100644 --- a/src/mos6502.bits.c +++ b/src/mos6502.bits.c @@ -142,11 +142,13 @@ DEFINE_INST(rol) carry = 1; } + cpu->P &= ~MOS_CARRY; if (carry) { result |= 0x01; + cpu->P |= MOS_CARRY; } - mos6502_modify_status(cpu, MOS_NZC, oper, result); + mos6502_modify_status(cpu, MOS_NZ, oper, result); if (cpu->eff_addr) { mos6502_set(cpu, cpu->eff_addr, result & 0xff); @@ -168,11 +170,13 @@ DEFINE_INST(ror) carry = 1; } + cpu->P &= ~MOS_CARRY; if (carry) { result |= 0x80; + cpu->P |= MOS_CARRY; } - mos6502_modify_status(cpu, MOS_NZC, oper, result); + mos6502_modify_status(cpu, MOS_NZ, oper, result); if (cpu->eff_addr) { mos6502_set(cpu, cpu->eff_addr, result & 0xff);