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 csaSpellTablePointer; uint csaSpellTable = ImageUtilMagic.FindCSASpellTable("FEditor", out csaSpellTablePointer); if (csaSpellTable == U.NOT_FOUND) { R.ShowWarning("魔法リストの拡張がされていません。\r\nリストの拡張を選択して、魔法リストを増やしてください。"); } 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.FEDITOR_ADV) { return; } { uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount(); uint csaSpellTablePointer; uint csaSpellTable = ImageUtilMagic.FindCSASpellTable("FEditor", out csaSpellTablePointer); if (csaSpellTable == U.NOT_FOUND) { return; } 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); ImageUtilMagicFEditor.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 csaSpellTablePointer; uint csaSpellTable = ImageUtilMagic.FindCSASpellTable("FEditor", out csaSpellTablePointer); 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); } } } }
//魔法拡張は大量の0x00地帯が生れるので、フリー領域と誤認しないように確認する. public static bool IsMagicArea(ref uint addr) { magic_system_enum magicType = SearchMagicSystem(); if (magicType == magic_system_enum.NO) { return(false); } uint csaSpellTable, csaSpellTablePointer; if (magicType == magic_system_enum.CSA_CREATOR) { csaSpellTable = ImageUtilMagic.FindCSASpellTable("SCA_Creator", out csaSpellTablePointer); } else if (magicType == magic_system_enum.FEDITOR_ADV) { csaSpellTable = ImageUtilMagic.FindCSASpellTable("FEditor", out csaSpellTablePointer); } else { Debug.Assert(false); 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); }
private void MagicListExpandsButton_Click(object sender, EventArgs e) { DialogResult dr = R.ShowYesNo("魔法テーブルを拡張してもよろしいですか?"); if (dr != System.Windows.Forms.DialogResult.Yes) { return; } Undo.UndoData undodata = Program.Undo.NewUndoData(this, "expands"); uint csaSpellTablePointer; uint csaSpellTable = ImageUtilMagic.FindCSASpellTable("SCA_Creator", out csaSpellTablePointer); if (csaSpellTablePointer == U.NOT_FOUND) { R.ShowStopError("CSASpellTable Not Found."); return; } //魔法エフェクトテーブルの拡張. uint spellDataCount = ImageUtilMagicFEditor.SpellDataCount(); uint datasize = spellDataCount; InputFormRef.ExpandsArea(this, 254, Program.ROM.RomInfo.magic_effect_pointer(), datasize, FEBuilderGBA.InputFormRef.ExpandsFillOption.NO, 4, undodata); //CSA追加魔法テーブルの拡張 if (U.isSafetyOffset(csaSpellTablePointer)) {//CSA追加魔法テーブルが正しくセットされている場合 datasize = InputFormRef.DataCount; } else {//セットされていなければ初期値は0 datasize = 0; } csaSpellTable = InputFormRef.ExpandsArea(this, 254, csaSpellTablePointer, datasize, FEBuilderGBA.InputFormRef.ExpandsFillOption.NO, 5 * 4, undodata); Program.Undo.Push(undodata); //開きなおす. InputFormRef.ReOpenForm <ImageMagicCSACreatorForm>(); }
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 csaSpellTablePointer; uint csaSpellTable = ImageUtilMagic.FindCSASpellTable("FEditor", out csaSpellTablePointer); 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 csaSpellTablePointer; uint csaSpellTable = ImageUtilMagic.FindCSASpellTable("FEditor", out csaSpellTablePointer); 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); } }); }