コード例 #1
0
        // assemblers
        private void Disassemble()
        {
            int    offset;
            ushort offsetStart = 0;
            ushort offsetEnd   = 0;
            Mod    tMod;
            int    pointerOffset = (index * 2) + 0x1D5EBD;

            offsetStart = Bits.GetShort(rom, pointerOffset); pointerOffset += 2;
            offsetEnd   = Bits.GetShort(rom, pointerOffset);
            if (index == 0x1FF)
            {
                offsetEnd = 0;
            }
            if (offsetStart >= offsetEnd)
            {
                return; // no exit fields for level
            }
            offset = offsetStart + 0x1D0000;
            while (offset < offsetEnd + 0x1D0000)
            {
                tMod = new Mod();
                tMod.Disassemble(ref offset);
                mods.Add(tMod);
            }
        }
コード例 #2
0
 public static void SetBit(byte[] data, int offset, int bit, bool value)
 {
     try
     {
         if (bit < 8)
         {
             if (value)
             {
                 data[offset] |= (byte)(Math.Pow(2, bit));
             }
             else if (!value)
             {
                 data[offset] &= (byte)((byte)(Math.Pow(2, bit)) ^ 0xFF);
             }
         }
         else
         {
             ushort number = Bits.GetShort(data, offset);
             if (value)
             {
                 number |= (ushort)(Math.Pow(2, bit));
             }
             else
             {
                 number &= (ushort)((ushort)(Math.Pow(2, bit)) ^ 0xFFFF);
             }
             Bits.SetShort(data, offset, number);
         }
     }
     catch
     {
         ShowError(offset, data.Length);
         throw new Exception();
     }
 }
コード例 #3
0
        // public functions
        public void Refresh()
        {
            sequences   = new List <Sequence>();
            molds       = new List <Mold>();
            uniqueTiles = new List <Mold.Tile>();
            //
            int    offset = 2;
            ushort sequencePacketPointer = Bits.GetShort(buffer, offset); offset += 2;
            ushort moldPacketPointer     = Bits.GetShort(buffer, offset); offset += 2;
            byte   sequenceCount         = buffer[offset++];
            byte   moldCount             = buffer[offset++];

            vramAllocation = (ushort)(buffer[offset] << 8); offset += 2;
            unknown        = Bits.GetShort(buffer, offset);
            //
            offset = sequencePacketPointer;
            for (int i = 0; i < sequenceCount; i++)
            {
                Sequence tSequence = new Sequence();
                tSequence.Disassemble(buffer, offset);
                sequences.Add(tSequence);
                offset += 2;
            }
            offset = moldPacketPointer;
            for (int i = 0; i < moldCount; i++)
            {
                Mold tMold = new Mold();
                tMold.Disassemble(buffer, offset, uniqueTiles, index, animationOffset);
                molds.Add(tMold);
                offset += 2;
            }
        }
コード例 #4
0
        // assemblers
        private void Disassemble()
        {
            int    pointerOffset = (index * 2) + 0x1D8DB0;
            ushort offsetStart   = Bits.GetShort(rom, pointerOffset); pointerOffset += 2;
            ushort offsetEnd     = Bits.GetShort(rom, pointerOffset);

            if (index == 0x1FF)
            {
                offsetEnd = 0;
            }
            // no exit fields for level
            if (offsetStart >= offsetEnd)
            {
                return;
            }
            //
            int offset = offsetStart + 0x1D0000;

            if (index == 84)
            {
                index = 84;
            }
            while (offset < offsetEnd + 0x1D0000)
            {
                LevelMod tMod = new LevelMod();
                tMod.Disassemble(ref offset);
                mods.Add(tMod);
            }
        }
コード例 #5
0
        // assemblers
        private void Disassemble()
        {
            animationOffset = Bits.GetInt24(rom, 0x252000 + (index * 3)) - 0xC00000;
            int animationLength = Bits.GetShort(rom, animationOffset);

            buffer = Bits.GetBytes(rom, animationOffset, animationLength);
            //
            int    offset = 2;
            ushort sequencePacketPointer = Bits.GetShort(buffer, offset); offset += 2;
            ushort moldPacketPointer     = Bits.GetShort(buffer, offset); offset += 2;
            byte   sequenceCount         = buffer[offset++];
            byte   moldCount             = buffer[offset++];

            vramAllocation = (ushort)(buffer[offset] << 8); offset += 2;
            unknown        = Bits.GetShort(buffer, offset);
            //
            offset = sequencePacketPointer;
            for (int i = 0; i < sequenceCount; i++)
            {
                Sequence tSequence = new Sequence();
                tSequence.Disassemble(buffer, offset);
                sequences.Add(tSequence);
                offset += 2;
            }
            offset = moldPacketPointer;
            for (int i = 0; i < moldCount; i++)
            {
                Mold tMold = new Mold();
                tMold.Disassemble(buffer, offset, uniqueTiles, index, animationOffset);
                molds.Add(tMold);
                offset += 2;
            }
        }
