Esempio n. 1
0
        // IGenerator
        public void OutputAsmConfig()
        {
            CpuDef cpuDef = Project.CpuDef;
            string cpuStr;

            if (cpuDef.Type == CpuDef.CpuType.Cpu65816)
            {
                cpuStr = "65816";
            }
            else if (cpuDef.Type == CpuDef.CpuType.Cpu65C02)
            {
                cpuStr = "65c02";
            }
            else if (cpuDef.Type == CpuDef.CpuType.CpuW65C02)
            {
                cpuStr = "w65c02";
            }
            else if (cpuDef.Type == CpuDef.CpuType.Cpu6502 && cpuDef.HasUndocumented)
            {
                cpuStr = "6510";
            }
            else
            {
                cpuStr = "6502";
            }

            OutputLine(string.Empty, SourceFormatter.FormatPseudoOp("!cpu"), cpuStr, string.Empty);
        }
Esempio n. 2
0
        private void changeFlagButton_Click(object sender, EventArgs e)
        {
            EditStatusFlags dlg = new EditStatusFlags();

            dlg.FlagValue = WorkProps.EntryFlags;

            CpuDef cpuDef = CpuDef.GetBestMatch(WorkProps.CpuType,
                                                WorkProps.IncludeUndocumentedInstr);

            dlg.HasEmuFlag = cpuDef.HasEmuFlag;

            dlg.ShowDialog();
            if (dlg.DialogResult == DialogResult.OK)
            {
                if (WorkProps.EntryFlags != dlg.FlagValue)
                {
                    // Flags changed.
                    WorkProps.EntryFlags = dlg.FlagValue;
                    mDirty = true;
                    UpdateControls();
                }
            }

            dlg.Dispose();
        }
Esempio n. 3
0
        /// <summary>
        /// Refreshes the project after something of substance has changed.  Some
        /// re-analysis will be done, followed by a complete rebuild of the DisplayList.
        /// </summary>
        /// <param name="reanalysisRequired">Indicates whether reanalysis is required, and
        ///   what level.</param>
        private void RefreshProject(UndoableChange.ReanalysisScope reanalysisRequired)
        {
            Debug.Assert(reanalysisRequired != UndoableChange.ReanalysisScope.None);

            // NOTE: my goal is to arrange things so that reanalysis (data-only, and ideally
            // code+data) takes less than 100ms.  With that response time there's no need for
            // background processing and progress bars.  Since we need to do data-only
            // reanalysis after many common operations, the program becomes unpleasant to
            // use if we miss this goal, and progress bars won't make it less so.

            // Changing the CPU type or whether undocumented instructions are supported
            // invalidates the Formatter's mnemonic cache.  We can change these values
            // through undo/redo, so we need to check it here.
            if (mOutputFormatterCpuDef != mProject.CpuDef)      // reference equality is fine
            {
                Debug.WriteLine("CpuDef has changed, resetting formatter (now " +
                                mProject.CpuDef + ")");
                mOutputFormatter = new Formatter(mFormatterConfig);
                mDisplayList.SetFormatter(mOutputFormatter);
                mDisplayList.SetPseudoOpNames(mPseudoOpNames);
                mOutputFormatterCpuDef = mProject.CpuDef;
            }

#if false
            if (mDisplayList.Count > 200000)
            {
                string prevStatus = toolStripStatusLabel.Text;

                // The Windows stuff can take 50-100ms, potentially longer than the actual
                // work, so don't bother unless the file is very large.
                try {
                    mReanalysisTimer.StartTask("Do Windows stuff");
                    Application.UseWaitCursor = true;
                    Cursor.Current            = Cursors.WaitCursor;
                    toolStripStatusLabel.Text = Res.Strings.STATUS_RECALCULATING;
                    Refresh();      // redraw status label
                    mReanalysisTimer.EndTask("Do Windows stuff");

                    DoRefreshProject(reanalysisRequired);
                } finally {
                    Application.UseWaitCursor = false;
                    toolStripStatusLabel.Text = prevStatus;
                }
            }
            else
            {
                DoRefreshProject(reanalysisRequired);
            }
#endif

            if (FormatDescriptor.DebugCreateCount != 0)
            {
                Debug.WriteLine("FormatDescriptor total=" + FormatDescriptor.DebugCreateCount +
                                " prefab=" + FormatDescriptor.DebugPrefabCount + " (" +
                                (FormatDescriptor.DebugPrefabCount * 100) / FormatDescriptor.DebugCreateCount +
                                "%)");
            }
        }
