|
I prefer polling the VBL rather than using an NMI handler for simple experiments on the NES but have observed $2002.7 not being set sometimes. The following code demonstrates this by toggling the DMC's DAC for every VBL ,which makes missed VBLs audibly obvious:
lda #0 ; init PPU sta $2000 sta $2001 lda #63 loop: bit $2002 bpl loop eor #63 ; toggle DAC sta $4011 jmp loop
If I use LDA instead of BIT (with appropriate saving and restoring of A), the results are the same. If I insert NOPs into the loop, the VBL is periodically missed. My current solution is to use a minimal NMI handler that just sets a "NMI occurred" flag and returns, but this is inelegant. Is there some subtlety to properly polling $2002.7?
|