public ImageMagicFEditorForm()
        {
            InitializeComponent();
            U.SetIcon(MagicAnimeExportButton, Properties.Resources.icon_arrow);
            U.SetIcon(MagicAnimeImportButton, Properties.Resources.icon_upload);

            if (ImageUtilMagic.SearchMagicSystem(out MagicEngineBaseAddr, out DimAddr, out NoDimAddr) != ImageUtilMagic.magic_system_enum.FEDITOR_ADV)
            {
                Debug.Assert(false);
                return;
            }

            InputFormRef.markupJumpLabel(LinkInternt);

            U.SelectedIndexSafety(ShowZoomComboBox, 0);
            Dictionary <uint, string> effectDic = U.LoadDicResource(U.ConfigDataFilename("item_anime_effect_"));
            uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount();

            uint csaSpellTable = ImageUtilMagic.GetCSASpellTableAddr();

            if (csaSpellTable == U.NOT_FOUND)
            {
                R.ShowWarning("魔法リストの拡張がされていません。\r\nリストの拡張を選択して、魔法リストを増やしてください。");
                return;
            }

            this.InputFormRef = Init(this, DimAddr, NoDimAddr, spellDataCount, csaSpellTable, effectDic);
            this.InputFormRef.MakeGeneralAddressListContextMenu(true);
            this.InputFormRef.IsMemoryNotContinuous = true; //メモリは連続していないので、警告不能.
            if (this.InputFormRef.DataCount > Program.ROM.RomInfo.magic_effect_original_data_count)
            {                                               //拡張済みなので、拡張ボタンを無効にする
                MagicListExpandsButton.Enabled = false;
            }
        }
        //全データの取得
        public static void MakeAllDataLength(List <Address> list, bool isPointerOnly)
        {
            string       name;
            InputFormRef InputFormRef;
            uint         baseaddr, dimaddr, no_dimaddr;

            if (ImageUtilMagic.SearchMagicSystem(out baseaddr, out dimaddr, out no_dimaddr) != ImageUtilMagic.magic_system_enum.CSA_CREATOR)
            {
                return;
            }

            {
                uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount();
                uint csaSpellTable  = ImageUtilMagic.GetCSASpellTableAddr();
                if (csaSpellTable == U.NOT_FOUND)
                {
                    return;
                }
                uint csaSpellTablePointer = ImageUtilMagic.GetCSASpellTablePointer();

                Dictionary <uint, string> effectDic = new Dictionary <uint, string>();
                InputFormRef = Init(null, dimaddr, no_dimaddr, spellDataCount, csaSpellTable, effectDic);

                name = "Magic";
                FEBuilderGBA.Address.AddAddress(list
                                                , InputFormRef
                                                , name, new uint[] { 0 }
                                                );

                //追加魔法テーブル(結構無駄な構造ですが、仕方ない)
                FEBuilderGBA.Address.AddAddress(list
                                                , csaSpellTable
                                                , InputFormRef.DataCount * 4 * 5
                                                , csaSpellTablePointer
                                                , "Magic_Append_SpellTable"
                                                , FEBuilderGBA.Address.DataTypeEnum.MAGIC_APPEND_SPELLTABLE
                                                );

                uint addr = InputFormRef.BaseAddress;
                for (int i = 0; i < InputFormRef.DataCount; i++, addr += InputFormRef.BlockSize)
                {
                    uint baseaddress = Program.ROM.p32(Program.ROM.RomInfo.magic_effect_pointer);
                    uint csaaddress  = (uint)(csaSpellTable + (20 * i));

                    uint dataaddr = Program.ROM.p32(addr);
                    if (dataaddr == 0)
                    {
                        continue;
                    }
                    if (
                        dataaddr == dimaddr ||
                        dataaddr == no_dimaddr)
                    {
                        name = "Magic:" + U.To0xHexString(i);
                        ImageUtilMagicCSACreator.RecycleOldAnime(ref list, name, isPointerOnly, csaaddress);
                    }
                }
            }
        }
        //エラーチェック
        public static void MakeCheckError(List <FELint.ErrorSt> errors)
        {
            string       name;
            InputFormRef InputFormRef;
            uint         baseaddr, dimaddr, no_dimaddr;

            if (ImageUtilMagic.SearchMagicSystem(out baseaddr, out dimaddr, out no_dimaddr) != ImageUtilMagic.magic_system_enum.FEDITOR_ADV)
            {
                return;
            }

            {
                uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount();
                uint csaSpellTable  = ImageUtilMagic.GetCSASpellTableAddr();
                if (csaSpellTable == U.NOT_FOUND)
                {
                    return;
                }
                Dictionary <uint, string> effectDic = new Dictionary <uint, string>();
                InputFormRef = Init(null, dimaddr, no_dimaddr, spellDataCount, csaSpellTable, effectDic);

                uint addr = InputFormRef.BaseAddress;
                for (int i = 0; i < InputFormRef.DataCount; i++, addr += InputFormRef.BlockSize)
                {
                    uint baseaddress = Program.ROM.p32(Program.ROM.RomInfo.magic_effect_pointer);
                    uint csaaddress  = (uint)(csaSpellTable + (20 * i));

                    uint dataaddr = Program.ROM.p32(addr);
                    if (dataaddr == 0)
                    {
                        continue;
                    }

                    if (U.isSafetyOffset(dataaddr))
                    {
                    }

                    if (
                        dataaddr == dimaddr ||
                        dataaddr == no_dimaddr)
                    {
                        name = "Magic:" + U.To0xHexString(i);

                        ImageUtilMagicFEditor.MakeCheckError(ref errors, name, csaaddress, (uint)i);
                    }
                }
            }
        }
        //変更するアニメデータから、他のアニメーションでも使っているものを除外する
        public static void SubConfilctArea(RecycleAddress ra, uint Now_baseaddress)
        {
            InputFormRef InputFormRef;
            uint         baseaddr, dimaddr, no_dimaddr;

            if (ImageUtilMagic.SearchMagicSystem(out baseaddr, out dimaddr, out no_dimaddr) != ImageUtilMagic.magic_system_enum.FEDITOR_ADV)
            {
                return;
            }

            {
                uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount();
                uint csaSpellTable  = ImageUtilMagic.GetCSASpellTableAddr();
                if (csaSpellTable == U.NOT_FOUND)
                {
                    return;
                }
                Dictionary <uint, string> effectDic = new Dictionary <uint, string>();
                InputFormRef = Init(null, dimaddr, no_dimaddr, spellDataCount, csaSpellTable, effectDic);

                uint addr = InputFormRef.BaseAddress;
                for (int i = 0; i < InputFormRef.DataCount; i++, addr += InputFormRef.BlockSize)
                {
                    uint baseaddress = Program.ROM.p32(Program.ROM.RomInfo.magic_effect_pointer);
                    uint csaaddress  = (uint)(csaSpellTable + (20 * i));

                    uint dataaddr = Program.ROM.p32(addr);
                    if (dataaddr == 0)
                    {
                        continue;
                    }
                    if (csaaddress == Now_baseaddress)
                    {
                        continue;
                    }

                    if (
                        dataaddr == dimaddr ||
                        dataaddr == no_dimaddr)
                    {
                        List <Address> list = new List <Address>();
                        ImageUtilMagicFEditor.RecycleOldAnime(ref list, "", false, csaaddress);
                        ra.SubRecycle(list);
                    }
                }
            }
        }
        public static Dictionary <uint, string> MakeItemEffectAndAppendMagic(Form from)
        {
            InputFormRef InputFormRef;
            Dictionary <uint, string> effectDic = U.LoadDicResource(U.ConfigDataFilename("item_anime_effect_"));

            uint baseaddr, dimaddr, no_dimaddr;

            if (ImageUtilMagic.SearchMagicSystem(out baseaddr, out dimaddr, out no_dimaddr) != ImageUtilMagic.magic_system_enum.FEDITOR_ADV)
            {
                return(effectDic);
            }

            uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount();
            uint csaSpellTable  = ImageUtilMagic.GetCSASpellTableAddr();

            if (csaSpellTable == U.NOT_FOUND)
            {
                return(effectDic);
            }

            InputFormRef = Init(from, dimaddr, no_dimaddr, spellDataCount, csaSpellTable, effectDic);
            List <U.AddrResult> ret = InputFormRef.MakeList();

            for (int i = 0; i < ret.Count; i++)
            {
                U.AddrResult ar = ret[i];
                if (ar.name.IndexOf(" EMPTY") >= 0)
                {
                    continue;
                }

                //処理効率最悪なのだが、 テキストの先頭に16進数でIDが入っている
                uint   no         = U.atoh(ar.name);
                string effectname = R._("追加魔法");
                if (Program.CommentCache.CheckFast(ar.addr))
                {
                    effectname = " " + Program.CommentCache.At(ar.addr);
                }

                effectDic[no] = effectname;
            }

            return(effectDic);
        }
        private void ImageMagicForm_Load(object sender, EventArgs e)
        {
            if (ImageUtilMagic.SearchMagicSystem() != ImageUtilMagic.magic_system_enum.FEDITOR_ADV)
            {
                this.Close();
            }
            uint csaSpellTable = ImageUtilMagic.GetCSASpellTableAddr();

            if (csaSpellTable == U.NOT_FOUND)
            {
                this.MagicListExpandsButton.PerformClick();
            }

            U.AllowDropFilename(this, new string[] { ".TXT" }, (string filename) =>
            {
                using (ImageFormRef.AutoDrag ad = new ImageFormRef.AutoDrag(filename))
                {
                    MagicAnimeImportButton_Click(null, null);
                }
            });
        }
Ejemplo n.º 7
0
        //魔法拡張は大量の0x00地帯が生れるので、フリー領域と誤認しないように確認する.
        public static bool IsMagicArea(ref uint addr)
        {
            magic_system_enum magicType = SearchMagicSystem();

            if (magicType == magic_system_enum.NO)
            {
                return(false);
            }
            uint csaSpellTable = ImageUtilMagic.GetCSASpellTableAddr();

            if (csaSpellTable == U.NOT_FOUND)
            {
                return(false);
            }

            uint effect_table_addr = Program.ROM.p32(Program.ROM.RomInfo.magic_effect_pointer);

            if (!U.isSafetyOffset(effect_table_addr))
            {
                return(false);
            }

            uint end = effect_table_addr + (0x4 * 0xff);

            if (addr >= effect_table_addr && addr < end)
            {
                addr = end;
                return(true);
            }
            end = csaSpellTable + (0x4 * 0x5 * 0xff);
            if (addr >= csaSpellTable && addr < end)
            {
                addr = end;
                return(true);
            }
            return(false);
        }