コード例 #6
0
            // disassembler
            private void Disassemble()
            {
                int offset = 0x3A1AFF + ((index - 2) * 2);

                expNeeded = Bits.GetShort(rom, offset);
                //
                byte temp;

                offset = (owner * 3) + ((index - 2) * 15) + 0x3A1B39;
                hpPlus = rom[offset++];
                temp   = rom[offset]; attackPlus = (byte)((temp & 0xF0) >> 4);
                temp   = rom[offset]; defensePlus = (byte)((temp & 0x0F)); offset++;
                temp   = rom[offset]; mgAttackPlus = (byte)((temp & 0xF0) >> 4);
                temp   = rom[offset]; mgDefensePlus = (byte)((temp & 0x0F)); offset++;
                //
                offset      = (owner * 3) + ((index - 2) * 15) + 0x3A1CEC;
                hpPlusBonus = rom[offset++];
                temp        = rom[offset]; attackPlusBonus = (byte)((temp & 0xF0) >> 4);
                temp        = rom[offset]; defensePlusBonus = (byte)((temp & 0x0F)); offset++;
                temp        = rom[offset]; mgAttackPlusBonus = (byte)((temp & 0xF0) >> 4);
                temp        = rom[offset]; mgDefensePlusBonus = (byte)((temp & 0x0F)); offset++;
                //
                spellLearned = rom[owner + ((index - 2) * 5) + 0x3A42F5];
                if (spellLearned > 0x1F)
                {
                    spellLearned = 0x20;
                }
            }
コード例 #7
0
        public void DrawTileset(byte[] src, Tile[] dst)
        {
            byte    temp;
            ushort  tile;
            Subtile source;
            int     offset = 0;

            for (int i = 0; i < dst.Length; i++)
            {
                for (int z = 0; z < 2; z++)
                {
                    tile               = (ushort)(Bits.GetShort(src, offset) & 0x03FF); offset++;
                    temp               = src[offset++];
                    source             = Do.DrawSubtile(tile, temp, graphics, palettes.Palettes, 0x20);
                    dst[i].Subtiles[z] = source;
                }
                offset += 60; // jump forward in buffer to grab correct 8x8 tiles
                for (int a = 2; a < 4; a++)
                {
                    tile               = (ushort)(Bits.GetShort(src, offset) & 0x03FF); offset++;
                    temp               = src[offset++];
                    source             = Do.DrawSubtile(tile, temp, graphics, palettes.Palettes, 0x20);
                    dst[i].Subtiles[a] = source;
                }
                if ((i - 15) % 16 == 0)
                {
                    offset += 64;
                }
                offset -= 64; // jump back in buffer so that we can start the next 16x16 tile
            }
        }
コード例 #8
0
        // class functions
        private char[] GetText()
        {
            this.pointer = Bits.GetShort(rom, 0x249000 + index * 2); // from pointer table
            this.offset  = pointer + 0x249100;
            //
            int counter = this.offset;
            int length  = 0;
            int letter  = -1;

            while (letter != 0x00 && letter != 0x06)
            {
                letter = rom[counter];
                if (letter == 0x0B || letter == 0x0D || letter == 0x1C)
                {
                    length++;
                    counter++;
                }
                length++;
                counter++;
            }
            length--;
            char[] text = new char[length];
            for (int i = 0; i < length; i++)
            {
                text[i] = (char)rom[this.offset + i];
            }
            return(text);
        }
