I have encountered a very strange behavior. I'm reading PPUSTATUS ($2002) in main code (reset vector) in a loop, and for some reason sometimes NMI isn't called in this case. It depends on ticks between reads from the $2002.
For example this code:
Causes that NMI will not be called at all in Dendy (Hybrid) mode of the Nintendulator or puNES.
My NMI does nothing but increment nmi_counter:
How to reproduce:
1. Download this example: http://veg.by/files/nes/nonmibug.7z
2. Open Nintendulator, set Hybrid PPU mode, open demo.nes from the archive
3. Open debugger, press Add breakpoint, choose NMI, press Add
4. Press run.
You will see that NMI is called only 3 times. After it only infinite loop in the main code will be executed.
What's the cause of this?
For example this code:
Code:
RESET:
; ... basic init code is skipped
LDA #PPU_CTRL_NMI_ON
STA PPU_CTRL
@loop:
LDA PPU_STATUS
NOP
NOP
JMP @loop
; ... basic init code is skipped
LDA #PPU_CTRL_NMI_ON
STA PPU_CTRL
@loop:
LDA PPU_STATUS
NOP
NOP
JMP @loop
Causes that NMI will not be called at all in Dendy (Hybrid) mode of the Nintendulator or puNES.
My NMI does nothing but increment nmi_counter:
Code:
NMI:
PHA
TXA
PHA
TYA
PHA
INC nmi_counter
PLA
TAY
PLA
TAX
PLA
RTI
PHA
TXA
PHA
TYA
PHA
INC nmi_counter
PLA
TAY
PLA
TAX
PLA
RTI
How to reproduce:
1. Download this example: http://veg.by/files/nes/nonmibug.7z
2. Open Nintendulator, set Hybrid PPU mode, open demo.nes from the archive
3. Open debugger, press Add breakpoint, choose NMI, press Add
4. Press run.
You will see that NMI is called only 3 times. After it only infinite loop in the main code will be executed.
What's the cause of this?