Пример #1
0
        public static void swapSubTiles(Subtile subtile1, Subtile subtile2)
        {
            Subtile swapTile = subtile1;

            subtile1 = subtile2;
            subtile2 = swapTile;
        }
Пример #2
0
 public void BuildTilesetTiles(Tile[] tileset_tiles)
 {
     for (int y = 0; y < 4; y++)
     {
         for (int x = 0; x < 4; x++)
         {
             for (int z = 0; z < 4; z++)
             {
                 // for palette index 1
                 byte status = 0x04;
                 byte index  = (byte)(y * 16 + (x * 2) + (z % 2));
                 index += z >= 2 ? (byte)8 : (byte)0;
                 Subtile source = Do.DrawSubtile(index, status, graphics, palettes.Palettes, 0x20);
                 tileset_tiles[y * 16 + x].Subtiles[z]     = source;
                 tileset_tiles[y * 16 + x + 8].Subtiles[z] = source;
                 // for palette index 1
                 status = 0x44;
                 index ^= 7;
                 source = Do.DrawSubtile(index, status, graphics, palettes.Palettes, 0x20);
                 tileset_tiles[y * 16 + x + 4].Subtiles[z]  = source;
                 tileset_tiles[y * 16 + x + 12].Subtiles[z] = source;
             }
         }
     }
 }