コード例 #9
0
        // constructor
        public MenuTexts(int index)
        {
            this.index = index;
            int         offset     = Bits.GetShort(Model.ROM, index * 2 + 0x3EEF00) + 0x3EF000;
            List <char> characters = new List <char>();

            while (Model.ROM[offset] != 0)
            {
                characters.Add((char)Model.ROM[offset++]);
            }
            Text = characters.ToArray();
            //
            switch (index)
            {
            case 14: x = (Model.ROM[0x03328E] & 0x3F) / 2; break;

            case 15: x = (Model.ROM[0x03327E] & 0x3F) / 2; break;

            case 16: x = (Model.ROM[0x033282] & 0x3F) / 2; break;

            case 17: x = (Model.ROM[0x033286] & 0x3F) / 2; break;

            case 18: x = (Model.ROM[0x03328A] & 0x3F) / 2; break;

            case 19: x = (Model.ROM[0x03327A] & 0x3F) / 2; break;
            }
        }
コード例 #10
0
        private void Disassemble()
        {
            int    pointerOffset = (index * 2) + 0x20E000;
            ushort offsetStart   = Bits.GetShort(rom, pointerOffset); pointerOffset += 2;
            ushort offsetEnd     = Bits.GetShort(rom, pointerOffset);

            if (index == 0x1FF)
            {
                offsetEnd = 0;
            }
            // no event fields for level
            if (offsetStart >= offsetEnd)
            {
                return;
            }
            //
            int offset = offsetStart + 0x200000;

            music         = rom[offset++];
            entranceEvent = Bits.GetShort(rom, offset); offset += 2;
            while (offset < offsetEnd + 0x200000)
            {
                Event tEvent = new Event();
                tEvent.Disassemble(offset);
                events.Add(tEvent);
                offset += 5;
                if (tEvent.Width > 0)
                {
                    offset += 1;
                }
            }
        }
コード例 #11
0
        // assemblers
        public void Disassemble(int offset)
        {
            runEvent = (ushort)(Bits.GetShort(rom, offset++) & 0x0FFF);
            byte temp          = rom[offset++];
            bool lengthOverOne = (temp & 0x80) == 0x80;

            //
            temp = rom[offset++];
            if ((temp & 0x80) == 0x80)
            {
                x_half = true;
            }
            x    = (byte)(temp & 0x7F);
            temp = rom[offset++];
            if ((temp & 0x80) == 0x80)
            {
                y_half = true;
            }
            y      = (byte)(temp & 0x7F);
            temp   = rom[offset++];
            z      = (byte)(temp & 0x1F);
            height = (byte)((temp & 0xF0) >> 5);
            //
            if (lengthOverOne)
            {
                temp  = rom[offset++];
                width = (byte)(temp & 0x0F);
                f     = (byte)((temp & 0x80) >> 7);
            }
        }
コード例 #12
0
        private void Disassemble()
        {
            int    pointerOffset = (index * 2) + 0x148000;
            ushort offsetStart   = Bits.GetShort(rom, pointerOffset); pointerOffset += 2;
            ushort offsetEnd     = Bits.GetShort(rom, pointerOffset);

            if (index == 0x1FF)
            {
                offsetEnd = 0;
            }
            // no npc fields for level
            if (offsetStart >= offsetEnd)
            {
                return;
            }
            //
            int offset = offsetStart + 0x140000;

            this.startingOffset = offset;
            this.partition      = rom[offset++];
            while (offset < offsetEnd + 0x140000)
            {
                NPC tNPC = new NPC();
                tNPC.Disassemble(offset);
                npcs.Add(tNPC);
                offset += 12;
                for (int i = 0; i < tNPC.CloneAmount; i++)
                {
                    offset += 4;
                }
            }
        }
コード例 #13
0
        // class functions
        private char[] GetText()
        {
            this.offset = Bits.GetShort(rom, pointerOffset + index * 2) + baseOffset;
            int counter = this.offset;
            int length  = 0;
            int letter  = -1;

            while (letter != 0x00 && letter != 0x06)
            {
                letter = rom[counter];
                if (letter == 0x0B || letter == 0x0D || letter == 0x1C)
                {
                    length++;
                    counter++;
                }
                length++;
                counter++;
            }
            char[] text = new char[length];
            for (int i = 0; i < length; i++)
            {
                text[i] = (char)rom[this.offset + i];
            }
            return(text);
        }
