private void picPicture_MouseMove(object sender, MouseEventArgs e) { DebugEventInfo?result = GetEventAtPosition(e.Location); if (result == null) { ResetTooltip(); UpdateOverlay(e.Location); return; } DebugEventInfo evt = result.Value; Point newPos = new Point(evt.Cycle, evt.Scanline); if (_lastPos == newPos) { return; } Dictionary <string, string> values; if (this.CpuType == CpuType.Gameboy) { values = new Dictionary <string, string>() { { "Type", ResourceHelper.GetEnumText(evt.Type) }, { "Scanline", evt.Scanline.ToString() }, { "Cycle", evt.Cycle.ToString() }, { "PC", "$" + evt.ProgramCounter.ToString("X4") }, }; } else { values = new Dictionary <string, string>() { { "Type", ResourceHelper.GetEnumText(evt.Type) }, { "Scanline", evt.Scanline.ToString() }, { "H-Clock", evt.Cycle.ToString() + " (" + GetCycle(evt.Cycle) + ")" }, { "PC", "$" + evt.ProgramCounter.ToString("X6") }, }; } switch (evt.Type) { case DebugEventType.Register: bool isWrite = evt.Operation.Type == MemoryOperationType.Write || evt.Operation.Type == MemoryOperationType.DmaWrite; bool isDma = evt.Operation.Type == MemoryOperationType.DmaWrite || evt.Operation.Type == MemoryOperationType.DmaRead; CodeLabel label = LabelManager.GetLabel(new AddressInfo() { Address = (int)evt.Operation.Address, Type = SnesMemoryType.CpuMemory }); string registerText = "$" + evt.Operation.Address.ToString("X4"); if (label != null) { registerText = label.Label + " (" + registerText + ")"; } values["Register"] = registerText + (isWrite ? " (Write)" : " (Read)") + (isDma ? " (DMA)" : ""); values["Value"] = "$" + evt.Operation.Value.ToString("X2"); if (isDma && this.CpuType != CpuType.Gameboy) { bool indirectHdma = false; values["Channel"] = (evt.DmaChannel & 0x07).ToString(); if ((evt.DmaChannel & ctrlEventViewerPpuView.HdmaChannelFlag) != 0) { indirectHdma = evt.DmaChannelInfo.HdmaIndirectAddressing; values["Channel"] += indirectHdma ? " (Indirect HDMA)" : " (HDMA)"; values["Line Counter"] = "$" + evt.DmaChannelInfo.HdmaLineCounterAndRepeat.ToString("X2"); } values["Mode"] = evt.DmaChannelInfo.TransferMode.ToString(); int aBusAddress; if (indirectHdma) { aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.TransferSize; } else { aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.SrcAddress; } if (!evt.DmaChannelInfo.InvertDirection) { values["Transfer"] = "$" + aBusAddress.ToString("X4") + " -> $" + evt.DmaChannelInfo.DestAddress.ToString("X2"); } else { values["Transfer"] = "$" + aBusAddress.ToString("X4") + " <- $" + evt.DmaChannelInfo.DestAddress.ToString("X2"); } } break; case DebugEventType.Breakpoint: ReadOnlyCollection <Breakpoint> breakpoints = BreakpointManager.Breakpoints; if (evt.BreakpointId >= 0 && evt.BreakpointId < breakpoints.Count) { Breakpoint bp = breakpoints[evt.BreakpointId]; values["CPU Type"] = ResourceHelper.GetEnumText(bp.CpuType); values["BP Type"] = bp.ToReadableType(); values["BP Addresses"] = bp.GetAddressString(true); if (bp.Condition.Length > 0) { values["BP Condition"] = bp.Condition; } } break; } UpdateOverlay(new Point((int)(evt.Cycle / _xRatio * this.ImageScale), (int)(evt.Scanline * 2 * this.ImageScale))); Form parentForm = this.FindForm(); Point location = parentForm.PointToClient(Control.MousePosition); BaseForm.GetPopupTooltip(parentForm).SetTooltip(location, values); }
private ListViewItem CreateListViewItem(int index) { DebugEventInfo evt = _debugEvents[index]; bool isDma = evt.Operation.Type == MemoryOperationType.DmaWrite || evt.Operation.Type == MemoryOperationType.DmaRead; string details = ""; if (evt.Type == DebugEventType.Breakpoint) { if (evt.BreakpointId >= 0 && evt.BreakpointId < _breakpoints.Count) { Breakpoint bp = _breakpoints[evt.BreakpointId]; details += " Type: " + bp.ToReadableType(); details += " Addresses: " + bp.GetAddressString(true); if (bp.Condition.Length > 0) { details += " Condition: " + bp.Condition; } } } if (isDma) { bool indirectHdma = false; if ((evt.DmaChannel & ctrlEventViewerPpuView.HdmaChannelFlag) != 0) { indirectHdma = evt.DmaChannelInfo.HdmaIndirectAddressing; details += "HDMA #" + (evt.DmaChannel & 0x07).ToString(); details += indirectHdma ? " (indirect)" : ""; } else { details += "DMA #" + (evt.DmaChannel & 0x07).ToString(); } int aBusAddress; if (indirectHdma) { aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.TransferSize; } else { aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.SrcAddress; } if (!evt.DmaChannelInfo.InvertDirection) { details += " - $" + aBusAddress.ToString("X4") + " -> $" + (0x2100 | evt.DmaChannelInfo.DestAddress).ToString("X4"); } else { details += " - $" + aBusAddress.ToString("X4") + " <- $" + (0x2100 | evt.DmaChannelInfo.DestAddress).ToString("X4"); } } return(new ListViewItem(new string[] { evt.ProgramCounter.ToString("X4"), evt.Scanline.ToString(), evt.Cycle.ToString(), evt.Type.ToString(), evt.Type == DebugEventType.Register ? ("$" + evt.Operation.Address.ToString("X4")) : "", evt.Type == DebugEventType.Register ? ("$" + evt.Operation.Value.ToString("X2")) : "", details })); }