Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.