Example #1
0
 /// <summary>
 /// Creates a new subtile from the current properties of the loaded subtile.
 /// </summary>
 /// <returns></returns>
 private Subtile CreateNewSubtile()
 {
     return(Do.DrawSubtile((ushort)this.subtileIndex.Value,
                           (byte)this.subtilePalette.Value,
                           this.subtileStatus.GetItemChecked(0),
                           this.subtileStatus.GetItemChecked(1),
                           this.subtileStatus.GetItemChecked(2),
                           graphics, paletteSet.Palettes, format));
 }
Example #2
0
        /// <summary>
        /// Converts a tileset's binary data to a manageable tile collection.
        /// </summary>
        /// <param name="src">The tileset's binary data.</param>
        /// <param name="dst">The tile collection to write to from the binary data.</param>
        /// <param name="graphics">The graphics to use for creating the subtile pixels.</param>
        /// <param name="format">The size of a single subtile's graphics, 0x10 or 0x20.</param>
        public void BuildTilesetTiles(byte[] src, Tile[] dst, byte[] graphics, byte format)
        {
            int offset = 0;

            for (int i = 0; i < Width / 16; i++)
            {
                for (int y = 0; y < Height; y++)
                {
                    for (int x = i * 16; x < i * 16 + 16; x++)
                    {
                        int index = y * Width + x;
                        if (index >= dst.Length)
                        {
                            continue;
                        }
                        dst[index] = new Tile(index);
                        for (int z = 0; z < 4; z++)
                        {
                            if (z == 2)
                            {
                                offset += this.tileSize * 30;
                            }
                            ushort tilenum = 0;
                            byte   status  = 0;
                            if (this.tileSize == 2)
                            {
                                tilenum = (ushort)(Bits.GetShort(src, offset++) & 0x03FF);
                                status  = src[offset++];
                            }
                            else
                            {
                                tilenum = src[offset++];
                                status  = (byte)(Palette_bytes[tilenum] << 2);
                            }
                            var subtile = Do.DrawSubtile(tilenum, status, graphics, PaletteSet.Palettes, format);
                            dst[index].Subtiles[z] = subtile;
                        }
                        if (x < i * 16 + 15)
                        {
                            offset -= this.tileSize * 32;
                        }
                    }
                }
            }
        }