Ejemplo n.º 1
0
        // IGenerator
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);
            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            if (!Settings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false))
            {
                mLocalizer.LocalPrefix = "@";
                mLocalizer.Analyze();
            }
            mLocalizer.FixOpcodeLabels();

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "acme", V0_96_4, AsmAcme.OPTIONS));
                }

                if (HasNonZeroBankCode())
                {
                    // don't try
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               "ACME can't handle 65816 code that lives outside bank zero");
                    int orgAddr = Project.AddrMap.Get(0);
                    OutputOrgDirective(0, orgAddr);
                    OutputDenseHex(0, Project.FileData.Length, string.Empty, string.Empty);
                }
                else
                {
                    GenCommon.Generate(this, sw, worker);
                }

                if (mInPseudoPcBlock)
                {
                    OutputLine(string.Empty, CLOSE_PSEUDOPC, string.Empty, string.Empty);
                }
            }
            mOutStream = null;

            return(pathNames);
        }
Ejemplo n.º 2
0
        // IGenerator
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string pathName = Path.Combine(mWorkDirectory, mFileNameBase + ASM_FILE_SUFFIX);

            pathNames.Add(pathName);
            string cfgName = Path.Combine(mWorkDirectory, mFileNameBase + CFG_FILE_SUFFIX);

            pathNames.Add(cfgName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);
            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            if (!Settings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false))
            {
                mLocalizer.LocalPrefix            = "@";
                mLocalizer.QuirkVariablesEndScope = true;
                mLocalizer.Analyze();
            }
            mLocalizer.FixOpcodeLabels();

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(cfgName, false, new UTF8Encoding(false))) {
                GenerateLinkerScript(sw);
            }
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    //if (mAsmVersion.IsValid && mAsmVersion <= V2_17) {
                    //    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                    //        string.Format(Properties.Resources.GENERATED_FOR_VERSION,
                    //        "cc65", mAsmVersion.ToString()));
                    //} else {
                    //    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                    //        string.Format(Properties.Resources.GENERATED_FOR_LATEST, "cc65"));
                    //}

                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "cc65", V2_18,
                                             AsmCc65.OPTIONS + " -C " + Path.GetFileName(cfgName)));
                }

                GenCommon.Generate(this, sw, worker);
            }
            mOutStream = null;

            return(pathNames);
        }
Ejemplo n.º 3
0
        // IGenerator
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            SetFormatConfigValues(ref config);

            // Configure delimiters for single-character operands.
            Formatter.DelimiterSet charDelimSet = new Formatter.DelimiterSet();
            charDelimSet.Set(CharEncoding.Encoding.C64Petscii, Formatter.SINGLE_QUOTE_DELIM);
            charDelimSet.Set(CharEncoding.Encoding.C64ScreenCode, Formatter.SINGLE_QUOTE_DELIM);
            charDelimSet.Set(CharEncoding.Encoding.Ascii, Formatter.SINGLE_QUOTE_DELIM);
            charDelimSet.Set(CharEncoding.Encoding.HighAscii,
                             new Formatter.DelimiterDef(string.Empty, '\'', '\'', " | $80"));

            config.mCharDelimiters = charDelimSet;

            SourceFormatter = new Formatter(config);

            string msg = string.Format(Res.Strings.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            if (!Settings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false))
            {
                mLocalizer.LocalPrefix = "_";
                mLocalizer.Analyze();
            }
            mLocalizer.MaskLeadingUnderscores();
            mLocalizer.FixOpcodeLabels();

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    OutputLine(SourceFormatter.FullLineCommentDelimiter +
                               string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
                                             "64tass", V1_53, AsmTass64.OPTIONS));
                }

                GenCommon.Generate(this, sw, worker);

                if (mNeedHereOp)
                {
                    OutputLine(string.Empty, SourceFormatter.FormatPseudoOp(HERE_PSEUDO_OP),
                               string.Empty, string.Empty);
                }
            }
            mOutStream = null;

            return(pathNames);
        }