Пример #3
0
    public bool OffsetByOne(CompassDirection direction, out Subtile newTile)
    {
        var newX = X;
        var newY = Y;

        switch (direction)
        {
        case CompassDirection.Top:
            newX--;
            newY--;
            break;

        case CompassDirection.TopRight:
            newX--;
            break;

        case CompassDirection.Right:
            newX--;
            newY++;
            break;

        case CompassDirection.BottomRight:
            newY++;
            break;

        case CompassDirection.Bottom:
            newX++;
            newY++;
            break;

        case CompassDirection.BottomLeft:
            newX++;
            break;

        case CompassDirection.Left:
            newX++;
            newY--;
            break;

        case CompassDirection.TopLeft:
            newY--;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        if (newX < 0 || newX >= GameSystems.Location.LocationLimitX * 3 ||
            newY < 0 || newY >= GameSystems.Location.LocationLimitY * 3)
        {
            newTile = default;
            return(false);
        }
        else
        {
            newTile = new Subtile(newX, newY);
            return(true);
        }
    }
Пример #4
0
 /// <summary>
 /// Writes this tileset's tile data to the elements in the global Model.
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public void WriteToModel(int width, int height)
 {
     // Iterate through each quadrant
     for (int q = 0; q < 4; q++)
     {
         // Iterate through each row of tiles
         for (int y = 0; y < height; y++)
         {
             // Iterate through each tile in row
             for (int x = 0; x < width; x++)
             {
                 var tile = Tileset_tiles[(y * width + x) + (q * 256)];
                 if (tile == null)
                 {
                     continue;
                 }
                 for (int s = 0; s < 4; s++)
                 {
                     int offset = y * (width * 2 * 2 * 2) + (x * 2 * 2);
                     offset += (s % 2) * 2;
                     offset += (s / 2) * (width * 2 * 2);
                     offset += (q * 256) * 8;
                     Subtile subtile = tile.Subtiles[s];
                     if (subtile == null)
                     {
                         continue;
                     }
                     Bits.SetShort(Tileset_bytes, offset, (ushort)subtile.Index);
                     Tileset_bytes[offset + 1] |= (byte)(subtile.Palette << 2);
                     Bits.SetBit(Tileset_bytes, offset + 1, 5, subtile.Priority1);
                     Bits.SetBit(Tileset_bytes, offset + 1, 6, subtile.Mirror);
                     Bits.SetBit(Tileset_bytes, offset + 1, 7, subtile.Invert);
                 }
             }
         }
     }
     Model.EditTilesets[Battlefield.Tileset] = true;
     if (Battlefield.GraphicSetA < 0xC8)
     {
         Buffer.BlockCopy(Graphics, 0, Areas.Model.GraphicSets[Battlefield.GraphicSetA + 0x48], 0, 0x2000);
     }
     if (Battlefield.GraphicSetB < 0xC8)
     {
         Buffer.BlockCopy(Graphics, 0x2000, Areas.Model.GraphicSets[Battlefield.GraphicSetB + 0x48], 0, 0x1000);
     }
     if (Battlefield.GraphicSetC < 0xC8)
     {
         Buffer.BlockCopy(Graphics, 0x3000, Areas.Model.GraphicSets[Battlefield.GraphicSetC + 0x48], 0, 0x1000);
     }
     if (Battlefield.GraphicSetD < 0xC8)
     {
         Buffer.BlockCopy(Graphics, 0x4000, Areas.Model.GraphicSets[Battlefield.GraphicSetD + 0x48], 0, 0x1000);
     }
     if (Battlefield.GraphicSetE < 0xC8)
     {
         Buffer.BlockCopy(Graphics, 0x5000, Areas.Model.GraphicSets[Battlefield.GraphicSetE + 0x48], 0, 0x1000);
     }
 }
Пример #5
0
        public void CreateTileset()
        {
            int offset = 0x1CEA00;
            int index = 0, loc = 0, place = 0;

            int[] palette = new int[16];
            for (int i = 0; i < palette.Length; i++)
            {
                palette[i] = Color.Black.ToArgb();
            }
            Subtile source;

            Tile[] subtiles;
            // Iterate through all 104 tiles
            for (int i = 0; i < Tileset.Length; i++)
            {
                subtiles = new Tile[4];
                for (int o = 0; o < subtiles.Length; o++)
                {
                    subtiles[o] = new Tile(o);
                }
                for (int a = 0; a < 4; a++) // the four 16x16 tiles in an overlap tile
                {
                    index  = Model.ROM[i * 5 + a + offset];
                    place  = (i / 8) * 32;
                    place += ((i % 8) * 2) + (a % 2) + ((a / 2) * 16);
                    subtiles[a].Mirror = Bits.GetBit(Model.ROM, i * 5 + 4 + offset, ((a * 2) + 1) ^ 7);
                    subtiles[a].Invert = Bits.GetBit(Model.ROM, i * 5 + 4 + offset, (a * 2) ^ 7);
                    if (index != 0)
                    {
                        index--;
                        loc    = index % 8 * 0x40;
                        loc   += index / 8 * 0x400;
                        source = new Subtile(index, GraphicSet, loc, palette, false, false, false, false);
                        subtiles[a].Subtiles[0] = source;
                        source = new Subtile(index, GraphicSet, loc + 0x20, palette, false, false, false, false);
                        subtiles[a].Subtiles[1] = source;
                        source = new Subtile(index, GraphicSet, loc + 0x200, palette, false, false, false, false);
                        subtiles[a].Subtiles[2] = source;
                        source = new Subtile(index, GraphicSet, loc + 0x220, palette, false, false, false, false);
                        subtiles[a].Subtiles[3] = source;
                    }
                    else
                    {
                        source = new Subtile(index, new byte[0x20], 0, palette, false, false, false, false);
                        subtiles[a].Subtiles[0] = source;
                        subtiles[a].Subtiles[1] = source;
                        subtiles[a].Subtiles[2] = source;
                        subtiles[a].Subtiles[3] = source;
                    }
                    Tileset[i].Subtiles[a] = subtiles[a];
                }
            }
        }
Пример #6
0
            // Subtiles
            public void DrawSubtiles(byte[] graphics, int[] palette, bool gridplane)
            {
                int stop = 0;

                if (gridplane)
                {
                    if (Subtile_bytes == null)
                    {
                        return;
                    }
                    switch (Format)
                    {
                    case 0: stop = 9; break;

                    case 1:
                    case 2: stop = 12; break;

                    case 3: stop = 16; break;
                    }
                    Subtile_tiles = new Subtile[16];
                    for (int i = 0; i < stop; i++)
                    {
                        if (Subtile_bytes[i] != 0)
                        {
                            Subtile_tiles[i] = new Subtile(Subtile_bytes[i] - 1, graphics, (Subtile_bytes[i] - 1) * 0x20, palette, false, false, false, false);
                        }
                        else
                        {
                            Subtile_tiles[i] = new Subtile(0, new byte[0x20], 0, new int[16], false, false, false, false);
                        }
                    }
                }
                else
                {
                    Subtile_tiles = new Subtile[4];
                    for (int i = 0; i < 4; i++)
                    {
                        if (Subtile_bytes[i] != 0)
                        {
                            Subtile_tiles[i] = new Subtile(Subtile_bytes[i] - 1, graphics, (Subtile_bytes[i] - 1) * 0x20, palette, false, false, false, false);
                        }
                        else
                        {
                            Subtile_tiles[i] = new Subtile(0, new byte[0x20], 0, new int[16], false, false, false, false);
                        }
                    }
                }
            }
Пример #7
0
 public bool Equals(Subtile other)
 {
     return(X == other.X && Y == other.Y);
 }
Пример #8
0
        /// <summary>
        /// tileSubTile fills the specified sub-tile while tileBorder draws a line around the edge of the tile at the specified sub-tile location, or around the whole tile if subtile is MM.
        /// </summary>
        public static void OverlayTileSubTile(float x, float y, Subtile subtile)
        {
#if DEBUG
            System.Console.Out.WriteLine("v tileSubTile " + y + " " + x + " " + subtile);
#endif
        }