Exemple #1
0
        private void File_Assemble_Click(object sender, EventArgs e)
        {
            OpenFileDialog openWindow = new OpenFileDialog();

            openWindow.RestoreDirectory = true;
            openWindow.Multiselect      = false;
            openWindow.FilterIndex      = 1;
            openWindow.Filter           =
                "Text file (*.event)|*.event|" +
                "All files (*.*)|*.*";

            string filepath = "";

            if (openWindow.ShowDialog() == DialogResult.OK)
            {
                filepath = openWindow.FileName;
                if (filepath == null || !File.Exists(filepath))
                {
                    throw new Exception("The given filepath is invalid.");
                }
            }
            else
            {
                return;
            }

            Core.SuspendUpdate();

            EA_Log     log    = new EA_Log();
            ROM_Stream stream = new ROM_Stream(this);

            using (TextReader file = (TextReader)File.OpenText(filepath))
                using (BinaryWriter output = new BinaryWriter(stream))
                {
                    stream.Description = "EventAssembler [" + Entry_ArrayBox.Text + "]";
                    EA.Program.Assemble(Language, file, output, log);
                    if (log.ErrorCount == 0)
                    {
                        stream.WriteToROM(Tools_ManageSpace.Checked);
                    }
                    log.PrintAll();
                }

            Core.ResumeUpdate();
            Core.PerformUpdate();
        }
Exemple #2
0
        private void File_Assemble_CurrentText_Click(object sender, EventArgs e)
        {
            Core.SuspendUpdate();

            string     code   = Core_GetAllArrayDefines() + Event_CodeBox.Text;
            EA_Log     log    = new EA_Log();
            ROM_Stream stream = new ROM_Stream(this);

            using (TextReader text = new StringReader(code))
                using (BinaryWriter output = new BinaryWriter(stream))
                {
                    stream.Description = "EventAssembler [" + Entry_ArrayBox.Text + "]";
                    EA.Program.Assemble(Language, text, output, log);
                    if (log.ErrorCount == 0)
                    {
                        stream.WriteToROM(Tools_ManageSpace.Checked);
                    }
                    log.PrintAll();
                }

            Core.ResumeUpdate();
            Core.PerformUpdate();
        }