             @sprite.inFront = (attributes & 0x20) is 0
             @sprite.zeroSprite = address is 0
             @sprite.patternRow0 = @ppuMemory.read @addressBus
+        else
+            @sprite = null
 
     fetchSpriteHigh: ->
-        @addressBus += 8
         if @sprite
+            @addressBus += 8
             @sprite.patternRow1 = @ppuMemory.read @addressBus
             @spriteNumber++
 


    resetOAM: ->
        @primaryOAM = (0 for [0..0x100])  # 256B
        @secondaryOAM = []

    resetRegisters: ->
        @setControl 0       #  8-bit PPUCTRL register

cycleFlagsTable[338]    |= F_SKIP
scanlineFlagsTable[261] |= F_SKIP

class Sprite

    constructor: ->
        @address = 0
        @height = 0
        @rowNumber = 0
        @x = 0
        @horizontalFlip = false
        @paletteNumber = 0
        @inFront = false
        @zeroSprite = false
        @patternRow0 = 0
        @patternRow1 = 0

###########################################################
# Picture processing unit
###########################################################
