Exemple #1
0
        // https://stackoverflow.com/a/29679597
        private void UpdateSample()
        {
            // cheeky way of using the same methods for disassembling a different set of data :^)
            while (sampleTable.Count < 0x8000)
            {
                sampleTable.Add(new ROMByte());
            }

            using (MemoryStream mem = new MemoryStream())
                using (StreamWriter sw = new StreamWriter(mem))
                {
                    List <ROMByte>             tempTable = Data.GetTable();
                    Data.ROMMapMode            tempMode = Data.GetROMMapMode();
                    Data.ROMSpeed              tempSpeed = Data.GetROMSpeed();
                    Dictionary <int, string>   tempAlias = Data.GetAllLabels(), tempComment = Data.GetAllComments();
                    LogCreator.FormatStructure tempStructure = LogCreator.structure;
                    Data.Restore(sampleTable, Data.ROMMapMode.LoROM, Data.ROMSpeed.FastROM, sampleAlias, sampleComment);
                    LogCreator.structure = LogCreator.FormatStructure.SingleFile;

                    LogCreator.CreateLog(sw, StreamWriter.Null);

                    Data.Restore(tempTable, tempMode, tempSpeed, tempAlias, tempComment);
                    LogCreator.structure = tempStructure;

                    sw.Flush();
                    mem.Seek(0, SeekOrigin.Begin);

                    textSample.Text = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length);
                }
        }
Exemple #2
0
        private void exportLogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExportDisassembly export = new ExportDisassembly();
            DialogResult      result = export.ShowDialog();

            if (result == DialogResult.OK)
            {
                string file = null, error = null;
                if (LogCreator.structure == LogCreator.FormatStructure.SingleFile)
                {
                    saveLogSingleFile.InitialDirectory = Project.currentFile;
                    result = saveLogSingleFile.ShowDialog();
                    if (result == DialogResult.OK && saveLogSingleFile.FileName != "")
                    {
                        file  = saveLogSingleFile.FileName;
                        error = Path.GetDirectoryName(file) + "/error.txt";
                    }
                }
                else
                {
                    chooseLogFolder.SelectedPath = Path.GetDirectoryName(Project.currentFile);
                    result = chooseLogFolder.ShowDialog();
                    if (result == DialogResult.OK && chooseLogFolder.SelectedPath != "")
                    {
                        file  = chooseLogFolder.SelectedPath + "/main.asm";
                        error = Path.GetDirectoryName(file) + "/error.txt";
                    }
                }

                if (file != null)
                {
                    int errors = 0;
                    using (StreamWriter sw = new StreamWriter(file))
                        using (StreamWriter er = new StreamWriter(error))
                        {
                            errors = LogCreator.CreateLog(sw, er);
                            if (errors > 0)
                            {
                                MessageBox.Show("Disassembly created with errors. See errors.txt for details.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                MessageBox.Show("Disassembly created successfully!", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }
                    if (errors == 0)
                    {
                        File.Delete(error);
                    }
                }
            }
        }
 private bool ValidateFormat()
 {
     return(LogCreator.ValidateFormat(textFormat.Text));
 }