示例#1
0
        /// <summary>
        /// Returns the tiles of this Tileset (empty 0th tile excluded) written sequentially in a byte array
        /// </summary>
        public byte[] ToBytes(bool compressed)
        {
            byte[] result = new byte[Count * GBA.Tile.LENGTH];
            int    index  = 0;

            for (int i = 0; i < Count; i++)
            {
                Array.Copy(Sheet[i].Bytes, 0, result, index, Sheet[i].Bytes.Length);
                index += Sheet[i].Bytes.Length;
            }

            return(compressed ? LZ77.Compress(result) : result);
        }
示例#2
0
        /// <summary>
        /// Returns a byte array of this GBA.Palette.
        /// </summary>
        public Byte[] ToBytes(bool compressed)
        {
            byte[] result = new byte[Count * 2];
            byte[] color;
            int    index = 0;

            for (int i = 0; i < Count; i++)
            {
                color             = Colors[i].ToBytes(true);
                result[index]     = color[0];
                result[index + 1] = color[1];
                index            += 2;
            }
            return(compressed ? LZ77.Compress(result) : result);
        }
示例#3
0
        /// <summary>
        /// Returns this TSA array as a byte array, LZ77 compressed or not
        /// </summary>
        public Byte[] ToBytes(bool compressed, bool flipRows)
        {
            byte[] result = new byte[Tiles.Length * 2];
            for (int i = 0; i < Tiles.Length; i++)
            {
                result[i * 2]     = (byte)(Tiles[i].Value & 0x00FF);
                result[i * 2 + 1] = (byte)((Tiles[i].Value & 0xFF00) >> 8);
            }

            if (flipRows)
            {
                result = FlipRows(Width, Height, result);
            }

            return(compressed ? LZ77.Compress(result) : result);
        }
 public static byte[] getCCG(byte[] memblock, int position)
 {
     for (int i = 0; i < CCGStart.Length; i++)
     {
         if (CCGStart[i] != memblock[position + i])
         {
             return(null);
         }
     }
     byte[] ReturnCCG = new byte[0xC + LZ77.getLength(memblock, position + 0xC) + 0x4];
     for (int i = 0; i < ReturnCCG.Length - 4; i++)
     {
         ReturnCCG[i] = memblock[position + i];
     }
     for (int i = 0; i < CCGEnd.Length; i++)
     {
         ReturnCCG[ReturnCCG.Length - 4 + i] = CCGEnd[i];
     }
     return(ReturnCCG);
 }