コード例 #14
0
        private void DrawWavelength(Graphics g, int width, int height, byte[] wav)
        {
            int          size    = Bits.GetInt32(wav, 0x0028) / 2;
            int          offset  = 0x2C;
            List <Point> points  = new List <Point>();
            double       w_ratio = (double)width / (double)size;
            double       h_ratio = (double)height / 65536.0;

            for (int i = 0; i < size; i++)
            {
                int x = (int)((double)i * w_ratio);
                int y = (int)((double)(Bits.GetShort(wav, offset) ^ 0x8000) * h_ratio);
                points.Add(new Point(x, y));
                offset += 2;
            }
            int loopStart = (int)((double)sample.LoopStart / (double)sample.Length * (double)width);

            if (loopStart < 0)
            {
                loopStart = 0;
            }
            g.DrawLine(Pens.Gray, 0, height / 2, width, height / 2);
            g.DrawLine(Pens.Gray, loopStart, 0, loopStart, height);
            g.DrawLines(Pens.Lime, points.ToArray());
        }
コード例 #15
0
        private void UpdateInformationLabels()
        {
            if (selection + 2 >= rom.Length)
            {
                return;
            }
            info_offset.Text = "Offset: " + selection.ToString("X6");
            if (ROMData.SelectionLength / 3 == 3)
            {
                info_value.Text = "Value: " + Bits.GetInt24(rom, selection).ToString();
            }
            else if (ROMData.SelectionLength / 3 == 2)
            {
                info_value.Text = "Value: " + Bits.GetShort(rom, selection).ToString();
            }
            else if (ROMData.SelectionLength / 3 <= 1)
            {
                info_value.Text = "Value: " + rom[selection].ToString();
            }
            else
            {
                info_value.Text = "Value: ";
            }
            int sel = ROMData.SelectionLength / 3;

            info_sel.Text = "Sel: 0x" + sel.ToString("X") + " (" + sel.ToString() + ") bytes";
        }
コード例 #16
0
        private void Disassemble()
        {
            int     offset;
            ushort  offsetStart = 0;
            ushort  offsetEnd   = 0;
            Overlap tOverlap;
            int     pointerOffset = (index * 2) + 0x1D4905;

            offsetStart = Bits.GetShort(rom, pointerOffset); pointerOffset += 2;
            offsetEnd   = Bits.GetShort(rom, pointerOffset);
            if (index == 0x1FF)
            {
                offsetEnd = 0;
            }
            if (offsetStart >= offsetEnd)
            {
                return; // no overlaps for level
            }
            offset = offsetStart + 0x1D0000;
            while (offset < offsetEnd + 0x1D0000)
            {
                tOverlap = new Overlap();
                tOverlap.Disassemble(offset);
                overlaps.Add(tOverlap);
                offset += 4;
            }
        }
コード例 #17
0
        private void Disassemble()
        {
            int    pointerOffset = (index * 2) + 0x1D2D64;
            ushort offsetStart   = Bits.GetShort(rom, pointerOffset);
            ushort offsetEnd     = Bits.GetShort(rom, pointerOffset + 2);

            if (index == 0x1FF)
            {
                offsetEnd = 0;
            }
            // no exit fields for level
            if (offsetStart >= offsetEnd)
            {
                return;
            }
            int offset = offsetStart + 0x1D0000;

            while (offset < offsetEnd + 0x1D0000)
            {
                Exit tExit = new Exit();
                tExit.Disassemble(offset);
                exits.Add(tExit);
                offset += 5;
                if (tExit.ExitType == 0)
                {
                    offset += 3;
                }
                if (tExit.Width > 0)
                {
                    offset += 1;
                }
            }
        }
コード例 #18
0
        // assemblers
        private void Disassemble()
        {
            int    offset = index * 7 + 0x1DB800;
            ushort temp   = Bits.GetShort(rom, offset++);

            //
            sprite = (ushort)(temp & 0x03FF);
            byte1a = (byte)((rom[offset] >> 2) & 7);
            byte1b = (byte)(rom[offset++] >> 5);
            //
            priority0 = (rom[offset] & 0x20) == 0x20;
            priority1 = (rom[offset] & 0x40) == 0x40;
            priority2 = (rom[offset] & 0x80) == 0x80;
            b2b0      = (rom[offset] & 0x01) == 0x01;
            b2b1      = (rom[offset] & 0x02) == 0x02;
            b2b2      = (rom[offset] & 0x04) == 0x04;
            b2b3      = (rom[offset] & 0x08) == 0x08;
            b2b4      = (rom[offset++] & 0x10) == 0x10;
            //
            yPixelShiftUp = (byte)(rom[offset] & 0x0F);
            shift16pxDown = (rom[offset] & 0x10) == 0x10;
            shadow        = (byte)((rom[offset] & 0x60) >> 5);
            activeVRAM    = (rom[offset++] & 0x80) == 0x80;
            //
            acuteAxis  = (byte)(rom[offset] & 0x0F);
            obtuseAxis = (byte)((rom[offset++] & 0xF0) >> 4);
            //
            height     = (byte)(rom[offset] & 0x1F);
            showShadow = (rom[offset] & 0x20) == 0x20;
            b5b6       = (rom[offset] & 0x40) == 0x40;
            b5b7       = (rom[offset++] & 0x80) == 0x80;
            //
            b6b2 = (rom[offset] & 0x04) == 0x04;
        }
