Ejemplo n.º 1
0
        private void ExportToBASIC(Types.FileInfo fileToExport, C64Models.BASIC.Dialect Dialect)
        {
            RetroDevStudio.Types.FileInfo fileInfo = null;

            if (m_Media != null)
            {
                fileInfo = m_Media.LoadFile(fileToExport.Filename);
            }
            if (fileInfo != null)
            {
                if (fileInfo.Data.Length >= 2)
                {
                    //if ( startAddress == 0x0801 )
                    {
                        // can only load from that address

                        List <string> lines;

                        // trunc load address
                        var parser = new Parser.BasicFileParser(new Parser.BasicFileParser.ParserSettings());
                        parser.SetBasicDialect(Dialect);
                        if (parser.Disassemble(fileInfo.Data.SubBuffer(2), out lines))
                        {
                            var document = new SourceBasicEx(Core);
                            document.ShowHint = DockState.Document;

                            document.Core = Core;
                            document.Show(Core.MainForm.panelMain);
                            document.SetBASICDialect(Dialect);

                            StringBuilder sb = new StringBuilder();
                            foreach (string line in lines)
                            {
                                sb.AppendLine(line);
                            }
                            document.FillContent(sb.ToString(), false);
                        }
                    }
                }
            }
        }