     renderSpritePixel: ->
         # TODO rewrite and optimize this
         @fetchSprites() if @cycle is 1
+        return 0 if not @spritesVisible or @cycle < 9 and @spriteClipping
         @spriteZeroRendered = false
-        currentX = @cycle
-        currentY = @scanline
+        currentX = @cycle - 1
+        currentY = @scanline - 1
         heightMask = if @bigSprites then 0x0F else 0x07
         for address in @spriteAddresses
             innerX = currentX - @objectAttributeMemory[address + 3]


    renderBackgroundPixel: ->
        @fetchPattern() if @fineXScroll is 0 # When coarse scroll X was incremented.
        bitNumber = @fineXScroll ^ 0x07 # 7 - fineXScroll
        colorSelect1 =  (@patternLayer1Row >>> bitNumber) & 0x01
        colorSelect2 = ((@patternLayer2Row >>> bitNumber) & 0x01) << 1

        @framePosition++ # Skip alpha because it was already set to 0xFF.

    renderFramePixel: ->
        backgroundColor = @renderBackgroundPixel()
        spriteColor = @renderSpritePixel()
        if (spriteColor & 0x03) and (backgroundColor & 0x03) # Both bagckground and sprite pixels are visible
            @spriteZeroHit |= @spriteZeroRendered
            if @spriteInFront then spriteColor else backgroundColor
