diff --git a/cpu.c b/cpu.c index 0fe6cbd..61b835c 100644 --- a/cpu.c +++ b/cpu.c @@ -8,7 +8,7 @@ #define STATUS_UPDATE_ZERO(r) \ (regs.status.zero = r == 0) #define STATUS_UPDATE_NEGATIVE(r) \ - (regs.status.negative = ((r & (1 << 7)) > 0)) + (regs.status.negative = ((r & (1 << 7)) != 0)) #define MEMORY_MIRROR(addr) \ if (addr < 0x2000) \ @@ -197,7 +197,7 @@ adc(uint8_t arg) regs.status.carry = sum > 0xFF; /* overflow flag formula: https://stackoverflow.com/a/29224684 */ - regs.status.overflow = (~(regs.a ^ arg) & (regs.a ^ sum) & 0x80) > 0; + regs.status.overflow = (~(regs.a ^ arg) & (regs.a ^ sum) & 0x80) != 0; STATUS_UPDATE_ZERO(regs.a); STATUS_UPDATE_NEGATIVE(regs.a); } @@ -262,7 +262,7 @@ static void bit(uint8_t arg) { regs.status.zero = (regs.a & arg) == 0; - regs.status.overflow = (arg & (1 << 6)) > 0; + regs.status.overflow = (arg & (1 << 6)) != 0; STATUS_UPDATE_NEGATIVE(arg); } @@ -557,21 +557,21 @@ plp(void) status = PULL(); - regs.status.carry = (status & (1 << 7)) > 0; - regs.status.zero = (status & (1 << 6)) > 0; - regs.status.interrupt_disable = (status & (1 << 5)) > 0; - regs.status.decimal_mode = (status & (1 << 4)) > 0; - regs.status.brk = (status & (1 << 3)) > 0; - regs.status.unused = (status & (1 << 2)) > 0; - regs.status.overflow = (status & (1 << 1)) > 0; - regs.status.negative = (status & 1) > 0; + regs.status.carry = (status & (1 << 7)) != 0; + regs.status.zero = (status & (1 << 6)) != 0; + regs.status.interrupt_disable = (status & (1 << 5)) != 0; + regs.status.decimal_mode = (status & (1 << 4)) != 0; + regs.status.brk = (status & (1 << 3)) != 0; + regs.status.unused = (status & (1 << 2)) != 0; + regs.status.overflow = (status & (1 << 1)) != 0; + regs.status.negative = (status & 1) != 0; } static void rol_acc(void) { uint8_t carry; - carry = (regs.a & (1 << 7)) > 0; + carry = (regs.a & (1 << 7)) != 0; regs.a <<= 1; regs.a |= regs.status.carry; @@ -585,7 +585,7 @@ static void rol(uint16_t mem) { uint8_t carry, tmp; - carry = (peek(mem) & (1 << 7)) > 0; + carry = (peek(mem) & (1 << 7)) != 0; tmp = (peek(mem) << 1) | regs.status.carry; memwrite(mem, tmp);