     ###########################################################
 
     tick: ->
-        @startFrame() if @isFirstRenderingCycle()
         @updateFramePixel() if @isRenderingCycle()
         @updateScrolling() if @isRenderingInProgress()
         @incrementCycle()
-
-    isFirstRenderingCycle: ->
-        @scanline is 0 and @cycle is 1
 
     isRenderingCycle: ->
         0 <= @scanline <= 239 and 1 <= @cycle <= 256
     
     isRenderingInProgress: ->
-        not @isVBlank() and @isRenderingEnabled()
+        not @isVBlank() and (@spritesVisible or @backgroundVisible)
 
     isVBlank: ->
         241 <= @scanline <= 260
-
-    isRenderingEnabled: ->
-        @spritesVisible or @backgroundVisible
 
     isFrameAvailable: ->
         @frameAvailable

    # Byte 3 = x screen coordinate

    renderSpritePixel: ->
        @fetchSprites() if @cycle is 1
        @renderedSprite = null
        return 0 if not @spritesVisible or (@cycle < 9 and @spriteClipping)
        rightX = @cycle - 1
        leftX = rightX - 8
        for sprite in @secondaryOAM when leftX <= sprite.x <= rightX

        else
            backgroundColor

    setFramePixel: (color) ->
        colorPosition = color << 2 # Each RGBA color is 4B.
        @frameBuffer[@framePosition++] = RGBA_COLORS[colorPosition++]
        @frameBuffer[@framePosition++] = RGBA_COLORS[colorPosition++]
        @frameBuffer[@framePosition++] = RGBA_COLORS[colorPosition]
        @framePosition++ # Skip alpha because it was already set to 0xFF.

    updateScrolling: ->
        if 1 <= @cycle <= 256
            @incrementFineXScroll()
            @incrementFineYScroll() if @cycle is 256
        else if @cycle is 257
            @copyHorizontalScrollBits()
        else if @scanline is -1 and 280 <= @cycle <= 304
            @copyVerticalScrollBits() 

    incrementCycle: ->
        @cycle++
