code: function initPalettes() {
  	var i, j,
  	    result = new Uint8Array( 0x100 );
  
  	for ( i = 0; i < 4; i++ ) {
  		for ( j = 0; j < 8; j += 2 ) {
  			result[ i << j ] = i << 2; // shift by 2 places, so value can be easily ORed with color
  		}
  	}
  
  	return result;
  }
docs: Initialize tile palette lookup table.
  Maps ( attribute byte & mask ) to palette value.