Beispiel #1
0
        public static string MakeEAAutoDef(string target_filename, uint freearea, uint org_sp)
        {
            StringBuilder sb = new StringBuilder();

            string target_text = File.ReadAllText(target_filename);

            if (IsInjectHackInstallation(target_text))
            {
                sb.AppendLine("#include \"Extensions/Hack Installation.txt\"");
            }

            if (freearea == U.NOT_FOUND && org_sp == U.NOT_FOUND)
            {
                sb.AppendLine(String.Format("#include \"{0}\"\r\n"
                                            , Path.GetFileName(target_filename)));
                return(sb.ToString());
            }

            EAUtil ea = new EAUtil(target_filename);

            for (int i = 0; i < ea.IfNDefList.Count; i++)
            {
                string ifndef_keyword = ea.IfNDefList[i];
                switch (ifndef_keyword)
                {
                case "FreeSpace":
                    if (freearea != 0)
                    {
                        sb.AppendLine("#define FreeSpace " + U.To0xHexString(freearea));
                    }
                    break;
                }
            }

            sb.AppendLine("#define ItemImage "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.icon_pointer())));
            sb.AppendLine("#define ItemPalette "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.icon_palette_pointer())));
            sb.AppendLine("#define ItemTable "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.item_pointer())));
            sb.AppendLine("#define TextTable "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.text_pointer())));
            sb.AppendLine("#define PortraitTable "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.face_pointer())));
            if (Program.ROM.RomInfo.version() == 8)
            {
                sb.AppendLine("#define SummonUnitTable "
                              + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.summon_unit_pointer())));
                if (PatchUtil.SearchSkillSystem() == PatchUtil.skill_system_enum.SkillSystem)
                {
                    SkillConfigSkillSystemForm.Export(sb);
                }
            }
            sb.AppendLine("#define AI1Table "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.ai1_pointer())));
            sb.AppendLine("#define AI2Table "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.ai2_pointer())));


            UnitActionPointerForm.SupportActionRework(sb);
            if (org_sp != U.NOT_FOUND)
            {
                sb.AppendLine("#define FEBUILDER_EXTRA_ORG " + U.To0xHexString(org_sp));
            }

            Program.ExportFunction.ExportEA(sb);

            if (freearea != 0)
            {
                sb.AppendLine(String.Format("ORG {0}\r\n#include \"{1}\"\r\n"
                                            , U.To0xHexString(freearea), target_filename));
            }
            else
            {
                sb.AppendLine(String.Format("#include \"{0}\"\r\n"
                                            , Path.GetFileName(target_filename)));
            }
            return(sb.ToString());
        }
Beispiel #2
0
        public static string MakeEAAutoDef(string target_filename, uint freearea, uint org_sp, uint org_data, bool isColorzCore)
        {
            StringBuilder sb = new StringBuilder();

            string target_text = File.ReadAllText(target_filename);

            if (IsInjectHackInstallation(target_text))
            {
                sb.AppendLine("#include \"Extensions/Hack Installation.txt\"");
            }

            if (freearea == U.NOT_FOUND && org_sp == U.NOT_FOUND)
            {
                sb.AppendLine(String.Format("#include \"{0}\"\r\n"
                                            , Path.GetFileName(target_filename)));
                return(sb.ToString());
            }

            EAUtil ea = new EAUtil(target_filename);

            for (int i = 0; i < ea.IfNDefList.Count; i++)
            {
                string ifndef_keyword = ea.IfNDefList[i];
                switch (ifndef_keyword)
                {
                case "FreeSpace":
                    if (freearea != 0)
                    {
                        sb.AppendLine("#define FreeSpace " + U.To0xHexString(freearea));
                    }
                    break;
                }
            }

            sb.AppendLine("#define ItemImage "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.icon_pointer)));
            sb.AppendLine("#define ItemPalette "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.icon_palette_pointer)));
            sb.AppendLine("#define ItemTable "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.item_pointer)));
            sb.AppendLine("#define TextTable "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.text_pointer)));
            sb.AppendLine("#define PortraitTable "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.portrait_pointer)));
            if (Program.ROM.RomInfo.version == 8)
            {
                sb.AppendLine("#define SummonUnitTable "
                              + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.summon_unit_pointer)));
                if (PatchUtil.SearchSkillSystem() == PatchUtil.skill_system_enum.SkillSystem)
                {
                    SkillConfigSkillSystemForm.Export(sb, isColorzCore);
                }
            }
            sb.AppendLine("#define AI1Table "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.ai1_pointer)));
            sb.AppendLine("#define AI2Table "
                          + U.To0xHexString(Program.ROM.p32(Program.ROM.RomInfo.ai2_pointer)));


            UnitActionPointerForm.SupportActionRework(sb);
            if (org_sp != U.NOT_FOUND)
            {
                sb.AppendLine("#define FEBUILDER_EXTRA_ORG " + U.To0xHexString(org_sp));
            }
            if (org_data != U.NOT_FOUND)
            {
                sb.AppendLine("#define FEBUILDER_DATA_ORG " + U.To0xHexString(org_data));
            }

            Program.ExportFunction.ExportEA(sb, isColorzCore);

            PatchUtil.skill_system_enum skillsystem = PatchUtil.SearchSkillSystem();
            if (skillsystem == PatchUtil.skill_system_enum.SkillSystem)
            {
                if (sb.ToString().IndexOf("SkillTester") >= 0)
                {
                    sb.AppendLine("#define SKILLSYSTEM_SKILL_TESTER SkillTester");
                }
            }
            //魔法分離パッチ
            MagicSplitUtil.magic_split_enum magic_split = MagicSplitUtil.SearchMagicSplit();
            if (magic_split == MagicSplitUtil.magic_split_enum.FE8NMAGIC)
            {
                sb.AppendLine("#define MAGIC_PATCH");
            }
            else if (magic_split == MagicSplitUtil.magic_split_enum.FE8UMAGIC)
            {
                sb.AppendLine("#define USE_STRMAG_SPLIT");
            }
            else if (magic_split == MagicSplitUtil.magic_split_enum.FE7UMAGIC)
            {
                sb.AppendLine("#define USE_STRMAG_SPLIT");
            }


            if (freearea == 0 || freearea == U.NOT_FOUND)
            {
                sb.AppendLine(String.Format("#include \"{0}\"\r\n"
                                            , Path.GetFileName(target_filename)));
            }
            else
            {
                sb.AppendLine(String.Format("ORG {0}\r\n#include \"{1}\"\r\n"
                                            , U.To0xHexString(freearea), target_filename));
            }
            return(sb.ToString());
        }