Exemplo n.º 1
0
        private void DisplaySymbolTooltip(Ld65DbgImporter.SymbolInfo symbol, int?arrayIndex = null)
        {
            AddressTypeInfo addressInfo = SymbolProvider.GetSymbolAddressInfo(symbol);

            if (addressInfo != null && addressInfo.Address >= 0)
            {
                int    relativeAddress = InteropEmu.DebugGetRelativeAddress((uint)(addressInfo.Address + (arrayIndex ?? 0)), addressInfo.Type);
                byte   byteValue       = relativeAddress >= 0 ? InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, (UInt32)relativeAddress) : (byte)0;
                UInt16 wordValue       = relativeAddress >= 0 ? (UInt16)(byteValue | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, (UInt32)relativeAddress + 1) << 8)) : (UInt16)0;

                var values = new Dictionary <string, string>()
                {
                    { "Symbol", symbol.Name + (arrayIndex != null ? $"+{arrayIndex.Value}" : "") }
                };

                if (relativeAddress >= 0)
                {
                    values["CPU Address"] = "$" + relativeAddress.ToString("X4");
                }
                else
                {
                    values["CPU Address"] = "<out of scope>";
                }

                if (addressInfo.Type == AddressType.PrgRom)
                {
                    values["PRG Offset"] = "$" + (addressInfo.Address + (arrayIndex ?? 0)).ToString("X4");
                }

                values["Value"] = (relativeAddress >= 0 ? $"${byteValue.ToString("X2")} (byte){Environment.NewLine}${wordValue.ToString("X4")} (word)" : "n/a");

                ShowTooltip(symbol.Name, values, -1, addressInfo);
            }
            else
            {
                var values = new Dictionary <string, string>()
                {
                    { "Symbol", symbol.Name },
                    { "Constant", symbol.Address.HasValue ? ("$" + symbol.Address.Value.ToString("X2")) : "<unknown>" }
                };
                ShowTooltip(symbol.Name, values, -1, addressInfo);
            }
        }
Exemplo n.º 2
0
        private void DisplaySymbolTooltip(Ld65DbgImporter.SymbolInfo symbol)
        {
            int    relativeAddress = symbol.Address.HasValue ? symbol.Address.Value : -1;
            byte   byteValue       = relativeAddress >= 0 ? InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, (UInt32)relativeAddress) : (byte)0;
            UInt16 wordValue       = relativeAddress >= 0 ? (UInt16)(byteValue | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, (UInt32)relativeAddress + 1) << 8)) : (UInt16)0;

            AddressTypeInfo?addressInfo = SymbolProvider.GetSymbolAddressInfo(symbol);

            if (addressInfo != null)
            {
                var values = new Dictionary <string, string>()
                {
                    { "Symbol", symbol.Name }
                };

                if (relativeAddress >= 0)
                {
                    values["CPU Address"] = "$" + relativeAddress.ToString("X4");
                }
                ;

                if (addressInfo.Value.Type == AddressType.PrgRom)
                {
                    values["PRG Offset"] = "$" + addressInfo.Value.Address.ToString("X4");
                }

                values["Value"] = (relativeAddress >= 0 ? $"${byteValue.ToString("X2")} (byte){Environment.NewLine}${wordValue.ToString("X4")} (word)" : "n/a");

                ShowTooltip(symbol.Name, values, -1, addressInfo);
            }
            else
            {
                var values = new Dictionary <string, string>()
                {
                    { "Symbol", symbol.Name },
                    { "Constant", "$" + relativeAddress.ToString("X2") }
                };
                ShowTooltip(symbol.Name, values, -1, addressInfo);
            }
        }
Exemplo n.º 3
0
        public void ProcessMouseMove(Point location)
        {
            if (_previousLocation != location)
            {
                bool closeExistingPopup = true;

                _previousLocation = location;

                string word = _codeViewer.GetWordUnderLocation(location);
                if (word.StartsWith("$"))
                {
                    try {
                        UInt32 address = UInt32.Parse(word.Substring(1), NumberStyles.AllowHexSpecifier);

                        AddressTypeInfo info = new AddressTypeInfo();
                        InteropEmu.DebugGetAbsoluteAddressAndType(address, info);

                        if (info.Address >= 0)
                        {
                            CodeLabel label = LabelManager.GetLabel((UInt32)info.Address, info.Type);
                            if (label == null)
                            {
                                DisplayAddressTooltip(word, address);
                                closeExistingPopup = false;
                            }
                            else
                            {
                                DisplayLabelTooltip(word, label, 0);
                                closeExistingPopup = false;
                            }
                        }
                        else
                        {
                            DisplayAddressTooltip(word, address);
                            closeExistingPopup = false;
                        }
                    } catch { }
                }
                else
                {
                    Match arrayMatch = LabelArrayFormat.Match(word);
                    int?  arrayIndex = null;
                    if (arrayMatch.Success)
                    {
                        word       = arrayMatch.Groups[1].Value;
                        arrayIndex = Int32.Parse(arrayMatch.Groups[2].Value);
                    }

                    int address = _codeViewer.GetLineNumberAtPosition(location.Y);
                    if (SymbolProvider != null)
                    {
                        int rangeStart, rangeEnd;
                        if (_codeViewer.GetNoteRangeAtLocation(location.Y, out rangeStart, out rangeEnd))
                        {
                            Ld65DbgImporter.SymbolInfo symbol = SymbolProvider.GetSymbol(word, rangeStart, rangeEnd);
                            if (symbol != null)
                            {
                                DisplaySymbolTooltip(symbol, arrayIndex);
                                return;
                            }
                        }
                    }
                    else
                    {
                        CodeLabel label = LabelManager.GetLabel(word);
                        if (label != null)
                        {
                            DisplayLabelTooltip(word, label, arrayIndex);
                            return;
                        }
                    }

                    if (ConfigManager.Config.DebugInfo.ShowOpCodeTooltips && frmOpCodeTooltip.IsOpCode(word))
                    {
                        ShowTooltip(word, null, address, new AddressTypeInfo()
                        {
                            Address = address, Type = AddressType.Register
                        });
                        closeExistingPopup = false;
                    }
                }

                if (closeExistingPopup)
                {
                    this.Close();
                }
            }
        }
Exemplo n.º 4
0
 public void FindAllOccurrences(Ld65DbgImporter.SymbolInfo symbol)
 {
     FindAllOccurrences(symbol.Name, true, true);
 }