Mednafen wrote:
Out of tangential curiosity, has anyone written tests yet that do something like this in the interrupt handler?
CLI
STA $xxxx ; Acknowledge IRQ
and
CLI
INC $xxxx ; Acknowledge IRQ
I think the CLI+STA version should generate an interrupt but not the CLI+INC version.
Basically, each instruction has a polling point for interrupts, which looks to be just before the last tick (again, would be nice to have confirmed). For CLI and SEI (and the other flag-manipulating instructions) the polling point comes before the value of the flag changes, which is why the interrupt isn't seen by those if the I flag was set. For RTI, the polling point is after the flags are restored, so there the flags on the stack matter.
For STA, the polling point is before the value is written, and so it will see the IRQ before it is acknowledged. For INC, the dummy write comes before the polling point, so there the IRQ will probably get acknowledged before it has a chance to be seen.