コード例 #1
0
        private void ImportTilemap(byte[] array, int layer, int offset)
        {
            if (!checkBox4.Checked || tilemap.Tilemaps_Tiles[layer] == null)
            {
                return;
            }
            int  counter = 0;
            int  extratiles = 256;
            bool mirror, invert;

            for (int i = 0; i < tilemap.Tilemaps_Tiles[layer].Length; i++)
            {
                int tile = Bits.GetShort(array, offset) & 0x1FF;
                mirror = Bits.GetBit(array, offset + 1, 6);
                invert = Bits.GetBit(array, offset + 1, 7);
                tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][tile];
                if (layer != 2)
                {
                    Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter, tile);
                    counter += 2; offset += 2;
                }
                else
                {
                    tilemap.Tilemaps_Bytes[layer][counter] = (byte)tile;
                    counter++; offset += 2;
                }
                if (tileset.Tilesets_tiles[layer] == null || tileset.Tilesets_tiles[layer].Length != 512)
                {
                    continue;
                }
                if (mirror || invert)
                {
                    Tile copy = tileset.Tilesets_tiles[layer][tile].Copy();
                    if (mirror)
                    {
                        Do.FlipHorizontal(copy);
                    }
                    if (invert)
                    {
                        Do.FlipVertical(copy);
                    }
                    Tile contains = Do.Contains(tileset.Tilesets_tiles[layer], copy);
                    if (contains == null)
                    {
                        tileset.Tilesets_tiles[layer][extratiles]       = copy;
                        tileset.Tilesets_tiles[layer][extratiles].Index = extratiles;
                        tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][extratiles];
                        Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter - 2, extratiles);
                        extratiles++;
                    }
                    else
                    {
                        tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][contains.Index];
                        Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter - 2, contains.Index);
                    }
                }
            }
        }
コード例 #2
0
        public void DrawOverlapsTileSet(OverlapTile[] tileset)
        {
            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;
            for (int i = 0; i < tileset.Length; i++)   // for all 104 overlap tiles
            {
                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].SetSubtile(subtiles[a], a);
                }
            }
        }
コード例 #3
0
        // disassembler
        private void Disassemble()
        {
            int offset = (index * 20) + 0x3A002C;

            //
            startingLevel      = rom[offset++];
            startingCurrentHP  = Bits.GetShort(rom, offset); offset += 2;
            startingMaxHP      = Bits.GetShort(rom, offset); offset += 2;
            startingSpeed      = rom[offset++];
            startingAttack     = rom[offset++];
            startingDefense    = rom[offset++];
            startingMgAttack   = rom[offset++];
            startingMgDefense  = rom[offset++];
            startingExperience = Bits.GetShort(rom, offset); offset += 2;
            startingWeapon     = rom[offset++];
            startingArmor      = rom[offset++];
            startingAccessory  = rom[offset]; offset += 2;
            //
            startingMagic = new bool[32];
            int a = 0;

            for (int o = 0; o < 4; o++, offset++)
            {
                for (int i = 0; i < 8; i++)
                {
                    startingMagic[a++] = Bits.GetBit(rom, offset, i);
                }
            }
            // set up the levels
            levels = new LevelUp[31];
            for (int i = 2; i < levels.Length; i++)
            {
                levels[i] = new LevelUp(i, index);
            }
            //
            startingCoins     = Bits.GetShort(rom, 0x3A00DB);
            startingCurrentFP = rom[0x3A00DD];
            startingMaximumFP = rom[0x3A00DE];
            startingFrogCoins = Bits.GetShort(rom, 0x3A00DF);
            //
            defenseStartL1 = rom[0x02C9B3];
            defenseStartL2 = rom[0x02C9B9];
            defenseEndL2   = rom[0x02C9BF];
            defenseEndL1   = rom[0x02C9C5];
            //
            name = new char[10];
            for (int i = 0; i < name.Length; i++)
            {
                name[i] = (char)rom[(index * 10) + 0x3a134d + i];
            }
        }
