public void RefreshData() { if (_sorting) { return; } InteropEmu.DebugGetMemoryAccessCounts(_memoryType, ref _counts); DebugState state = new DebugState(); InteropEmu.DebugGetState(ref state); _cycleCount = state.CPU.CycleCount; _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(); })); }); }
public void Prepare(long firstByteIndex, long lastByteIndex) { int visibleByteCount = (int)(lastByteIndex - firstByteIndex + 1); if (_highlightBreakpoints) { Breakpoint[] breakpoints = BreakpointManager.Breakpoints.ToArray(); _breakpointTypes = new BreakpointType[visibleByteCount]; for (int i = 0; i < visibleByteCount; i++) { int byteIndex = i + (int)firstByteIndex; foreach (Breakpoint bp in breakpoints) { if (bp.Enabled && !bp.IsCpuBreakpoint && bp.Matches(byteIndex, _memoryType)) { _breakpointTypes[i] = bp.BreakOnWrite ? BreakpointType.WriteVram : BreakpointType.ReadVram; break; } } } } else { _breakpointTypes = null; } InteropEmu.DebugGetState(ref _state); _readStamps = InteropEmu.DebugGetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read); _writeStamps = InteropEmu.DebugGetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write); _readCounts = InteropEmu.DebugGetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read); _writeCounts = InteropEmu.DebugGetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write); if (_memoryType == DebugMemoryType.ChrRom && (_highlightDrawnBytes || _highlightReadBytes)) { _cdlData = InteropEmu.DebugGetCdlData((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType); } else { _cdlData = null; } }
public void Prepare(long firstByteIndex, long lastByteIndex) { int visibleByteCount = (int)(lastByteIndex - firstByteIndex + 1); if (_highlightBreakpoints) { Breakpoint[] breakpoints = BreakpointManager.Breakpoints.ToArray(); _breakpointTypes = new BreakpointType[visibleByteCount]; for (int i = 0; i < visibleByteCount; i++) { int byteIndex = i + (int)firstByteIndex; foreach (Breakpoint bp in breakpoints) { if (bp.Enabled && bp.IsCpuBreakpoint && bp.Matches(byteIndex, _memoryType)) { _breakpointTypes[i] = bp.BreakOnExec ? BreakpointType.Execute : (bp.BreakOnWrite ? BreakpointType.WriteRam : BreakpointType.ReadRam); break; } } } } else { _breakpointTypes = null; } _readStamps = InteropEmu.DebugGetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read); _writeStamps = InteropEmu.DebugGetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write); _execStamps = InteropEmu.DebugGetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Exec); if (_memoryType == DebugMemoryType.CpuMemory) { _freezeState = InteropEmu.DebugGetFreezeState((UInt16)firstByteIndex, (UInt16)visibleByteCount); } _readCounts = InteropEmu.DebugGetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read); _writeCounts = InteropEmu.DebugGetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write); _execCounts = InteropEmu.DebugGetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Exec); _cdlData = null; if (_highlightDmcDataBytes || _highlightDataBytes || _highlightCodeBytes) { switch (_memoryType) { case DebugMemoryType.ChrRom: case DebugMemoryType.PpuMemory: case DebugMemoryType.CpuMemory: case DebugMemoryType.PrgRom: _cdlData = InteropEmu.DebugGetCdlData((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType); break; } } _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); } } } InteropEmu.DebugGetState(ref _state); }
public void RefreshData() { int[] readCounts = InteropEmu.DebugGetMemoryAccessCounts(_memoryType, MemoryOperationType.Read, false); int[] writeCounts = InteropEmu.DebugGetMemoryAccessCounts(_memoryType, MemoryOperationType.Write, false); int[] execCounts = InteropEmu.DebugGetMemoryAccessCounts(_memoryType, MemoryOperationType.Exec, false); int[] uninitReads = InteropEmu.DebugGetMemoryAccessCounts(_memoryType, MemoryOperationType.Read, true); int[] addresses = new int[readCounts.Length]; string[] content = new string[readCounts.Length]; if (_data == null || _data.Length != readCounts.Length) { _data = new MemoryCountData[readCounts.Length]; for (int i = 0; i < readCounts.Length; i++) { _data[i] = new MemoryCountData(); } } for (int i = 0; i < readCounts.Length; i++) { _data[i].Address = i; _data[i].ReadCount = readCounts[i]; _data[i].WriteCount = writeCounts[i]; _data[i].ExecCount = execCounts[i]; _data[i].UninitRead = uninitReads[i] > 0; } MemoryCountData[] data = new MemoryCountData[readCounts.Length]; Array.Copy(_data, data, readCounts.Length); switch (_sortType) { case SortType.Address: break; case SortType.Read: Array.Sort(data.Select((e) => - e.ReadCount).ToArray <int>(), data); break; case SortType.Write: Array.Sort(data.Select((e) => - e.WriteCount).ToArray <int>(), data); break; case SortType.Exec: Array.Sort(data.Select((e) => - e.ExecCount).ToArray <int>(), data); break; case SortType.UninitRead: Array.Sort(data.Select((e) => e.UninitRead ? -e.ReadCount : (Int32.MaxValue - e.ReadCount)).ToArray <int>(), data); break; } for (int i = 0; i < readCounts.Length; i++) { addresses[i] = data[i].Address; content[i] = data[i].Content; } if (chkHighlightUninitRead.Checked) { ctrlScrollableTextbox.StyleProvider = new LineStyleProvider(new HashSet <int>(data.Where((e) => e.UninitRead).Select((e) => e.Address))); } else { ctrlScrollableTextbox.StyleProvider = null; } ctrlScrollableTextbox.Header = "Read".PadRight(12) + "Write".PadRight(12) + "Execute".PadRight(12); ctrlScrollableTextbox.LineNumbers = addresses; ctrlScrollableTextbox.TextLines = content; }
public void RefreshData() { bool isPpu = ( _memoryType == DebugMemoryType.ChrRom || _memoryType == DebugMemoryType.ChrRam || _memoryType == DebugMemoryType.PaletteMemory || _memoryType == DebugMemoryType.NametableRam ); int[] readCounts = InteropEmu.DebugGetMemoryAccessCounts(_memoryType, MemoryOperationType.Read); int[] writeCounts = InteropEmu.DebugGetMemoryAccessCounts(_memoryType, MemoryOperationType.Write); int[] execCounts = isPpu ? new int[readCounts.Length] : InteropEmu.DebugGetMemoryAccessCounts(_memoryType, MemoryOperationType.Exec); int[] uninitReads = isPpu ? new int[readCounts.Length] : InteropEmu.DebugGetUninitMemoryReads(_memoryType); List <int> addresses = new List <int>(readCounts.Length); List <string> content = new List <string>(readCounts.Length); if (_data == null || _data.Length != readCounts.Length) { _data = new MemoryCountData[readCounts.Length]; for (int i = 0; i < readCounts.Length; i++) { _data[i] = new MemoryCountData(); } } for (int i = 0; i < readCounts.Length; i++) { _data[i].Address = i; _data[i].ReadCount = readCounts[i]; _data[i].WriteCount = writeCounts[i]; _data[i].ExecCount = execCounts[i]; _data[i].UninitRead = uninitReads[i] > 0; _data[i].IsPpu = isPpu; } MemoryCountData[] data = new MemoryCountData[readCounts.Length]; Array.Copy(_data, data, readCounts.Length); switch (_sortType) { case SortType.Address: break; case SortType.Read: Array.Sort(data.Select((e) => - e.ReadCount).ToArray <int>(), data); break; case SortType.Write: Array.Sort(data.Select((e) => - e.WriteCount).ToArray <int>(), data); break; case SortType.Exec: Array.Sort(data.Select((e) => - e.ExecCount).ToArray <int>(), data); break; case SortType.UninitRead: Array.Sort(data.Select((e) => e.UninitRead ? -e.ReadCount : (Int32.MaxValue - e.ReadCount)).ToArray <int>(), data); break; } bool hideUnusedAddresses = chkHideUnusedAddresses.Checked; for (int i = 0; i < readCounts.Length; i++) { if (!hideUnusedAddresses || !data[i].Empty) { addresses.Add(data[i].Address); content.Add(data[i].Content); } } if (chkHighlightUninitRead.Checked) { ctrlScrollableTextbox.StyleProvider = new LineStyleProvider(new HashSet <int>(data.Where((e) => e.UninitRead).Select((e) => e.Address))); } else { ctrlScrollableTextbox.StyleProvider = null; } if (isPpu) { ctrlScrollableTextbox.Header = " " + "Read".PadRight(12) + "Write"; } else { ctrlScrollableTextbox.Header = " " + "Read".PadRight(12) + "Write".PadRight(12) + "Execute"; } ctrlScrollableTextbox.LineNumbers = addresses.ToArray(); ctrlScrollableTextbox.TextLines = content.ToArray(); }
public void Prepare(long firstByteIndex, long lastByteIndex) { int visibleByteCount = (int)(lastByteIndex - firstByteIndex + 1); if (_highlightBreakpoints) { Breakpoint[] breakpoints = BreakpointManager.Breakpoints.ToArray(); _breakpointTypes = new BreakpointType[visibleByteCount]; for (int i = 0; i < visibleByteCount; i++) { int byteIndex = i + (int)firstByteIndex; foreach (Breakpoint bp in breakpoints) { if (bp.Enabled && bp.IsCpuBreakpoint && bp.Matches(byteIndex, _memoryType)) { _breakpointTypes[i] = bp.BreakOnExec ? BreakpointType.Execute : (bp.BreakOnWrite ? BreakpointType.WriteRam : BreakpointType.ReadRam); break; } } } } else { _breakpointTypes = null; } _counts = InteropEmu.DebugGetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType); if (_memoryType == DebugMemoryType.CpuMemory) { _freezeState = InteropEmu.DebugGetFreezeState((UInt16)firstByteIndex, (UInt16)visibleByteCount); } _cdlData = null; if (_highlightDmcDataBytes || _highlightDataBytes || _highlightCodeBytes) { switch (_memoryType) { case DebugMemoryType.ChrRom: case DebugMemoryType.PpuMemory: case DebugMemoryType.CpuMemory: case DebugMemoryType.PrgRom: _cdlData = InteropEmu.DebugGetCdlData((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType); break; } } _hasLabel = new ByteLabelState[visibleByteCount]; if (_highlightLabelledBytes) { if (_memoryType == DebugMemoryType.CpuMemory) { for (long i = 0; i < _hasLabel.Length; i++) { UInt16 addr = (UInt16)(i + firstByteIndex); CodeLabel label = LabelManager.GetLabel(addr); if (label == null) { label = LabelManager.GetLabel(addr, AddressType.Register); } if (label != null && !string.IsNullOrWhiteSpace(label.Label)) { if (label.Length > 1) { int relAddress = label.GetRelativeAddress(); _hasLabel[i] = relAddress == addr ? ByteLabelState.LabelFirstByte : ByteLabelState.LabelExtraByte; } else { _hasLabel[i] = ByteLabelState.LabelFirstByte; } } } } else if (_memoryType == DebugMemoryType.PrgRom || _memoryType == DebugMemoryType.WorkRam || _memoryType == DebugMemoryType.SaveRam) { for (long i = 0; i < _hasLabel.Length; i++) { UInt32 addr = (UInt32)(i + firstByteIndex); CodeLabel label = LabelManager.GetLabel(addr, _memoryType.ToAddressType()); if (label != null && !string.IsNullOrWhiteSpace(label.Label)) { _hasLabel[i] = label.Length == 1 || label.Address == addr ? ByteLabelState.LabelFirstByte : ByteLabelState.LabelExtraByte; } } } } InteropEmu.DebugGetState(ref _state); }