diff --git a/src/mos6502.arith.c b/src/mos6502.arith.c index eb75028..3accbd9 100644 --- a/src/mos6502.arith.c +++ b/src/mos6502.arith.c @@ -17,6 +17,8 @@ DEFINE_INST(adc) { CARRY_BIT(); cpu->A += oper + carry; + + mos6502_modify_status(cpu, NEGATIVE | OVERFLOW | CARRY | ZERO, cpu->A); } /* @@ -59,6 +61,7 @@ DEFINE_INST(dec) { if (cpu->last_addr) { vm_segment_set(cpu->memory, cpu->last_addr, oper - 1); + mos6502_modify_status(cpu, NEGATIVE | ZERO, oper - 1); } } @@ -68,6 +71,7 @@ DEFINE_INST(dec) DEFINE_INST(dex) { cpu->X--; + mos6502_modify_status(cpu, NEGATIVE | ZERO, cpu->X); } /* @@ -76,6 +80,7 @@ DEFINE_INST(dex) DEFINE_INST(dey) { cpu->Y--; + mos6502_modify_status(cpu, NEGATIVE | ZERO, cpu->Y); } /* @@ -87,6 +92,7 @@ DEFINE_INST(inc) { if (cpu->last_addr) { vm_segment_set(cpu->memory, cpu->last_addr, oper + 1); + mos6502_modify_status(cpu, NEGATIVE | ZERO, oper + 1); } } @@ -96,6 +102,7 @@ DEFINE_INST(inc) DEFINE_INST(inx) { cpu->X++; + mos6502_modify_status(cpu, NEGATIVE | ZERO, cpu->X); } /* @@ -104,6 +111,7 @@ DEFINE_INST(inx) DEFINE_INST(iny) { cpu->Y++; + mos6502_modify_status(cpu, NEGATIVE | ZERO, cpu->Y); } /* @@ -116,4 +124,6 @@ DEFINE_INST(sbc) { CARRY_BIT(); cpu->A = cpu->A - oper - carry; + + mos6502_modify_status(cpu, NEGATIVE | OVERFLOW | CARRY | ZERO, cpu->A); } diff --git a/src/mos6502.bits.c b/src/mos6502.bits.c index 2e271ec..5b78e59 100644 --- a/src/mos6502.bits.c +++ b/src/mos6502.bits.c @@ -15,6 +15,7 @@ DEFINE_INST(and) { cpu->A &= oper; + mos6502_modify_status(cpu, NEGATIVE | ZERO, cpu->A); } /* @@ -42,6 +43,8 @@ DEFINE_INST(asl) } else { cpu->A = oper; } + + mos6502_modify_status(cpu, NEGATIVE | CARRY | ZERO, oper); } /* @@ -75,6 +78,7 @@ DEFINE_INST(bit) DEFINE_INST(eor) { cpu->A ^= oper; + mos6502_modify_status(cpu, NEGATIVE | ZERO, cpu->A); } /* @@ -98,6 +102,9 @@ DEFINE_INST(lsr) } else { cpu->A = oper; } + + // NEGATIVE is intentionally not included here. + mos6502_modify_status(cpu, CARRY | ZERO, oper); } /* @@ -107,6 +114,7 @@ DEFINE_INST(lsr) DEFINE_INST(ora) { cpu->A |= oper; + mos6502_modify_status(cpu, NEGATIVE | ZERO, cpu->A); } /* @@ -133,6 +141,8 @@ DEFINE_INST(rol) } else { cpu->A = oper; } + + mos6502_modify_status(cpu, NEGATIVE | CARRY | ZERO, oper); } /* @@ -158,4 +168,6 @@ DEFINE_INST(ror) } else { cpu->A = oper; } + + mos6502_modify_status(cpu, NEGATIVE | CARRY | ZERO, oper); } diff --git a/src/mos6502.loadstor.c b/src/mos6502.loadstor.c index 14cefa4..6b13615 100644 --- a/src/mos6502.loadstor.c +++ b/src/mos6502.loadstor.c @@ -58,6 +58,7 @@ DEFINE_INST(php) DEFINE_INST(pla) { cpu->A = mos6502_pop_stack(cpu); + mos6502_modify_status(cpu, NEGATIVE | ZERO, cpu->A); } /*