public void RefreshData()
        {
            if (_sorting)
            {
                return;
            }

            DebugApi.GetMemoryAccessCounts(_memoryType, ref _newCounts);

            DebugState state = DebugApi.GetState();

            _masterClock = state.MasterClock;

            _sorting = true;
            Task.Run(() => {
                switch (_sortType)
                {
                case SortType.Address: break;

                case SortType.Value: break;

                case SortType.Read: Array.Sort(_newCounts, new SortReadComparer()); break;

                case SortType.ReadStamp: Array.Sort(_newCounts, new SortReadStampComparer()); break;

                case SortType.Write: Array.Sort(_newCounts, new SortWriteComparer()); break;

                case SortType.WriteStamp: Array.Sort(_newCounts, new SortWriteStampComparer()); break;

                case SortType.Exec: Array.Sort(_newCounts, new SortExecComparer()); break;

                case SortType.ExecStamp: Array.Sort(_newCounts, new SortExecStampComparer()); break;

                case SortType.UninitRead: Array.Sort(_newCounts, new SortUninitComparer()); break;
                }

                AddressCounters[] counts = _counts;
                _counts    = _newCounts;
                _newCounts = counts;

                this.BeginInvoke((Action)(() => {
                    _sorting = false;
                    lstCounters.BeginUpdate();
                    lstCounters.VirtualListSize = _counts.Length;
                    lstCounters.EndUpdate();
                }));
            });
        }
Example #2
0
        public void Prepare(long firstByteIndex, long lastByteIndex)
        {
            int visibleByteCount = (int)(lastByteIndex - firstByteIndex + 1);

            if (_highlightBreakpoints)
            {
                Breakpoint[] breakpoints = BreakpointManager.Breakpoints.ToArray();
                _breakpointTypes = new BreakpointTypeFlags[visibleByteCount];

                for (int i = 0; i < visibleByteCount; i++)
                {
                    int byteIndex = i + (int)firstByteIndex;
                    foreach (Breakpoint bp in breakpoints)
                    {
                        if (bp.Enabled && bp.Matches((uint)byteIndex, _memoryType, null))
                        {
                            _breakpointTypes[i] = bp.BreakOnExec ? BreakpointTypeFlags.Execute : (bp.BreakOnWrite ? BreakpointTypeFlags.Write : BreakpointTypeFlags.Read);
                            break;
                        }
                    }
                }
            }
            else
            {
                _breakpointTypes = null;
            }

            _counters = DebugApi.GetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType);

            _cdlData = null;
            if (_highlightDataBytes || _highlightCodeBytes)
            {
                switch (_memoryType)
                {
                case SnesMemoryType.CpuMemory:
                case SnesMemoryType.Sa1Memory:
                case SnesMemoryType.Cx4Memory:
                case SnesMemoryType.GsuMemory:
                case SnesMemoryType.GameboyMemory:
                case SnesMemoryType.PrgRom:
                case SnesMemoryType.GbPrgRom:
                    _cdlData = DebugApi.GetCdlData((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType);
                    break;
                }
            }

            _hasLabel = new bool[visibleByteCount];
            if (_highlightLabelledBytes)
            {
                if (_memoryType <= SnesMemoryType.SpcMemory)
                {
                    AddressInfo addr = new AddressInfo();
                    addr.Type = _memoryType;
                    for (long i = 0; i < _hasLabel.Length; i++)
                    {
                        addr.Address = (int)(firstByteIndex + i);
                        _hasLabel[i] = !string.IsNullOrWhiteSpace(LabelManager.GetLabel(addr)?.Label);
                    }
                }
                else if (_memoryType == SnesMemoryType.PrgRom || _memoryType == SnesMemoryType.WorkRam || _memoryType == SnesMemoryType.SaveRam)
                {
                    for (long i = 0; i < _hasLabel.Length; i++)
                    {
                        _hasLabel[i] = !string.IsNullOrWhiteSpace(LabelManager.GetLabel((uint)(firstByteIndex + i), _memoryType)?.Label);
                    }
                }
            }

            _state = DebugApi.GetState();
        }
Example #3
0
        public void Prepare(long firstByteIndex, long lastByteIndex)
        {
            int visibleByteCount = (int)(lastByteIndex - firstByteIndex + 1);

            if (_highlightBreakpoints)
            {
                Breakpoint[] breakpoints = BreakpointManager.Breakpoints.ToArray();
                _breakpointTypes = new BreakpointTypeFlags[visibleByteCount];

                for (int i = 0; i < visibleByteCount; i++)
                {
                    int byteIndex = i + (int)firstByteIndex;
                    foreach (Breakpoint bp in breakpoints)
                    {
                        if (bp.Enabled && bp.Matches((uint)byteIndex, _memoryType))
                        {
                            _breakpointTypes[i] = bp.BreakOnExec ? BreakpointTypeFlags.Execute : (bp.BreakOnWrite ? BreakpointTypeFlags.Write : BreakpointTypeFlags.Read);
                            break;
                        }
                    }
                }
            }
            else
            {
                _breakpointTypes = null;
            }

            _readStamps  = DebugApi.GetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read);
            _writeStamps = DebugApi.GetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write);
            _execStamps  = DebugApi.GetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.ExecOpCode);

            _readCounts  = DebugApi.GetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read);
            _writeCounts = DebugApi.GetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write);
            _execCounts  = DebugApi.GetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.ExecOpCode);

            _cdlData = null;
            if (_highlightDataBytes || _highlightCodeBytes)
            {
                switch (_memoryType)
                {
                case SnesMemoryType.CpuMemory:
                case SnesMemoryType.PrgRom:
                    _cdlData = DebugApi.GetCdlData((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType);
                    break;
                }
            }

            //TODO LABELS

            /*_hasLabel = new bool[visibleByteCount];
             * if(_highlightLabelledBytes) {
             *      if(_memoryType == DebugMemoryType.CpuMemory) {
             *              for(long i = 0; i < _hasLabel.Length; i++) {
             *                      _hasLabel[i] = (
             *                              !string.IsNullOrWhiteSpace(LabelManager.GetLabel((UInt16)(i + firstByteIndex))?.Label) ||
             *                              !string.IsNullOrWhiteSpace(LabelManager.GetLabel((uint)(i + firstByteIndex), AddressType.Register)?.Label)
             *                      );
             *              }
             *      } else if(_memoryType == DebugMemoryType.PrgRom || _memoryType == DebugMemoryType.WorkRam || _memoryType == DebugMemoryType.SaveRam) {
             *              for(long i = 0; i < _hasLabel.Length; i++) {
             *                      _hasLabel[i] = !string.IsNullOrWhiteSpace(LabelManager.GetLabel((uint)(firstByteIndex + i), _memoryType.ToAddressType())?.Label);
             *              }
             *      }
             * }*/

            _state = DebugApi.GetState();
        }