The code was already clearing the decimal flag on a BRK instruction, so this changes it to also clear it on IRQ, NMI, and RESET signals. I also improved the handling of other flags during these signals. According to section 3.11 of the manual, the B and I flags are set during a reset, so this PR also sets those flags during a reset. With that change to how the B flag is handled, I also updated the NMI to push the status register with the B flag cleared. I had some difficulty determining how the flag is handled on an NMI, with the only resource I could find being this one for the NES, so I'm not 100% confident about how it's handled on the 65C02.
This is an attempt to fix #414
The code was already clearing the decimal flag on a
BRK
instruction, so this changes it to also clear it on IRQ, NMI, and RESET signals. I also improved the handling of other flags during these signals. According to section 3.11 of the manual, the B and I flags are set during a reset, so this PR also sets those flags during a reset. With that change to how the B flag is handled, I also updated the NMI to push the status register with the B flag cleared. I had some difficulty determining how the flag is handled on an NMI, with the only resource I could find being this one for the NES, so I'm not 100% confident about how it's handled on the 65C02.