commanderx16 / x16-emulator

Emulator for the Commander X16 8-bit computer
384 stars 61 forks source link

Clear D Flag on IRQ/NMI #436

Closed LRFLEW closed 1 year ago

LRFLEW commented 1 year ago

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.

LRFLEW commented 1 year ago

Rebased on top of #434 to resolve the merge conflict