Example #1
0
        public static void WriteEA(string EA, uint freearea, uint org_sp, Undo.UndoData undodata, SymbolUtil.DebugSymbol storeSymbol)
        {
            string output;
            string symbol;
            bool   r;

            try
            {
                r = MainFormUtil.CompilerEventAssembler(EA, freearea, org_sp, out output, out symbol);
            }
            catch (Win32Exception e)
            {
                r      = false;
                symbol = "";
                output = R._("プロセスを実行できません。\r\nfilename:{0}\r\n{1}", EA, e.ToString());
            }
            if (!r)
            {
                throw new PatchForm.PatchException(output);
            }

            r = Program.ROM.SwapNewROMData(File.ReadAllBytes(output)
                                           , "event_assembler", undodata);
            if (!r)
            {
                throw new PatchForm.PatchException(R.Notify("変更をユーザーが取り消しました"));
            }
            SymbolUtil.ProcessSymbolByComment(EA, symbol, storeSymbol, 0);

            //EAの結果作成したROMを消します. 残すとROMがPATCHディレクトリに残るのでいろいろよろしくない.
            File.Delete(output);
        }
Example #2
0
        static string RunAutoReCompile(string eaFilename)
        {
            if (!File.Exists(eaFilename))
            {
                return("");
            }

            EAUtil ea = new EAUtil(eaFilename);

            foreach (EAUtil.Data d in ea.DataList)
            {
                if (d.Dir == "")
                {
                    continue;
                }

                if (d.DataType == EAUtil.DataEnum.ASM ||
                    d.DataType == EAUtil.DataEnum.LYN)
                {
                    string targetfilename = Path.Combine(d.Dir, d.Name);

                    string sourceCode;
                    if (!IsUpdateSourceCode(targetfilename, out sourceCode))
                    {
                        continue;
                    }

                    MainFormUtil.CompileType compileType = MainFormUtil.CompileType.NONE;
                    if (d.DataType == EAUtil.DataEnum.LYN)
                    {
                        if (targetfilename.IndexOf(".lyn.event") >= 0)
                        {
                            compileType = MainFormUtil.CompileType.CONVERT_LYN;
                        }
                        else
                        {
                            compileType = MainFormUtil.CompileType.KEEP_ELF;
                        }
                    }

                    string error;
                    string symbol;
                    bool   r = MainFormUtil.Compile(sourceCode, out error, out symbol, compileType, checkMissingLabelCheck: true);
                    if (!r)
                    {
                        return(error);
                    }
                    SymbolUtil.ProcessSymbolByComment(sourceCode, symbol, SymbolUtil.DebugSymbol.SaveSymTxt, 0);
                }
            }

            return("");
        }
Example #3
0
 public static void ProcessSymbol(string basefilename, string symbol, SymbolUtil.DebugSymbol storeSymbol, uint baseaddr)
 {
     if (storeSymbol == SymbolUtil.DebugSymbol.None)
     {//シンボルを利用しない
     }
     else if (storeSymbol == SymbolUtil.DebugSymbol.SaveSymTxt)
     {//シンボルをファイルに保存
         SymbolUtil.StoreSymbol(basefilename, symbol);
     }
     else if (storeSymbol == SymbolUtil.DebugSymbol.SaveComment)
     {//シンボルをコメントとして保存
         SymbolUtil.RegistSymbol(basefilename, symbol, baseaddr);
     }
     else if (storeSymbol == SymbolUtil.DebugSymbol.SaveBoth)
     {                                                 //両方
         SymbolUtil.StoreSymbol(basefilename, symbol); //まずは保存.
         SymbolUtil.RegistSymbol(basefilename, symbol, baseaddr);
     }
 }
