; Tests timing of NMI and immediate occurrence when enabled with ; VBL flag already set. .include "prefix_ppu.a" test_name: .db "NMI TIMING",0 nmi: cpx #1 ; if x isn't 1, interrupt wasn't expected bne + ldx #2 ; x = 2 signals that interrupt occurred rti : lda #0 sta $2001 jmp report_final_result test_too_soon: jmp test_common ; 3 test_too_late: nop ; 2 test_common: ldx #0 ; 2 nmi shouldn't occur lda #$80 ; 6 enable nmi sta $2000 pha ; 14 delay pla pha pla ldx #1 ; 2 ; nmi should occur here dex ; 0 if didn't occur, 1 if did lda #$00 ; disable nmi sta $2000 cpx #1 ; nmi should have occurred jsr error_if_ne rts .code reset: jsr begin_ppu_test lda #2;) NMI occurred 3 or more PPU clocks too early sta