示例#1
0
 private static void EncodeTile8(ref Tileset.Tile tile, ref byte[] bytes, int index)
 {
     for (int y = 0; y < 8; y++)
     {
         for (int x = 0; x < 8; x++)
         {
             bytes[index + x + y * 8] = (byte)tile[x, y];
         }
     }
 }
示例#2
0
 private static void EncodeTile4(ref Tileset.Tile tile, ref byte[] bytes, int index)
 {
     for (int y = 0; y < 8; y++)
     {
         for (int x = 0; x < 4; x++)
         {
             bytes[index + x + y * 4] = (byte)((tile[x * 2, y] & 0xF) | ((tile[x * 2 + 1, y] & 0xF) << 4));
         }
     }
 }
示例#3
0
 private static void DecodeTile8(ref byte[] bytes, int index, ref Tileset.Tile tile)
 {
     for (int y = 0; y < 8; y++)
     {
         for (int x = 0; x < 8; x++)
         {
             tile[x, y] = bytes[index + x + y * 8];
         }
     }
 }
示例#4
0
 private static void DecodeTile4(ref byte[] bytes, int index, ref Tileset.Tile tile)
 {
     for (int y = 0; y < 8; y++)
     {
         for (int x = 0; x < 4; x++)
         {
             tile[x * 2, y]     = (bytes[index + x + y * 4] & 0xF);
             tile[x * 2 + 1, y] = (bytes[index + x + y * 4] >> 4 & 0xF);
         }
     }
 }
示例#5
0
        public static Tileset.Tile[] DecodeTiles8(byte[] bytes)
        {
            var tiles = new Tileset.Tile[bytes.Length >> 6]; // / (8 * 8)

            for (int i = 0; i < tiles.Length; i++)
            {
                DecodeTile8(ref bytes, i << 6, ref tiles[i]); // * (8 * 8)
            }

            return(tiles);
        }
示例#6
0
        public static Tileset.Tile[] DecodeTiles4(byte[] bytes)
        {
            var tiles = new Tileset.Tile[bytes.Length >> 5]; // / (8 * 8 / 2)

            for (int i = 0; i < tiles.Length; i++)
            {
                DecodeTile4(ref bytes, i << 5, ref tiles[i]); // * (8 * 8 / 2)
            }

            return(tiles);
        }