コード例 #19
0
        // assemblers
        private void Disassemble()
        {
            // mode7 objects
            int offset = Bits.GetShort(buffer, 0);

            for (int i = 0; i < 8; i++)
            {
                M7ObjectsA[i] = new MCObject(buffer[offset++], buffer[offset++]);
            }
            for (int i = 0; i < 8; i++)
            {
                M7ObjectsB[i] = new MCObject(buffer[offset++], buffer[offset++]);
            }
            // side-scrolling objects A
            SSObjectsA = new List <MCObject>();
            offset     = Bits.GetShort(buffer, 2);
            WidthA     = Bits.GetShort(buffer, offset); offset += 2;
            while (Bits.GetShort(buffer, offset) != 0xFFFF)
            {
                int x    = Bits.GetShort(buffer, offset) + 256; offset += 2;
                int type = buffer[offset++];
                int size = buffer[offset++];
                int y    = buffer[offset++];
                SSObjectsA.Add(new MCObject(type, x, y, size));
            }
            // side-scrolling objects B
            SSObjectsB = new List <MCObject>();
            offset     = Bits.GetShort(buffer, 4);
            WidthB     = Bits.GetShort(buffer, offset); offset += 2;
            while (Bits.GetShort(buffer, offset) != 0xFFFF)
            {
                int x    = Bits.GetShort(buffer, offset) + 256; offset += 2;
                int type = buffer[offset++];
                int size = buffer[offset++];
                int y    = buffer[offset++];
                SSObjectsB.Add(new MCObject(type, x, y, size));
            }
            // side-scrolling L1 screens
            L1Screens = new List <int>();
            offset    = Bits.GetShort(buffer, 6);
            while (offset != Bits.GetShort(buffer, 8))
            {
                L1Screens.Add(buffer[offset++]);
            }
            // side-scrolling L2 screens
            L2Screens = new List <int>();
            offset    = Bits.GetShort(buffer, 8);
            while (offset != Bits.GetShort(buffer, 10))
            {
                L2Screens.Add(buffer[offset++]);
            }
            // side-scrolling rail screens (2nd map)
            RailScreens = new List <int>();
            offset      = Bits.GetShort(buffer, 10);
            while (offset < buffer.Length)
            {
                RailScreens.Add(buffer[offset++]);
            }
        }
コード例 #20
0
        // assemblers
        private void Disassemble()
        {
            int offset = (index * 4) + 0x250000;

            image           = (ushort)(Bits.GetShort(rom, offset) & 0x1FF); offset++;
            paletteIndex    = (byte)((rom[offset] & 0x0E) >> 1); offset++;
            animationPacket = Bits.GetShort(rom, offset);
        }