Example #4
0
        private void RunButton_Click(object sender, EventArgs e)
        {
            this.ComplieBinFilename = "";
            string fullpath = this.SRCFilename.Text;

            if (!File.Exists(fullpath))
            {
                R.ShowStopError(("ファイルがありません。\r\nファイル名:{0}"), fullpath);
                return;
            }

            if (IsMakeLynEventMode() && this.Method.SelectedIndex != 0)
            {
                R.ShowStopError("lyn.eventを作成する時は、ROMに書き込むことはできません。");
                return;
            }

            string result;
            string symbol;
            bool   r = MainFormUtil.Compile(fullpath, out result, out symbol, GetCompileType());

            if (r == false)
            {
                R.ShowStopError("エラーが返されました。\r\n{0}", result);
                return;
            }

            this.ComplieBinFilename = result;
            if (this.Method.SelectedIndex == 0)
            {
                SymbolUtil.ProcessSymbolByComment(fullpath, symbol, GetPlanOfDebugSymbol(), 0);

                //ROMに書き込まない場合、成果物を選択しよう.
                U.SelectFileByExplorer(result, false);
                return;
            }

            uint addr = U.toOffset((uint)this.Address.Value);

            if (!U.CheckZeroAddressWrite(addr))
            {
                return;
            }
            if (!U.isSafetyOffset(addr))
            {
                if (addr != Program.ROM.Data.Length)
                {
                    R.ShowStopError("無効なポインタです。\r\nこの設定は危険です。");
                    return;
                }
            }

            if (!File.Exists(result))
            {
                R.ShowStopError("ファイルがありません。\r\nファイル名:{0}", result);
                return;
            }
            byte[] bin = File.ReadAllBytes(result);
            if (bin.Length <= 0)
            {
                R.ShowStopError("ファイルがゼロバイトです。\r\nファイル名:{0}", result);
                return;
            }
            if (bin.Length > 1024 * 10)
            {
                DialogResult dr = R.ShowNoYes("このファイルは {0}バイトも書き換えますが、本当によろしいですか?\r\n\r\n(ORG指定を間違って利用していませんか?)\r\nファイル名:{1}", bin.Length, result);
                if (dr != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }
            }

            Undo.UndoData undodata = Program.Undo.NewUndoData(this);
            if (this.Method.SelectedIndex == 1)
            {
                uint newlength = addr + (uint)bin.Length;
                if (!U.isSafetyOffset(newlength))
                {
                    Program.ROM.write_resize_data(newlength);
                }
                Program.ROM.write_range(addr, bin, undodata);
                Program.CommentCache.RemoveRange(addr, addr + (uint)bin.Length);
                SymbolUtil.ProcessSymbolByComment(fullpath, symbol, GetPlanOfDebugSymbol(), addr);
            }
            else
            {
                uint freeaddr = U.toOffset((uint)this.FREEAREA.Value);
                if (!U.CheckZeroAddressWrite(freeaddr))
                {
                    return;
                }
                //フックに利用する場所
                undodata.list.Add(new Undo.UndoPostion(addr, 2 * 4));

                uint endaddr = freeaddr + (uint)bin.Length;
                undodata.list.Add(new Undo.UndoPostion(freeaddr, (uint)bin.Length));

                if (endaddr > Program.ROM.Data.Length)
                {//長さが増える場合、ROMを増設する.
                    Program.ROM.write_resize_data(endaddr);
                }
                Program.ROM.write_range(freeaddr, bin);
                uint usereg = GetSaftyRegister();

                byte[] jumpCode = DisassemblerTrumb.MakeInjectJump(addr, freeaddr, usereg);
                Program.ROM.write_range(addr, jumpCode, undodata);

                Program.CommentCache.RemoveRange(freeaddr, freeaddr + (uint)bin.Length);
                SymbolUtil.ProcessSymbolByComment(fullpath, symbol, GetPlanOfDebugSymbol(), freeaddr);
            }
            Program.Undo.Push(undodata);
            InputFormRef.ShowWriteNotifyAnimation(this, addr);

            this.UndoButton.Show();
        }