         @tempXScroll = 0    #  3-bit
 
     resetVariables: ->
-        @scanline = -1 # Total 262 scanlines (0..261)
-        @cycle = 0     # Total 341 cycles per scanline (0..340)
-        @renderedSprite = null
+        @scanline = -1         # Total 262 scanlines (0..261)
+        @cycle = 0             # Total 341 cycles per scanline (0..340)
+        @renderedSprite = null # Currently rendered sprite
+        @delayedNMI = false    # Generate NMI after next instruction when its enabled (from 0 to 1) during VBLANK
 
     setNTSCMode: (ntscMode) ->
         @ntscMode = ntscMode

        @$updateScrolling() if @$isRenderingActive()
        @$updateVBlank()
        @$incrementCycle()

    isRenderingCycle: ->
        0 <= @scanline <= 239 and 1 <= @cycle <= 256

        @vblankStarted = 1
        @vblankActive = 1
        @frameAvailable = true
        @cpu.activateInterrupt Interrupt.NMI if @nmiEnabled

    leaveVBlank: ->
        @vblankStarted = 0
        @vblankActive = 0
        @spriteZeroHit = 0

    generateDelayedNMI: ->
        @cpu.activateInterrupt Interrupt.NMI
        @delayedNMI = false

    incrementCycle: ->
        @cycle++
