         @ppuMemory.write address, value
 
     isPalleteAddress: (address) ->
-        address & 0x3F00
+        (address & 0x3F00) == 0x3F00
 
     ###########################################################
     # Rendering

    powerUp: ->
        @resetOAM()
        @resetRegisters()

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

        @framebuffer

    tick: ->

    incrementXScroll: ->
        @fineXScroll = (@fineXScroll + 1) & 0x07
        if @fineXScroll is 0 # Fine X scroll overflow
            @coarseXScroll = (@coarseXScroll + 1) & 0x1E
            if @coarseXScroll is 0 # Coarse X scroll overflow
                @selectedNameTableIndex ^= 0x01 # Switch horizontal nametable
        @updateVRAMAddressFromScrollingData()

    incrementYScroll: ->
        @fineYScroll = (@fineYScroll + 1) & 0x07
        if @fineYScroll is 0 # Fine X scroll overflow
            @coarseYScroll = (@coarseYScroll + 1) & 0x1E
            if @coarseYScroll is 0 # Coarse X scroll overflow
                @selectedNameTableIndex ^= 0x02 # Switch vertical nametable
        @updateVRAMAddressFromScrollingData()

module.exports = PPU
