Пример #1
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;
        }
        // functions
        private void Initialize()
        {
            ProgressBar pBar = new ProgressBar(Model.ROM, "CALCULATING...", 428);

            pBar.Show();
            int          bank, index, size, bankIndex;
            int          offset;
            Color        bg;
            ListViewItem item;

            bank      = 0x160000; // Set bank pointer
            index     = 0;        // Set initial index for this bank
            bankIndex = 0;
            offset    = 0x00DA;   // Set initial offset for this bank
            bg        = Color.White;
            for (; index < 109; index++, bankIndex++)
            {
                size = Comp.Compress(Model.Tilemaps[index], null);
                if (offset + size > 0xFFFF) // Do we pass the bounds of this bank?
                {
                    bg = Color.Red;
                }
                item = new ListViewItem(new string[]
                {
                    index.ToString(),
                    (bank >> 16).ToString("X2"),
                    (bank + (bankIndex * 2)).ToString("X2"),
                    (bank + offset).ToString("X6"),
                    size.ToString("X"),
                    (0xFFFF - (offset + size + 1)).ToString("X"),
                });
                item.BackColor = bg;
                tilemapListView.Items.Add(item);
                pBar.PerformStep("TILE MAP #" + index.ToString("d3"));
                offset++;
                offset += size;
            }
            bank      = 0x170000; // Set bank pointer
            index     = 109;      // Set initial index for this bank
            bankIndex = 0;
            offset    = 0x006C;   // Set initial offset for this bank
            bg        = Color.FromArgb(240, 240, 240);
            for (; index < 163; index++, bankIndex++)
            {
                size = Comp.Compress(Model.Tilemaps[index], null);
                if (offset + size > 0xFFFF) // Do we pass the bounds of this bank?
                {
                    bg = Color.Red;
                }
                item = new ListViewItem(new string[]
                {
                    index.ToString(),
                    (bank >> 16).ToString("X2"),
                    (bank + (bankIndex * 2)).ToString("X2"),
                    (bank + offset).ToString("X6"),
                    size.ToString("X"),
                    (0xFFFF - (offset + size + 1)).ToString("X"),
                });
                item.BackColor = bg;
                tilemapListView.Items.Add(item);
                pBar.PerformStep("TILE MAP #" + index.ToString("d3"));
                offset++;
                offset += size;
            }
            bank      = 0x180000; // Set bank pointer
            index     = 163;      // Set initial index for this bank
            bankIndex = 0;
            offset    = 0x0070;   // Set initial offset for this bank
            bg        = Color.FromArgb(224, 224, 224);
            for (; index < 219; index++, bankIndex++)
            {
                size = Comp.Compress(Model.Tilemaps[index], null);
                if (offset + size > 0xFFFF) // Do we pass the bounds of this bank?
                {
                    bg = Color.Red;
                }
                item = new ListViewItem(new string[]
                {
                    index.ToString(),
                    (bank >> 16).ToString("X2"),
                    (bank + (bankIndex * 2)).ToString("X2"),
                    (bank + offset).ToString("X6"),
                    size.ToString("X"),
                    (0xFFFF - (offset + size + 1)).ToString("X"),
                });
                item.BackColor = bg;
                tilemapListView.Items.Add(item);
                pBar.PerformStep("TILE MAP #" + index.ToString("d3"));
                offset++;
                offset += size;
            }
            bank      = 0x190000; // Set bank pointer
            index     = 219;      // Set initial index for this bank
            bankIndex = 0;
            offset    = 0x0070;   // Set initial offset for this bank
            bg        = Color.FromArgb(240, 240, 240);
            for (; index < 275; index++, bankIndex++)
            {
                size = Comp.Compress(Model.Tilemaps[index], null);
                if (offset + size > 0xFFFF) // Do we pass the bounds of this bank?
                {
                    bg = Color.Red;
                }
                item = new ListViewItem(new string[]
                {
                    index.ToString(),
                    (bank >> 16).ToString("X2"),
                    (bank + (bankIndex * 2)).ToString("X2"),
                    (bank + offset).ToString("X6"),
                    size.ToString("X"),
                    (0xFFFF - (offset + size + 1)).ToString("X"),
                });
                item.BackColor = bg;
                tilemapListView.Items.Add(item);
                pBar.PerformStep("TILE MAP #" + index.ToString("d3"));
                offset++;
                offset += size;
            }
            bank      = 0x1A0000; // Set bank pointer
            index     = 275;      // Set initial index for this bank
            bankIndex = 0;
            offset    = 0x0044;   // Set initial offset for this bank
            bg        = Color.FromArgb(255, 255, 255);
            for (; index < 309; index++, bankIndex++)
            {
                size = Comp.Compress(Model.Tilemaps[index], null);
                if (offset + size > 0xFFFF) // Do we pass the bounds of this bank?
                {
                    bg = Color.Red;
                }
                item = new ListViewItem(new string[]
                {
                    index.ToString(),
                    (bank >> 16).ToString("X2"),
                    (bank + (bankIndex * 2)).ToString("X2"),
                    (bank + offset).ToString("X6"),
                    size.ToString("X"),
                    (0xFFFF - (offset + size + 1)).ToString("X"),
                });
                item.BackColor = bg;
                tilemapListView.Items.Add(item);
                pBar.PerformStep("TILE MAP #" + index.ToString("d3"));
                offset++;
                offset += size;
            }

            /****PHYSICAL MAPS****/
            bank      = 0x1B0000; // Set bank pointer
            index     = 0;        // Set initial index for this bank
            bankIndex = 0;
            offset    = 0x00A0;   // Set initial offset for this bank
            bg        = Color.White;
            for (; index < 80; index++, bankIndex++)
            {
                size = Comp.Compress(Model.SolidityMaps[index], null);
                if (offset + size > 0xFFFF) // Do we pass the bounds of this bank?
                {
                    bg = Color.Red;
                }
                item = new ListViewItem(new string[]
                {
                    index.ToString(),
                    (bank >> 16).ToString("X2"),
                    (bank + (bankIndex * 2)).ToString("X2"),
                    (bank + offset).ToString("X6"),
                    size.ToString("X"),
                    (0xFFFF - (offset + size + 1)).ToString("X"),
                });
                item.BackColor = bg;
                soliditymapListView.Items.Add(item);
                pBar.PerformStep("SOLIDITY MAP #" + index.ToString("d3"));
                offset++;
                offset += size;
            }
            bank      = 0x1C0000; // Set bank pointer
            index     = 80;       // Set initial index for this bank
            bankIndex = 0;
            offset    = 0x0050;   // Set initial offset for this bank
            bg        = Color.FromArgb(240, 240, 240);
            for (; index < 120; index++, bankIndex++)
            {
                size = Comp.Compress(Model.SolidityMaps[index], null);
                if (offset + size > 0x7FFF) // Do we pass the bounds of this bank?
                {
                    bg = Color.Red;
                }
                item = new ListViewItem(new string[]
                {
                    index.ToString(),
                    (bank >> 16).ToString("X2"),
                    (bank + (bankIndex * 2)).ToString("X2"),
                    (bank + offset).ToString("X6"),
                    size.ToString("X"),
                    (0xFFFF - (offset + size + 1)).ToString("X"),
                });
                item.BackColor = bg;
                soliditymapListView.Items.Add(item);
                pBar.PerformStep("SOLIDITY MAP #" + index.ToString("d3"));
                offset++;
                offset += size;
            }
            pBar.Close();
        }