コード例 #4
0
        // assemblers
        private void Disassemble()
        {
            int offset = index * 5 + 0x1DB000;

            //
            sprite     = (byte)(rom[offset] & 0x3F);
            b0         = (byte)(rom[offset++] >> 6);
            b1a        = (byte)(rom[offset] & 0x07);
            b1b        = (byte)((rom[offset] >> 3) & 0x03);
            b1c        = (byte)(rom[offset++] >> 5);
            b2b2       = Bits.GetBit(rom, offset, 2);
            b2b3       = Bits.GetBit(rom, offset, 3);
            b2b4       = Bits.GetBit(rom, offset, 4);
            showShadow = Bits.GetBit(rom, offset, 5);
            b2         = (byte)(rom[offset++] >> 6);
            action     = (ushort)(Bits.GetShort(rom, offset++) & 0x3FF);
            b4         = (byte)(rom[offset] >> 4);
        }
コード例 #5
0
        public void Invert(int[] palette)
        {
            int maxY = GetBottomMostPixel(palette);
            int maxX = GetRightMostPixel(palette);
            int minY = GetTopMostPixel(palette);
            int minX = GetLeftMostPixel(palette);

            for (int x = minX; x < maxX + 1; x++)
            {
                for (int a = minY, b = maxY; a < b; a++, b--)
                {
                    byte rowA    = (byte)a;
                    byte colA    = (byte)x;
                    byte bitA    = (byte)((colA & 7) ^ 7);
                    int  offsetA = rowA * 2;
                    byte rowB    = (byte)b;
                    byte colB    = (byte)x;
                    byte bitB    = (byte)((colB & 7) ^ 7);
                    int  offsetB = rowB * 2;
                    switch (Type)
                    {
                    case FontType.Menu:
                    case FontType.Description:
                        bool tempM = Bits.GetBit(Graphics, offsetA, bitA);
                        bool tempN = Bits.GetBit(Graphics, offsetA + 1, bitA);
                        Bits.SetBit(Graphics, offsetA, bitA, Bits.GetBit(Graphics, offsetB, bitB));
                        Bits.SetBit(Graphics, offsetA + 1, bitA, Bits.GetBit(Graphics, offsetB + 1, bitB));
                        Bits.SetBit(Graphics, offsetB, bitB, tempM);
                        Bits.SetBit(Graphics, offsetB + 1, bitB, tempN);
                        break;

                    case FontType.Dialogue:
                        offsetA += colA >= 8 ? 24 : 0;
                        offsetB += colB >= 8 ? 24 : 0;
                        goto case 0;

                    case FontType.Triangles:
                        offsetA += colA >= 8 ? 16 : 0;
                        offsetB += colB >= 8 ? 16 : 0;
                        goto case 0;
                    }
                }
            }
        }
コード例 #6
0
        private void ImportTileset(byte[] array, int layer, int offset)
        {
            if (!checkBox3.Checked || tileset.Tilesets_tiles[layer] == null)
            {
                return;
            }
            int  length;
            byte format;

            if (layer == 2)
            {
                length = tileset.GraphicsL3.Length;
                format = 0x10;
            }
            else
            {
                length = tileset.Graphics.Length;
                format = 0x20;
            }
            foreach (Tile tile in tileset.Tilesets_tiles[layer])
            {
                if (tile == null)
                {
                    offset += 3;
                    continue;
                }
                foreach (Subtile subtile in tile.Subtiles)
                {
                    subtile.Index = Bits.GetShort(array, offset);
                    if (subtile.Index * format >= length)
                    {
                        subtile.Index = 0;
                    }
                    offset           += 2;
                    subtile.Palette   = array[offset] & 7;
                    subtile.Priority1 = Bits.GetBit(array, offset, 5);
                    subtile.Mirror    = Bits.GetBit(array, offset, 6);
                    subtile.Invert    = Bits.GetBit(array, offset, 7);
                    offset++;
                }
            }
        }