x and y Offseting / Bit shifting
<p>I'm really confused with this method, mainly because I'm confused why he bit shifts in some parts. </p>

<p>I have no idea why a map width mask is used or anything here its all so confusing, can someone dissect this all for me? </p>

<pre><code>public static final int MAP_WIDTH = 64;
public static final int MAP_WIDTH_MASK = MAP_WIDTH - 1;

public int[] tiles = new int[MAP_WIDTH * MAP_WIDTH];
public int[] colours = new int[MAP_WIDTH * MAP_WIDTH * 4];

public int xOffSet = 0;
public int yOffSet = 0;

public int width;
public int height;

public void render(int[] pixels, int offset, int row) {
    for(int yTile = yOffSet &gt;&gt; 3; yTile &lt;= (yOffSet +height) &gt;&gt; 3; yTile++) {
        int yMin = yTile * 8 - yOffSet;
        int yMax = yMin + 8;
        if(yMin &lt;0) yMin = 0;
        if(yMax &gt; height) yMax = height;

        for(int xTile = xOffSet &gt;&gt; 3; xTile &lt;= (xOffSet + width) &gt;&gt; 3; xTile++) {
            int xMin = xTile * 8 - xOffSet;
            int xMax = xMin + 8;
            if(xMin &lt;0) xMin = 0;
            if(xMax &gt; width) xMax = width;

            int tileIndex = (xTile &amp; (MAP_WIDTH_MASK)) + (yTile &amp; (MAP_WIDTH_MASK)) * MAP_WIDTH;

            for(int y= yMin; y&lt;yMax; y++) {
                int sheetPixel = ((y + yOffSet) &amp; 7) * sheet.width + ((xMin + xOffSet) &amp; 7 );
                int tilePixel = offset + xMin + y * row;
                for(int x = xMin; x &lt; xMax; x++) {
                    int colour = tileIndex * 4 + sheet.pixels[sheetPixel++];
                    pixels[tilePixel++] = colours[colour];
                }
            }
        }
    }
}
</code></pre>