コード例 #21
0
        // assemblers
        private void Disassemble()
        {
            animationOffset = Bits.GetInt24(rom, 0x252C00 + (index * 3)) - 0xC00000;
            ushort animationLength = Bits.GetShort(rom, animationOffset);

            buffer = Bits.GetBytes(rom, animationOffset, Bits.GetShort(rom, animationOffset));
            //
            int    offset                = 2;
            ushort graphicSetPointer     = Bits.GetShort(buffer, offset); offset += 2;
            ushort paletteSetPointer     = Bits.GetShort(buffer, offset); offset += 2;
            ushort sequencePacketPointer = Bits.GetShort(buffer, offset); offset += 2;
            ushort moldPacketPointer     = Bits.GetShort(buffer, offset); offset += 2;

            // skip 2 unknown bytes
            offset += 2;
            //
            width  = buffer[offset++];
            height = buffer[offset++];
            codec  = Bits.GetShort(buffer, offset); offset += 2;
            //
            int tileSetPointer = Bits.GetShort(buffer, offset);

            graphicSetLength = paletteSetPointer - graphicSetPointer;
            graphicSet       = new byte[0x2000];
            Buffer.BlockCopy(buffer, graphicSetPointer, graphicSet, 0, graphicSetLength);
            paletteSetLength = (ushort)(tileSetPointer - paletteSetPointer);
            paletteSet       = new PaletteSet(buffer, 0, paletteSetPointer, 8, 16, 32);
            tilesetLength    = sequencePacketPointer - tileSetPointer - 2;
            tileset_bytes    = new byte[64 * 4 * 2 * 4];
            Buffer.BlockCopy(buffer, tileSetPointer, tileset_bytes, 0, tilesetLength);
            //
            offset = sequencePacketPointer;
            for (int i = 0; Bits.GetShort(buffer, offset) != 0x0000; i++)
            {
                E_Sequence tSequence = new E_Sequence();
                tSequence.Disassemble(buffer, offset);
                sequences.Add(tSequence);
                offset += 2;
            }
            offset = moldPacketPointer;
            ushort end = 0;

            for (int i = 0; Bits.GetShort(buffer, offset) != 0x0000; i++)
            {
                if (Bits.GetShort(buffer, offset + 2) == 0x0000)
                {
                    end = animationLength;
                }
                else
                {
                    end = Bits.GetShort(buffer, offset + 2);
                }
                E_Mold tMold = new E_Mold();
                tMold.Disassemble(buffer, offset, end);
                molds.Add(tMold);
                offset += 2;
            }
        }
コード例 #22
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);
                    }
                }
            }
        }
コード例 #23
0
        // tooltips
        public void Assemble()
        {
            Model.ROM[0x037DCF] = (byte)this.music.SelectedIndex;
            //
            Model.Compress(Model.WorldMapLogos, 0x3E004C, 0x2000, 0xE1C, "World map logos, banners");
            //
            foreach (WorldMap wm in worldMaps)
            {
                wm.Assemble();
            }
            // Graphics
            Model.WorldMapLogoPalette.Assemble(Model.MenuPalettes, 0xE0);
            int offset  = Bits.GetShort(Model.ROM, 0x3E000C) + 0x3E0000;
            int maxComp = Bits.GetShort(Model.ROM, 0x3E000E) - Bits.GetShort(Model.ROM, 0x3E000C);

            Model.Compress(Model.MenuPalettes, offset, 0x200, maxComp, "World map logo palettes");
            Model.Compress(Model.WorldMapGraphics, 0x3E2E81, 0x8000, 0x56F6, "Graphics");
            //   Model.Compress(Model.WorldMapSprites, 0x3E90A7, 0x400, 0x1F8, "Sprite Graphics");
            // Tilesets
            byte[] compress  = new byte[0x800];
            int    totalSize = 0;
            int    pOffset   = 0x3E0014;
            int    dOffset   = 0x3E929F;
            int    size      = 0;

            for (int i = 0; i < Model.WorldMapTilesets.Length; i++)
            {
                Bits.SetShort(Model.ROM, pOffset, (ushort)dOffset);
                size       = Comp.Compress(Model.WorldMapTilesets[i], compress);
                totalSize += size + 1;
                if (totalSize > 0x4D8)
                {
                    MessageBox.Show(
                        "Recompressed tilesets exceed allotted ROM space by " + (totalSize - 0x4D6).ToString() + " bytes.\nSaving has been discontinued for tilesets " + i.ToString() + " and higher.\nChange or delete some tiles to reduce the size.",
                        "LAZY SHELL");
                    break;
                }
                else
                {
                    Model.ROM[dOffset] = 1; dOffset++;
                    Bits.SetBytes(Model.ROM, dOffset, compress, 0, size - 1);
                    dOffset += size;
                    pOffset += 2;
                }
            }
            Bits.SetShort(Model.ROM, pOffset, (ushort)dOffset);
            Model.Compress(Model.WorldMapLogoTileset, dOffset, 0x800, 0xC1, "World map logo tileset");
            // Palettes
            palettes.Assemble(Model.WorldMapPalettes, 0);
            Model.Compress(Model.WorldMapPalettes, 0x3E988C, 0x100, 0xD4, "Palette set");
            foreach (Location mp in locations)
            {
                mp.Assemble();
            }
            AssembleLocationTexts();
            this.Modified = false;
        }