Esempio n. 4
0
        // IGenerator
        public void OutputAsmConfig()
        {
            CpuDef cpuDef = Project.CpuDef;
            string cpuStr;

            if (cpuDef.Type == CpuDef.CpuType.Cpu65816)
            {
                cpuStr = "65816";
            }
            else if (cpuDef.Type == CpuDef.CpuType.Cpu65C02)
            {
                cpuStr = "65c02";
            }
            else if (cpuDef.Type == CpuDef.CpuType.CpuW65C02)
            {
                cpuStr = "w65c02";
            }
            else if (cpuDef.Type == CpuDef.CpuType.Cpu6502 && cpuDef.HasUndocumented)
            {
                cpuStr = "6502i";
            }
            else
            {
                cpuStr = "6502";
            }

            OutputLine(string.Empty, SourceFormatter.FormatPseudoOp(".cpu"),
                       '\"' + cpuStr + '\"', string.Empty);

            // C64 PETSCII and C64 screen codes are built in.  Define ASCII if we also
            // need that.
            mCurrentEncoding = CharEncoding.Encoding.C64Petscii;

            CheckAsciiFormats(out bool hasAscii, out bool hasHighAscii);
            if (hasHighAscii)
            {
                OutputLine(string.Empty, ".enc", '"' + HIGH_ASCII_ENC_NAME + '"', string.Empty);
                OutputLine(string.Empty, ".cdef", "$20,$7e,$a0", string.Empty);
                mCurrentEncoding = CharEncoding.Encoding.HighAscii;
            }
            if (hasAscii)
            {
                OutputLine(string.Empty, ".enc", '"' + ASCII_ENC_NAME + '"', string.Empty);
                OutputLine(string.Empty, ".cdef", "$20,$7e,$20", string.Empty);
                mCurrentEncoding = CharEncoding.Encoding.Ascii;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Validates the values read from JSON.
        /// </summary>
        /// <returns>True if the inputs are valid and complete.</returns>
        public bool Validate()
        {
            if (string.IsNullOrEmpty(Name))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(GroupName))
            {
                return(false);
            }
            if (CpuDef.GetCpuTypeFromName(Cpu) == CpuDef.CpuType.CpuUnknown)
            {
                return(false);
            }
            if (Speed == 0.0f)
            {
                return(false);
            }
            if (SymbolFiles == null || ExtensionScripts == null || Parameters == null)
            {
                // We don't really need to require these, but it's probably best to
                // insist on fully-formed entries.
                return(false);
            }

            // Disallow file idents that point outside the runtime directory.  I don't think
            // there's any harm in allowing it, but there's currently no value in it either.
            foreach (string str in SymbolFiles)
            {
                if (!str.StartsWith("RT:"))
                {
                    return(false);
                }
            }
            foreach (string str in ExtensionScripts)
            {
                if (!str.StartsWith("RT:"))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 6
0
        private void ChangeFlagButton_Click(object sender, RoutedEventArgs e)
        {
            CpuDef cpuDef = CpuDef.GetBestMatch(mWorkProps.CpuType,
                                                mWorkProps.IncludeUndocumentedInstr, mWorkProps.TwoByteBrk);
            EditStatusFlags dlg =
                new EditStatusFlags(this, mWorkProps.EntryFlags, cpuDef.HasEmuFlag);

            dlg.ShowDialog();
            if (dlg.DialogResult == true)
            {
                if (mWorkProps.EntryFlags != dlg.FlagValue)
                {
                    // Flags changed.
                    mWorkProps.EntryFlags = dlg.FlagValue;
                    UpdateEntryFlags();
                    IsDirty = true;
                }
            }
        }
Esempio n. 7
0
        private void UpdateControls()
        {
            CpuItem item = (CpuItem)cpuSelectionComboBox.SelectedItem;

            if (item == null)
            {
                // initializing
                return;
            }

            // Push current choice to settings.
            AppSettings.Global.SetEnum(AppSettings.INSTCH_MODE, typeof(CpuDef.CpuType),
                                       (int)item.Type);
            AppSettings.Global.SetBool(AppSettings.INSTCH_SHOW_UNDOC, mShowUndocumented);

            // Populate the items source.
            InstructionItems.Clear();
            CpuDef cpuDef = CpuDef.GetBestMatch(item.Type, true, false);

            for (int opc = 0; opc < 256; opc++)
            {
                OpDef op = cpuDef[opc];
                if (!mShowUndocumented && op.IsUndocumented)
                {
                    continue;
                }

                int    opLen       = op.GetLength(StatusFlags.AllIndeterminate);
                string sampleValue = "$12";
                if (op.AddrMode == OpDef.AddressMode.BlockMove)
                {
                    sampleValue = "#$12,#$34";
                }
                else if (opLen == 3)
                {
                    sampleValue = "$1234";
                }
                else if (opLen == 4)
                {
                    sampleValue = "$123456";
                }
                string instrSample = mFormatter.FormatMnemonic(op.Mnemonic,
                                                               OpDef.WidthDisambiguation.None) + " " +
                                     mFormatter.FormatOperand(op, sampleValue, OpDef.WidthDisambiguation.None);


                StringBuilder     flags         = new StringBuilder(8);
                const string      FLAGS         = "NVMXDIZC";
                Asm65.StatusFlags affectedFlags = op.FlagsAffected;
                for (int fl = 0; fl < 8; fl++)
                {
                    if (affectedFlags.GetBit((StatusFlags.FlagBits)(7 - fl)) >= 0)
                    {
                        flags.Append(FLAGS[fl]);
                    }
                    else
                    {
                        flags.Append("-");
                    }
                }

                string         cycles = op.Cycles.ToString();
                OpDef.CycleMod mods   = cpuDef.GetOpCycleMod(opc);
                if (mods != 0)
                {
                    cycles += '+';
                }

                InstructionItems.Add(new InstructionItem(mFormatter.FormatHexValue(opc, 2),
                                                         instrSample, flags.ToString(), cycles,
                                                         mOpDesc.GetShortDescription(op.Mnemonic),
                                                         mOpDesc.GetAddressModeDescription(op.AddrMode),
                                                         op.IsUndocumented));
            }
        }