コード例 #24
0
 // disassemblers
 public void Disassemble(byte[] buffer, int offset, ushort end)
 {
     this.buffer = buffer;
     moldOffset  = (ushort)offset;
     offset      = Bits.GetShort(buffer, offset);
     mold        = new byte[256];
     byte[] compressed = new byte[end - offset];
     Buffer.BlockCopy(buffer, offset, compressed, 0, end - offset);
     Decompress(compressed, mold);
 }
コード例 #25
0
 public void RefreshLevel()
 {
     if (Index < 2)
     {
         paletteSet = Model.MinecartM7PaletteSet;
         tileset    = new Tileset(Model.MinecartM7PaletteSet);
         if (Index == 0)
         {
             tilemap = new Mode7Tilemap(Model.MinecartM7TilemapA, tileset, paletteSet);
         }
         else
         {
             tilemap = new Mode7Tilemap(Model.MinecartM7TilemapB, tileset, paletteSet);
         }
         toolStripLabel5.Visible     = true;
         startX.Visible              = true;
         startY.Visible              = true;
         toolStripSeparator6.Visible = true;
         startX.Value = Bits.GetShort(Model.ROM, 0x039670);
         startY.Value = Bits.GetShort(Model.ROM, 0x039679);
         panelScreens.Hide();
     }
     else
     {
         paletteSet = Model.MinecartSSPaletteSet;
         tileset    = new Tileset(Model.MinecartSSTileset, Model.MinecartSSGraphics, paletteSet, 16, 16, TilesetType.SideScrolling);
         bgtileset  = new Tileset(Model.MinecartSSBGTileset, Model.MinecartSSGraphics, paletteSet, 32, 16, TilesetType.SideScrolling);
         tilemap    = new SideTilemap(Model.MinecartSSTilemap, null, tileset, paletteSet);
         //
         if (Index == 2)
         {
             screenWidth.Value = MinecartData.WidthA;
         }
         else
         {
             screenWidth.Value = MinecartData.WidthB;
         }
         toolStripLabel5.Visible     = false;
         startX.Visible              = false;
         startY.Visible              = false;
         toolStripSeparator6.Visible = false;
         InitializeScreens();
         InitializeObjects();
         panelScreens.Show();
     }
     LoadStagePaletteEditor();
     LoadStageGraphicEditor();
     LoadSpritePaletteEditor();
     LoadSpriteGraphicEditor();
     LoadTilesetEditor();
     LoadTilemapEditor();
     //
     railColorKey.Visible = state.Rails && Index < 2;
     tilesetEditor.Rails  = state.Rails && Index < 2;
 }
コード例 #26
0
        public BonusMessage(int index)
        {
            this.Index = index;
            int offset = 0x020000 + Bits.GetShort(Model.ROM, index * 2 + 0x02F967);
            int length = Model.ROM[offset++];

            this.Text = "";
            for (int i = 0; i < length; i++)
            {
                this.Text += Lists.KeystrokesBonus[Model.ROM[offset++]];
            }
        }
コード例 #27
0
        public void Disassemble(byte[] sm, int offset)
        {
            Frame tFrame;

            offset = Bits.GetShort(sm, offset);
            while (offset != 0xFFFF && sm[offset] != 0)
            {
                tFrame = new Frame();
                tFrame.Disassemble(sm, offset);
                frames.Add(tFrame);
                offset += 2;
            }
        }
コード例 #28
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];
            }
        }
コード例 #29
0
        // assemblers
        private void Disassemble()
        {
            int offset = (index * 4) + 0x251800;
            int bank   = (int)(((rom[offset] & 0x0F) << 16) + 0x280000);

            graphicOffset = (int)((Bits.GetShort(rom, offset) & 0xFFF0) + bank); offset += 2;
            paletteOffset = (int)(Bits.GetShort(rom, offset) + 0x250000);
            //
            if (paletteOffset < 0x253000)
            {
                paletteOffset = 0x253000;
            }
            paletteNum = (paletteOffset - 0x253000) / 30;
        }
コード例 #30
0
        private void resetWorldMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("You're about to undo all changes to the current world map. Go ahead with reset?",
                                "LAZY SHELL", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;
            }
            int pointer = Bits.GetShort(Model.ROM, worldMap.Tileset * 2 + 0x3E0014);
            int offset  = 0x3E0000 + pointer + 1;

            Model.WorldMapTilesets[worldMap.Tileset] = Comp.Decompress(Model.ROM, offset, 0x800);
            worldMap = new WorldMap(index);
            RefreshWorldMap();
        }